|
@@ -3,14 +3,15 @@ package com.fdkankan.ucenter.service.impl;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.fdkankan.common.constant.SceneConstant;
|
|
import com.fdkankan.common.constant.SceneConstant;
|
|
-import com.fdkankan.common.exception.BusinessException;
|
|
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
import com.fdkankan.ucenter.common.PageInfo;
|
|
import com.fdkankan.ucenter.common.PageInfo;
|
|
import com.fdkankan.ucenter.common.RedisKeyUtil;
|
|
import com.fdkankan.ucenter.common.RedisKeyUtil;
|
|
import com.fdkankan.ucenter.common.SceneSourceUtil;
|
|
import com.fdkankan.ucenter.common.SceneSourceUtil;
|
|
import com.fdkankan.ucenter.common.constants.NacosProperty;
|
|
import com.fdkankan.ucenter.common.constants.NacosProperty;
|
|
|
|
+import com.fdkankan.ucenter.common.constants.ResultCode;
|
|
import com.fdkankan.ucenter.constant.LoginConstant;
|
|
import com.fdkankan.ucenter.constant.LoginConstant;
|
|
import com.fdkankan.ucenter.entity.*;
|
|
import com.fdkankan.ucenter.entity.*;
|
|
|
|
+import com.fdkankan.ucenter.exception.BusinessException;
|
|
import com.fdkankan.ucenter.httpClient.service.LaserService;
|
|
import com.fdkankan.ucenter.httpClient.service.LaserService;
|
|
import com.fdkankan.ucenter.mapper.ISceneCooperationMapper;
|
|
import com.fdkankan.ucenter.mapper.ISceneCooperationMapper;
|
|
import com.fdkankan.ucenter.service.*;
|
|
import com.fdkankan.ucenter.service.*;
|
|
@@ -75,15 +76,26 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void deleteCooperationList(List<ScenePro> sceneProList,List<ScenePlus> scenePlusList) {
|
|
|
|
|
|
+ public void deleteCooperationList(List<ScenePro> sceneProList,List<ScenePlus> scenePlusList,List<Long> userIds) {
|
|
if(CollectionUtils.isEmpty(sceneProList) && CollectionUtils.isEmpty(scenePlusList)){
|
|
if(CollectionUtils.isEmpty(sceneProList) && CollectionUtils.isEmpty(scenePlusList)){
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
List<String> numList = sceneProList.stream().map(ScenePro::getNum).collect(Collectors.toList());
|
|
List<String> numList = sceneProList.stream().map(ScenePro::getNum).collect(Collectors.toList());
|
|
List<String> numList2 = scenePlusList.stream().map(ScenePlus::getNum).collect(Collectors.toList());
|
|
List<String> numList2 = scenePlusList.stream().map(ScenePlus::getNum).collect(Collectors.toList());
|
|
numList.addAll(numList2);
|
|
numList.addAll(numList2);
|
|
|
|
+ this.deleteCooperationList(numList,userIds);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void deleteCooperationList(List<String> numList,List<Long> userIds) {
|
|
|
|
+ if(CollectionUtils.isEmpty(numList) ){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
LambdaQueryWrapper<SceneCooperation> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<SceneCooperation> wrapper = new LambdaQueryWrapper<>();
|
|
wrapper.in(SceneCooperation::getSceneNum,numList);
|
|
wrapper.in(SceneCooperation::getSceneNum,numList);
|
|
|
|
+ if(userIds != null && !userIds.isEmpty()){
|
|
|
|
+ wrapper.in(SceneCooperation::getUserId,userIds);
|
|
|
|
+ }
|
|
List<SceneCooperation> list = this.list(wrapper);
|
|
List<SceneCooperation> list = this.list(wrapper);
|
|
List<Long> ids = list.stream().map(SceneCooperation::getId).collect(Collectors.toList());
|
|
List<Long> ids = list.stream().map(SceneCooperation::getId).collect(Collectors.toList());
|
|
if(ids.size() >0){
|
|
if(ids.size() >0){
|
|
@@ -226,9 +238,9 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
|
|
List<String> numList = Arrays.asList(nums);
|
|
List<String> numList = Arrays.asList(nums);
|
|
List<ScenePro> proList = sceneProService.getListByNums(numList);
|
|
List<ScenePro> proList = sceneProService.getListByNums(numList);
|
|
List<ScenePlus> plusList = scenePlusService.getListByNums(numList);
|
|
List<ScenePlus> plusList = scenePlusService.getListByNums(numList);
|
|
- this.deleteCooperationList(proList,plusList);
|
|
|
|
|
|
+ this.deleteCooperationList(proList,plusList,Arrays.asList(user.getId()));
|
|
|
|
|
|
- saveCooperationCommon(loginUser,param.getLang(),Arrays.asList(user),proList,plusList);
|
|
|
|
|
|
+ saveCooperationCommon(loginUser,param.getLang(),Arrays.asList(user),proList,plusList,null,"scene");
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -252,30 +264,97 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
|
|
String[] nums = param.getSceneNum().split(",");
|
|
String[] nums = param.getSceneNum().split(",");
|
|
List<String> numList = Arrays.asList(nums);
|
|
List<String> numList = Arrays.asList(nums);
|
|
|
|
|
|
- ProductOrder productOrder = checkNeedPay(numList, users, loginUser, param.getPayType(), param.getTimeZone());
|
|
|
|
|
|
+ ProductOrder productOrder = checkNeedPay(numList, users, loginUser, param.getPayType(), param.getTimeZone(),null,param.getLang());
|
|
|
|
|
|
if(productOrder == null){
|
|
if(productOrder == null){
|
|
successAddCooperation(numList,users,param.getLang(),loginUser);
|
|
successAddCooperation(numList,users,param.getLang(),loginUser);
|
|
}else {
|
|
}else {
|
|
- productCooperationService.add(productOrder,users,numList);
|
|
|
|
|
|
+ productCooperationService.add(productOrder,users,numList,null);
|
|
}
|
|
}
|
|
return productOrder;
|
|
return productOrder;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public ProductOrder saveCamera(SceneCooperationParam param, String loginUserName) {
|
|
|
|
+ if(param.getCameraId() == null || StringUtils.isEmpty(param.getUserName())){
|
|
|
|
+ throw new BusinessException(LoginConstant.FAILURE_CODE_3001, LoginConstant.FAILURE_MSG_3001);
|
|
|
|
+ }
|
|
|
|
+ if(param.getUserName().equals( loginUserName)){
|
|
|
|
+ throw new BusinessException(LoginConstant.FAILURE_CODE_3025, LoginConstant.FAILURE_MSG_3025);
|
|
|
|
+ }
|
|
|
|
+ User user = userService.getByUserName(param.getUserName());
|
|
|
|
+ if(user == null){
|
|
|
|
+ throw new BusinessException(LoginConstant.FAILURE_CODE_3015,LoginConstant.FAILURE_MSG_3015);
|
|
|
|
+ }
|
|
|
|
+ User loginUser = userService.getByUserName(loginUserName);
|
|
|
|
+ Camera camera = cameraService.getById(param.getCameraId());
|
|
|
|
+ CameraDetail cameraDetail = cameraDetailService.getByCameraId(param.getCameraId());
|
|
|
|
+ if(camera == null || cameraDetail == null || cameraDetail.getUserId() == null){
|
|
|
|
+ throw new BusinessException(ResultCode.CAMERA_NOT_EXIT);
|
|
|
|
+ }
|
|
|
|
+ if(loginUser.getId().equals(cameraDetail.getUserId())){
|
|
|
|
+ throw new BusinessException(LoginConstant.FAILURE_CODE_3025, LoginConstant.FAILURE_MSG_3025);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<ScenePro> v3List = sceneProService.getListByCameraId(param.getCameraId());
|
|
|
|
+ List<ScenePlus> v4List = scenePlusService.getListByCameraId(param.getCameraId());
|
|
|
|
+ List<String> v3NumList = v3List.stream().map(ScenePro::getNum).collect(Collectors.toList());
|
|
|
|
+ List<String> v4NumList = v4List.stream().map(ScenePlus::getNum).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ List<String> allList = new ArrayList<>();
|
|
|
|
+ allList.addAll(v3NumList);
|
|
|
|
+ allList.addAll(v4NumList);
|
|
|
|
+
|
|
|
|
+ ProductOrder productOrder = checkNeedPay(allList, Arrays.asList(user), loginUser, param.getPayType(), param.getTimeZone(),param.getCameraId(),param.getLang());
|
|
|
|
+ if(productOrder == null){
|
|
|
|
+ successAddCooperation(v3List,v4List,Arrays.asList(user),param.getLang(),loginUser,Arrays.asList(camera));
|
|
|
|
+ cameraDetailService.updateCooperationByIds(Arrays.asList(param.getCameraId()),user.getId());
|
|
|
|
+ }else {
|
|
|
|
+ productCooperationService.add(productOrder,Arrays.asList(user),allList,param.getCameraId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return productOrder;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void successAddCooperation(List<String> numList,List<User> users,String lang,User loginUser){
|
|
|
|
+ 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);
|
|
|
|
+
|
|
|
|
+ saveCooperationCommon(loginUser,lang,users,proList,plusList,null,"scene");
|
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void successAddCooperation(List<String> numList,List<User> users,String lang,User loginUser){
|
|
|
|
|
|
+ public void successAddCooperation(List<String> numList,List<Long> userIds,Long loginUserId,Long cameraId,String lang){
|
|
|
|
+ this.deleteCooperationList(numList,userIds);
|
|
List<ScenePro> proList = sceneProService.getListByNums(numList);
|
|
List<ScenePro> proList = sceneProService.getListByNums(numList);
|
|
List<ScenePlus> plusList = scenePlusService.getListByNums(numList);
|
|
List<ScenePlus> plusList = scenePlusService.getListByNums(numList);
|
|
- this.deleteCooperationList(proList,plusList);
|
|
|
|
- saveCooperationCommon(loginUser,lang,users,proList,plusList);
|
|
|
|
|
|
+ List<User> users = userService.listByIds(userIds);
|
|
|
|
+ User user = userService.getById(loginUserId);
|
|
|
|
+ if(cameraId != null ){
|
|
|
|
+ Camera camera = cameraService.getById(cameraId);
|
|
|
|
+ saveCooperationCommon(user,lang,users,proList,plusList,Arrays.asList(camera),"camera");
|
|
|
|
+ cameraDetailService.updateCooperationByIds(Arrays.asList(cameraId),userIds.get(0));
|
|
|
|
+ }else {
|
|
|
|
+ saveCooperationCommon(user,lang,users,proList,plusList,null,"scene");
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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);
|
|
|
|
+ saveCooperationCommon(loginUser,lang,users,v3List,v4List,cameraList,"camera");
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- private ProductOrder checkNeedPay(List<String> numList, List<User> users,User loginUser,Integer payType,Integer timeZone) {
|
|
|
|
- Integer totalCount = users.size() -1;
|
|
|
|
|
|
+ private ProductOrder checkNeedPay(List<String> numList, List<User> users,User loginUser,Integer payType,Integer timeZone,Long cameraId,String lang) {
|
|
|
|
+ Integer totalCount = (users.size() -1) * numList.size();
|
|
HashMap<String, List<User>> map = this.getByNumList(numList);
|
|
HashMap<String, List<User>> map = this.getByNumList(numList);
|
|
for (String num : map.keySet()) {
|
|
for (String num : map.keySet()) {
|
|
List<User> users1 = map.get(num);
|
|
List<User> users1 = map.get(num);
|
|
@@ -293,14 +372,14 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
|
|
if(totalCount <=0){
|
|
if(totalCount <=0){
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
- return productOrderService.createOrder(totalCount, "cooperation", loginUser, payType, timeZone);
|
|
|
|
|
|
+ return productOrderService.createOrder(totalCount, "cooperation", loginUser, payType, timeZone,cameraId,lang);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
LaserService laserService;
|
|
LaserService laserService;
|
|
|
|
|
|
- private void saveCooperationCommon(User LoginUser,String lang,List<User> userList,List<ScenePro> proList, List<ScenePlus> plusList){
|
|
|
|
|
|
+ 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) {
|
|
for (User user : userList) {
|
|
if( !proList.isEmpty()){
|
|
if( !proList.isEmpty()){
|
|
@@ -311,7 +390,13 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
|
|
}
|
|
}
|
|
|
|
|
|
if("aws".equals(NacosProperty.uploadType)){
|
|
if("aws".equals(NacosProperty.uploadType)){
|
|
- mailTemplateService.sendSceneCooperation(proList,plusList,user.getUserName(),lang);
|
|
|
|
|
|
+ if("camera".equals(type) && cameraList != null){
|
|
|
|
+ HashMap<Long, Camera> cameraMap = new HashMap<>();
|
|
|
|
+ cameraList.forEach(e -> cameraMap.put(e.getId(),e));
|
|
|
|
+ mailTemplateService.sendCameraCooperation(cameraMap,user.getUserName(),lang);
|
|
|
|
+ }else {
|
|
|
|
+ mailTemplateService.sendSceneCooperation(proList,plusList,user.getUserName(),lang);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -321,7 +406,9 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
|
|
List<String> numList2 = collect2.stream().map(ScenePlus::getNum).collect(Collectors.toList());
|
|
List<String> numList2 = collect2.stream().map(ScenePlus::getNum).collect(Collectors.toList());
|
|
numList1.addAll(numList2);
|
|
numList1.addAll(numList2);
|
|
List<String> collect = userList.stream().map(User::getUserName).collect(Collectors.toList());
|
|
List<String> collect = userList.stream().map(User::getUserName).collect(Collectors.toList());
|
|
- laserService.saveBatchCooperation(numList2,LoginUser.getUserName(),collect);
|
|
|
|
|
|
+
|
|
|
|
+ List<String> snCodeList = cameraList.stream().map(Camera::getSnCode).collect(Collectors.toList());
|
|
|
|
+ laserService.saveBatchCooperation(numList2,snCodeList,LoginUser.getUserName(),collect,type);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -334,7 +421,7 @@ public class SceneCooperationServiceImpl extends ServiceImpl<ISceneCooperationMa
|
|
List<String> numList = Arrays.asList(nums);
|
|
List<String> numList = Arrays.asList(nums);
|
|
List<ScenePro> proList = sceneProService.getListByNums(numList);
|
|
List<ScenePro> proList = sceneProService.getListByNums(numList);
|
|
List<ScenePlus> plusList = scenePlusService.getListByNums(numList);
|
|
List<ScenePlus> plusList = scenePlusService.getListByNums(numList);
|
|
- this.deleteCooperationList(proList,plusList);
|
|
|
|
|
|
+ this.deleteCooperationList(proList,plusList,null);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|