Browse Source

日报表导出

丁治程 8 months ago
parent
commit
c092d3f567
15 changed files with 241 additions and 30 deletions
  1. 1 1
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/controller/InterlockDetailHistoryController.java
  2. 7 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/mapper/InterlockDetailHistoryMapper.java
  3. 2 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/mapper/InterlockSummaryHistoryMapper.java
  4. 104 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/mapper/xml/InterlockDetailHistoryMapper.xml
  5. 35 6
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/mapper/xml/InterlockSummaryHistoryMapper.xml
  6. 8 1
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/quartz/ReportJob.java
  7. 14 7
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/quartz/ReportJobDay.java
  8. 1 1
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/quartz/ReportJobMonth.java
  9. 1 1
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/quartz/ReportJobYear.java
  10. 1 1
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/service/IInterlockDetailHistoryService.java
  11. 57 12
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/service/impl/InterlockDetailHistoryServiceImpl.java
  12. 1 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/summary/mapper/InterlockSummaryMapper.java
  13. 3 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/summary/mapper/xml/InterlockSummaryMapper.xml
  14. 1 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/summary/service/IInterlockSummaryService.java
  15. 5 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/summary/service/impl/InterlockSummaryServiceImpl.java

+ 1 - 1
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/controller/InterlockDetailHistoryController.java

@@ -90,7 +90,7 @@ public class InterlockDetailHistoryController extends JeecgController<InterlockD
 
 	 	Workbook workbook = new XSSFWorkbook();
 	 	try {
-	 		workbook = interlockDetailHistoryService.exportXlsToFile(dto, zzxtvoList, InterlockSummaryHistoryVO.class);
+	 		workbook = interlockDetailHistoryService.exportXlsToFile(dto, zzxtvoList, InterlockSummaryHistoryVO.class,"1");
 	 	} catch (IOException e) {
 	 		e.printStackTrace();
 	 	}

+ 7 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/mapper/InterlockDetailHistoryMapper.java

@@ -62,4 +62,11 @@ public interface InterlockDetailHistoryMapper extends BaseMapper<InterlockDetail
     @Select("select * from interlock_user where username=#{wiseUser}")
     InterlockUser getUserInfoByName(@Param("wiseUser") String wiseUser);
 
+    List<String> getAllForExport(InterlockHistoryQueryDTO dto);
+
+    InterlockSummaryHistoryVO getOneInfoForExport(@Param("dto") InterlockHistoryQueryDTO dto,@Param("summaryOriginId") String summaryOriginId);
+
+    List<String> getAllForExport1(InterlockHistoryQueryDTO dto);
+
+    List<InterlockSummaryHistoryVO> getForExport1(InterlockHistoryQueryDTO dto);
 }

+ 2 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/mapper/InterlockSummaryHistoryMapper.java

@@ -51,4 +51,6 @@ public interface InterlockSummaryHistoryMapper extends BaseMapper<InterlockSumma
     *   date: 2024/6/18
     */
     List<InterlockCountDay> getYbStatusListByTagTime(@Param("yesterday") String yesterday);
+
+    List<InterlockHistoryDistinctZZXTVO> getDistinctZZXTSummaryList1(InterlockHistoryQueryDTO dto);
 }

+ 104 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/mapper/xml/InterlockDetailHistoryMapper.xml

@@ -230,4 +230,108 @@
         order by s.tag_time desc
     </select>
 
+
+    <select id="getAllForExport" resultType="java.lang.String">
+        select DISTINCT(s.summary_origin_id)
+        from interlock_detail_history d left join interlock_summary_history s on d.summaryid = s.id
+        left join interlock_base_hy h1 on h1.interlock_status = s.interlock_status and h1.interlock_system_id = s.interlock_system_id
+        left join interlock_base_hy h2 on h2.bypass = d.bypass and h2.interlock_system_id = s.interlock_system_id
+        left join interlock_base_hy h3 on h3.instrument_status = d.instrument_status and h3.interlock_system_id = s.interlock_system_id
+        left join interlock_base_hy h4 on h4.control_system_status = d.control_system_status and h4.interlock_system_id = s.interlock_system_id
+        <where>
+            <if test="interlockSystemId != null and interlockSystemId != ''"> and s.interlock_system_id =  #{interlockSystemId}</if>
+            <if test="interlockApparatusId != null and interlockApparatusId != ''"> and s.interlock_apparatus_id =  #{interlockApparatusId}</if>
+
+            <if test="interlockname != null and interlockname != ''"> and d.interlockname like concat('%', #{interlockname}, '%')</if>
+            <if test="interlockCondition != null and interlockCondition != ''"> and d.interlock_condition = #{interlockCondition}</if>
+            <if test="interlockConditionTag != null and interlockConditionTag != ''"> and d.interlock_condition_tag like concat('%',#{interlockConditionTag},'%')</if>
+            <if test="instrumentStatus != null and instrumentStatus != ''"> and d.instrument_status = #{instrumentStatus}</if>
+            <if test="controlSystemStatus != null and controlSystemStatus != ''"> and d.control_system_status = #{controlSystemStatus}</if>
+            <if test="interlockStatus != null and interlockStatus != ''"> and s.interlock_status = #{interlockStatus}</if>
+            <if test="loopHealthLevel != null and loopHealthLevel != ''"> and s.loop_health_level = #{loopHealthLevel}</if>
+            <if test="beginTime != null"> and s.tag_time &gt; #{beginTime} </if>
+            <if test="endTime != null"> and s.tag_time &lt; #{endTime} </if>
+        </where>
+    </select>
+
+    <select id="getOneInfoForExport" resultType="org.jeecg.modules.history.vo.InterlockSummaryHistoryVO">
+        select s.*
+        from
+        (
+            select d.id, d.summaryid, d.interlockname, d.interlock_condition, d.interlock_condition_tag, d.instrument_status, d.control_system_status,
+            s.interlock_status, s.loop_health_level, d.bypass, s.tag_time,
+            h1.interlock_status_name, h2.bypass_name,
+            h3.instrument_status_name, h4.control_system_status_name,
+            ROW_NUMBER() OVER (PARTITION BY s.summary_origin_id ORDER BY s.tag_time DESC) AS mm
+            from interlock_detail_history d left join interlock_summary_history s on d.summaryid = s.id
+            left join interlock_base_hy h1 on h1.interlock_status = s.interlock_status and h1.interlock_system_id = s.interlock_system_id
+            left join interlock_base_hy h2 on h2.bypass = d.bypass and h2.interlock_system_id = s.interlock_system_id
+            left join interlock_base_hy h3 on h3.instrument_status = d.instrument_status and h3.interlock_system_id = s.interlock_system_id
+            left join interlock_base_hy h4 on h4.control_system_status = d.control_system_status and h4.interlock_system_id = s.interlock_system_id
+            <where>
+                <if test="dto.interlockSystemId != null and dto.interlockSystemId != ''"> and s.interlock_system_id =  #{dto.interlockSystemId}</if>
+                <if test="dto.interlockApparatusId != null and dto.interlockApparatusId != ''"> and s.interlock_apparatus_id =  #{dto.interlockApparatusId}</if>
+
+                <if test="dto.interlockname != null and dto.interlockname != ''"> and d.interlockname like concat('%', #{dto.interlockname}, '%')</if>
+                <if test="dto.interlockCondition != null and dto.interlockCondition != ''"> and d.interlock_condition = #{dto.interlockCondition}</if>
+                <if test="dto.interlockConditionTag != null and dto.interlockConditionTag != ''"> and d.interlock_condition_tag like concat('%',#{dto.interlockConditionTag},'%')</if>
+                <if test="dto.instrumentStatus != null and dto.instrumentStatus != ''"> and d.instrument_status = #{dto.instrumentStatus}</if>
+                <if test="dto.controlSystemStatus != null and dto.controlSystemStatus != ''"> and d.control_system_status = #{dto.controlSystemStatus}</if>
+                <if test="dto.interlockStatus != null and dto.interlockStatus != ''"> and s.interlock_status = #{dto.interlockStatus}</if>
+                <if test="dto.loopHealthLevel != null and dto.loopHealthLevel != ''"> and s.loop_health_level = #{dto.loopHealthLevel}</if>
+                <if test="dto.beginTime != null"> and s.tag_time <![CDATA[ <= ]]> #{dto.beginTime} </if>
+                <if test="summaryOriginId != null and summaryOriginId != ''"> and s.summary_origin_id = #{summaryOriginId} </if>
+            </where>
+        ) s
+        where mm = 1
+    </select>
+
+    <select id="getAllForExport1" resultType="java.lang.String">
+        select DISTINCT(s.summary_origin_id)
+        from interlock_detail_history d left join interlock_summary_history s on d.summaryid = s.id
+        left join interlock_base_hy h1 on h1.interlock_status = s.interlock_status and h1.interlock_system_id = s.interlock_system_id
+        left join interlock_base_hy h2 on h2.bypass = d.bypass and h2.interlock_system_id = s.interlock_system_id
+        left join interlock_base_hy h3 on h3.instrument_status = d.instrument_status and h3.interlock_system_id = s.interlock_system_id
+        left join interlock_base_hy h4 on h4.control_system_status = d.control_system_status and h4.interlock_system_id = s.interlock_system_id
+        <where>
+            <if test="interlockSystemId != null and interlockSystemId != ''"> and s.interlock_system_id =  #{interlockSystemId}</if>
+            <if test="interlockApparatusId != null and interlockApparatusId != ''"> and s.interlock_apparatus_id =  #{interlockApparatusId}</if>
+
+            <if test="interlockname != null and interlockname != ''"> and d.interlockname like concat('%', #{interlockname}, '%')</if>
+            <if test="interlockCondition != null and interlockCondition != ''"> and d.interlock_condition = #{interlockCondition}</if>
+            <if test="interlockConditionTag != null and interlockConditionTag != ''"> and d.interlock_condition_tag like concat('%',#{interlockConditionTag},'%')</if>
+            <if test="instrumentStatus != null and instrumentStatus != ''"> and d.instrument_status = #{instrumentStatus}</if>
+            <if test="controlSystemStatus != null and controlSystemStatus != ''"> and d.control_system_status = #{controlSystemStatus}</if>
+            <if test="interlockStatus != null and interlockStatus != ''"> and s.interlock_status = #{interlockStatus}</if>
+            <if test="loopHealthLevel != null and loopHealthLevel != ''"> and s.loop_health_level = #{loopHealthLevel}</if>
+            <if test="beginTime != null"> and s.tag_time = #{beginTime} </if>
+        </where>
+    </select>
+
+    <select id="getForExport1" resultType="org.jeecg.modules.history.vo.InterlockSummaryHistoryVO">
+        select d.id, d.summaryid, d.interlockname, d.interlock_condition, d.interlock_condition_tag, d.instrument_status, d.control_system_status,
+        s.interlock_status, s.loop_health_level, d.bypass, s.tag_time,
+        h1.interlock_status_name, h2.bypass_name,
+        h3.instrument_status_name, h4.control_system_status_name
+        from interlock_detail_history d left join interlock_summary_history s on d.summaryid = s.id
+        left join interlock_base_hy h1 on h1.interlock_status = s.interlock_status and h1.interlock_system_id = s.interlock_system_id
+        left join interlock_base_hy h2 on h2.bypass = d.bypass and h2.interlock_system_id = s.interlock_system_id
+        left join interlock_base_hy h3 on h3.instrument_status = d.instrument_status and h3.interlock_system_id = s.interlock_system_id
+        left join interlock_base_hy h4 on h4.control_system_status = d.control_system_status and h4.interlock_system_id = s.interlock_system_id
+        <where>
+            <if test="interlockSystemId != null and interlockSystemId != ''"> and s.interlock_system_id =  #{interlockSystemId}</if>
+            <if test="interlockApparatusId != null and interlockApparatusId != ''"> and s.interlock_apparatus_id =  #{interlockApparatusId}</if>
+
+            <if test="interlockname != null and interlockname != ''"> and d.interlockname like concat('%', #{interlockname}, '%')</if>
+            <if test="interlockCondition != null and interlockCondition != ''"> and d.interlock_condition = #{interlockCondition}</if>
+            <if test="interlockConditionTag != null and interlockConditionTag != ''"> and d.interlock_condition_tag like concat('%',#{interlockConditionTag},'%')</if>
+            <if test="instrumentStatus != null and instrumentStatus != ''"> and d.instrument_status = #{instrumentStatus}</if>
+            <if test="controlSystemStatus != null and controlSystemStatus != ''"> and d.control_system_status = #{controlSystemStatus}</if>
+            <if test="interlockStatus != null and interlockStatus != ''"> and s.interlock_status = #{interlockStatus}</if>
+            <if test="loopHealthLevel != null and loopHealthLevel != ''"> and s.loop_health_level = #{loopHealthLevel}</if>
+            <if test="beginTime != null"> and s.tag_time = #{beginTime} </if>
+        </where>
+        order by s.tag_time desc
+    </select>
+
 </mapper>

+ 35 - 6
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/mapper/xml/InterlockSummaryHistoryMapper.xml

@@ -23,12 +23,12 @@
             <if test="controlSystemStatus != null and controlSystemStatus != ''"> and d.control_system_status = #{controlSystemStatus}</if>
             <if test="interlockStatus != null and interlockStatus != ''"> and s.interlock_status = #{interlockStatus}</if>
             <if test="loopHealthLevel != null and loopHealthLevel != ''"> and s.loop_health_level = #{loopHealthLevel}</if>
-            <if test="beginTime != null">
-                <![CDATA[ AND TO_TIMESTAMP(s.tag_time, 'YYYY-MM-DD HH24:MI:SS') > #{beginTime} ]]>
-            </if>
-            <if test="endTime != null">
-                <![CDATA[ AND TO_TIMESTAMP(s.tag_time, 'YYYY-MM-DD HH24:MI:SS') < #{endTime} ]]>
-            </if>
+<!--            <if test="beginTime != null">-->
+<!--                <![CDATA[ AND TO_TIMESTAMP(s.tag_time, 'YYYY-MM-DD HH24:MI:SS') > #{beginTime} ]]>-->
+<!--            </if>-->
+<!--            <if test="endTime != null">-->
+<!--                <![CDATA[ AND TO_TIMESTAMP(s.tag_time, 'YYYY-MM-DD HH24:MI:SS') < #{endTime} ]]>-->
+<!--            </if>-->
             and s.interlock_system_id IS NOT NULL
             AND s.interlock_apparatus_id IS NOT NULL
         </where>
@@ -129,4 +129,33 @@
             h.interlock_system_id
 
     </select>
+
+    <select id="getDistinctZZXTSummaryList1" resultType="org.jeecg.modules.history.vo.InterlockHistoryDistinctZZXTVO">
+        select distinct s.interlock_system_id, system_base.interlock_name AS interlockSystemName,
+        s.interlock_apparatus_id, apparatus_base.interlock_name AS interlockApparatusName
+        from interlock_detail_history d
+        LEFT JOIN interlock_summary_history s on d.summaryid = s.id
+        LEFT JOIN
+        interlock_base system_base ON s.interlock_system_id = system_base.id AND system_base.interlock_type = '1'
+        LEFT JOIN
+        interlock_base apparatus_base ON s.interlock_apparatus_id = apparatus_base.id AND apparatus_base.interlock_type = '0'
+        <where>
+            <if test="interlockSystemId != null and interlockSystemId != ''"> and s.interlock_system_id =  #{interlockSystemId}</if>
+            <if test="interlockApparatusId != null and interlockApparatusId != ''"> and s.interlock_apparatus_id =  #{interlockApparatusId}</if>
+
+            <if test="interlockname != null and interlockname != ''"> and d.interlockname like concat('%', #{interlockname}, '%')</if>
+            <if test="interlockCondition != null and interlockCondition != ''"> and d.interlock_condition = #{interlockCondition}</if>
+            <if test="interlockConditionTag != null and interlockConditionTag != ''"> and d.interlock_condition_tag like concat('%',#{interlockConditionTag},'%')</if>
+            <if test="instrumentStatus != null and instrumentStatus != ''"> and d.instrument_status = #{instrumentStatus}</if>
+            <if test="controlSystemStatus != null and controlSystemStatus != ''"> and d.control_system_status = #{controlSystemStatus}</if>
+            <if test="interlockStatus != null and interlockStatus != ''"> and s.interlock_status = #{interlockStatus}</if>
+            <if test="loopHealthLevel != null and loopHealthLevel != ''"> and s.loop_health_level = #{loopHealthLevel}</if>
+<!--            <if test="beginTime != null">-->
+<!--                AND TO_TIMESTAMP(s.tag_time, 'YYYY-MM-DD HH24:MI:SS') = #{beginTime}-->
+<!--            </if>-->
+            and s.interlock_system_id IS NOT NULL
+            AND s.interlock_apparatus_id IS NOT NULL
+        </where>
+        order by s.interlock_apparatus_id
+    </select>
 </mapper>

+ 8 - 1
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/quartz/ReportJob.java

@@ -67,6 +67,7 @@ public class ReportJob implements Job {
         String separator = "/";
         String filePrex = this.parameter;
         String reportType = "";
+        String type = "";
 
         InterlockHistoryQueryDTO dto = new InterlockHistoryQueryDTO();
         Calendar start = Calendar.getInstance();
@@ -87,6 +88,8 @@ public class ReportJob implements Job {
 
             reportType = "0";
 
+            type = "0";
+
         }else if(this.parameter.equals("month")){
             // 上个月的第一天凌晨00:00:00
             start.add(Calendar.MONTH, -1);
@@ -97,6 +100,8 @@ public class ReportJob implements Job {
 
             reportType = "1";
 
+            type = "1";
+
         }else if(this.parameter.equals("year")){
             // 去年的第一天凌晨00:00:00
             start.add(Calendar.YEAR, -1);
@@ -108,6 +113,8 @@ public class ReportJob implements Job {
             end.add(Calendar.DAY_OF_MONTH, -1);
 
             reportType = "2";
+
+            type = "1";
         }
 
         Date beginTime = start.getTime();
@@ -137,7 +144,7 @@ public class ReportJob implements Job {
         else {
             Workbook workbook = new XSSFWorkbook();
             try {
-                workbook = interlockDetailHistoryService.exportXlsToFile(dto, zzxtvoList, InterlockSummaryHistoryVO.class);
+                workbook = interlockDetailHistoryService.exportXlsToFile(dto, zzxtvoList, InterlockSummaryHistoryVO.class,type);
             } catch (IOException e) {
                 e.printStackTrace();
             }

+ 14 - 7
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/quartz/ReportJobDay.java

@@ -109,13 +109,19 @@ public class ReportJobDay implements Job {
             reportType = "2";
         }
 
-        Date beginTime = start.getTime();
-        Date endTime = end.getTime();
+        //Date beginTime = start.getTime();
+        //Date endTime = end.getTime();
 
-        log.info(String.format(" **********导出" + filePrex + "历史数据**********  时间:" + beginTime + "——" + endTime));
+        //log.info(String.format(" **********导出" + filePrex + "历史数据**********  时间:" + beginTime + "——" + endTime));
 
-        dto.setBeginTime(beginTime);
-        dto.setEndTime(endTime);
+        //dto.setBeginTime(beginTime);
+        //dto.setEndTime(endTime);
+
+        Calendar currentDate = Calendar.getInstance();
+        Date currentTime = currentDate.getTime();
+        dto.setBeginTime(currentTime);
+
+        log.info(" **********导出" + filePrex + "历史数据**********  时间:" + currentTime);
 
         // 文件路径,如"D:/ttt/opt/upFiles/"
         String fileUrlPrex = upLoadPath + separator + filePrex + separator;
@@ -130,13 +136,14 @@ public class ReportJobDay implements Job {
 
         String filePath = fileUrlPrex  + fileName;
 
-        List<InterlockHistoryDistinctZZXTVO> zzxtvoList = summaryHistoryMapper.getDistinctZZXTSummaryList(dto);
+        //List<InterlockHistoryDistinctZZXTVO> zzxtvoList = summaryHistoryMapper.getDistinctZZXTSummaryList(dto);
+        List<InterlockHistoryDistinctZZXTVO> zzxtvoList = summaryHistoryMapper.getDistinctZZXTSummaryList1(dto);
 
         if(zzxtvoList == null || zzxtvoList.size()==0) return;
         else {
             Workbook workbook = new XSSFWorkbook();
             try {
-                workbook = interlockDetailHistoryService.exportXlsToFile(dto, zzxtvoList, InterlockSummaryHistoryVO.class);
+                workbook = interlockDetailHistoryService.exportXlsToFile(dto, zzxtvoList, InterlockSummaryHistoryVO.class,"0");
             } catch (IOException e) {
                 e.printStackTrace();
             }

+ 1 - 1
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/quartz/ReportJobMonth.java

@@ -136,7 +136,7 @@ public class ReportJobMonth implements Job {
         else {
             Workbook workbook = new XSSFWorkbook();
             try {
-                workbook = interlockDetailHistoryService.exportXlsToFile(dto, zzxtvoList, InterlockSummaryHistoryVO.class);
+                workbook = interlockDetailHistoryService.exportXlsToFile(dto, zzxtvoList, InterlockSummaryHistoryVO.class,"1");
             } catch (IOException e) {
                 e.printStackTrace();
             }

+ 1 - 1
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/quartz/ReportJobYear.java

@@ -136,7 +136,7 @@ public class ReportJobYear implements Job {
         else {
             Workbook workbook = new XSSFWorkbook();
             try {
-                workbook = interlockDetailHistoryService.exportXlsToFile(dto, zzxtvoList, InterlockSummaryHistoryVO.class);
+                workbook = interlockDetailHistoryService.exportXlsToFile(dto, zzxtvoList, InterlockSummaryHistoryVO.class,"1");
             } catch (IOException e) {
                 e.printStackTrace();
             }

+ 1 - 1
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/service/IInterlockDetailHistoryService.java

@@ -48,7 +48,7 @@ public interface IInterlockDetailHistoryService extends IService<InterlockDetail
      *      * 定时任务导出
      *      * 手动导出
      */
-    public Workbook exportXlsToFile(InterlockHistoryQueryDTO dto, List<InterlockHistoryDistinctZZXTVO> zzxtvoList, Class<InterlockSummaryHistoryVO> clazz) throws IOException;
+    public Workbook exportXlsToFile(InterlockHistoryQueryDTO dto, List<InterlockHistoryDistinctZZXTVO> zzxtvoList, Class<InterlockSummaryHistoryVO> clazz,String type) throws IOException;
 
 
     /**

+ 57 - 12
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/service/impl/InterlockDetailHistoryServiceImpl.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.history.service.impl;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -19,6 +20,8 @@ import org.jeecg.modules.history.vo.InterlockHistoryDistinctZZXTVO;
 import org.jeecg.modules.history.vo.InterlockSummaryHistoryLimitVO;
 import org.jeecg.modules.history.vo.InterlockSummaryHistoryVO;
 import org.jeecg.modules.interlockUser.entity.InterlockUser;
+import org.jeecg.modules.summary.entity.InterlockSummary;
+import org.jeecg.modules.summary.service.IInterlockSummaryService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -26,10 +29,7 @@ import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
 import java.io.IOException;
 import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * @Description: 联锁详细信息历史数据表
@@ -50,6 +50,10 @@ public class InterlockDetailHistoryServiceImpl extends ServiceImpl<InterlockDeta
     @SuppressWarnings("all")
     private InterlockBaseMapper interlockBaseMapper;
 
+    @Autowired
+    @SuppressWarnings("all")
+    private IInterlockSummaryService summaryService;
+
 
     /**
      * 联锁历史数据详细信息-分页查询
@@ -69,16 +73,53 @@ public class InterlockDetailHistoryServiceImpl extends ServiceImpl<InterlockDeta
      * 联锁历史数据——各种逻辑状态分页查询——用于手动导出
      */
     public List<InterlockSummaryHistoryVO> getForExport(InterlockHistoryQueryDTO dto){
-        return interlockDetailHistoryMapper.getForExport(dto);
+
+        List<String> summaryList = summaryService.getAllInterlockInfoBySystemId(dto.getInterlockSystemId());
+        List<String> historySummaryList = interlockDetailHistoryMapper.getAllForExport(dto);
+        List<InterlockSummaryHistoryVO> list1 = interlockDetailHistoryMapper.getForExport(dto);
+
+        if (summaryList.size() != historySummaryList.size()) {
+            for (String item : summaryList) {
+                if (!historySummaryList.contains(item)){
+                    // 如果 联锁 不存在 历史数据中 查询距离begintime最近的一条历史数据
+                    InterlockSummaryHistoryVO historyVO = interlockDetailHistoryMapper.getOneInfoForExport(dto,item);
+                    if (ObjectUtil.isNotNull(historyVO)){
+                        list1.add(historyVO);
+                    }
+                }
+            }
+        }
+
+        return list1;
     }
 
+    public List<InterlockSummaryHistoryVO> getForExport0(InterlockHistoryQueryDTO dto){
+
+        List<String> summaryList = summaryService.getAllInterlockInfoBySystemId(dto.getInterlockSystemId());
+        List<String> historySummaryList = interlockDetailHistoryMapper.getAllForExport1(dto);
+        List<InterlockSummaryHistoryVO> list1 = interlockDetailHistoryMapper.getForExport1(dto);
+
+        if (summaryList.size() != historySummaryList.size()) {
+            for (String item : summaryList) {
+                if (!historySummaryList.contains(item)){
+                    // 如果 联锁 不存在 历史数据中 查询距离begintime最近的一条历史数据
+                    InterlockSummaryHistoryVO historyVO = interlockDetailHistoryMapper.getOneInfoForExport(dto,item);
+                    if (ObjectUtil.isNotNull(historyVO)){
+                        list1.add(historyVO);
+                    }
+                }
+            }
+        }
+
+        return list1;
+    }
 
     /**
      * 导出excel
      * 定时任务导出
      * 手动导出
      */
-    public Workbook  exportXlsToFile(InterlockHistoryQueryDTO dto, List<InterlockHistoryDistinctZZXTVO> zzxtvoList, Class<InterlockSummaryHistoryVO> clazz) throws IOException {
+    public Workbook  exportXlsToFile(InterlockHistoryQueryDTO dto, List<InterlockHistoryDistinctZZXTVO> zzxtvoList, Class<InterlockSummaryHistoryVO> clazz,String type) throws IOException {
         SXSSFWorkbook workbook = new SXSSFWorkbook();
         Map<String,CellStyle> cellStyleMap = getCellStyle(workbook);
 
@@ -86,17 +127,17 @@ public class InterlockDetailHistoryServiceImpl extends ServiceImpl<InterlockDeta
 
             for (InterlockHistoryDistinctZZXTVO zzxtvo : zzxtvoList) {
 
-                if(dto.getBeginTime()==null){
+                if(dto.getBeginTime()==null && "1".equals(type)){
                     Date minTagTime = interlockDetailHistoryMapper.getMinTagTime(dto);
                     if(minTagTime!=null) dto.setBeginTime(minTagTime);
                 }
-                if(dto.getEndTime()==null){
+                if(dto.getEndTime()==null && "1".equals(type)){
                     Date maxTagTime = interlockDetailHistoryMapper.getMaxTagTime(dto);
                     if(maxTagTime!=null) dto.setEndTime(maxTagTime);
                 }
 
                 String sheetName =generateSheetName(zzxtvo) ;
-                processSheet(workbook, cellStyleMap, sheetName, dto, zzxtvo);
+                processSheet(workbook, cellStyleMap, sheetName, dto, zzxtvo,type);
 
             }
         }
@@ -198,14 +239,18 @@ public class InterlockDetailHistoryServiceImpl extends ServiceImpl<InterlockDeta
         return cellStyleMap;
     }
 
-    private SXSSFWorkbook processSheet(SXSSFWorkbook workbook, Map<String,CellStyle> cellStyleMap, String sheetName, InterlockHistoryQueryDTO dto, InterlockHistoryDistinctZZXTVO zzxtvo) throws IOException {
+    private SXSSFWorkbook processSheet(SXSSFWorkbook workbook, Map<String,CellStyle> cellStyleMap, String sheetName, InterlockHistoryQueryDTO dto, InterlockHistoryDistinctZZXTVO zzxtvo,String type) throws IOException {
 
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         String formattedBeginTime = dto.getBeginTime() != null ? sdf.format(dto.getBeginTime()) : "";
         String formattedEndTime = dto.getEndTime() != null ? sdf.format(dto.getEndTime()) : "";
-
+        List<InterlockSummaryHistoryVO> exportList = new ArrayList<InterlockSummaryHistoryVO>();
         dto.setInterlockSystemId(zzxtvo.getInterlockSystemId()); // 系统id
-        List<InterlockSummaryHistoryVO> exportList = this.getForExport(dto);
+        if ("0".equals(type)){
+            exportList = this.getForExport0(dto);
+        }else {
+            exportList = this.getForExport(dto);
+        }
 
         System.out.println("系统开始-----------------------------------------------------------------------------------"+zzxtvo.getInterlockSystemName());
 

+ 1 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/summary/mapper/InterlockSummaryMapper.java

@@ -14,4 +14,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface InterlockSummaryMapper extends BaseMapper<InterlockSummary> {
 
+    List<String> getAllInterlockInfoBySystemId(@Param("interlockSystemId") String interlockSystemId);
 }

+ 3 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/summary/mapper/xml/InterlockSummaryMapper.xml

@@ -2,4 +2,7 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.modules.summary.mapper.InterlockSummaryMapper">
 
+    <select id="getAllInterlockInfoBySystemId" resultType="java.lang.String">
+        select id from interlock_summary where interlock_system_id = #{interlockSystemId}
+    </select>
 </mapper>

+ 1 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/summary/service/IInterlockSummaryService.java

@@ -40,4 +40,5 @@ public interface IInterlockSummaryService extends IService<InterlockSummary> {
      */
     public void addLS(InterlockAddDTO interlockAddDTO);
 
+    List<String> getAllInterlockInfoBySystemId(String interlockSystemId);
 }

+ 5 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/summary/service/impl/InterlockSummaryServiceImpl.java

@@ -550,4 +550,9 @@ public class InterlockSummaryServiceImpl extends ServiceImpl<InterlockSummaryMap
         else return "0";
     }
 
+
+    @Override
+    public List<String> getAllInterlockInfoBySystemId(String interlockSystemId) {
+        return interlockSummaryMapper.getAllInterlockInfoBySystemId(interlockSystemId);
+    }
 }