|
@@ -162,125 +162,176 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 创建pdf查询数据
|
|
|
|
|
|
+ * 创建pdf核心逻辑
|
|
*
|
|
*
|
|
- * @param map
|
|
|
|
|
|
+ * @param examDetailCourseList
|
|
|
|
+ * @param examPrintPlan
|
|
|
|
+ * @param examDetail
|
|
|
|
+ * @param sysUser
|
|
|
|
+ * @param paperTypeParam
|
|
|
|
+ * @param basicAttachmentList
|
|
|
|
+ * @param attachmentIds
|
|
|
|
+ * @param ftlList
|
|
|
|
+ * @param basicSchool
|
|
|
|
+ * @param list
|
|
* @return
|
|
* @return
|
|
|
|
+ * @throws IOException
|
|
|
|
+ * @throws DocumentException
|
|
*/
|
|
*/
|
|
- public Map<String, Object> createPdfSelectData(Map<String, Object> map) {
|
|
|
|
- TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
|
|
|
|
- SysUser sysUser = (SysUser) map.get(SystemConstant.USER);
|
|
|
|
- Long examDetailId = tbTask.getEntityId();
|
|
|
|
- List<Long> examDetailIds = Objects.nonNull(map.get("examDetailIds")) ? (List<Long>) map.get("examDetailIds") : null;
|
|
|
|
- Long schoolId = tbTask.getSchoolId();
|
|
|
|
- List<Long> examDetailCourseIds = Objects.nonNull(map.get("examDetailCourseIds")) ? (List<Long>) map.get("examDetailCourseIds") : null;
|
|
|
|
|
|
+ @Transactional
|
|
|
|
+ public List<BasicAttachment> createPdfCoreLogic(List<ExamDetailCourse> examDetailCourseList,
|
|
|
|
+ ExamPrintPlan examPrintPlan,
|
|
|
|
+ ExamDetail examDetail,
|
|
|
|
+ SysUser sysUser,
|
|
|
|
+ String paperTypeParam,
|
|
|
|
+ List<BasicAttachment> basicAttachmentList,
|
|
|
|
+ Set<Long> attachmentIds,
|
|
|
|
+ Set<File> ftlList,
|
|
|
|
+ BasicSchool basicSchool,
|
|
|
|
+ List<PdfDto>... list
|
|
|
|
+ ) throws IOException, DocumentException {
|
|
|
|
+ if (Objects.nonNull(examDetailCourseList) && examDetailCourseList.size() > 0) {
|
|
|
|
+ for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
|
|
|
|
+ if (Objects.nonNull(examPrintPlan.getOrdinaryContent())) {
|
|
|
|
+ //获取普通印品
|
|
|
|
+ JSONArray jsonArrayOrdinary = JSONArray.parseArray(examPrintPlan.getOrdinaryContent());
|
|
|
|
+ for (int i = 0; i < jsonArrayOrdinary.size(); i++) {
|
|
|
|
+ JSONObject jsonObjectOrdinary = jsonArrayOrdinary.getJSONObject(i);
|
|
|
|
+ if (Objects.nonNull(jsonObjectOrdinary.get("attachmentId")) && !Objects.equals("", jsonObjectOrdinary.get("attachmentId"))) {
|
|
|
|
+ Long attachmentId = Long.parseLong((String) jsonObjectOrdinary.get("attachmentId"));
|
|
|
|
+ BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
|
|
|
|
+ createPdfUtil.createCheckIn(examDetail, basicAttachment, list[0], (Integer) jsonObjectOrdinary.get("backupCount"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- //查询printPlan
|
|
|
|
- ExamPrintPlan examPrintPlan = examPrintPlanService.getById(tbTask.getPrintPlanId());
|
|
|
|
- if (Objects.isNull(examPrintPlan)) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("印刷计划为空");
|
|
|
|
- }
|
|
|
|
|
|
+ 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)
|
|
|
|
+ .orderByAsc(ExamTask::getPaperNumber);
|
|
|
|
+ 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("题卡为空");
|
|
|
|
+ }
|
|
|
|
+ QueryWrapper<ExamCardDetail> examCardDetailQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ examCardDetailQueryWrapper.lambda().eq(ExamCardDetail::getCardId, examCard.getId());
|
|
|
|
+ List<ExamCardDetail> examCardDetailList = examCardDetailService.list(examCardDetailQueryWrapper);
|
|
|
|
+
|
|
|
|
+ //拼装key
|
|
|
|
+ String key = examDetail.getSchoolId()
|
|
|
|
+ + "_" + examDetail.getExamStartTime()
|
|
|
|
+ + "_" + examDetail.getExamEndTime()
|
|
|
|
+ + "_" + examDetailCourse.getCourseCode()
|
|
|
|
+ + "_" + examDetailCourse.getPaperNumber();
|
|
|
|
+ String paperType = null;
|
|
|
|
+ if (Objects.nonNull(paperTypeParam)) {
|
|
|
|
+ paperType = paperTypeParam;
|
|
|
|
+ CreatePdfCacheUtil.setPaperType(key, paperType);
|
|
|
|
+ } else {
|
|
|
|
+ paperType = createPdfUtil.getPaperType(examPrintPlan, examTaskDetail, key);//抽取卷型
|
|
|
|
+ }
|
|
|
|
+ examTaskDetail.setRelatePaperType(paperType);
|
|
|
|
+ examDetailCourse.setPaperType(paperType);
|
|
|
|
|
|
- BasicExamRule basicExamRule = basicExamRuleService.getBySchoolId(schoolId);
|
|
|
|
- if (Objects.isNull(basicExamRule)) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("考务规则为空");
|
|
|
|
- }
|
|
|
|
|
|
+ PaperPdfDto paperPdfDto = createPdfUtil.getPaperPdfFile(paperType, examTaskDetail);
|
|
|
|
|
|
- //查询examDetail
|
|
|
|
- QueryWrapper<ExamDetail> examDetailQueryWrapper = new QueryWrapper<>();
|
|
|
|
- examDetailQueryWrapper.lambda().eq(ExamDetail::getSchoolId, sysUser.getSchoolId())
|
|
|
|
- .eq(ExamDetail::getPrintPlanId, tbTask.getPrintPlanId());
|
|
|
|
- if (Objects.nonNull(examDetailId)) {
|
|
|
|
- examDetailQueryWrapper.lambda().eq(ExamDetail::getId, examDetailId);
|
|
|
|
- } else if (Objects.nonNull(examDetailIds)) {
|
|
|
|
- examDetailQueryWrapper.lambda().in(ExamDetail::getId, examDetailIds);
|
|
|
|
- }
|
|
|
|
- List<ExamDetail> examDetailList = detailService.list(examDetailQueryWrapper);
|
|
|
|
- if (Objects.isNull(examDetailList) || examDetailList.size() == 0) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("考务计划为空");
|
|
|
|
- }
|
|
|
|
- map.computeIfAbsent("examDetailList", v -> examDetailList);
|
|
|
|
- map.computeIfAbsent("examDetailCourseIds", v -> examDetailCourseIds);
|
|
|
|
- map.computeIfAbsent("examPrintPlan", v -> examPrintPlan);
|
|
|
|
- map.computeIfAbsent("basicExamRule", v -> basicExamRule);
|
|
|
|
- return map;
|
|
|
|
- }
|
|
|
|
|
|
+ //获取试卷pdf
|
|
|
|
+ PdfDto pdfDto = createPdfUtil.getPaperPdf(paperPdfDto, examPrintPlan.getBackupCount(), backupPaperTempPdfList);
|
|
|
|
+ examDetailCourse.setPaperPagesA3(Objects.nonNull(pdfDto) ? pdfDto.getPageCount() : examDetailCourse.getPaperPagesA3());
|
|
|
|
+ list[1].addAll(backupPaperTempPdfList);
|
|
|
|
|
|
- /**
|
|
|
|
- * 查询考场科目
|
|
|
|
- *
|
|
|
|
- * @param tbTask
|
|
|
|
- * @param examDetail
|
|
|
|
- * @param examDetailCourseIds
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- public List<ExamDetailCourse> selectExamDetailCourse(TBTask tbTask, ExamDetail examDetail, List<Long> examDetailCourseIds) {
|
|
|
|
- tbTask.setObjName(examDetail.getExamRoom() + "-" + examDetail.getExamPlace());
|
|
|
|
- QueryWrapper<ExamDetailCourse> examDetailCourseQueryWrapper = new QueryWrapper<>();
|
|
|
|
- if (Objects.nonNull(examDetailCourseIds) && examDetailCourseIds.size() > 0) {
|
|
|
|
- examDetailCourseQueryWrapper.lambda().in(ExamDetailCourse::getId, examDetailCourseIds);
|
|
|
|
- } else {
|
|
|
|
- examDetailCourseQueryWrapper.lambda().eq(ExamDetailCourse::getExamDetailId, examDetail.getId());
|
|
|
|
- }
|
|
|
|
- return detailCourseService.list(examDetailCourseQueryWrapper);
|
|
|
|
- }
|
|
|
|
|
|
+ basicAttachmentList = Objects.isNull(basicAttachmentList) ? basicAttachmentList = new ArrayList<>() : basicAttachmentList;
|
|
|
|
+ for (ExamCardDetail examCardDetail : examCardDetailList) {
|
|
|
|
+ createPdfUtil.getCardAttachmentId(examCardDetail, attachmentIds);
|
|
|
|
|
|
- /**
|
|
|
|
- * 创建普通印品
|
|
|
|
- *
|
|
|
|
- * @param examPrintPlan
|
|
|
|
- * @param examDetail
|
|
|
|
- * @param ordinaryPdfList
|
|
|
|
- */
|
|
|
|
- public void createCheckIn(ExamPrintPlan examPrintPlan, ExamDetail examDetail, List<PdfDto> ordinaryPdfList) throws IOException, DocumentException {
|
|
|
|
- if (Objects.nonNull(examPrintPlan.getOrdinaryContent())) {
|
|
|
|
- //获取普通印品
|
|
|
|
- JSONArray jsonArrayOrdinary = JSONArray.parseArray(examPrintPlan.getOrdinaryContent());
|
|
|
|
- for (int i = 0; i < jsonArrayOrdinary.size(); i++) {
|
|
|
|
- JSONObject jsonObjectOrdinary = jsonArrayOrdinary.getJSONObject(i);
|
|
|
|
- if (Objects.nonNull(jsonObjectOrdinary.get("attachmentId")) && !Objects.equals("", jsonObjectOrdinary.get("attachmentId"))) {
|
|
|
|
- Long attachmentId = Long.parseLong((String) jsonObjectOrdinary.get("attachmentId"));
|
|
|
|
- BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
|
|
|
|
- createPdfUtil.createCheckIn(examDetail, basicAttachment, ordinaryPdfList, (Integer) jsonObjectOrdinary.get("backupCount"));
|
|
|
|
|
|
+ //把模板页面上的 ${} 替换成实际内容
|
|
|
|
+ String cardContent = createPdfUtil.replaceHtmlTemplete(examCardDetail);
|
|
|
|
+ String studentContent = cardContent;
|
|
|
|
+
|
|
|
|
+ for (int i = 1; i <= examPrintPlan.getBackupCount(); i++) {
|
|
|
|
+ BasicAttachment basicAttachment = createPdfUtil.cardHtml(String.format("%02d", i), cardContent, examDetail, examDetailCourse, examCard, jsonArray, sysUser.getId(), cardPdfTempList);
|
|
|
|
+ examDetailCourse.setCardPagesA3(basicAttachment.getPages());
|
|
|
|
+ basicAttachmentList.add(basicAttachment);
|
|
|
|
+ }
|
|
|
|
+ list[2].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");
|
|
|
|
+ if (Objects.nonNull(jsonObjectVariable.get("attachmentId")) && !Objects.equals("", jsonObjectVariable.get("attachmentId"))) {
|
|
|
|
+ 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(), examDetail, examDetailCourse, examStudentList, list[3], (Integer) jsonObjectVariable.get("backupCount"));
|
|
|
|
+ } else if (Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "PACKAGE")) {//卷袋贴
|
|
|
|
+ if (Objects.nonNull(pdfDto)) {
|
|
|
|
+ createPdfUtil.createPaperPackage(pdfDto.isTag(), basicAttachment, basicSchool.getName(), examDetail, examDetailCourse, examStudentList, list[3], (Integer) jsonObjectVariable.get("backupCount"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Collections.sort(list[3], new Comparator<PdfDto>() {
|
|
|
|
+ @Override
|
|
|
|
+ public int compare(PdfDto o1, PdfDto o2) {
|
|
|
|
+ return o1.getSequence() > o2.getSequence() ? 1 : -1;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ for (ExamStudent t : examStudentList) {
|
|
|
|
+ if (Objects.nonNull(pdfDto)) {
|
|
|
|
+ createPdfUtil.getExamStudentPaperPdf(paperPdfDto, paperPdfTempList);
|
|
|
|
+ }
|
|
|
|
+ basicAttachmentList.add(createPdfUtil.examStudentHtml(attachmentIds, studentContent, t, examDetail, examDetailCourse, sysUser.getId(), examStudentTempPdfList));
|
|
|
|
+ }
|
|
|
|
+ list[4].addAll(paperPdfTempList);
|
|
|
|
+ list[5].addAll(examStudentTempPdfList);
|
|
|
|
+ examStudentService.saveOrUpdateBatch(examStudentList);
|
|
|
|
+ jsonObject.put("card", jsonArray);
|
|
|
|
+ examCardDetail.setAttachmentId(jsonObject.toJSONString());
|
|
|
|
+ }
|
|
|
|
+ examCardDetailService.saveOrUpdateBatch(examCardDetailList);
|
|
}
|
|
}
|
|
|
|
+ examTaskDetailService.saveOrUpdateBatch(examTaskDetailList);
|
|
}
|
|
}
|
|
|
|
+ detailCourseService.saveOrUpdateBatch(examDetailCourseList);
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 查询examTask
|
|
|
|
- *
|
|
|
|
- * @param sysUser
|
|
|
|
- * @param examDetailCourse
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- public List<ExamTask> selectExamTask(SysUser sysUser, ExamDetailCourse examDetailCourse) {
|
|
|
|
- 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)
|
|
|
|
- .orderByAsc(ExamTask::getPaperNumber);
|
|
|
|
- List<ExamTask> examTaskList = examTaskService.list(examTaskQueryWrapper);
|
|
|
|
- if (Objects.isNull(examTaskList) || examTaskList.size() == 0) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("命题任务为空");
|
|
|
|
- }
|
|
|
|
- return examTaskList;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 查询examTaskDetail
|
|
|
|
- *
|
|
|
|
- * @param examTaskIds
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- public List<ExamTaskDetail> selectExamTaskDetail(Set<Long> examTaskIds) {
|
|
|
|
- QueryWrapper<ExamTaskDetail> examTaskDetailQueryWrapper = new QueryWrapper<>();
|
|
|
|
- examTaskDetailQueryWrapper.lambda().in(ExamTaskDetail::getExamTaskId, examTaskIds)
|
|
|
|
- .eq(ExamTaskDetail::getEnable, true);
|
|
|
|
- return examTaskDetailService.list(examTaskDetailQueryWrapper);
|
|
|
|
|
|
+ return basicAttachmentList;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -290,156 +341,82 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
|
|
+// @Transactional
|
|
public Map<String, Object> executeCreatePdfLogic(Map<String, Object> map) throws IOException {
|
|
public Map<String, Object> executeCreatePdfLogic(Map<String, Object> map) throws IOException {
|
|
List<BasicAttachment> basicAttachmentList = null;
|
|
List<BasicAttachment> basicAttachmentList = null;
|
|
- map = createPdfSelectData(map);
|
|
|
|
- TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
|
|
|
|
- SysUser sysUser = (SysUser) map.get(SystemConstant.USER);
|
|
|
|
- String paperTypeParam = Objects.nonNull(map.get("paperType")) ? (String) map.get("paperType") : null;
|
|
|
|
- List<ExamDetail> examDetailList = (List<ExamDetail>) map.get("examDetailList");
|
|
|
|
- List<Long> examDetailCourseIds = (List<Long>) map.get("examDetailCourseIds");
|
|
|
|
- ExamPrintPlan examPrintPlan = (ExamPrintPlan) map.get("examPrintPlan");
|
|
|
|
- BasicExamRule basicExamRule = (BasicExamRule) map.get("basicExamRule");
|
|
|
|
- //这里为保存附件html的逻辑
|
|
|
|
- //查询题卡详情是否有附件id,有的话则把以前的附件删除
|
|
|
|
- Set<Long> attachmentIds = new HashSet<>();
|
|
|
|
- Set<File> ftlList = new HashSet<>();
|
|
|
|
- BasicSchool basicSchool = cacheService.schoolCache(examPrintPlan.getSchoolId());
|
|
|
|
try {
|
|
try {
|
|
- for (ExamDetail examDetail : examDetailList) {
|
|
|
|
- //查询examDetailCourse
|
|
|
|
- List<ExamDetailCourse> examDetailCourseList = selectExamDetailCourse(tbTask, examDetail, examDetailCourseIds);
|
|
|
|
- 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<>();//备份题卡
|
|
|
|
-
|
|
|
|
- for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
|
|
|
|
- //获取普通印品
|
|
|
|
- createCheckIn(examPrintPlan, examDetail, ordinaryPdfList);
|
|
|
|
-
|
|
|
|
- List<PdfDto> paperPdfTempList = new ArrayList<>();//所有试卷
|
|
|
|
- List<PdfDto> examStudentTempPdfList = new ArrayList<>();//所有题卡
|
|
|
|
- List<PdfDto> backupPaperTempPdfList = new ArrayList<>();//备份试卷
|
|
|
|
- List<PdfDto> cardPdfTempList = new ArrayList<>();//备份题卡
|
|
|
|
-
|
|
|
|
- //查询试卷
|
|
|
|
- List<ExamTask> examTaskList = selectExamTask(sysUser, examDetailCourse);
|
|
|
|
- //查询任务明细
|
|
|
|
- List<ExamTaskDetail> examTaskDetailList = selectExamTaskDetail(examTaskList.stream().map(s -> s.getId()).collect(Collectors.toSet()));
|
|
|
|
-
|
|
|
|
- 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);
|
|
|
|
-
|
|
|
|
- //拼装key
|
|
|
|
- String key = examDetail.getSchoolId()
|
|
|
|
- + "_" + examDetail.getExamStartTime()
|
|
|
|
- + "_" + examDetail.getExamEndTime()
|
|
|
|
- + "_" + examDetailCourse.getCourseCode()
|
|
|
|
- + "_" + examDetailCourse.getPaperNumber();
|
|
|
|
- String paperType = null;
|
|
|
|
- if (Objects.nonNull(paperTypeParam)) {
|
|
|
|
- paperType = paperTypeParam;
|
|
|
|
- CreatePdfCacheUtil.setPaperType(key, paperType);
|
|
|
|
- } else {
|
|
|
|
- paperType = createPdfUtil.getPaperType(examPrintPlan, examTaskDetail, key);//抽取卷型
|
|
|
|
- }
|
|
|
|
- examTaskDetail.setRelatePaperType(paperType);
|
|
|
|
- examDetailCourse.setPaperType(paperType);
|
|
|
|
-
|
|
|
|
- PaperPdfDto paperPdfDto = createPdfUtil.getPaperPdfFile(paperType, examTaskDetail);
|
|
|
|
-
|
|
|
|
- //获取试卷pdf
|
|
|
|
- PdfDto pdfDto = createPdfUtil.getPaperPdf(paperPdfDto, examPrintPlan.getBackupCount(), backupPaperTempPdfList);
|
|
|
|
- examDetailCourse.setPaperPagesA3(Objects.nonNull(pdfDto) ? pdfDto.getPageCount() : examDetailCourse.getPaperPagesA3());
|
|
|
|
- backupPaperPdfList.addAll(backupPaperTempPdfList);
|
|
|
|
-
|
|
|
|
- basicAttachmentList = Objects.isNull(basicAttachmentList) ? basicAttachmentList = new ArrayList<>() : basicAttachmentList;
|
|
|
|
- for (ExamCardDetail examCardDetail : examCardDetailList) {
|
|
|
|
- createPdfUtil.getCardAttachmentId(examCardDetail, attachmentIds);
|
|
|
|
-
|
|
|
|
- //把模板页面上的 ${} 替换成实际内容
|
|
|
|
- String cardContent = createPdfUtil.replaceHtmlTemplete(examCardDetail);
|
|
|
|
- String studentContent = cardContent;
|
|
|
|
-
|
|
|
|
- for (int i = 1; i <= examPrintPlan.getBackupCount(); i++) {
|
|
|
|
- BasicAttachment basicAttachment = createPdfUtil.cardHtml(String.format("%02d", i), cardContent, examDetail, examDetailCourse, examCard, jsonArray, sysUser.getId(), cardPdfTempList);
|
|
|
|
- examDetailCourse.setCardPagesA3(basicAttachment.getPages());
|
|
|
|
- basicAttachmentList.add(basicAttachment);
|
|
|
|
- }
|
|
|
|
- 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");
|
|
|
|
- if (Objects.nonNull(jsonObjectVariable.get("attachmentId")) && !Objects.equals("", jsonObjectVariable.get("attachmentId"))) {
|
|
|
|
- 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(), examDetail, examDetailCourse, examStudentList, variablePdfList, (Integer) jsonObjectVariable.get("backupCount"));
|
|
|
|
- } else if (Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "PACKAGE")) {//卷袋贴
|
|
|
|
- if (Objects.nonNull(pdfDto)) {
|
|
|
|
- createPdfUtil.createPaperPackage(pdfDto.isTag(), basicAttachment, basicSchool.getName(), examDetail, examDetailCourse, examStudentList, variablePdfList, (Integer) jsonObjectVariable.get("backupCount"));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
|
|
|
|
+ SysUser sysUser = (SysUser) map.get(SystemConstant.USER);
|
|
|
|
+ Long examDetailId = tbTask.getEntityId();
|
|
|
|
+ List<Long> examDetailIds = Objects.nonNull(map.get("examDetailIds")) ? (List<Long>) map.get("examDetailIds") : null;
|
|
|
|
+ Long schoolId = tbTask.getSchoolId();
|
|
|
|
+ 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;
|
|
|
|
+
|
|
|
|
+ //查询printPlan
|
|
|
|
+ ExamPrintPlan examPrintPlan = examPrintPlanService.getById(tbTask.getPrintPlanId());
|
|
|
|
+ if (Objects.isNull(examPrintPlan)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("印刷计划为空");
|
|
|
|
+ }
|
|
|
|
|
|
- Collections.sort(variablePdfList, new Comparator<PdfDto>() {
|
|
|
|
- @Override
|
|
|
|
- public int compare(PdfDto o1, PdfDto o2) {
|
|
|
|
- return o1.getSequence() > o2.getSequence() ? 1 : -1;
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ BasicSchool basicSchool = cacheService.schoolCache(examPrintPlan.getSchoolId());
|
|
|
|
+ BasicExamRule basicExamRule = basicExamRuleService.getBySchoolId(schoolId);
|
|
|
|
+ if (Objects.isNull(basicExamRule)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("考务规则为空");
|
|
|
|
+ }
|
|
|
|
|
|
- for (ExamStudent t : examStudentList) {
|
|
|
|
- if (Objects.nonNull(pdfDto)) {
|
|
|
|
- createPdfUtil.getExamStudentPaperPdf(paperPdfDto, paperPdfTempList);
|
|
|
|
- }
|
|
|
|
- basicAttachmentList.add(createPdfUtil.examStudentHtml(attachmentIds, studentContent, t, examDetail, examDetailCourse, sysUser.getId(), examStudentTempPdfList));
|
|
|
|
- }
|
|
|
|
- paperPdfList.addAll(paperPdfTempList);
|
|
|
|
- examStudentPdfList.addAll(examStudentTempPdfList);
|
|
|
|
-// examStudentService.saveOrUpdateBatch(examStudentList);
|
|
|
|
- jsonObject.put("card", jsonArray);
|
|
|
|
- examCardDetail.setAttachmentId(jsonObject.toJSONString());
|
|
|
|
- }
|
|
|
|
- examCardDetailService.saveOrUpdateBatch(examCardDetailList);
|
|
|
|
- }
|
|
|
|
- examTaskDetailService.saveOrUpdateBatch(examTaskDetailList);
|
|
|
|
- }
|
|
|
|
- detailCourseService.saveOrUpdateBatch(examDetailCourseList);
|
|
|
|
- //合并pdf
|
|
|
|
- basicAttachmentList.add(createPdfUtil.mergePdf(basicExamRule, tbTask, examDetail, sysUser.getId(), tbTask.getSchoolId(), variablePdfList, ordinaryPdfList, paperPdfList, examStudentPdfList, backupPaperPdfList, cardPdfList));
|
|
|
|
- }
|
|
|
|
|
|
+ //查询examDetail
|
|
|
|
+ QueryWrapper<ExamDetail> examDetailQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ examDetailQueryWrapper.lambda().eq(ExamDetail::getSchoolId, sysUser.getSchoolId())
|
|
|
|
+ .eq(ExamDetail::getPrintPlanId, tbTask.getPrintPlanId());
|
|
|
|
+ if (Objects.nonNull(examDetailId)) {
|
|
|
|
+ examDetailQueryWrapper.lambda().eq(ExamDetail::getId, examDetailId);
|
|
|
|
+ } else if (Objects.nonNull(examDetailIds)) {
|
|
|
|
+ examDetailQueryWrapper.lambda().in(ExamDetail::getId, examDetailIds);
|
|
}
|
|
}
|
|
- if (PrintMethodEnum.AUTO == basicExamRule.getPrintMethod()) {
|
|
|
|
- examPrintPlan.setStatus(PrintPlanStatusEnum.PRINTING);
|
|
|
|
- examPrintPlanService.updateById(examPrintPlan);
|
|
|
|
|
|
+ List<ExamDetail> examDetailList = detailService.list(examDetailQueryWrapper);
|
|
|
|
+ if (Objects.isNull(examDetailList) || examDetailList.size() == 0) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("考务计划为空");
|
|
}
|
|
}
|
|
|
|
+ Set<Long> attachmentIds = new HashSet<>();
|
|
|
|
+ Set<File> ftlList = new HashSet<>();
|
|
|
|
+ for (ExamDetail examDetail : examDetailList) {
|
|
|
|
+ tbTask.setObjName(examDetail.getExamRoom() + "-" + examDetail.getExamPlace());
|
|
|
|
+ //查询examDetailCourse
|
|
|
|
+ QueryWrapper<ExamDetailCourse> examDetailCourseQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ 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<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<>();//备份题卡
|
|
|
|
+
|
|
|
|
+ //创建pdf核心逻辑
|
|
|
|
+ basicAttachmentList = createPdfCoreLogic(examDetailCourseList,
|
|
|
|
+ examPrintPlan,
|
|
|
|
+ examDetail,
|
|
|
|
+ sysUser,
|
|
|
|
+ paperTypeParam,
|
|
|
|
+ basicAttachmentList,
|
|
|
|
+ attachmentIds,
|
|
|
|
+ ftlList,
|
|
|
|
+ basicSchool,
|
|
|
|
+ ordinaryPdfList,
|
|
|
|
+ backupPaperPdfList,
|
|
|
|
+ cardPdfList,
|
|
|
|
+ variablePdfList,
|
|
|
|
+ paperPdfList,
|
|
|
|
+ examStudentPdfList);
|
|
|
|
+ //合并pdf
|
|
|
|
+ basicAttachmentList.add(createPdfUtil.mergePdf(basicExamRule, tbTask, examDetail, sysUser.getId(), variablePdfList, ordinaryPdfList, paperPdfList, examStudentPdfList, backupPaperPdfList, cardPdfList));
|
|
|
|
+ }
|
|
|
|
+ updateExamPrintPlan(basicExamRule, examPrintPlan);
|
|
map.computeIfAbsent("size", v -> examDetailList.size());
|
|
map.computeIfAbsent("size", v -> examDetailList.size());
|
|
//最后一步删除附件
|
|
//最后一步删除附件
|
|
// createPdfUtil.deleteAttachment(attachmentIds, ftlList);
|
|
// createPdfUtil.deleteAttachment(attachmentIds, ftlList);
|
|
@@ -455,6 +432,20 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
return map;
|
|
return map;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 更新考试计划
|
|
|
|
+ *
|
|
|
|
+ * @param basicExamRule
|
|
|
|
+ * @param examPrintPlan
|
|
|
|
+ */
|
|
|
|
+ @Transactional
|
|
|
|
+ public void updateExamPrintPlan(BasicExamRule basicExamRule, ExamPrintPlan examPrintPlan) {
|
|
|
|
+ if (PrintMethodEnum.AUTO == basicExamRule.getPrintMethod()) {
|
|
|
|
+ examPrintPlan.setStatus(PrintPlanStatusEnum.PRINTING);
|
|
|
|
+ examPrintPlanService.updateById(examPrintPlan);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Override
|
|
@Override
|
|
public Map<String, Object> executeExaminationLogic(Map<String, Object> map) throws Exception {
|
|
public Map<String, Object> executeExaminationLogic(Map<String, Object> map) throws Exception {
|