|
@@ -3,14 +3,14 @@ package com.qmth.distributed.print.api;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import com.qmth.boot.api.annotation.Aac;
|
|
|
-import com.qmth.boot.api.annotation.BOOL;
|
|
|
import com.qmth.boot.api.constant.ApiConstant;
|
|
|
import com.qmth.distributed.print.business.bean.result.EditResult;
|
|
|
import com.qmth.distributed.print.business.bean.result.TSyncExamStudentScoreResult;
|
|
|
+import com.qmth.distributed.print.business.entity.ExamPrintPlan;
|
|
|
import com.qmth.distributed.print.business.entity.TBSyncTask;
|
|
|
import com.qmth.distributed.print.business.entity.TSyncExamStudentScore;
|
|
|
import com.qmth.distributed.print.business.enums.ImageTrajectoryEnum;
|
|
|
+import com.qmth.distributed.print.business.service.ExamPrintPlanService;
|
|
|
import com.qmth.distributed.print.business.service.PrintCommonService;
|
|
|
import com.qmth.distributed.print.business.service.TSyncExamStudentScoreService;
|
|
|
import com.qmth.distributed.print.business.templete.execute.AsyncScoreBatchDownloadService;
|
|
@@ -18,31 +18,26 @@ import com.qmth.distributed.print.business.templete.execute.AsyncScoreExportServ
|
|
|
import com.qmth.distributed.print.business.templete.execute.AsyncScorePushService;
|
|
|
import com.qmth.teachcloud.common.config.DictionaryConfig;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
+import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
import com.qmth.teachcloud.common.entity.TBTask;
|
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
import com.qmth.teachcloud.common.enums.PushTypeEnum;
|
|
|
import com.qmth.teachcloud.common.enums.TaskTypeEnum;
|
|
|
-import com.qmth.teachcloud.common.enums.UploadFileEnum;
|
|
|
-import com.qmth.teachcloud.common.util.FileUtil;
|
|
|
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.*;
|
|
|
|
|
|
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.File;
|
|
|
-import java.io.FileInputStream;
|
|
|
-import java.io.OutputStream;
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.util.*;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -55,7 +50,7 @@ import java.util.*;
|
|
|
@Api(tags = "成绩归档Controller")
|
|
|
@RestController
|
|
|
@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/${prefix.url.sync}")
|
|
|
-@Aac(auth = BOOL.FALSE, strict = BOOL.FALSE)
|
|
|
+//@Aac(auth = BOOL.FALSE, strict = BOOL.FALSE)
|
|
|
@Validated
|
|
|
public class TSyncExamStudentScoreController {
|
|
|
|
|
@@ -77,6 +72,9 @@ public class TSyncExamStudentScoreController {
|
|
|
@Resource
|
|
|
AsyncScoreBatchDownloadService asyncScoreBatchDownloadService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ ExamPrintPlanService examPrintPlanService;
|
|
|
+
|
|
|
@ApiOperation(value = "成绩归档查询列表")
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "成绩查询信息", response = TSyncExamStudentScoreResult.class)})
|
|
|
@RequestMapping(value = "/score/list", method = RequestMethod.POST)
|
|
@@ -118,11 +116,21 @@ public class TSyncExamStudentScoreController {
|
|
|
@ApiOperation(value = "成绩查询同步")
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "同步异步任务信息", response = TBSyncTask.class)})
|
|
|
@RequestMapping(value = "/score/sync", method = RequestMethod.POST)
|
|
|
- public Result sync(@ApiParam(value = "考试id", required = true) @RequestParam String examId,
|
|
|
- @ApiParam(value = "考试编码", required = false) @RequestParam(required = false) String examCode) {
|
|
|
+ public Result sync(@ApiParam(value = "学期id", required = true) @RequestParam String semesterId,
|
|
|
+ @ApiParam(value = "学院id", required = true) @RequestParam String orgId) {
|
|
|
+ SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
+ QueryWrapper<ExamPrintPlan> examPrintPlanQueryWrapper = new QueryWrapper<ExamPrintPlan>();
|
|
|
+ examPrintPlanQueryWrapper.select(" DISTINCT third_relate_id ").eq("school_id", sysUser.getSchoolId())
|
|
|
+ .eq("semester_id", SystemConstant.convertIdToInteger(semesterId))
|
|
|
+ .eq("org_id", SystemConstant.convertIdToInteger(orgId));
|
|
|
+ List<ExamPrintPlan> examPrintPlanList = examPrintPlanService.list(examPrintPlanQueryWrapper);
|
|
|
+ if (Objects.isNull(examPrintPlanList) || examPrintPlanList.size() == 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("此学期学院下未找到需要同步的考试记录");
|
|
|
+ } else if (examPrintPlanList.size() > 1) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("此学期学院下找到了多条考试记录");
|
|
|
+ }
|
|
|
Map<String, Object> map = printCommonService.savePush(PushTypeEnum.SCORE_PUSH);
|
|
|
- map.computeIfAbsent("examId", v -> SystemConstant.convertIdToInteger(examId));
|
|
|
- map.computeIfAbsent("examCode", v -> examCode);
|
|
|
+ map.computeIfAbsent("examId", v -> examPrintPlanList.get(0).getThirdRelateId());
|
|
|
asyncScorePushService.pushTask(map);
|
|
|
TBSyncTask tbSyncTask = Objects.nonNull(map.get(SystemConstant.TB_SYNC_TASK)) ? (TBSyncTask) map.get(SystemConstant.TB_SYNC_TASK) : null;
|
|
|
return Objects.nonNull(tbSyncTask) ? ResultUtil.ok(tbSyncTask.getId()) : ResultUtil.error("创建同步推送任务失败");
|
|
@@ -134,9 +142,9 @@ public class TSyncExamStudentScoreController {
|
|
|
@RequestMapping(value = "/score/download", method = RequestMethod.POST)
|
|
|
@Transactional
|
|
|
public void download(@ApiParam(value = "学号", required = true) @RequestParam String studentCode) throws Exception {
|
|
|
-// SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
+ SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
QueryWrapper<TSyncExamStudentScore> tSyncExamStudentScoreQueryWrapper = new QueryWrapper<>();
|
|
|
- tSyncExamStudentScoreQueryWrapper.lambda().eq(TSyncExamStudentScore::getSchoolId, 2L).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("未找到此考生信息"));
|
|
|
boolean update = Objects.isNull(tSyncExamStudentScore.getTrajectoryUrls()) ? true : false;
|
|
@@ -145,47 +153,7 @@ public class TSyncExamStudentScoreController {
|
|
|
if (update || Objects.isNull(tSyncExamStudentScore.getTrajectoryUrls())) {
|
|
|
tSyncExamStudentScoreService.updateById(tSyncExamStudentScore);
|
|
|
}
|
|
|
- File zipFile = null;
|
|
|
- OutputStream outputStream = null;
|
|
|
- try {
|
|
|
- if (Objects.nonNull(tSyncExamStudentScore.getTrajectoryFileList())) {
|
|
|
- StringJoiner stringJoiner = new StringJoiner("");
|
|
|
- stringJoiner.add(SystemConstant.TEMP_FILES_DIR).add(File.separator);
|
|
|
- LocalDateTime nowTime = LocalDateTime.now();
|
|
|
- StringJoiner dirZipName = new StringJoiner("");
|
|
|
- dirZipName.add(UploadFileEnum.FILE.getTitle()).add(File.separator)
|
|
|
- .add(String.valueOf(nowTime.getYear())).add(File.separator)
|
|
|
- .add(String.format("%02d", nowTime.getMonthValue())).add(File.separator)
|
|
|
- .add(String.format("%02d", nowTime.getDayOfMonth()))
|
|
|
- .add(File.separator).add(SystemConstant.getUuid()).add(SystemConstant.ZIP_PREFIX);
|
|
|
- zipFile = new File(stringJoiner.toString() + dirZipName.toString());
|
|
|
- if (!zipFile.exists()) {
|
|
|
- zipFile.getParentFile().mkdirs();
|
|
|
- zipFile.createNewFile();
|
|
|
- }
|
|
|
- FileUtil.doZip(zipFile, Arrays.asList(tSyncExamStudentScore.getTrajectoryFileList().get(0).getParentFile()));
|
|
|
- HttpServletResponse response = ServletUtil.getResponse();
|
|
|
-// response.setContentType("image/jpeg");
|
|
|
-// outputStream = new BufferedOutputStream(response.getOutputStream());
|
|
|
-// IOUtils.copy(new FileInputStream(zipFile), outputStream);
|
|
|
- response.reset();
|
|
|
- response.setHeader("Content-Disposition", "attachment;fileName=" + zipFile.getName());
|
|
|
- response.addHeader("Content-Length", "" + zipFile.length());
|
|
|
- response.setContentType("application/octet-stream;charset=UTF-8");
|
|
|
- outputStream = new BufferedOutputStream(response.getOutputStream());
|
|
|
- IOUtils.copy(new FileInputStream(zipFile), outputStream);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- if (Objects.nonNull(outputStream)) {
|
|
|
- outputStream.flush();
|
|
|
- outputStream.close();
|
|
|
- }
|
|
|
- if (Objects.nonNull(zipFile)) {
|
|
|
- zipFile.delete();
|
|
|
- }
|
|
|
- }
|
|
|
+ tSyncExamStudentScoreService.createZipFile(tSyncExamStudentScore);
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "成绩动态轨迹图一键下载")
|