|
@@ -217,12 +217,13 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
|
|
|
/**
|
|
|
* 创建pdf核心逻辑
|
|
|
+ *
|
|
|
* @param examDetailCourseList
|
|
|
- * @param examPrintPlan 印刷计划
|
|
|
- * @param examDetail 考场对象
|
|
|
- * @param sysUser 当前用户
|
|
|
- * @param paperTypeParam 试卷类型
|
|
|
- * @param basicAttachmentList 附件集合
|
|
|
+ * @param examPrintPlan 印刷计划
|
|
|
+ * @param examDetail 考场对象
|
|
|
+ * @param sysUser 当前用户
|
|
|
+ * @param paperTypeParam 试卷类型
|
|
|
+ * @param basicAttachmentList 附件集合
|
|
|
* @param attachmentIds
|
|
|
* @param list
|
|
|
*/
|
|
@@ -308,7 +309,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
// 查询考试
|
|
|
BasicExam basicExam = basicExamService.getById(examTask.getExamId());
|
|
|
//
|
|
|
- List<String> paperTypes = Arrays.asList(paperType.split(",")).stream().sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList());
|
|
|
+ List<String> paperTypes = Arrays.stream(paperType.split(",")).sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList());
|
|
|
int backupCount = examPrintPlan.getBackupCount() != null ? examPrintPlan.getBackupCount() : 0;
|
|
|
|
|
|
if (examStudentList != null && examStudentList.size() > 0) {
|
|
@@ -318,121 +319,87 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
int mod = i1 % examTaskDetail.getDrawCount();
|
|
|
t.setPaperType(paperTypes.get(mod));
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- // 试卷
|
|
|
- if (printContent.contains("PAPER")) {
|
|
|
- List<PaperPdfDto> paperPdfDto = createPdfUtil.getPaperPdfFile(paperType, examTaskDetail);
|
|
|
+ // 试卷数据组装
|
|
|
+ if (printContent.contains("PAPER")) {
|
|
|
+ List<PaperPdfDto> paperPdfDto = createPdfUtil.getPaperPdfFile(paperType, examTaskDetail);
|
|
|
|
|
|
- //获取试卷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 (Objects.nonNull(pdfDto)) {
|
|
|
+ examDetailCourse.setPaperPagesA3(pdfDto.getPageCount());
|
|
|
+ } else {
|
|
|
+ examDetailCourse.setPaperPagesA3(examDetailCourse.getPaperPagesA3());
|
|
|
+ }
|
|
|
+ // 备用试卷
|
|
|
+ list[0].addAll(backupPaperPdfList);
|
|
|
|
|
|
+ if (examStudentList != null && examStudentList.size() > 0) {
|
|
|
for (ExamStudent t : examStudentList) {
|
|
|
if (Objects.nonNull(pdfDto)) {
|
|
|
PdfDto stuPdfDto = createPdfUtil.getExamStudentPaperPdf(t.getPaperType(), paperPdfDto, studentPaperPdfList);
|
|
|
}
|
|
|
}
|
|
|
- // 考生试卷
|
|
|
- list[2].addAll(studentPaperPdfList);
|
|
|
- }
|
|
|
-
|
|
|
- basicAttachmentList = Objects.isNull(basicAttachmentList) ? new ArrayList<>() : basicAttachmentList;
|
|
|
- if (printContent.contains("CARD")) {
|
|
|
- QueryWrapper<ExamCardDetail> examCardDetailQueryWrapper = new QueryWrapper<>();
|
|
|
- examCardDetailQueryWrapper.lambda().eq(ExamCardDetail::getCardId, examCard.getId());
|
|
|
- ExamCardDetail examCardDetail = examCardDetailService.getOne(examCardDetailQueryWrapper);
|
|
|
-
|
|
|
- createPdfUtil.getCardAttachmentId(examCardDetail, attachmentIds);
|
|
|
-
|
|
|
- //把模板页面上的 ${} 替换成实际内容
|
|
|
- String cardContent = createPdfUtil.replaceHtmlTemplate(examCardDetail);
|
|
|
- String studentContent = examCardDetail.getHtmlContent();
|
|
|
-
|
|
|
- for (int i = 1; i <= backupCount; i++) {
|
|
|
- BasicAttachment basicAttachment = createPdfUtil.cardHtml(String.format("%02d", i), cardContent, examDetail, examDetailCourse, jsonArray, sysUser.getId(), backupCardPdfList, basicCardRule);
|
|
|
- examDetailCourse.setCardPagesA3(basicAttachment.getPages());
|
|
|
- basicAttachmentList.add(basicAttachment);
|
|
|
- }
|
|
|
- // 备用题卡
|
|
|
- list[1].addAll(backupCardPdfList);
|
|
|
-
|
|
|
- for (ExamStudent t : examStudentList) {
|
|
|
- basicAttachmentList.add(createPdfUtil.examStudentHtml(studentContent, t, examDetail, examDetailCourse, sysUser.getId(), studentCardPdfList, basicCardRule));
|
|
|
- }
|
|
|
- // 题卡
|
|
|
- list[3].addAll(studentCardPdfList);
|
|
|
- jsonObject.put("card", jsonArray);
|
|
|
- examDetailCourse.setAttachmentId(jsonObject.toJSONString());
|
|
|
- }
|
|
|
- examStudentService.saveOrUpdateBatch(examStudentList);
|
|
|
- } else if (examDetail.getPrintCount() != null){
|
|
|
- // 试卷
|
|
|
- if (printContent.contains("PAPER")) {
|
|
|
- List<PaperPdfDto> paperPdfDto = createPdfUtil.getPaperPdfFile(paperType, examTaskDetail);
|
|
|
-
|
|
|
- //获取试卷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);
|
|
|
-
|
|
|
+ } else if (examDetail.getPrintCount() != null) {
|
|
|
AtomicInteger atomicInteger = new AtomicInteger(0);
|
|
|
int i = 0;
|
|
|
while (i < examDetail.getPrintCount()) {
|
|
|
- int i1 = atomicInteger.getAndIncrement();
|
|
|
- int mod = i1 % examTaskDetail.getDrawCount();
|
|
|
+ int seq = atomicInteger.getAndIncrement();
|
|
|
+ int mod = seq % examTaskDetail.getDrawCount();
|
|
|
if (Objects.nonNull(pdfDto)) {
|
|
|
PdfDto stuPdfDto = createPdfUtil.getExamStudentPaperPdf(paperTypes.get(mod), paperPdfDto, studentPaperPdfList);
|
|
|
}
|
|
|
i++;
|
|
|
}
|
|
|
-
|
|
|
- // 考生试卷
|
|
|
- list[2].addAll(studentPaperPdfList);
|
|
|
+ } else {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("数据错误:未找到考生或者印刷数量");
|
|
|
}
|
|
|
+ // 考生试卷
|
|
|
+ list[2].addAll(studentPaperPdfList);
|
|
|
+ }
|
|
|
|
|
|
- basicAttachmentList = Objects.isNull(basicAttachmentList) ? new ArrayList<>() : basicAttachmentList;
|
|
|
- if (printContent.contains("CARD")) {
|
|
|
- QueryWrapper<ExamCardDetail> examCardDetailQueryWrapper = new QueryWrapper<>();
|
|
|
- examCardDetailQueryWrapper.lambda().eq(ExamCardDetail::getCardId, examCard.getId());
|
|
|
- ExamCardDetail examCardDetail = examCardDetailService.getOne(examCardDetailQueryWrapper);
|
|
|
+ // 题卡数据组装
|
|
|
+ basicAttachmentList = Objects.isNull(basicAttachmentList) ? new ArrayList<>() : basicAttachmentList;
|
|
|
+ if (printContent.contains("CARD")) {
|
|
|
+ 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.replaceHtmlTemplate(examCardDetail);
|
|
|
+ //把模板页面上的 ${} 替换成实际内容
|
|
|
+ String cardContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
|
|
|
|
|
|
- for (int i = 1; i <= backupCount; i++) {
|
|
|
- BasicAttachment basicAttachment = createPdfUtil.cardHtml(String.format("%02d", i), cardContent, examDetail, examDetailCourse, jsonArray, sysUser.getId(), backupCardPdfList, basicCardRule);
|
|
|
- examDetailCourse.setCardPagesA3(basicAttachment.getPages());
|
|
|
- basicAttachmentList.add(basicAttachment);
|
|
|
- }
|
|
|
- // 备用题卡
|
|
|
- list[1].addAll(backupCardPdfList);
|
|
|
+ for (int i = 1; i <= backupCount; i++) {
|
|
|
+ BasicAttachment basicAttachment = createPdfUtil.cardHtml(String.format("%02d", i), cardContent, examDetail, examDetailCourse, jsonArray, sysUser.getId(), backupCardPdfList, basicCardRule);
|
|
|
+ examDetailCourse.setCardPagesA3(basicAttachment.getPages());
|
|
|
+ basicAttachmentList.add(basicAttachment);
|
|
|
+ }
|
|
|
+ // 备用题卡
|
|
|
+ list[1].addAll(backupCardPdfList);
|
|
|
|
|
|
+ if (examStudentList != null && examStudentList.size() > 0) {
|
|
|
+ for (ExamStudent t : examStudentList) {
|
|
|
+ // 用带条码的模板
|
|
|
+ basicAttachmentList.add(createPdfUtil.examStudentHtml(examCardDetail.getHtmlContent(), t, examDetail, examDetailCourse, sysUser.getId(), studentCardPdfList, basicCardRule));
|
|
|
+ }
|
|
|
+ } else if (examDetail.getPrintCount() != null) {
|
|
|
int i = 0;
|
|
|
while (i < examDetail.getPrintCount()) {
|
|
|
- basicAttachmentList.add(createPdfUtil.cardHtml(String.format("%02d", i), cardContent, examDetail, examDetailCourse, jsonArray, sysUser.getId(), studentCardPdfList, basicCardRule));
|
|
|
+ // 用不带条码的模板
|
|
|
+ basicAttachmentList.add(createPdfUtil.examStudentHtml(cardContent, null, examDetail, examDetailCourse, sysUser.getId(), studentCardPdfList, basicCardRule));
|
|
|
i++;
|
|
|
}
|
|
|
-
|
|
|
- // 题卡
|
|
|
- list[3].addAll(studentCardPdfList);
|
|
|
- jsonObject.put("card", jsonArray);
|
|
|
- examDetailCourse.setAttachmentId(jsonObject.toJSONString());
|
|
|
+ } else {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("数据错误:未找到考生或者印刷数量");
|
|
|
}
|
|
|
- examStudentService.saveOrUpdateBatch(examStudentList);
|
|
|
+ // 题卡
|
|
|
+ list[3].addAll(studentCardPdfList);
|
|
|
+ jsonObject.put("card", jsonArray);
|
|
|
+ examDetailCourse.setAttachmentId(jsonObject.toJSONString());
|
|
|
}
|
|
|
+ examStudentService.saveOrUpdateBatch(examStudentList);
|
|
|
}
|
|
|
examDetailCourse.setAttachmentId(jsonObject.toJSONString());
|
|
|
examTaskDetailService.saveOrUpdateBatch(examTaskDetailList);
|
|
@@ -1160,7 +1127,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCard.getId());
|
|
|
String htmlContent;
|
|
|
if (MakeMethodEnum.SELECT.equals(makeMethodEnum)) {
|
|
|
- htmlContent = createPdfUtil.replaceHtmlTemplate(examCardDetail);
|
|
|
+ htmlContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
|
|
|
} else {
|
|
|
BasicCardRule basicCardRule = basicCardRuleService.getById(examTask.getCardRuleId());
|
|
|
htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
|