|
@@ -27,16 +27,18 @@ import com.qmth.teachcloud.common.util.Result;
|
|
|
import com.qmth.teachcloud.common.util.ResultUtil;
|
|
|
import com.qmth.teachcloud.common.util.ServletUtil;
|
|
|
import io.swagger.annotations.*;
|
|
|
+import org.apache.commons.io.IOUtils;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.constraints.Max;
|
|
|
import javax.validation.constraints.Min;
|
|
|
+import java.io.BufferedOutputStream;
|
|
|
+import java.io.FileInputStream;
|
|
|
+import java.io.OutputStream;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import java.util.Optional;
|
|
@@ -125,25 +127,38 @@ public class TSyncExamStudentScoreController {
|
|
|
return Objects.nonNull(tbSyncTask) ? ResultUtil.ok(tbSyncTask.getId()) : ResultUtil.error("创建同步推送任务失败");
|
|
|
}
|
|
|
|
|
|
+ @CrossOrigin(maxAge = 3600) //支持跨域
|
|
|
@ApiOperation(value = "成绩动态轨迹图下载")
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = EditResult.class)})
|
|
|
@RequestMapping(value = "/score/download", method = RequestMethod.POST)
|
|
|
@Transactional
|
|
|
- public Result download(@ApiParam(value = "学号", required = true) @RequestParam String studentCode) throws Exception {
|
|
|
+ public void download(@ApiParam(value = "学号", required = true) @RequestParam String studentCode) throws Exception {
|
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
QueryWrapper<TSyncExamStudentScore> tSyncExamStudentScoreQueryWrapper = new QueryWrapper<>();
|
|
|
- tSyncExamStudentScoreQueryWrapper.lambda().eq(TSyncExamStudentScore::getSchoolId, sysUser.getSchoolId())
|
|
|
- .eq(TSyncExamStudentScore::getStudentCode, studentCode);
|
|
|
+ tSyncExamStudentScoreQueryWrapper.lambda().eq(TSyncExamStudentScore::getSchoolId, sysUser.getSchoolId()).eq(TSyncExamStudentScore::getStudentCode, studentCode);
|
|
|
TSyncExamStudentScore tSyncExamStudentScore = tSyncExamStudentScoreService.getOne(tSyncExamStudentScoreQueryWrapper);
|
|
|
- Optional.ofNullable(tSyncExamStudentScore).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("考生不存在"));
|
|
|
- tSyncExamStudentScore = tSyncExamStudentScoreService.createImageTrajectory(tSyncExamStudentScore, ImageTrajectoryEnum.PREVIEW);
|
|
|
boolean update = Objects.isNull(tSyncExamStudentScore.getTrajectoryUrls()) ? true : false;
|
|
|
tSyncExamStudentScore = tSyncExamStudentScoreService.createImageTrajectory(tSyncExamStudentScore, ImageTrajectoryEnum.PREVIEW);
|
|
|
Optional.ofNullable(tSyncExamStudentScore.getTrajectoryUrls()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("资源未获取到,请稍候再试"));
|
|
|
if (update || Objects.isNull(tSyncExamStudentScore.getTrajectoryUrls())) {
|
|
|
tSyncExamStudentScoreService.updateById(tSyncExamStudentScore);
|
|
|
}
|
|
|
- return ResultUtil.ok(new EditResult(tSyncExamStudentScore.getPath()));
|
|
|
+ OutputStream outputStream = null;
|
|
|
+ try {
|
|
|
+ if (Objects.nonNull(tSyncExamStudentScore.getTrajectoryFile())) {
|
|
|
+ HttpServletResponse response = ServletUtil.getResponse();
|
|
|
+ response.setContentType("image/jpeg");
|
|
|
+ outputStream = new BufferedOutputStream(response.getOutputStream());
|
|
|
+ IOUtils.copy(new FileInputStream(tSyncExamStudentScore.getTrajectoryFile()), outputStream);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ if (Objects.nonNull(outputStream)) {
|
|
|
+ outputStream.flush();
|
|
|
+ outputStream.close();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "成绩动态轨迹图一键下载")
|