xiaof 3 years ago
parent
commit
95d2cbc5ea

+ 34 - 27
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/TaskLogicServiceImpl.java

@@ -37,7 +37,6 @@ import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.checkerframework.checker.units.qual.K;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -297,21 +296,43 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                     examTaskDetail.setRelatePaperType(paperType);
                     examDetailCourse.setPaperType(paperType);
 
+                    //查询考生
+                    QueryWrapper<ExamStudent> examStudentQueryWrapper = new QueryWrapper<>();
+                    examStudentQueryWrapper.lambda().eq(ExamStudent::getSchoolId, sysUser.getSchoolId())
+                            .eq(ExamStudent::getExamDetailCourseId, examDetailCourse.getId());
+                    List<ExamStudent> examStudentList = examStudentService.list(examStudentQueryWrapper);
+
                     List<PaperPdfDto> paperPdfDto = null;
                     if (printContent.contains("PAPER")) {
                         paperPdfDto = createPdfUtil.getPaperPdfFile(paperType, examTaskDetail);
-                    }
 
-                    //获取试卷pdf
-                    PdfDto pdfDto = createPdfUtil.getPaperPdf(paperPdfDto, examPrintPlan.getBackupCount(), backupPaperTempPdfList);
-                    if (Objects.nonNull(pdfDto)) {
-                        examDetailCourse.setPaperPagesA3(pdfDto.getPageCount());
-                    } else {
-                        examDetailCourse.setPaperPagesA3(examDetailCourse.getPaperPagesA3());
+                        //获取试卷pdf
+                        PdfDto pdfDto = createPdfUtil.getPaperPdf(paperPdfDto, examPrintPlan.getBackupCount(), backupPaperTempPdfList);
+                        if (Objects.nonNull(pdfDto)) {
+                            examDetailCourse.setPaperPagesA3(pdfDto.getPageCount());
+                        } else {
+                            examDetailCourse.setPaperPagesA3(examDetailCourse.getPaperPagesA3());
+                        }
+                        // 备用试卷
+                        list[0].addAll(backupPaperTempPdfList);
+
+                        List<String> paperTypes = Arrays.asList(paperType.split(",")).stream().sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList());
+                        int i = 0;
+                        for (ExamStudent t : examStudentList) {
+                            int mod = i % examTaskDetail.getDrawCount().intValue();
+                            String stuPaperType = paperTypes.get(mod);
+                            if (Objects.nonNull(pdfDto)) {
+                                createPdfUtil.getExamStudentPaperPdf(stuPaperType, paperPdfDto, paperPdfTempList);
+                            }
+                            t.setPaperType(stuPaperType);
+                            i++;
+                        }
+                        examStudentService.saveOrUpdateBatch(examStudentList);
+                        // 试卷
+                        list[2].addAll(paperPdfTempList);
                     }
-                    list[0].addAll(backupPaperTempPdfList);
 
-                    basicAttachmentList = Objects.isNull(basicAttachmentList) ? basicAttachmentList = new ArrayList<>() : basicAttachmentList;
+                    basicAttachmentList = Objects.isNull(basicAttachmentList) ? new ArrayList<>() : basicAttachmentList;
                     if (printContent.contains("CARD")) {
                         for (ExamCardDetail examCardDetail : examCardDetailList) {
                             createPdfUtil.getCardAttachmentId(examCardDetail, attachmentIds);
@@ -325,33 +346,19 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                                 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);
-
-                            List<String> paperTypes = Arrays.asList(paperType.split(",")).stream().sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList());
-                            int i = 0;
                             for (ExamStudent t : examStudentList) {
-                                int mod = i % examTaskDetail.getDrawCount().intValue();
-                                String stuPaperType = paperTypes.get(mod);
-                                if (Objects.nonNull(pdfDto)) {
-                                    createPdfUtil.getExamStudentPaperPdf(stuPaperType, paperPdfDto, paperPdfTempList);
-                                }
-                                t.setPaperType(stuPaperType);
                                 basicAttachmentList.add(createPdfUtil.examStudentHtml(attachmentIds, studentContent, t, examDetail, examDetailCourse, sysUser.getId(), examStudentTempPdfList));
-                                i++;
                             }
+                            // 试卷
                             list[2].addAll(paperPdfTempList);
+                            // 题卡
                             list[3].addAll(examStudentTempPdfList);
-                            examStudentService.saveOrUpdateBatch(examStudentList);
                             jsonObject.put("card", jsonArray);
                             examDetailCourse.setAttachmentId(jsonObject.toJSONString());
                         }
-//                        examCardDetailService.saveOrUpdateBatch(examCardDetailList);
                     }
                 }
                 examDetailCourse.setAttachmentId(jsonObject.toJSONString());