|
@@ -1,5 +1,6 @@
|
|
|
package com.fdkankan.scene.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -8,6 +9,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fdkankan.model.constants.ConstantFilePath;
|
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
+import com.fdkankan.scene.entity.*;
|
|
|
+import com.fdkankan.scene.service.*;
|
|
|
import com.fdkankan.web.response.ResultData;
|
|
|
import com.fdkankan.model.utils.CreateObjUtil;
|
|
|
import com.fdkankan.common.util.DateUtil;
|
|
@@ -20,36 +23,12 @@ import com.fdkankan.redis.util.RedisLockUtil;
|
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
|
import com.fdkankan.scene.bean.RequestRebuildVedioScene;
|
|
|
import com.fdkankan.scene.bean.RequestSceneCooperation;
|
|
|
-import com.fdkankan.scene.entity.Camera;
|
|
|
-import com.fdkankan.scene.entity.CameraDetail;
|
|
|
-import com.fdkankan.scene.entity.PicSceneProgress;
|
|
|
-import com.fdkankan.scene.entity.Scene;
|
|
|
-import com.fdkankan.scene.entity.SceneCooperation;
|
|
|
-import com.fdkankan.scene.entity.ScenePlus;
|
|
|
-import com.fdkankan.scene.entity.ScenePlusExt;
|
|
|
-import com.fdkankan.scene.entity.ScenePro;
|
|
|
-import com.fdkankan.scene.entity.SceneProEdit;
|
|
|
-import com.fdkankan.scene.entity.SceneResource;
|
|
|
-import com.fdkankan.scene.entity.User;
|
|
|
-import com.fdkankan.scene.entity.UserIncrement;
|
|
|
-import com.fdkankan.scene.entity.VideoSceneProgress;
|
|
|
import com.fdkankan.scene.mapper.ISceneMapper;
|
|
|
-import com.fdkankan.scene.service.ICameraDetailService;
|
|
|
-import com.fdkankan.scene.service.ICameraService;
|
|
|
-import com.fdkankan.scene.service.IPicSceneProgressService;
|
|
|
-import com.fdkankan.scene.service.ISceneCooperationService;
|
|
|
-import com.fdkankan.scene.service.IScenePlusExtService;
|
|
|
-import com.fdkankan.scene.service.IScenePlusService;
|
|
|
-import com.fdkankan.scene.service.ISceneProEditService;
|
|
|
-import com.fdkankan.scene.service.ISceneProService;
|
|
|
-import com.fdkankan.scene.service.ISceneResourceService;
|
|
|
-import com.fdkankan.scene.service.ISceneService;
|
|
|
-import com.fdkankan.scene.service.IUserIncrementService;
|
|
|
-import com.fdkankan.scene.service.IUserService;
|
|
|
-import com.fdkankan.scene.service.IVideoSceneProgressService;
|
|
|
+import com.fdkankan.web.user.SSOLoginHelper;
|
|
|
import com.fdkankan.web.user.SSOUser;
|
|
|
import java.io.File;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -102,6 +81,10 @@ public class SceneServiceImpl extends ServiceImpl<ISceneMapper, Scene> implement
|
|
|
private IPicSceneProgressService picSceneProgressService;
|
|
|
@Autowired
|
|
|
private RabbitMqProducer rabbitMqProducer;
|
|
|
+ @Autowired
|
|
|
+ private IUserRoleService userRoleService;
|
|
|
+ @Autowired
|
|
|
+ private IUserService iUserService;
|
|
|
|
|
|
@Value("${queue.modeling.queue-video-a}")
|
|
|
private String queueVideoA;
|
|
@@ -115,151 +98,46 @@ public class SceneServiceImpl extends ServiceImpl<ISceneMapper, Scene> implement
|
|
|
|
|
|
@Override
|
|
|
public ResultData isLogin(String num, SSOUser ssoUser) throws Exception {
|
|
|
-
|
|
|
- if(Objects.isNull(ssoUser)){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_3004);
|
|
|
- }
|
|
|
-
|
|
|
- // 解密获得username,用于和数据库进行对比
|
|
|
- String username = ssoUser.getUserName();
|
|
|
-
|
|
|
- ScenePro sceneProEntity = sceneProService.findBySceneNum(num);
|
|
|
- if(sceneProEntity == null){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
- }
|
|
|
- if(sceneProEntity.getPayStatus() != 1){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
- }
|
|
|
- if(sceneProEntity.getStatus() != 1 && sceneProEntity.getStatus() != -2){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
+ if(StrUtil.isEmpty(num) ){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
|
|
|
}
|
|
|
-
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
-
|
|
|
- //判断本地资源是否已本删除,如果已删除,前端根据字段值为true提示用户不能使用某些功能,需要重算
|
|
|
- Date algorithmTime = sceneProEntity.getCreateTime();
|
|
|
- jsonObject.put("sourceExpired", false);
|
|
|
- if (!ObjectUtils.isEmpty(expiredMonth) && com.fdkankan.common.util.DateUtil.delay(algorithmTime, expiredMonth, Calendar.MONTH).before(new Date())) {
|
|
|
- jsonObject.put("sourceExpired", true);
|
|
|
+ if (ssoUser == null){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_3004);
|
|
|
}
|
|
|
-
|
|
|
- List<SceneResource> exclude = new ArrayList<>();
|
|
|
- SceneResource excludeEntity = new SceneResource();
|
|
|
- excludeEntity.setKeyWord("data");
|
|
|
- exclude.add(excludeEntity);
|
|
|
-
|
|
|
- Camera camera = cameraService.findByChildName(username);
|
|
|
- jsonObject.put("exclude", exclude);
|
|
|
- jsonObject.put("include", new ArrayList<>());
|
|
|
- jsonObject.put("company", null);
|
|
|
- ResultData result = ResultData.ok(jsonObject);
|
|
|
-
|
|
|
- //判断该场景是否属于增值权益
|
|
|
- boolean isIncrement = false;
|
|
|
- //获取该相机是否有权益
|
|
|
- boolean isExpired = false;
|
|
|
- Camera sceneCamera = cameraService.getById(sceneProEntity.getCameraId());
|
|
|
- if(sceneCamera != null){
|
|
|
- UserIncrement userIncrementEntity = userIncrementService.findByCameraId(sceneCamera.getId());
|
|
|
-
|
|
|
- if(userIncrementEntity != null){
|
|
|
- if( userIncrementEntity.getIsExpired().intValue() == 0){
|
|
|
- isIncrement = true;
|
|
|
- }
|
|
|
- if(userIncrementEntity.getIsExpired().intValue() == 1){
|
|
|
- isExpired = true;
|
|
|
- }
|
|
|
- }else{
|
|
|
- try {
|
|
|
- Date date = DateUtil.string2Date("2021-09-09 00:00:00",null);
|
|
|
-
|
|
|
- //非07批次的放开
|
|
|
- String pc = sceneCamera.getSnCode().substring(0,2);
|
|
|
- if(!pc.equals("07") ){
|
|
|
- if(sceneCamera.getCreateTime()!=null && date.after(sceneCamera.getCreateTime())){
|
|
|
-
|
|
|
- isIncrement = true;
|
|
|
- isExpired = false;
|
|
|
- }
|
|
|
- }
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
+ List<UserRole> list = userRoleService.list(new LambdaQueryWrapper<UserRole>().eq(UserRole::getUserId, ssoUser.getId()));
|
|
|
+ Set<Long> roleIdSet = null;
|
|
|
+ if(CollUtil.isNotEmpty(list)){
|
|
|
+ roleIdSet = list.stream().map(ur -> ur.getRoleId()).collect(Collectors.toSet());
|
|
|
}
|
|
|
-
|
|
|
- jsonObject.put("isExpired", isExpired );
|
|
|
- jsonObject.put("isIncrement", isIncrement);
|
|
|
-
|
|
|
- //判断过期时间
|
|
|
- Date date = DateUtil.string2Date(expectedTime,null);
|
|
|
-
|
|
|
- jsonObject.put("isTransition",DateUtil.isBeforeNow2(date));
|
|
|
-
|
|
|
-
|
|
|
- if(camera != null){
|
|
|
- if(!sceneProEntity.getCameraId().equals(camera.getId())){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5014);
|
|
|
- }
|
|
|
-
|
|
|
- CameraDetail cameraDetailEntity = cameraDetailService.findByCameraId(camera.getId());
|
|
|
- if(cameraDetailEntity.getCompanyId() != null){
|
|
|
- if(cameraDetailEntity.getCompanyId().longValue() == 1 || cameraDetailEntity.getCompanyId().longValue() == 14){
|
|
|
- jsonObject.put("exclude", new ArrayList<>());
|
|
|
- jsonObject.put("company", cameraDetailEntity.getCompanyId().longValue());
|
|
|
+ if(!roleIdSet.contains(5)){
|
|
|
+ ScenePro sceneProEntity = sceneProService.findBySceneNum(num);
|
|
|
+ if(!sceneProEntity.getUserId().equals(ssoUser.getId())){
|
|
|
+ if(!ssoUser.getRoleSet().contains("6")){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5014);
|
|
|
}
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- User user = userService.findByUserName(username);
|
|
|
- if("18750226207".equals(username)){
|
|
|
- log.info("18750226207该账号默认超级管理员,可以操作所有场景");
|
|
|
- }
|
|
|
- else if(user == null || sceneProEntity.getUserId() == null || user.getId().longValue() != sceneProEntity.getUserId().longValue()){
|
|
|
- log.info("user:" + user.getId() + ",scene:" + sceneProEntity.getUserId());
|
|
|
-
|
|
|
- List<SceneCooperation> list =
|
|
|
- sceneCooperationService.list(
|
|
|
- new LambdaQueryWrapper<SceneCooperation>()
|
|
|
- .eq(SceneCooperation::getSceneNum, num));
|
|
|
- if(list != null && list.size() > 0){
|
|
|
- if(list.get(0).getUserId().longValue() != user.getId().longValue()){
|
|
|
+ User userEntity = iUserService.getById(sceneProEntity.getUserId());
|
|
|
+ User tokenUser = iUserService.getById(ssoUser.getId());
|
|
|
+ if(Objects.isNull(userEntity) || Objects.isNull(userEntity.getCompanyId())
|
|
|
+ || Objects.isNull(tokenUser) || Objects.isNull(tokenUser.getCompanyId())
|
|
|
+ || !userEntity.getCompanyId().equals(tokenUser.getCompanyId())){
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5014);
|
|
|
}
|
|
|
- }else {
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5014);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(sceneProEntity.getCameraId() != null){
|
|
|
- camera = cameraService.getById(sceneProEntity.getCameraId());
|
|
|
- if(camera != null){
|
|
|
- CameraDetail cameraDetail = cameraDetailService.findByCameraId(camera.getId());
|
|
|
- if(cameraDetail.getCompanyId() != null){
|
|
|
- if(cameraDetail.getCompanyId().longValue() == 1 || cameraDetail.getCompanyId().longValue() == 14){
|
|
|
- jsonObject.put("exclude", new ArrayList<>());
|
|
|
- jsonObject.put("company", cameraDetail.getCompanyId().longValue());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ //判断该场景是否属于增值权益
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
|
|
- //权限控制完后判断若是协作账号,获取协作权限
|
|
|
- SceneCooperation sceneCooperation = sceneCooperationService.getByNum(num);
|
|
|
- //若数据为空表示可操作全部资源
|
|
|
- if(sceneCooperation == null || sceneCooperation.getUserId().longValue() != ssoUser.getId().longValue()){
|
|
|
- return result;
|
|
|
- }
|
|
|
+ jsonObject.put("isExpired", false );
|
|
|
+ jsonObject.put("isIncrement", false);
|
|
|
|
|
|
- if(sceneProEntity.getUserId()!= null && sceneCooperation.getUserId()!= null &&
|
|
|
- sceneProEntity.getUserId().equals(sceneCooperation.getUserId())){
|
|
|
- return result;
|
|
|
- }
|
|
|
+ //判断过期时间
|
|
|
+ jsonObject.put("isTransition",false);
|
|
|
+ jsonObject.put("exclude", new ArrayList<>());
|
|
|
+ jsonObject.put("include", new ArrayList<>());
|
|
|
|
|
|
- jsonObject.put("include", sceneResourceService.findByCooperationId(sceneCooperation.getId()));
|
|
|
|
|
|
- return result;
|
|
|
+ return ResultData.ok(jsonObject);
|
|
|
}
|
|
|
|
|
|
@Override
|