瀏覽代碼

bug修改

xiaof 4 年之前
父節點
當前提交
c562563274

+ 13 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/ExamDetailCourse.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.distributed.print.business.base.BaseEntity;
+import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
 
@@ -44,6 +45,18 @@ public class ExamDetailCourse extends BaseEntity implements Serializable {
     @TableField("card_pages_a3")
     private Integer cardPagesA3;
 
+    @ApiModelProperty(value = "当前试卷类型")
+    @TableField("paper_type")
+    private String paperType;
+
+    public String getPaperType() {
+        return paperType;
+    }
+
+    public void setPaperType(String paperType) {
+        this.paperType = paperType;
+    }
+
     public Long getSchoolId() {
         return schoolId;
     }

+ 6 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamDetailService.java

@@ -14,6 +14,7 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * <p>
@@ -70,10 +71,11 @@ public interface ExamDetailService extends IService<ExamDetail> {
      * @param packageCode 卷袋编号
      * @param pageNumber 分页页码
      * @param pageSize 分页数量
+     * @param orgIds 权限控制参数
      * @return 查询结果
      */
-    IPage<ExaminationResult> findExaminationBriefPage(Long schoolId,Long printPlanId,String courseCode,String paperNumber,
-                                                      String examPlace,String examRoom,String packageCode,int pageNumber,int pageSize);
+    IPage<ExaminationResult> findExaminationBriefPage(Long schoolId, Long printPlanId, String courseCode, String paperNumber,
+                                                      String examPlace, String examRoom, String packageCode, int pageNumber, int pageSize, Set<Long> orgIds);
 
     /**
      * 查询考务数据-汇总数据查询
@@ -84,10 +86,11 @@ public interface ExamDetailService extends IService<ExamDetail> {
      * @param examPlace 考点
      * @param examRoom 考场
      * @param packageCode 卷袋编号
+     * @param orgIds 权限控制参数
      * @return 查询结果
      */
     SummarizedDataResult findSummarizedData(Long schoolId,Long printPlanId,String courseCode,String paperNumber,
-                                            String examPlace,String examRoom,String packageCode);
+                                            String examPlace,String examRoom,String packageCode,Set<Long> orgIds);
 
 
     /**

+ 10 - 7
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamDetailServiceImpl.java

@@ -208,9 +208,8 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
 
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public IPage<ExaminationResult> findExaminationBriefPage(Long schoolId, Long printPlanId, String courseCode, String paperNumber, String examPlace, String examRoom, String packageCode, int pageNumber, int pageSize) {
-        Set<Long> orgIds = commonService.listSubOrgIds(null);
-        IPage<ExaminationResult> page = examDetailMapper.findBriefPage(new Page<>(pageNumber, pageSize), schoolId, printPlanId, courseCode, paperNumber, examPlace, examRoom, packageCode, orgIds);
+    public IPage<ExaminationResult> findExaminationBriefPage(Long schoolId, Long printPlanId, String courseCode, String paperNumber, String examPlace, String examRoom, String packageCode, int pageNumber, int pageSize,Set<Long> orgIds) {
+        IPage<ExaminationResult> page = examDetailMapper.findBriefPage(new Page<>(pageNumber, pageSize), schoolId, printPlanId, courseCode, paperNumber, examPlace, examRoom, packageCode,orgIds);
         List<ExaminationResult> list = page.getRecords();
         for (ExaminationResult examinationResult : list) {
             String examDetailCourseIds = examinationResult.getExamDetailCourseIds();
@@ -250,8 +249,8 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
 
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public SummarizedDataResult findSummarizedData(Long schoolId, Long printPlanId, String courseCode, String paperNumber, String examPlace, String examRoom, String packageCode) {
-        IPage<ExaminationResult> page = this.findExaminationBriefPage(schoolId, printPlanId, courseCode, paperNumber, examPlace, examRoom, packageCode, SystemConstant.PAGE_NUMBER, SystemConstant.PAGE_SIZE);
+    public SummarizedDataResult findSummarizedData(Long schoolId, Long printPlanId, String courseCode, String paperNumber, String examPlace, String examRoom, String packageCode, Set<Long> orgIds) {
+        IPage<ExaminationResult> page = this.findExaminationBriefPage(schoolId, printPlanId, courseCode, paperNumber, examPlace, examRoom, packageCode, SystemConstant.PAGE_NUMBER, SystemConstant.PAGE_SIZE,orgIds);
         List<ExaminationResult> list = page.getRecords();
         int totalSubjects = 0;
         for (ExaminationResult examinationResult : list) {
@@ -269,7 +268,7 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
     @Override
     public IPage<ExaminationDetailResult> findExaminationDetail(Long schoolId, Long printPlanId, String courseCode, String paperNumber, String examPlace, String examRoom, String studentParams, int pageNumber, int pageSize) {
         Set<Long> orgIds = commonService.listSubOrgIds(null);
-        return examDetailMapper.findDetailPage(new Page<>(pageNumber, pageSize), schoolId, printPlanId, courseCode, paperNumber, examPlace, examRoom, studentParams, orgIds);
+        return examDetailMapper.findDetailPage(new Page<>(pageNumber, pageSize), schoolId, printPlanId, courseCode, paperNumber, examPlace, examRoom, studentParams,orgIds);
     }
 
     @Transactional(rollbackFor = Exception.class)
@@ -593,6 +592,10 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
         if (map.get("packageCode") != null) {
             packageCode = String.valueOf(map.get("packageCode"));
         }
+        Set<Long> orgIds = new HashSet<>();
+        if (Objects.nonNull(map.get("orgIds"))){
+            orgIds = (Set<Long>) map.get("orgIds");
+        }
 
         TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
         Long userId = tbTask.getCreateId();
@@ -600,7 +603,7 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
 
         List<ExaminationResult> examinationResultList = this.findExaminationBriefPage(schoolId,
                 printPlanId, courseCode, paperNumber, examPlace, examRoom, packageCode,
-                SystemConstant.PAGE_NUMBER, SystemConstant.PAGE_SIZE).getRecords();
+                SystemConstant.PAGE_NUMBER, SystemConstant.PAGE_SIZE,orgIds).getRecords();
         int index = 0;
         List<ExaminationExportDto> examinationExportDtoList = new ArrayList<>();
         for (ExaminationResult examinationResult : examinationResultList) {

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

@@ -186,7 +186,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                             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"))) {
+                                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"));
@@ -233,6 +233,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                             //抽取卷型
                             String paperType = Objects.nonNull(paperTypeParam) ? paperTypeParam : createPdfUtil.getPaperType(examPrintPlan, examTaskDetail, examDetail, examDetailCourse);
                             examTaskDetail.setRelatePaperType(paperType);
+                            examDetailCourse.setPaperType(paperType);
 
                             PaperPdfDto paperPdfDto = createPdfUtil.getPaperPdfFile(paperType, examTaskDetail);
 
@@ -250,7 +251,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                                 String studentContent = cardContent;
 
                                 for (int i = 1; i <= examPrintPlan.getBackupCount(); i++) {
-                                    BasicAttachment basicAttachment = createPdfUtil.cardHtml(String.format("%02d", i), cardContent, paperType, examDetail, examDetailCourse, examCard, jsonArray, sysUser.getId(), cardPdfTempList);
+                                    BasicAttachment basicAttachment = createPdfUtil.cardHtml(String.format("%02d", i), cardContent, examDetail, examDetailCourse, examCard, jsonArray, sysUser.getId(), cardPdfTempList);
                                     examDetailCourse.setCardPagesA3(basicAttachment.getPages());
                                     basicAttachmentList.add(basicAttachment);
                                 }
@@ -268,14 +269,16 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                                     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"))) {
+                                        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")) {//卷袋贴
-                                                createPdfUtil.createPaperPackage(pdfDto.isTag(), basicAttachment, basicSchool.getName(), examDetail, examDetailCourse, examStudentList, variablePdfList, (Integer) jsonObjectVariable.get("backupCount"));
+                                                if (Objects.nonNull(pdfDto)) {
+                                                    createPdfUtil.createPaperPackage(pdfDto.isTag(), basicAttachment, basicSchool.getName(), examDetail, examDetailCourse, examStudentList, variablePdfList, (Integer) jsonObjectVariable.get("backupCount"));
+                                                }
                                             }
                                         }
                                     }
@@ -289,7 +292,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                                 });
 
                                 for (ExamStudent t : examStudentList) {
-                                    createPdfUtil.getExamStudentPaperPdf(paperPdfDto, paperPdfTempList);
+                                    if (Objects.nonNull(pdfDto)) {
+                                        createPdfUtil.getExamStudentPaperPdf(paperPdfDto, paperPdfTempList);
+                                    }
                                     basicAttachmentList.add(createPdfUtil.examStudentHtml(attachmentIds, studentContent, t, paperType, examCard, sysUser.getId(), examStudentTempPdfList));
                                 }
                                 paperPdfList.addAll(paperPdfTempList);
@@ -662,17 +667,19 @@ public class TaskLogicServiceImpl implements TaskLogicService {
 
             // 处理试卷样品
             List<Map> paperInfo = JSONObject.parseArray(examTaskDetail.getPaperAttachmentIds(), Map.class);
+            if (Objects.isNull(paperInfo)) {
+                throw ExceptionResultEnum.ERROR.exception("试卷信息不存在");
+            }
             System.out.println("paperInfo = " + JSON.toJSONString(paperInfo));
             Set<Long> attPaperIds = new HashSet<>();
             for (Map paperMap : paperInfo) {
-                if (Objects.isNull(paperMap.get("attachmentId"))) {
-                    throw ExceptionResultEnum.ERROR.exception("未找到附件id");
+                if (Objects.nonNull(paperMap.get("attachmentId")) && String.valueOf(paperMap.get("attachmentId")).length() > 0 && !String.valueOf(paperMap.get("attachmentId")).equals("null")) {
+                    Long attachmentId = Long.valueOf(String.valueOf(paperMap.get("attachmentId")));
+                    attPaperIds.add(attachmentId);
                 }
-                Long attachmentId = Long.valueOf(String.valueOf(paperMap.get("attachmentId")));
-                attPaperIds.add(attachmentId);
             }
-            List<BasicAttachment> paperAttachmentList = basicAttachmentService.listByIds(attPaperIds);
-            if (Objects.nonNull(paperAttachmentList)) {
+            if (attPaperIds.size() > 0) {
+                List<BasicAttachment> paperAttachmentList = basicAttachmentService.listByIds(attPaperIds);
                 for (BasicAttachment paperAttachment : paperAttachmentList) {
                     JSONObject jsonObject = JSONObject.parseObject(paperAttachment.getPath());
                     String paperPath = firstPath + File.separator + "试卷" + File.separator + paperAttachment.getName() + paperAttachment.getType();
@@ -692,8 +699,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                 Long attachmentId = Long.valueOf(String.valueOf(confirmMap.get("attachmentId")));
                 attConfirmIds.add(attachmentId);
             }
-            List<BasicAttachment> confirmAttachmentList = basicAttachmentService.listByIds(attConfirmIds);
-            if (Objects.nonNull(confirmAttachmentList)) {
+            if (attConfirmIds.size() > 0) {
+                List<BasicAttachment> confirmAttachmentList = basicAttachmentService.listByIds(attConfirmIds);
                 for (BasicAttachment confirmAttachment : confirmAttachmentList) {
                     JSONObject jsonObject = JSONObject.parseObject(confirmAttachment.getPath());
                     String confirmPath = firstPath + File.separator + "审核样本" + File.separator + confirmAttachment.getName() + confirmAttachment.getType();
@@ -729,7 +736,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                 JSONObject jsonObject = JSONObject.parseObject(cardAttachment.getPath());
                 String cardPath = firstPath + File.separator + "题卡" + File.separator + cardAttachment.getName() + cardAttachment.getType();
                 ossUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), cardPath);
-                count++;
             } else {
                 List<ExamCardDetail> examCardDetailList = examCardDetailService.list(new QueryWrapper<ExamCardDetail>().lambda().eq(ExamCardDetail::getCardId, cardId));
                 if (examCardDetailList.size() != 1) {
@@ -744,8 +750,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                     localFile.getParentFile().mkdirs();
                 }
                 FileCopyUtils.copy(bytes, localFile);
-                count++;
             }
+            count++;
         }
         ZipUtil.zip(zipLocalRootPath, zipFile.getPath(), true);
         ossUtil.ossUpload(dirNameTmp, zipFile, BinaryUtil.toBase64String(HexUtils.decodeHex(DigestUtils.md5Hex(new FileInputStream(zipFile)))));

+ 7 - 8
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/CreatePdfUtil.java

@@ -281,12 +281,12 @@ public class CreatePdfUtil {
      * @param attachmentIds
      */
     public void getCardAttachmentId(ExamCardDetail examCardDetail, Set<Long> attachmentIds) {
-        if (Objects.nonNull(examCardDetail.getAttachmentId())) {
+        if (Objects.nonNull(examCardDetail.getAttachmentId()) && !Objects.equals("", 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"))) {
+                if (Objects.nonNull(object.get("attachmentId")) && !Objects.equals("", object.get("attachmentId"))) {
                     attachmentIds.add((Long) (object.get("attachmentId")));
                 }
             }
@@ -348,7 +348,7 @@ public class CreatePdfUtil {
         JSONArray jsonArrayPaper = JSONArray.parseArray(examTaskDetail.getPaperAttachmentIds());
         for (int i = 0; i < jsonArrayPaper.size(); i++) {
             JSONObject object = (JSONObject) jsonArrayPaper.get(i);
-            if (Objects.nonNull(object.get("attachmentId"))) {
+            if (Objects.nonNull(object.get("attachmentId")) && !Objects.equals("", object.get("attachmentId"))) {
                 Long attachmentId = Long.parseLong((String) (object.get("attachmentId")));
                 BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
                 if (Objects.isNull(basicAttachment)) {
@@ -561,7 +561,6 @@ public class CreatePdfUtil {
      * 通用题卡html
      *
      * @param cardContent
-     * @param paperType
      * @param examDetailCourse
      * @param examCard
      * @param jsonArray
@@ -570,12 +569,12 @@ public class CreatePdfUtil {
      * @return
      * @throws IOException
      */
-    public BasicAttachment cardHtml(String sequence, String cardContent, String paperType, ExamDetail examDetail, ExamDetailCourse examDetailCourse, ExamCard examCard, JSONArray jsonArray, Long userId, List<PdfDto> cardPdfList) throws IOException {
+    public BasicAttachment cardHtml(String sequence, String cardContent, ExamDetail examDetail, ExamDetailCourse examDetailCourse, ExamCard examCard, JSONArray jsonArray, Long userId, List<PdfDto> cardPdfList) throws IOException {
         //通用题卡
         String cardTemp = cardContent;
-        cardTemp = cardTemp.replaceAll("\\$\\{paperTypeName\\}", paperType);
+        cardTemp = cardTemp.replaceAll("\\$\\{paperTypeName\\}", examDetailCourse.getPaperType());
         //随机生成试卷条码并将图片转成base64
-        cardTemp = cardTemp.replaceAll("\\$\\{paperType\\}", GoogleBarCodeUtil.createBarCode(SystemConstant.convertPaperType(paperType), false));
+        cardTemp = cardTemp.replaceAll("\\$\\{paperType\\}", GoogleBarCodeUtil.createBarCode(SystemConstant.convertPaperType(examDetailCourse.getPaperType()), false));
         //通用题卡生成卷袋贴条码
         String packageCode = examDetail.getPackageCode() + sequence;
         String packageCodeImg = GoogleBarCodeUtil.createBarCode(packageCode, false);
@@ -583,7 +582,7 @@ public class CreatePdfUtil {
         cardTemp = cardTemp.replaceAll("<div class=\"page-box page-box-0\">", packageCodeDiv);
         BasicAttachment cardAttachment = basicAttachmentService.saveAttachmentHtml(examCard.getSchoolId() + "|" + examCard.getCourseCode(), cardTemp, userId, cardPdfList);
         JSONObject object = new JSONObject();
-        object.put("name", paperType);
+        object.put("name", examDetailCourse.getPaperType());
         object.put("examDetailCourseId", examDetailCourse.getId());
         object.put("attachmentId", cardAttachment.getId());
         object.put("packageCode", packageCode);

+ 10 - 2
distributed-print/src/main/java/com/qmth/distributed/print/api/ExamDetailController.java

@@ -7,6 +7,7 @@ import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.distributed.print.business.bean.result.EditResult;
 import com.qmth.distributed.print.business.entity.TBTask;
 import com.qmth.distributed.print.business.enums.TaskTypeEnum;
+import com.qmth.distributed.print.business.service.CommonService;
 import com.qmth.distributed.print.business.service.ExamDetailService;
 import com.qmth.distributed.print.business.service.ExamStudentService;
 import com.qmth.distributed.print.business.service.TBTaskService;
@@ -29,6 +30,7 @@ import java.io.IOException;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.Set;
 
 /**
  * <p>
@@ -51,6 +53,8 @@ public class ExamDetailController {
     private AsyncExaminationExportTemplateService asyncExaminationExportTemplateService;
     @Resource
     private ExamDetailService examDetailService;
+    @Resource
+    private CommonService commonService;
 
     @Autowired
     private ExamStudentService examStudentService;
@@ -79,8 +83,9 @@ public class ExamDetailController {
                                        @ApiParam(value = "分页数", required = true) @RequestParam int pageSize) {
 
         Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
+        Set<Long> orgIds = commonService.listSubOrgIds(null);
         return ResultUtil.ok(examDetailService.findExaminationBriefPage(schoolId,
-                SystemConstant.convertIdToLong(printPlanId), courseCode, paperNumber, examPlace, examRoom, packageCode, pageNumber, pageSize));
+                SystemConstant.convertIdToLong(printPlanId), courseCode, paperNumber, examPlace, examRoom, packageCode, pageNumber, pageSize,orgIds));
     }
 
     @ApiOperation(value = "考务数据导入-汇总数据查询")
@@ -94,8 +99,9 @@ public class ExamDetailController {
                                      @ApiParam(value = "卷袋号") @RequestParam(required = false) String packageCode) {
 
         Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
+        Set<Long> orgIds = commonService.listSubOrgIds(null);
         return ResultUtil.ok(examDetailService.findSummarizedData(schoolId,
-                SystemConstant.convertIdToLong(printPlanId), courseCode, paperNumber, examPlace, examRoom, packageCode));
+                SystemConstant.convertIdToLong(printPlanId), courseCode, paperNumber, examPlace, examRoom, packageCode,orgIds));
     }
 
     @ApiOperation(value = "考务数据导入-查看明细")
@@ -165,6 +171,7 @@ public class ExamDetailController {
                            @ApiParam(value = "考点") @RequestParam(required = false) String examPlace,
                            @ApiParam(value = "考场") @RequestParam(required = false) String examRoom,
                            @ApiParam(value = "卷袋号") @RequestParam(required = false) String packageCode) {
+        Set<Long> orgIds = commonService.listSubOrgIds(null);
         Map<String, Object> map = tbTaskService.saveTask(TaskTypeEnum.EXAMINATION_EXPORT);
         map.put("printPlanId",printPlanId);
         map.put("courseCode",courseCode);
@@ -172,6 +179,7 @@ public class ExamDetailController {
         map.put("examPlace",examPlace);
         map.put("examRoom",examRoom);
         map.put("packageCode",packageCode);
+        map.put("orgIds",orgIds);
         asyncExaminationExportTemplateService
                 .exportTask(map);
         TBTask tbTask = Objects.nonNull(map.get(SystemConstant.TASK)) ? (TBTask) map.get(SystemConstant.TASK) : null;