|
@@ -1,5 +1,6 @@
|
|
|
package com.qmth.distributed.print.business.templete.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -14,22 +15,21 @@ import com.qmth.distributed.print.business.enums.ExamStatusEnum;
|
|
|
import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
|
|
|
import com.qmth.distributed.print.business.service.*;
|
|
|
import com.qmth.distributed.print.business.templete.service.PdfTaskLogicService;
|
|
|
+import com.qmth.distributed.print.business.util.PdfUtil;
|
|
|
import com.qmth.distributed.print.business.util.pdf.CreatePdfNewUtil;
|
|
|
import com.qmth.teachcloud.common.base.BaseEntity;
|
|
|
+import com.qmth.teachcloud.common.bean.vo.FilePathVo;
|
|
|
import com.qmth.teachcloud.common.bean.vo.PaperInfoVo;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
import com.qmth.teachcloud.common.entity.BasicAttachment;
|
|
|
import com.qmth.teachcloud.common.entity.BasicExam;
|
|
|
-import com.qmth.teachcloud.common.entity.BasicPrintConfig;
|
|
|
import com.qmth.teachcloud.common.entity.BasicSchool;
|
|
|
-import com.qmth.teachcloud.common.enums.CreatePdfTypeEnum;
|
|
|
-import com.qmth.teachcloud.common.enums.ExamCategoryEnum;
|
|
|
-import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
-import com.qmth.teachcloud.common.enums.FlowStatusEnum;
|
|
|
+import com.qmth.teachcloud.common.enums.*;
|
|
|
import com.qmth.teachcloud.common.service.BasicAttachmentService;
|
|
|
import com.qmth.teachcloud.common.service.BasicStudentService;
|
|
|
import com.qmth.teachcloud.common.service.CommonCacheService;
|
|
|
-import com.qmth.teachcloud.common.util.ExamTaskUtil;
|
|
|
+import com.qmth.teachcloud.common.service.FileUploadService;
|
|
|
+import com.qmth.teachcloud.common.util.FileUtil;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
@@ -39,6 +39,8 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.io.File;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -84,6 +86,10 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
|
|
|
BasicExamService basicExamService;
|
|
|
@Resource
|
|
|
ExamTaskAssignPaperTypeService examTaskAssignPaperTypeService;
|
|
|
+ @Resource
|
|
|
+ private PrintCommonService printCommonService;
|
|
|
+ @Resource
|
|
|
+ private FileUploadService fileUploadService;
|
|
|
|
|
|
/**
|
|
|
* 创建A4文件
|
|
@@ -140,32 +146,111 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
|
|
|
|
|
|
@Override
|
|
|
public void executeCreatePdfLogic(TBTaskPdf tbTaskPdf) {
|
|
|
+ CreatePdfDto createPdfDto = new CreatePdfDto();
|
|
|
try {
|
|
|
// 更新状态(考场状态、印刷计划状态)
|
|
|
updatePdfDataStatus(tbTaskPdf);
|
|
|
+
|
|
|
+ ExamDetail examDetail = examDetailService.getById(tbTaskPdf.getId());
|
|
|
+ createPdfDto.setExamDetail(examDetail);
|
|
|
+ ExamPrintPlan examPrintPlan = examPrintPlanService.getById(examDetail.getPrintPlanId());
|
|
|
+ createPdfDto.setExamPrintPlan(examPrintPlan);
|
|
|
List<ExamDetailCourse> examDetailCourseList = examDetailCourseService.listByExamDetailId(tbTaskPdf.getId());
|
|
|
+ createPdfDto.setExamDetailCourseList(examDetailCourseList);
|
|
|
+
|
|
|
// 抽取卷型,更新考场、考生对应卷型值
|
|
|
- updateAssignPaperType(tbTaskPdf, examDetailCourseList);
|
|
|
+ updateAssignPaperType(tbTaskPdf, createPdfDto);
|
|
|
// 查询生成pdf需要文件
|
|
|
- CreatePdfDto createPdfDto = new CreatePdfDto();
|
|
|
assemblePdfFile(tbTaskPdf, createPdfDto);
|
|
|
// 生成pdf文件并合并
|
|
|
//合并(试卷+备用试卷)
|
|
|
- String dirNamePaper = createPdfNewUtil.mergeA3Pdf(createPdfDto.getPaperPdfList(), createPdfDto.getBackupPaperPdfList());
|
|
|
+ String dirNamePaper = createPdfNewUtil.mergeA3Pdf(createPdfDto.getPaperPdfList());
|
|
|
//合并A3(题卡+备用题卡)
|
|
|
- String dirNameCardA3 = createPdfNewUtil.mergeA3Pdf(createPdfDto.getCardPdfList(), createPdfDto.getBackupCardPdfList());
|
|
|
- // 生成A4文件
|
|
|
- createA4File(tbTaskPdf, examDetailCourseList);
|
|
|
+ String dirNameCardA3 = createPdfNewUtil.mergeA3Pdf(createPdfDto.getCardPdfList());
|
|
|
// 更新文件路径、更新考场状态、印刷计划状态
|
|
|
createPdfNewUtil.mergePdfSaveDb(dirNamePaper, dirNameCardA3, tbTaskPdf);
|
|
|
+ // 生成A4文件
|
|
|
+ createA4File(tbTaskPdf, examDetailCourseList);
|
|
|
} catch (Exception e) {
|
|
|
throw new RuntimeException(e);
|
|
|
+ } finally {
|
|
|
+ if(CollectionUtils.isNotEmpty(createPdfDto.getFileTempList())){
|
|
|
+ for (File file : createPdfDto.getFileTempList()) {
|
|
|
+ FileUtil.deleteFile(file);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void updatePdfDataStatus(TBTaskPdf tbTaskPdf) {
|
|
|
+ //查询printPlan
|
|
|
+ ExamPrintPlan examPrintPlan = examPrintPlanService.getById(tbTaskPdf.getPrintPlanId());
|
|
|
+ if (Objects.isNull(examPrintPlan)) {
|
|
|
+ throw ExceptionResultEnum.EXAM_PRINT_IS_NULL.exception();
|
|
|
+ }
|
|
|
+ UpdateWrapper<ExamDetail> examDetailQueryWrapper = new UpdateWrapper<>();
|
|
|
+ examDetailQueryWrapper.lambda().set(ExamDetail::getStatus, ExamDetailStatusEnum.CREATING)
|
|
|
+ .eq(ExamDetail::getId, tbTaskPdf.getId());
|
|
|
+ examDetailService.update(examDetailQueryWrapper);
|
|
|
+
|
|
|
+ //所有考场都撤回,印刷任务状态改为就绪
|
|
|
+ QueryWrapper<ExamDetail> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.lambda().eq(ExamDetail::getPrintPlanId, tbTaskPdf.getPrintPlanId())
|
|
|
+ .notIn(ExamDetail::getStatus, ExamDetailStatusEnum.NEW, ExamDetailStatusEnum.READY);
|
|
|
+ List<ExamDetail> examDetails = examDetailService.list(queryWrapper);
|
|
|
+ if (CollectionUtils.isEmpty(examDetails)) {
|
|
|
+ examPrintPlanService.updateStatusById(tbTaskPdf.getPrintPlanId(), PrintPlanStatusEnum.READY);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ public void updateAssignPaperType(TBTaskPdf tbTaskPdf, CreatePdfDto createPdfDto) {
|
|
|
+ for (ExamDetailCourse examDetailCourse : createPdfDto.getExamDetailCourseList()) {
|
|
|
+ ExamTaskAssignPaperType examTaskAssignPaperType = examTaskAssignPaperTypeService.extractPaperType(tbTaskPdf, examDetailCourse);
|
|
|
+ List<ExamStudent> examStudentList = examStudentService.listByExamDetailCourseId(examDetailCourse.getId());
|
|
|
+ // 考生实际关联试卷类型
|
|
|
+ List<String> relatePaperTypes = new ArrayList<>();
|
|
|
+ List<String> paperTypes = Arrays.stream(examTaskAssignPaperType.getPaperType().split(",")).sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isNotEmpty(examStudentList)) {
|
|
|
+ AtomicInteger atomicInteger = new AtomicInteger(0);
|
|
|
+ for (ExamStudent examStudent : examStudentList) {
|
|
|
+ int i1 = atomicInteger.getAndIncrement();
|
|
|
+ int mod = i1 % paperTypes.size();
|
|
|
+ examStudent.setPaperType(paperTypes.get(mod));
|
|
|
+ if (!relatePaperTypes.contains(examStudent.getPaperType())) {
|
|
|
+ relatePaperTypes.add(examStudent.getPaperType());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (examDetailCourse.getTotalSubjects() != null) {
|
|
|
+ if (examDetailCourse.getTotalSubjects().intValue() - paperTypes.size() >= 0) {
|
|
|
+ relatePaperTypes.addAll(paperTypes);
|
|
|
+ } else {
|
|
|
+ for (int i = 0; i < examDetailCourse.getTotalSubjects().intValue(); i++) {
|
|
|
+ relatePaperTypes.add(paperTypes.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ relatePaperTypes.addAll(paperTypes);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新卷型数据
|
|
|
+ if (!CollectionUtils.isEqualCollection(paperTypes, relatePaperTypes)) {
|
|
|
+ examTaskAssignPaperType.setPaperType(String.join(",", relatePaperTypes));
|
|
|
+ examTaskAssignPaperTypeService.updateByMultiId(examTaskAssignPaperType);
|
|
|
+ }
|
|
|
+
|
|
|
+ examDetailCourse.setPaperType(String.join(",", relatePaperTypes));
|
|
|
+ examDetailCourseService.updateById(examDetailCourse);
|
|
|
+
|
|
|
+ examStudentService.updateBatchById(examStudentList);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void assemblePdfFile(TBTaskPdf tbTaskPdf, CreatePdfDto createPdfDto) throws Exception {
|
|
|
- List<ExamDetailCourse> examDetailCourseList = examDetailCourseService.listByExamDetailId(tbTaskPdf.getId());
|
|
|
- for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
|
|
|
+ ExamDetail examDetail = createPdfDto.getExamDetail();
|
|
|
+ ExamPrintPlan examPrintPlan = createPdfDto.getExamPrintPlan();
|
|
|
+
|
|
|
+ for (ExamDetailCourse examDetailCourse : createPdfDto.getExamDetailCourseList()) {
|
|
|
String[] paperTypes = examDetailCourse.getPaperType().split(",");
|
|
|
|
|
|
List<PdfDto> studentPaperPdfList = new ArrayList<>();//所有试卷
|
|
@@ -188,57 +273,25 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
|
|
|
}
|
|
|
ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamTaskId(examTask.getId());
|
|
|
|
|
|
- Map<String, ExamCard> examCardMap = new HashMap<>();
|
|
|
- List<PaperInfoVo> paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetail.getPaperAttachmentIds());
|
|
|
- ExamCard examCard;
|
|
|
- for (PaperInfoVo paperInfoVo : paperInfoVoList) {
|
|
|
- Long cardId = Long.valueOf(paperInfoVo.getCardId());
|
|
|
- if (Objects.nonNull(cardId)) {
|
|
|
- examCard = examCardService.getById(cardId);
|
|
|
- if (Objects.isNull(examCard)) {
|
|
|
- throw ExceptionResultEnum.EXAM_CARD_IS_NULL.exception();
|
|
|
- }
|
|
|
- examCardMap.put(paperInfoVo.getName(), examCard);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //查询题卡规则
|
|
|
- BasicCardRule basicCardRule = basicCardRuleService.getById(examTask.getCardRuleId());
|
|
|
-
|
|
|
List<ExamStudent> examStudentList = examStudentService.listByExamDetailCourseId(examDetailCourse.getId());
|
|
|
|
|
|
CreatePdfTypeEnum createPdfType = tbTaskPdf.getCreateType();
|
|
|
-
|
|
|
- ExamPrintPlan examPrintPlan = examPrintPlanService.getById(tbTaskPdf.getPrintPlanId());
|
|
|
String printContent = examPrintPlan.getPrintContent();
|
|
|
if (StringUtils.isBlank(printContent)) {
|
|
|
- continue;
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("印刷计划未设置打印内容,[试卷、题卡]至少选择一项");
|
|
|
}
|
|
|
-
|
|
|
// 计算备份数量,默认最小为1份。
|
|
|
- ExamDetail examDetail = examDetailService.getById(tbTaskPdf.getId());
|
|
|
int backupCount = SystemConstant.calcBackupCount(examDetail.getBackupCount(), examDetail.getTotalSubjects(), 1);
|
|
|
|
|
|
// 试卷数据组装
|
|
|
if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.PAPER.equals(createPdfType)) && printContent.contains("PAPER")) {
|
|
|
- List<PaperPdfDto> paperPdfDto = createPdfNewUtil.getPaperPdfFile(examDetailCourse.getPaperType(), examTaskDetail, createPdfDto.getFileTempList());
|
|
|
-
|
|
|
- //获取试卷pdf
|
|
|
- PdfDto pdfDto = createPdfNewUtil.getPaperPdf(paperPdfDto, backupCount, backupPaperPdfList);
|
|
|
- if (Objects.nonNull(pdfDto)) {
|
|
|
- examDetailCourse.setPaperPagesA3(pdfDto.getPageCount());
|
|
|
- } else {
|
|
|
- examDetailCourse.setPaperPagesA3(examDetailCourse.getPaperPagesA3());
|
|
|
- }
|
|
|
- // 备用试卷
|
|
|
- createPdfDto.getBackupPaperPdfList().addAll(backupPaperPdfList);
|
|
|
+ List<PaperPdfDto> paperPdfDtoList = createPdfNewUtil.getPaperPdfFile(examDetailCourse.getPaperType(), examTaskDetail.getPaperInfoVoList(null), createPdfDto);
|
|
|
|
|
|
- if (examStudentList != null && examStudentList.size() > 0) {
|
|
|
+ // 生成考生试卷
|
|
|
+ if (CollectionUtils.isNotEmpty(examStudentList)) {
|
|
|
for (ExamStudent t : examStudentList) {
|
|
|
- if (Objects.nonNull(pdfDto)) {
|
|
|
- String[] waterMarkNames = {t.getStudentName(), t.getTicketNumber()};
|
|
|
- createPdfNewUtil.getExamStudentPaperPdf(t.getPaperType(), paperPdfDto, studentPaperPdfList, waterMarkNames);
|
|
|
- }
|
|
|
+ String[] waterMarkNames = {t.getStudentName(), t.getTicketNumber()};
|
|
|
+ createPdfNewUtil.getExamStudentPaperPdf(t.getPaperType(), paperPdfDtoList, createPdfDto, waterMarkNames);
|
|
|
}
|
|
|
} else if (examDetail.getTotalSubjects() != null) {
|
|
|
AtomicInteger atomicInteger = new AtomicInteger(0);
|
|
@@ -246,56 +299,41 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
|
|
|
while (i < examDetail.getTotalSubjects()) {
|
|
|
int seq = atomicInteger.getAndIncrement();
|
|
|
int mod = seq % paperTypes.length;
|
|
|
- if (Objects.nonNull(pdfDto)) {
|
|
|
- createPdfNewUtil.getExamStudentPaperPdf(paperTypes[mod], paperPdfDto, studentPaperPdfList, null);
|
|
|
- }
|
|
|
+ createPdfNewUtil.getExamStudentPaperPdf(paperTypes[mod], paperPdfDtoList, createPdfDto, null);
|
|
|
i++;
|
|
|
}
|
|
|
} else {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("数据错误:未找到考生或者印刷数量");
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("考试数据有误,未找到考生或者印刷数量");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取备份试卷
|
|
|
+ PdfDto pdfDto = createPdfNewUtil.getBackupPaperPdfList(paperPdfDtoList, backupCount, createPdfDto);
|
|
|
+ if (Objects.nonNull(pdfDto)) {
|
|
|
+ examDetailCourse.setPaperPagesA3(pdfDto.getPageCount());
|
|
|
}
|
|
|
- // 考生试卷
|
|
|
- createPdfDto.getPaperPdfList().addAll(studentPaperPdfList);
|
|
|
}
|
|
|
|
|
|
// 题卡数据组装
|
|
|
if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.CARD_A3.equals(createPdfType)) && printContent.contains("CARD")) {
|
|
|
- Map<String, ExamCard> examCardDetailMap = new HashMap<>();
|
|
|
- Map<String, String> cardContentMap = new HashMap<>();
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
- JSONArray jsonArray = new JSONArray();
|
|
|
- JSONArray stuJsonArray = new JSONArray();
|
|
|
- for (String s : paperTypes) {
|
|
|
- examCard = examCardMap.get(s);
|
|
|
- Optional.ofNullable(examCard).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("卷型" + s + "题卡不存在"));
|
|
|
-
|
|
|
- //把模板页面上的 ${} 替换成空
|
|
|
- String cardContent = createPdfNewUtil.resetHtmlTemplateBar(examCard.getHtmlContent());
|
|
|
-
|
|
|
- for (int i = 1; i <= backupCount; i++) {
|
|
|
- String packageCode = examDetail.getPackageCode() + String.format(SystemConstant.DATE_TIME_FORMAT, i);
|
|
|
- BasicAttachment basicAttachment = createPdfNewUtil.cardHtml(packageCode, cardContent, s, tbTaskPdf.getCreateId(), backupCardPdfList, basicCardRule);
|
|
|
- examDetailCourse.setCardPagesA3(basicAttachment.getPages());
|
|
|
-
|
|
|
- JSONObject object = new JSONObject();
|
|
|
- object.put("name", s);
|
|
|
- object.put("attachmentId", basicAttachment.getId());
|
|
|
- object.put("packageCode", packageCode);
|
|
|
- jsonArray.add(object);
|
|
|
+ //查询题卡规则
|
|
|
+ BasicCardRule basicCardRule = basicCardRuleService.getById(examTask.getCardRuleId());
|
|
|
+ Map<String, ExamCard> examCardMap = new HashMap<>();
|
|
|
+ ExamCard examCard;
|
|
|
+ for (PaperInfoVo paperInfoVo : examTaskDetail.getPaperInfoVoList(null)) {
|
|
|
+ if (StringUtils.isNotBlank(paperInfoVo.getCardId())) {
|
|
|
+ examCard = examCardService.getById(paperInfoVo.getCardId());
|
|
|
+ if (Objects.isNull(examCard)) {
|
|
|
+ throw ExceptionResultEnum.EXAM_CARD_IS_NULL.exception();
|
|
|
+ }
|
|
|
+ examCardMap.put(paperInfoVo.getName(), examCard);
|
|
|
}
|
|
|
- examCardDetailMap.put(s, examCard);
|
|
|
- cardContentMap.put(s, cardContent);
|
|
|
}
|
|
|
- jsonObject.put("card", jsonArray);
|
|
|
- examDetailCourse.setAttachmentId(jsonObject.toJSONString());
|
|
|
-
|
|
|
- // 备用题卡
|
|
|
- createPdfDto.getBackupCardPdfList().addAll(backupCardPdfList);
|
|
|
|
|
|
+ JSONArray stuJsonArray = new JSONArray();
|
|
|
if (examStudentList != null && examStudentList.size() > 0) {
|
|
|
for (ExamStudent t : examStudentList) {
|
|
|
// 用带条码的模板
|
|
|
- createPdfNewUtil.examStudentHtml(examCardDetailMap.get(t.getPaperType()).getHtmlContent(), t, t.getPaperType(), examDetail, tbTaskPdf.getCreateId(), studentCardPdfList, basicCardRule);
|
|
|
+ createPdfNewUtil.examStudentHtml(examCardMap.get(t.getPaperType()).getHtmlContent(), t, t.getPaperType(), examDetail, tbTaskPdf.getCreateId(), studentCardPdfList, basicCardRule);
|
|
|
}
|
|
|
examStudentService.updateBatchById(examStudentList);
|
|
|
} else if (examDetailCourse.getTotalSubjects() != null) {
|
|
@@ -306,7 +344,7 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
|
|
|
int seq = atomicInteger.getAndIncrement();
|
|
|
int mod = seq % examTaskDetail.getDrawCount();
|
|
|
String tempPaperType = paperTypes[mod];
|
|
|
- BasicAttachment basicAttachment = createPdfNewUtil.examStudentHtml(cardContentMap.get(tempPaperType), null, tempPaperType, examDetail, tbTaskPdf.getCreateId(), studentCardPdfList, basicCardRule);
|
|
|
+ BasicAttachment basicAttachment = createPdfNewUtil.examStudentHtml(examCardMap.get(tempPaperType).getHtmlContent(), null, tempPaperType, examDetail, tbTaskPdf.getCreateId(), studentCardPdfList, basicCardRule);
|
|
|
|
|
|
if (!stringBasicAttachmentMap.containsKey(tempPaperType)) {
|
|
|
stringBasicAttachmentMap.put(tempPaperType, basicAttachment);
|
|
@@ -326,84 +364,36 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
|
|
|
}
|
|
|
// 题卡
|
|
|
createPdfDto.getCardPdfList().addAll(studentCardPdfList);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- @Transactional
|
|
|
- public void updateAssignPaperType(TBTaskPdf tbTaskPdf, List<ExamDetailCourse> examDetailCourseList) {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
+ for (String s : paperTypes) {
|
|
|
+ examCard = examCardMap.get(s);
|
|
|
+ for (int i = 1; i <= backupCount; i++) {
|
|
|
+ String backupPackageCode = examDetail.getPackageCode() + String.format(SystemConstant.DATE_TIME_FORMAT, i);
|
|
|
+ String replaceBackupCardHtmlContent = createPdfNewUtil.replaceBackupCardHtmlParam(examCard.getHtmlContent(), s, basicCardRule, backupPackageCode);
|
|
|
+ File pdfFile = PdfUtil.htmlToPdf(replaceBackupCardHtmlContent);
|
|
|
+ PdfDto pdfDto = PdfUtil.addPdfPage(pdfFile);
|
|
|
+ FilePathVo filePathVo = fileUploadService.uploadFile(pdfFile, UploadFileEnum.PDF, pdfFile.getName());
|
|
|
+ BasicAttachment basicAttachment = new BasicAttachment(JSON.toJSONString(filePathVo), pdfFile.getName(), SystemConstant.PDF_PREFIX, new BigDecimal(pdfFile.length()), filePathVo.getMd5(), tbTaskPdf.getCreateId());
|
|
|
+ basicAttachmentService.save(basicAttachment);
|
|
|
|
|
|
- for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
|
|
|
- ExamTaskAssignPaperType examTaskAssignPaperType = examTaskAssignPaperTypeService.extractPaperType(tbTaskPdf, examDetailCourse);
|
|
|
- List<ExamStudent> examStudentList = examStudentService.listByExamDetailCourseId(examDetailCourse.getId());
|
|
|
- // 考生实际关联试卷类型
|
|
|
- List<String> relatePaperTypes = new ArrayList<>();
|
|
|
- List<String> paperTypes = Arrays.stream(examTaskAssignPaperType.getPaperType().split(",")).sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList());
|
|
|
- if (CollectionUtils.isNotEmpty(examStudentList)) {
|
|
|
- AtomicInteger atomicInteger = new AtomicInteger(0);
|
|
|
- for (ExamStudent examStudent : examStudentList) {
|
|
|
- int i1 = atomicInteger.getAndIncrement();
|
|
|
- int mod = i1 % paperTypes.size();
|
|
|
- examStudent.setPaperType(paperTypes.get(mod));
|
|
|
- if (!relatePaperTypes.contains(examStudent.getPaperType())) {
|
|
|
- relatePaperTypes.add(examStudent.getPaperType());
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (examDetailCourse.getTotalSubjects() != null) {
|
|
|
- if (examDetailCourse.getTotalSubjects().intValue() - paperTypes.size() >= 0) {
|
|
|
- relatePaperTypes.addAll(paperTypes);
|
|
|
- } else {
|
|
|
- for (int i = 0; i < examDetailCourse.getTotalSubjects().intValue(); i++) {
|
|
|
- relatePaperTypes.add(paperTypes.get(i));
|
|
|
+ examDetailCourse.setCardPagesA3(pdfDto.getActualPageCount());
|
|
|
+
|
|
|
+ // 备用题卡
|
|
|
+ createPdfDto.getCardPdfList().add(new PdfDto(pdfFile.getPath(), PageSizeEnum.A3, pdfDto.getPageCount()));
|
|
|
+
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
+ object.put("name", s);
|
|
|
+ object.put("attachmentId", basicAttachment.getId());
|
|
|
+ object.put("packageCode", backupPackageCode);
|
|
|
+ jsonArray.add(object);
|
|
|
}
|
|
|
}
|
|
|
- } else {
|
|
|
- relatePaperTypes.addAll(paperTypes);
|
|
|
- }
|
|
|
-
|
|
|
- // 更新卷型数据
|
|
|
- if (!CollectionUtils.isEqualCollection(paperTypes, relatePaperTypes)) {
|
|
|
- examTaskAssignPaperType.setPaperType(String.join(",", relatePaperTypes));
|
|
|
- examTaskAssignPaperTypeService.updateByMultiId(examTaskAssignPaperType);
|
|
|
+ jsonObject.put("card", jsonArray);
|
|
|
+ examDetailCourse.setAttachmentId(jsonObject.toJSONString());
|
|
|
}
|
|
|
-
|
|
|
- examDetailCourse.setPaperType(String.join(",", relatePaperTypes));
|
|
|
- examDetailCourseService.updateById(examDetailCourse);
|
|
|
-
|
|
|
- examStudentService.updateBatchById(examStudentList);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void updatePdfDataStatus(TBTaskPdf tbTaskPdf) {
|
|
|
- //查询printPlan
|
|
|
- ExamPrintPlan examPrintPlan = examPrintPlanService.getById(tbTaskPdf.getPrintPlanId());
|
|
|
- if (Objects.isNull(examPrintPlan)) {
|
|
|
- throw ExceptionResultEnum.EXAM_PRINT_IS_NULL.exception();
|
|
|
- }
|
|
|
- UpdateWrapper<ExamDetail> examDetailQueryWrapper = new UpdateWrapper<>();
|
|
|
- examDetailQueryWrapper.lambda().set(ExamDetail::getStatus, ExamDetailStatusEnum.CREATING)
|
|
|
- .eq(ExamDetail::getId, tbTaskPdf.getId());
|
|
|
- examDetailService.update(examDetailQueryWrapper);
|
|
|
-
|
|
|
- //所有考场都撤回,印刷任务状态改为就绪
|
|
|
- QueryWrapper<ExamDetail> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.lambda().eq(ExamDetail::getPrintPlanId, tbTaskPdf.getPrintPlanId())
|
|
|
- .notIn(ExamDetail::getStatus, ExamDetailStatusEnum.NEW, ExamDetailStatusEnum.READY);
|
|
|
- List<ExamDetail> examDetails = examDetailService.list(queryWrapper);
|
|
|
- if (CollectionUtils.isEmpty(examDetails)) {
|
|
|
- examPrintPlanService.updateStatusById(tbTaskPdf.getPrintPlanId(), PrintPlanStatusEnum.READY);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 更新考试计划
|
|
|
- *
|
|
|
- * @param basicPrintConfig
|
|
|
- * @param examPrintPlan
|
|
|
- */
|
|
|
- @Transactional
|
|
|
- public void updateExamPrintPlan(BasicPrintConfig basicPrintConfig, ExamPrintPlan examPrintPlan) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
}
|