From b7dd69a4f6c63e25d7d9ff567992c9095b48919c Mon Sep 17 00:00:00 2001
From: Lius <Lius2225@163.com>
Date: 星期二, 17 六月 2025 17:56:53 +0800
Subject: [PATCH] 算法调整

---
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/MdcEquipmentStatisticalDto.java                |   16 +++++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalInfoMapper.xml   |   18 +++--
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentFaultInfoServiceImpl.java |   66 +++++++++++++++------
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentStatisticalInfoMonth.java       |   24 ++++++++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/CollectEquipmentDataMonthJob.java              |   42 ++++++++-----
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml           |    7 +
 6 files changed, 128 insertions(+), 45 deletions(-)

diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/MdcEquipmentStatisticalDto.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/MdcEquipmentStatisticalDto.java
index 62877b1..fe21267 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/MdcEquipmentStatisticalDto.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/MdcEquipmentStatisticalDto.java
@@ -37,6 +37,22 @@
      */
     private BigDecimal totalLong = new BigDecimal("0");
     /**
+     * 鏁呴殰鏃堕暱
+     */
+    private BigDecimal faultLong = new BigDecimal("0");
+    /**
+     * 鏁呴殰鐜�
+     */
+    private BigDecimal faultRate = new BigDecimal("0");
+    /**
+     * 杩愯鏃堕暱(鍘婚櫎鏁呴殰鏃堕棿)
+     */
+    private BigDecimal removeFaultRunLong = new BigDecimal("0");
+    /**
+     * 鍘婚櫎鏁呴殰鏃堕棿鍒╃敤鐜�
+     */
+    private BigDecimal removeFaultRate = new BigDecimal("0");
+    /**
      * 澶╂暟
      */
     private BigDecimal dayNum;
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentStatisticalInfoMonth.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentStatisticalInfoMonth.java
index c987011..822b2ca 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentStatisticalInfoMonth.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentStatisticalInfoMonth.java
@@ -78,6 +78,18 @@
     @ApiModelProperty(value = "鎶ヨ鏃堕暱")
     private Integer errorLong;
     /**
+     * 鏁呴殰鏃堕暱
+     */
+    @Excel(name = "鏁呴殰鏃堕暱", width = 15)
+    @ApiModelProperty(value = "鏁呴殰鏃堕暱")
+    private Integer faultLong;
+    /**
+     * 鍘婚櫎鏁呴殰鏃堕棿鐨勮繍琛屾椂闂�
+     */
+    @Excel(name = "鍘婚櫎鏁呴殰鏃堕棿鐨勮繍琛屾椂闂�", width = 15)
+    @ApiModelProperty(value = "鍘婚櫎鏁呴殰鏃堕棿鐨勮繍琛屾椂闂�")
+    private Integer removeFaultRunLong;
+    /**
      * 鍒╃敤鐜�
      */
     @Excel(name = "鍒╃敤鐜�", width = 15)
@@ -96,6 +108,18 @@
     @ApiModelProperty(value = "寮�鏈虹巼")
     private BigDecimal openRate;
     /**
+     * 鏁呴殰鐜�
+     */
+    @Excel(name = "鏁呴殰鐜�", width = 15)
+    @ApiModelProperty(value = "鏁呴殰鐜�")
+    private BigDecimal faultRate;
+    /**
+     * 鍘婚櫎鏁呴殰鏃堕棿鍒╃敤鐜�
+     */
+    @Excel(name = "鍘婚櫎鏁呴殰鏃堕棿鍒╃敤鐜�", width = 15)
+    @ApiModelProperty(value = "鍘婚櫎鏁呴殰鏃堕棿鍒╃敤鐜�")
+    private BigDecimal removeFaultRate;
+    /**
      * 鍒涘缓鏃堕棿
      */
     @Excel(name = "鍒涘缓鏃堕棿", width = 20, format = "yyyy-MM-dd HH:mm:ss")
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/CollectEquipmentDataMonthJob.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/CollectEquipmentDataMonthJob.java
index 456f302..5617bc7 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/CollectEquipmentDataMonthJob.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/CollectEquipmentDataMonthJob.java
@@ -100,14 +100,20 @@
                     MdcEquipmentStatisticalInfoMonth mdcEquipmentStatisticalInfoMonth = new MdcEquipmentStatisticalInfoMonth();
                     mdcEquipmentStatisticalInfoMonth.setEquipmentId(mdcEquipment.getEquipmentId());
                     mdcEquipmentStatisticalInfoMonth.setTheMonth(date);
-                    mdcEquipmentStatisticalInfoMonth.setCloseLong(mdcEquipmentStatisticalDto.getCloseLong().intValue());
-                    mdcEquipmentStatisticalInfoMonth.setErrorLong(mdcEquipmentStatisticalDto.getErrorLong().intValue());
-                    mdcEquipmentStatisticalInfoMonth.setOpenLong(mdcEquipmentStatisticalDto.getOpenLong().intValue());
-                    mdcEquipmentStatisticalInfoMonth.setProcessLong(mdcEquipmentStatisticalDto.getProcessLong().intValue());
-                    mdcEquipmentStatisticalInfoMonth.setWaitLong(mdcEquipmentStatisticalDto.getWaitLong().intValue());
-                    mdcEquipmentStatisticalInfoMonth.setOpenRate(mdcEquipmentStatisticalDto.getOpenLong().divide((new BigDecimal("86400").multiply(mdcEquipmentStatisticalDto.getDayNum())), 4, RoundingMode.HALF_UP));
-                    mdcEquipmentStatisticalInfoMonth.setStartRate(mdcEquipmentStatisticalDto.getOpenLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentStatisticalDto.getProcessLong().divide(mdcEquipmentStatisticalDto.getOpenLong(), 4, RoundingMode.HALF_UP) : BigDecimal.ZERO);
-                    mdcEquipmentStatisticalInfoMonth.setUtilizationRate(mdcEquipmentStatisticalDto.getProcessLong().divide((new BigDecimal("86400").multiply(mdcEquipmentStatisticalDto.getDayNum())), 4, RoundingMode.HALF_UP));
+                    if (mdcEquipmentStatisticalDto != null) {
+                        mdcEquipmentStatisticalInfoMonth.setCloseLong(mdcEquipmentStatisticalDto.getCloseLong().intValue());
+                        mdcEquipmentStatisticalInfoMonth.setErrorLong(mdcEquipmentStatisticalDto.getErrorLong().intValue());
+                        mdcEquipmentStatisticalInfoMonth.setOpenLong(mdcEquipmentStatisticalDto.getOpenLong().intValue());
+                        mdcEquipmentStatisticalInfoMonth.setProcessLong(mdcEquipmentStatisticalDto.getProcessLong().intValue());
+                        mdcEquipmentStatisticalInfoMonth.setWaitLong(mdcEquipmentStatisticalDto.getWaitLong().intValue());
+                        mdcEquipmentStatisticalInfoMonth.setOpenRate(mdcEquipmentStatisticalDto.getOpenLong().divide((new BigDecimal("86400").multiply(mdcEquipmentStatisticalDto.getDayNum())), 4, RoundingMode.HALF_UP));
+                        mdcEquipmentStatisticalInfoMonth.setStartRate(mdcEquipmentStatisticalDto.getOpenLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentStatisticalDto.getProcessLong().divide(mdcEquipmentStatisticalDto.getOpenLong(), 4, RoundingMode.HALF_UP) : BigDecimal.ZERO);
+                        mdcEquipmentStatisticalInfoMonth.setUtilizationRate(mdcEquipmentStatisticalDto.getProcessLong().divide((new BigDecimal("86400").multiply(mdcEquipmentStatisticalDto.getDayNum())), 4, RoundingMode.HALF_UP));
+                        mdcEquipmentStatisticalInfoMonth.setFaultLong(mdcEquipmentStatisticalDto.getFaultLong().intValue());
+                        mdcEquipmentStatisticalInfoMonth.setFaultRate(mdcEquipmentStatisticalDto.getFaultRate());
+                        mdcEquipmentStatisticalInfoMonth.setRemoveFaultRate(mdcEquipmentStatisticalDto.getRemoveFaultRate());
+                        mdcEquipmentStatisticalInfoMonth.setRemoveFaultRunLong(mdcEquipmentStatisticalDto.getRemoveFaultRunLong().intValue());
+                    }
                     mdcEquipmentStatisticalInfoMonthList.add(mdcEquipmentStatisticalInfoMonth);
                     // step.3 姹囨�荤彮娆″埄鐢ㄧ巼鏁版嵁
                     MdcEquipmentStatisticalDto mdcEquipmentShiftStatisticalDto = mdcEquipmentStatisticalShiftInfoService.findByEquipmentAndMonth(mdcEquipment.getEquipmentId(), date);
@@ -115,15 +121,17 @@
                     mdcEquipmentShiftInfoMonth.setEquipmentId(mdcEquipment.getEquipmentId());
                     mdcEquipmentShiftInfoMonth.setTheMonth(date);
                     mdcEquipmentShiftInfoMonth.setShiftType(CommonConstant.SHIFT_TYPE_1);
-                    mdcEquipmentShiftInfoMonth.setCloseLong(mdcEquipmentShiftStatisticalDto.getCloseLong().intValue());
-                    mdcEquipmentShiftInfoMonth.setTotalLong(mdcEquipmentShiftStatisticalDto.getTotalLong().intValue());
-                    mdcEquipmentShiftInfoMonth.setOpenLong(mdcEquipmentShiftStatisticalDto.getOpenLong().intValue());
-                    mdcEquipmentShiftInfoMonth.setErrorLong(mdcEquipmentShiftStatisticalDto.getErrorLong().intValue());
-                    mdcEquipmentShiftInfoMonth.setWaitLong(mdcEquipmentShiftStatisticalDto.getWaitLong().intValue());
-                    mdcEquipmentShiftInfoMonth.setProcessLong(mdcEquipmentShiftStatisticalDto.getProcessLong().intValue());
-                    mdcEquipmentShiftInfoMonth.setUtilizationRate(mdcEquipmentShiftStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getProcessLong().divide(mdcEquipmentShiftStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP) : BigDecimal.ZERO);
-                    mdcEquipmentShiftInfoMonth.setStartRate(mdcEquipmentShiftStatisticalDto.getOpenLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getProcessLong().divide(mdcEquipmentShiftStatisticalDto.getOpenLong(), 4, RoundingMode.HALF_UP) : BigDecimal.ZERO);
-                    mdcEquipmentShiftInfoMonth.setOpenRate(mdcEquipmentShiftStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getOpenLong().divide(mdcEquipmentShiftStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP) : BigDecimal.ZERO);
+                    if (mdcEquipmentShiftStatisticalDto != null) {
+                        mdcEquipmentShiftInfoMonth.setCloseLong(mdcEquipmentShiftStatisticalDto.getCloseLong().intValue());
+                        mdcEquipmentShiftInfoMonth.setTotalLong(mdcEquipmentShiftStatisticalDto.getTotalLong().intValue());
+                        mdcEquipmentShiftInfoMonth.setOpenLong(mdcEquipmentShiftStatisticalDto.getOpenLong().intValue());
+                        mdcEquipmentShiftInfoMonth.setErrorLong(mdcEquipmentShiftStatisticalDto.getErrorLong().intValue());
+                        mdcEquipmentShiftInfoMonth.setWaitLong(mdcEquipmentShiftStatisticalDto.getWaitLong().intValue());
+                        mdcEquipmentShiftInfoMonth.setProcessLong(mdcEquipmentShiftStatisticalDto.getProcessLong().intValue());
+                        mdcEquipmentShiftInfoMonth.setUtilizationRate(mdcEquipmentShiftStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getProcessLong().divide(mdcEquipmentShiftStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP) : BigDecimal.ZERO);
+                        mdcEquipmentShiftInfoMonth.setStartRate(mdcEquipmentShiftStatisticalDto.getOpenLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getProcessLong().divide(mdcEquipmentShiftStatisticalDto.getOpenLong(), 4, RoundingMode.HALF_UP) : BigDecimal.ZERO);
+                        mdcEquipmentShiftInfoMonth.setOpenRate(mdcEquipmentShiftStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getOpenLong().divide(mdcEquipmentShiftStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP) : BigDecimal.ZERO);
+                    }
                     mdcEquipmentStatisticalShiftInfoMonthList.add(mdcEquipmentShiftInfoMonth);
                     // step.4 姹囨�诲悇鐝鍒╃敤鐜囨暟鎹�
                     List<MdcEquipmentStatisticalDto> essdList = mdcEquipmentStatisticalShiftInfoService.findShiftByEquipmentAndMonth(mdcEquipment.getEquipmentId(), date);
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml
index b5d68c6..d7c9488 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml
@@ -195,7 +195,8 @@
         SELECT
             t3.equipment_name,
             t1.utilization_rate AS utilizationRate,
-            t2.utilization_rate AS shiftUtilizationRate
+            t2.utilization_rate AS shiftUtilizationRate,
+            t1.remove_fault_rate AS amendUtilizationRate
         FROM
             mdc_equipment_statistical_info_month t1
                 LEFT JOIN mdc_equipment_statistical_shift_info_month t2 ON t1.the_month = t2.the_month AND t2.shift_type = 1
@@ -215,7 +216,8 @@
         SELECT
             t3.team_code AS teamCode,
             t1.utilization_rate AS utilizationRate,
-            t2.utilization_rate AS shiftUtilizationRate
+            t2.utilization_rate AS shiftUtilizationRate,
+            t1.remove_fault_rate AS amendUtilizationRate
         FROM
             mdc_equipment_statistical_info_month t1
                 LEFT JOIN mdc_equipment_statistical_shift_info_month t2 ON t1.the_month = t2.the_month AND t2.shift_type = 1
@@ -234,6 +236,7 @@
             t1.the_month AS theMonth,
             AVG ( t1.utilization_rate ) AS utilizationRate,
             AVG ( t2.utilization_rate ) AS shiftUtilizationRate,
+            AVG ( t1.remove_fault_rate ) AS amendUtilizationRate,
             SUM ( t1.process_long ) AS processLong
         FROM
             mdc_equipment_statistical_info_month t1
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalInfoMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalInfoMapper.xml
index e542769..62ae98e 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalInfoMapper.xml
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalInfoMapper.xml
@@ -15,16 +15,20 @@
 
     <select id="findByEquipmentAndMonth" resultType="org.jeecg.modules.mdc.dto.MdcEquipmentStatisticalDto">
         SELECT
-            SUM(open_long) openLong,
-            SUM(close_long) closeLong,
-            SUM(wait_long) waitLong,
-            SUM(process_long) processLong,
-            SUM(error_long) errorLong,
+            SUM ( t1.open_long ) openLong,
+            SUM ( t1.close_long ) closeLong,
+            SUM ( t1.wait_long ) waitLong,
+            SUM ( t1.process_long ) processLong,
+            SUM ( t1.error_long ) errorLong,
+            SUM ( t2.fault_long ) faultLong,
+            AVG ( t2.fault_rate ) faultRate,
+            SUM ( t2.remove_fault_run_long ) removeFaultRunLong,
+            AVG ( t2.remove_fault_rate ) removeFaultRate,
             COUNT(*) dayNum
         FROM
-            mdc_equipment_statistical_info
+            mdc_equipment_statistical_info t1 LEFT JOIN mdc_equipment_fault_info t2 ON t1.equipment_id = t2.equipment_id AND t1.the_date = t2.the_date
         WHERE
-            equipment_id = #{equipmentId} AND the_date LIKE CONCAT(#{date}, '%')
+            t1.equipment_id = #{equipmentId} AND t1.the_date LIKE CONCAT(#{date}, '%')
     </select>
 
     <select id="findByEquIdsAndMonth" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo">
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentFaultInfoServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentFaultInfoServiceImpl.java
index df0f7c6..3a35ec8 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentFaultInfoServiceImpl.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentFaultInfoServiceImpl.java
@@ -86,18 +86,18 @@
         if (equFaultRecordList != null && !equFaultRecordList.isEmpty()) {
             // 淇暣鏃堕棿
             Map<String, List<EquFaultRecord>> equFaultRecordMap = equFaultRecordList.stream().collect(Collectors.groupingBy(EquFaultRecord::getEquipmentId));
-            equFaultRecordMap.forEach((key, value) -> {
-                if (map.containsKey(key)) {
-                    MdcEquipmentFaultInfo equFaultRecords = map.get(key);
+            map.forEach((key, value1) -> {
+                MdcEquipmentFaultInfo equFaultRecords = value1;
+                if (equFaultRecordMap.containsKey(key)) {
+                    List<EquFaultRecord> value = equFaultRecordMap.get(key);
                     long faultLong = calculateTotalFaultDuration(value, start, end);
                     equFaultRecords.setFaultLong((int) faultLong);
                     if (faultLong != 0) {
-                        equFaultRecords.setFaultRate(new BigDecimal(faultLong).divide(new BigDecimal("86400"), 2, RoundingMode.HALF_UP));
+                        equFaultRecords.setFaultRate(new BigDecimal(faultLong).divide(new BigDecimal("864"), 2, RoundingMode.HALF_UP));
                     }
-
                     // 璁$畻鍘婚櫎鏁呴殰鏃堕暱鐨勫姞宸ユ椂闂�
                     // step.1 鏌ヨ鍔犲伐鏃堕棿
-                    List<MdcEquipmentRunningSection> mdcEquipmentRunningSections = mdcEquipmentRunningSectionService.selectRunningData(key, start, end);
+                    List<MdcEquipmentRunningSection> mdcEquipmentRunningSections = mdcEquipmentRunningSectionService.listEquipmentRunningSectionRun(key, start.getTime(), end.getTime());
                     if (mdcEquipmentRunningSections != null && !mdcEquipmentRunningSections.isEmpty()) {
                         // 鏃堕棿淇
                         if (mdcEquipmentRunningSections.get(0).getStartTime().before(start)) {
@@ -112,17 +112,49 @@
                                 mdcEquipmentRunningSections.get(0).setEndTime(end);
                             }
                         }
-                        // step.2 璁$畻鍘婚櫎鏁呴殰鏃堕暱鐨勫姞宸ユ椂闂�
-                        long processingTime = calculateProcessingTimeWithoutFaults(mdcEquipmentRunningSections, value, start, end);
-                        equFaultRecords.setRemoveFaultRunLong((int) processingTime);
-                        if (faultLong != 0) {
+                        List<MdcEquipmentRunningSection> collect = mdcEquipmentRunningSections.stream().filter(mdcEquipmentRunningSection -> mdcEquipmentRunningSection.getStatus() == 3).collect(Collectors.toList());
+                        if (!collect.isEmpty()) {
+                            // step.2 璁$畻鍘婚櫎鏁呴殰鏃堕暱鐨勫姞宸ユ椂闂�
+                            long processingTime = calculateProcessingTimeWithoutFaults(collect, value, start, end);
+                            equFaultRecords.setRemoveFaultRunLong((int) processingTime);
+                            if (faultLong != 0 && faultLong != 86400) {
+                                // 璁$畻鍘婚櫎鏁呴殰鏃堕暱鐨勫埄鐢ㄧ巼
+                                BigDecimal removeFaultRate = new BigDecimal(processingTime).divide(new BigDecimal("864").subtract(new BigDecimal(faultLong)), 2, RoundingMode.HALF_UP);
+                                equFaultRecords.setRemoveFaultRate(removeFaultRate);
+                            }
+                        }
+                    }
+                } else {
+                    List<MdcEquipmentRunningSection> mdcEquipmentRunningSections = mdcEquipmentRunningSectionService.listEquipmentRunningSectionRun(key, start.getTime(), end.getTime());
+                    if (mdcEquipmentRunningSections != null && !mdcEquipmentRunningSections.isEmpty()) {
+                        // 鏃堕棿淇
+                        if (mdcEquipmentRunningSections.get(0).getStartTime().before(start)) {
+                            mdcEquipmentRunningSections.get(0).setStartTime(start);
+                        }
+                        if (mdcEquipmentRunningSections.size() > 1) {
+                            if (mdcEquipmentRunningSections.get(mdcEquipmentRunningSections.size() - 1).getEndTime().after(end)) {
+                                mdcEquipmentRunningSections.get(mdcEquipmentRunningSections.size() - 1).setEndTime(end);
+                            }
+                        } else {
+                            if (mdcEquipmentRunningSections.get(0).getEndTime().after(end)) {
+                                mdcEquipmentRunningSections.get(0).setEndTime(end);
+                            }
+                        }
+                        List<MdcEquipmentRunningSection> collect = mdcEquipmentRunningSections.stream().filter(mdcEquipmentRunningSection -> mdcEquipmentRunningSection.getStatus() == 3).collect(Collectors.toList());
+
+                        if (!collect.isEmpty()) {
+                            long totalProcessingTime = 0;
+                            for (MdcEquipmentRunningSection mdcEquipmentRunningSection : collect) {
+                                totalProcessingTime += ChronoUnit.SECONDS.between(DateUtils.convertToLocalDateTime(mdcEquipmentRunningSection.getStartTime()), DateUtils.convertToLocalDateTime(mdcEquipmentRunningSection.getEndTime()));
+                            }
+                            equFaultRecords.setRemoveFaultRunLong((int) totalProcessingTime);
                             // 璁$畻鍘婚櫎鏁呴殰鏃堕暱鐨勫埄鐢ㄧ巼
-                            BigDecimal removeFaultRate = new BigDecimal(processingTime).divide(new BigDecimal("86400").subtract(new BigDecimal(faultLong)), 2, RoundingMode.HALF_UP);
+                            BigDecimal removeFaultRate = new BigDecimal(totalProcessingTime).divide(new BigDecimal("864"), 2, RoundingMode.HALF_UP);
                             equFaultRecords.setRemoveFaultRate(removeFaultRate);
                         }
                     }
-                    map.put(key, equFaultRecords);
                 }
+                map.put(key, equFaultRecords);
             });
         }
         if (!map.isEmpty()) {
@@ -215,13 +247,9 @@
         LocalDateTime start = DateUtils.convertToLocalDateTime(startTime);
         LocalDateTime end = DateUtils.convertToLocalDateTime(endTime);
 
-        // 灏嗘晠闅滆褰曡浆鎹负鏃堕棿鍖洪棿骞跺悎骞堕噸鍙犻儴鍒�
-//        List<TimeInterval> faultIntervals = faultRecords.stream()
-//                .map(record -> new TimeInterval(
-//                        convertToLocalDateTime(record.getStartTime()),
-//                        convertToLocalDateTime(record.getEndTime())))
-//                .collect(Collectors.toList());
-        List<TimeInterval> mergedFaultIntervals = mergeIntervals(faultRecords);
+        // 淇璁板綍鏃堕棿
+        List<EquFaultRecord> correctedRecords = correctRecordTimes(faultRecords, start, end);
+        List<TimeInterval> mergedFaultIntervals = mergeIntervals(correctedRecords);
 
         long totalProcessingTime = 0;
 

--
Gitblit v1.9.3