|
@@ -110,31 +110,57 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void saveBatchByList(List<ScenePro> sceneProList, List<ScenePlus> scenePlusList, Long userId,List<Long> resourceIdList) {
|
|
|
+ public void saveBatchByList(List<String> numList, List<Long> userIds,String type) {
|
|
|
List<SceneCooperation> list = new ArrayList<>();
|
|
|
- for (ScenePro scenePro : sceneProList) {
|
|
|
- SceneCooperation sceneCooperationEntity = new SceneCooperation();
|
|
|
- sceneCooperationEntity.setUserId(userId);
|
|
|
- sceneCooperationEntity.setSceneNum(scenePro.getNum());
|
|
|
- sceneCooperationEntity.setRecStatus("A");
|
|
|
- sceneCooperationEntity.setCreateTime(DateUserUtil.getDate(new Date()));
|
|
|
- sceneCooperationEntity.setUpdateTime(DateUserUtil.getDate(new Date()));
|
|
|
- list.add(sceneCooperationEntity);
|
|
|
- }
|
|
|
- for (ScenePlus scenePlus : scenePlusList) {
|
|
|
- SceneCooperation sceneCooperationEntity = new SceneCooperation();
|
|
|
- sceneCooperationEntity.setUserId(userId);
|
|
|
- sceneCooperationEntity.setSceneNum(scenePlus.getNum());
|
|
|
- sceneCooperationEntity.setRecStatus("A");
|
|
|
- sceneCooperationEntity.setCreateTime(DateUserUtil.getDate(new Date()));
|
|
|
- sceneCooperationEntity.setUpdateTime(DateUserUtil.getDate(new Date()));
|
|
|
- list.add(sceneCooperationEntity);
|
|
|
+ List<String> delList = new ArrayList<>();
|
|
|
+
|
|
|
+ HashMap<String, List<User>> byNumList = this.getByNumList(numList);
|
|
|
+
|
|
|
+
|
|
|
+ for (Long userId : userIds) {
|
|
|
+ for (String num : numList) {
|
|
|
+ List<User> users = byNumList.get(num);
|
|
|
+ List<Long> collect1 = users.stream().map(User::getId).collect(Collectors.toList());
|
|
|
+ if(collect1.contains(userId)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if("scene".equals(type)){
|
|
|
+ for (Long l : collect1) {
|
|
|
+ if(!userIds.contains(l)){
|
|
|
+ delList.add(num + "," +l);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ SceneCooperation sceneCooperationEntity = new SceneCooperation();
|
|
|
+ sceneCooperationEntity.setUserId(userId);
|
|
|
+ sceneCooperationEntity.setSceneNum(num);
|
|
|
+ sceneCooperationEntity.setRecStatus("A");
|
|
|
+ sceneCooperationEntity.setCreateTime(DateUserUtil.getDate(new Date()));
|
|
|
+ sceneCooperationEntity.setUpdateTime(DateUserUtil.getDate(new Date()));
|
|
|
+ list.add(sceneCooperationEntity);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
for (SceneCooperation sceneCooperation : list) {
|
|
|
redisUtil.hset(RedisKeyUtil.SCENE_COOPERATION_NUM_USERID, sceneCooperation.getSceneNum(), sceneCooperation.getUserId() + "");
|
|
|
}
|
|
|
this.saveBatch(list);
|
|
|
|
|
|
+ for (String num : delList) {
|
|
|
+ String[] split = num.split(",");
|
|
|
+ delCooperation(split[0],Long.valueOf(split[1]));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void delCooperation(String num ,Long userId){
|
|
|
+ redisUtil.hdel(RedisKeyUtil.SCENE_COOPERATION_NUM_USERID,num,userId);
|
|
|
+ LambdaQueryWrapper<SceneCooperation> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(SceneCooperation::getSceneNum,num);
|
|
|
+ wrapper.eq(SceneCooperation::getUserId,userId);
|
|
|
+ this.remove(wrapper);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -240,7 +266,7 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
|
|
|
List<String> numList = Arrays.asList(nums);
|
|
|
List<ScenePro> proList = sceneProService.getListByNums(numList);
|
|
|
List<ScenePlus> plusList = scenePlusService.getListByNums(numList);
|
|
|
- this.deleteCooperationList(proList,plusList,Arrays.asList(user.getId()));
|
|
|
+ //this.deleteCooperationList(proList,plusList,Arrays.asList(user.getId()));
|
|
|
|
|
|
saveCooperationCommon(loginUser,param.getLang(),Arrays.asList(user),proList,plusList,null,"scene");
|
|
|
}
|
|
@@ -326,14 +352,14 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
|
|
|
List<ScenePro> proList = sceneProService.getListByNums(numList);
|
|
|
List<ScenePlus> plusList = scenePlusService.getListByNums(numList);
|
|
|
List<Long> userIds = users.stream().map(User::getId).collect(Collectors.toList());
|
|
|
- this.deleteCooperationList(proList,plusList,userIds);
|
|
|
+ //this.deleteCooperationList(proList,plusList,userIds);
|
|
|
|
|
|
saveCooperationCommon(loginUser,lang,users,proList,plusList,null,"scene");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void successAddCooperation(List<String> numList,List<Long> userIds,Long loginUserId,Long cameraId,String lang){
|
|
|
- this.deleteCooperationList(numList,userIds);
|
|
|
+ //this.deleteCooperationList(numList,userIds);
|
|
|
List<ScenePro> proList = sceneProService.getListByNums(numList);
|
|
|
List<ScenePlus> plusList = scenePlusService.getListByNums(numList);
|
|
|
List<User> users = userService.listByIds(userIds);
|
|
@@ -352,7 +378,7 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
|
|
|
|
|
|
private void successAddCooperation(List<ScenePro> v3List,List<ScenePlus> v4List,List<User> users,String lang,User loginUser,List<Camera>cameraList){
|
|
|
List<Long> userIds = users.stream().map(User::getId).collect(Collectors.toList());
|
|
|
- this.deleteCooperationList(v3List,v4List,userIds);
|
|
|
+ //this.deleteCooperationList(v3List,v4List,userIds);
|
|
|
saveCooperationCommon(loginUser,lang,users,v3List,v4List,cameraList,"camera");
|
|
|
|
|
|
}
|
|
@@ -382,14 +408,18 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
|
|
|
|
|
|
private void saveCooperationCommon(User LoginUser,String lang,List<User> userList,List<ScenePro> proList, List<ScenePlus> plusList,List<Camera >cameraList,String type){
|
|
|
|
|
|
- for (User user : userList) {
|
|
|
- if( !proList.isEmpty()){
|
|
|
- this.saveBatchByList(proList,new ArrayList<>(),user.getId(),null);
|
|
|
- }
|
|
|
- if(!plusList.isEmpty()){
|
|
|
- this.saveBatchByList(new ArrayList<>(),plusList,user.getId(),null);
|
|
|
- }
|
|
|
+ List<Long> userIds = userList.stream().map(User::getId).collect(Collectors.toList());
|
|
|
+ List<String> numList = new ArrayList<>();
|
|
|
+ List<String> v3List = proList.stream().map(ScenePro::getNum).collect(Collectors.toList());
|
|
|
+ List<String> v4List = plusList.stream().map(ScenePlus::getNum).collect(Collectors.toList());
|
|
|
+ numList.addAll(v3List);
|
|
|
+ numList.addAll(v4List);
|
|
|
|
|
|
+ if( !numList.isEmpty()){
|
|
|
+ this.saveBatchByList(numList,userIds,type);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (User user : userList) {
|
|
|
if("aws".equals(NacosProperty.uploadType)){
|
|
|
if("camera".equals(type) && cameraList != null){
|
|
|
HashMap<Long, Camera> cameraMap = new HashMap<>();
|