|
@@ -110,6 +110,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
SysUser sysUser = (SysUser) map.get(SystemConstant.USER);
|
|
SysUser sysUser = (SysUser) map.get(SystemConstant.USER);
|
|
Long examDetailId = Objects.nonNull(map.get("examDetailId")) ? (Long) map.get("examDetailId") : null;
|
|
Long examDetailId = Objects.nonNull(map.get("examDetailId")) ? (Long) map.get("examDetailId") : null;
|
|
Long schoolId = (Long) map.get("schoolId");
|
|
Long schoolId = (Long) map.get("schoolId");
|
|
|
|
+ List<Long> examDetailCourseIds = Objects.nonNull(map.get("examDetailCourseIds")) ? (List<Long>) map.get("examDetailCourseIds") : null;
|
|
|
|
+ String paperTypeParam = Objects.nonNull(map.get("paperType")) ? (String) map.get("paperType") : null;
|
|
|
|
|
|
//这里为保存附件html的逻辑
|
|
//这里为保存附件html的逻辑
|
|
//查询题卡详情是否有附件id,有的话则把以前的附件删除
|
|
//查询题卡详情是否有附件id,有的话则把以前的附件删除
|
|
@@ -140,129 +142,135 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
for (ExamDetail examDetail : examDetailList) {
|
|
for (ExamDetail examDetail : examDetailList) {
|
|
//查询examDetailCourse
|
|
//查询examDetailCourse
|
|
QueryWrapper<ExamDetailCourse> examDetailCourseQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<ExamDetailCourse> examDetailCourseQueryWrapper = new QueryWrapper<>();
|
|
- examDetailCourseQueryWrapper.lambda().eq(ExamDetailCourse::getExamDetailId, examDetail.getId());
|
|
|
|
|
|
+ if (Objects.nonNull(examDetailCourseIds) && examDetailCourseIds.size() > 0) {
|
|
|
|
+ examDetailCourseQueryWrapper.lambda().in(ExamDetailCourse::getId, examDetailCourseIds);
|
|
|
|
+ } else {
|
|
|
|
+ examDetailCourseQueryWrapper.lambda().eq(ExamDetailCourse::getExamDetailId, examDetail.getId());
|
|
|
|
+ }
|
|
List<ExamDetailCourse> examDetailCourseList = detailCourseService.list(examDetailCourseQueryWrapper);
|
|
List<ExamDetailCourse> examDetailCourseList = detailCourseService.list(examDetailCourseQueryWrapper);
|
|
-
|
|
|
|
- List<PdfDto> variablePdfList = new ArrayList<>();//变量印品(签到表、卷袋贴)
|
|
|
|
- List<PdfDto> ordinaryPdfList = new ArrayList<>();//普通印品(登记表)
|
|
|
|
- List<PdfDto> paperPdfList = new ArrayList<>();//所有试卷
|
|
|
|
- List<PdfDto> examStudentPdfList = new ArrayList<>();//所有题卡
|
|
|
|
- List<PdfDto> backupPaperPdfList = new ArrayList<>();//备份试卷
|
|
|
|
- List<PdfDto> cardPdfList = new ArrayList<>();//备份题卡
|
|
|
|
-
|
|
|
|
- if (Objects.nonNull(examPrintPlan.getOrdinaryContent())) {
|
|
|
|
- //获取普通印品
|
|
|
|
- JSONArray jsonArrayOrdinary = JSONArray.parseArray(examPrintPlan.getOrdinaryContent());
|
|
|
|
- for (int i = 0; i < jsonArrayOrdinary.size(); i++) {
|
|
|
|
- JSONObject jsonObjectOrdinary = jsonArrayOrdinary.getJSONObject(i);
|
|
|
|
- Long attachmentId = Long.parseLong((String) jsonObjectOrdinary.get("attachmentId"));
|
|
|
|
- BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
|
|
|
|
- createPdfUtil.createCheckIn(basicAttachment, ordinaryPdfList, (Integer) jsonObjectOrdinary.get("backupCount"));
|
|
|
|
|
|
+ if (Objects.nonNull(examDetailCourseList) && examDetailCourseList.size() > 0) {
|
|
|
|
+ List<PdfDto> variablePdfList = new ArrayList<>();//变量印品(签到表、卷袋贴)
|
|
|
|
+ List<PdfDto> ordinaryPdfList = new ArrayList<>();//普通印品(登记表)
|
|
|
|
+ List<PdfDto> paperPdfList = new ArrayList<>();//所有试卷
|
|
|
|
+ List<PdfDto> examStudentPdfList = new ArrayList<>();//所有题卡
|
|
|
|
+ List<PdfDto> backupPaperPdfList = new ArrayList<>();//备份试卷
|
|
|
|
+ List<PdfDto> cardPdfList = new ArrayList<>();//备份题卡
|
|
|
|
+
|
|
|
|
+ if (Objects.nonNull(examPrintPlan.getOrdinaryContent())) {
|
|
|
|
+ //获取普通印品
|
|
|
|
+ JSONArray jsonArrayOrdinary = JSONArray.parseArray(examPrintPlan.getOrdinaryContent());
|
|
|
|
+ for (int i = 0; i < jsonArrayOrdinary.size(); i++) {
|
|
|
|
+ JSONObject jsonObjectOrdinary = jsonArrayOrdinary.getJSONObject(i);
|
|
|
|
+ Long attachmentId = Long.parseLong((String) jsonObjectOrdinary.get("attachmentId"));
|
|
|
|
+ BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
|
|
|
|
+ createPdfUtil.createCheckIn(basicAttachment, ordinaryPdfList, (Integer) jsonObjectOrdinary.get("backupCount"));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
- for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
|
|
|
|
- List<PdfDto> paperPdfTempList = new ArrayList<>();//所有试卷
|
|
|
|
- List<PdfDto> examStudentTempPdfList = new ArrayList<>();//所有题卡
|
|
|
|
- List<PdfDto> backupPaperTempPdfList = new ArrayList<>();//备份试卷
|
|
|
|
- List<PdfDto> cardPdfTempList = new ArrayList<>();//备份题卡
|
|
|
|
-
|
|
|
|
- //查询试卷
|
|
|
|
- QueryWrapper<ExamTask> examTaskQueryWrapper = new QueryWrapper<>();
|
|
|
|
- examTaskQueryWrapper.lambda().eq(ExamTask::getSchoolId, sysUser.getSchoolId())
|
|
|
|
- .eq(ExamTask::getCourseCode, examDetailCourse.getCourseCode())
|
|
|
|
- .eq(ExamTask::getCourseName, examDetailCourse.getCourseName())
|
|
|
|
- .eq(ExamTask::getPaperNumber, examDetailCourse.getPaperNumber())
|
|
|
|
- .eq(ExamTask::getEnable, true)
|
|
|
|
- .eq(ExamTask::getStatus, ExamStatusEnum.FINISH);
|
|
|
|
- List<ExamTask> examTaskList = examTaskService.list(examTaskQueryWrapper);
|
|
|
|
- if (Objects.isNull(examTaskList) || examTaskList.size() == 0) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("命题任务为空");
|
|
|
|
- }
|
|
|
|
- Set<Long> examTaskIds = examTaskList.stream().map(s -> s.getId()).collect(Collectors.toSet());
|
|
|
|
-
|
|
|
|
- QueryWrapper<ExamTaskDetail> examTaskDetailQueryWrapper = new QueryWrapper<>();
|
|
|
|
- examTaskDetailQueryWrapper.lambda().in(ExamTaskDetail::getExamTaskId, examTaskIds)
|
|
|
|
- .eq(ExamTaskDetail::getEnable, true);
|
|
|
|
- List<ExamTaskDetail> examTaskDetailList = examTaskDetailService.list(examTaskDetailQueryWrapper);
|
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
|
- JSONArray jsonArray = new JSONArray();
|
|
|
|
- for (ExamTaskDetail examTaskDetail : examTaskDetailList) {
|
|
|
|
- //查询题卡
|
|
|
|
- ExamCard examCard = examCardService.getById(examTaskDetail.getCardId());
|
|
|
|
- if (Objects.isNull(examCard)) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("题卡为空");
|
|
|
|
|
|
+ for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
|
|
|
|
+ List<PdfDto> paperPdfTempList = new ArrayList<>();//所有试卷
|
|
|
|
+ List<PdfDto> examStudentTempPdfList = new ArrayList<>();//所有题卡
|
|
|
|
+ List<PdfDto> backupPaperTempPdfList = new ArrayList<>();//备份试卷
|
|
|
|
+ List<PdfDto> cardPdfTempList = new ArrayList<>();//备份题卡
|
|
|
|
+
|
|
|
|
+ //查询试卷
|
|
|
|
+ QueryWrapper<ExamTask> examTaskQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ examTaskQueryWrapper.lambda().eq(ExamTask::getSchoolId, sysUser.getSchoolId())
|
|
|
|
+ .eq(ExamTask::getCourseCode, examDetailCourse.getCourseCode())
|
|
|
|
+ .eq(ExamTask::getCourseName, examDetailCourse.getCourseName())
|
|
|
|
+ .eq(ExamTask::getPaperNumber, examDetailCourse.getPaperNumber())
|
|
|
|
+ .eq(ExamTask::getEnable, true)
|
|
|
|
+ .eq(ExamTask::getStatus, ExamStatusEnum.FINISH);
|
|
|
|
+ List<ExamTask> examTaskList = examTaskService.list(examTaskQueryWrapper);
|
|
|
|
+ if (Objects.isNull(examTaskList) || examTaskList.size() == 0) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("命题任务为空");
|
|
}
|
|
}
|
|
- QueryWrapper<ExamCardDetail> examCardDetailQueryWrapper = new QueryWrapper<>();
|
|
|
|
- examCardDetailQueryWrapper.lambda().eq(ExamCardDetail::getCardId, examCard.getId());
|
|
|
|
- List<ExamCardDetail> examCardDetailList = examCardDetailService.list(examCardDetailQueryWrapper);
|
|
|
|
|
|
+ Set<Long> examTaskIds = examTaskList.stream().map(s -> s.getId()).collect(Collectors.toSet());
|
|
|
|
+
|
|
|
|
+ QueryWrapper<ExamTaskDetail> examTaskDetailQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ examTaskDetailQueryWrapper.lambda().in(ExamTaskDetail::getExamTaskId, examTaskIds)
|
|
|
|
+ .eq(ExamTaskDetail::getEnable, true);
|
|
|
|
+ List<ExamTaskDetail> examTaskDetailList = examTaskDetailService.list(examTaskDetailQueryWrapper);
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
|
+ for (ExamTaskDetail examTaskDetail : examTaskDetailList) {
|
|
|
|
+ //查询题卡
|
|
|
|
+ ExamCard examCard = examCardService.getById(examTaskDetail.getCardId());
|
|
|
|
+ if (Objects.isNull(examCard)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("题卡为空");
|
|
|
|
+ }
|
|
|
|
+ QueryWrapper<ExamCardDetail> examCardDetailQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ examCardDetailQueryWrapper.lambda().eq(ExamCardDetail::getCardId, examCard.getId());
|
|
|
|
+ List<ExamCardDetail> examCardDetailList = examCardDetailService.list(examCardDetailQueryWrapper);
|
|
|
|
|
|
- //抽取卷型
|
|
|
|
- String paperType = createPdfUtil.getPaperType(examPrintPlan, examTaskDetail);
|
|
|
|
|
|
+ //抽取卷型
|
|
|
|
+ String paperType = Objects.nonNull(paperTypeParam) ? paperTypeParam : createPdfUtil.getPaperType(examPrintPlan, examTaskDetail);
|
|
|
|
+ examTaskDetail.setRelatePaperType(paperType);
|
|
|
|
|
|
- //获取试卷pdf
|
|
|
|
- createPdfUtil.getPaperPdf(examTaskDetail, examPrintPlan.getBackupCount(), paperPdfTempList, backupPaperTempPdfList);
|
|
|
|
- paperPdfList.addAll(paperPdfTempList);
|
|
|
|
- backupPaperPdfList.addAll(backupPaperTempPdfList);
|
|
|
|
|
|
+ //获取试卷pdf
|
|
|
|
+ createPdfUtil.getPaperPdf(examTaskDetail, examPrintPlan.getBackupCount(), paperPdfTempList, backupPaperTempPdfList);
|
|
|
|
+ paperPdfList.addAll(paperPdfTempList);
|
|
|
|
+ backupPaperPdfList.addAll(backupPaperTempPdfList);
|
|
|
|
|
|
- basicAttachmentList = Objects.isNull(basicAttachmentList) ? basicAttachmentList = new ArrayList<>() : basicAttachmentList;
|
|
|
|
- for (ExamCardDetail examCardDetail : examCardDetailList) {
|
|
|
|
- createPdfUtil.getCardAttachmentId(examCardDetail, attachmentIds);
|
|
|
|
|
|
+ basicAttachmentList = Objects.isNull(basicAttachmentList) ? basicAttachmentList = new ArrayList<>() : basicAttachmentList;
|
|
|
|
+ for (ExamCardDetail examCardDetail : examCardDetailList) {
|
|
|
|
+ createPdfUtil.getCardAttachmentId(examCardDetail, attachmentIds);
|
|
|
|
|
|
- //把模板页面上的 ${} 替换成实际内容
|
|
|
|
- String cardContent = createPdfUtil.replaceHtmlTemplete(examCardDetail);
|
|
|
|
- String studentContent = cardContent;
|
|
|
|
|
|
+ //把模板页面上的 ${} 替换成实际内容
|
|
|
|
+ String cardContent = createPdfUtil.replaceHtmlTemplete(examCardDetail);
|
|
|
|
+ String studentContent = cardContent;
|
|
|
|
|
|
- for (int i = 1; i <= examPrintPlan.getBackupCount(); i++) {
|
|
|
|
- basicAttachmentList.add(createPdfUtil.cardHtml(cardContent, paperType, examDetailCourse, examCard, jsonArray, sysUser.getId(), cardPdfTempList));
|
|
|
|
- }
|
|
|
|
- cardPdfList.addAll(cardPdfTempList);
|
|
|
|
-
|
|
|
|
- //查询考生
|
|
|
|
- QueryWrapper<ExamStudent> examStudentQueryWrapper = new QueryWrapper<>();
|
|
|
|
- examStudentQueryWrapper.lambda().eq(ExamStudent::getSchoolId, sysUser.getSchoolId())
|
|
|
|
- .eq(ExamStudent::getExamDetailCourseId, examDetailCourse.getId());
|
|
|
|
- List<ExamStudent> examStudentList = examStudentService.list(examStudentQueryWrapper);
|
|
|
|
-
|
|
|
|
- if (Objects.nonNull(examPrintPlan.getVariableContent())) {
|
|
|
|
- //获取变量印品
|
|
|
|
- JSONArray jsonArrayVariable = JSONArray.parseArray(examPrintPlan.getVariableContent());
|
|
|
|
- for (int i = 0; i < jsonArrayVariable.size(); i++) {
|
|
|
|
- JSONObject jsonObjectVariable = jsonArrayVariable.getJSONObject(i);
|
|
|
|
- String type = (String) jsonObjectVariable.get("type");
|
|
|
|
- Long attachmentId = Long.parseLong((String) jsonObjectVariable.get("attachmentId"));
|
|
|
|
- BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
|
|
|
|
- ftlList.add(commonService.getFile(basicAttachment.getPath(), false));
|
|
|
|
- if (Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "SIGN")) {//签到表
|
|
|
|
- createPdfUtil.createSignBook(basicAttachment, basicSchool.getName(), examDetailCourse, examStudentList, variablePdfList, (Integer) jsonObjectVariable.get("backupCount"));
|
|
|
|
- } else if (Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "PACKAGE")) {//卷袋贴
|
|
|
|
- createPdfUtil.createPaperPackage(basicAttachment, basicSchool.getName(), examDetailCourse, examStudentList, variablePdfList, (Integer) jsonObjectVariable.get("backupCount"));
|
|
|
|
|
|
+ for (int i = 1; i <= examPrintPlan.getBackupCount(); i++) {
|
|
|
|
+ basicAttachmentList.add(createPdfUtil.cardHtml(cardContent, paperType, examDetailCourse, examCard, jsonArray, sysUser.getId(), cardPdfTempList));
|
|
|
|
+ }
|
|
|
|
+ cardPdfList.addAll(cardPdfTempList);
|
|
|
|
+
|
|
|
|
+ //查询考生
|
|
|
|
+ QueryWrapper<ExamStudent> examStudentQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ examStudentQueryWrapper.lambda().eq(ExamStudent::getSchoolId, sysUser.getSchoolId())
|
|
|
|
+ .eq(ExamStudent::getExamDetailCourseId, examDetailCourse.getId());
|
|
|
|
+ List<ExamStudent> examStudentList = examStudentService.list(examStudentQueryWrapper);
|
|
|
|
+
|
|
|
|
+ if (Objects.nonNull(examPrintPlan.getVariableContent())) {
|
|
|
|
+ //获取变量印品
|
|
|
|
+ JSONArray jsonArrayVariable = JSONArray.parseArray(examPrintPlan.getVariableContent());
|
|
|
|
+ for (int i = 0; i < jsonArrayVariable.size(); i++) {
|
|
|
|
+ JSONObject jsonObjectVariable = jsonArrayVariable.getJSONObject(i);
|
|
|
|
+ String type = (String) jsonObjectVariable.get("type");
|
|
|
|
+ Long attachmentId = Long.parseLong((String) jsonObjectVariable.get("attachmentId"));
|
|
|
|
+ BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
|
|
|
|
+ ftlList.add(commonService.getFile(basicAttachment.getPath(), false));
|
|
|
|
+ if (Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "SIGN")) {//签到表
|
|
|
|
+ createPdfUtil.createSignBook(basicAttachment, basicSchool.getName(), examDetailCourse, examStudentList, variablePdfList, (Integer) jsonObjectVariable.get("backupCount"));
|
|
|
|
+ } else if (Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "PACKAGE")) {//卷袋贴
|
|
|
|
+ createPdfUtil.createPaperPackage(basicAttachment, basicSchool.getName(), examDetailCourse, examStudentList, variablePdfList, (Integer) jsonObjectVariable.get("backupCount"));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
- for (ExamStudent t : examStudentList) {
|
|
|
|
- basicAttachmentList.add(createPdfUtil.examStudentHtml(attachmentIds, studentContent, t, paperType, examCard, sysUser.getId(), examStudentTempPdfList));
|
|
|
|
|
|
+ for (ExamStudent t : examStudentList) {
|
|
|
|
+ basicAttachmentList.add(createPdfUtil.examStudentHtml(attachmentIds, studentContent, t, paperType, examCard, sysUser.getId(), examStudentTempPdfList));
|
|
|
|
+ }
|
|
|
|
+ examStudentPdfList.addAll(examStudentTempPdfList);
|
|
|
|
+ examStudentService.saveOrUpdateBatch(examStudentList);
|
|
|
|
+ jsonObject.put("card", jsonArray);
|
|
|
|
+ examCardDetail.setAttachmentId(jsonObject.toJSONString());
|
|
}
|
|
}
|
|
- examStudentPdfList.addAll(examStudentTempPdfList);
|
|
|
|
- examStudentService.saveOrUpdateBatch(examStudentList);
|
|
|
|
- jsonObject.put("card", jsonArray);
|
|
|
|
- examCardDetail.setAttachmentId(jsonObject.toJSONString());
|
|
|
|
|
|
+ examCardDetailService.saveOrUpdateBatch(examCardDetailList);
|
|
}
|
|
}
|
|
- examCardDetailService.saveOrUpdateBatch(examCardDetailList);
|
|
|
|
|
|
+ examTaskDetailService.saveOrUpdateBatch(examTaskDetailList);
|
|
|
|
+
|
|
|
|
+ Integer paperPageA3 = 0;
|
|
|
|
+ Integer cardPageA3 = 0;
|
|
|
|
+ paperPageA3 = paperPageA3 + paperPdfTempList.stream().mapToInt(PdfDto::getPageCount).sum() + backupPaperTempPdfList.stream().mapToInt(PdfDto::getPageCount).sum();
|
|
|
|
+ cardPageA3 = cardPageA3 + examStudentTempPdfList.stream().mapToInt(PdfDto::getPageCount).sum() + cardPdfTempList.stream().mapToInt(PdfDto::getPageCount).sum();
|
|
|
|
+ examDetailCourse.setPaperPagesA3(paperPageA3);
|
|
|
|
+ examDetailCourse.setCardPagesA3(cardPageA3);
|
|
}
|
|
}
|
|
- examTaskDetailService.saveOrUpdateBatch(examTaskDetailList);
|
|
|
|
-
|
|
|
|
- Integer paperPageA3 = 0;
|
|
|
|
- Integer cardPageA3 = 0;
|
|
|
|
- paperPageA3 = paperPageA3 + paperPdfTempList.stream().mapToInt(PdfDto::getPageCount).sum() + backupPaperTempPdfList.stream().mapToInt(PdfDto::getPageCount).sum();
|
|
|
|
- cardPageA3 = cardPageA3 + examStudentTempPdfList.stream().mapToInt(PdfDto::getPageCount).sum() + cardPdfTempList.stream().mapToInt(PdfDto::getPageCount).sum();
|
|
|
|
- examDetailCourse.setPaperPagesA3(paperPageA3);
|
|
|
|
- examDetailCourse.setCardPagesA3(cardPageA3);
|
|
|
|
|
|
+ detailCourseService.saveOrUpdateBatch(examDetailCourseList);
|
|
|
|
+ //合并pdf
|
|
|
|
+ basicAttachmentList.add(createPdfUtil.mergePdf(tbTask, examDetail, sysUser.getId(), schoolId, variablePdfList, ordinaryPdfList, paperPdfList, examStudentPdfList, backupPaperPdfList, cardPdfList));
|
|
}
|
|
}
|
|
- detailCourseService.saveOrUpdateBatch(examDetailCourseList);
|
|
|
|
- //合并pdf
|
|
|
|
- basicAttachmentList.add(createPdfUtil.mergePdf(tbTask, examDetail, sysUser.getId(), schoolId, variablePdfList, ordinaryPdfList, paperPdfList, examStudentPdfList, backupPaperPdfList, cardPdfList));
|
|
|
|
}
|
|
}
|
|
map.computeIfAbsent("size", v -> examDetailList.size());
|
|
map.computeIfAbsent("size", v -> examDetailList.size());
|
|
//最后一步删除附件
|
|
//最后一步删除附件
|