|
@@ -168,432 +168,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
@Resource
|
|
|
SysRoleService sysRoleService;
|
|
|
|
|
|
- /**
|
|
|
- * 创建pdf前置条件
|
|
|
- *
|
|
|
- * @param map
|
|
|
- * @return
|
|
|
- */
|
|
|
- @Override
|
|
|
- @Transactional
|
|
|
- public Map<String, Object> createPdfPrepose(Map<String, Object> map) {
|
|
|
- TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
|
|
|
- SysUser sysUser = (SysUser) map.get(SystemConstant.USER);
|
|
|
- Long examDetailId = tbTask.getEntityId();
|
|
|
- //查询printPlan
|
|
|
- ExamPrintPlan examPrintPlan = examPrintPlanService.getById(tbTask.getPrintPlanId());
|
|
|
- if (Objects.isNull(examPrintPlan)) {
|
|
|
- throw ExceptionResultEnum.EXAM_PRINT_IS_NULL.exception();
|
|
|
- }
|
|
|
- UpdateWrapper<ExamDetail> examDetailQueryWrapper = new UpdateWrapper<>();
|
|
|
- if (Objects.isNull(examDetailId)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("生成pdf考场ID异常");
|
|
|
- }
|
|
|
- examDetailQueryWrapper.lambda().set(ExamDetail::getStatus, ExamDetailStatusEnum.CREATING)
|
|
|
- .set(ExamDetail::getTaskId, tbTask.getId())
|
|
|
- .eq(ExamDetail::getId, examDetailId);
|
|
|
- examDetailService.update(examDetailQueryWrapper);
|
|
|
-
|
|
|
- //所有考场都撤回,印刷任务状态改为就绪
|
|
|
- examPrintPlanService.updateStatusById(tbTask.getPrintPlanId(), PrintPlanStatusEnum.READY);
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 创建pdf核心逻辑
|
|
|
- *
|
|
|
- * @param examDetailCourseList
|
|
|
- * @param examPrintPlan 印刷计划
|
|
|
- * @param examDetail 考场对象
|
|
|
- * @param sysUser 当前用户
|
|
|
- * @param specifyPaperType 试卷类型
|
|
|
- * @param basicAttachmentList 附件集合
|
|
|
- * @param attachmentIds
|
|
|
- * @param fileTempList
|
|
|
- * @param list
|
|
|
- */
|
|
|
- @Transactional
|
|
|
- public List<BasicAttachment> createPdfCoreLogic(List<ExamDetailCourse> examDetailCourseList,
|
|
|
- ExamPrintPlan examPrintPlan,
|
|
|
- ExamDetail examDetail,
|
|
|
- SysUser sysUser,
|
|
|
- String specifyPaperType,
|
|
|
- CreatePdfTypeEnum createPdfType,
|
|
|
- List<BasicAttachment> basicAttachmentList,
|
|
|
- Set<Long> attachmentIds,
|
|
|
- List<File> fileTempList,
|
|
|
- List<PdfDto>... list
|
|
|
- ) throws Exception {
|
|
|
- if (CreatePdfTypeEnum.SIGN.equals(createPdfType) || CreatePdfTypeEnum.PACKAGE.equals(createPdfType) || CreatePdfTypeEnum.CHECK_IN.equals(createPdfType)) {
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
|
|
|
- List<PdfDto> studentPaperPdfList = new ArrayList<>();//所有试卷
|
|
|
- List<PdfDto> studentCardPdfList = new ArrayList<>();//所有题卡
|
|
|
- List<PdfDto> backupPaperPdfList = new ArrayList<>();//备份试卷
|
|
|
- List<PdfDto> backupCardPdfList = new ArrayList<>();//备份题卡
|
|
|
-
|
|
|
-
|
|
|
- String printContent = examPrintPlan.getPrintContent();
|
|
|
- if (StringUtils.isBlank(printContent)) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- //查询命题任务绑定的试卷和题卡
|
|
|
- ExamTask examTask = examTaskService.getByExamIdAndCourseCodeAndPaperNumber(examDetail.getExamId(), examDetailCourse.getCourseCode(), examDetailCourse.getPaperNumber());
|
|
|
- if (examTask == null) {
|
|
|
- throw ExceptionResultEnum.EXAM_TASK_IS_NULL.exception();
|
|
|
- } else if (examTask.getReview()) {
|
|
|
- examTask = examTaskService.findExamTaskByFlowStatus(sysUser.getSchoolId(), examDetail.getExamId(), examDetailCourse.getCourseCode(), examDetailCourse.getPaperNumber(), FlowStatusEnum.FINISH);
|
|
|
- } else {
|
|
|
- if (!ExamStatusEnum.SUBMIT.equals(examTask.getStatus())) {
|
|
|
- throw ExceptionResultEnum.EXAM_TASK_NOT_SUBMIT.exception();
|
|
|
- } else if (!examTask.getEnable()) {
|
|
|
- throw ExceptionResultEnum.EXAM_TASK_ENABLE.exception();
|
|
|
- }
|
|
|
- }
|
|
|
- ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamTaskId(examTask.getId());
|
|
|
-
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
- JSONArray jsonArray = new JSONArray();
|
|
|
- JSONArray stuJsonArray = new JSONArray();
|
|
|
- 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());
|
|
|
-
|
|
|
- //试卷编号本考场使用卷型key
|
|
|
- String key = getPaperTypeKey(examDetail.getExamId(), examDetailCourse.getPaperNumber(), examDetail.getExamStartTime(), examDetail.getExamEndTime());
|
|
|
- //抽取卷型
|
|
|
- String paperType = createPdfUtil.getPaperType(examPrintPlan.getDrawRule(), examTaskDetail, key, specifyPaperType);
|
|
|
- //查询考生
|
|
|
- List<ExamStudent> examStudentList = examStudentService.listByExamDetailCourseId(examDetailCourse.getId());
|
|
|
-
|
|
|
- List<String> paperTypes = Arrays.stream(paperType.split(",")).sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList());
|
|
|
- // 计算备份数量,默认最小为1份。
|
|
|
- int backupCount = SystemConstant.calcBackupCount(examDetail.getBackupCount(), examDetail.getTotalSubjects(), 1);
|
|
|
-
|
|
|
- // 当前关联试卷类型
|
|
|
- List<String> relatePaperTypes = new ArrayList<>();
|
|
|
- // 考生实际关联试卷类型
|
|
|
- if (!CollectionUtils.isEmpty(examStudentList)) {
|
|
|
- AtomicInteger atomicInteger = new AtomicInteger(0);
|
|
|
- for (ExamStudent t : examStudentList) {
|
|
|
- int i1 = atomicInteger.getAndIncrement();
|
|
|
- int mod = i1 % examTaskDetail.getDrawCount();
|
|
|
- t.setPaperType(paperTypes.get(mod));
|
|
|
- if (!relatePaperTypes.contains(t.getPaperType())) {
|
|
|
- relatePaperTypes.add(t.getPaperType());
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- relatePaperTypes.addAll(paperTypes);
|
|
|
- }
|
|
|
-
|
|
|
- examTaskDetail.setRelatePaperType(String.join(",", relatePaperTypes));
|
|
|
- examDetailCourse.setPaperType(String.join(",", relatePaperTypes));
|
|
|
-
|
|
|
- // 试卷数据组装
|
|
|
- if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.PAPER.equals(createPdfType)) && printContent.contains("PAPER")) {
|
|
|
- List<PaperPdfDto> paperPdfDto = createPdfUtil.getPaperPdfFile(examDetailCourse.getPaperType(), examTaskDetail, fileTempList);
|
|
|
-
|
|
|
- //获取试卷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)) {
|
|
|
- String[] waterMarkNames = {t.getStudentName(), t.getTicketNumber()};
|
|
|
- createPdfUtil.getExamStudentPaperPdf(t.getPaperType(), paperPdfDto, studentPaperPdfList, waterMarkNames);
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (examDetail.getTotalSubjects() != null) {
|
|
|
- AtomicInteger atomicInteger = new AtomicInteger(0);
|
|
|
- int i = 0;
|
|
|
- while (i < examDetail.getTotalSubjects()) {
|
|
|
- int seq = atomicInteger.getAndIncrement();
|
|
|
- int mod = seq % examTaskDetail.getDrawCount();
|
|
|
- if (Objects.nonNull(pdfDto)) {
|
|
|
- createPdfUtil.getExamStudentPaperPdf(paperTypes.get(mod), paperPdfDto, studentPaperPdfList, null);
|
|
|
- }
|
|
|
- i++;
|
|
|
- }
|
|
|
- } else {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("数据错误:未找到考生或者印刷数量");
|
|
|
- }
|
|
|
- // 考生试卷
|
|
|
- list[2].addAll(studentPaperPdfList);
|
|
|
- }
|
|
|
-
|
|
|
- // 题卡数据组装
|
|
|
- basicAttachmentList = Objects.isNull(basicAttachmentList) ? new ArrayList<>() : basicAttachmentList;
|
|
|
- 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<>();
|
|
|
- for (String s : examDetailCourse.getPaperType().split(",")) {
|
|
|
- examCard = examCardMap.get(s);
|
|
|
- Optional.ofNullable(examCard).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("卷型" + s + "题卡不存在"));
|
|
|
-
|
|
|
- createPdfUtil.getCardAttachmentId(examCard, attachmentIds);
|
|
|
-
|
|
|
- //把模板页面上的 ${} 替换成实际内容
|
|
|
- String cardContent = createPdfUtil.resetHtmlTemplateBar(examCard.getHtmlContent());
|
|
|
-
|
|
|
- for (int i = 1; i <= backupCount; i++) {
|
|
|
- BasicAttachment basicAttachment = createPdfUtil.cardHtml(String.format(SystemConstant.DATE_TIME_FORMAT, i), cardContent, examDetail, examDetailCourse, s, jsonArray, sysUser.getId(), backupCardPdfList, basicCardRule, fileTempList);
|
|
|
- examDetailCourse.setCardPagesA3(basicAttachment.getPages());
|
|
|
- basicAttachmentList.add(basicAttachment);
|
|
|
- }
|
|
|
- examCardDetailMap.put(s, examCard);
|
|
|
- cardContentMap.put(s, cardContent);
|
|
|
- }
|
|
|
- // 备用题卡
|
|
|
- list[1].addAll(backupCardPdfList);
|
|
|
-
|
|
|
- if (examStudentList != null && examStudentList.size() > 0) {
|
|
|
- for (ExamStudent t : examStudentList) {
|
|
|
- // 用带条码的模板
|
|
|
- basicAttachmentList.add(createPdfUtil.examStudentHtml(examCardDetailMap.get(t.getPaperType()).getHtmlContent(), t, paperType, examDetail, examDetailCourse, sysUser.getId(), studentCardPdfList, basicCardRule, fileTempList));
|
|
|
- }
|
|
|
- } else if (examDetail.getTotalSubjects() != null) {
|
|
|
- AtomicInteger atomicInteger = new AtomicInteger(0);
|
|
|
- Map<String, BasicAttachment> stringBasicAttachmentMap = new HashMap<>();
|
|
|
- int i = 0;
|
|
|
- while (i < examDetail.getTotalSubjects()) {
|
|
|
- int seq = atomicInteger.getAndIncrement();
|
|
|
- int mod = seq % examTaskDetail.getDrawCount();
|
|
|
- String tempPaperType = paperTypes.get(mod);
|
|
|
- BasicAttachment basicAttachment = createPdfUtil.examStudentHtml(cardContentMap.get(tempPaperType), null, tempPaperType, examDetail, examDetailCourse, sysUser.getId(), studentCardPdfList, basicCardRule, fileTempList);
|
|
|
-
|
|
|
- if (!stringBasicAttachmentMap.containsKey(tempPaperType)) {
|
|
|
- stringBasicAttachmentMap.put(tempPaperType, basicAttachment);
|
|
|
- JSONObject object = new JSONObject();
|
|
|
- object.put("name", tempPaperType);
|
|
|
- object.put("attachmentId", basicAttachment.getId());
|
|
|
- stuJsonArray.add(object);
|
|
|
-
|
|
|
- // 用不带条码的模板
|
|
|
- basicAttachmentList.add(basicAttachment);
|
|
|
- }
|
|
|
- i++;
|
|
|
- }
|
|
|
- } else {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("数据错误:未找到考生或者印刷数量");
|
|
|
- }
|
|
|
- // 题卡
|
|
|
- list[3].addAll(studentCardPdfList);
|
|
|
- jsonObject.put("card", jsonArray);
|
|
|
- examDetailCourse.setAttachmentId(jsonObject.toJSONString());
|
|
|
- examDetailCourse.setCommonAttachmentId(stuJsonArray.toJSONString());
|
|
|
- }
|
|
|
- examStudentService.saveOrUpdateBatch(examStudentList);
|
|
|
-
|
|
|
- examDetailCourse.setAttachmentId(jsonObject.toJSONString());
|
|
|
- examTaskDetailService.saveOrUpdate(examTaskDetail);
|
|
|
-
|
|
|
- }
|
|
|
- examDetailCourseService.saveOrUpdateBatch(examDetailCourseList);
|
|
|
-
|
|
|
- return basicAttachmentList;
|
|
|
- }
|
|
|
-
|
|
|
- private static String getPaperTypeKey(Long examId, String paperNumber, Long examStartTime, Long examEndTime) {
|
|
|
- //试卷编号本考场使用卷型key
|
|
|
- StringJoiner stringJoiner = new StringJoiner("_");
|
|
|
- stringJoiner.add(String.valueOf(examId)).add(paperNumber).add(String.valueOf(examStartTime)).add(String.valueOf(examEndTime));
|
|
|
- return stringJoiner.toString();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 创建A4文件
|
|
|
- *
|
|
|
- * @param createPdfType
|
|
|
- * @param examPrintPlan
|
|
|
- * @param examDetail
|
|
|
- * @param basicSchool
|
|
|
- * @param examDetailCourseList
|
|
|
- * @param fileTempList
|
|
|
- * @param list
|
|
|
- * @throws IOException
|
|
|
- * @throws DocumentException
|
|
|
- */
|
|
|
- @Transactional
|
|
|
- public void createA4File(CreatePdfTypeEnum createPdfType, ExamPrintPlan examPrintPlan, ExamDetail examDetail, BasicSchool basicSchool, List<ExamDetailCourse> examDetailCourseList, List<File> fileTempList, List<PdfDto>... list) throws Exception {
|
|
|
- // 印品
|
|
|
- String ordinaryContent = examPrintPlan.getOrdinaryContent();
|
|
|
- if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.CHECK_IN.equals(createPdfType)) && StringUtils.isNotBlank(ordinaryContent)) {
|
|
|
- //获取普通印品
|
|
|
- JSONArray jsonArrayOrdinary = JSONArray.parseArray(ordinaryContent);
|
|
|
- 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"), fileTempList);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- BasicExam basicExam = basicExamService.getById(examPrintPlan.getExamId());
|
|
|
- if (basicExam.getCategory().equals(ExamCategoryEnum.FORMAL)) {
|
|
|
- String variableContent = examPrintPlan.getVariableContent();
|
|
|
- if (StringUtils.isNotBlank(variableContent)) {
|
|
|
- List<Long> examDetailCourseListIds = examDetailCourseList.stream().map(BaseEntity::getId).collect(Collectors.toList());
|
|
|
- List<ExamStudentCourseDto> examStudentCourseDtoList = examStudentService.queryBySchoolIdAndExamDetailCourseIds(basicSchool.getId(), examDetailCourseListIds);
|
|
|
- //获取变量印品
|
|
|
- JSONArray jsonArrayVariable = JSONArray.parseArray(variableContent);
|
|
|
- for (int i = 0; i < jsonArrayVariable.size(); i++) {
|
|
|
- JSONObject jsonObjectVariable = jsonArrayVariable.getJSONObject(i);
|
|
|
- String type = (String) jsonObjectVariable.get("type");
|
|
|
- if (Objects.nonNull(jsonObjectVariable.get("templateId")) && !Objects.equals("", jsonObjectVariable.get("templateId"))) {
|
|
|
- Long templateId = Long.parseLong((String) jsonObjectVariable.get("templateId"));
|
|
|
- if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.SIGN.equals(createPdfType)) && Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "SIGN")) {//签到表
|
|
|
- createPdfUtil.createSignBook(templateId, basicSchool.getName(), examDetail, examStudentCourseDtoList, list[1], (Integer) jsonObjectVariable.get("backupCount"), examDetailCourseList, fileTempList);
|
|
|
- } else if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.PACKAGE.equals(createPdfType)) && Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "PACKAGE")) {//卷袋贴
|
|
|
- Integer backupCount = SystemConstant.calcBackupCount(examDetail.getBackupCount(), examDetail.getTotalSubjects(), 1);
|
|
|
- createPdfUtil.createPaperPackage(templateId, basicSchool.getName(), examDetail, examStudentCourseDtoList, list[1], backupCount, (Integer) jsonObjectVariable.get("backupCount"), examDetailCourseList, examPrintPlan.getExamId(), fileTempList);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- list[1].sort((o1, o2) -> o1.getSequence() > o2.getSequence() ? 1 : -1);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 创建pdf逻辑
|
|
|
- *
|
|
|
- * @param map
|
|
|
- * @return
|
|
|
- */
|
|
|
- @Override
|
|
|
- public Map<String, Object> executeCreatePdfLogic(Map<String, Object> map) {
|
|
|
- List<BasicAttachment> basicAttachmentList = null;
|
|
|
- List<File> fileTempList = new ArrayList<>();
|
|
|
- TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
|
|
|
- SysUser sysUser = (SysUser) map.get(SystemConstant.USER);
|
|
|
- Long examDetailId = tbTask.getEntityId();
|
|
|
- try {
|
|
|
- String specifyPaperType = Objects.nonNull(map.get("paperType")) ? (String) map.get("paperType") : null;
|
|
|
- CreatePdfTypeEnum createPdfType = Objects.nonNull(map.get(SystemConstant.CREATE_PDF_TYPE)) ? CreatePdfTypeEnum.valueOf((String) map.get(SystemConstant.CREATE_PDF_TYPE)) : CreatePdfTypeEnum.ALL;
|
|
|
-
|
|
|
- //查询printPlan
|
|
|
- ExamPrintPlan examPrintPlan = examPrintPlanService.getById(tbTask.getPrintPlanId());
|
|
|
-
|
|
|
- BasicSchool basicSchool = commonCacheService.schoolCache(examPrintPlan.getSchoolId());
|
|
|
- BasicPrintConfig basicPrintConfig = basicPrintConfigService.getByExamId(examPrintPlan.getExamId());
|
|
|
-
|
|
|
- //查询examDetail
|
|
|
- Set<Long> attachmentIds = new HashSet<>();
|
|
|
- ExamDetail examDetail = examDetailService.getById(examDetailId);
|
|
|
- if (examDetail == null) {
|
|
|
- throw ExceptionResultEnum.EXAM_DETAIL_IS_NULL.exception();
|
|
|
- }
|
|
|
-
|
|
|
- tbTask.setObjName(examDetail.getExamRoom() + SystemConstant.HYPHEN + examDetail.getExamPlace());
|
|
|
- //查询examDetailCourse
|
|
|
- QueryWrapper<ExamDetailCourse> examDetailCourseQueryWrapper = new QueryWrapper<>();
|
|
|
- examDetailCourseQueryWrapper.lambda().eq(ExamDetailCourse::getExamDetailId, examDetail.getId());
|
|
|
- List<ExamDetailCourse> examDetailCourseList = examDetailCourseService.list(examDetailCourseQueryWrapper);
|
|
|
-
|
|
|
-
|
|
|
- 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> backupCardPdfList = new ArrayList<>();//备份题卡
|
|
|
-
|
|
|
- //创建pdf核心逻辑
|
|
|
- basicAttachmentList = createPdfCoreLogic(examDetailCourseList,
|
|
|
- examPrintPlan,
|
|
|
- examDetail,
|
|
|
- sysUser,
|
|
|
- specifyPaperType,
|
|
|
- createPdfType,
|
|
|
- basicAttachmentList,
|
|
|
- attachmentIds,
|
|
|
- fileTempList,
|
|
|
- backupPaperPdfList,
|
|
|
- backupCardPdfList,
|
|
|
- paperPdfList,
|
|
|
- examStudentPdfList);
|
|
|
-
|
|
|
- createA4File(createPdfType, examPrintPlan, examDetail, basicSchool, examDetailCourseList, fileTempList, ordinaryPdfList, variablePdfList);
|
|
|
-
|
|
|
- //合并A3(试卷+题卡+备用试卷+备用题卡)
|
|
|
-// String dirNameA3 = createPdfUtil.mergeA3Pdf(paperPdfList, examStudentPdfList, backupPaperPdfList, backupCardPdfList);
|
|
|
- //合并(试卷+备用试卷)
|
|
|
- String dirNamePaper = createPdfUtil.mergeA3Pdf(fileTempList, paperPdfList, backupPaperPdfList);
|
|
|
- //合并A4(签到表+卷袋贴+登记表)
|
|
|
-// String dirNameA4 = createPdfUtil.mergeA4Pdf(fileTempList, variablePdfList, ordinaryPdfList);
|
|
|
- //合并A3(题卡+备用题卡)
|
|
|
- String dirNameCardA3 = createPdfUtil.mergeA3Pdf(fileTempList, examStudentPdfList, backupCardPdfList);
|
|
|
-
|
|
|
- BasicAttachment attachment = createPdfUtil.mergePdfSaveDb(dirNamePaper, dirNameCardA3, tbTask, sysUser.getId(), examDetail, basicPrintConfig, fileTempList);
|
|
|
- if (basicAttachmentList != null) {
|
|
|
- basicAttachmentList.add(attachment);
|
|
|
- }
|
|
|
-
|
|
|
- examDetailService.updateById(examDetail);
|
|
|
-
|
|
|
- updateExamPrintPlan(basicPrintConfig, examPrintPlan);
|
|
|
- map.putIfAbsent("size", 1);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error(SystemConstant.LOG_ERROR, e);
|
|
|
- if (Objects.nonNull(dictionaryConfig.sysDomain()) && dictionaryConfig.sysDomain().isOss()) {
|
|
|
- basicAttachmentService.batchDeleteAttachment(basicAttachmentList);
|
|
|
- }
|
|
|
- // 生成失败,状态改为新建
|
|
|
- examDetailService.updateStatusById(examDetailId, ExamDetailStatusEnum.NEW);
|
|
|
- if (e instanceof ApiException) {
|
|
|
- ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
|
|
|
- } else {
|
|
|
- ResultUtil.error(e.getMessage());
|
|
|
- }
|
|
|
- } finally {
|
|
|
- if (!CollectionUtils.isEmpty(fileTempList)) {
|
|
|
- for (File file : fileTempList) {
|
|
|
- file.delete();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 更新考试计划
|
|
|
- *
|
|
|
- * @param basicPrintConfig
|
|
|
- * @param examPrintPlan
|
|
|
- */
|
|
|
- @Transactional
|
|
|
- public void updateExamPrintPlan(BasicPrintConfig basicPrintConfig, ExamPrintPlan examPrintPlan) {
|
|
|
- if (PrintMethodEnum.AUTO == basicPrintConfig.getPrintMethod()) {
|
|
|
- examPrintPlan.setStatus(PrintPlanStatusEnum.PRINTING);
|
|
|
- examPrintPlanService.updateById(examPrintPlan);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public Map<String, Object> executeExaminationLogic(Map<String, Object> map) throws Exception {
|
|
@@ -1047,69 +621,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 获取附件文件
|
|
|
- *
|
|
|
- * @param jsonObject
|
|
|
- * @param pathName
|
|
|
- * @return
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- private File getJsonFile(JSONObject jsonObject, String pathName) throws Exception {
|
|
|
- File file = new File(pathName);
|
|
|
- if (!file.exists()) {
|
|
|
- file.getParentFile().mkdirs();
|
|
|
- file.createNewFile();
|
|
|
- }
|
|
|
- String attachmentType = jsonObject.getString(SystemConstant.TYPE);
|
|
|
- if (Objects.nonNull(attachmentType) && !Objects.equals(attachmentType, SystemConstant.LOCAL)) {
|
|
|
- file = fileStoreUtil.ossDownload(jsonObject.getString(SystemConstant.PDF_PATH), file, UploadFileEnum.PDF.getFssType());
|
|
|
- } else {
|
|
|
- File sourceFile = null;
|
|
|
- if (dictionaryConfig.fssPrivateDomain().getConfig().startsWith(SystemConstant.START_PARENT) || dictionaryConfig.fssPublicDomain().getConfig().startsWith(SystemConstant.START_PARENT)) {
|
|
|
- sourceFile = new File(dictionaryConfig.fssPrivateDomain().getConfig(), jsonObject.getString(SystemConstant.PDF_PATH));
|
|
|
- } else {
|
|
|
- sourceFile = new File(jsonObject.getString(SystemConstant.PDF_PATH));
|
|
|
- }
|
|
|
- FileUtils.copyFile(sourceFile, file);
|
|
|
- }
|
|
|
- return file;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取附件文件
|
|
|
- *
|
|
|
- * @param attachment
|
|
|
- * @param pathName
|
|
|
- * @return
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- private File getAttachmentFile(BasicAttachment attachment, String pathName) throws Exception {
|
|
|
- File file = null;
|
|
|
- if (Objects.nonNull(attachment) && Objects.nonNull(attachment.getPath())) {
|
|
|
- file = new File(pathName);
|
|
|
- if (!file.exists()) {
|
|
|
- file.getParentFile().mkdirs();
|
|
|
- file.createNewFile();
|
|
|
- }
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(attachment.getPath());
|
|
|
- String attachmentType = jsonObject.getString(SystemConstant.TYPE);
|
|
|
- UploadFileEnum uploadFileEnum = UploadFileEnum.valueOf(jsonObject.getString(SystemConstant.UPLOAD_TYPE));
|
|
|
- if (Objects.nonNull(attachmentType) && !Objects.equals(attachmentType, SystemConstant.LOCAL)) {
|
|
|
- file = fileStoreUtil.ossDownload(jsonObject.getString(SystemConstant.PATH), file, uploadFileEnum.getFssType());
|
|
|
- } else {
|
|
|
- File sourceFile = null;
|
|
|
- if (dictionaryConfig.fssPrivateDomain().getConfig().startsWith(SystemConstant.START_PARENT) || dictionaryConfig.fssPublicDomain().getConfig().startsWith(SystemConstant.START_PARENT)) {
|
|
|
- sourceFile = new File(dictionaryConfig.fssPrivateDomain().getConfig(), jsonObject.getString(SystemConstant.PATH));
|
|
|
- } else {
|
|
|
- sourceFile = new File(jsonObject.getString(SystemConstant.PATH));
|
|
|
- }
|
|
|
- FileUtils.copyFile(sourceFile, file);
|
|
|
- }
|
|
|
- }
|
|
|
- return file;
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public Map<String, Object> executeExportSampleLogic(Map<String, Object> map) throws Exception {
|
|
@@ -1527,45 +1038,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
return sysUserService.executeSysUserImportLogic(finalList, map);
|
|
|
}
|
|
|
|
|
|
- @Transactional
|
|
|
- @Override
|
|
|
- public Map<String, Object> executeImportBasicClazzLogic(Map<String, Object> map) throws Exception {
|
|
|
- InputStream inputStream = (InputStream) map.get("inputStream");
|
|
|
- System.out.println(inputStream);
|
|
|
- List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(inputStream, Lists.newArrayList(BasicClazzImportDto.class, DescribeImportDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
|
|
|
- List<ExcelError> excelErrorTemp = new ArrayList<>();
|
|
|
- Map<String, String> checkNameMap = new HashMap<>();
|
|
|
- for (int i = 0; i < finalExcelList.size(); i++) {
|
|
|
- LinkedMultiValueMap<Integer, Object> excelMap = finalExcelList.get(i);
|
|
|
- List<Object> basicClazzImportDtoList = excelMap.get(i);
|
|
|
- assert basicClazzImportDtoList != null;
|
|
|
- if (basicClazzImportDtoList.get(0) instanceof DescribeImportDto) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- for (int y = 0; y < Objects.requireNonNull(basicClazzImportDtoList).size(); y++) {
|
|
|
- BasicClazzImportDto basicClazzImportDto = (BasicClazzImportDto) basicClazzImportDtoList.get(y);
|
|
|
- String clazzName = basicClazzImportDto.getClazzName();
|
|
|
-
|
|
|
- // 检验excel中
|
|
|
- // 检验学号
|
|
|
- if (checkNameMap.containsKey(clazzName)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("导入的excel中包含在重复的班级名称[" + clazzName + "]");
|
|
|
- } else {
|
|
|
- checkNameMap.put(clazzName, clazzName);
|
|
|
- }
|
|
|
-
|
|
|
- excelErrorTemp.addAll(ExcelUtil.checkExcelField(basicClazzImportDto, y, i));
|
|
|
- }
|
|
|
- }
|
|
|
- if (excelErrorTemp.size() > 0) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(excelErrorTemp));
|
|
|
- }
|
|
|
- return finalExcelList;
|
|
|
- }, 2);
|
|
|
- return basicClazzService.executeBasicClazzImportLogic(finalList, map);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public Map<String, Object> executeImportStatisticsLogic(Map<String, Object> map) throws Exception {
|
|
@@ -2037,7 +1509,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
basicExamStudentParam.setId(id);
|
|
|
basicExamStudentParam.setSemesterId(semesterId);
|
|
|
basicExamStudentParam.setExamId(examId);
|
|
|
- basicExamStudentParam.setCourseCode(courseCode);
|
|
|
+// basicExamStudentParam.setCourseId(courseCode);
|
|
|
basicExamStudentParam.setStudentName(studentName);
|
|
|
basicExamStudentParam.setStudentCode(studentCode);
|
|
|
basicExamStudentParam.setCollege(college);
|
|
@@ -2085,119 +1557,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- @Transactional
|
|
|
- @Override
|
|
|
- public Map<String, Object> executeImportMarkStudentLogic(Map<String, Object> map) throws Exception {
|
|
|
- InputStream inputStream = (InputStream) map.get("inputStream");
|
|
|
- // 检验课程编号和课程名称对应
|
|
|
- Map<String, String> courseCodeNameCheckMap = new HashMap<>();
|
|
|
- // 检验学号在课程下唯一
|
|
|
- Map<String, List<String>> checkStudentCodeMap = new HashMap<>();
|
|
|
- // 检验同一个课程、试卷下的班级信息要么全填要么全不填
|
|
|
- Map<String, Boolean> checkClazzMap = new HashMap<>();
|
|
|
-
|
|
|
- List<MarkStudentImportDto> datasource = new ArrayList<>();
|
|
|
- AtomicInteger successInteger = new AtomicInteger(0);
|
|
|
- AtomicInteger exceptionInteger = new AtomicInteger(0);
|
|
|
-
|
|
|
- ExcelUtil.excelReader(inputStream, Lists.newArrayList(MarkStudentImportDto.class),
|
|
|
- (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
|
|
|
-
|
|
|
- for (int i = 0; i < finalExcelList.size(); i++) {
|
|
|
- LinkedMultiValueMap<Integer, Object> excelMap = finalExcelList.get(i);
|
|
|
- List<Object> MarkStudentImportDtoList = excelMap.get(i);
|
|
|
- // 无数据,跳过
|
|
|
- if (CollectionUtils.isEmpty(MarkStudentImportDtoList)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- for (int y = 0; y < Objects.requireNonNull(MarkStudentImportDtoList).size(); y++) {
|
|
|
- List<String> errorMsgList = new ArrayList<>();
|
|
|
- // 行索引
|
|
|
- MarkStudentImportDto markStudentImportDto = (MarkStudentImportDto) MarkStudentImportDtoList.get(
|
|
|
- y);
|
|
|
- String courseName = StringUtils.trimToNull(markStudentImportDto.getCourseName());
|
|
|
- String courseCode = StringUtils.trimToNull(markStudentImportDto.getCourseCode());
|
|
|
- String paperNumber = StringUtils.trimToNull(markStudentImportDto.getPaperNumber());
|
|
|
- String studentName = StringUtils.trimToNull(markStudentImportDto.getStudentName());
|
|
|
- String studentCode = StringUtils.trimToNull(markStudentImportDto.getStudentCode());
|
|
|
- String college = StringUtils.trimToNull(markStudentImportDto.getCollege());
|
|
|
- String major = StringUtils.trimToNull(markStudentImportDto.getMajor());
|
|
|
- String clazz = StringUtils.trimToNull(markStudentImportDto.getClazz());
|
|
|
- String examDate = StringUtils.trimToNull(markStudentImportDto.getExamDate());
|
|
|
- String examTime = StringUtils.trimToNull(markStudentImportDto.getExamTime());
|
|
|
- String examPlace = StringUtils.trimToNull(markStudentImportDto.getExamPlace());
|
|
|
- String examRoom = StringUtils.trimToNull(markStudentImportDto.getExamRoom());
|
|
|
-
|
|
|
- // 本行全部列为空,跳过
|
|
|
- if (StringUtils.isAllBlank(courseName, courseCode, paperNumber, studentName, studentCode,
|
|
|
- college, major, clazz, examDate, examTime, examDate, examPlace, examRoom)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- // 课程编号和课程名称一致
|
|
|
- if (courseCodeNameCheckMap.containsKey(courseCode)) {
|
|
|
- if (!courseCodeNameCheckMap.get(courseCode).equals(courseName)) {
|
|
|
- errorMsgList.add("同一个课程编号对应了多个课程名称");
|
|
|
- }
|
|
|
- } else {
|
|
|
- courseCodeNameCheckMap.put(courseCode, courseName);
|
|
|
- }
|
|
|
-
|
|
|
- // 学号在课程下唯一
|
|
|
- if (checkStudentCodeMap.containsKey(courseCode)) {
|
|
|
- List<String> studentCodeList = checkStudentCodeMap.get(courseCode);
|
|
|
- if (studentCodeList.contains(studentCode)) {
|
|
|
- errorMsgList.add("学号重复(学号需要在课程下唯一)");
|
|
|
- } else {
|
|
|
- studentCodeList.add(studentCode);
|
|
|
- }
|
|
|
- } else {
|
|
|
- List<String> studentCodeList = new ArrayList<>();
|
|
|
- studentCodeList.add(studentCode);
|
|
|
- checkStudentCodeMap.put(courseCode, studentCodeList);
|
|
|
- }
|
|
|
-
|
|
|
- // 同一个课程、试卷下的班级信息要么全填要么全不填
|
|
|
- String clazzCheckKey = courseCode + SystemConstant.HYPHEN + paperNumber;
|
|
|
- if (checkClazzMap.containsKey(clazzCheckKey)) {
|
|
|
- Boolean hasData = checkClazzMap.get(clazzCheckKey);
|
|
|
- if (SystemConstant.strNotNull(clazz) != hasData) {
|
|
|
- errorMsgList.add("班级信息异常(同一个课程、试卷下的班级信息要么全填要么全不填)");
|
|
|
- }
|
|
|
- } else {
|
|
|
- checkClazzMap.put(clazzCheckKey, SystemConstant.strNotNull(clazz));
|
|
|
- }
|
|
|
-
|
|
|
- try {
|
|
|
- if (SystemConstant.strNotNull(examDate) && SystemConstant.strNotNull(examTime)) {
|
|
|
- ConvertUtil.analyzeStartAndEndTime(examDate, examTime);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- errorMsgList.add(e.getMessage());
|
|
|
- }
|
|
|
-
|
|
|
- if (CollectionUtils.isNotEmpty(errorMsgList)) {
|
|
|
- markStudentImportDto.setErrorMsg(String.join(";", errorMsgList));
|
|
|
- exceptionInteger.getAndIncrement();
|
|
|
- } else {
|
|
|
- successInteger.getAndIncrement();
|
|
|
- }
|
|
|
- datasource.add(markStudentImportDto);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (datasource.stream().anyMatch(e -> SystemConstant.strNotNull(e.getErrorMsg()))) {
|
|
|
- map.put(SystemConstant.ERROR_DATA_LIST, datasource);
|
|
|
- } else {
|
|
|
- map.put(SystemConstant.DATASOURCE, datasource);
|
|
|
- }
|
|
|
- map.put(SystemConstant.DATA_COUNT, datasource.size());
|
|
|
- map.put(SystemConstant.SUCCESS_DATA_COUNT, successInteger.get());
|
|
|
- map.put(SystemConstant.ERROR_DATA_COUNT, exceptionInteger.get());
|
|
|
- return finalExcelList;
|
|
|
- }, 2);
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public void saveMarkStudent(Long examId, List<BasicExamStudent> basicExamStudentList) {
|
|
@@ -2211,7 +1570,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
MarkPaper markPaper = markPaperService.getByExamIdAndPaperNumber(examId, entry.getKey());
|
|
|
if (markPaper == null) {
|
|
|
BasicCourse basicCourse = basicCourseService.getByCode(basicExamStudent.getCourseCode());
|
|
|
- markPaper = new MarkPaper(examId, basicExamStudent.getCourseCode(), basicCourse.getName(), entry.getKey(), String.valueOf(System.currentTimeMillis()), requestUserId, SystemConstant.DEFAULT_PAPER_TYPE_A);
|
|
|
+ markPaper = new MarkPaper(examId, basicExamStudent.getCourseId(), entry.getKey(), String.valueOf(System.currentTimeMillis()), requestUserId, SystemConstant.DEFAULT_PAPER_TYPE_A);
|
|
|
markPaperService.save(markPaper);
|
|
|
}
|
|
|
Set<String> secretNumberSet = new HashSet<>();
|
|
@@ -2747,43 +2106,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
return basicCourse;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 验证用户是否存在
|
|
|
- *
|
|
|
- * @param userMap
|
|
|
- * @param key
|
|
|
- * @param schoolId
|
|
|
- * @param excelErrorTemp
|
|
|
- * @param row
|
|
|
- * @param sheet
|
|
|
- * @param cloumnName
|
|
|
- * @return
|
|
|
- */
|
|
|
- private SysUser validSysUserExists(Map<String, SysUser> userMap,
|
|
|
- String key,
|
|
|
- Long schoolId,
|
|
|
- List<ExcelError> excelErrorTemp,
|
|
|
- int row,
|
|
|
- int sheet,
|
|
|
- String cloumnName) {
|
|
|
- SysUser sysUser = null;
|
|
|
- if (!userMap.containsKey(key)) {//不存在查询
|
|
|
- QueryWrapper<SysUser> sysUserQueryWrapper = new QueryWrapper<>();
|
|
|
- sysUserQueryWrapper.lambda().eq(SysUser::getSchoolId, schoolId)
|
|
|
- .eq(SysUser::getRealName, key)
|
|
|
- .eq(SysUser::getEnable, true);
|
|
|
- sysUser = sysUserService.getOne(sysUserQueryWrapper);
|
|
|
- } else {
|
|
|
- sysUser = userMap.get(key);
|
|
|
- }
|
|
|
- if (Objects.isNull(sysUser)) {
|
|
|
- excelErrorTemp.add(new ExcelError(row, "excel第" + sheet + "个sheet第" + row + "行[" + cloumnName + "]不存在"));
|
|
|
- } else {
|
|
|
- SysUser finalSysUser = sysUser;
|
|
|
- userMap.computeIfAbsent(key, v -> finalSysUser);
|
|
|
- }
|
|
|
- return sysUser;
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 验证班级是否存在
|