|
@@ -68,6 +68,8 @@ public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implem
|
|
|
ISceneCooperationService sceneCooperationService;
|
|
|
@Autowired
|
|
|
ICameraIncrementLogService cameraIncrementLogService;
|
|
|
+ @Autowired
|
|
|
+ IMailTemplateService mailTemplateService;
|
|
|
|
|
|
@Override
|
|
|
public Camera getBySnCode(String snCode) {
|
|
@@ -79,6 +81,15 @@ public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implem
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+ public Camera getByWfiName(String snCode) {
|
|
|
+ LambdaQueryWrapper<Camera> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(Camera::getWifiName,snCode);
|
|
|
+ List<Camera> list = this.list(wrapper);
|
|
|
+ if(list !=null && list.size() > 0){
|
|
|
+ return list.get(0);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public List<Camera> getCameraLikeSnCode(String snCode) {
|
|
@@ -248,26 +259,26 @@ public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implem
|
|
|
public void bind(Integer cameraType, String snCodes, String username) {
|
|
|
User user = userService.getByUserName(username);
|
|
|
String[] snCodeArr = snCodes.split(",");
|
|
|
- List<String> snCodeList = Arrays.asList(snCodeArr);
|
|
|
- LambdaUpdateWrapper<Camera> wrapper = new LambdaUpdateWrapper<>();
|
|
|
- wrapper.in(Camera::getSnCode,snCodeList);
|
|
|
- List<Camera> list = this.list(wrapper);
|
|
|
- if(list.size() <=0){
|
|
|
- throw new BusinessException(AppConstant.FAILURE_CODE_4010, snCodes +"-"+ AppConstant.FAILURE_MSG_4010);
|
|
|
- }
|
|
|
- List<String> dbSnCode = list.stream().map(Camera::getSnCode).collect(Collectors.toList());
|
|
|
- for (String code : snCodeList) {
|
|
|
- if(!dbSnCode.contains(code)){
|
|
|
- throw new BusinessException(AppConstant.FAILURE_CODE_4010, code +"-"+ AppConstant.FAILURE_MSG_4010);
|
|
|
+ List<Long> cameraIds = new ArrayList<>();
|
|
|
+ for (String wifiName : snCodeArr) {
|
|
|
+ Camera camera = null;
|
|
|
+ if(wifiName.contains("_")){
|
|
|
+ camera = this.getByWfiName(wifiName);
|
|
|
+ }else {
|
|
|
+ camera = this.getBySnCode(wifiName);
|
|
|
}
|
|
|
- }
|
|
|
- Map<Long, Camera> cameraHashMap = list.stream().collect(Collectors.toMap(Camera::getId, camera -> camera, (o1, o2) -> o1));
|
|
|
- List<Long> cameraIds = new ArrayList<>(cameraHashMap.keySet());
|
|
|
- HashMap<Long, CameraDetail> detailHashMap = cameraDetailService.getByCameraIds(cameraIds);
|
|
|
- for (CameraDetail detail : detailHashMap.values()) {
|
|
|
- if(detail.getUserId() != null){
|
|
|
- throw new BusinessException(CameraConstant.FAILURE_CODE_6010, cameraHashMap.get(detail.getCameraId()).getSnCode() +"-"+ CameraConstant.FAILURE_MSG_6010);
|
|
|
+
|
|
|
+ if(camera == null){
|
|
|
+ throw new BusinessException(AppConstant.FAILURE_CODE_4010, wifiName +"-"+ AppConstant.FAILURE_MSG_4010);
|
|
|
+ }
|
|
|
+ CameraDetail cameraDetail = cameraDetailService.getByCameraId(camera.getId());
|
|
|
+ if(cameraDetail == null){
|
|
|
+ throw new BusinessException(AppConstant.FAILURE_CODE_4010, wifiName +"-"+ AppConstant.FAILURE_MSG_4010);
|
|
|
}
|
|
|
+ if( cameraDetail.getUserId() != null){
|
|
|
+ throw new BusinessException(CameraConstant.FAILURE_CODE_6010, wifiName +"-"+ CameraConstant.FAILURE_MSG_6010);
|
|
|
+ }
|
|
|
+ cameraIds.add(camera.getId());
|
|
|
}
|
|
|
|
|
|
cameraIncrementLogService.saveLog(cameraIds,null,user.getId(),2);
|
|
@@ -283,7 +294,7 @@ public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implem
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void saveCooperationUser(String ids, Long id,String resourceIds, String username) {
|
|
|
+ public void saveCooperationUser(String ids, Long id,String resourceIds, String username,String lang) {
|
|
|
User user = userService.getByUserName(username);
|
|
|
if(user == null){
|
|
|
throw new BusinessException(LoginConstant.FAILURE_CODE_3021, LoginConstant.FAILURE_MSG_3021);
|
|
@@ -339,6 +350,9 @@ public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implem
|
|
|
|
|
|
fdkkLaserService.disableCooperation(detailMap, cameraMap);
|
|
|
fdkkLaserService.enableCameraCooperation(detailMap, cameraMap, username);
|
|
|
+ if("aws".equals(NacosProperty.uploadType)){
|
|
|
+ mailTemplateService.sendCameraCooperation(cameraMap,username,lang);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|