|
@@ -202,10 +202,11 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
} else if (Objects.nonNull(examDetailIds)) {
|
|
} else if (Objects.nonNull(examDetailIds)) {
|
|
examDetailQueryWrapper.lambda().in(ExamDetail::getId, examDetailIds);
|
|
examDetailQueryWrapper.lambda().in(ExamDetail::getId, examDetailIds);
|
|
}
|
|
}
|
|
- examDetailQueryWrapper.lambda().set(ExamDetail::getStatus, ExamDetailStatusEnum.NEW)
|
|
|
|
|
|
+ examDetailQueryWrapper.lambda().set(ExamDetail::getStatus, ExamDetailStatusEnum.CREATING)
|
|
.set(ExamDetail::getAttachmentPath, null);
|
|
.set(ExamDetail::getAttachmentPath, null);
|
|
examDetailService.update(examDetailQueryWrapper);
|
|
examDetailService.update(examDetailQueryWrapper);
|
|
|
|
|
|
|
|
+ // todo 是否在这里校验???
|
|
//所有考场都撤回,印刷任务状态改为就绪
|
|
//所有考场都撤回,印刷任务状态改为就绪
|
|
QueryWrapper<ExamDetail> queryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<ExamDetail> queryWrapper = new QueryWrapper<>();
|
|
queryWrapper.lambda().eq(ExamDetail::getPrintPlanId, tbTask.getPrintPlanId())
|
|
queryWrapper.lambda().eq(ExamDetail::getPrintPlanId, tbTask.getPrintPlanId())
|
|
@@ -243,240 +244,206 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
List<File> fileTempList,
|
|
List<File> fileTempList,
|
|
List<PdfDto>... list
|
|
List<PdfDto>... list
|
|
) throws Exception {
|
|
) throws Exception {
|
|
- if (Objects.nonNull(examDetailCourseList) && examDetailCourseList.size() > 0) {
|
|
|
|
- Map<Long, BasicCardRule> basicCardRuleMap = new HashMap<>();
|
|
|
|
- for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
|
|
|
|
- List<PdfDto> studentPaperPdfList = new ArrayList<>();//所有试卷
|
|
|
|
- List<PdfDto> studentCardPdfList = new ArrayList<>();//所有题卡
|
|
|
|
- List<PdfDto> backupPaperPdfList = new ArrayList<>();//备份试卷
|
|
|
|
- List<PdfDto> backupCardPdfList = new ArrayList<>();//备份题卡
|
|
|
|
|
|
+ for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
|
|
|
|
+ List<PdfDto> studentPaperPdfList = new ArrayList<>();//所有试卷
|
|
|
|
+ List<PdfDto> studentCardPdfList = new ArrayList<>();//所有题卡
|
|
|
|
+ List<PdfDto> backupPaperPdfList = new ArrayList<>();//备份试卷
|
|
|
|
+ List<PdfDto> backupCardPdfList = new ArrayList<>();//备份题卡
|
|
|
|
|
|
- List<ExamDetailCoursePaperType> examDetailCoursePaperTypes = new ArrayList<>();
|
|
|
|
|
|
+ List<ExamDetailCoursePaperType> examDetailCoursePaperTypes = new ArrayList<>();
|
|
|
|
|
|
- String printContent = examPrintPlan.getPrintContent();
|
|
|
|
- if (StringUtils.isBlank(printContent)) {
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
- //查询试卷
|
|
|
|
- List<ExamTask> examTaskList = examTaskService.findByFlowStatus(sysUser.getSchoolId(), examPrintPlan.getExamId(), examDetailCourse.getCourseCode(), examDetailCourse.getCourseName(), examDetailCourse.getPaperNumber(), FlowStatusEnum.FINISH);
|
|
|
|
- if (Objects.isNull(examTaskList) || examTaskList.size() == 0) {
|
|
|
|
- throw ExceptionResultEnum.EXAM_TASK_IS_NULL.exception();
|
|
|
|
- }
|
|
|
|
- Set<Long> examTaskIds = examTaskList.stream().map(ExamTask::getId).collect(Collectors.toSet());
|
|
|
|
- Map<Long, ExamTask> examTaskMap = examTaskList.stream().collect(Collectors.toMap(ExamTask::getId, Function.identity(), (dto1, dto2) -> dto1));
|
|
|
|
-
|
|
|
|
- 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();
|
|
|
|
- JSONArray stuJsonArray = new JSONArray();
|
|
|
|
- Map<String, ExamCard> examCardMap = new HashMap<>();
|
|
|
|
- for (ExamTaskDetail examTaskDetail : examTaskDetailList) {
|
|
|
|
- JSONArray jsonArrayPaper = JSONArray.parseArray(examTaskDetail.getPaperAttachmentIds());
|
|
|
|
- ExamCard examCard = null;
|
|
|
|
- for (int i = 0; i < jsonArrayPaper.size(); i++) {
|
|
|
|
- JSONObject object = jsonArrayPaper.getJSONObject(i);
|
|
|
|
- if (Objects.nonNull(object.get("cardId")) && !Objects.equals("", object.get("cardId"))) {
|
|
|
|
- examCard = examCardService.getById(Long.parseLong((String) object.get("cardId")));
|
|
|
|
- if (Objects.isNull(examCard)) {
|
|
|
|
- throw ExceptionResultEnum.EXAM_CARD_IS_NULL.exception();
|
|
|
|
- }
|
|
|
|
- examCardMap.put((String) object.get("name"), examCard);
|
|
|
|
- }
|
|
|
|
|
|
+ String printContent = examPrintPlan.getPrintContent();
|
|
|
|
+ if (StringUtils.isBlank(printContent)) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ //查询命题任务绑定的试卷和题卡
|
|
|
|
+ ExamTask examTask = examTaskService.findExamTaskByFlowStatus(sysUser.getSchoolId(), examPrintPlan.getExamId(), examDetailCourse.getCourseCode(), examDetailCourse.getPaperNumber(), FlowStatusEnum.FINISH);
|
|
|
|
+ ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamTaskId(examTask.getId());
|
|
|
|
+
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
|
+ JSONArray stuJsonArray = new JSONArray();
|
|
|
|
+ Map<String, ExamCard> examCardMap = new HashMap<>();
|
|
|
|
+ JSONArray jsonArrayPaper = JSONArray.parseArray(examTaskDetail.getPaperAttachmentIds());
|
|
|
|
+ ExamCard examCard;
|
|
|
|
+ for (int i = 0; i < jsonArrayPaper.size(); i++) {
|
|
|
|
+ JSONObject object = jsonArrayPaper.getJSONObject(i);
|
|
|
|
+ if (Objects.nonNull(object.get("cardId")) && !Objects.equals("", object.get("cardId"))) {
|
|
|
|
+ examCard = examCardService.getById(Long.parseLong((String) object.get("cardId")));
|
|
|
|
+ if (Objects.isNull(examCard)) {
|
|
|
|
+ throw ExceptionResultEnum.EXAM_CARD_IS_NULL.exception();
|
|
}
|
|
}
|
|
|
|
+ examCardMap.put((String) object.get("name"), examCard);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- ExamTask examTask = examTaskMap.get(examTaskDetail.getExamTaskId());
|
|
|
|
|
|
+ //查询题卡规则
|
|
|
|
+ BasicCardRule basicCardRule = basicCardRuleService.getById(examTask.getCardRuleId());
|
|
|
|
|
|
- //查询题卡规则
|
|
|
|
- BasicCardRule basicCardRule = null;
|
|
|
|
- if (!basicCardRuleMap.containsKey(examTask.getCardRuleId())) {
|
|
|
|
- basicCardRule = basicCardRuleService.getById(examTask.getCardRuleId());
|
|
|
|
- BasicCardRule finalBasicCardRule = basicCardRule;
|
|
|
|
- basicCardRuleMap.computeIfAbsent(examTask.getCardRuleId(), v -> finalBasicCardRule);
|
|
|
|
- } else {
|
|
|
|
- basicCardRule = basicCardRuleMap.get(examTask.getCardRuleId());
|
|
|
|
- }
|
|
|
|
|
|
+ //试卷编号本考场使用卷型key
|
|
|
|
+ StringJoiner stringJoiner = new StringJoiner("_");
|
|
|
|
+ stringJoiner.add(String.valueOf(examPrintPlan.getExamId())).add(examDetailCourse.getPaperNumber()).add(String.valueOf(examDetail.getExamStartTime())).add(String.valueOf(examDetail.getExamEndTime()));
|
|
|
|
+ String key = stringJoiner.toString();
|
|
|
|
|
|
- //拼装key
|
|
|
|
- StringJoiner stringJoiner = new StringJoiner("_");
|
|
|
|
- stringJoiner.add(String.valueOf(examPrintPlan.getId()))
|
|
|
|
- .add(examDetailCourse.getPaperNumber())
|
|
|
|
- .add(String.valueOf(examDetail.getExamStartTime()))
|
|
|
|
- .add(String.valueOf(examDetail.getExamEndTime()));
|
|
|
|
- String key = stringJoiner.toString();
|
|
|
|
-
|
|
|
|
- String paperType;
|
|
|
|
- if (Objects.nonNull(paperTypeParam)) {
|
|
|
|
- paperType = paperTypeParam;
|
|
|
|
- CreatePdfCacheUtil.setPaperType(key, paperType);
|
|
|
|
- } else {
|
|
|
|
- paperType = createPdfUtil.getPaperType(examPrintPlan.getDrawRule(), examTaskDetail, key);//抽取卷型
|
|
|
|
- }
|
|
|
|
- //查询考生
|
|
|
|
- QueryWrapper<ExamStudent> examStudentQueryWrapper = new QueryWrapper<>();
|
|
|
|
- examStudentQueryWrapper.lambda().eq(ExamStudent::getExamDetailCourseId, examDetailCourse.getId());
|
|
|
|
- List<ExamStudent> examStudentList = examStudentService.list(examStudentQueryWrapper);
|
|
|
|
-
|
|
|
|
- List<String> paperTypes = Arrays.stream(paperType.split(",")).sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList());
|
|
|
|
- int backupCount = SystemConstant.calcBackupCount(examDetail.getBackupCount(), examDetail.getTotalSubjects(), 1);
|
|
|
|
-
|
|
|
|
- // 当前关联试卷类型
|
|
|
|
- List<String> relatePaperTypes = new ArrayList<>();
|
|
|
|
-// if (StringUtils.isNotBlank(examTaskDetail.getRelatePaperType())) {
|
|
|
|
-// String[] strings = examTaskDetail.getRelatePaperType().split(",");
|
|
|
|
-// if (strings.length > 0) {
|
|
|
|
-// relatePaperTypes.addAll(Arrays.asList(strings));
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
- // 考生实际关联试卷类型
|
|
|
|
- List<String> studentPaperTypes = new ArrayList<>();
|
|
|
|
- if (examStudentList != null && !examStudentList.isEmpty()) {
|
|
|
|
- AtomicInteger atomicInteger = new AtomicInteger(0);
|
|
|
|
- for (ExamStudent t : examStudentList) {
|
|
|
|
- int i1 = atomicInteger.getAndIncrement();
|
|
|
|
- int mod = i1 % examTaskDetail.getDrawCount();
|
|
|
|
- t.setPaperType(paperTypes.get(mod));
|
|
|
|
- if (!relatePaperTypes.contains(t.getPaperType())) {
|
|
|
|
- relatePaperTypes.add(t.getPaperType());
|
|
|
|
- }
|
|
|
|
- if (!studentPaperTypes.contains(t.getPaperType())) {
|
|
|
|
- studentPaperTypes.add(t.getPaperType());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- relatePaperTypes.addAll(paperTypes);
|
|
|
|
- studentPaperTypes.addAll(paperTypes);
|
|
|
|
|
|
+ //抽取卷型
|
|
|
|
+ String paperType;
|
|
|
|
+ if (Objects.nonNull(paperTypeParam)) {
|
|
|
|
+ paperType = paperTypeParam;
|
|
|
|
+ CreatePdfCacheUtil.setPaperType(key, paperType);
|
|
|
|
+ } else {
|
|
|
|
+ paperType = createPdfUtil.getPaperType(examPrintPlan.getDrawRule(), examTaskDetail, key);
|
|
|
|
+ }
|
|
|
|
+ //查询考生
|
|
|
|
+ QueryWrapper<ExamStudent> examStudentQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ examStudentQueryWrapper.lambda().eq(ExamStudent::getExamDetailCourseId, examDetailCourse.getId());
|
|
|
|
+ List<ExamStudent> examStudentList = examStudentService.list(examStudentQueryWrapper);
|
|
|
|
+
|
|
|
|
+ List<String> paperTypes = Arrays.stream(paperType.split(",")).sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList());
|
|
|
|
+ // 计算备份数量,默认最小为1份。
|
|
|
|
+ int backupCount = SystemConstant.calcBackupCount(examDetail.getBackupCount(), examDetail.getTotalSubjects(), 1);
|
|
|
|
+
|
|
|
|
+ // 当前关联试卷类型
|
|
|
|
+ List<String> relatePaperTypes = new ArrayList<>();
|
|
|
|
+ // 考生实际关联试卷类型
|
|
|
|
+ if (!CollectionUtils.isEmpty(examStudentList)) {
|
|
|
|
+ AtomicInteger atomicInteger = new AtomicInteger(0);
|
|
|
|
+ for (ExamStudent t : examStudentList) {
|
|
|
|
+ int i1 = atomicInteger.getAndIncrement();
|
|
|
|
+ int mod = i1 % examTaskDetail.getDrawCount();
|
|
|
|
+ t.setPaperType(paperTypes.get(mod));
|
|
|
|
+ if (!relatePaperTypes.contains(t.getPaperType())) {
|
|
|
|
+ relatePaperTypes.add(t.getPaperType());
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ relatePaperTypes.addAll(paperTypes);
|
|
|
|
+ }
|
|
|
|
|
|
- examTaskDetail.setRelatePaperType(String.join(",", relatePaperTypes));
|
|
|
|
- examDetailCourse.setPaperType(String.join(",", studentPaperTypes));
|
|
|
|
-
|
|
|
|
- studentPaperTypes.forEach(m -> {
|
|
|
|
- ExamDetailCoursePaperType examDetailCoursePaperType = new ExamDetailCoursePaperType();
|
|
|
|
- examDetailCoursePaperType.setId(SystemConstant.getDbUuid());
|
|
|
|
- examDetailCoursePaperType.setExamDetailCourseId(examDetailCourse.getId());
|
|
|
|
- examDetailCoursePaperType.setPaperType(m);
|
|
|
|
- examDetailCoursePaperTypes.add(examDetailCoursePaperType);
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- // 试卷数据组装
|
|
|
|
- if (printContent.contains("PAPER")) {
|
|
|
|
- List<PaperPdfDto> paperPdfDto = createPdfUtil.getPaperPdfFile(examDetailCourse.getPaperType(), examTaskDetail, fileTempList);
|
|
|
|
|
|
+ examTaskDetail.setRelatePaperType(String.join(",", relatePaperTypes));
|
|
|
|
+ examDetailCourse.setPaperType(String.join(",", relatePaperTypes));
|
|
|
|
+
|
|
|
|
+ relatePaperTypes.forEach(m -> {
|
|
|
|
+ ExamDetailCoursePaperType examDetailCoursePaperType = new ExamDetailCoursePaperType();
|
|
|
|
+ examDetailCoursePaperType.setId(SystemConstant.getDbUuid());
|
|
|
|
+ examDetailCoursePaperType.setExamDetailCourseId(examDetailCourse.getId());
|
|
|
|
+ examDetailCoursePaperType.setPaperType(m);
|
|
|
|
+ examDetailCoursePaperTypes.add(examDetailCoursePaperType);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 试卷数据组装
|
|
|
|
+ if (printContent.contains("PAPER")) {
|
|
|
|
+ List<PaperPdfDto> paperPdfDto = createPdfUtil.getPaperPdfFile(examDetailCourse.getPaperType(), examTaskDetail, fileTempList);
|
|
|
|
+
|
|
|
|
+ //获取试卷pdf
|
|
|
|
+ PdfDto pdfDto = createPdfUtil.getPaperPdf(paperPdfDto, backupCount, backupPaperPdfList);
|
|
|
|
+ if (Objects.nonNull(pdfDto)) {
|
|
|
|
+ examDetailCourse.setPaperPagesA3(pdfDto.getPageCount());
|
|
|
|
+ } else {
|
|
|
|
+ examDetailCourse.setPaperPagesA3(examDetailCourse.getPaperPagesA3());
|
|
|
|
+ }
|
|
|
|
+ // 备用试卷
|
|
|
|
+ list[0].addAll(backupPaperPdfList);
|
|
|
|
|
|
- //获取试卷pdf
|
|
|
|
- PdfDto pdfDto = createPdfUtil.getPaperPdf(paperPdfDto, backupCount, backupPaperPdfList);
|
|
|
|
|
|
+ if (examStudentList != null && examStudentList.size() > 0) {
|
|
|
|
+ for (ExamStudent t : examStudentList) {
|
|
if (Objects.nonNull(pdfDto)) {
|
|
if (Objects.nonNull(pdfDto)) {
|
|
- examDetailCourse.setPaperPagesA3(pdfDto.getPageCount());
|
|
|
|
- } else {
|
|
|
|
- examDetailCourse.setPaperPagesA3(examDetailCourse.getPaperPagesA3());
|
|
|
|
|
|
+ String[] waterMarkNames = {t.getStudentName(), t.getTicketNumber()};
|
|
|
|
+ createPdfUtil.getExamStudentPaperPdf(t.getPaperType(), paperPdfDto, studentPaperPdfList, waterMarkNames);
|
|
}
|
|
}
|
|
- // 备用试卷
|
|
|
|
- list[0].addAll(backupPaperPdfList);
|
|
|
|
-
|
|
|
|
- if (examStudentList != null && examStudentList.size() > 0) {
|
|
|
|
- for (ExamStudent t : examStudentList) {
|
|
|
|
- if (Objects.nonNull(pdfDto)) {
|
|
|
|
- String[] waterMarkNames = {t.getStudentName(), t.getTicketNumber()};
|
|
|
|
- createPdfUtil.getExamStudentPaperPdf(t.getPaperType(), paperPdfDto, studentPaperPdfList, waterMarkNames);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else if (examDetail.getTotalSubjects() != null) {
|
|
|
|
- AtomicInteger atomicInteger = new AtomicInteger(0);
|
|
|
|
- int i = 0;
|
|
|
|
- while (i < examDetail.getTotalSubjects()) {
|
|
|
|
- int seq = atomicInteger.getAndIncrement();
|
|
|
|
- int mod = seq % examTaskDetail.getDrawCount();
|
|
|
|
- if (Objects.nonNull(pdfDto)) {
|
|
|
|
- createPdfUtil.getExamStudentPaperPdf(paperTypes.get(mod), paperPdfDto, studentPaperPdfList, null);
|
|
|
|
- }
|
|
|
|
- i++;
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("数据错误:未找到考生或者印刷数量");
|
|
|
|
|
|
+ }
|
|
|
|
+ } else if (examDetail.getTotalSubjects() != null) {
|
|
|
|
+ AtomicInteger atomicInteger = new AtomicInteger(0);
|
|
|
|
+ int i = 0;
|
|
|
|
+ while (i < examDetail.getTotalSubjects()) {
|
|
|
|
+ int seq = atomicInteger.getAndIncrement();
|
|
|
|
+ int mod = seq % examTaskDetail.getDrawCount();
|
|
|
|
+ if (Objects.nonNull(pdfDto)) {
|
|
|
|
+ createPdfUtil.getExamStudentPaperPdf(paperTypes.get(mod), paperPdfDto, studentPaperPdfList, null);
|
|
}
|
|
}
|
|
- // 考生试卷
|
|
|
|
- list[2].addAll(studentPaperPdfList);
|
|
|
|
|
|
+ i++;
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("数据错误:未找到考生或者印刷数量");
|
|
|
|
+ }
|
|
|
|
+ // 考生试卷
|
|
|
|
+ list[2].addAll(studentPaperPdfList);
|
|
|
|
+ }
|
|
|
|
|
|
- // 题卡数据组装
|
|
|
|
- basicAttachmentList = Objects.isNull(basicAttachmentList) ? new ArrayList<>() : basicAttachmentList;
|
|
|
|
- if (printContent.contains("CARD")) {
|
|
|
|
- Map<String, ExamCardDetail> examCardDetailMap = new HashMap<>();
|
|
|
|
- Map<String, String> cardContentMap = new HashMap<>();
|
|
|
|
- for (String s : examDetailCourse.getPaperType().split(",")) {
|
|
|
|
- examCard = examCardMap.get(s);
|
|
|
|
- Optional.ofNullable(examCard).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("卷型" + s + "题卡不存在"));
|
|
|
|
|
|
+ // 题卡数据组装
|
|
|
|
+ basicAttachmentList = Objects.isNull(basicAttachmentList) ? new ArrayList<>() : basicAttachmentList;
|
|
|
|
+ if (printContent.contains("CARD")) {
|
|
|
|
+ Map<String, ExamCardDetail> examCardDetailMap = new HashMap<>();
|
|
|
|
+ Map<String, String> cardContentMap = new HashMap<>();
|
|
|
|
+ for (String s : examDetailCourse.getPaperType().split(",")) {
|
|
|
|
+ examCard = examCardMap.get(s);
|
|
|
|
+ Optional.ofNullable(examCard).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("卷型" + s + "题卡不存在"));
|
|
|
|
|
|
- QueryWrapper<ExamCardDetail> examCardDetailQueryWrapper = new QueryWrapper<>();
|
|
|
|
- examCardDetailQueryWrapper.lambda().eq(ExamCardDetail::getCardId, examCard.getId());
|
|
|
|
- ExamCardDetail examCardDetail = examCardDetailService.getOne(examCardDetailQueryWrapper);
|
|
|
|
|
|
+ QueryWrapper<ExamCardDetail> examCardDetailQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ examCardDetailQueryWrapper.lambda().eq(ExamCardDetail::getCardId, examCard.getId());
|
|
|
|
+ ExamCardDetail examCardDetail = examCardDetailService.getOne(examCardDetailQueryWrapper);
|
|
|
|
|
|
- createPdfUtil.getCardAttachmentId(examCardDetail, attachmentIds);
|
|
|
|
|
|
+ createPdfUtil.getCardAttachmentId(examCardDetail, attachmentIds);
|
|
|
|
|
|
- //把模板页面上的 ${} 替换成实际内容
|
|
|
|
- String cardContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
|
|
|
|
|
|
+ //把模板页面上的 ${} 替换成实际内容
|
|
|
|
+ String cardContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
|
|
|
|
|
|
- for (int i = 1; i <= backupCount; i++) {
|
|
|
|
- BasicAttachment basicAttachment = createPdfUtil.cardHtml(String.format(SystemConstant.DATE_TIME_FORMAT, i), cardContent, examDetail, examDetailCourse, s, jsonArray, sysUser.getId(), backupCardPdfList, basicCardRule, fileTempList);
|
|
|
|
- examDetailCourse.setCardPagesA3(basicAttachment.getPages());
|
|
|
|
- basicAttachmentList.add(basicAttachment);
|
|
|
|
- }
|
|
|
|
- examCardDetailMap.put(s, examCardDetail);
|
|
|
|
- cardContentMap.put(s, cardContent);
|
|
|
|
- }
|
|
|
|
- // 备用题卡
|
|
|
|
- list[1].addAll(backupCardPdfList);
|
|
|
|
|
|
+ for (int i = 1; i <= backupCount; i++) {
|
|
|
|
+ BasicAttachment basicAttachment = createPdfUtil.cardHtml(String.format(SystemConstant.DATE_TIME_FORMAT, i), cardContent, examDetail, examDetailCourse, s, jsonArray, sysUser.getId(), backupCardPdfList, basicCardRule, fileTempList);
|
|
|
|
+ examDetailCourse.setCardPagesA3(basicAttachment.getPages());
|
|
|
|
+ basicAttachmentList.add(basicAttachment);
|
|
|
|
+ }
|
|
|
|
+ examCardDetailMap.put(s, examCardDetail);
|
|
|
|
+ cardContentMap.put(s, cardContent);
|
|
|
|
+ }
|
|
|
|
+ // 备用题卡
|
|
|
|
+ list[1].addAll(backupCardPdfList);
|
|
|
|
|
|
- if (examStudentList != null && examStudentList.size() > 0) {
|
|
|
|
- for (ExamStudent t : examStudentList) {
|
|
|
|
- // 用带条码的模板
|
|
|
|
- basicAttachmentList.add(createPdfUtil.examStudentHtml(examCardDetailMap.get(t.getPaperType()).getHtmlContent(), t, paperType, examDetail, examDetailCourse, sysUser.getId(), studentCardPdfList, basicCardRule, fileTempList));
|
|
|
|
- }
|
|
|
|
- } else if (examDetail.getTotalSubjects() != null) {
|
|
|
|
- AtomicInteger atomicInteger = new AtomicInteger(0);
|
|
|
|
- Map<String, BasicAttachment> stringBasicAttachmentMap = new HashMap<>();
|
|
|
|
- int i = 0;
|
|
|
|
- while (i < examDetail.getTotalSubjects()) {
|
|
|
|
- int seq = atomicInteger.getAndIncrement();
|
|
|
|
- int mod = seq % examTaskDetail.getDrawCount();
|
|
|
|
- String tempPaperType = paperTypes.get(mod);
|
|
|
|
- BasicAttachment basicAttachment = createPdfUtil.examStudentHtml(cardContentMap.get(tempPaperType), null, tempPaperType, examDetail, examDetailCourse, sysUser.getId(), studentCardPdfList, basicCardRule, fileTempList);
|
|
|
|
-
|
|
|
|
- if (!stringBasicAttachmentMap.containsKey(tempPaperType)) {
|
|
|
|
- stringBasicAttachmentMap.put(tempPaperType, basicAttachment);
|
|
|
|
- JSONObject object = new JSONObject();
|
|
|
|
- object.put("name", tempPaperType);
|
|
|
|
- object.put("attachmentId", basicAttachment.getId());
|
|
|
|
- stuJsonArray.add(object);
|
|
|
|
-
|
|
|
|
- // 用不带条码的模板
|
|
|
|
- basicAttachmentList.add(basicAttachment);
|
|
|
|
- }
|
|
|
|
- i++;
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("数据错误:未找到考生或者印刷数量");
|
|
|
|
|
|
+ if (examStudentList != null && examStudentList.size() > 0) {
|
|
|
|
+ for (ExamStudent t : examStudentList) {
|
|
|
|
+ // 用带条码的模板
|
|
|
|
+ basicAttachmentList.add(createPdfUtil.examStudentHtml(examCardDetailMap.get(t.getPaperType()).getHtmlContent(), t, paperType, examDetail, examDetailCourse, sysUser.getId(), studentCardPdfList, basicCardRule, fileTempList));
|
|
|
|
+ }
|
|
|
|
+ } else if (examDetail.getTotalSubjects() != null) {
|
|
|
|
+ AtomicInteger atomicInteger = new AtomicInteger(0);
|
|
|
|
+ Map<String, BasicAttachment> stringBasicAttachmentMap = new HashMap<>();
|
|
|
|
+ int i = 0;
|
|
|
|
+ while (i < examDetail.getTotalSubjects()) {
|
|
|
|
+ int seq = atomicInteger.getAndIncrement();
|
|
|
|
+ int mod = seq % examTaskDetail.getDrawCount();
|
|
|
|
+ String tempPaperType = paperTypes.get(mod);
|
|
|
|
+ BasicAttachment basicAttachment = createPdfUtil.examStudentHtml(cardContentMap.get(tempPaperType), null, tempPaperType, examDetail, examDetailCourse, sysUser.getId(), studentCardPdfList, basicCardRule, fileTempList);
|
|
|
|
+
|
|
|
|
+ if (!stringBasicAttachmentMap.containsKey(tempPaperType)) {
|
|
|
|
+ stringBasicAttachmentMap.put(tempPaperType, basicAttachment);
|
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
|
+ object.put("name", tempPaperType);
|
|
|
|
+ object.put("attachmentId", basicAttachment.getId());
|
|
|
|
+ stuJsonArray.add(object);
|
|
|
|
+
|
|
|
|
+ // 用不带条码的模板
|
|
|
|
+ basicAttachmentList.add(basicAttachment);
|
|
}
|
|
}
|
|
- // 题卡
|
|
|
|
- list[3].addAll(studentCardPdfList);
|
|
|
|
- jsonObject.put("card", jsonArray);
|
|
|
|
- examDetailCourse.setAttachmentId(jsonObject.toJSONString());
|
|
|
|
- examDetailCourse.setCommonAttachmentId(stuJsonArray.toJSONString());
|
|
|
|
|
|
+ i++;
|
|
}
|
|
}
|
|
- examStudentService.saveOrUpdateBatch(examStudentList);
|
|
|
|
|
|
+ } else {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("数据错误:未找到考生或者印刷数量");
|
|
}
|
|
}
|
|
|
|
+ // 题卡
|
|
|
|
+ list[3].addAll(studentCardPdfList);
|
|
|
|
+ jsonObject.put("card", jsonArray);
|
|
examDetailCourse.setAttachmentId(jsonObject.toJSONString());
|
|
examDetailCourse.setAttachmentId(jsonObject.toJSONString());
|
|
- examTaskDetailService.saveOrUpdateBatch(examTaskDetailList);
|
|
|
|
-
|
|
|
|
- examDetailCoursePaperTypeService.deleteByExamDetailCourseId(examDetailCourse.getId());
|
|
|
|
- examDetailCoursePaperTypeService.saveBatch(examDetailCoursePaperTypes);
|
|
|
|
|
|
+ examDetailCourse.setCommonAttachmentId(stuJsonArray.toJSONString());
|
|
}
|
|
}
|
|
- examDetailCourseService.saveOrUpdateBatch(examDetailCourseList);
|
|
|
|
|
|
+ examStudentService.saveOrUpdateBatch(examStudentList);
|
|
|
|
|
|
|
|
+ examDetailCourse.setAttachmentId(jsonObject.toJSONString());
|
|
|
|
+ examTaskDetailService.saveOrUpdate(examTaskDetail);
|
|
|
|
+
|
|
|
|
+ examDetailCoursePaperTypeService.deleteByExamDetailCourseId(examDetailCourse.getId());
|
|
|
|
+ examDetailCoursePaperTypeService.saveBatch(examDetailCoursePaperTypes);
|
|
}
|
|
}
|
|
|
|
+ examDetailCourseService.saveOrUpdateBatch(examDetailCourseList);
|
|
|
|
+
|
|
return basicAttachmentList;
|
|
return basicAttachmentList;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -540,8 +507,7 @@ 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) {
|
|
List<BasicAttachment> basicAttachmentList = null;
|
|
List<BasicAttachment> basicAttachmentList = null;
|
|
List<File> fileTempList = new ArrayList<>();
|
|
List<File> fileTempList = new ArrayList<>();
|
|
try {
|
|
try {
|
|
@@ -559,10 +525,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
}
|
|
}
|
|
|
|
|
|
BasicSchool basicSchool = commonCacheService.schoolCache(examPrintPlan.getSchoolId());
|
|
BasicSchool basicSchool = commonCacheService.schoolCache(examPrintPlan.getSchoolId());
|
|
- BasicPrintConfig basicPrintConfig = basicPrintConfigService.getByExamIdAndOrgId(examPrintPlan.getExamId());
|
|
|
|
- if (Objects.isNull(basicPrintConfig)) {
|
|
|
|
- throw ExceptionResultEnum.EXAM_PRINT_CONFIG_IS_NULL.exception();
|
|
|
|
- }
|
|
|
|
|
|
+ BasicPrintConfig basicPrintConfig = basicPrintConfigService.getByExamId(examPrintPlan.getExamId());
|
|
|
|
|
|
//查询examDetail
|
|
//查询examDetail
|
|
QueryWrapper<ExamDetail> examDetailQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<ExamDetail> examDetailQueryWrapper = new QueryWrapper<>();
|
|
@@ -625,7 +588,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
//合并A3(题卡+备用题卡)
|
|
//合并A3(题卡+备用题卡)
|
|
String dirNameCardA3 = createPdfUtil.mergeA3Pdf(fileTempList, examStudentPdfList, backupCardPdfList);
|
|
String dirNameCardA3 = createPdfUtil.mergeA3Pdf(fileTempList, examStudentPdfList, backupCardPdfList);
|
|
|
|
|
|
-// BasicAttachment attachment = createPdfUtil.mergePdfSaveDb(dirNameA4, dirNameA3, dirNameCardA3, tbTask, sysUser.getId(), examDetail, basicExamRule, mergePdfDeleteList);
|
|
|
|
BasicAttachment attachment = createPdfUtil.mergePdfSaveDb(dirNamePaper, dirNameCardA3, tbTask, sysUser.getId(), examDetail, basicPrintConfig, fileTempList);
|
|
BasicAttachment attachment = createPdfUtil.mergePdfSaveDb(dirNamePaper, dirNameCardA3, tbTask, sysUser.getId(), examDetail, basicPrintConfig, fileTempList);
|
|
if (basicAttachmentList != null) {
|
|
if (basicAttachmentList != null) {
|
|
basicAttachmentList.add(attachment);
|
|
basicAttachmentList.add(attachment);
|