Browse Source

设备新增导入

xiongchao 3 years ago
parent
commit
c7eb836acc

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

@@ -478,21 +478,14 @@ public class CustomExcelImportUtil {
                 "C:\\Users\\cyz\\Desktop\\固定资产0207(1)\\固定资产折旧明细表-2020年12月-苏丹.xls",
                 "C:\\Users\\cyz\\Desktop\\固定资产0207(1)\\固定资产折旧明细表-2020年12月-坦桑尼亚.xls",
                 "C:\\Users\\cyz\\Desktop\\固定资产0207(1)\\固定资产折旧明细表-2020年12月-苏丹.xls"};*/
-        String[] files = {"C:\\Users\\cyz\\Desktop\\备件基础信息 导入版.xls"};
+        String[] files = {"C:\\Users\\cyz\\Desktop\\2021.5.31 注塑设备台账导入文件.xls"};
         InputStream inputstream = new FileInputStream(files[0]);
         LocalDateTime now = LocalDateTime.now();
-        List<SparePartInfoVO> list = importSparePartInfoList(now, inputstream);
-        //List<SbInfo> list = importSbInfoList(inputstream);
+       //  List<SparePartInfoVO> list = importSparePartInfoList(now, inputstream);
+        List<SbInfoVO> list = importSbInfoList(inputstream);
         // List<SbModel> list = importModelList(inputstream);
         //List<SbInfo> list = importSbInfoListForUpdateValue(inputstream);
 
-
-  /*      List<SpareStore> list = importSpareStoreList(inputstream);
-        list.forEach(item -> {
-            System.out.println(item.toString());
-        });*/
-
-
         //List<SparePartInfoVO> list = importSparePartInfoListForUpdate(LocalDateTime.now(), inputstream);
         list.forEach(item -> {
             System.out.println(item.toString());
@@ -847,15 +840,28 @@ public class CustomExcelImportUtil {
         for (int i = 2; i <= rowCounts; i++) {
             record = new SbInfoVO();
             Row row = sheet.getRow(i);
-            String index = row.getCell(0).getStringCellValue() + "";
+            if(isRowEmpty(row)){
+                continue;
+            }
+            String index = row.getCell(1).getStringCellValue() + "";
             try {
                 //i,j i:行 j:列
                 record.setNo(row.getCell(1).getStringCellValue().trim());
                 record.setZbh(getCellValue(row.getCell(2)));
                 record.setName(row.getCell(3).getStringCellValue().trim().replace("'", ""));
                 record.setModel(getCellValue(row.getCell(4)).trim());
-                record.setLevel(getLevel(row.getCell(5).getStringCellValue()));
-                record.setInitialValue(new Double(getCellValue(row.getCell(6))));
+                String level = getCellValue(row.getCell(5));
+                if(StringUtils.isBlank(level)){
+                    record.setLevel(1);
+                }else{
+                    record.setLevel(getLevel(level));
+                }
+                String value = getCellValue(row.getCell(6));
+                if(StringUtils.isBlank(value)){
+                    record.setInitialValue(0.0);
+                }else{
+                    record.setInitialValue(new Double(value));
+                }
                 record.setTypeId(row.getCell(7).getStringCellValue().trim());
                 record.setUseType(getUseType(row.getCell(8).getStringCellValue().trim()));
                 record.setZz(getCellValue(row.getCell(9)));

+ 2 - 2
platform-rest/src/main/java/com/platform/rest/controller/sb/SbInfoController.java

@@ -251,10 +251,10 @@ public class SbInfoController {
      */
     @SysLog("新增导入设备")
     @PostMapping("/import")
-    public R importExcelByUpdate(@RequestParam("type") Integer type, @RequestParam("file") MultipartFile file,@RequestParam("useCompany") String useCompany, @RequestParam("useProject") String useProject) throws Exception {
+    public R importExcelByUpdate(@RequestParam("type") Integer type, @RequestParam("file") MultipartFile file) throws Exception {
         String result = "";
         if(type == 1){
-            result = sbInfoService.importListByAdd(useCompany, useProject, file);
+            result = sbInfoService.importListByAdd( file);
         }else if(type == 2){
             result = sbInfoService.importListByUpdateValue(file);
         }else{

+ 1 - 1
platform-service/src/main/java/com/platform/service/sb/SbInfoService.java

@@ -181,7 +181,7 @@ public interface SbInfoService extends IBaseService<SbInfo, SbInfoDTO> {
      */
     void updateQrCode(SbInfoDTO model);
 
-    String importListByAdd(String useCompany, String useProject, MultipartFile file);
+    String importListByAdd(MultipartFile file);
     String importListByUpdateValue(MultipartFile file);
     String importListByUpdate(MultipartFile file);
     String importListByUpdateALl(MultipartFile file);

+ 1 - 1
platform-service/src/main/java/com/platform/service/sb/impl/SbInfoServiceImpl.java

@@ -932,7 +932,7 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public String importListByAdd(String useCompany, String useProject, MultipartFile file) {
+    public String importListByAdd(MultipartFile file) {
         int addNum = 0;
         List<String> modelError = new ArrayList<String>();
         try {