Kaynağa Gözat

Merge branch 'dev' of http://git.qmth.com.cn/wangliang/distributed-print-service into dev

xiaof 4 yıl önce
ebeveyn
işleme
1ca48c1454

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

@@ -137,14 +137,14 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
     public List<FieldsDto> findExaminationFields(Long schoolId) {
         BasicExamRule basicExamRule = basicExamRuleService.list(new QueryWrapper<BasicExamRule>().lambda().eq(BasicExamRule::getSchoolId, schoolId)).get(0);
         if (basicExamRule == null) {
-            throw ExceptionResultEnum.ERROR.exception("找不到该学校考务字段信息 + schoolId" + schoolId);
+            throw ExceptionResultEnum.ERROR.exception("找不到该学校考务字段信息");
         }
         String requiredFields = basicExamRule.getRequiredFields();
         String extendFields = basicExamRule.getExtendFields();
         // 必选字段
         List<FieldsDto> requiredFieldsList = JSONObject.parseArray(requiredFields, FieldsDto.class);
         if (requiredFieldsList.stream().anyMatch(e -> !e.getEnable())) {
-            throw ExceptionResultEnum.ERROR.exception("该学校考务字段设置存在必选字段禁用的情况 schoolId = " + schoolId);
+            throw ExceptionResultEnum.ERROR.exception("该学校考务字段设置存在必选字段禁用的情况");
         }
         for (FieldsDto fieldsDto : requiredFieldsList) {
             fieldsDto.setLevel("primary");
@@ -154,7 +154,7 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
         List<FieldsDto> extendFieldsList = JSONObject.parseArray(extendFields, FieldsDto.class);
         List<String> extendCodeList = extendFieldsList.stream().map(FieldsDto::getCode).collect(Collectors.toList());
         if (extendCodeList.stream().anyMatch(e -> requiredFieldsList.stream().map(FieldsDto::getCode).collect(Collectors.toList()).contains(e))) {
-            throw ExceptionResultEnum.ERROR.exception("该学校考务字段设置存在相同的code schoolId = " + schoolId);
+            throw ExceptionResultEnum.ERROR.exception("该学校考务字段设置存在相同的代码");
         }
         // 有效的扩展字段
         List<FieldsDto> validExtendList = extendFieldsList.stream().filter(FieldsDto::getEnable).collect(Collectors.toList());
@@ -643,7 +643,7 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
     public void deleteExaminationData(Long printPlanId) {
         ExamPrintPlan examPrintPlan = examPrintPlanService.getById(printPlanId);
         if (examPrintPlan.getId() == null || examPrintPlan.getId() <= 0) {
-            throw ExceptionResultEnum.ERROR.exception("未找主键为 '" + printPlanId + "' 的印刷计划信息");
+            throw ExceptionResultEnum.ERROR.exception("未找印刷计划信息");
         }
         PrintPlanStatusEnum status = examPrintPlan.getStatus();
         if (PrintPlanStatusEnum.NEW != status && PrintPlanStatusEnum.READY != status) {

+ 6 - 6
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamPrintPlanServiceImpl.java

@@ -194,17 +194,17 @@ public class ExamPrintPlanServiceImpl extends ServiceImpl<ExamPrintPlanMapper, E
         Long id = printPlanParams.getId();
         Long schoolId = printPlanParams.getSchoolId();
         if (basicSchoolService.list(new QueryWrapper<BasicSchool>().lambda().eq(BasicSchool::getId, schoolId).eq(BasicSchool::getEnable, true)).size() != 1) {
-            throw ExceptionResultEnum.ERROR.exception("输入的学校id不满足条件 schoolId = " + schoolId);
+            throw ExceptionResultEnum.ERROR.exception("输入的学校id不满足条件");
         }
 
         // 校验是否印试卷和题卡
         List<String> printContentList = printPlanParams.getPrintContent();
         BasicExamRule basicExamRule = basicExamRuleService.getBySchoolId(schoolId);
         if (Objects.isNull(basicExamRule)) {
-            throw ExceptionResultEnum.ERROR.exception("未找到学校的通用规则! schoolId : " + schoolId);
+            throw ExceptionResultEnum.ERROR.exception("未找到学校的通用规则");
         }
         if (basicExamRule.getIncludePaper() && !printContentList.contains("PAPER")) {
-            throw ExceptionResultEnum.ERROR.exception("学校通用规则设置了强制包含试卷的必须选择试卷印品! schoolId : " + schoolId);
+            throw ExceptionResultEnum.ERROR.exception("学校通用规则设置了强制包含试卷的必须选择试卷印品!");
         }
         if (printContentList.contains("PAPER") && !printContentList.contains("CARD")) {
             throw ExceptionResultEnum.ERROR.exception("如果试卷题卡印品选择了试卷,题卡必须被选择");
@@ -225,7 +225,7 @@ public class ExamPrintPlanServiceImpl extends ServiceImpl<ExamPrintPlanMapper, E
             // 包含印刷计划id -> 编辑印刷计划
             ExamPrintPlan tmp = this.getById(id);
             if (tmp == null) {
-                throw ExceptionResultEnum.ERROR.exception("印刷计划id不存在 id= " + id);
+                throw ExceptionResultEnum.ERROR.exception("印刷计划id不存在");
             }
             PrintPlanStatusEnum status = tmp.getStatus();
             if (!PrintPlanStatusEnum.NEW.equals(status) && !PrintPlanStatusEnum.READY.equals(status)) {
@@ -244,14 +244,14 @@ public class ExamPrintPlanServiceImpl extends ServiceImpl<ExamPrintPlanMapper, E
         Long id = deleteParams.getId();
         ExamPrintPlan examPrintPlan = this.getById(id);
         if (examPrintPlan == null) {
-            throw ExceptionResultEnum.ERROR.exception("要删除的项目计划不存在 id = " + id);
+            throw ExceptionResultEnum.ERROR.exception("要删除的项目计划不存在");
         }
         // TODO: 2021/4/23 只有新建能删除  && !PrintPlanStatusEnum.READY.equals(examPrintPlan.getStatus())
         if (!PrintPlanStatusEnum.NEW.equals(examPrintPlan.getStatus())) {
             throw ExceptionResultEnum.ERROR.exception("只有'新建'状态的项目计划可以被删除");
         }
 //        if (!PrintPlanStatusEnum.NEW.equals(examPrintPlan.getStatus()) && !PrintPlanStatusEnum.READY.equals(examPrintPlan.getStatus())){
-//            throw ExceptionResultEnum.ERROR.exception("只有'新建'状态的项目计划可以被删除 status = " + examPrintPlan.getStatus());
+//            throw ExceptionResultEnum.ERROR.exception("只有'新建'状态的项目计划可以被删除");
 //        }
         examDetailService.deleteExaminationData(id);
         return this.removeById(id);

+ 1 - 4
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/SysUserServiceImpl.java

@@ -249,10 +249,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
     public boolean saveUserCommon(UserSaveParams userSaveParams) {
         boolean isSuccess = true;
         try {
-            Long schoolId = null;
-            if (Objects.nonNull(ServletUtil.getRequestHeaderSchoolId())) {
-                schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
-            }
+            Long schoolId = Objects.nonNull(ServletUtil.getRequestHeaderSchoolIdByNotVaild()) ? Long.valueOf(ServletUtil.getRequestHeaderSchoolIdByNotVaild().toString()) : null;
             SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
             Gson gson = new Gson();
             userSaveParams.setSchoolId(schoolId);

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

@@ -325,8 +325,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
     public Map<String, Object> executeExaminationLogic(Map<String, Object> map) throws Exception {
         List<ExaminationExportDto> examinationExportDtoList = examDetailService.findExaminationExportDtoDatasource(map);
 
-        System.out.println("examinationResultList = " + JSON.toJSONString(examinationExportDtoList));
-
         ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
         ExcelUtil.excelMake(ExaminationExportDto.class, examinationExportDtoList, outputStream);
         InputStream in = new ByteArrayInputStream(outputStream.toByteArray());
@@ -381,7 +379,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
         String importFilePath = tbTask.getImportFilePath();
         Map importFilePathMap = JSONObject.parseObject(importFilePath);
         String path = String.valueOf(importFilePathMap.get("path"));
-        System.out.println("path = " + path);
         Workbook workbook;
         if (path.endsWith(SystemConstant.XLSX)) {
             workbook = new XSSFWorkbook(inputStream);
@@ -399,7 +396,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
         if (totalRows > 1 && sheet.getRow(0) != null) {
             totalCells = sheet.getRow(0).getPhysicalNumberOfCells();
         }
-        System.out.println("行 : " + totalRows + "\n列 : " + totalCells);
         Row head = sheet.getRow(0);
         List<String> headList = new ArrayList<>();
         // 将必填字段匹配excel解析的表头索引
@@ -416,14 +412,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
         // 搜索所有有效字段 excel中的表头是否包含
         for (FieldsDto fieldsDto : fieldsDtoList) {
             if (!headList.contains(fieldsDto.getName())) {
-                System.out.println("exception " + fieldsDto.getName());
                 throw ExceptionResultEnum.ERROR.exception("学校考务必填字段 :'" + fieldsDto.getName() + "' 不存在");
             }
         }
-
-        System.out.println("headList : " + headList);
-        System.out.println("fieldsDtoList : " + JSONObject.toJSONString(fieldsDtoList));
-
         List<Map<String, Object>> dataList = new ArrayList<>();
 
         for (int r = 1; r < totalRows; r++) {
@@ -446,6 +437,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                 String level = fieldsDto.getLevel();
 
                 Cell cell = row.getCell(index);
+                if (cell == null) {
+                    throw ExceptionResultEnum.ERROR.exception("excel中第[" + (r + 1) + "]行,第[" + (index + 1) + "]列,字段[" + name + "]必填");
+                }
                 String cellValue = String.valueOf(ExcelUtil.convert(cell));
                 if (cellValue == null || cellValue.length() < 1 || cellValue.equals("null")) {
                     throw ExceptionResultEnum.ERROR.exception("excel中第[" + (r + 1) + "]行,第[" + (index + 1) + "]列,字段[" + name + "]必填");
@@ -673,7 +667,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
             String firstPath = zipLocalRootPath + File.separator + examTaskSign;
             List<ExamTaskDetail> examTaskDetailList = examTaskDetailService.list(new QueryWrapper<ExamTaskDetail>().lambda().eq(ExamTaskDetail::getExamTaskId, id));
             if (examTaskDetailList.size() != 1) {
-                throw ExceptionResultEnum.ERROR.exception("获取命题任务详情失败 命题任务id : " + id);
+                throw ExceptionResultEnum.ERROR.exception("获取命题任务详情失败");
             }
             ExamTaskDetail examTaskDetail = examTaskDetailList.get(0);
 
@@ -724,25 +718,25 @@ public class TaskLogicServiceImpl implements TaskLogicService {
             Long cardId = examTaskDetail.getCardId();
             ExamCard examCard = examCardService.getById(cardId);
             if (Objects.isNull(examCard)) {
-                throw ExceptionResultEnum.ERROR.exception("找不到答题卡 cardId = " + cardId);
+                throw ExceptionResultEnum.ERROR.exception("找不到答题卡");
             }
             MakeMethodEnum makeMethodEnum = examCard.getMakeMethod();
             if (MakeMethodEnum.SELECT.equals(makeMethodEnum)) {
                 Long templateId = examCard.getTemplateId();
                 if (templateId == null || templateId == 0) {
-                    throw ExceptionResultEnum.ERROR.exception("找不到题卡对应的模板 templateId = " + templateId);
+                    throw ExceptionResultEnum.ERROR.exception("找不到题卡对应的模板");
                 }
                 BasicTemplate basicTemplate = basicTemplateService.getById(templateId);
                 if (Objects.isNull(basicTemplate)) {
-                    throw ExceptionResultEnum.ERROR.exception("找不到模板信息 templateId = " + templateId);
+                    throw ExceptionResultEnum.ERROR.exception("找不到模板信息");
                 }
                 Long attachmentId = basicTemplate.getAttachmentId();
                 if (attachmentId == null || attachmentId == 0) {
-                    throw ExceptionResultEnum.ERROR.exception("找不到模板对应的附件 templateId = " + templateId);
+                    throw ExceptionResultEnum.ERROR.exception("找不到模板对应的附件");
                 }
                 BasicAttachment cardAttachment = basicAttachmentService.getById(attachmentId);
                 if (Objects.isNull(cardAttachment)) {
-                    throw ExceptionResultEnum.ERROR.exception("找不到附件 attachmentId = " + attachmentId);
+                    throw ExceptionResultEnum.ERROR.exception("找不到附件");
                 }
                 JSONObject jsonObject = JSONObject.parseObject(cardAttachment.getPath());
                 String cardPath = firstPath + File.separator + "题卡" + File.separator + cardAttachment.getName() + cardAttachment.getType();
@@ -751,7 +745,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
             } else {
                 List<ExamCardDetail> examCardDetailList = examCardDetailService.list(new QueryWrapper<ExamCardDetail>().lambda().eq(ExamCardDetail::getCardId, cardId));
                 if (examCardDetailList.size() != 1) {
-                    throw ExceptionResultEnum.ERROR.exception("题卡明细信息异常 card_id = " + cardId);
+                    throw ExceptionResultEnum.ERROR.exception("题卡明细信息异常");
                 }
                 ExamCardDetail examCardDetail = examCardDetailService.getByCardId(cardId);
                 String htmlContent = examCardDetail.getHtmlContent();

+ 11 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/ServletUtil.java

@@ -152,12 +152,20 @@ public class ServletUtil {
      */
     public static Object getRequestHeaderSchoolId() {
         Object object = getRequest().getHeader(SystemConstant.SCHOOL_ID);
-//        if (Objects.isNull(object)) {
-//            throw ExceptionResultEnum.NOT_LOGIN.exception();
-//        }
+        if (Objects.isNull(object)) {
+            throw ExceptionResultEnum.NOT_LOGIN.exception();
+        }
         return object;
     }
 
+    /**
+     * 获取header中schoolId
+     * @return
+     */
+    public static Object getRequestHeaderSchoolIdByNotVaild() {
+        return getRequest().getHeader(SystemConstant.SCHOOL_ID);
+    }
+
     /**
      * 获取请求的学校
      *

+ 0 - 7
distributed-print/src/main/java/com/qmth/distributed/print/api/ExamTaskController.java

@@ -374,13 +374,6 @@ public class ExamTaskController {
         return ResultUtil.ok(isSuccess);
     }
 
-    /**
-     * 导出审核样本
-     * @param arraysParams
-     * @param bindingResult
-     * @return
-     * @throws Exception
-     */
     @ApiOperation(value = "导出审核样本")
     @RequestMapping(value = "/review_export", method = RequestMethod.POST)
     public Result taskReviewExport(@Valid @RequestBody ArraysParams arraysParams, BindingResult bindingResult) throws Exception {