xiongchao 3 年之前
父節點
當前提交
9487e692d7
共有 1 個文件被更改,包括 7 次插入7 次删除
  1. 7 7
      platform-dao/src/main/java/com/platform/dao/util/CustomExcelImportUtil.java

+ 7 - 7
platform-dao/src/main/java/com/platform/dao/util/CustomExcelImportUtil.java

@@ -462,7 +462,7 @@ public class CustomExcelImportUtil {
     public static void main(String[] args) throws IOException, InvalidFormatException {
         String[] files = {"C:\\Users\\cyz\\Downloads\\---C-020 (S-35).xls",
                 "C:\\Users\\cyz\\Downloads\\--C-025 (S-40).xls",
-                "C:\\Users\\cyz\\Downloads\\---C-021 (S-36).xls"};
+                "C:\\Users\\cyz\\Downloads\\---C-026 (S-41-REP-V48-1).xls"};
         InputStream inputstream = new FileInputStream(files[2]);
         LocalDateTime now = LocalDateTime.now();
        //  List<SparePartInfoVO> list = importSparePartInfoList(now, inputstream);
@@ -964,7 +964,7 @@ public class CustomExcelImportUtil {
         CheckStandard record = null;
         String sbNo = "" ;
         int type = 0;// 没有负责人的,1有
-        if(sheet.getRow(4).getCell(10) != null && StringUtils.isNotBlank(sheet.getRow(4).getCell(10) .getStringCellValue())){
+        if(sheet.getRow(4).getCell(10) != null && StringUtils.isNotBlank(sheet.getRow(4).getCell(10).getStringCellValue())){
             type = 0;
             sbNo = sheet.getRow(4).getCell(10).getStringCellValue().trim();
         }else{
@@ -973,6 +973,7 @@ public class CustomExcelImportUtil {
         }
         StringBuffer error = new StringBuffer();
         LOGGER.info("文件行数:" + rowCounts);
+        int sort = 1;
         for (int i = 12; i <= rowCounts; i++) {
             record = new CheckStandard();
             Row row = sheet.getRow(i);
@@ -988,7 +989,10 @@ public class CustomExcelImportUtil {
             } catch (Exception e) {
                 throw new BusinessException("导入异常,行号:"+ i + ", 错误信息" + e.getMessage() +  ", 错误原因" + e.getCause());
             }
-            result.add(record);
+            record.setSort(sort++);
+            if(StringUtils.isNotBlank(record.getName())){
+                result.add(record);
+            }
         }
         return result;
     }
@@ -996,8 +1000,6 @@ public class CustomExcelImportUtil {
     private static void setPerson(String sbNo, Row row, CheckStandard record) {
         //i,j i:行 j:列
         setPeriod(row, record);
-        String sort = getCellValue(row.getCell(11)).trim();
-        record.setSort(Integer.valueOf(sort.substring(0,sort.length()-2 )));
         record.setRequirement(row.getCell(12).getStringCellValue().trim());
         int length = record.getRequirement().length();
         length = (length>20)?20:length;
@@ -1013,8 +1015,6 @@ public class CustomExcelImportUtil {
     private static void setNoPerson(String sbNo, Row row, CheckStandard record) {
         //i,j i:行 j:列
         setPeriod(row, record);
-        String sort = getCellValue(row.getCell(8)).trim();
-        record.setSort(Integer.valueOf(sort.substring(0,sort.length()-2 )));
         record.setRequirement(row.getCell(9).getStringCellValue().trim());
         int length = record.getRequirement().length();
         length = (length>20)?20:length;