|
@@ -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.*;
|
|
@@ -47,6 +48,7 @@ import java.io.*;
|
|
import java.lang.reflect.Field;
|
|
import java.lang.reflect.Field;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.function.Function;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -117,6 +119,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
@Resource
|
|
@Resource
|
|
TBTaskService tbTaskService;
|
|
TBTaskService tbTaskService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ BasicCardRuleService basicCardRuleService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 创建pdf前置条件
|
|
* 创建pdf前置条件
|
|
*
|
|
*
|
|
@@ -133,7 +138,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
//查询printPlan
|
|
//查询printPlan
|
|
ExamPrintPlan examPrintPlan = examPrintPlanService.getById(tbTask.getPrintPlanId());
|
|
ExamPrintPlan examPrintPlan = examPrintPlanService.getById(tbTask.getPrintPlanId());
|
|
if (Objects.isNull(examPrintPlan)) {
|
|
if (Objects.isNull(examPrintPlan)) {
|
|
- throw ExceptionResultEnum.ERROR.exception("印刷计划为空");
|
|
|
|
|
|
+ throw ExceptionResultEnum.EXAM_PRINT_IS_NULL.exception();
|
|
}
|
|
}
|
|
UpdateWrapper<ExamDetail> examDetailQueryWrapper = new UpdateWrapper<>();
|
|
UpdateWrapper<ExamDetail> examDetailQueryWrapper = new UpdateWrapper<>();
|
|
examDetailQueryWrapper.lambda().eq(ExamDetail::getSchoolId, sysUser.getSchoolId())
|
|
examDetailQueryWrapper.lambda().eq(ExamDetail::getSchoolId, sysUser.getSchoolId())
|
|
@@ -160,6 +165,208 @@ 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 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,
|
|
|
|
+ List<PdfDto>... list
|
|
|
|
+ ) throws IOException, DocumentException {
|
|
|
|
+ if (Objects.nonNull(examDetailCourseList) && examDetailCourseList.size() > 0) {
|
|
|
|
+ Map<Long, BasicCardRule> basicCardRuleMap = new HashMap<>();
|
|
|
|
+ for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
|
|
|
|
+ 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.EXAM_TASK_IS_NULL.exception();
|
|
|
|
+ }
|
|
|
|
+ Set<Long> examTaskIds = examTaskList.stream().map(s -> s.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();
|
|
|
|
+ for (ExamTaskDetail examTaskDetail : examTaskDetailList) {
|
|
|
|
+ //查询题卡
|
|
|
|
+ ExamCard examCard = examCardService.getById(examTaskDetail.getCardId());
|
|
|
|
+ if (Objects.isNull(examCard)) {
|
|
|
|
+ throw ExceptionResultEnum.EXAM_CARD_IS_NULL.exception();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //查询题卡规则
|
|
|
|
+ ExamTask examTask = examTaskMap.get(examTaskDetail.getExamTaskId());
|
|
|
|
+ BasicCardRule basicCardRule = null;
|
|
|
|
+ if (Objects.nonNull(examTask)) {
|
|
|
|
+ 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());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ 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[0].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, basicCardRule);
|
|
|
|
+ examDetailCourse.setCardPagesA3(basicAttachment.getPages());
|
|
|
|
+ basicAttachmentList.add(basicAttachment);
|
|
|
|
+ }
|
|
|
|
+ list[1].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);
|
|
|
|
+
|
|
|
|
+ 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[2].addAll(paperPdfTempList);
|
|
|
|
+ list[3].addAll(examStudentTempPdfList);
|
|
|
|
+ examStudentService.saveOrUpdateBatch(examStudentList);
|
|
|
|
+ jsonObject.put("card", jsonArray);
|
|
|
|
+ examCardDetail.setAttachmentId(jsonObject.toJSONString());
|
|
|
|
+ }
|
|
|
|
+ examCardDetailService.saveOrUpdateBatch(examCardDetailList);
|
|
|
|
+ }
|
|
|
|
+ examTaskDetailService.saveOrUpdateBatch(examTaskDetailList);
|
|
|
|
+ }
|
|
|
|
+ detailCourseService.saveOrUpdateBatch(examDetailCourseList);
|
|
|
|
+ }
|
|
|
|
+ return basicAttachmentList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 创建A4文件
|
|
|
|
+ *
|
|
|
|
+ * @param examPrintPlan
|
|
|
|
+ * @param examDetail
|
|
|
|
+ * @param basicSchool
|
|
|
|
+ * @param ftlList
|
|
|
|
+ * @param examDetailCourseListIds
|
|
|
|
+ * @param list
|
|
|
|
+ * @throws IOException
|
|
|
|
+ * @throws DocumentException
|
|
|
|
+ */
|
|
|
|
+ @Transactional
|
|
|
|
+ public void createA4File(ExamPrintPlan examPrintPlan, ExamDetail examDetail, BasicSchool basicSchool, Set<File> ftlList, List<Long> examDetailCourseListIds, List<PdfDto>... list) 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, list[0], (Integer) jsonObjectOrdinary.get("backupCount"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (Objects.nonNull(examPrintPlan.getVariableContent())) {
|
|
|
|
+ List<ExamStudentCourseDto> examStudentCourseDtoList = examStudentService.queryBySchoolIdAndExamDetailCourseIds(basicSchool.getId(), examDetailCourseListIds);
|
|
|
|
+ int count = (int) examStudentCourseDtoList.stream().filter(s -> s.getPaperPageA3() > 2).count();
|
|
|
|
+ boolean tag = count > 0 ? true : false;
|
|
|
|
+
|
|
|
|
+ //获取变量印品
|
|
|
|
+ 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, examStudentCourseDtoList, list[1], (Integer) jsonObjectVariable.get("backupCount"));
|
|
|
|
+ } else if (Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "PACKAGE")) {//卷袋贴
|
|
|
|
+ createPdfUtil.createPaperPackage(tag, basicAttachment, basicSchool.getName(), examDetail, examStudentCourseDtoList, list[1], (Integer) jsonObjectVariable.get("backupCount"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Collections.sort(list[1], new Comparator<PdfDto>() {
|
|
|
|
+ @Override
|
|
|
|
+ public int compare(PdfDto o1, PdfDto o2) {
|
|
|
|
+ return o1.getSequence() > o2.getSequence() ? 1 : -1;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 创建pdf逻辑
|
|
* 创建pdf逻辑
|
|
*
|
|
*
|
|
@@ -167,7 +374,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,21 +386,16 @@ 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)) {
|
|
- throw ExceptionResultEnum.ERROR.exception("印刷计划为空");
|
|
|
|
|
|
+ throw ExceptionResultEnum.EXAM_PRINT_IS_NULL.exception();
|
|
}
|
|
}
|
|
|
|
|
|
BasicSchool basicSchool = cacheService.schoolCache(examPrintPlan.getSchoolId());
|
|
BasicSchool basicSchool = cacheService.schoolCache(examPrintPlan.getSchoolId());
|
|
BasicExamRule basicExamRule = basicExamRuleService.getBySchoolId(schoolId);
|
|
BasicExamRule basicExamRule = basicExamRuleService.getBySchoolId(schoolId);
|
|
if (Objects.isNull(basicExamRule)) {
|
|
if (Objects.isNull(basicExamRule)) {
|
|
- throw ExceptionResultEnum.ERROR.exception("考务规则为空");
|
|
|
|
|
|
+ throw ExceptionResultEnum.EXAM_RULE_IS_NULL.exception();
|
|
}
|
|
}
|
|
|
|
|
|
//查询examDetail
|
|
//查询examDetail
|
|
@@ -207,10 +409,10 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
}
|
|
}
|
|
List<ExamDetail> examDetailList = detailService.list(examDetailQueryWrapper);
|
|
List<ExamDetail> examDetailList = detailService.list(examDetailQueryWrapper);
|
|
if (Objects.isNull(examDetailList) || examDetailList.size() == 0) {
|
|
if (Objects.isNull(examDetailList) || examDetailList.size() == 0) {
|
|
- throw ExceptionResultEnum.ERROR.exception("考务计划为空");
|
|
|
|
|
|
+ throw ExceptionResultEnum.EXAM_DETAIL_IS_NULL.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 +423,40 @@ 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<Long> examDetailCourseListIds = examDetailCourseList.stream().map(s -> s.getId()).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ 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,
|
|
|
|
+ backupPaperPdfList,
|
|
|
|
+ cardPdfList,
|
|
|
|
+ paperPdfList,
|
|
|
|
+ examStudentPdfList);
|
|
|
|
+
|
|
|
|
+ createA4File(examPrintPlan, examDetail, basicSchool, ftlList, examDetailCourseListIds, ordinaryPdfList, variablePdfList);
|
|
|
|
+
|
|
|
|
+ //合并pdf
|
|
|
|
+ String dirNameA3 = createPdfUtil.mergeA3Pdf(paperPdfList, examStudentPdfList, backupPaperPdfList, cardPdfList);
|
|
|
|
+ String dirNameA4 = createPdfUtil.mergeA4Pdf(variablePdfList, ordinaryPdfList);
|
|
|
|
+
|
|
|
|
+ List<PdfDto> mergePdfDeleteList = new ArrayList<>();
|
|
|
|
+ mergePdfDeleteList.addAll(examStudentPdfList);
|
|
|
|
+ mergePdfDeleteList.addAll(cardPdfList);
|
|
|
|
+ basicAttachmentList.add(createPdfUtil.mergePdfSaveDb(dirNameA4, dirNameA3, tbTask, sysUser.getId(), examDetail, basicExamRule, mergePdfDeleteList));
|
|
}
|
|
}
|
|
|
|
+ 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 +472,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 {
|