Browse Source

3.3.0 考务数据导入第一行为空bug修改

xiaofei 1 year ago
parent
commit
4298308ff7

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

@@ -698,6 +698,14 @@ public class TaskLogicServiceImpl implements TaskLogicService {
         if (sheet.getLastRowNum() == 0 && sheet.getPhysicalNumberOfRows() == 0) {
             throw ExceptionResultEnum.ERROR.exception("第一个sheet为空,考务数据必须放在第一个sheet(工作表)内");
         }
+        // 第一行为说明内容,不能为空
+        if (sheet.getRow(0) == null || !sheet.getRow(0).getCell(0).getStringCellValue().startsWith("说明")) {
+            throw ExceptionResultEnum.ERROR.exception("表格第一行为说明内容,不能为空,且必须以\"说明\"开头");
+        }
+        // 第二行为表头,不能为空,且校验第一列为学号
+        if (sheet.getRow(1) == null || !"学号".equals(sheet.getRow(1).getCell(0).getStringCellValue())) {
+            throw ExceptionResultEnum.ERROR.exception("表格第二行为表头,不能为空,且第一列必须为\"学号\"");
+        }
         // 获取sheet行数
         int totalRows = sheet.getPhysicalNumberOfRows();
         // 获取sheet列数(列数从第二行开始记录,因为第一行是说明内容)