|
@@ -297,7 +297,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
CreatePdfCacheUtil.setPaperType(key, paperType);
|
|
|
} else {
|
|
|
// if (StringUtils.isBlank(examDetailCourse.getPaperType())) {
|
|
|
- paperType = createPdfUtil.getPaperType(examPrintPlan.getDrawRule(), examTaskDetail, key);
|
|
|
+ paperType = createPdfUtil.getPaperType(examPrintPlan.getDrawRule(), examTaskDetail, key);
|
|
|
// } else {
|
|
|
// paperType = examDetailCourse.getPaperType();
|
|
|
// }
|
|
@@ -1145,7 +1145,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
File zipFile = null;
|
|
|
String zipLocalRootPath = null;
|
|
|
try {
|
|
|
- int count = 0;
|
|
|
TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
|
|
|
Long time = System.currentTimeMillis();
|
|
|
boolean oss = dictionaryConfig.sysDomain().isOss();
|
|
@@ -1162,123 +1161,99 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
|
|
|
// 跟文件路径
|
|
|
Long[] ids = (Long[]) map.get("ids");
|
|
|
+ int count = 0;
|
|
|
for (Long id : ids) {
|
|
|
ExamTask examTask = examTaskService.getById(id);
|
|
|
if (Objects.isNull(examTask)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("未找到命题任务");
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s]的命题任务不存在", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber()));
|
|
|
}
|
|
|
String examTaskSign = examTask.getCourseName() + SystemConstant.HYPHEN + examTask.getPaperNumber();
|
|
|
String firstPath = zipLocalRootPath + File.separator + examTaskSign;
|
|
|
- ReviewSampleDto reviewSampleDto = examTaskService.findReviewSampleInfoByExamTaskId(id);
|
|
|
+ ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamTaskId(id);
|
|
|
+ if (examTaskDetail == null) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s]的" + ExceptionResultEnum.EXAM_TASK_NOT_SUBMIT.getMessage(), examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber()));
|
|
|
+ }
|
|
|
|
|
|
// 收集处理试卷和题卡
|
|
|
- List<ExamPaperInfoDto> paperInfoDtoList = JSONObject.parseArray(reviewSampleDto.getPaperAttachmentIds(), ExamPaperInfoDto.class);
|
|
|
+ List<ExamPaperInfoDto> paperInfoDtoList = JSONObject.parseArray(examTaskDetail.getPaperAttachmentIds(), ExamPaperInfoDto.class);
|
|
|
if (Objects.isNull(paperInfoDtoList)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("试卷信息不存在");
|
|
|
- }
|
|
|
- Set<Long> attPaperIds = new HashSet<>();
|
|
|
- List<ExamCardDto> examCardDtoList = new ArrayList<>();
|
|
|
- for (ExamPaperInfoDto paperInfo : paperInfoDtoList) {
|
|
|
- Long attachmentId = paperInfo.getAttachmentId();
|
|
|
- Long cardId = paperInfo.getCardId();
|
|
|
- String paperType = paperInfo.getName();
|
|
|
- if (SystemConstant.longNotNull(attachmentId)) {
|
|
|
- attPaperIds.add(attachmentId);
|
|
|
- }
|
|
|
- if (SystemConstant.longNotNull(cardId)) {
|
|
|
- ExamCardDto examCardDto = new ExamCardDto();
|
|
|
- examCardDto.setCardId(cardId);
|
|
|
- examCardDto.setPaperType(paperType);
|
|
|
- examCardDtoList.add(examCardDto);
|
|
|
- }
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s]的命题任务未上传试卷或题卡", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber()));
|
|
|
}
|
|
|
- if (attPaperIds.size() > 0) {
|
|
|
- List<BasicAttachment> paperAttachmentList = basicAttachmentService.listByIds(attPaperIds);
|
|
|
- for (BasicAttachment paperAttachment : paperAttachmentList) {
|
|
|
+
|
|
|
+ for (ExamPaperInfoDto examPaperInfoDto : paperInfoDtoList) {
|
|
|
+ // 下载试卷
|
|
|
+ if (examPaperInfoDto.getAttachmentId() != null) {
|
|
|
+ BasicAttachment paperAttachment = basicAttachmentService.getById(examPaperInfoDto.getAttachmentId());
|
|
|
JSONObject jsonObject = JSONObject.parseObject(paperAttachment.getPath());
|
|
|
UploadFileEnum uploadFileEnum = UploadFileEnum.valueOf((String) jsonObject.get(SystemConstant.UPLOAD_TYPE));
|
|
|
- String paperPath = firstPath + File.separator + "试卷" + File.separator + paperAttachment.getName() + paperAttachment.getType();
|
|
|
+ String paperPath = firstPath + File.separator + "试卷" + File.separator + examPaperInfoDto.getName() + "-" + paperAttachment.getName() + paperAttachment.getType();
|
|
|
if (oss || (!oss && dictionaryConfig.fssPrivateDomain().getConfig().startsWith(SystemConstant.START_PARENT))) {
|
|
|
fileStoreUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), paperPath, uploadFileEnum.getFssType());
|
|
|
} else {
|
|
|
FileUtil.copyFile(jsonObject.getString(SystemConstant.PATH), paperPath);
|
|
|
}
|
|
|
- count++;
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- // 处理审核样品
|
|
|
- List<Map> confirmInfo = JSONObject.parseArray(reviewSampleDto.getPaperConfirmAttachmentIds(), Map.class);
|
|
|
- Set<Long> attConfirmIds = new HashSet<>();
|
|
|
- for (Map confirmMap : confirmInfo) {
|
|
|
- if (Objects.isNull(confirmMap.get("attachmentId"))) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("未找到附件id");
|
|
|
- }
|
|
|
- Long attachmentId = Long.valueOf(String.valueOf(confirmMap.get("attachmentId")));
|
|
|
- attConfirmIds.add(attachmentId);
|
|
|
- }
|
|
|
- if (attConfirmIds.size() > 0) {
|
|
|
- List<BasicAttachment> confirmAttachmentList = basicAttachmentService.listByIds(attConfirmIds);
|
|
|
- for (BasicAttachment confirmAttachment : confirmAttachmentList) {
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(confirmAttachment.getPath());
|
|
|
- UploadFileEnum uploadFileEnum = UploadFileEnum.valueOf((String) jsonObject.get(SystemConstant.UPLOAD_TYPE));
|
|
|
- String confirmPath = firstPath + File.separator + "审核样本" + File.separator + confirmAttachment.getName() + confirmAttachment.getType();
|
|
|
- if (oss || (!oss && dictionaryConfig.fssPrivateDomain().getConfig().startsWith(SystemConstant.START_PARENT))) {
|
|
|
- fileStoreUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), confirmPath, uploadFileEnum.getFssType());
|
|
|
+ // 下载题卡
|
|
|
+ Long cardId = examPaperInfoDto.getCardId();
|
|
|
+ if (cardId != null) {
|
|
|
+ String paperType = examPaperInfoDto.getName();
|
|
|
+ ExamCard examCard = examCardService.getById(cardId);
|
|
|
+ if (Objects.isNull(examCard)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s],卷型[%s]的题卡不存在", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber(), paperType));
|
|
|
+ }
|
|
|
+ MakeMethodEnum makeMethodEnum = examCard.getMakeMethod();
|
|
|
+ if (MakeMethodEnum.SELECT.equals(makeMethodEnum) && CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
|
|
|
+ Long attachmentId = examCard.getAttachmentId();
|
|
|
+ if (attachmentId == null || attachmentId == 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s],卷型[%s]的题卡未上传", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber(), paperType));
|
|
|
+ }
|
|
|
+ BasicAttachment cardAttachment = basicAttachmentService.getById(attachmentId);
|
|
|
+ if (Objects.isNull(cardAttachment)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s],卷型[%s]的题卡未找到上传附件数据", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber(), paperType));
|
|
|
+ }
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(cardAttachment.getPath());
|
|
|
+ // 题卡路径
|
|
|
+ String cardPath = firstPath + File.separator + "题卡" + File.separator + paperType + "-" + cardAttachment.getName() + cardAttachment.getType();
|
|
|
+ UploadFileEnum uploadFileEnum = UploadFileEnum.valueOf((String) jsonObject.get(SystemConstant.UPLOAD_TYPE));
|
|
|
+
|
|
|
+ if (oss || (!oss && dictionaryConfig.fssPrivateDomain().getConfig().startsWith(SystemConstant.START_PARENT))) {
|
|
|
+ fileStoreUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), cardPath, uploadFileEnum.getFssType());
|
|
|
+ } else {
|
|
|
+ FileUtil.copyFile(jsonObject.getString(SystemConstant.PATH), cardPath);
|
|
|
+ }
|
|
|
} else {
|
|
|
- FileUtil.copyFile(jsonObject.getString(SystemConstant.PATH), confirmPath);
|
|
|
+ String htmlContent = examCard.getHtmlContent();
|
|
|
+ byte[] bytes = htmlContent.getBytes(StandardCharsets.UTF_8);
|
|
|
+ // 题卡路径
|
|
|
+ String cardPath = firstPath + File.separator + "题卡" + File.separator + paperType + "-" + examCard.getTitle() + SystemConstant.HTML_PREFIX;
|
|
|
+ File localFile = new File(cardPath);
|
|
|
+ if (!localFile.getParentFile().exists()) {
|
|
|
+ localFile.getParentFile().mkdirs();
|
|
|
+ }
|
|
|
+ FileCopyUtils.copy(bytes, localFile);
|
|
|
}
|
|
|
- count++;
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- // 处理题卡
|
|
|
- for (ExamCardDto examCardDto : examCardDtoList) {
|
|
|
- Long cardId = examCardDto.getCardId();
|
|
|
- String paperType = examCardDto.getPaperType();
|
|
|
- ExamCard examCard = examCardService.getById(cardId);
|
|
|
- if (Objects.isNull(examCard)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("找不到答题卡");
|
|
|
- }
|
|
|
- MakeMethodEnum makeMethodEnum = examCard.getMakeMethod();
|
|
|
- if (MakeMethodEnum.SELECT.equals(makeMethodEnum) && CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
|
|
|
- Long attachmentId = examCard.getAttachmentId();
|
|
|
- if (attachmentId == null || attachmentId == 0) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("找不到模板对应的附件");
|
|
|
- }
|
|
|
- BasicAttachment cardAttachment = basicAttachmentService.getById(attachmentId);
|
|
|
- if (Objects.isNull(cardAttachment)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("找不到附件");
|
|
|
+ // 处理审核样品
|
|
|
+ List<Map> confirmInfo = JSONObject.parseArray(examTaskDetail.getPaperConfirmAttachmentIds(), Map.class);
|
|
|
+ for (Map confirmMap : confirmInfo) {
|
|
|
+ if (Objects.isNull(confirmMap.get("attachmentId"))) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s]的附件未上传", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber()));
|
|
|
}
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(cardAttachment.getPath());
|
|
|
- // 题卡路径
|
|
|
- String cardPath = firstPath + File.separator + "题卡" + File.separator + cardAttachment.getName() + cardAttachment.getType();
|
|
|
- if (SystemConstant.strNotNull(paperType)) {
|
|
|
- cardPath = cardPath + "(" + paperType + ")";
|
|
|
+ Long attachmentId = Long.valueOf(String.valueOf(confirmMap.get("attachmentId")));
|
|
|
+ BasicAttachment confirmAttachment = basicAttachmentService.getById(attachmentId);
|
|
|
+ if (confirmAttachment == null) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s]的附件未找到上传数据", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber()));
|
|
|
}
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(confirmAttachment.getPath());
|
|
|
UploadFileEnum uploadFileEnum = UploadFileEnum.valueOf((String) jsonObject.get(SystemConstant.UPLOAD_TYPE));
|
|
|
-
|
|
|
+ String confirmPath = firstPath + File.separator + "审核样本" + File.separator + confirmAttachment.getName() + confirmAttachment.getType();
|
|
|
if (oss || (!oss && dictionaryConfig.fssPrivateDomain().getConfig().startsWith(SystemConstant.START_PARENT))) {
|
|
|
- fileStoreUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), cardPath, uploadFileEnum.getFssType());
|
|
|
+ fileStoreUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), confirmPath, uploadFileEnum.getFssType());
|
|
|
} else {
|
|
|
- FileUtil.copyFile(jsonObject.getString(SystemConstant.PATH), cardPath);
|
|
|
- }
|
|
|
- } else {
|
|
|
- String htmlContent = examCard.getHtmlContent();
|
|
|
- byte[] bytes = htmlContent.getBytes(StandardCharsets.UTF_8);
|
|
|
-
|
|
|
- // 题卡路径
|
|
|
- String cardPath = firstPath + File.separator + "题卡" + File.separator + examCard.getTitle();
|
|
|
- if (SystemConstant.strNotNull(paperType)) {
|
|
|
- cardPath = cardPath + "(" + paperType + ")";
|
|
|
- }
|
|
|
- cardPath = cardPath + SystemConstant.HTML_PREFIX;
|
|
|
-
|
|
|
- File localFile = new File(cardPath);
|
|
|
- if (!localFile.getParentFile().exists()) {
|
|
|
- localFile.getParentFile().mkdirs();
|
|
|
+ FileUtil.copyFile(jsonObject.getString(SystemConstant.PATH), confirmPath);
|
|
|
}
|
|
|
- FileCopyUtils.copy(bytes, localFile);
|
|
|
}
|
|
|
}
|
|
|
count++;
|