Эх сурвалжийг харах

Merge remote-tracking branch 'origin/master'

lipenghui 14 цаг өмнө
parent
commit
655d16f018

+ 18 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotopeationfill/IotOpeationFillController.java

@@ -400,6 +400,24 @@ public class IotOpeationFillController {
             return;
         }
 
+        // 2. 使用Stream.allMatch()判断所有元素是否满足两个条件(同时满足)
+        boolean allMatch = allFillData.stream()
+                .allMatch(vo -> {
+                    // 条件1:isSum == 0(处理包装类型null的情况,避免空指针)
+                    boolean isSumEquals0 = Objects.nonNull(vo.getIsSum()) && vo.getIsSum().equals(0);
+                    // 条件2:deviceCode 是空串(包含null和""两种情况)
+                    // 方式A:使用StringUtils.isEmpty(推荐,简洁)
+                    boolean deviceCodeIsEmpty = StringUtils.isEmpty(vo.getDeviceCode());
+                    // 方式B:手动双重判断(不依赖第三方工具)
+                    // boolean deviceCodeIsEmpty = vo.getDeviceCode() == null || vo.getDeviceCode().trim().isEmpty();
+
+                    // 两个条件必须同时满足(逻辑与 &&)
+                    return isSumEquals0 && deviceCodeIsEmpty;
+                });
+        if(allMatch){
+            return;
+        }
+
         // 1. 合并过滤逻辑:一次性过滤出累计数据,按sumId分组(避免两次流式过滤)
         Map<Long, List<IotOpeationFillSaveReqVO>> sumDataGroup = allFillData.stream()
                 .filter(fill -> 1 == fill.getIsSum())

+ 3 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrhdailyreport/vo/IotRhDailyReportPageReqVO.java

@@ -136,4 +136,7 @@ public class IotRhDailyReportPageReqVO extends PageParam {
 
     @Schema(description = "年", example = "2025")
     private String year;
+
+    @Schema(description = "非生产时效", example = "Y")
+    private String nonProductFlag;
 }

+ 3 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrydailyreport/vo/IotRyDailyReportPageReqVO.java

@@ -158,4 +158,7 @@ public class IotRyDailyReportPageReqVO extends PageParam {
 
     @Schema(description = "施工状态集合", example = "[dt,zx]")
     private Collection<String> statuses;
+
+    @Schema(description = "非生产时效查询标识", example = "Y")
+    private String nonProductFlag;
 }

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

@@ -110,6 +110,11 @@ public class IotReportOrderController {
                 }
             }
         }
+
+        List<AllOrderResp> dailyReports = iotRhDailyReportMapper.selectStatusNumber(pageReqVO);
+        List<AllOrderResp> ryDailyReports = iotRyDailyReportMapper.selectStatusNumber(pageReqVO);
+        List<AllOrderResp> rdDailyReports = iotRdDailyReportMapper.selectStatusNumber(pageReqVO);
+
         Long hbWxNum = 0L;
         Long hbXjNum = 0L;
         Long hbYxNum = 0L;
@@ -134,9 +139,6 @@ public class IotReportOrderController {
         // 同比 去年同期相同统计数据对比 无数据
         tbByNum = tbByNum == null ? 0l : tbByNum;
 
-        List<AllOrderResp> dailyReports = iotRhDailyReportMapper.selectStatusNumber(pageReqVO);
-        List<AllOrderResp> ryDailyReports = iotRyDailyReportMapper.selectStatusNumber(pageReqVO);
-        List<AllOrderResp> rdDailyReports = iotRdDailyReportMapper.selectStatusNumber(pageReqVO);
         List<AllOrderResp> reports = new ArrayList<>();
         AtomicReference<Long> noStatus = new AtomicReference<>(0l);
         AtomicReference<Long> yesStatus = new AtomicReference<>(0l);

+ 25 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotrydailyreport/IotRyDailyReportMapper.java

@@ -149,14 +149,37 @@ public interface IotRyDailyReportMapper extends BaseMapperX<IotRyDailyReportDO>
 
         // 单独处理 projectClassification 条件
         if ("1".equals(projectClassification)) {
-            // 当值为 "1" 时,查询 project_classification 为 "1" 或空字符串的记录
+            // 当值为 "1" 时,查询 project_classification 为 "1" 或空字符串的记录 钻井
             queryWrapper.and(wrapper -> wrapper
                     .eq(IotRyDailyReportDO::getProjectClassification, "1")
                     .or().eq(IotRyDailyReportDO::getProjectClassification, "")
             );
+            // 查询非生产时效
+            if ("Y".equals(reqVO.getNonProductFlag())) {
+                queryWrapper.and(wrapper -> wrapper
+                        .gt(IotRyDailyReportDO::getAccidentTime, BigDecimal.ZERO)
+                        .or()
+                        .gt(IotRyDailyReportDO::getRepairTime, BigDecimal.ZERO)
+                        .or()
+                        .gt(IotRyDailyReportDO::getSelfStopTime, BigDecimal.ZERO)
+                        .or()
+                        .gt(IotRyDailyReportDO::getComplexityTime, BigDecimal.ZERO)
+                        .or()
+                        .gt(IotRyDailyReportDO::getRelocationTime, BigDecimal.ZERO)
+                        .or()
+                        .gt(IotRyDailyReportDO::getRectificationTime, BigDecimal.ZERO)
+                        .or()
+                        .gt(IotRyDailyReportDO::getWaitingStopTime, BigDecimal.ZERO)
+                        .or()
+                        .gt(IotRyDailyReportDO::getWinterBreakTime, BigDecimal.ZERO)
+                );
+            }
         } else {
-            // 其他情况:有值则精确匹配,无值则不添加条件(保持原逻辑)
+            // 其他情况:有值则精确匹配,无值则不添加条件(保持原逻辑) 修井
             queryWrapper.eqIfPresent(IotRyDailyReportDO::getProjectClassification, projectClassification);
+            if ("Y".equals(reqVO.getNonProductFlag())) {
+                queryWrapper.and(wrapper -> wrapper.gt(IotRyDailyReportDO::getNonProductionTime, BigDecimal.ZERO));
+            }
         }
 
         return selectPage(reqVO, queryWrapper);

+ 7 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/job/IotOperationPlanJob.java

@@ -327,9 +327,14 @@ public class IotOperationPlanJob implements JobHandler {
         //筛选出所有小队
         List<DeptDO> teams = depts.stream().filter(e->e.getType().equals("3")).collect(Collectors.toList());
 
+
         //查询增压机状态为非施工的小队
         List<IotDeviceDO> teamStatusL = iotOpeationFillMapper.selectDevStatusBatch(teams);
 
+        System.out.println("-------开始打印RH非正常工单-----");
+        teams.forEach(System.out::println);
+        System.out.println("-------结束打印RH非正常工单-----");
+
         if(teamStatusL.size()>0){
             for (IotDeviceDO vir:teamStatusL) {
                 IotRhDailyReportSaveReqVO saveReqVO = new IotRhDailyReportSaveReqVO();
@@ -385,7 +390,7 @@ public class IotOperationPlanJob implements JobHandler {
             //插入日报设备
             iotOpeationFillMapper.insertFill(devList);
 
-            //2、瑞恒无指定队伍全部队伍插入日报设备
+            /*//2、瑞恒无指定队伍全部队伍插入日报设备
             //筛选正常工单部门id
             List<Long> deptIdList = orderList1.stream().map(IotOpeationFillOrderDO::getDeptId).collect(Collectors.toList());
             //查询瑞恒所有责任人数据
@@ -438,7 +443,7 @@ public class IotOperationPlanJob implements JobHandler {
                     saveReqVO.setCreator(String.valueOf(vir.getUserId()));
                     iotRhDailyReportService.createIotRhDailyReport(saveReqVO);
                 }
-            }
+            }*/
         }
     }
 

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

@@ -515,16 +515,24 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
         return capacity.get();
     }
 
-    @Override
+    /* @Override
     public Map<Long, BigDecimal> queryCapacities(List<Long> deptIds) {
         Map<Long, BigDecimal> capacityPair = new HashMap<>();
         // 找到当前小队下的 电驱增压机 分类下设备的产能 计算 运行时效
         DictTypeDO dictType = dictTypeService.getDictType("rq_iot_charger_device_category");
         if (ObjUtil.isNotEmpty(dictType)) {
             if (StrUtil.isNotBlank(dictType.getRemark())) {
+                // 可能统计多个设备的产能 remark 是逗号分隔的数据
+                List<Long> deviceCategoryIdLongs = Arrays.stream(dictType.getRemark().split(","))
+                        .map(String::trim)
+                        .filter(s -> s.matches("\\d+")) // 过滤出纯数字字符串
+                        .map(Long::valueOf)
+                        .collect(Collectors.toList());
+                // 查询队伍下维护了产能的已知类别的设备 累加所有产能
                 IotDevicePageReqVO capacityReqVO = new IotDevicePageReqVO();
                 capacityReqVO.setDeptIds(deptIds);
-                capacityReqVO.setAssetClass(Long.valueOf(dictType.getRemark()));
+                // capacityReqVO.setAssetClass(Long.valueOf(dictType.getRemark()));
+                capacityReqVO.setAssetClasses(deviceCategoryIdLongs);
                 List<IotDeviceDO> capacityDevices = iotDeviceMapper.selectList(capacityReqVO);
                 if (CollUtil.isNotEmpty(capacityDevices)) {
                     // 解析每个设备的 扩展属性 找出 已经设置 了产能的设备并提取值
@@ -544,13 +552,99 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
                                 });
                             }
                         }
+                        // 如果相同的部门下有多个设备维护过产能 累加所有设备的产能
+
                     });
                 }
             }
         }
+        return capacityPair;
+    } */
+
+    /**
+     * 查询队伍下设备产能
+     * @param deptIds
+     * @return
+     */
+    @Override
+    public Map<Long, BigDecimal> queryCapacities(List<Long> deptIds) {
+        Map<Long, BigDecimal> capacityPair = new HashMap<>();
+
+        // 找到当前小队下的 电驱增压机 分类下设备的产能 计算 运行时效
+        DictTypeDO dictType = dictTypeService.getDictType("rq_iot_charger_device_category");
+        if (ObjUtil.isNotEmpty(dictType) && StrUtil.isNotBlank(dictType.getRemark())) {
+            // 可能统计多个设备的产能 remark 是逗号分隔的数据
+            List<Long> deviceCategoryIdLongs = Arrays.stream(dictType.getRemark().split(","))
+                    .map(String::trim)
+                    .filter(s -> s.matches("\\d+")) // 过滤出纯数字字符串
+                    .map(Long::valueOf)
+                    .collect(Collectors.toList());
+
+            // 查询队伍下维护了产能的已知类别的设备
+            IotDevicePageReqVO capacityReqVO = new IotDevicePageReqVO();
+            capacityReqVO.setDeptIds(deptIds);
+            capacityReqVO.setAssetClasses(deviceCategoryIdLongs);
+
+            List<IotDeviceDO> capacityDevices = iotDeviceMapper.selectList(capacityReqVO);
+
+            if (CollUtil.isNotEmpty(capacityDevices)) {
+                // 使用Map按部门分组累加产能
+                Map<Long, List<IotDeviceDO>> devicesByDept = capacityDevices.stream()
+                        .collect(Collectors.groupingBy(IotDeviceDO::getDeptId));
+
+                // 遍历每个部门的设备列表
+                for (Map.Entry<Long, List<IotDeviceDO>> entry : devicesByDept.entrySet()) {
+                    Long deptId = entry.getKey();
+                    List<IotDeviceDO> deptDevices = entry.getValue();
+
+                    // 累加当前部门下所有设备的产能
+                    BigDecimal deptTotalCapacity = BigDecimal.ZERO;
+
+                    for (IotDeviceDO device : deptDevices) {
+                        BigDecimal deviceCapacity = extractCapacityFromDevice(device);
+                        deptTotalCapacity = deptTotalCapacity.add(deviceCapacity);
+                    }
+
+                    // 将部门总产能放入结果Map
+                    capacityPair.put(deptId, deptTotalCapacity);
+                }
+            }
+        }
+
         return capacityPair;
     }
 
+    /**
+     * 从设备中提取产能值
+     */
+    private BigDecimal extractCapacityFromDevice(IotDeviceDO device) {
+        if (StrUtil.isBlank(device.getTemplateJson())) {
+            return BigDecimal.ZERO;
+        }
+
+        try {
+            Gson gson = new Gson();
+            Type listType = new TypeToken<List<IotDeviceProperty>>(){}.getType();
+            List<IotDeviceProperty> deviceProperties = gson.fromJson(device.getTemplateJson(), listType);
+
+            if (CollUtil.isEmpty(deviceProperties)) {
+                return BigDecimal.ZERO;
+            }
+
+            // 查找产能属性并返回其值
+            return deviceProperties.stream()
+                    .filter(property -> "产能".equals(property.getName()))
+                    .filter(property -> StrUtil.isNotBlank(property.getValue()))
+                    .findFirst() // 假设每个设备只有一个产能属性,如果有多个可以改为求和
+                    .map(property -> new BigDecimal(property.getValue()))
+                    .orElse(BigDecimal.ZERO);
+
+        } catch (Exception e) {
+            // 解析JSON失败时返回0
+            System.out.println("{} 解析设备模板JSON失败,设备ID: {}" + e.getMessage());
+            return BigDecimal.ZERO;
+        }
+    }
 
     @Override
     public PageResult<IotRhDailyReportDO> dailyReportSummary(IotRhDailyReportPageReqVO pageReqVO) {

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

@@ -661,6 +661,7 @@
         on
         b.dept_id = c.id
         where b.id is not null
+        and c.type = '3'
         <if test="deviceIds != null and !deviceIds.isEmpty()">
             and c.id  in
             <foreach collection="deviceIds" item="id" open="(" separator="," close=")">

+ 3 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/iotprojecttask/IotRhDailyReportMapper.xml

@@ -180,6 +180,9 @@
                 #{key}
             </foreach>
         </if>
+        <if test='reqVO.nonProductFlag != null and reqVO.nonProductFlag == "Y"'>
+            AND rdr.non_production_time &gt; 0
+        </if>
         <if test="reqVO.createTime != null and reqVO.createTime.length > 0">
             <!-- 处理“开始时间”(数组第1位,如 createTime[0] = 2024-01-01 00:00:00) -->
             <if test="reqVO.createTime[0] != null">