|
@@ -381,7 +381,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
String importFilePath = tbTask.getImportFilePath();
|
|
String importFilePath = tbTask.getImportFilePath();
|
|
Map importFilePathMap = JSONObject.parseObject(importFilePath);
|
|
Map importFilePathMap = JSONObject.parseObject(importFilePath);
|
|
String path = String.valueOf(importFilePathMap.get("path"));
|
|
String path = String.valueOf(importFilePathMap.get("path"));
|
|
- System.out.println("path = " + path);
|
|
|
|
Workbook workbook;
|
|
Workbook workbook;
|
|
if (path.endsWith(SystemConstant.XLSX)) {
|
|
if (path.endsWith(SystemConstant.XLSX)) {
|
|
workbook = new XSSFWorkbook(inputStream);
|
|
workbook = new XSSFWorkbook(inputStream);
|
|
@@ -399,7 +398,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
if (totalRows > 1 && sheet.getRow(0) != null) {
|
|
if (totalRows > 1 && sheet.getRow(0) != null) {
|
|
totalCells = sheet.getRow(0).getPhysicalNumberOfCells();
|
|
totalCells = sheet.getRow(0).getPhysicalNumberOfCells();
|
|
}
|
|
}
|
|
- System.out.println("行 : " + totalRows + "\n列 : " + totalCells);
|
|
|
|
Row head = sheet.getRow(0);
|
|
Row head = sheet.getRow(0);
|
|
List<String> headList = new ArrayList<>();
|
|
List<String> headList = new ArrayList<>();
|
|
// 将必填字段匹配excel解析的表头索引
|
|
// 将必填字段匹配excel解析的表头索引
|
|
@@ -416,14 +414,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
// 搜索所有有效字段 excel中的表头是否包含
|
|
// 搜索所有有效字段 excel中的表头是否包含
|
|
for (FieldsDto fieldsDto : fieldsDtoList) {
|
|
for (FieldsDto fieldsDto : fieldsDtoList) {
|
|
if (!headList.contains(fieldsDto.getName())) {
|
|
if (!headList.contains(fieldsDto.getName())) {
|
|
- System.out.println("exception " + fieldsDto.getName());
|
|
|
|
throw ExceptionResultEnum.ERROR.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<>();
|
|
List<Map<String, Object>> dataList = new ArrayList<>();
|
|
|
|
|
|
for (int r = 1; r < totalRows; r++) {
|
|
for (int r = 1; r < totalRows; r++) {
|
|
@@ -446,6 +439,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
String level = fieldsDto.getLevel();
|
|
String level = fieldsDto.getLevel();
|
|
|
|
|
|
Cell cell = row.getCell(index);
|
|
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));
|
|
String cellValue = String.valueOf(ExcelUtil.convert(cell));
|
|
if (cellValue == null || cellValue.length() < 1 || cellValue.equals("null")) {
|
|
if (cellValue == null || cellValue.length() < 1 || cellValue.equals("null")) {
|
|
throw ExceptionResultEnum.ERROR.exception("excel中第[" + (r + 1) + "]行,第[" + (index + 1) + "]列,字段[" + name + "]必填");
|
|
throw ExceptionResultEnum.ERROR.exception("excel中第[" + (r + 1) + "]行,第[" + (index + 1) + "]列,字段[" + name + "]必填");
|