lyhzzz 5 місяців тому
батько
коміт
7ed8a919dd

+ 1 - 1
src/main/java/com/fdkankan/ucenter/service/ISceneCooperationService.java

@@ -24,7 +24,7 @@ public interface ISceneCooperationService extends IService<SceneCooperation> {
     void deleteCooperationList(List<ScenePro> sceneProList, List<ScenePlus> scenePlusList,List<Long> userIds) ;
     void deleteCooperationList(List<String> numList,List<Long> userIds) ;
 
-    void saveBatchByList(List<String> numList, List<Long> userId ,String type);
+    List<SceneCooperation> saveBatchByList(List<String> numList, List<Long> userId ,String type);
 
     JSONObject sceneResourceList(SceneCooperationParam param);
 

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

@@ -20,6 +20,7 @@ import com.fdkankan.ucenter.util.DateUserUtil;
 import com.fdkankan.ucenter.vo.request.SceneCooperationParam;
 import com.fdkankan.ucenter.vo.request.SceneParam;
 import com.google.common.collect.Lists;
+import com.sun.org.apache.bcel.internal.generic.RET;
 import org.apache.commons.lang3.StringUtils;
 import org.opencv.face.Face;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -110,7 +111,7 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
     }
 
     @Override
-    public void saveBatchByList(List<String> numList,  List<Long> userIds,String type) {
+    public List<SceneCooperation> saveBatchByList(List<String> numList,  List<Long> userIds,String type) {
         List<SceneCooperation> list = new ArrayList<>();
         List<String> delList = new ArrayList<>();
 
@@ -142,16 +143,18 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
             }
         }
 
-        for (SceneCooperation sceneCooperation : list) {
-            redisUtil.hset(RedisKeyUtil.SCENE_COOPERATION_NUM_USERID, sceneCooperation.getSceneNum(), sceneCooperation.getUserId() + "");
+        if(!list.isEmpty()){
+            for (SceneCooperation sceneCooperation : list) {
+                redisUtil.hset(RedisKeyUtil.SCENE_COOPERATION_NUM_USERID, sceneCooperation.getSceneNum(), sceneCooperation.getUserId() + "");
+            }
+            this.saveBatch(list);
         }
-        this.saveBatch(list);
 
         for (String num : delList) {
             String[] split = num.split(",");
             delCooperation(split[0],Long.valueOf(split[1]));
         }
-
+        return  list;
     }
 
     private void delCooperation(String num ,Long userId){
@@ -413,11 +416,11 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
         List<String> v4List = plusList.stream().map(ScenePlus::getNum).collect(Collectors.toList());
         numList.addAll(v3List);
         numList.addAll(v4List);
-
+        List<SceneCooperation> addList =new ArrayList<>();
         if( !numList.isEmpty()){
-            this.saveBatchByList(numList,userIds,type);
+            addList = this.saveBatchByList(numList, userIds, type);
         }
-
+        List<Long> collect3 = addList.stream().map(SceneCooperation::getUserId).collect(Collectors.toList());
         for (User user : userList) {
             if("aws".equals(NacosProperty.uploadType)){
                 if("camera".equals(type) && cameraList != null){
@@ -425,7 +428,9 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
                     cameraList.forEach(e -> cameraMap.put(e.getId(),e));
                     mailTemplateService.sendCameraCooperation(cameraMap,user.getUserName(),lang);
                 }else {
-                    mailTemplateService.sendSceneCooperation(proList,plusList,user.getUserName(),lang);
+                    if(collect3.contains(user.getId())){
+                        mailTemplateService.sendSceneCooperation(proList,plusList,user.getUserName(),lang);
+                    }
                 }
             }
         }