lyhzzz 5 months ago
parent
commit
b380b5186c

+ 10 - 2
src/main/java/com/fdkankan/ucenter/service/impl/SceneCooperationServiceImpl.java

@@ -123,7 +123,7 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
                 List<User> users = byNumList.get(num);
                 if(users != null && !users.isEmpty()){
                     List<Long> collect1 = users.stream().map(User::getId).collect(Collectors.toList());
-                    if("scene".equals(type)){
+                    if("scene".equals(type) && numList.size() == 1){
                         for (Long l : collect1) {
                             if(!userIds.contains(l)){
                                 delList.add(num + "," +l);
@@ -296,6 +296,14 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
             throw new BusinessException(ResultCode.COO_LIMIT_ERROR);
         }
         User loginUser = userService.getByUserName(loginUserName);
+        if(numList.size() >1){
+            HashMap<String, List<User>> byNumList = this.getByNumList(numList, param.getSceneType());
+            for (String num : byNumList.keySet()) {
+                if(byNumList.get(num).size() + param.getUserNameList().size() >5){
+                    throw new BusinessException(ResultCode.COO_LIMIT_ERROR);
+                }
+            }
+        }
 
         List<User> users = new ArrayList<>();
         for (String userName : param.getUserNameList()) {
@@ -425,7 +433,7 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
 
             List<User> dbUserList = map.get(num);
             if(dbUserList != null && !dbUserList.isEmpty()){
-                if(cameraId != null){
+                if(numList.size() >1){
                     freeCount = (dbUserList.size() > freeCount ? dbUserList.size() :  (freeCount - dbUserList.size()));
                 }else {
                     freeCount = (dbUserList.size() > freeCount ? dbUserList.size() : freeCount) ;