|
@@ -1,49 +1,33 @@
|
|
|
package com.fdkankan.scene.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
-import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.fdkankan.common.constant.CommonStatus;
|
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
-import com.fdkankan.common.util.DateExtUtil;
|
|
|
import com.fdkankan.model.constants.UploadFilePath;
|
|
|
-import com.fdkankan.scene.entity.Camera;
|
|
|
-import com.fdkankan.scene.entity.CameraDetail;
|
|
|
-import com.fdkankan.scene.entity.SceneCooperation;
|
|
|
import com.fdkankan.scene.entity.ScenePlus;
|
|
|
import com.fdkankan.scene.entity.ScenePlusExt;
|
|
|
import com.fdkankan.scene.entity.SceneResource;
|
|
|
-import com.fdkankan.scene.entity.User;
|
|
|
-import com.fdkankan.scene.entity.UserIncrement;
|
|
|
import com.fdkankan.scene.oss.OssUtil;
|
|
|
-import com.fdkankan.scene.service.ICameraDetailService;
|
|
|
-import com.fdkankan.scene.service.ICameraService;
|
|
|
-import com.fdkankan.scene.service.ISceneCooperationService;
|
|
|
import com.fdkankan.scene.service.ISceneEditInfoExtService;
|
|
|
import com.fdkankan.scene.service.ISceneEditService;
|
|
|
import com.fdkankan.scene.service.IScenePlusExtService;
|
|
|
import com.fdkankan.scene.service.IScenePlusService;
|
|
|
import com.fdkankan.scene.service.ISceneProService;
|
|
|
-import com.fdkankan.scene.service.ISceneResourceService;
|
|
|
import com.fdkankan.scene.service.ISceneUploadService;
|
|
|
-import com.fdkankan.scene.service.IUserIncrementService;
|
|
|
-import com.fdkankan.scene.service.IUserService;
|
|
|
import com.fdkankan.scene.vo.BaseDataParamVO;
|
|
|
import com.fdkankan.scene.vo.BaseSceneParamVO;
|
|
|
import com.fdkankan.scene.vo.DeleteFileParamVO;
|
|
|
-import com.fdkankan.scene.vo.LocalesParamVO;
|
|
|
import com.fdkankan.scene.vo.SceneAuthVO;
|
|
|
import com.fdkankan.web.response.ResultData;
|
|
|
import com.fdkankan.web.user.SSOUser;
|
|
|
import java.io.IOException;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -71,18 +55,6 @@ public class SceneEditServiceImpl implements ISceneEditService {
|
|
|
@Autowired
|
|
|
private ISceneEditInfoExtService sceneEditInfoExtService;
|
|
|
@Autowired
|
|
|
- private ICameraDetailService cameraDetailService;
|
|
|
- @Autowired
|
|
|
- private ICameraService cameraService;
|
|
|
- @Autowired
|
|
|
- private IUserIncrementService userIncrementService;
|
|
|
- @Autowired
|
|
|
- private IUserService userService;
|
|
|
- @Autowired
|
|
|
- private ISceneCooperationService sceneCooperationService;
|
|
|
- @Autowired
|
|
|
- private ISceneResourceService sceneResourceService;
|
|
|
- @Autowired
|
|
|
private IScenePlusExtService scenePlusExtService;
|
|
|
@Autowired
|
|
|
private OssUtil ossUtil;
|
|
@@ -90,9 +62,6 @@ public class SceneEditServiceImpl implements ISceneEditService {
|
|
|
@Override
|
|
|
public SceneAuthVO getAuth(String num, SSOUser ssoUser){
|
|
|
|
|
|
- // 解密获得username,用于和数据库进行对比
|
|
|
- String username = ssoUser.getUserName();
|
|
|
-
|
|
|
ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
|
|
|
|
SceneAuthVO sceneAuthVO = new SceneAuthVO();
|
|
@@ -102,7 +71,6 @@ public class SceneEditServiceImpl implements ISceneEditService {
|
|
|
excludeEntity.setKeyWord("data");
|
|
|
exclude.add(excludeEntity);
|
|
|
|
|
|
- Camera camera = cameraService.findByChildName(username);
|
|
|
sceneAuthVO.setExclude(exclude);
|
|
|
sceneAuthVO.setInclude(new ArrayList<>());
|
|
|
sceneAuthVO.setCompany(null);
|
|
@@ -111,102 +79,13 @@ public class SceneEditServiceImpl implements ISceneEditService {
|
|
|
boolean isVip = false;
|
|
|
//获取该相机是否有权益
|
|
|
boolean isExpired = false;
|
|
|
- Camera sceneCamera = cameraService.getById(scenePlus.getCameraId());
|
|
|
- if(sceneCamera != null){
|
|
|
- UserIncrement userIncrementEntity = userIncrementService.findByCameraId(sceneCamera.getId());
|
|
|
-
|
|
|
- if(userIncrementEntity != null){
|
|
|
- if( userIncrementEntity.getIsExpired().intValue() == 0){
|
|
|
- isVip = true;
|
|
|
- }
|
|
|
- if(userIncrementEntity.getIsExpired().intValue() == 1){
|
|
|
- isExpired = true;
|
|
|
- }
|
|
|
- }else{
|
|
|
- try {
|
|
|
- Date date = DateUtil.parse("2021-09-09 00:00:00", DateExtUtil.dateStyle);
|
|
|
-
|
|
|
- //非07批次的放开
|
|
|
- String pc = sceneCamera.getSnCode().substring(0,2);
|
|
|
- if(!pc.equals("07") ){
|
|
|
- if(sceneCamera.getCreateTime()!=null && date.after(sceneCamera.getCreateTime())){
|
|
|
- isVip = true;
|
|
|
- isExpired = false;
|
|
|
- }
|
|
|
- }
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
sceneAuthVO.setIsExpired(isExpired);
|
|
|
sceneAuthVO.setIsVip(isVip);
|
|
|
|
|
|
//判断过期时间
|
|
|
- if(camera != null){
|
|
|
- if(!scenePlus.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){
|
|
|
- sceneAuthVO.setExclude(new ArrayList<>());
|
|
|
- sceneAuthVO.setCompany(cameraDetailEntity.getCompanyId());
|
|
|
- }
|
|
|
- }
|
|
|
- return sceneAuthVO;
|
|
|
- }
|
|
|
-
|
|
|
- User user = userService.findByUserName(username);
|
|
|
- if("18750226207".equals(username)){
|
|
|
- log.info("18750226207该账号默认超级管理员,可以操作所有场景");
|
|
|
- }
|
|
|
- else if(user == null || scenePlus.getUserId() == null || user.getId().longValue() != scenePlus.getUserId().longValue()){
|
|
|
- log.info("user:" + user.getId() + ",scene:" + scenePlus.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()){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5014);
|
|
|
- }
|
|
|
- }else {
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5014);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(scenePlus.getCameraId() != null){
|
|
|
- camera = cameraService.getById(scenePlus.getCameraId());
|
|
|
- if(camera != null){
|
|
|
- CameraDetail cameraDetail = cameraDetailService.findByCameraId(camera.getId());
|
|
|
- if(cameraDetail.getCompanyId() != null){
|
|
|
- if(cameraDetail.getCompanyId().longValue() == 1 || cameraDetail.getCompanyId().longValue() == 14){
|
|
|
- sceneAuthVO.setExclude(new ArrayList<>());
|
|
|
- sceneAuthVO.setCompany(cameraDetail.getCompanyId());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //权限控制完后判断若是协作账号,获取协作权限
|
|
|
- SceneCooperation sceneCooperation = sceneCooperationService.getByNum(num);
|
|
|
- //若数据为空表示可操作全部资源
|
|
|
- if(sceneCooperation == null || sceneCooperation.getUserId().longValue() != ssoUser.getId().longValue()){
|
|
|
- return sceneAuthVO;
|
|
|
- }
|
|
|
-
|
|
|
- if(scenePlus.getUserId()!= null && sceneCooperation.getUserId()!= null &&
|
|
|
- scenePlus.getUserId().equals(sceneCooperation.getUserId())){
|
|
|
- return sceneAuthVO;
|
|
|
- }
|
|
|
-
|
|
|
- sceneAuthVO.setInclude(sceneResourceService.findByCooperationId(sceneCooperation.getId()));
|
|
|
-
|
|
|
return sceneAuthVO;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// @Override
|