|
@@ -1008,25 +1008,29 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
}
|
|
}
|
|
String examTaskSign = examTask.getCourseName() + "-" + examTask.getPaperNumber();
|
|
String examTaskSign = examTask.getCourseName() + "-" + examTask.getPaperNumber();
|
|
String firstPath = zipLocalRootPath + File.separator + examTaskSign;
|
|
String firstPath = zipLocalRootPath + File.separator + examTaskSign;
|
|
-// List<ExamTaskDetail> examTaskDetailList = examTaskDetailService.list(new QueryWrapper<ExamTaskDetail>().lambda().eq(ExamTaskDetail::getExamTaskId, id));
|
|
|
|
-// if (examTaskDetailList.size() != 1) {
|
|
|
|
-// throw ExceptionResultEnum.ERROR.exception("获取命题任务详情失败");
|
|
|
|
-// }
|
|
|
|
-// ExamTaskDetail examTaskDetail = examTaskDetailList.get(0);
|
|
|
|
ReviewSampleDto reviewSampleDto = examTaskService.findReviewSampleInfoByExamTaskId(id);
|
|
ReviewSampleDto reviewSampleDto = examTaskService.findReviewSampleInfoByExamTaskId(id);
|
|
|
|
|
|
|
|
|
|
- // 处理试卷样品
|
|
|
|
- List<Map> paperInfo = JSONObject.parseArray(reviewSampleDto.getPaperAttachmentIds(), Map.class);
|
|
|
|
- if (Objects.isNull(paperInfo)) {
|
|
|
|
|
|
+ // 收集处理试卷和题卡
|
|
|
|
+ List<ExamPaperInfoDto> paperInfoDtoList = JSONObject.parseArray(reviewSampleDto.getPaperAttachmentIds(), ExamPaperInfoDto.class);
|
|
|
|
+ if (Objects.isNull(paperInfoDtoList)) {
|
|
throw ExceptionResultEnum.ERROR.exception("试卷信息不存在");
|
|
throw ExceptionResultEnum.ERROR.exception("试卷信息不存在");
|
|
}
|
|
}
|
|
Set<Long> attPaperIds = new HashSet<>();
|
|
Set<Long> attPaperIds = new HashSet<>();
|
|
- for (Map paperMap : paperInfo) {
|
|
|
|
- if (Objects.nonNull(paperMap.get("attachmentId")) && String.valueOf(paperMap.get("attachmentId")).length() > 0 && !String.valueOf(paperMap.get("attachmentId")).equals("null")) {
|
|
|
|
- Long attachmentId = Long.valueOf(String.valueOf(paperMap.get("attachmentId")));
|
|
|
|
|
|
+ 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);
|
|
attPaperIds.add(attachmentId);
|
|
}
|
|
}
|
|
|
|
+ if (SystemConstant.longNotNull(cardId)){
|
|
|
|
+ ExamCardDto examCardDto = new ExamCardDto();
|
|
|
|
+ examCardDto.setCardId(cardId);
|
|
|
|
+ examCardDto.setPaperType(paperType);
|
|
|
|
+ examCardDtoList.add(examCardDto);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if (attPaperIds.size() > 0) {
|
|
if (attPaperIds.size() > 0) {
|
|
List<BasicAttachment> paperAttachmentList = basicAttachmentService.listByIds(attPaperIds);
|
|
List<BasicAttachment> paperAttachmentList = basicAttachmentService.listByIds(attPaperIds);
|
|
@@ -1069,44 +1073,59 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
}
|
|
}
|
|
|
|
|
|
// 处理题卡
|
|
// 处理题卡
|
|
- Long cardId = reviewSampleDto.getCardId();
|
|
|
|
- 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("找不到附件");
|
|
|
|
|
|
+ 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("找不到答题卡");
|
|
}
|
|
}
|
|
- JSONObject jsonObject = JSONObject.parseObject(cardAttachment.getPath());
|
|
|
|
- String cardPath = firstPath + File.separator + "题卡" + File.separator + cardAttachment.getName() + cardAttachment.getType();
|
|
|
|
- UploadFileEnum uploadFileEnum = UploadFileEnum.valueOf((String) jsonObject.get(SystemConstant.UPLOAD_TYPE));
|
|
|
|
|
|
+ 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("找不到附件");
|
|
|
|
+ }
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(cardAttachment.getPath());
|
|
|
|
+ // 题卡路径
|
|
|
|
+ String cardPath = firstPath + File.separator + "题卡" + File.separator + cardAttachment.getName() + cardAttachment.getType();
|
|
|
|
+ if (SystemConstant.strNotNull(paperType)){
|
|
|
|
+ cardPath = cardPath + "(" + paperType + ")";
|
|
|
|
+ }
|
|
|
|
+ UploadFileEnum uploadFileEnum = UploadFileEnum.valueOf((String) jsonObject.get(SystemConstant.UPLOAD_TYPE));
|
|
|
|
|
|
- if (oss) {
|
|
|
|
- fileStoreUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), cardPath, uploadFileEnum.getFssType());
|
|
|
|
|
|
+ if (oss) {
|
|
|
|
+ fileStoreUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), cardPath, uploadFileEnum.getFssType());
|
|
|
|
+ } else {
|
|
|
|
+ FileUtil.copyFile(jsonObject.getString(SystemConstant.PATH), cardPath);
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
- FileUtil.copyFile(jsonObject.getString(SystemConstant.PATH), cardPath);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- List<ExamCardDetail> examCardDetailList = examCardDetailService.list(new QueryWrapper<ExamCardDetail>().lambda().eq(ExamCardDetail::getCardId, cardId));
|
|
|
|
- if (examCardDetailList.size() != 1) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("题卡明细信息异常");
|
|
|
|
- }
|
|
|
|
- ExamCardDetail examCardDetail = examCardDetailService.getByCardId(cardId);
|
|
|
|
- String htmlContent = examCardDetail.getHtmlContent();
|
|
|
|
- byte[] bytes = htmlContent.getBytes();
|
|
|
|
- String cardPath = firstPath + File.separator + "题卡" + File.separator + examCard.getTitle() + SystemConstant.HTML_PREFIX;
|
|
|
|
- File localFile = new File(cardPath);
|
|
|
|
- if (!localFile.getParentFile().exists()) {
|
|
|
|
- localFile.getParentFile().mkdirs();
|
|
|
|
|
|
+ List<ExamCardDetail> examCardDetailList = examCardDetailService.list(new QueryWrapper<ExamCardDetail>().lambda().eq(ExamCardDetail::getCardId, cardId));
|
|
|
|
+ if (examCardDetailList.size() != 1) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("题卡明细信息异常");
|
|
|
|
+ }
|
|
|
|
+ ExamCardDetail examCardDetail = examCardDetailService.getByCardId(cardId);
|
|
|
|
+ String htmlContent = examCardDetail.getHtmlContent();
|
|
|
|
+ byte[] bytes = htmlContent.getBytes();
|
|
|
|
+
|
|
|
|
+ // 题卡路径
|
|
|
|
+ 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();
|
|
|
|
+ }
|
|
|
|
+ FileCopyUtils.copy(bytes, localFile);
|
|
}
|
|
}
|
|
- FileCopyUtils.copy(bytes, localFile);
|
|
|
|
}
|
|
}
|
|
count++;
|
|
count++;
|
|
}
|
|
}
|