소스 검색

pms 瑞恒 生成日报及统计 设备利用率 更新主设备类别

zhangcl 4 일 전
부모
커밋
70f79d281b

+ 17 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrhdailyreport/IotRhDailyReportController.java

@@ -523,6 +523,19 @@ public class IotRhDailyReportController {
         // key施工队伍id   value状态为LY的项目部id
         Map<Long, Long> teamProjectIdPair = new HashMap<>();
         if (ObjUtil.isNotEmpty(deptId)) {
+            // 筛选瑞恒 主设备 rq_iot_rh_main_device_category
+            Set<Long> mainDeviceCategoryIds = new HashSet<>();
+            List<DictDataDO> constructionStatusDictData = dictDataService.getDictDataListByDictType("rq_iot_rh_main_device_category");
+            if (CollUtil.isNotEmpty(constructionStatusDictData)) {
+                constructionStatusDictData.forEach(data -> {
+                    String value = data.getValue();
+                    if (NumberUtil.isNumber(value)) {
+                        Long longValue = Long.valueOf(value);
+                        mainDeviceCategoryIds.add(longValue);
+                    }
+                });
+            }
+
             // 查询指定部门下所有子部门
             Set<Long> childDeptIds = deptService.getChildDeptIdListFromCache(deptId);
             Map<Long, DeptDO> allDeptPair = deptService.getDeptMap(childDeptIds);
@@ -535,7 +548,10 @@ public class IotRhDailyReportController {
             if (CollUtil.isNotEmpty(allRhDevices)) {
                 // 筛选出包含设备的队伍部门集合
                 allRhDevices.forEach(device -> {
-                    haveDeviceDeptIds.add(device.getDeptId());
+                    // 20260605 筛选包含主设备的队伍
+                    if (mainDeviceCategoryIds.contains(device.getAssetClass())) {
+                        haveDeviceDeptIds.add(device.getDeptId());
+                    }
                 });
             }
             if (CollUtil.isNotEmpty(allDeptPair)) {

+ 39 - 4
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotrhdailyreport/IotRhDailyReportServiceImpl.java

@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.pms.service.iotrhdailyreport;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DatePattern;
 import cn.hutool.core.date.LocalDateTimeUtil;
+import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.ObjUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.iocoder.yudao.framework.common.pojo.PageParam;
@@ -35,11 +36,11 @@ import cn.iocoder.yudao.module.pms.job.IotDeviceCarFuelVO;
 import cn.iocoder.yudao.module.pms.message.PmsMessage;
 import cn.iocoder.yudao.module.pms.util.ZHBDUtil;
 import cn.iocoder.yudao.module.supplier.enums.common.SupplierAuditStatusEnum;
-import cn.iocoder.yudao.module.system.api.dept.DeptApi;
 import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
 import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
 import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
 import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
+import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
 import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictTypeDO;
 import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO;
 import cn.iocoder.yudao.module.system.dal.dataobject.permission.UserRoleDO;
@@ -47,6 +48,7 @@ import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
 import cn.iocoder.yudao.module.system.dal.mysql.dept.DeptMapper;
 import cn.iocoder.yudao.module.system.dal.mysql.permission.UserRoleMapper;
 import cn.iocoder.yudao.module.system.service.dept.DeptService;
+import cn.iocoder.yudao.module.system.service.dict.DictDataService;
 import cn.iocoder.yudao.module.system.service.dict.DictTypeService;
 import cn.iocoder.yudao.module.system.service.permission.RoleService;
 import cn.iocoder.yudao.module.system.service.user.AdminUserService;
@@ -123,7 +125,7 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
     @Resource
     private PmsMessage pmsMessage;
     @Resource
-    private DeptApi deptApi;
+    private DictDataService dictDataService;
     @Resource
     private DeptMapper deptMapper;
 
@@ -1089,6 +1091,19 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
         // key队伍id/项目部id   value设备利用率(按小时统计)
         Map<Long, BigDecimal> hourDeviceUtilizationPair = new HashMap<>();
 
+        // 筛选瑞恒 主设备 rq_iot_rh_main_device_category
+        Set<Long> mainDeviceCategoryIds = new HashSet<>();
+        List<DictDataDO> constructionStatusDictData = dictDataService.getDictDataListByDictType("rq_iot_rh_main_device_category");
+        if (CollUtil.isNotEmpty(constructionStatusDictData)) {
+            constructionStatusDictData.forEach(data -> {
+                String value = data.getValue();
+                if (NumberUtil.isNumber(value)) {
+                    Long longValue = Long.valueOf(value);
+                    mainDeviceCategoryIds.add(longValue);
+                }
+            });
+        }
+
         // 以项目部为维度统计数据
         // 找到所有项目部与队伍的对应关系
         // 查询指定根部门下的所有子部门
@@ -1105,7 +1120,10 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
         if (CollUtil.isNotEmpty(devices)) {
             // 筛选出包含设备的队伍部门集合
             devices.forEach(device -> {
-                haveDeviceDeptIds.add(device.getDeptId());
+                // 20260605 筛选包含主设备的队伍
+                if (mainDeviceCategoryIds.contains(device.getAssetClass())) {
+                    haveDeviceDeptIds.add(device.getDeptId());
+                }
             });
         }
 
@@ -1983,6 +2001,19 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
         // key队伍id/项目部id   value设备利用率(按小时统计)
         Map<Long, BigDecimal> hourDeviceUtilizationPair = new HashMap<>();
 
+        // 筛选瑞恒 主设备 rq_iot_rh_main_device_category
+        Set<Long> mainDeviceCategoryIds = new HashSet<>();
+        List<DictDataDO> constructionStatusDictData = dictDataService.getDictDataListByDictType("rq_iot_rh_main_device_category");
+        if (CollUtil.isNotEmpty(constructionStatusDictData)) {
+            constructionStatusDictData.forEach(data -> {
+                String value = data.getValue();
+                if (NumberUtil.isNumber(value)) {
+                    Long longValue = Long.valueOf(value);
+                    mainDeviceCategoryIds.add(longValue);
+                }
+            });
+        }
+
         // 以 队伍 为维度统计数据
         // 找到所有项目部与队伍的对应关系
         // 查询指定根部门下的所有子部门
@@ -2018,7 +2049,11 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
         if (CollUtil.isNotEmpty(devices)) {
             // 筛选出包含设备的队伍部门集合
             devices.forEach(device -> {
-                haveDeviceDeptIds.add(device.getDeptId());
+                // 20260605 筛选包含主设备的队伍
+                if (mainDeviceCategoryIds.contains(device.getAssetClass())) {
+                    device.getAssetClass();
+                    haveDeviceDeptIds.add(device.getDeptId());
+                }
             });
         }
 

+ 5 - 5
yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/IotOpeationFillMapper.xml

@@ -1322,13 +1322,13 @@
         SELECT 1
         FROM rq_iot_device
         WHERE dept_id = d.dept_id
-        AND asset_class IN (157, 158, 191)
+        AND asset_class IN (157, 158)
         AND deleted = 0
         ) THEN (
         SELECT device_status
         FROM rq_iot_device
         WHERE dept_id = d.dept_id
-        AND asset_class IN (157, 158, 191)
+        AND asset_class IN (157, 158)
         AND deleted = 0
         AND device_status != 'sg'
         LIMIT 1
@@ -1352,13 +1352,13 @@
         SELECT 1
         FROM rq_iot_device
         WHERE dept_id = d.dept_id
-        AND asset_class = 112
+        AND asset_class = 308
         AND deleted = 0
         ) THEN (
         SELECT device_status
         FROM rq_iot_device
         WHERE dept_id = d.dept_id
-        AND asset_class = 112
+        AND asset_class = 308
         AND deleted = 0
         AND device_status != 'sg'
         LIMIT 1
@@ -1372,7 +1372,7 @@
         <foreach collection="teams" item="item" open="(" separator="," close=")">
             #{item.id}
         </foreach>
-        AND asset_class IN (159, 160, 122, 106, 157, 158, 191,112)
+        AND asset_class IN (159, 160, 122, 106, 157, 158, 308, 108)
         AND deleted = 0
         ) AS d
         ) AS temp