yq 2 years ago
parent
commit
6824023161

+ 10 - 0
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/impl/DmpDeviceInfoServiceImpl.java

@@ -32,6 +32,7 @@ import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -195,9 +196,18 @@ public class DmpDeviceInfoServiceImpl extends AbstractCrudService<DmpDeviceInfoM
                     || StringUtils.isBlank(device.getSimCode())
                     || null == device.getSubscribeFlag()
             ).count();
+            long count1 = deviceInfos.stream()
+                    .collect(Collectors.toMap(DmpDeviceInfo::getDeviceName, s -> 1, Integer::sum))
+                    .entrySet()
+                    .stream()
+                    .filter(entry -> entry.getValue() > 1)
+                    .count();
             if (count > 0){
                 throw new BusinessException("表格字段不能为空");
             }
+            if (count1 > 0){
+                throw new BusinessException("设备名称不能重复");
+            }
             return deviceInfos;
         }catch (Exception e){
             throw new BusinessException("解析表格异常,检查表格格式"+e.getMessage());