Explorar o código

pms 瑞都编辑任务时 查询公司下所有设备及人员

zhangcl hai 3 días
pai
achega
1b3656da4e

+ 12 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotDeviceServiceImpl.java

@@ -543,9 +543,21 @@ public class IotDeviceServiceImpl implements IotDeviceService {
 
     @Override
     public List<IotDeviceDO> getDevicesByDepts(IotDevicePageReqVO reqVO) {
+        // 如果 reqVO.getDeptIds 有值 就是根据选择的部门 查询部门下所有设备
+        // 考虑到设备调拨的情况 可以修改 成查询所选部门所属公司下所有设备
         if (CollUtil.isEmpty(reqVO.getDeviceIds()) && CollUtil.isEmpty(reqVO.getDeptIds())) {
             throw new ServiceException(IOT_DEPT_NOT_SELECTED);
         }
+        if (CollUtil.isNotEmpty(reqVO.getDeptIds())) {
+            // 查询选择的部门 选择的部门所属的公司 属于 瑞都 163l 则查询所有瑞都下的设备
+            List<Long> deptIds = reqVO.getDeptIds();
+            Long randomDeptId = deptIds.get(0);
+            // 查询 瑞都下的所有 部门
+            Set<Long> childDeptIds = deptService.getChildDeptIdListFromCache(163l);
+            if (childDeptIds.contains(randomDeptId)) {
+                reqVO.setDeptIds(new ArrayList<>(childDeptIds));
+            }
+        }
         AtomicReference<List<IotDeviceDO>> devices = new AtomicReference<>(new ArrayList<>());
         // 忽略数据权限
         DataPermissionUtils.executeIgnore(() -> {

+ 15 - 3
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java

@@ -695,16 +695,28 @@ public class AdminUserServiceImpl implements AdminUserService {
             });
             return resultUsers.get();
         }
-        if (CollUtil.isEmpty(reqVO.getDeptIds())) {
+        List<Long> reqDeptIds = reqVO.getDeptIds();
+        if (CollUtil.isEmpty(reqDeptIds)) {
             throw exception(DEPT_NOT_FOUND);
         }
+        Long randomDeptId = reqDeptIds.get(0);
         DeptListReqVO deptListReqVO = new DeptListReqVO();
         deptListReqVO.setDeptIds(reqVO.getDeptIds());
-        List<Long> deptIds = deptService.selectedDepts(deptListReqVO);
+        List<Long> deptIds = new ArrayList<>();
+        // 查询 瑞都下的所有 部门
+        Set<Long> childDeptIds = deptService.getChildDeptIdListFromCache(163l);
+        childDeptIds.add(163l);
+        if (childDeptIds.contains(randomDeptId)) {
+            // 瑞都下的部门 队伍
+            deptIds = new ArrayList<>(childDeptIds);
+        } else {
+            deptIds = deptService.selectedDepts(deptListReqVO);
+        }
         if (CollUtil.isNotEmpty(deptIds)) {
             // 查询部门下所有人员
+            List<Long> finalDeptIds = deptIds;
             DataPermissionUtils.executeIgnore(() -> {
-                List<AdminUserDO> users = userMapper.selectSimpleList(deptIds);
+                List<AdminUserDO> users = userMapper.selectSimpleList(finalDeptIds);
                 if (CollUtil.isNotEmpty(users)) {
                     resultUsers.set(users);
                 }