From ae68c6103dfb1383d9360aa0b86d5b91677fcd1e Mon Sep 17 00:00:00 2001
From: zhangnaisong <2434969829@qq.com>
Date: 星期五, 31 五月 2024 14:30:42 +0800
Subject: [PATCH] 光电查询加入自定义权限bug修改提交
---
ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java | 121 +++++++++++++++++++++++++++++++++++++++-
1 files changed, 118 insertions(+), 3 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java b/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java
index 7f7c334..a9f53ab 100644
--- a/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java
@@ -56,13 +56,13 @@
private SysDeptMapper sysDeptMapper;
@Resource
private RedisCache redisCache;
- @Autowired
+ @Resource
private ISysDeptService deptService;
@Resource
private ArdChannelMapper ardChannelMapper;
@Resource
private IVtduService vtduService;
- @Autowired
+ @Resource
protected Validator validator;
@PostConstruct
@@ -320,6 +320,28 @@
}
@Override
+ public List<Map<String, Object>> getChildDeptAndCameraOwn(Boolean disabled) {
+ Long deptId = SecurityUtils.getDeptId();
+ SysDept sysDept = sysDeptMapper.selectDeptById(deptId);
+ List<Long> ownDeptIdList = sysDeptMapper.selectRoleDeptIdByUsersId(SecurityUtils.getUserId());//鑷畾涔夋潈闄愪富閿煡璇�
+ ownDeptIdList.remove(SecurityUtils.getDeptId());//鑻ヨ嚜瀹氫箟鏉冮檺鍖呭惈鏈骇鏉冮檺锛屽垯绉婚櫎
+ Map<String, Object> map = fetchChildDepartments(sysDept, disabled, ownDeptIdList);//鏌ヨ鏈潈闄愬強涓嬪睘鏉冮檺璁惧骞跺湪鑷畾涔夋潈闄愪腑绉婚櫎涓嬪睘閮ㄩ棬涓婚敭
+ Set<Long> pIdSet = new HashSet();//鑷畾涔夋潈闄愪富閿殑鏈�璇ユ潈闄�
+ for(Long deptIdn : ownDeptIdList){
+ List<SysDept> pSysDeptList = sysDeptMapper.getParentsDeptListByDeptId(deptIdn);
+ pIdSet.add(pSysDeptList.get(pSysDeptList.size() - 1).getDeptId());//鑾峰彇
+ }
+ List<Map<String, Object>> result = new ArrayList();
+ result.add(map);
+ for(Long pId : pIdSet){
+ SysDept pSysDept = sysDeptMapper.selectDeptById(pId);
+ Map<String, Object> mapO = fetchChildDepartments(ownDeptIdList, pSysDept, disabled);
+ result.add(mapO);
+ }
+ return result;
+ }
+
+ @Override
public List<DeptAndCamerasDto> getChildDeptAndCamera() {
List<SysDept> depts = deptService.selectDeptList(new SysDept());
return fetchChildDepartments(depts);
@@ -346,6 +368,84 @@
childMap.put("deptId", childDept.getDeptId());
childMap.put("disabled", disabled);
Map<String, Object> map1 = fetchChildDepartments(childDept, disabled);
+ childMap.putAll(map1);
+ childList.add(childMap);
+ }
+ if (ardCameras.size() > 0) {
+ for (ArdCameras camera : ardCameras) {
+ ArdChannel ardChannel = new ArdChannel();
+ ardChannel.setDeviceId(camera.getId());
+ List<ArdChannel> ardChannels = ardChannelMapper.selectArdChannelList(ardChannel);
+ if (ardChannels != null) {
+ ardChannels.stream().sorted();
+ camera.setChannelList(ardChannels);
+ }
+ Map<String, Object> cameraMap = ArdTool.convertEntityToMap(camera);
+ childList.add(cameraMap);
+ }
+ }
+ map.put("children", childList);
+ return map;
+ }
+
+ /**
+ * zns
+ *
+ * */
+ public Map<String, Object> fetchChildDepartments(SysDept sysDept, Boolean disabled, List<Long> ownDeptIdList) {
+ Map<String, Object> map = new HashMap<>();
+ map.put("name", sysDept.getDeptName());
+ map.put("deptId", sysDept.getDeptId());
+ map.put("disabled", disabled);
+ List<SysDept> sysDepts = sysDeptMapper.selectNextChildrenDeptById(sysDept.getDeptId());
+ for(SysDept sysDeptC : sysDepts){//鑻ヨ嚜瀹氫箟鏉冮檺鍖呭惈涓嬬骇鏉冮檺锛屽垯绉婚櫎
+ if(ownDeptIdList.contains(sysDeptC.getDeptId())){
+ ownDeptIdList.remove(sysDeptC.getDeptId());
+ }
+ }
+ List<ArdCameras> ardCameras = ardCamerasMapper.selectArdCamerasByDeptId(sysDept.getDeptId());
+ List<Object> childList = new ArrayList<>();
+ for (SysDept childDept : sysDepts) {
+ Map<String, Object> childMap = new HashMap<>();
+ childMap.put("name", childDept.getDeptName());
+ childMap.put("deptId", childDept.getDeptId());
+ childMap.put("disabled", disabled);
+ Map<String, Object> map1 = fetchChildDepartments(childDept, disabled);
+ childMap.putAll(map1);
+ childList.add(childMap);
+ }
+ if (ardCameras.size() > 0) {
+ for (ArdCameras camera : ardCameras) {
+ ArdChannel ardChannel = new ArdChannel();
+ ardChannel.setDeviceId(camera.getId());
+ List<ArdChannel> ardChannels = ardChannelMapper.selectArdChannelList(ardChannel);
+ if (ardChannels != null) {
+ ardChannels.stream().sorted();
+ camera.setChannelList(ardChannels);
+ }
+ Map<String, Object> cameraMap = ArdTool.convertEntityToMap(camera);
+ childList.add(cameraMap);
+ }
+ }
+ map.put("children", childList);
+ return map;
+ }
+
+ public Map<String, Object> fetchChildDepartments(List<Long> ownDeptIdList, SysDept sysDept, Boolean disabled) {
+ Map<String, Object> map = new HashMap<>();
+ map.put("name", sysDept.getDeptName());
+ map.put("deptId", sysDept.getDeptId());
+ map.put("disabled", disabled);
+ List<SysDept> sysDepts = sysDeptMapper.selectNextChildrenDeptByIdAndInList(sysDept.getDeptId(),ownDeptIdList);
+ List<ArdCameras> ardCameras = ardCamerasMapper.selectArdCamerasByDeptId(sysDept.getDeptId());
+ List<Object> childList = new ArrayList<>();
+ for (SysDept childDept : sysDepts) {
+ Map<String, Object> childMap = new HashMap<>();
+ childMap.put("name", childDept.getDeptName());
+ childMap.put("deptId", childDept.getDeptId());
+ childMap.put("disabled", disabled);
+ //Map<String, Object> map1 = fetchChildDepartments(childDept, disabled);
+ Map<String, Object> map1 = fetchChildDepartments(ownDeptIdList,childDept, disabled);
childMap.putAll(map1);
childList.add(childMap);
}
@@ -565,10 +665,25 @@
@Override
public List<Map<String, Object>> getCamerasByDeptId(Long deptId,String userId) {
- List<Map<String, Object>> result = ardCamerasMapper.getCamerasByDeptId(deptId,userId);
+ List<Long> deptIdList = new ArrayList();
+ deptIdList.add(deptId);
+ deptIdList = getOwnAndChildrenDeptIdList(deptIdList,new ArrayList());//閫掑綊鏌ヨ涓嬪睘閮ㄩ棬涓婚敭
+ //List<Map<String, Object>> result = ardCamerasMapper.getCamerasByDeptId(deptId,userId);
+ List<Map<String, Object>> result = ardCamerasMapper.getCamerasByDeptId(deptIdList,userId);
return result;
}
+ public List<Long> getOwnAndChildrenDeptIdList(List<Long> deptIdList,List<Long> deptIdListr){
+ deptIdListr.addAll(deptIdList);
+ List<Long> result = sysDeptMapper.getChildrenDeptIdList(deptIdList);
+ if(result.size() != 0){
+ deptIdListr.addAll(result);
+ result = getOwnAndChildrenDeptIdList(result,deptIdListr);
+ }
+ deptIdListr = deptIdListr.stream().distinct().collect(Collectors.toList());
+ return deptIdListr;
+ }
+
@Override
public Boolean getCameraOperationByCameraId(String id, String userId) {
Boolean result = ardCamerasMapper.getCameraOperationByCameraId(id,userId);
--
Gitblit v1.9.3