Explorar o código

pms 瑞恒 统计包含设备的队伍

zhangcl hai 23 horas
pai
achega
79f280e1fc

+ 13 - 3
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/stat/IotStaticController.java

@@ -1463,6 +1463,17 @@ public class IotStaticController {
         Map<Long, String> projectPair = new HashMap<>();
         // key项目部id   value项目部包含的队伍id集合
         Map<Long, Set<Long>> projectTeamPair = new HashMap<>();
+        // 查询 瑞恒 所有设备 只统计包含 施工 状态设备的队伍
+        IotDevicePageReqVO deviceReqVO = new IotDevicePageReqVO();
+        deviceReqVO.setDeptIds(new ArrayList<>(childDeptIds));
+        List<IotDeviceDO> allRhDevices = iotDeviceMapper.selectListAlone(deviceReqVO);
+        Set<Long> haveDeviceDeptIds = new HashSet<>();
+        if (CollUtil.isNotEmpty(allRhDevices)) {
+            // 筛选出包含设备的队伍部门集合
+            allRhDevices.forEach(device -> {
+                haveDeviceDeptIds.add(device.getDeptId());
+            });
+        }
         if (CollUtil.isNotEmpty(allDeptPair)) {
             allDeptPair.forEach((deptId, dept) -> {
                 if (dept.getName().contains("项目部") ) {
@@ -1471,13 +1482,13 @@ public class IotStaticController {
                     projectPair.put(deptId, dept.getName());
                 }
             });
-            // 遍历所有部门
+            // 遍历所有部门 只筛选出有设备的队伍
             allDeptPair.forEach((deptId, dept) -> {
                 // 找出每个项目部下的队伍
                 if (projectPair.containsKey(dept.getParentId())) {
                     // 获得当前部门的上级项目部
                     projectPair.forEach((projectDeptId, projectDept) -> {
-                        if (projectDeptId.equals(dept.getParentId())) {
+                        if (projectDeptId.equals(dept.getParentId()) && haveDeviceDeptIds.contains(deptId)) {
                             if (projectTeamPair.containsKey(projectDeptId)) {
                                 Set<Long> teamIds = projectTeamPair.get(projectDeptId);
                                 teamIds.add(deptId);
@@ -1533,7 +1544,6 @@ public class IotStaticController {
             }
             // 计算每个项目部的设备利用率
             if (CollUtil.isNotEmpty(projectTeamPair)) {
-
                 projectTeamPair.forEach((projectDeptId, teamIds) -> {
                     ProjectUtilizationRateVo rateVo = new ProjectUtilizationRateVo();
                     rateVo.setProjectDeptId(projectDeptId);

+ 1 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/IotDeviceMapper.java

@@ -114,6 +114,7 @@ public interface IotDeviceMapper extends BaseMapperX<IotDeviceDO> {
         LambdaQueryWrapperX<IotDeviceDO> queryWrapper = new LambdaQueryWrapperX<>();
         queryWrapper
                 .inIfPresent(IotDeviceDO::getId, reqVO.getDeviceIds())
+                .inIfPresent(IotDeviceDO::getDeptId, reqVO.getDeptIds())
                 .eqIfPresent(IotDeviceDO::getBrand, reqVO.getBrand())
                 .eqIfPresent(IotDeviceDO::getModel, reqVO.getModel())
                 .eqIfPresent(IotDeviceDO::getDeviceStatus, reqVO.getDeviceStatus())