|
@@ -8,6 +8,7 @@ import com.google.gson.Gson;
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
import com.qmth.distributed.print.business.bean.dto.excel.UserImportDto;
|
|
import com.qmth.distributed.print.business.bean.dto.excel.UserImportDto;
|
|
import com.qmth.distributed.print.business.entity.*;
|
|
import com.qmth.distributed.print.business.entity.*;
|
|
|
|
+import com.qmth.distributed.print.business.enums.DrawRuleEnum;
|
|
import com.qmth.distributed.print.business.enums.ExamStatusEnum;
|
|
import com.qmth.distributed.print.business.enums.ExamStatusEnum;
|
|
import com.qmth.distributed.print.business.service.*;
|
|
import com.qmth.distributed.print.business.service.*;
|
|
import com.qmth.distributed.print.business.templete.service.TaskLogicService;
|
|
import com.qmth.distributed.print.business.templete.service.TaskLogicService;
|
|
@@ -178,9 +179,13 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
List<ExamDetailCourse> examDetailCourseList = detailCourseService.list(examDetailCourseQueryWrapper);
|
|
List<ExamDetailCourse> examDetailCourseList = detailCourseService.list(examDetailCourseQueryWrapper);
|
|
|
|
|
|
for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
|
|
for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
|
|
- List<String> paperPdfList = new ArrayList<>();
|
|
|
|
- List<String> cardPdfList = new ArrayList<>();
|
|
|
|
- List<String> examStudentPdfList = new ArrayList<>();
|
|
|
|
|
|
+ List<String> variablePdfList = new ArrayList<>();//变量印品(签到表、卷袋贴)
|
|
|
|
+ List<String> ordinaryPdfList = new ArrayList<>();//普通印品(登记表)
|
|
|
|
+ List<String> paperPdfList = new ArrayList<>();//所有试卷
|
|
|
|
+ List<String> examStudentPdfList = new ArrayList<>();//所有题卡
|
|
|
|
+ List<String> backUpPaperPdfList = new ArrayList<>();//备份试卷
|
|
|
|
+ List<String> cardPdfList = new ArrayList<>();//备份题卡
|
|
|
|
+
|
|
//查询试卷
|
|
//查询试卷
|
|
QueryWrapper<ExamTask> examTaskQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<ExamTask> examTaskQueryWrapper = new QueryWrapper<>();
|
|
examTaskQueryWrapper.lambda().eq(ExamTask::getSchoolId, sysUser.getSchoolId())
|
|
examTaskQueryWrapper.lambda().eq(ExamTask::getSchoolId, sysUser.getSchoolId())
|
|
@@ -211,54 +216,34 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
examCardDetailQueryWrapper.lambda().eq(ExamCardDetail::getCardId, examCard.getId());
|
|
examCardDetailQueryWrapper.lambda().eq(ExamCardDetail::getCardId, examCard.getId());
|
|
List<ExamCardDetail> examCardDetailList = examCardDetailService.list(examCardDetailQueryWrapper);
|
|
List<ExamCardDetail> examCardDetailList = examCardDetailService.list(examCardDetailQueryWrapper);
|
|
|
|
|
|
- String[] paperTypes = examTaskDetail.getPaperType().split("/");
|
|
|
|
- JSONObject jsonObjectPaper = JSONObject.parseObject(examTaskDetail.getPaperAttachmentIds());
|
|
|
|
- JSONArray jsonArrayPaper = jsonObjectPaper.getJSONArray("paper");
|
|
|
|
- for (int i = 0; i < jsonArrayPaper.size(); i++) {
|
|
|
|
- JSONObject object = (JSONObject) jsonArrayPaper.get(i);
|
|
|
|
- if (Objects.nonNull(object.get("attachmentId"))) {
|
|
|
|
- Long attachmentId = Long.parseLong(String.valueOf(object.get("attachmentId")));
|
|
|
|
- BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
|
|
|
|
- paperPdfList.add(commonService.getFile(basicAttachment.getPath(), false));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ //抽取卷型
|
|
|
|
+ String paperType = getPaperType(examPrintPlan, examTaskDetail);
|
|
|
|
+
|
|
|
|
+ //获取试卷pdf
|
|
|
|
+ getPaperPdf(examTaskDetail, paperPdfList);
|
|
|
|
+
|
|
basicAttachmentList = Objects.isNull(basicAttachmentList) ? basicAttachmentList = new ArrayList<>() : basicAttachmentList;
|
|
basicAttachmentList = Objects.isNull(basicAttachmentList) ? basicAttachmentList = new ArrayList<>() : basicAttachmentList;
|
|
for (ExamCardDetail examCardDetail : examCardDetailList) {
|
|
for (ExamCardDetail examCardDetail : examCardDetailList) {
|
|
- if (Objects.nonNull(examCardDetail.getAttachmentId())) {
|
|
|
|
- JSONObject jsonObjectCard = JSONObject.parseObject(examCardDetail.getAttachmentId());
|
|
|
|
- JSONArray jsonArrayCard = (JSONArray) jsonObjectCard.get("card");
|
|
|
|
- for (int i = 0; i < jsonArrayCard.size(); i++) {
|
|
|
|
- JSONObject object = (JSONObject) jsonArrayCard.get(i);
|
|
|
|
- if (Objects.nonNull(object.get("attachmentId"))) {
|
|
|
|
- attachmentIds.add(Long.parseLong(String.valueOf(object.get("attachmentId"))));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ getCardAttachmentId(examCardDetail, attachmentIds);
|
|
|
|
|
|
//把模板页面上的 ${} 替换成实际内容
|
|
//把模板页面上的 ${} 替换成实际内容
|
|
- String content = examCardDetail.getHtmlContent();
|
|
|
|
- log.info("contentTemp:{}", content);
|
|
|
|
- String cardContent = content;
|
|
|
|
- String studentContent = content;
|
|
|
|
- cardContent = cardContent.replaceAll("<img src=\"data:image/png;base64,\\$\\{examNumber\\}\">", "");
|
|
|
|
- cardContent = cardContent.replaceAll("\\$\\{examNumberStr\\}", "");
|
|
|
|
-
|
|
|
|
- for (String paperType : paperTypes) {
|
|
|
|
- for (Integer integer = 1; integer <= examPrintPlan.getBackupCount(); integer++) {
|
|
|
|
- basicAttachmentList.add(cardHtml(cardContent, paperType, examDetailCourse, examCard, examTaskDetail, jsonArray, sysUser.getId(), cardPdfList));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //查询考生
|
|
|
|
- QueryWrapper<ExamStudent> examStudentQueryWrapper = new QueryWrapper<>();
|
|
|
|
- examStudentQueryWrapper.lambda().eq(ExamStudent::getSchoolId, sysUser.getSchoolId())
|
|
|
|
- .eq(ExamStudent::getExamDetailCourseId, examTaskDetail.getId());
|
|
|
|
- List<ExamStudent> examStudentList = examStudentService.list(examStudentQueryWrapper);
|
|
|
|
-
|
|
|
|
- for (ExamStudent t : examStudentList) {
|
|
|
|
- basicAttachmentList.add(examStudentHtml(attachmentIds, studentContent, t, paperType, examCard, sysUser.getId(), examStudentPdfList));
|
|
|
|
- }
|
|
|
|
- examStudentService.saveOrUpdateBatch(examStudentList);
|
|
|
|
|
|
+ String cardContent = replaceHtmlTemplete(examCardDetail);
|
|
|
|
+ String studentContent = cardContent;
|
|
|
|
+
|
|
|
|
+ for (int i = 1; i <= examPrintPlan.getBackupCount(); i++) {
|
|
|
|
+ basicAttachmentList.add(cardHtml(cardContent, paperType, examDetailCourse, examCard, examTaskDetail, jsonArray, sysUser.getId(), cardPdfList));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //查询考生
|
|
|
|
+ QueryWrapper<ExamStudent> examStudentQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ examStudentQueryWrapper.lambda().eq(ExamStudent::getSchoolId, sysUser.getSchoolId())
|
|
|
|
+ .eq(ExamStudent::getExamDetailCourseId, examTaskDetail.getId());
|
|
|
|
+ List<ExamStudent> examStudentList = examStudentService.list(examStudentQueryWrapper);
|
|
|
|
+
|
|
|
|
+ for (ExamStudent t : examStudentList) {
|
|
|
|
+ basicAttachmentList.add(examStudentHtml(attachmentIds, studentContent, t, paperType, examCard, sysUser.getId(), examStudentPdfList));
|
|
}
|
|
}
|
|
|
|
+ examStudentService.saveOrUpdateBatch(examStudentList);
|
|
jsonObject.put("card", jsonArray);
|
|
jsonObject.put("card", jsonArray);
|
|
examCardDetail.setAttachmentId(jsonObject.toJSONString());
|
|
examCardDetail.setAttachmentId(jsonObject.toJSONString());
|
|
}
|
|
}
|
|
@@ -267,6 +252,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
//合并pdf
|
|
//合并pdf
|
|
basicAttachmentList.add(mergePdf(tbTask, examDetail, sysUser.getId(), paperPdfList, cardPdfList, examStudentPdfList));
|
|
basicAttachmentList.add(mergePdf(tbTask, examDetail, sysUser.getId(), paperPdfList, cardPdfList, examStudentPdfList));
|
|
}
|
|
}
|
|
|
|
+ examTaskDetailService.saveOrUpdateBatch(examTaskDetailList);
|
|
}
|
|
}
|
|
//最后一步删除附件
|
|
//最后一步删除附件
|
|
deleteAttachment(attachmentIds);
|
|
deleteAttachment(attachmentIds);
|
|
@@ -282,6 +268,96 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
return map;
|
|
return map;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 替换html通用模版
|
|
|
|
+ *
|
|
|
|
+ * @param examCardDetail
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public String replaceHtmlTemplete(ExamCardDetail examCardDetail) {
|
|
|
|
+ String content = examCardDetail.getHtmlContent();
|
|
|
|
+ log.info("contentTemp:{}", content);
|
|
|
|
+ content = content.replaceAll("<img src=\"data:image/png;base64,\\$\\{examNumber\\}\">", "");
|
|
|
|
+ content = content.replaceAll("\\$\\{examNumberStr\\}", "");
|
|
|
|
+ return content;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取题卡attachmentId
|
|
|
|
+ *
|
|
|
|
+ * @param examCardDetail
|
|
|
|
+ * @param attachmentIds
|
|
|
|
+ */
|
|
|
|
+ public void getCardAttachmentId(ExamCardDetail examCardDetail, Set<Long> attachmentIds) {
|
|
|
|
+ if (Objects.nonNull(examCardDetail.getAttachmentId())) {
|
|
|
|
+ JSONObject jsonObjectCard = JSONObject.parseObject(examCardDetail.getAttachmentId());
|
|
|
|
+ JSONArray jsonArrayCard = (JSONArray) jsonObjectCard.get("card");
|
|
|
|
+ for (int i = 0; i < jsonArrayCard.size(); i++) {
|
|
|
|
+ JSONObject object = (JSONObject) jsonArrayCard.get(i);
|
|
|
|
+ if (Objects.nonNull(object.get("attachmentId"))) {
|
|
|
|
+ attachmentIds.add(Long.parseLong(String.valueOf(object.get("attachmentId"))));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取试卷pdf
|
|
|
|
+ *
|
|
|
|
+ * @param examTaskDetail
|
|
|
|
+ * @param paperPdfList
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ public void getPaperPdf(ExamTaskDetail examTaskDetail, List<String> paperPdfList) throws IOException {
|
|
|
|
+ JSONObject jsonObjectPaper = JSONObject.parseObject(examTaskDetail.getPaperAttachmentIds());
|
|
|
|
+ JSONArray jsonArrayPaper = jsonObjectPaper.getJSONArray("paper");
|
|
|
|
+ for (int i = 0; i < jsonArrayPaper.size(); i++) {
|
|
|
|
+ JSONObject object = (JSONObject) jsonArrayPaper.get(i);
|
|
|
|
+ if (Objects.nonNull(object.get("attachmentId"))) {
|
|
|
|
+ Long attachmentId = Long.parseLong(String.valueOf(object.get("attachmentId")));
|
|
|
|
+ BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
|
|
|
|
+ paperPdfList.add(commonService.getFile(basicAttachment.getPath(), false));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 抽取试卷
|
|
|
|
+ *
|
|
|
|
+ * @param examPrintPlan
|
|
|
|
+ * @param examTaskDetail
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public String getPaperType(ExamPrintPlan examPrintPlan, ExamTaskDetail examTaskDetail) {
|
|
|
|
+ //抽取卷型
|
|
|
|
+ DrawRuleEnum drawRule = Objects.nonNull(examPrintPlan.getDrawRule()) ? examPrintPlan.getDrawRule() : DrawRuleEnum.ONE;
|
|
|
|
+ //未曝光卷型
|
|
|
|
+ String unexposedPaperType = examTaskDetail.getUnexposedPaperType();
|
|
|
|
+ //已曝光卷型
|
|
|
|
+ String exposedPaperType = examTaskDetail.getExposedPaperType();
|
|
|
|
+ String[] paperTypes = null;
|
|
|
|
+ if (drawRule == DrawRuleEnum.ONE) {
|
|
|
|
+ if (Objects.isNull(unexposedPaperType)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("当前没有未曝光的卷型");
|
|
|
|
+ } else {
|
|
|
|
+ paperTypes = unexposedPaperType.split("/");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if (Objects.isNull(exposedPaperType) || Objects.isNull(unexposedPaperType)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("当前没有未曝光的卷型");
|
|
|
|
+ }
|
|
|
|
+ if (Objects.nonNull(unexposedPaperType)) {
|
|
|
|
+ paperTypes = unexposedPaperType.split("/");
|
|
|
|
+ } else {
|
|
|
|
+ paperTypes = exposedPaperType.split("/");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ int paperRandom = new Random().nextInt(paperTypes.length);
|
|
|
|
+ String paperType = paperTypes[paperRandom];
|
|
|
|
+ examTaskDetail.setPaperType(paperType);
|
|
|
|
+ return paperType;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 合并pdf
|
|
* 合并pdf
|
|
*
|
|
*
|