lyhzzz 2 年之前
父節點
當前提交
3bba3808d7

+ 35 - 15
src/main/java/com/fdkankan/manage/service/impl/CameraServiceImpl.java

@@ -160,7 +160,7 @@ public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implem
     }
     }
     @Override
     @Override
     public Integer ins(List<String> wifiNameList){
     public Integer ins(List<String> wifiNameList){
-        List<Integer> errorRow = getErrorRow(wifiNameList, null);
+        List<Integer> errorRow = getErrorRow(wifiNameList);
         getResultIn(errorRow);
         getResultIn(errorRow);
         LambdaQueryWrapper<Camera> wrapper = new LambdaQueryWrapper<>();
         LambdaQueryWrapper<Camera> wrapper = new LambdaQueryWrapper<>();
         wrapper.in(Camera::getWifiName,wifiNameList);
         wrapper.in(Camera::getWifiName,wifiNameList);
@@ -186,22 +186,39 @@ public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implem
         throw new BusinessException(-1, res.toString());
         throw new BusinessException(-1, res.toString());
     }
     }
 
 
-    private List<Integer> getErrorRow(List<String> wifiNameList, List<String> newList){
+    private List<Integer> getErrorRow(List<String> wifiNameList){
         List<Integer> errorIndexList = new ArrayList<>();
         List<Integer> errorIndexList = new ArrayList<>();
-        boolean bo = false;
-        if(newList == null){
-            newList = wifiNameList;
-            bo = true;
-        }
-        for (String wifiName : newList) {
-            int index = wifiNameList.indexOf(wifiName) + 4;
-            if(bo){
-                if( !wifiName.contains("_") || !wifiName.contains("4D")
-                        || !CameraTypeEnum.typePrefixMap.containsKey(wifiName.split("_")[0]+"_")){
-                    errorIndexList.add(index);
-                }
-            }else {
+        Set<String> wifiNameSet = new HashSet<>();
+        Integer index = 3;
+        for (String wifiName : wifiNameList) {
+            index ++;
+            if(StringUtils.isBlank(wifiName)){
+                errorIndexList.add(index);
+                continue;
+            }
+            if(wifiNameSet.contains(wifiName)){
                 errorIndexList.add(index);
                 errorIndexList.add(index);
+                continue;
+            }
+            if( !wifiName.contains("_") || !wifiName.contains("4D")
+                    || !CameraTypeEnum.typePrefixMap.containsKey(wifiName.split("_")[0]+"_")){
+                errorIndexList.add(index);
+            }
+            wifiNameSet.add(wifiName);
+        }
+        return errorIndexList;
+    }
+    private List<Integer> getErrorRow(List<String> wifiNameList,List<String> dbList){
+        List<Integer> errorIndexList = new ArrayList<>();
+
+        if(dbList.size() <=0){
+            return errorIndexList;
+        }
+        Integer index = 3;
+        for (String wifiName : wifiNameList) {
+            index ++;
+            if(dbList.contains(wifiName)){
+               errorIndexList.add(index);
             }
             }
         }
         }
         return errorIndexList;
         return errorIndexList;
@@ -265,6 +282,9 @@ public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implem
     private void checkSnCode(List<String> snCodeList) {
     private void checkSnCode(List<String> snCodeList) {
         HashMap<String,Integer> map = new HashMap<>();
         HashMap<String,Integer> map = new HashMap<>();
         for (String snCode : snCodeList) {
         for (String snCode : snCodeList) {
+            if(StringUtils.isBlank(snCode)){
+                map.put(snCode,2);
+            }
             if(map.get(snCode) == null){
             if(map.get(snCode) == null){
                 map.put(snCode,1);
                 map.put(snCode,1);
             }else {
             }else {

+ 0 - 1
src/main/java/com/fdkankan/manage/service/impl/ExcelServiceImpl.java

@@ -82,7 +82,6 @@ public class ExcelServiceImpl implements IExcelService {
         try {
         try {
             excelRowList = ExcelUtil.getExcelRowList(file);
             excelRowList = ExcelUtil.getExcelRowList(file);
         }catch (Exception e){
         }catch (Exception e){
-            e.printStackTrace();
             throw new BusinessException(50002,"模板错误");
             throw new BusinessException(50002,"模板错误");
         }
         }
         List<String> wifiNameList = new ArrayList<>();
         List<String> wifiNameList = new ArrayList<>();

+ 1 - 2
src/main/java/com/fdkankan/manage/util/ExcelUtil.java

@@ -31,8 +31,7 @@ public class ExcelUtil {
             for (int cellNum=0;cellNum<= row.getLastCellNum();cellNum++){
             for (int cellNum=0;cellNum<= row.getLastCellNum();cellNum++){
                 Cell cell = row.getCell(cellNum);
                 Cell cell = row.getCell(cellNum);
                 if(cell != null){
                 if(cell != null){
-                    cell.setCellType(CellType.STRING);
-                    map.put(cellNum,cell.getStringCellValue().trim());
+                    map.put(cellNum,cell.toString().trim());
                 }
                 }
             }
             }
             rowList.add(map);
             rowList.add(map);