|
@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.aliyun.oss.common.utils.BinaryUtil;
|
|
import com.aliyun.oss.common.utils.BinaryUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
+import com.itextpdf.text.DocumentException;
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
import com.qmth.distributed.print.business.annotation.ExcelDBFieldDesc;
|
|
import com.qmth.distributed.print.business.annotation.ExcelDBFieldDesc;
|
|
import com.qmth.distributed.print.business.bean.dto.*;
|
|
import com.qmth.distributed.print.business.bean.dto.*;
|
|
@@ -160,6 +161,179 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
return map;
|
|
return map;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 创建pdf核心逻辑
|
|
|
|
+ *
|
|
|
|
+ * @param examDetailCourseList
|
|
|
|
+ * @param examPrintPlan
|
|
|
|
+ * @param examDetail
|
|
|
|
+ * @param sysUser
|
|
|
|
+ * @param paperTypeParam
|
|
|
|
+ * @param basicAttachmentList
|
|
|
|
+ * @param attachmentIds
|
|
|
|
+ * @param ftlList
|
|
|
|
+ * @param basicSchool
|
|
|
|
+ * @param list
|
|
|
|
+ * @return
|
|
|
|
+ * @throws IOException
|
|
|
|
+ * @throws DocumentException
|
|
|
|
+ */
|
|
|
|
+ @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"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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);
|
|
|
|
+
|
|
|
|
+ PaperPdfDto paperPdfDto = createPdfUtil.getPaperPdfFile(paperType, examTaskDetail);
|
|
|
|
+
|
|
|
|
+ //获取试卷pdf
|
|
|
|
+ PdfDto pdfDto = createPdfUtil.getPaperPdf(paperPdfDto, examPrintPlan.getBackupCount(), backupPaperTempPdfList);
|
|
|
|
+ examDetailCourse.setPaperPagesA3(Objects.nonNull(pdfDto) ? pdfDto.getPageCount() : examDetailCourse.getPaperPagesA3());
|
|
|
|
+ list[1].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);
|
|
|
|
+ }
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+ return basicAttachmentList;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 创建pdf逻辑
|
|
* 创建pdf逻辑
|
|
*
|
|
*
|
|
@@ -167,7 +341,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- @Transactional
|
|
|
|
|
|
+// @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;
|
|
try {
|
|
try {
|
|
@@ -179,11 +353,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
List<Long> examDetailCourseIds = Objects.nonNull(map.get("examDetailCourseIds")) ? (List<Long>) map.get("examDetailCourseIds") : null;
|
|
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;
|
|
String paperTypeParam = Objects.nonNull(map.get("paperType")) ? (String) map.get("paperType") : null;
|
|
|
|
|
|
- //这里为保存附件html的逻辑
|
|
|
|
- //查询题卡详情是否有附件id,有的话则把以前的附件删除
|
|
|
|
- Set<Long> attachmentIds = null;
|
|
|
|
- Set<File> ftlList = null;
|
|
|
|
-
|
|
|
|
//查询printPlan
|
|
//查询printPlan
|
|
ExamPrintPlan examPrintPlan = examPrintPlanService.getById(tbTask.getPrintPlanId());
|
|
ExamPrintPlan examPrintPlan = examPrintPlanService.getById(tbTask.getPrintPlanId());
|
|
if (Objects.isNull(examPrintPlan)) {
|
|
if (Objects.isNull(examPrintPlan)) {
|
|
@@ -209,8 +378,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
if (Objects.isNull(examDetailList) || examDetailList.size() == 0) {
|
|
if (Objects.isNull(examDetailList) || examDetailList.size() == 0) {
|
|
throw ExceptionResultEnum.ERROR.exception("考务计划为空");
|
|
throw ExceptionResultEnum.ERROR.exception("考务计划为空");
|
|
}
|
|
}
|
|
- attachmentIds = Objects.isNull(attachmentIds) ? attachmentIds = new HashSet<>() : attachmentIds;
|
|
|
|
- ftlList = Objects.isNull(ftlList) ? ftlList = new HashSet<>() : ftlList;
|
|
|
|
|
|
+ Set<Long> attachmentIds = new HashSet<>();
|
|
|
|
+ Set<File> ftlList = new HashSet<>();
|
|
for (ExamDetail examDetail : examDetailList) {
|
|
for (ExamDetail examDetail : examDetailList) {
|
|
tbTask.setObjName(examDetail.getExamRoom() + "-" + examDetail.getExamPlace());
|
|
tbTask.setObjName(examDetail.getExamRoom() + "-" + examDetail.getExamPlace());
|
|
//查询examDetailCourse
|
|
//查询examDetailCourse
|
|
@@ -221,161 +390,33 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
examDetailCourseQueryWrapper.lambda().eq(ExamDetailCourse::getExamDetailId, examDetail.getId());
|
|
examDetailCourseQueryWrapper.lambda().eq(ExamDetailCourse::getExamDetailId, examDetail.getId());
|
|
}
|
|
}
|
|
List<ExamDetailCourse> examDetailCourseList = detailCourseService.list(examDetailCourseQueryWrapper);
|
|
List<ExamDetailCourse> examDetailCourseList = detailCourseService.list(examDetailCourseQueryWrapper);
|
|
- 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) {
|
|
|
|
- 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"));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- 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);
|
|
|
|
-
|
|
|
|
- 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"));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Collections.sort(variablePdfList, 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));
|
|
|
|
- }
|
|
|
|
- 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(), schoolId, variablePdfList, ordinaryPdfList, paperPdfList, examStudentPdfList, backupPaperPdfList, cardPdfList));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (PrintMethodEnum.AUTO == basicExamRule.getPrintMethod()) {
|
|
|
|
- examPrintPlan.setStatus(PrintPlanStatusEnum.PRINTING);
|
|
|
|
- examPrintPlanService.updateById(examPrintPlan);
|
|
|
|
|
|
+ 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);
|
|
@@ -391,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 {
|