lyhzzz hace 11 meses
padre
commit
745a67d3ff

+ 26 - 4
src/main/java/com/fdkankan/manage/service/impl/RtkDeviceServiceImpl.java

@@ -11,6 +11,7 @@ import com.fdkankan.manage.constant.RtkTypeEnum;
 import com.fdkankan.manage.entity.*;
 import com.fdkankan.manage.exception.BusinessException;
 import com.fdkankan.manage.mapper.IRtkDeviceMapper;
+import com.fdkankan.manage.service.ICameraService;
 import com.fdkankan.manage.service.IExcelService;
 import com.fdkankan.manage.service.IRtkDeviceService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -24,10 +25,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -46,6 +44,8 @@ public class RtkDeviceServiceImpl extends ServiceImpl<IRtkDeviceMapper, RtkDevic
     ISysUserService sysUserService;
     @Autowired
     IExcelService excelService;
+    @Autowired
+    ICameraService cameraService;
     @Override
     public RtkDevice getByRtkSnCode(String rtkSnCode) {
         LambdaQueryWrapper<RtkDevice> wrapper = new LambdaQueryWrapper<>();
@@ -112,6 +112,10 @@ public class RtkDeviceServiceImpl extends ServiceImpl<IRtkDeviceMapper, RtkDevic
         }
         RtkDevice  rtkDevice3 = null;
         if(StringUtils.isNotBlank(param.getCameraSn())){
+            Camera camera = cameraService.getBySnCode(param.getCameraSn());
+            if(camera == null){
+                throw new BusinessException(ResultCode.CAMERA_NOT_EXIST);
+            }
             rtkDevice3 = this.getByCameraSn(param.getCameraSn());
         }
         if(rtkDevice3 != null && param.getId() == null){
@@ -168,6 +172,8 @@ public class RtkDeviceServiceImpl extends ServiceImpl<IRtkDeviceMapper, RtkDevic
     public Integer insExcelList(List<HashMap<Integer, String>> excelRowList) {
         List<RtkDeviceInParam> params = new ArrayList<>();
         List<Integer> errorIndex = new ArrayList<>();
+        HashSet<String> rtkSnSet = new HashSet<>();
+        HashSet<String> cameraSnSet = new HashSet<>();
         Integer index = 0;
         for (HashMap<Integer, String> map : excelRowList) {
             index ++;
@@ -198,12 +204,28 @@ public class RtkDeviceServiceImpl extends ServiceImpl<IRtkDeviceMapper, RtkDevic
                 errorIndex.add(index -3);
                 continue;
             }
+            if(rtkSnSet.contains(rtkSn)){
+                errorIndex.add(index -3);
+                continue;
+            }
+            rtkSnSet.add(rtkSn);
             if(StringUtils.isNotBlank(cameraSn)){
+                Camera camera = cameraService.getBySnCode(cameraSn);
+                if(camera == null){
+                    errorIndex.add(index -3);
+                    continue;
+                }
                 RtkDevice rtkDevice2 = this.getByCameraSn(cameraSn);
                 if(rtkDevice2 !=null){
                     errorIndex.add(index -3);
                     continue;
                 }
+                if(cameraSnSet.contains(cameraSn)){
+                    errorIndex.add(index -3);
+                    continue;
+                }
+                cameraSnSet.add(cameraSn);
+
             }
             RtkDeviceInParam param = new RtkDeviceInParam(cameraSn,rtkTypeEnum.getCode(),rtkSn,rtkSgSn);
             params.add(param);