From 80e505b03b3be711aa49662ba2ce35b4fcf516e4 Mon Sep 17 00:00:00 2001
From: Lius <Lius2225@163.com>
Date: 星期二, 21 十一月 2023 15:19:27 +0800
Subject: [PATCH] OEE设备综合效率算法调整

---
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentOvertimeServiceImpl.java             |    5 
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcPlanCloseServiceImpl.java                     |   28 +++++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDeviceCalendarServiceImpl.java                |   10 -
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentOvertimeService.java                     |    3 
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentOvertimeMapper.java                        |    2 
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalShiftInfoServiceImpl.java |    4 
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcDeviceCalendarService.java                        |    6 
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDeviceCalendarMapper.xml                        |   12 +-
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcOverallEquipmentEfficiencyMapper.xml            |   11 -
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentOvertimeMapper.xml                     |    1 
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentStatisticalShiftInfoService.java         |    3 
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcDeviceCalendarMapper.java                           |    4 
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcOverallEquipmentEfficiency.java                     |    6 
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalShiftInfoMapper.xml         |    1 
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcPlanCloseService.java                             |    3 
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcOverallEquipmentEfficiencyServiceImpl.java    |  185 ++++++++++++++++++------------------
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/constant/MdcConstant.java                                     |    6 +
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentStatisticalShiftInfoMapper.java            |    2 
 18 files changed, 154 insertions(+), 138 deletions(-)

diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/constant/MdcConstant.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/constant/MdcConstant.java
index 231bbd5..d727367 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/constant/MdcConstant.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/constant/MdcConstant.java
@@ -51,4 +51,10 @@
      */
     public static final String OTHER_REST = "浼戞伅鐢ㄩ,棰勯槻鎬х淮淇�";
 
+    public static final String DAY = "澶�";
+
+    public static final String WEEK = "鍛�";
+
+    public static final String MONTH = "鏈�";
+
 }
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcOverallEquipmentEfficiency.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcOverallEquipmentEfficiency.java
index 3f82318..0736092 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcOverallEquipmentEfficiency.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcOverallEquipmentEfficiency.java
@@ -50,10 +50,10 @@
     @ApiModelProperty(value = "鏈夋晥鏃ユ湡")
     private String validDate;
     /**
-     * 鐝id
+     * 鐝
      */
-    @ApiModelProperty(value = "鐝id")
-    private String shiftSubId;
+    @ApiModelProperty(value = "鐝")
+    private String shift;
     /**
      * 姣忕彮灏忔椂
      */
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcDeviceCalendarMapper.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcDeviceCalendarMapper.java
index 92246e7..a427f8c 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcDeviceCalendarMapper.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcDeviceCalendarMapper.java
@@ -23,9 +23,9 @@
 
     List<MdcDeviceCalendarVo> findAcquiesceShift();
 
-    List<String> computeActualWorkDayCount(@Param("shiftSubId") String shiftSubId, @Param("equipmentId") String equipmentId, @Param("validDate") String validDate);
+    List<String> computeActualWorkDayCount(@Param("equipmentId") String equipmentId, @Param("validDate") String validDate);
 
     List<String> findShiftSort(@Param("equipmentId") String equipmentId, @Param("validDate") String validDate);
 
-    Integer computeShiftTimeCount(@Param("shiftSubId") String shiftSubId, @Param("equipmentId") String equipmentId, @Param("validDate") String validDate);
+    Integer computeShiftTimeCount(@Param("equipmentId") String equipmentId, @Param("validDate") String validDate);
 }
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentOvertimeMapper.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentOvertimeMapper.java
index 321ef29..ae71368 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentOvertimeMapper.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentOvertimeMapper.java
@@ -40,5 +40,5 @@
      * @param validDate
      * @return
      */
-    List<MdcEquipmentOvertime> computeOvertime(@Param("shiftSubId") String shiftSubId, @Param("equipmentId") String equipmentId, @Param("validDate") String validDate);
+    List<MdcEquipmentOvertime> computeOvertime(@Param("equipmentId") String equipmentId, @Param("validDate") String validDate);
 }
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentStatisticalShiftInfoMapper.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentStatisticalShiftInfoMapper.java
index 2723cde..2bdddbe 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentStatisticalShiftInfoMapper.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentStatisticalShiftInfoMapper.java
@@ -20,5 +20,5 @@
      */
     MdcEquipmentStatisticalShiftInfo getMaxStaticsData(@Param("equipmentId") String equipmentid);
 
-    BigDecimal findSpindleRunDuration(@Param("equipmentId") String equipmentId, @Param("validDate") String validDate, @Param("shiftSubId") String shiftSubId);
+    BigDecimal findSpindleRunDuration(@Param("equipmentId") String equipmentId, @Param("validDate") String validDate);
 }
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDeviceCalendarMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDeviceCalendarMapper.xml
index 6131c89..b2af396 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDeviceCalendarMapper.xml
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDeviceCalendarMapper.xml
@@ -93,18 +93,17 @@
         WHERE
             effective_date LIKE CONCAT(#{ validDate }, '%')
             AND equipment_id = #{ equipmentId }
-            AND shift_sub_id = #{ shiftSubId }
     </select>
 
     <!--鏌ヨ鐝鍒嗙被-->
     <select id="findShiftSort" resultType="java.lang.String">
-        SELECT
-            DISTINCT shift_sub_id
+        SELECT DISTINCT
+            t2.shift_name
         FROM
-            mdc_device_calendar
+            mdc_device_calendar t1 LEFT JOIN mdc_shift t2 ON t1.shift_id = t2.id
         WHERE
-            effective_date LIKE CONCAT(#{ validDate }, '%')
-            AND equipment_id = #{ equipmentId }
+            t1.effective_date LIKE CONCAT(#{ validDate }, '%')
+            AND t1.equipment_id = #{ equipmentId }
     </select>
 
     <!--鏌ヨ鐝鏁伴噺-->
@@ -116,7 +115,6 @@
         WHERE
             effective_date LIKE CONCAT(#{ validDate }, '%')
             AND equipment_id = #{ equipmentId }
-            AND shift_sub_id = #{ shiftSubId }
     </select>
 
 </mapper>
\ No newline at end of file
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentOvertimeMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentOvertimeMapper.xml
index 686c7f3..a528b02 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentOvertimeMapper.xml
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentOvertimeMapper.xml
@@ -88,6 +88,5 @@
         WHERE
             mdc.effective_date LIKE CONCAT(#{ validDate }, '%')
             AND mdc.equipment_id = #{ equipmentId }
-            AND mdc.shift_sub_id = #{ shiftSubId }
     </select>
 </mapper>
\ No newline at end of file
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalShiftInfoMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalShiftInfoMapper.xml
index f016ab5..97acaba 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalShiftInfoMapper.xml
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalShiftInfoMapper.xml
@@ -15,7 +15,6 @@
             mdc_equipment_statistical_shift_info
         WHERE
             equipment_id = #{ equipmentId }
-            AND shift_sub_id = #{ shiftSubId }
             AND the_date LIKE CONCAT(#{ validDate },'%')
     </select>
 </mapper>
\ No newline at end of file
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcOverallEquipmentEfficiencyMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcOverallEquipmentEfficiencyMapper.xml
index 303e102..7e17582 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcOverallEquipmentEfficiencyMapper.xml
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcOverallEquipmentEfficiencyMapper.xml
@@ -10,7 +10,7 @@
             t1.equipment_name,
             t1.equipment_model,
             t1.valid_date,
-            t2.shift_sub_name shiftSubId,
+            t1.shift,
             t1.shift_time_count,
             t1.overtime,
             t1.actual_work_day_count,
@@ -37,17 +37,10 @@
             t1.update_by,
             t1.update_time
         FROM
-            mdc_overall_equipment_efficiency t1 LEFT JOIN mdc_shift_sub t2 ON t1.shift_sub_id = t2.id
-            LEFT JOIN mdc_shift t3 ON t2.shift_id = t3.id
+            mdc_overall_equipment_efficiency t1
         <where>
             <if test="mdcOverallEquipmentEfficiency.startTime != null and mdcOverallEquipmentEfficiency.startTime != '' and mdcOverallEquipmentEfficiency.endTime != null and mdcOverallEquipmentEfficiency.endTime != ''">
                 AND t1.valid_date BETWEEN #{ mdcOverallEquipmentEfficiency.startTime } AND #{ mdcOverallEquipmentEfficiency.endTime }
-            </if>
-            <if test="mdcOverallEquipmentEfficiency.shiftId != null and mdcOverallEquipmentEfficiency.shiftId != ''">
-                AND t3.id = #{ mdcOverallEquipmentEfficiency.shiftId }
-            </if>
-            <if test="mdcOverallEquipmentEfficiency.shiftSubId != null and mdcOverallEquipmentEfficiency.shiftSubId != ''">
-                AND t1.shift_sub_id = #{ mdcOverallEquipmentEfficiency.shiftSubId }
             </if>
             <if test="mdcOverallEquipmentEfficiency.equipmentIdList != null and mdcOverallEquipmentEfficiency.equipmentIdList.size() > 0 ">
                 AND t1.equipment_id IN
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcDeviceCalendarService.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcDeviceCalendarService.java
index 4c2ce4a..54a6c0d 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcDeviceCalendarService.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcDeviceCalendarService.java
@@ -41,12 +41,11 @@
     /**
      * 璁$畻瀹為檯鐝骇澶╂暟
      *
-     * @param shiftSubId
      * @param equipmentId
      * @param validDate
      * @return
      */
-    BigDecimal computeActualWorkDayCount(String shiftSubId, String equipmentId, String validDate);
+    BigDecimal computeActualWorkDayCount(String equipmentId, String validDate);
 
     /**
      * 鏌ヨ鐝鍒嗙被
@@ -60,12 +59,11 @@
     /**
      * 璁$畻鐝鏃堕棿
      *
-     * @param shiftSubId
      * @param equipmentId
      * @param validDate
      * @return
      */
-    BigDecimal computeShiftTimeCount(String shiftSubId, String equipmentId, String validDate);
+    BigDecimal computeShiftTimeCount(String equipmentId, String validDate);
 
     /**
      * 鐢熸垚璁惧宸ヤ綔鏃ュ巻
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentOvertimeService.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentOvertimeService.java
index f8991b6..33f0763 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentOvertimeService.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentOvertimeService.java
@@ -41,10 +41,9 @@
     /**
      * 璁$畻鍔犵彮鏃堕棿
      *
-     * @param shiftSubId
      * @param equipmentId
      * @param validDate
      * @return
      */
-    BigDecimal computeOvertime(String shiftSubId, String equipmentId, String validDate);
+    BigDecimal computeOvertime(String equipmentId, String validDate);
 }
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentStatisticalShiftInfoService.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentStatisticalShiftInfoService.java
index c3048e1..cc1b424 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentStatisticalShiftInfoService.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentStatisticalShiftInfoService.java
@@ -24,9 +24,8 @@
      *
      * @param equipmentId
      * @param validDate
-     * @param shiftSubId
      * @return
      */
-    BigDecimal findSpindleRunDuration(String equipmentId, String validDate, String shiftSubId);
+    BigDecimal findSpindleRunDuration(String equipmentId, String validDate);
 
 }
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcPlanCloseService.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcPlanCloseService.java
index 66b9981..d2b83ed 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcPlanCloseService.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcPlanCloseService.java
@@ -3,6 +3,8 @@
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.mdc.entity.MdcPlanClose;
 
+import java.math.BigDecimal;
+
 /**
  * @Description: mdc璁″垝鍋滄満缁存姢琛�
  * @Author: Lius
@@ -11,4 +13,5 @@
  */
 public interface IMdcPlanCloseService extends IService<MdcPlanClose> {
 
+    BigDecimal findPlanTimeDuration(BigDecimal actualWorkDayCount, String planCloseType);
 }
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDeviceCalendarServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDeviceCalendarServiceImpl.java
index 06d005d..89dc713 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDeviceCalendarServiceImpl.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDeviceCalendarServiceImpl.java
@@ -146,15 +146,14 @@
     /**
      * 璁$畻瀹為檯鐝骇澶╂暟
      *
-     * @param shiftSubId
      * @param equipmentId
      * @param validDate
      * @return
      */
     @Override
-    public BigDecimal computeActualWorkDayCount(String shiftSubId, String equipmentId, String validDate) {
+    public BigDecimal computeActualWorkDayCount(String equipmentId, String validDate) {
         validDate = validDate.replaceAll("-", "");
-        List<String> validDateList = this.baseMapper.computeActualWorkDayCount(shiftSubId, equipmentId, validDate);
+        List<String> validDateList = this.baseMapper.computeActualWorkDayCount(equipmentId, validDate);
         return new BigDecimal(validDateList.size());
     }
 
@@ -174,14 +173,13 @@
     /**
      * 璁$畻鐝鏃堕棿
      *
-     * @param shiftSubId
      * @param equipmentId
      * @param validDate
      * @return
      */
     @Override
-    public BigDecimal computeShiftTimeCount(String shiftSubId, String equipmentId, String validDate) {
-        Integer shiftCount = this.baseMapper.computeShiftTimeCount(shiftSubId, equipmentId, validDate);
+    public BigDecimal computeShiftTimeCount(String equipmentId, String validDate) {
+        Integer shiftCount = this.baseMapper.computeShiftTimeCount(equipmentId, validDate);
         return new BigDecimal(shiftCount).multiply(new BigDecimal("8")).multiply(new BigDecimal("60"));
     }
 
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentOvertimeServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentOvertimeServiceImpl.java
index b5a1eb8..f2ff16d 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentOvertimeServiceImpl.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentOvertimeServiceImpl.java
@@ -132,14 +132,13 @@
     /**
      * 璁$畻鍔犵彮鏃堕棿锛堝垎閽燂級
      *
-     * @param shiftSubId
      * @param equipmentId
      * @param validDate
      * @return
      */
     @Override
-    public BigDecimal computeOvertime(String shiftSubId, String equipmentId, String validDate) {
-        List<MdcEquipmentOvertime> list = this.baseMapper.computeOvertime(shiftSubId, equipmentId, validDate);
+    public BigDecimal computeOvertime(String equipmentId, String validDate) {
+        List<MdcEquipmentOvertime> list = this.baseMapper.computeOvertime(equipmentId, validDate);
         BigDecimal result = new BigDecimal("0");
         if (list != null && !list.isEmpty()) {
             for (MdcEquipmentOvertime equipmentOvertime : list) {
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalShiftInfoServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalShiftInfoServiceImpl.java
index a24c990..6e1a082 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalShiftInfoServiceImpl.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalShiftInfoServiceImpl.java
@@ -84,9 +84,9 @@
      * @return
      */
     @Override
-    public BigDecimal findSpindleRunDuration(String equipmentId, String validDate, String shiftSubId) {
+    public BigDecimal findSpindleRunDuration(String equipmentId, String validDate) {
         validDate = validDate.replaceAll("-", "");
-        BigDecimal duration = this.baseMapper.findSpindleRunDuration(equipmentId, validDate, shiftSubId);
+        BigDecimal duration = this.baseMapper.findSpindleRunDuration(equipmentId, validDate);
         if (duration != null && duration.compareTo(BigDecimal.ZERO) != 0) {
             return duration.divide(new BigDecimal("60"), 0, RoundingMode.HALF_UP);
         } else {
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcOverallEquipmentEfficiencyServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcOverallEquipmentEfficiencyServiceImpl.java
index 62ec94a..60c496c 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcOverallEquipmentEfficiencyServiceImpl.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcOverallEquipmentEfficiencyServiceImpl.java
@@ -76,117 +76,114 @@
         List<MdcEquipment> equipmentList = mdcEquipmentService.list();
         for (MdcEquipment mdcEquipment : equipmentList) {
             String equipmentId = mdcEquipment.getEquipmentId();
-            // 鏌ヨ鐝鍒嗙被
+
+            MdcOverallEquipmentEfficiency mdcOverallEquipmentEfficiency = new MdcOverallEquipmentEfficiency();
+            // 鏃堕棿寮�鍔ㄧ巼璁$畻
+            mdcOverallEquipmentEfficiency.setEquipmentId(equipmentId);
+            mdcOverallEquipmentEfficiency.setEquipmentName(mdcEquipment.getEquipmentName());
+            mdcOverallEquipmentEfficiency.setEquipmentModel(mdcEquipment.getEquipmentModel());
+            mdcOverallEquipmentEfficiency.setValidDate(validDate);
+
+            // 鏌ヨ鐝埗鍒嗙被
             List<String> shiftSubIdList = mdcDeviceCalendarService.findShiftSort(equipmentId, validDate);
+            if (shiftSubIdList != null && !shiftSubIdList.isEmpty()) {
+                String shift = String.join(",", shiftSubIdList);
+                mdcOverallEquipmentEfficiency.setShift(shift);
+            }
+
+            BigDecimal shiftTimeCount = mdcDeviceCalendarService.computeShiftTimeCount(equipmentId, validDate);
+            mdcOverallEquipmentEfficiency.setShiftTimeCount(shiftTimeCount);
+
+            // 璁$畻鍔犵彮鏃堕棿
+            BigDecimal overtime = mdcEquipmentOvertimeService.computeOvertime(equipmentId, validDate);
+            mdcOverallEquipmentEfficiency.setOvertime(overtime);
+
+            // 璁$畻瀹為檯鐝骇澶╂暟
+            BigDecimal actualWorkDayCount = mdcDeviceCalendarService.computeActualWorkDayCount(equipmentId, validDate);
+            mdcOverallEquipmentEfficiency.setActualWorkDayCount(actualWorkDayCount);
+
+            // 鏈堝害瀹為檯鐝骇鎬绘椂闂�(鍒嗛挓)
+            mdcOverallEquipmentEfficiency.setMonthActualWorkDayTimeCount(mdcOverallEquipmentEfficiency.getShiftTimeCount().add(overtime));
+
             // 鏁呴殰鍋滄満鏃堕暱缁熻(鍒嗛挓)
             BigDecimal breakdownDownDuration = mdcNoplanCloseService.findNoplanTimeDuration(equipmentId, validDate, MdcConstant.BREAKDOWN_DOWN);
+            mdcOverallEquipmentEfficiency.setBreakdownDownDuration(breakdownDownDuration);
             // 鎹㈠瀷璋冭瘯鏃堕暱缁熻(鍒嗛挓)
             BigDecimal conversionDebugDuration = mdcNoplanCloseService.findNoplanTimeDuration(equipmentId, validDate, MdcConstant.CONVERSION_DEBUG);
+            mdcOverallEquipmentEfficiency.setConversionDebugDuration(conversionDebugDuration);
             // 鐗╂枡鐭己鏃堕暱缁熻(鍒嗛挓)
             BigDecimal materialShortageDuration = mdcNoplanCloseService.findNoplanTimeDuration(equipmentId, validDate, MdcConstant.MATERIAL_SHORTAGE);
+            mdcOverallEquipmentEfficiency.setMaterialShortageDuration(materialShortageDuration);
             // 璁″垝绛変换鍔℃椂闀跨粺璁�(鍒嗛挓)
             BigDecimal plannedTaskDuration = mdcNoplanCloseService.findNoplanTimeDuration(equipmentId, validDate, MdcConstant.PLANNED_TASK);
+            mdcOverallEquipmentEfficiency.setPlannedTaskDuration(plannedTaskDuration);
             // 妫�楠屾椂闀跨粺璁�(鍒嗛挓)
             BigDecimal inspectDuration = mdcNoplanCloseService.findNoplanTimeDuration(equipmentId, validDate, MdcConstant.INSPECT);
+            mdcOverallEquipmentEfficiency.setInspectDuration(inspectDuration);
             // 鍏朵粬鏃堕暱缁熻(鍒嗛挓)
             BigDecimal otherDuration = mdcNoplanCloseService.findNoplanTimeDuration(equipmentId, validDate, MdcConstant.OTHER);
+            mdcOverallEquipmentEfficiency.setOtherDuration(otherDuration);
             // 璁″垝淇濆吇鏃堕暱缁熻(鍒嗛挓)
-            BigDecimal plannedMaintenanceDuration = new BigDecimal("0");
+            BigDecimal plannedMaintenanceDuration = mdcPlanCloseService.findPlanTimeDuration(actualWorkDayCount, MdcConstant.PLANNED_MAINTENANCE);
+            mdcOverallEquipmentEfficiency.setPlannedMaintenanceDuration(plannedMaintenanceDuration);
             // 浼氳/鍩硅鏃堕暱缁熻(鍒嗛挓)
-            BigDecimal conferenceTrainingDuration = new BigDecimal("0");
+            BigDecimal conferenceTrainingDuration = mdcPlanCloseService.findPlanTimeDuration(actualWorkDayCount, MdcConstant.CONFERENCE_TRAINING);
+            mdcOverallEquipmentEfficiency.setConferenceTrainingDuration(conferenceTrainingDuration);
             // 鍏跺畠浼戞伅鏃堕暱缁熻(鍒嗛挓)
-            BigDecimal otherRestDuration = new BigDecimal("0");
-            if (shiftSubIdList != null && !shiftSubIdList.isEmpty()) {
-                for (String shiftSubId : shiftSubIdList) {
-                    MdcOverallEquipmentEfficiency mdcOverallEquipmentEfficiency = new MdcOverallEquipmentEfficiency();
-                    // 鏃堕棿寮�鍔ㄧ巼璁$畻
-                    mdcOverallEquipmentEfficiency.setEquipmentId(equipmentId);
-                    mdcOverallEquipmentEfficiency.setEquipmentName(mdcEquipment.getEquipmentName());
-                    mdcOverallEquipmentEfficiency.setEquipmentModel(mdcEquipment.getEquipmentModel());
-                    mdcOverallEquipmentEfficiency.setValidDate(validDate);
-                    // 鐝  鐝鏃堕棿
-                    mdcOverallEquipmentEfficiency.setShiftSubId(shiftSubId);
-                    BigDecimal shiftTimeCount = mdcDeviceCalendarService.computeShiftTimeCount(shiftSubId, equipmentId, validDate);
-                    mdcOverallEquipmentEfficiency.setShiftTimeCount(shiftTimeCount);
-                    // 璁$畻鍔犵彮鏃堕棿
-                    BigDecimal overtime = mdcEquipmentOvertimeService.computeOvertime(shiftSubId, equipmentId, validDate);
-                    mdcOverallEquipmentEfficiency.setOvertime(overtime);
-                    // 璁$畻瀹為檯鐝骇澶╂暟
-                    BigDecimal actualWorkDayCount = mdcDeviceCalendarService.computeActualWorkDayCount(shiftSubId, equipmentId, validDate);
-                    mdcOverallEquipmentEfficiency.setActualWorkDayCount(actualWorkDayCount);
-                    // 鏈堝害瀹為檯鐝骇鎬绘椂闂�(鍒嗛挓)
-                    mdcOverallEquipmentEfficiency.setMonthActualWorkDayTimeCount(mdcOverallEquipmentEfficiency.getShiftTimeCount().add(overtime));
-                    // 鏁呴殰鍋滄満鏃堕暱缁熻(鍒嗛挓)
-                    mdcOverallEquipmentEfficiency.setBreakdownDownDuration(breakdownDownDuration);
-                    // 鎹㈠瀷璋冭瘯鏃堕暱缁熻(鍒嗛挓)
-                    mdcOverallEquipmentEfficiency.setConversionDebugDuration(conversionDebugDuration);
-                    // 鐗╂枡鐭己鏃堕暱缁熻(鍒嗛挓)
-                    mdcOverallEquipmentEfficiency.setMaterialShortageDuration(materialShortageDuration);
-                    // 璁″垝绛変换鍔℃椂闀跨粺璁�(鍒嗛挓)
-                    mdcOverallEquipmentEfficiency.setPlannedTaskDuration(plannedTaskDuration);
-                    // 妫�楠屾椂闀跨粺璁�(鍒嗛挓)
-                    mdcOverallEquipmentEfficiency.setInspectDuration(inspectDuration);
-                    // 鍏朵粬鏃堕暱缁熻(鍒嗛挓)
-                    mdcOverallEquipmentEfficiency.setOtherDuration(otherDuration);
-                    // 璁″垝淇濆吇鏃堕暱缁熻(鍒嗛挓)
-                    mdcOverallEquipmentEfficiency.setPlannedMaintenanceDuration(plannedMaintenanceDuration);
-                    // 浼氳/鍩硅鏃堕暱缁熻(鍒嗛挓)
-                    mdcOverallEquipmentEfficiency.setConferenceTrainingDuration(conferenceTrainingDuration);
-                    // 鍏跺畠浼戞伅鏃堕暱缁熻(鍒嗛挓)
-                    mdcOverallEquipmentEfficiency.setOtherRestDuration(otherRestDuration);
-                    /*
-                        璐熻嵎鏃堕棿(灏忔椂) = 宸ヤ綔鏃ュ巻鏃堕棿 - 璁″垝鍋滄満鏃堕棿
-                        宸ヤ綔鏃ュ巻鏃堕棿 = 鏃ュ巻鏃堕棿 - 娉曞畾鍋囨棩 - 鍙屼紤鏃� + 鍔犵彮鏃堕棿
-                        璁″垝鍋滄満鏃堕棿 = 璁″垝淇濆吇鏃堕暱 + 浼氳/鍩硅鏃堕暱 + 浼氳/鍩硅鏃堕暱
-                     */
-                    // mdcOverallEquipmentEfficiency.getShiftTimeCount() - plannedMaintenanceDuration - conferenceTrainingDuration - otherRestDuration
-                    // 璐熻嵎鏃堕棿(鍒嗛挓)
-                    BigDecimal loadTime = mdcOverallEquipmentEfficiency.getShiftTimeCount().subtract(plannedMaintenanceDuration).subtract(conferenceTrainingDuration).subtract(otherRestDuration);
-                    mdcOverallEquipmentEfficiency.setLoadTime(loadTime.divide(new BigDecimal("60"), 1, RoundingMode.HALF_UP));
-                    // 鏃堕棿寮�鍔ㄧ巼
-                    BigDecimal timeActuationRate = BigDecimal.ZERO;
-                    if (loadTime.compareTo(BigDecimal.ZERO) == 0) {
-                        mdcOverallEquipmentEfficiency.setTimeActuationRate(BigDecimal.ZERO);
-                    } else {
-                        timeActuationRate = (loadTime.subtract(breakdownDownDuration).subtract(conversionDebugDuration).subtract(materialShortageDuration).subtract(plannedTaskDuration).subtract(inspectDuration).subtract(otherDuration)).divide(loadTime, 4, RoundingMode.HALF_UP);
-                        mdcOverallEquipmentEfficiency.setTimeActuationRate(timeActuationRate);
-                    }
-                    // 鍔犲伐闆朵欢鏁�(浠�)  processQuantity
-                    BigDecimal processQuantity = mdcPassRateService.findProcessQuantity(equipmentId, validDate);
-                    mdcOverallEquipmentEfficiency.setProcessQuantity(processQuantity);
-                    // 鏍囧噯鍔犲伐鏃堕棿(鍒嗛挓)
-                    MdcStandardProcessDuration mdcStandardProcessDuration = mdcStandardProcessDurationService.getOne(new LambdaQueryWrapper<MdcStandardProcessDuration>().eq(MdcStandardProcessDuration::getEquipmentId, equipmentId));
-                    if (mdcStandardProcessDuration != null) {
-                        mdcOverallEquipmentEfficiency.setStandardProcessDuration(new BigDecimal(mdcStandardProcessDuration.getDuration()).multiply(processQuantity));
-                    } else {
-                        mdcOverallEquipmentEfficiency.setStandardProcessDuration(BigDecimal.ZERO);
-                    }
-
-                    // 鎬ц兘寮�鍔ㄧ巼 = 涓昏酱杩愯鏃堕棿/璐熻嵎鏃堕棿
-                    // 鏌ヨ涓昏酱杩愯鏃堕棿(鍒嗛挓)
-                    BigDecimal spindleRunDuration = mdcEquipmentStatisticalShiftInfoService.findSpindleRunDuration(equipmentId, validDate, shiftSubId);
-                    if (loadTime.compareTo(BigDecimal.ZERO) != 0) {
-                        mdcOverallEquipmentEfficiency.setPerformanceRate(spindleRunDuration.divide(loadTime, 4, RoundingMode.HALF_UP));
-                    } else {
-                        mdcOverallEquipmentEfficiency.setPerformanceRate(BigDecimal.ZERO);
-                    }
-                    // 搴熷搧鏁� unqualifiedQuantity
-                    BigDecimal unqualifiedQuantity = mdcPassRateService.findUnqualifiedQuantity(equipmentId, validDate);
-                    mdcOverallEquipmentEfficiency.setUnqualifiedQuantity(unqualifiedQuantity);
-                    // 鍚堟牸鐜�
-                    if (processQuantity.compareTo(BigDecimal.ZERO) == 0) {
-                        mdcOverallEquipmentEfficiency.setPassRate(BigDecimal.ONE);
-                    } else {
-                        mdcOverallEquipmentEfficiency.setPassRate((processQuantity.subtract(unqualifiedQuantity)).divide(processQuantity, 4, RoundingMode.HALF_UP));
-                    }
-                    // 璁惧缁煎悎鏁堢巼 = 鏃堕棿寮�鍔ㄧ巼 脳 鎬ц兘寮�鍔ㄧ巼 脳 鍚堟牸鍝佺巼
-                    mdcOverallEquipmentEfficiency.setOverallEquipmentEfficiency(timeActuationRate.multiply(mdcOverallEquipmentEfficiency.getPerformanceRate()).multiply(mdcOverallEquipmentEfficiency.getPassRate()));
-                    if (mdcOverallEquipmentEfficiency.getOverallEquipmentEfficiency().compareTo(BigDecimal.ZERO) == 0) {
-                        mdcOverallEquipmentEfficiency.setOverallEquipmentEfficiency(BigDecimal.ONE);
-                    }
-                    result.add(mdcOverallEquipmentEfficiency);
-                }
+            BigDecimal otherRestDuration = mdcPlanCloseService.findPlanTimeDuration(actualWorkDayCount, MdcConstant.OTHER_REST);
+            mdcOverallEquipmentEfficiency.setOtherRestDuration(otherRestDuration);
+            /*
+                璐熻嵎鏃堕棿(灏忔椂) = 宸ヤ綔鏃ュ巻鏃堕棿 - 璁″垝鍋滄満鏃堕棿
+                宸ヤ綔鏃ュ巻鏃堕棿 = 鏃ュ巻鏃堕棿 - 娉曞畾鍋囨棩 - 鍙屼紤鏃� + 鍔犵彮鏃堕棿
+                璁″垝鍋滄満鏃堕棿 = 璁″垝淇濆吇鏃堕暱 + 浼氳/鍩硅鏃堕暱 + 浼氳/鍩硅鏃堕暱
+             */
+            // mdcOverallEquipmentEfficiency.getShiftTimeCount() - plannedMaintenanceDuration - conferenceTrainingDuration - otherRestDuration
+            // 璐熻嵎鏃堕棿(鍒嗛挓)
+            BigDecimal loadTime = mdcOverallEquipmentEfficiency.getShiftTimeCount().subtract(plannedMaintenanceDuration).subtract(conferenceTrainingDuration).subtract(otherRestDuration);
+            mdcOverallEquipmentEfficiency.setLoadTime(loadTime.divide(new BigDecimal("60"), 1, RoundingMode.HALF_UP));
+            // 鏃堕棿寮�鍔ㄧ巼
+            BigDecimal timeActuationRate = BigDecimal.ZERO;
+            if (loadTime.compareTo(BigDecimal.ZERO) == 0) {
+                mdcOverallEquipmentEfficiency.setTimeActuationRate(BigDecimal.ZERO);
+            } else {
+                timeActuationRate = (loadTime.subtract(breakdownDownDuration).subtract(conversionDebugDuration).subtract(materialShortageDuration).subtract(plannedTaskDuration).subtract(inspectDuration).subtract(otherDuration)).divide(loadTime, 4, RoundingMode.HALF_UP);
+                mdcOverallEquipmentEfficiency.setTimeActuationRate(timeActuationRate);
             }
+            // 鍔犲伐闆朵欢鏁�(浠�)  processQuantity
+            BigDecimal processQuantity = mdcPassRateService.findProcessQuantity(equipmentId, validDate);
+            mdcOverallEquipmentEfficiency.setProcessQuantity(processQuantity);
+            // 鏍囧噯鍔犲伐鏃堕棿(鍒嗛挓)
+            MdcStandardProcessDuration mdcStandardProcessDuration = mdcStandardProcessDurationService.getOne(new LambdaQueryWrapper<MdcStandardProcessDuration>().eq(MdcStandardProcessDuration::getEquipmentId, equipmentId));
+            if (mdcStandardProcessDuration != null) {
+                mdcOverallEquipmentEfficiency.setStandardProcessDuration(new BigDecimal(mdcStandardProcessDuration.getDuration()).multiply(processQuantity));
+            } else {
+                mdcOverallEquipmentEfficiency.setStandardProcessDuration(BigDecimal.ZERO);
+            }
+
+            // 鎬ц兘寮�鍔ㄧ巼 = 涓昏酱杩愯鏃堕棿/璐熻嵎鏃堕棿
+            // 鏌ヨ涓昏酱杩愯鏃堕棿(鍒嗛挓)
+            BigDecimal spindleRunDuration = mdcEquipmentStatisticalShiftInfoService.findSpindleRunDuration(equipmentId, validDate);
+            if (loadTime.compareTo(BigDecimal.ZERO) != 0) {
+                mdcOverallEquipmentEfficiency.setPerformanceRate(spindleRunDuration.divide(loadTime, 4, RoundingMode.HALF_UP));
+            } else {
+                mdcOverallEquipmentEfficiency.setPerformanceRate(BigDecimal.ZERO);
+            }
+            // 搴熷搧鏁� unqualifiedQuantity
+            BigDecimal unqualifiedQuantity = mdcPassRateService.findUnqualifiedQuantity(equipmentId, validDate);
+            mdcOverallEquipmentEfficiency.setUnqualifiedQuantity(unqualifiedQuantity);
+            // 鍚堟牸鐜�
+            if (processQuantity.compareTo(BigDecimal.ZERO) == 0) {
+                mdcOverallEquipmentEfficiency.setPassRate(BigDecimal.ONE);
+            } else {
+                mdcOverallEquipmentEfficiency.setPassRate((processQuantity.subtract(unqualifiedQuantity)).divide(processQuantity, 4, RoundingMode.HALF_UP));
+            }
+            // 璁惧缁煎悎鏁堢巼 = 鏃堕棿寮�鍔ㄧ巼 脳 鎬ц兘寮�鍔ㄧ巼 脳 鍚堟牸鍝佺巼
+            mdcOverallEquipmentEfficiency.setOverallEquipmentEfficiency(timeActuationRate.multiply(mdcOverallEquipmentEfficiency.getPerformanceRate()).multiply(mdcOverallEquipmentEfficiency.getPassRate()));
+            if (mdcOverallEquipmentEfficiency.getOverallEquipmentEfficiency().compareTo(BigDecimal.ZERO) == 0) {
+                mdcOverallEquipmentEfficiency.setOverallEquipmentEfficiency(BigDecimal.ONE);
+            }
+            result.add(mdcOverallEquipmentEfficiency);
+
         }
         super.saveBatch(result);
     }
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcPlanCloseServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcPlanCloseServiceImpl.java
index 9ef0320..7ed38b2 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcPlanCloseServiceImpl.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcPlanCloseServiceImpl.java
@@ -1,11 +1,16 @@
 package org.jeecg.modules.mdc.service.impl;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.jeecg.modules.mdc.entity.MdcPlanClose;
 import org.jeecg.modules.mdc.mapper.MdcPlanCloseMapper;
 import org.jeecg.modules.mdc.service.IMdcPlanCloseService;
 import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.Collections;
+import java.util.List;
 
 
 /**
@@ -17,4 +22,27 @@
 @Service
 public class MdcPlanCloseServiceImpl extends ServiceImpl<MdcPlanCloseMapper, MdcPlanClose> implements IMdcPlanCloseService {
 
+    @Override
+    public BigDecimal findPlanTimeDuration(BigDecimal actualWorkDayCount, String planCloseType) {
+        BigDecimal result = new BigDecimal("0");
+        List<MdcPlanClose> mdcPlanCloses = this.baseMapper.selectList(new LambdaQueryWrapper<MdcPlanClose>().in(MdcPlanClose::getPlanCloseType, Collections.singletonList(planCloseType)));
+        if (mdcPlanCloses != null && !mdcPlanCloses.isEmpty()) {
+            for (MdcPlanClose mdcPlanClose : mdcPlanCloses) {
+                switch (mdcPlanClose.getPlanCloseTimeType()) {
+                    case "澶�":
+                        result = result.add(actualWorkDayCount.multiply(new BigDecimal(mdcPlanClose.getPlanCloseTimeLong())));
+                        break;
+                    case "鍛�":
+                        result = result.add(new BigDecimal("4").multiply(new BigDecimal(mdcPlanClose.getPlanCloseTimeLong())));
+                        break;
+                    case "鏈�":
+                        result = result.add(new BigDecimal(mdcPlanClose.getPlanCloseTimeLong()));
+                        break;
+                    default:
+                        break;
+                }
+            }
+        }
+        return result;
+    }
 }

--
Gitblit v1.9.3