lyhzzz 4 months ago
parent
commit
b8c3b7241f

+ 2 - 1
src/main/java/com/fdkankan/ucenter/httpClient/service/LaserService.java

@@ -431,7 +431,7 @@ public class LaserService {
         return null ;
     }
 
-    public void saveBatchCooperation(List<String> numList2,List<String> snCodeList, String userName, List<String> userNameList,String type) {
+    public void saveBatchCooperation(List<String> numList2,List<String> snCodeList, String userName, List<String> userNameList,String type,String operatingMode) {
         log.info(numList2.size() +"---------"+snCodeList.size());
         if(numList2.isEmpty() && snCodeList.isEmpty()){
             return;
@@ -444,6 +444,7 @@ public class LaserService {
         map.put("type",type);
         map.put("snCodeList",snCodeList);
         map.put("userNameList",userNameList);
+        map.put("operatingMode",operatingMode);
         rabbitMqProducer.sendByWorkQueue("laser-batch-save-cooperation",map);
     }
 }

+ 8 - 14
src/main/java/com/fdkankan/ucenter/service/impl/SceneCooperationServiceImpl.java

@@ -299,25 +299,18 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
         User loginUser = userService.getByUserName(loginUserName);
         if(numList.size() >1){
             HashMap<String, List<User>> byNumList = this.getByNumList(numList, param.getSceneType());
-            Boolean flag = true;
             for (String num : numList) {
-                Boolean inFlag = true;
-                if(byNumList.get(num) != null && !byNumList.isEmpty()){
-                    if(byNumList.get(num).size() + param.getUserNameList().size() >5){
+                if(byNumList.get(num) != null && !byNumList.isEmpty()) {
+                    if (byNumList.get(num).size() + param.getUserNameList().size() > 5) {
                         throw new BusinessException(ResultCode.COO_LIMIT_ERROR);
                     }
                     List<User> users = byNumList.get(num);
-                    List<String> collect = users.stream().map(User::getUserName).collect(Collectors.toList());
-                    for (String userName : param.getUserNameList()) {
-                        if(!collect.contains(userName)){
-                            inFlag = false;
-                        }
+                    Set<String> collect = users.stream().map(User::getUserName).collect(Collectors.toSet());
+
+                    if(collect.containsAll(param.getUserNameList())){
+                        throw new BusinessException(ResultCode.COO_LIMIT_ERROR2);
                     }
                 }
-                flag = !inFlag;
-            }
-            if(flag){
-                throw new BusinessException(ResultCode.COO_LIMIT_ERROR2);
             }
         }
 
@@ -528,7 +521,8 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
         if(StringUtils.isNotBlank(sceneType) && "mesh".equals(sceneType)){
             return;
         }
-        laserService.saveBatchCooperation(new ArrayList<>(numList1),snCodeList,LoginUser.getUserName(),collect,type);
+        String operatingMode = numList.size() > 1 ? "add" :"update";
+        laserService.saveBatchCooperation(new ArrayList<>(numList1),snCodeList,LoginUser.getUserName(),collect,type,operatingMode);
 
     }