From c45790a3da8fa480091be24e0775e9f8dbab927c Mon Sep 17 00:00:00 2001
From: lius <Lius2225@163.com>
Date: 星期二, 25 七月 2023 14:30:43 +0800
Subject: [PATCH] 班次利用率定时任务算法

---
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentRunningSectionService.java               |   13 
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentStatisticalInfo.java                       |    4 
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java       |   62 ++++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IEquipmentLogService.java                             |    5 
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalInfoServiceImpl.java      |    2 
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDeviceCalendarServiceImpl.java                |   34 ++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentRunningSectionMapper.java                  |    5 
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/MdcShiftDateVo.java                                        |  106 +++++++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/EquipmentLogServiceImpl.java                     |    5 
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalShiftInfoServiceImpl.java |  368 ++++++++++++++++++++++++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentStatisticalShiftInfo.java                  |   91 ++++++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningAllEquipmentShiftStatisticalProcessJob.java        |   43 ++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcDeviceCalendarService.java                        |   12 
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDeviceCalendarMapper.xml                        |   44 ++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentStatisticalShiftInfoService.java         |   19 +
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/EquipmentLogMapper.java                                |    6 
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/EquipmentLogMapper.xml                             |    8 
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcDeviceCalendarMapper.java                           |    8 
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentStatisticalInfoService.java              |    2 
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml               |   13 
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalShiftInfoMapper.xml         |    9 
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentStatisticalShiftInfoMapper.java            |   20 +
 22 files changed, 872 insertions(+), 7 deletions(-)

diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentStatisticalInfo.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentStatisticalInfo.java
index 9cfa67c..04a9afb 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentStatisticalInfo.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentStatisticalInfo.java
@@ -17,7 +17,7 @@
 
 /**
  * @Description: 璁惧鍗曟棩杩愯鏁版嵁琛�
- * @Author: jeecg-boot
+ * @Author: LiuS
  * @Date: 2023-04-14
  * @Version: V1.0
  */
@@ -28,6 +28,8 @@
 @ApiModel(value = "mdc_equipment_statistical_info瀵硅薄", description = "璁惧鍗曟棩杩愯鏁版嵁琛�")
 public class MdcEquipmentStatisticalInfo implements Serializable {
 
+    private static final long serialVersionUID = -4733120585358211415L;
+
     /**
      * 涓婚敭
      */
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentStatisticalShiftInfo.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentStatisticalShiftInfo.java
new file mode 100644
index 0000000..1ffc1f7
--- /dev/null
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentStatisticalShiftInfo.java
@@ -0,0 +1,91 @@
+package org.jeecg.modules.mdc.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @Description: 璁惧鐝鍗曟棩杩愯鏁版嵁琛�
+ * @author: LiuS
+ * @create: 2023-07-24 11:13
+ */
+@Data
+@TableName("mdc_equipment_statistical_shift_info")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "mdc_equipment_statistical_shift_info瀵硅薄", description = "璁惧鐝鍗曟棩杩愯鏁版嵁琛�")
+public class MdcEquipmentStatisticalShiftInfo implements Serializable {
+
+    private static final long serialVersionUID = 1519876512924700514L;
+
+    /**
+     * 涓婚敭
+     */
+    @TableId(type = IdType.ASSIGN_ID)
+    @ApiModelProperty(value = "涓婚敭")
+    private String id;
+    /**
+     * 璁惧id
+     */
+    @ApiModelProperty(value = "璁惧id")
+    private String equipmentId;
+    /**
+     * 鐝埗id
+     */
+    @ApiModelProperty(value = "鐝埗id")
+    private String shiftId;
+    /**
+     * 鐝id
+     */
+    @ApiModelProperty(value = "鐝id")
+    private String shiftSubId;
+    /**
+     * 寮�鏈烘椂闀�
+     */
+    @ApiModelProperty(value = "寮�鏈烘椂闀�")
+    private BigDecimal openLong = new BigDecimal("0");
+    /**
+     * 鍏虫満鏃堕暱
+     */
+    @ApiModelProperty(value = "鍏虫満鏃堕暱")
+    private BigDecimal closeLong = new BigDecimal("0");
+    /**
+     * 寰呮満鏃堕暱
+     */
+    @ApiModelProperty(value = "寰呮満鏃堕暱")
+    private BigDecimal waitLong = new BigDecimal("0");
+    /**
+     * 鍔犲伐鏃堕暱
+     */
+    @ApiModelProperty(value = "鍔犲伐鏃堕暱")
+    private BigDecimal processLong = new BigDecimal("0");
+    /**
+     * 鎶ヨ鏃堕暱
+     */
+    @ApiModelProperty(value = "鎶ヨ鏃堕暱")
+    private BigDecimal errorLong = new BigDecimal("0");
+    /**
+     * 鏈夋晥鏃ユ湡
+     */
+    @ApiModelProperty(value = "鏈夋晥鏃ユ湡")
+    private String theDate;
+    /**
+     * 鍒涘缓鏃堕棿
+     */
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "鍒涘缓鏃堕棿")
+    private Date createTime;
+
+}
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningAllEquipmentShiftStatisticalProcessJob.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningAllEquipmentShiftStatisticalProcessJob.java
new file mode 100644
index 0000000..5443fa9
--- /dev/null
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningAllEquipmentShiftStatisticalProcessJob.java
@@ -0,0 +1,43 @@
+package org.jeecg.modules.mdc.job;
+
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.mdc.service.IMdcEquipmentStatisticalShiftInfoService;
+import org.quartz.*;
+
+import javax.annotation.Resource;
+
+/**
+ * @Description: 瀹氭椂缁熻鍗曟棩鐝鏁版嵁浠诲姟
+ * @author: LiuS
+ * @create: 2023-07-24 10:26
+ */
+@PersistJobDataAfterExecution
+@DisallowConcurrentExecution
+@Slf4j
+public class RunningAllEquipmentShiftStatisticalProcessJob implements Job {
+
+    /**
+     * 鑻ュ弬鏁板彉閲忓悕淇敼 QuartzJobController涓篃闇�瀵瑰簲淇敼  鏃堕棿锛� yyyyMMdd 渚嬶細 20230414
+     */
+    private String parameter;
+
+    public void setParameter(String parameter) {
+        this.parameter = parameter;
+    }
+
+    @Resource
+    private IMdcEquipmentStatisticalShiftInfoService mdcEquipmentStatisticalShiftInfoService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        log.info(String.format("瀹氭椂缁熻鍗曟棩鐝鏁版嵁浠诲姟 param: %s RunningAllEquipmentShiftStatisticalProcessJob start!  鏃堕棿:" + DateUtils.now(), this.parameter));
+        try {
+            mdcEquipmentStatisticalShiftInfoService.runningAllEquipmentShiftStatisticalProcess(this.parameter);
+            log.info("瀹氭椂缁熻鍗曟棩鐝鏁版嵁浠诲姟 RunningAllEquipmentShiftStatisticalProcessJob 鎵ц鎴愬姛!");
+        } catch (Exception e) {
+            log.error("瀹氭椂缁熻鍗曟棩鐝鏁版嵁浠诲姟 RunningAllEquipmentShiftStatisticalProcessJob 鎵ц澶辫触!");
+            log.error(e.getMessage(), e);
+        }
+    }
+}
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/EquipmentLogMapper.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/EquipmentLogMapper.java
index bfe738d..9b13b82 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/EquipmentLogMapper.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/EquipmentLogMapper.java
@@ -1,11 +1,17 @@
 package org.jeecg.modules.mdc.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 import org.jeecg.modules.mdc.entity.EquipmentLog;
+
+import java.util.Date;
 
 /**
  * @author: LiuS
  * @create: 2023-04-12 14:44
  */
 public interface EquipmentLogMapper extends BaseMapper<EquipmentLog> {
+
+
+    EquipmentLog getRow(@Param("equipmentid") String equipmentid, @Param("startTime") Date startTime);
 }
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 4fe2636..599d1dd 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
@@ -7,6 +7,9 @@
 import org.jeecg.modules.mdc.vo.MdcDeviceCalendarQueryVo;
 import org.jeecg.modules.mdc.vo.MdcDeviceCalendarVo;
 
+import java.util.Date;
+import java.util.List;
+
 /**
  * @Description: 璁惧宸ヤ綔鏃ュ巻琛�
  * @Author: jeecg-boot
@@ -16,4 +19,9 @@
 public interface MdcDeviceCalendarMapper extends BaseMapper<MdcDeviceCalendar> {
 
     IPage<MdcDeviceCalendarVo> pageList(IPage<MdcDeviceCalendarVo> pageData, @Param("deviceCalendar") MdcDeviceCalendarQueryVo mdcDeviceCalendarQueryVo);
+
+    List<MdcDeviceCalendarVo> listByEquipmentAndDate(@Param("equipmentid") String equipmentid, @Param("stringDate") String stringDate);
+
+    List<MdcDeviceCalendarVo> findAcquiesceShift();
+
 }
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentRunningSectionMapper.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentRunningSectionMapper.java
index aa32327..2a3a7c6 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentRunningSectionMapper.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentRunningSectionMapper.java
@@ -34,4 +34,9 @@
      * 鏌ヨ璁惧鍗曟棩杩愯鐘舵�佹椂闂存璁板綍
      */
     List<MdcEquipmentRunningSection> listForEquipmentStatisticalInfo(@Param("equipmentId") String equipmentId, @Param("startDate") Date startDate, @Param("endDate") Date endDate);
+
+    /**
+     * 璁$畻涓�娈垫椂闂村唴鐨勬暟鎹�
+     */
+    List<MdcEquipmentRunningSection> listEquipmentRunningSection(@Param("equipmentId") String equipmentid, @Param("startLong") long start, @Param("endLong") long end);
 }
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
new file mode 100644
index 0000000..8a3fc71
--- /dev/null
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentStatisticalShiftInfoMapper.java
@@ -0,0 +1,20 @@
+package org.jeecg.modules.mdc.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalShiftInfo;
+
+/**
+ * @author: LiuS
+ * @create: 2023-07-24 11:23
+ */
+public interface MdcEquipmentStatisticalShiftInfoMapper extends BaseMapper<MdcEquipmentStatisticalShiftInfo> {
+
+    /**
+     * 鑾峰彇璁惧鏈�鏂版棩鏈熺殑杩愯鏁版嵁
+     *
+     * @param equipmentid
+     * @return
+     */
+    MdcEquipmentStatisticalShiftInfo getMaxStaticsData(@Param("equipmentId") String equipmentid);
+}
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/EquipmentLogMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/EquipmentLogMapper.xml
new file mode 100644
index 0000000..a14f8cf
--- /dev/null
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/EquipmentLogMapper.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.mdc.mapper.EquipmentLogMapper">
+
+    <select id="getRow" resultType="org.jeecg.modules.mdc.entity.EquipmentLog">
+        SELECT top 1 * FROM EquipmentLog WHERE EquipmentID = #{ equipmentid } AND CollectTime &lt;= #{ startTime } AND Oporation in ('0','1','2','3') ORDER BY CollectTime ASC
+    </select>
+</mapper>
\ No newline at end of file
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 4e7d0b7..6ffa4dd 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
@@ -42,4 +42,48 @@
         ORDER BY t4.equipment_name ASC, t1.EFFECTIVE_DATE ASC
     </select>
 
+
+    <select id="listByEquipmentAndDate" resultType="org.jeecg.modules.mdc.vo.MdcDeviceCalendarVo">
+        SELECT
+            t1.*,
+            t2.shift_name,
+            t3.shift_sub_name,
+            t3.start_date,
+            t3.end_date,
+            t3.sleep_start_date,
+            t3.sleep_end_date,
+            t3.is_day_span,
+            t4.equipment_name,
+            t4.equipment_id
+        FROM
+            mdc_device_calendar t1
+            LEFT JOIN mdc_shift t2 ON t1.shift_id = t2.id
+            LEFT JOIN mdc_shift_sub t3 ON t1.shift_sub_id = t3.id
+            LEFT JOIN mdc_equipment t4 ON t1.equment_id = t4.equipment_id
+        <where>
+            <if test="equipmentid != null and equipmentid != ''">
+                AND t4.equment_id = #{ equipmentid }
+            </if>
+            <if test="stringDate != null and stringDate != ''">
+                AND t1.effective_date = #{ stringDate }
+            </if>
+        </where>
+    </select>
+
+    <select id="findAcquiesceShift" resultType="org.jeecg.modules.mdc.vo.MdcDeviceCalendarVo">
+        SELECT
+            t1.shift_id shiftId,
+            t2.shift_sub_id shiftSubId,
+            t1.shift_name shiftName,
+            t2.shift_sub_name shiftSubName,
+            t2.start_date startDate,
+            t2.end_date endDate,
+            t2.sleep_start_date sleepStartDate,
+            t2.sleep_end_date sleepEndDate,
+            t2.is_day_span isDaySpan
+        FROM
+            mdc_shift t1 LEFT JOIN mdc_shift_sub t2 ON t1.shift_sub_id = t2.id
+        WHERE t1.default_shift = 'true'
+    </select>
+
 </mapper>
\ No newline at end of file
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml
index 8d0ef8f..a9566ea 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml
@@ -30,5 +30,18 @@
             start_time
     </select>
 
+    <!--璁$畻涓�娈垫椂闂村唴鐨勬暟鎹�-->
+    <select id="listEquipmentRunningSection" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection">
+        SELECT
+            *
+        FROM
+            mdc_equipment_running_section
+        WHERE
+            equipment_id = #{ equipmentId }
+            AND  (start_long &lt;= #{ endLong } AND end_long &gt;= #{ startLong })
+        ORDER BY
+            start_time
+    </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
new file mode 100644
index 0000000..4168205
--- /dev/null
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalShiftInfoMapper.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.mdc.mapper.MdcEquipmentStatisticalShiftInfoMapper">
+
+
+    <select id="getMaxStaticsData" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalShiftInfo">
+        SELECT TOP 1 * FROM mdc_equipment_statistical_shift_info WHERE equipment_id = #{equipmentId} ORDER BY the_date DESC
+    </select>
+</mapper>
\ No newline at end of file
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IEquipmentLogService.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IEquipmentLogService.java
index cb204ac..8b0ea87 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IEquipmentLogService.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IEquipmentLogService.java
@@ -21,4 +21,9 @@
      * 鏌ヨ鏌愪釜璁惧鏌愪釜鏃堕棿鐐逛箣鍚庣殑鏁版嵁(鎶ヨ鏁版嵁)
      */
     List<EquipmentLog> findEquipmentLogByErrorEndTime(String equipmentId, Date endTime);
+
+    /**
+     * 鑾峰彇璁惧鏌愪釜鏃堕棿鐐逛箣鍚庣殑鏈�鏂颁竴鏉℃暟鎹�
+     */
+    EquipmentLog getRow(String equipmentid, Date startTime);
 }
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 dcaa656..659ea8d 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
@@ -8,11 +8,13 @@
 import org.jeecg.modules.mdc.vo.MdcDeviceCalendarVo;
 
 import javax.servlet.http.HttpServletRequest;
+import java.util.Date;
+import java.util.List;
 
 /**
  * @Description: 璁惧宸ヤ綔鏃ュ巻琛�
  * @Author: jeecg-boot
- * @Date:   2023-04-10
+ * @Date: 2023-04-10
  * @Version: V1.0
  */
 public interface IMdcDeviceCalendarService extends IService<MdcDeviceCalendar> {
@@ -27,4 +29,12 @@
      */
     boolean saveCalendar(EquipmentCalendarVo calendarVo);
 
+    /**
+     * 鏌ヨ鐝埗鏁版嵁
+     *
+     * @param equipmentid
+     * @param stringDates
+     * @return
+     */
+    List<MdcDeviceCalendarVo> listByEquipmentAndDate(String equipmentid, List<String> stringDates);
 }
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentRunningSectionService.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentRunningSectionService.java
index b4fa460..35e2297 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentRunningSectionService.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentRunningSectionService.java
@@ -12,7 +12,7 @@
 /**
  * @Description: 璁惧杩愯鏃舵鐘舵�佽〃
  * @Author: LiuS
- * @Date:   2023-04-13
+ * @Date: 2023-04-13
  * @Version: V1.0
  */
 public interface IMdcEquipmentRunningSectionService extends IService<MdcEquipmentRunningSection> {
@@ -38,8 +38,17 @@
     List<MdcEquipmentRunningSection> listForEquipmentStatisticalInfo(String equipmentId, Date startDate, Date endDate);
 
     /**
-     *  鏌ヨ璁惧鍘嗗彶杩愯鐘舵�佽褰曟暟鎹�
+     * 鏌ヨ璁惧鍘嗗彶杩愯鐘舵�佽褰曟暟鎹�
      */
     List<Map<String, Object>> logChart(MdcEquipmentRunningSectionVo equipmentRunningSectionVo);
 
+    /**
+     * 璁$畻涓�娈垫椂闂村唴鐨勬暟鎹�
+     */
+    List<MdcEquipmentRunningSection> listEquipmentRunningSection(String equipmentid, long start, long end);
+
+    /**
+     * 鏌ヨ鏌愪釜璁惧涓�娈垫椂闂村唴鐨勬暟鎹�
+     */
+    List<MdcEquipmentRunningSection> listRunningSectionFromLog(String equipmentid, long start, long end);
 }
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentStatisticalInfoService.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentStatisticalInfoService.java
index 2ccf4dc..51473ea 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentStatisticalInfoService.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentStatisticalInfoService.java
@@ -5,7 +5,7 @@
 
 /**
  * @Description: 璁惧鍗曟棩杩愯鏁版嵁琛�
- * @Author: jeecg-boot
+ * @Author: lius
  * @Date: 2023-04-14
  * @Version: V1.0
  */
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
new file mode 100644
index 0000000..1a5a86e
--- /dev/null
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentStatisticalShiftInfoService.java
@@ -0,0 +1,19 @@
+package org.jeecg.modules.mdc.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalShiftInfo;
+
+/**
+ * @Description: 璁惧鍗曟棩鐝杩愯鏁版嵁琛�
+ * @author: LiuS
+ * @create: 2023-07-24 10:32
+ */
+public interface IMdcEquipmentStatisticalShiftInfoService extends IService<MdcEquipmentStatisticalShiftInfo> {
+
+    /**
+     * 璁$畻璁惧鍗曟棩鐝杩愯鏁版嵁
+     *
+     * @param dateTime
+     */
+    void runningAllEquipmentShiftStatisticalProcess(String dateTime);
+}
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/EquipmentLogServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/EquipmentLogServiceImpl.java
index dacfa5a..fe8e18b 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/EquipmentLogServiceImpl.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/EquipmentLogServiceImpl.java
@@ -43,4 +43,9 @@
         lambdaQuery.orderByAsc(EquipmentLog::getCollectTime);
         return lambdaQuery.list();
     }
+
+    @Override
+    public EquipmentLog getRow(String equipmentid, Date startTime) {
+        return this.baseMapper.getRow(equipmentid, startTime);
+    }
 }
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 afb0a78..57dce4e 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
@@ -132,6 +132,40 @@
     }
 
     /**
+     * 鏌ヨ鐝埗鏁版嵁
+     *
+     * @param equipmentid
+     * @param stringDates
+     * @return
+     */
+    @Override
+    public List<MdcDeviceCalendarVo> listByEquipmentAndDate(String equipmentid, List<String> stringDates) {
+        List<MdcDeviceCalendarVo> result = new ArrayList<>();
+        try {
+            //鏌ヨ榛樿鐝埗
+            List<MdcDeviceCalendarVo> acquiesceShift = this.baseMapper.findAcquiesceShift();
+
+            for (String stringDate : stringDates) {
+                List<MdcDeviceCalendarVo> mdcDeviceCalendarVos = this.baseMapper.listByEquipmentAndDate(equipmentid, stringDate);
+                if (mdcDeviceCalendarVos != null && !mdcDeviceCalendarVos.isEmpty()) {
+                    result.addAll(mdcDeviceCalendarVos);
+                } else {
+                    acquiesceShift.forEach(mdcDeviceCalendarVo -> {
+                        mdcDeviceCalendarVo.setEquipmentId(equipmentid);
+                        mdcDeviceCalendarVo.setEffectiveDate(stringDate);
+                    });
+                    // 璁剧疆榛樿鐝埗
+                    result.addAll(acquiesceShift);
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return result;
+    }
+
+    /**
      * 鑾峰彇涓�娈垫椂闂磋寖鍥村唴绗﹀悎鏄熸湡鍑犵殑鏃ユ湡闆嗗悎
      *
      * @param startDate 寮�濮嬫椂闂�
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java
index 865fa7e..afefa7a 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java
@@ -519,8 +519,68 @@
         return result;
     }
 
+    /**
+     * 璁$畻涓�娈垫椂闂村唴鐨勬暟鎹�
+     */
+    @Override
+    public List<MdcEquipmentRunningSection> listEquipmentRunningSection(String equipmentid, long start, long end) {
+        return this.baseMapper.listEquipmentRunningSection(equipmentid, start, end);
+    }
+
+    @Override
+    public List<MdcEquipmentRunningSection> listRunningSectionFromLog(String equipmentid, long start, long end) {
+        if (StringUtils.isBlank(equipmentid) || start <= 0 || end <= 0) {
+            return null;
+        }
+        Date startTime = DateUtils.toDate(DateUtils.longToDate(start), DateUtils.STR_DATE_TIME_SMALL);
+        Date endTime = DateUtils.toDate(DateUtils.longToDate(end), DateUtils.STR_DATE_TIME_SMALL);
+        EquipmentLog equipmentLog = equipmentLogService.getRow(equipmentid, startTime);
+        if (equipmentLog == null) {
+            return null;
+        }
+        List<EquipmentLog> logList = new ArrayList<>();
+        EquipmentLog equipmentOne = new EquipmentLog();
+        equipmentOne.setEquipmentId(equipmentid);
+        equipmentOne.setOporation(equipmentLog.getOporation());
+        equipmentOne.setCollectTime(startTime);
+        logList.add(equipmentOne);
+        List<EquipmentLog> logListLast = equipmentLogService.findEquipmentLogByEndTime(equipmentid, startTime);
+        if (logListLast == null || logListLast.isEmpty()) {
+            EquipmentLog two = new EquipmentLog();
+            two.setEquipmentId(equipmentid);
+            two.setOporation(equipmentLog.getOporation());
+            two.setCollectTime(endTime);
+            logList.add(two);
+        } else {
+            for (EquipmentLog log : logListLast) {
+                if (log.getCollectTime().getTime() <= endTime.getTime()) {
+                    logList.add(log);
+                }
+            }
+        }
+        if (logList.get(logList.size() - 1).getCollectTime().getTime() < endTime.getTime()) {
+            EquipmentLog two = new EquipmentLog();
+            two.setEquipmentId(equipmentid);
+            two.setOporation(logList.get(logList.size() - 1).getOporation());
+            two.setCollectTime(endTime);
+            logList.add(two);
+        }
+        //鐐规暟鎹浆涓烘鏁版嵁
+        List<MdcEquipmentRunningSection> erts = parseLogToRunningTrace(logList);
+        if (erts.isEmpty()) {
+            return Collections.emptyList();
+        }
+        //鏁村悎鍔犲伐鍜屽緟鏈烘椂闂村皬浜巒绉掔殑鏁版嵁
+        erts = mergeLessMinTimeRecords(erts, null);
+        List<MdcEquipmentRunningSection> running = mergeRunningTrace(erts);
+        if (running != null || !running.isEmpty()) {
+            this.ergodicTrim(running);
+        }
+        return running;
+    }
+
     private Map<String, List<MdcEquipmentRunningSectionDto>> logCharts(MdcEquipmentRunningSectionVo equipmentRunningSectionVo, String date) {
-        Map<String, List<MdcEquipmentRunningSectionDto>> map = new  HashMap<>();
+        Map<String, List<MdcEquipmentRunningSectionDto>> map = new HashMap<>();
         List<MdcEquipmentRunningSectionDto> normal = new ArrayList<>();
         List<MdcEquipmentRunningSectionDto> waring = new ArrayList<>();
         //杩愯
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalInfoServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalInfoServiceImpl.java
index 232c828..7d337b3 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalInfoServiceImpl.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalInfoServiceImpl.java
@@ -22,7 +22,7 @@
 
 /**
  * @Description: 璁惧鍗曟棩杩愯鏁版嵁琛�
- * @Author: jeecg-boot
+ * @Author: lius
  * @Date: 2023-04-14
  * @Version: V1.0
  */
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
new file mode 100644
index 0000000..9b9c7dc
--- /dev/null
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalShiftInfoServiceImpl.java
@@ -0,0 +1,368 @@
+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.apache.commons.lang.StringUtils;
+import org.jeecg.modules.mdc.entity.Equipment;
+import org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection;
+import org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalShiftInfo;
+import org.jeecg.modules.mdc.mapper.MdcEquipmentStatisticalShiftInfoMapper;
+import org.jeecg.modules.mdc.service.IEquipmentService;
+import org.jeecg.modules.mdc.service.IMdcDeviceCalendarService;
+import org.jeecg.modules.mdc.service.IMdcEquipmentRunningSectionService;
+import org.jeecg.modules.mdc.service.IMdcEquipmentStatisticalShiftInfoService;
+import org.jeecg.modules.mdc.util.DateUtils;
+import org.jeecg.modules.mdc.vo.MdcDeviceCalendarVo;
+import org.jeecg.modules.mdc.vo.MdcShiftDateVo;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * @Description: 璁惧鍗曟棩鐝杩愯鏁版嵁琛�
+ * @author: LiuS
+ * @create: 2023-07-24 11:19
+ */
+@Service
+public class MdcEquipmentStatisticalShiftInfoServiceImpl extends ServiceImpl<MdcEquipmentStatisticalShiftInfoMapper, MdcEquipmentStatisticalShiftInfo> implements IMdcEquipmentStatisticalShiftInfoService {
+
+    @Resource
+    private IEquipmentService equipmentService;
+
+    @Resource
+    private IMdcEquipmentRunningSectionService mdcEquipmentRunningSectionService;
+
+    @Resource
+    private IMdcDeviceCalendarService mdcDeviceCalendarService;
+
+    /**
+     * 璁$畻璁惧鍗曟棩鐝杩愯鏁版嵁
+     *
+     * @param dateTime
+     */
+    @Override
+    @Transactional(rollbackFor = {Exception.class})
+    public void runningAllEquipmentShiftStatisticalProcess(String dateTime) {
+        if (StringUtils.isNotBlank(dateTime)) {
+            try {
+                Date initDate = DateUtils.toDate(dateTime, "yyyyMMdd");
+                if (initDate != null) {
+                    this.remove(new LambdaQueryWrapper<MdcEquipmentStatisticalShiftInfo>().eq(MdcEquipmentStatisticalShiftInfo::getTheDate, dateTime));
+                }
+            } catch (Exception e) {
+                log.error("鍙傛暟鏍煎紡涓嶅", e);
+            }
+        }
+        List<Equipment> equipmentList = equipmentService.list();
+        List<MdcEquipmentStatisticalShiftInfo> result = new ArrayList<>();
+        for (Equipment equipment : equipmentList) {
+            List<MdcEquipmentStatisticalShiftInfo> equipmentStatisticalShiftInfoList = equipmentShiftStatisticalProcess(equipment, dateTime);
+            if (equipmentStatisticalShiftInfoList != null && !equipmentStatisticalShiftInfoList.isEmpty()) {
+                result.addAll(equipmentStatisticalShiftInfoList);
+            }
+        }
+        if (!result.isEmpty()) {
+            this.saveBatch(result);
+        }
+    }
+
+    @Transactional(readOnly = true)
+    List<MdcEquipmentStatisticalShiftInfo> equipmentShiftStatisticalProcess(Equipment equipment, String dateTime) {
+        Date initDate = null;
+        //鍙栨渶鍚庣殑缁熻鏁版嵁
+        if (StringUtils.isBlank(dateTime)) {
+            MdcEquipmentStatisticalShiftInfo nearestDate = this.baseMapper.getMaxStaticsData(equipment.getEquipmentid());
+            if (nearestDate != null) {
+                initDate = DateUtils.toDate(nearestDate.getTheDate(), "yyyyMMdd");
+                initDate = DateUtils.plusTime(initDate, 1);
+            } else {
+                //鍒濇鍙栧�� 鍙栨渶鏃╂椂闂�
+                MdcEquipmentRunningSection equipmentRunningSection = mdcEquipmentRunningSectionService.getFirstData(equipment.getEquipmentid());
+                if (equipmentRunningSection != null) {
+                    initDate = equipmentRunningSection.getStartTime();
+                }
+            }
+        } else {
+            try {
+                initDate = DateUtils.toDate(dateTime, "yyyyMMdd");
+                initDate = DateUtils.plusTime(initDate, 0);
+            } catch (Exception e) {
+                log.error("鍙傛暟鏍煎紡涓嶅", null);
+                return null;
+            }
+        }
+        if (initDate == null) {
+            return null;
+        }
+        Date endDate = DateUtils.plusTime(DateUtils.getNow(), 0);
+        if (!DateUtils.less(initDate, endDate)) {
+            return Collections.emptyList();
+        }
+        //鑾峰彇涓や釜鏃堕棿娈电殑宸�
+        List<String> stringDates = DateUtils.getDatesStringList2(initDate, DateUtils.plusTime(endDate, -1));
+        if (stringDates.isEmpty()) {
+            return Collections.emptyList();
+        }
+        //鏌ヨ鐝埗鐝淇℃伅
+        Map<String, List<MdcDeviceCalendarVo>> listMap = this.mdcDeviceCalendarMap(equipment.getEquipmentid(), stringDates);
+        if (listMap.isEmpty()) {
+            listMap = new HashMap<>();
+        }
+        List<MdcEquipmentStatisticalShiftInfo> resultList = new ArrayList<>();
+        for (String stringDate : stringDates) {
+            if (listMap.containsKey(stringDate)) {
+                List<MdcDeviceCalendarVo> mdcDeviceCalendarVos = listMap.get(stringDate);
+                for (MdcDeviceCalendarVo mdcDeviceCalendarVo : mdcDeviceCalendarVos) {
+                    //鐝埗鐝鏃堕棿闆嗗悎
+                    List<MdcShiftDateVo> datesListByMdcDeviceCalendarVo = this.getDatesListByMdcDeviceCalendarVo(mdcDeviceCalendarVo);
+                    if (datesListByMdcDeviceCalendarVo == null || datesListByMdcDeviceCalendarVo.isEmpty()) {
+                        break;
+                    }
+                    //鍚堝苟
+                    MdcEquipmentStatisticalShiftInfo equipmentStatisticalShiftInfo = new MdcEquipmentStatisticalShiftInfo();
+                    equipmentStatisticalShiftInfo.setEquipmentId(equipment.getEquipmentid());
+                    //澶勭悊鏃堕棿
+                    Date date = DateUtils.strToDate(stringDate, DateUtils.STRDATE);
+                    equipmentStatisticalShiftInfo.setTheDate(DateUtils.format(date, DateUtils.STRDATE));
+                    equipmentStatisticalShiftInfo.setShiftId(mdcDeviceCalendarVo.getShiftId());
+                    equipmentStatisticalShiftInfo.setShiftSubId(mdcDeviceCalendarVo.getShiftSubId());
+                    equipmentStatisticalShiftInfo.setCreateTime(new Date());
+                    for (MdcShiftDateVo dates : datesListByMdcDeviceCalendarVo) {
+                        //澶勭悊鏁版嵁
+                        MdcEquipmentStatisticalShiftInfo shiftInfo = this.selectRunningEquipment(dates, equipment.getEquipmentid());
+                        equipmentStatisticalShiftInfo.setWaitLong(equipmentStatisticalShiftInfo.getWaitLong().add(shiftInfo.getWaitLong()));
+                        equipmentStatisticalShiftInfo.setProcessLong(equipmentStatisticalShiftInfo.getProcessLong().add(shiftInfo.getProcessLong()));
+                        equipmentStatisticalShiftInfo.setCloseLong(equipmentStatisticalShiftInfo.getCloseLong().add(shiftInfo.getCloseLong()));
+                        equipmentStatisticalShiftInfo.setOpenLong(equipmentStatisticalShiftInfo.getOpenLong().add(shiftInfo.getOpenLong()));
+                        equipmentStatisticalShiftInfo.setErrorLong(equipmentStatisticalShiftInfo.getErrorLong().add(shiftInfo.getErrorLong()));
+                    }
+                }
+            }
+        }
+        return resultList;
+    }
+
+    /**
+     * 鏌ヨ鏌愪竴澶╂煇涓彮娆$殑鏁版嵁
+     *
+     * @param dates
+     * @param equipmentid
+     * @return
+     */
+    private MdcEquipmentStatisticalShiftInfo selectRunningEquipment(MdcShiftDateVo dates, String equipmentid) {
+        if (dates == null || StringUtils.isBlank(equipmentid)) {
+            return null;
+        }
+        //涓嶈繃婊や紤鐝拰缁翠慨
+        //鑾峰彇鐝鏃堕棿娈靛唴鏁版嵁
+        List<MdcEquipmentRunningSection> sectionList = mdcEquipmentRunningSectionService.listEquipmentRunningSection(equipmentid, dates.getStart(), dates.getEnd());
+        //鏌ヨ鏃犳暟鎹渶瑕丒quipmentLog瑙f瀽
+        if (sectionList.isEmpty()) {
+            sectionList = mdcEquipmentRunningSectionService.listRunningSectionFromLog(equipmentid, dates.getStart(), dates.getEnd());
+        }
+        if (sectionList == null || sectionList.isEmpty()) {
+            sectionList = new ArrayList<>();
+        }
+        //澶勭悊鏁版嵁
+        long datesStart = dates.getStart();
+        long datesEnd = dates.getEnd();
+        for (int i = 0; i < sectionList.size(); i++) {
+            MdcEquipmentRunningSection equipmentRunningSection = sectionList.get(i);
+            long start = equipmentRunningSection.getStartTime().getTime();
+            long end = equipmentRunningSection.getEndTime().getTime();
+            if (datesStart <= start) {
+                equipmentRunningSection.setStartTime(equipmentRunningSection.getStartTime());
+            } else {
+                equipmentRunningSection.setStartTime(dates.getStartDate());
+            }
+            if (datesEnd >= end) {
+                equipmentRunningSection.setEndTime(equipmentRunningSection.getEndTime());
+            } else {
+                equipmentRunningSection.setEndTime(dates.getEndDate());
+            }
+            Long sen = DateUtils.differentSecond(equipmentRunningSection.getStartTime(), equipmentRunningSection.getEndTime());
+            if (sen <= 0) {
+                sectionList.remove(i);
+                i--;
+            } else {
+                equipmentRunningSection.setDuration(sen);
+                equipmentRunningSection.setStartLong(equipmentRunningSection.getStartTime().getTime());
+                equipmentRunningSection.setEndLong(equipmentRunningSection.getEndTime().getTime());
+            }
+        }
+        MdcEquipmentStatisticalShiftInfo shiftInfo = new MdcEquipmentStatisticalShiftInfo();
+        shiftInfo.setEquipmentId(equipmentid);
+        shiftInfo.setShiftId(dates.getShiftId());
+        shiftInfo.setShiftSubId(dates.getShiftSubId());
+        shiftInfo.setTheDate(dates.getDay());
+        long waitLong = 0L;
+        long processLong = 0L;
+        long closeLong = 0L;
+        long errorLong = 0L;
+        for (MdcEquipmentRunningSection equipmentRunningSection : sectionList) {
+            Long duration = equipmentRunningSection.getDuration();
+            int status = equipmentRunningSection.getStatus();
+            if (status == 2) {
+                waitLong += duration;
+            }
+            if (status == 3) {
+                processLong += duration;
+            }
+            if (status == 0) {
+                closeLong += duration;
+            }
+            if (status == 22) {
+                errorLong += duration;
+            }
+        }
+        shiftInfo.setWaitLong(new BigDecimal(waitLong));
+        shiftInfo.setProcessLong(new BigDecimal(processLong));
+        shiftInfo.setCloseLong(new BigDecimal(closeLong));
+        //寮�鏈烘椂闂磋绠椾负 鏈夋晥鏃堕暱 - 鍏虫満鏃堕暱
+        shiftInfo.setOpenLong(new BigDecimal((datesEnd - datesStart) / 1000).subtract(shiftInfo.getCloseLong()));
+        shiftInfo.setErrorLong(new BigDecimal(errorLong));
+
+        return shiftInfo;
+    }
+
+    /**
+     * 鏃堕棿闂澶勭悊 濡傛灉褰撳ぉ鏈�鏈熬鏃堕棿澶т簬褰撳墠鏃堕棿 杩斿洖0
+     *
+     * @param temp
+     * @return
+     */
+    private List<MdcShiftDateVo> getDatesListByMdcDeviceCalendarVo(MdcDeviceCalendarVo temp) {
+        List<MdcShiftDateVo> result = new ArrayList<>();
+        String startDateStr = temp.getStartDate();
+        String endDateStr = temp.getEndDate();
+        String sleepStartDateStr = temp.getSleepStartDate();
+        String sleepEndDateStr = temp.getSleepEndDate();
+        String effectiveDateStr = temp.getEffectiveDate();
+        String eff = DateUtils.format(DateUtils.toDate(effectiveDateStr, DateUtils.STRDATE), DateUtils.STR_DATE);
+        try {
+            Date effectiveDate = new SimpleDateFormat("yyyyMMdd").parse(effectiveDateStr);
+            long startDate = getLongDate(effectiveDate, startDateStr, "false");
+            long endDate = getLongDate(effectiveDate, endDateStr, temp.getIsDaySpan());
+            //澶勭悊鏈�鍚庣殑鏃堕棿闂 鏄惁瓒呰繃褰撳墠鏃堕棿 濡傛灉瓒呰繃涓嶅垪鍏ヨ绠� BUG
+            Date endTime = null;
+            if ("true".equals(temp.getIsDaySpan())) {
+                Date day = DateUtils.toDate(effectiveDateStr, DateUtils.STRDATE);
+                day = DateUtils.plusTime(day, 1);
+                String dayTime = DateUtils.format(day, DateUtils.STR_DATE);
+                endTime = DateUtils.toDate(dayTime + " " + temp.getEndDate(), DateUtils.STR_DATE_TIME_SMALL);
+            } else {
+                Date day = DateUtils.toDate(effectiveDateStr, DateUtils.STRDATE);
+                String dayTime = DateUtils.format(day, DateUtils.STR_DATE);
+                endTime = DateUtils.toDate(dayTime + " " + temp.getEndDate(), DateUtils.STR_DATE_TIME_SMALL);
+            }
+            if (endTime.getTime() > DateUtils.getNow().getTime()) {
+                return null;
+            }
+            if (StringUtils.isNotEmpty(sleepStartDateStr)) {
+                long sleepStartDate = getLongDate(effectiveDate, sleepStartDateStr, "false");
+                long sleepEndDate = getLongDate(effectiveDate, sleepEndDateStr, "false");
+                Date start1 = DateUtils.getFormatDate(eff + " " + startDateStr, DateUtils.STR_DATE_TIME_SMALL);
+                Date end1 = DateUtils.getFormatDate(eff + " " + sleepStartDateStr, DateUtils.STR_DATE_TIME_SMALL);
+                Date start2 = DateUtils.getFormatDate(eff + " " + sleepEndDateStr, DateUtils.STR_DATE_TIME_SMALL);
+                Date end2 = DateUtils.getFormatDate(eff + " " + endDateStr, DateUtils.STR_DATE_TIME_SMALL);
+                if ("true".equals(temp.getIsDaySpan())) {
+                    //璺ㄥぉ 鍒ゆ柇鐝寮�濮嬫椂闂村拰缁撴潫鏃堕棿鏄惁璺ㄥぉ
+                    if (startDateStr.compareTo(endDateStr) < 0) {
+                        //鐝寮�濮嬫椂闂村拰缁撴潫鏃堕棿閮借法澶�
+                        startDate = getLongDate(effectiveDate, startDateStr, temp.getIsDaySpan());
+                        start1 = DateUtils.addDays(start1, 1);
+                        end2 = DateUtils.addDays(end2, 1);
+                        //鐝寮�濮嬫椂闂村拰缁撴潫鏃堕棿閮借法澶� 浼戞伅寮�濮嬫椂闂村拰缁撴潫鏃堕棿涔熶竴瀹氳法澶�
+                        sleepStartDate = getLongDate(effectiveDate, sleepStartDateStr, temp.getIsDaySpan());
+                        end1 = DateUtils.addDays(end1, 1);
+                        sleepEndDate = getLongDate(effectiveDate, sleepEndDateStr, temp.getIsDaySpan());
+                        start2 = DateUtils.addDays(start2, 1);
+                    } else {
+                        //鐝寮�濮嬫椂闂翠笉璺ㄥぉ锛� 缁撴潫鏃堕棿璺ㄥぉ
+                        end2 = DateUtils.addDays(end2, 1);
+                        //鍒ゆ柇浼戞伅寮�濮嬫椂闂存槸鍚﹁法澶�
+                        if (startDateStr.compareTo(sleepStartDateStr) > 0) {
+                            //寮�濮嬩紤鎭椂闂磋法澶╋紝 缁撴潫浼戞伅鏃堕棿涔熶竴瀹氳法澶�
+                            sleepStartDate = getLongDate(effectiveDate, sleepStartDateStr, temp.getIsDaySpan());
+                            end1 = DateUtils.addDays(end1, 1);
+                            sleepEndDate = getLongDate(effectiveDate, sleepEndDateStr, temp.getIsDaySpan());
+                            start2 = DateUtils.addDays(start2, 1);
+                        } else {
+                            //浼戞伅寮�濮嬫椂闂翠笉璺ㄥぉ, 鍒ゆ柇浼戞伅缁撴潫鏃堕棿鏄惁璺ㄥぉ
+                            if (sleepStartDateStr.compareTo(sleepEndDateStr) > 0) {
+                                //浼戞伅缁撴潫鏃堕棿璺ㄥぉ
+                                sleepEndDate = getLongDate(effectiveDate, sleepEndDateStr, temp.getIsDaySpan());
+                                start2 = DateUtils.addDays(start2, 1);
+                            }
+                        }
+                    }
+
+                }
+                MdcShiftDateVo dates1 = new MdcShiftDateVo(temp.getShiftId(), temp.getShiftSubId(), startDate, sleepStartDate, effectiveDateStr, endTime, start1, end1);
+                result.add(dates1);
+                MdcShiftDateVo dates2 = new MdcShiftDateVo(temp.getShiftId(), temp.getShiftSubId(), sleepEndDate, endDate, effectiveDateStr, endTime, start2, end2);
+                result.add(dates2);
+            } else {
+                /*鑾峰彇鐝鐨勫紑濮嬫椂闂寸粨鏉熸椂闂�*/
+                Date start = DateUtils.getFormatDate(eff + " " + startDateStr, DateUtils.STR_DATE_TIME_SMALL);
+                Date end = DateUtils.getFormatDate(eff + " " + endDateStr, DateUtils.STR_DATE_TIME_SMALL);
+                if ("true".equals(temp.getIsDaySpan())) {
+                    if (startDateStr.compareTo(endDateStr) < 0) {
+                        startDate = getLongDate(effectiveDate, startDateStr, temp.getIsDaySpan());
+                        start = DateUtils.addDays(start, 1);
+                    }
+                    end = DateUtils.addDays(end, 1);
+                }
+                MdcShiftDateVo dates = new MdcShiftDateVo(temp.getShiftId(), temp.getShiftSubId(), startDate, endDate, effectiveDateStr, endTime, start, end);
+                result.add(dates);
+            }
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return result;
+    }
+
+    /**
+     * 璁惧鐝杞崲
+     *
+     * @param equipmentid
+     * @param stringDates
+     * @return
+     */
+    private Map<String, List<MdcDeviceCalendarVo>> mdcDeviceCalendarMap(String equipmentid, List<String> stringDates) {
+        List<MdcDeviceCalendarVo> mdcDeviceCalendarVos = mdcDeviceCalendarService.listByEquipmentAndDate(equipmentid, stringDates);
+        if (mdcDeviceCalendarVos.isEmpty()) {
+            return null;
+        }
+        Map<String, List<MdcDeviceCalendarVo>> map = new HashMap<>();
+        for (MdcDeviceCalendarVo mdcDeviceCalendarVo : mdcDeviceCalendarVos) {
+            List<MdcDeviceCalendarVo> mdcDeviceCalendarVos1;
+            if (map.containsKey(mdcDeviceCalendarVo.getEffectiveDate())) {
+                mdcDeviceCalendarVos1 = map.get(mdcDeviceCalendarVo.getEffectiveDate());
+            } else {
+                mdcDeviceCalendarVos1 = new ArrayList<>();
+            }
+            mdcDeviceCalendarVos1.add(mdcDeviceCalendarVo);
+            map.put(mdcDeviceCalendarVo.getEffectiveDate(), mdcDeviceCalendarVos1);
+        }
+        return map;
+    }
+
+    private long getLongDate(Date effectiveDate, String startDateStr, String isDaySpan) {
+        String[] startDateArray = startDateStr.split(":");
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(effectiveDate);
+        cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(startDateArray[0]));
+        cal.set(Calendar.MINUTE, Integer.parseInt(startDateArray[1]));
+        cal.set(Calendar.SECOND, Integer.parseInt(startDateArray[2]));
+        if ("true".equals(isDaySpan)) {
+            cal.add(Calendar.DAY_OF_YEAR, 1);
+        }
+        return cal.getTime().getTime();
+    }
+}
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/MdcShiftDateVo.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/MdcShiftDateVo.java
new file mode 100644
index 0000000..a9b4f6a
--- /dev/null
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/MdcShiftDateVo.java
@@ -0,0 +1,106 @@
+package org.jeecg.modules.mdc.vo;
+
+
+import java.util.Date;
+
+/**
+ * @author: LiuS
+ * @create: 2023-07-25 10:32
+ */
+public class MdcShiftDateVo {
+
+    private String shiftId;
+
+    private String shiftSubId;
+
+    private long start;
+
+    private long end;
+
+    private String day;
+
+    private Date endTime;
+    /**
+     * 寮�濮嬫椂闂�
+     */
+    private Date startDate;
+    /**
+     * 缁撴潫鏃堕棿
+     */
+    private Date endDate;
+
+    public String getShiftId() {
+        return shiftId;
+    }
+
+    public void setShiftId(String shiftId) {
+        this.shiftId = shiftId;
+    }
+
+    public String getShiftSubId() {
+        return shiftSubId;
+    }
+
+    public void setShiftSubId(String shiftSubId) {
+        this.shiftSubId = shiftSubId;
+    }
+
+    public long getStart() {
+        return start;
+    }
+
+    public void setStart(long start) {
+        this.start = start;
+    }
+
+    public long getEnd() {
+        return end;
+    }
+
+    public void setEnd(long end) {
+        this.end = end;
+    }
+
+    public String getDay() {
+        return day;
+    }
+
+    public void setDay(String day) {
+        this.day = day;
+    }
+
+    public Date getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(Date endTime) {
+        this.endTime = endTime;
+    }
+
+    public Date getStartDate() {
+        return startDate;
+    }
+
+    public void setStartDate(Date startDate) {
+        this.startDate = startDate;
+    }
+
+    public Date getEndDate() {
+        return endDate;
+    }
+
+    public void setEndDate(Date endDate) {
+        this.endDate = endDate;
+    }
+
+    public MdcShiftDateVo(String shiftId, String shiftSubId, long start, long end, String day, Date endTime, Date startDate, Date endDate) {
+        this.shiftId = shiftId;
+        this.shiftSubId = shiftSubId;
+        this.start = start;
+        this.end = end;
+        this.day = day;
+        this.endTime = endTime;
+        this.startDate = startDate;
+        this.endDate = endDate;
+    }
+}

--
Gitblit v1.9.3