Browse Source

[bug]考务数据导入-必选字段校验方式更改(处理了传入数据格式为int型时触发的空指针异常)

caozixuan 4 years ago
parent
commit
0d3dcc5f85

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

@@ -244,7 +244,7 @@ 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())) {

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

@@ -381,7 +381,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 +398,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 +414,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 +439,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 + "]必填");