Переглянути джерело

历史数据生成添加数据,手动导出修改

sl 1 місяць тому
батько
коміт
f30b33b5d2
12 змінених файлів з 789 додано та 14 видалено
  1. 67 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/binlog/PostgreSQLClient.java
  2. 73 3
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/controller/InterlockDetailHistoryController.java
  3. 52 6
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/controller/InterlockSummaryHistoryController.java
  4. 22 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/entity/InterlockDetailHistory.java
  5. 7 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/entity/InterlockSummaryHistory.java
  6. 24 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/mapper/InterlockDetailHistoryMapper.java
  7. 20 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/mapper/InterlockSummaryHistoryMapper.java
  8. 160 2
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/mapper/xml/InterlockDetailHistoryMapper.xml
  9. 109 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/mapper/xml/InterlockSummaryHistoryMapper.xml
  10. 10 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/service/IInterlockDetailHistoryService.java
  11. 240 3
      jeecg-module-interlock/src/main/java/org/jeecg/modules/history/service/impl/InterlockDetailHistoryServiceImpl.java
  12. 5 0
      jeecg-module-interlock/src/main/java/org/jeecg/modules/ssoClient/controller/SSOLoginLogoutController.java

+ 67 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/binlog/PostgreSQLClient.java

@@ -453,6 +453,7 @@ public class PostgreSQLClient implements ApplicationRunner {
                             summaryService.update(upSummaryQuery);
                         }
 
+                        /*
                         // 只要有任意一个状态发生了变化 就将当前联锁、联锁条件记录到历史数据中  (可此时记录的状态确实是未改变之前的,但是点位值却是已经改变之后的)
                         if ("1".equals(ifYbStatus) || "1".equals(ifLsStatus) || "1".equals(ifKzxtStatus) || "1".equals(ifHljkjbStatus) || "1".equals(ifPlStatus)){
                             QueryWrapper<InterlockSummaryTemp> summaryTempQuery = new QueryWrapper<>();
@@ -479,6 +480,72 @@ public class PostgreSQLClient implements ApplicationRunner {
                                 detailHistoryService.saveBatch(historyList);
                             }
                         }
+                        */
+
+                        // 只要有任意一个状态发生了变化 就将当前联锁、联锁条件记录到历史数据中  (可此时记录的状态确实是未改变之前的,但是点位值却是已经改变之后的)
+                        //修改:记录历史数据的同时,记录下当下的含义,便于以后展示历史数据
+                        if ("1".equals(ifYbStatus) || "1".equals(ifLsStatus) || "1".equals(ifKzxtStatus) || "1".equals(ifHljkjbStatus) || "1".equals(ifPlStatus)){
+                            QueryWrapper<InterlockSummaryTemp> summaryTempQuery = new QueryWrapper<>();
+                            summaryTempQuery.eq("id",summaryId);
+                            InterlockSummaryTemp interlockTemp = summaryTempService.getOne(summaryTempQuery);
+                            //QueryWrapper<InterlockSummaryHistory> summaryHistoryQuery = new QueryWrapper<>();
+                            //summaryHistoryQuery.eq("tag_time",interlockTemp.getTagTime());
+                            //long count1 = summaryHistoryService.count(summaryHistoryQuery);
+                            long count1 = 0;
+                            if (count1 == 0){
+                                List<InterlockDetailTemp> tempList = detailTempService.selectListBySummaryId(summaryId);
+                                InterlockSummaryHistory interlockSummaryHistory = InterlockSummaryHistoryConvert.INSTANCE.toTempHistory(interlockTemp);
+                                interlockSummaryHistory.setSummaryOriginId(interlockTemp.getId());
+                                interlockSummaryHistory.setTagTime(tagTime);
+                                interlockSummaryHistory.setInterlockStatusTy(base.getInterlockStatusTy());//联锁状态-正常状态-值
+                                interlockSummaryHistory.setInterlockStatusTyName(base.getInterlockStatusTyName());//联锁状态-正常状态-名称
+                                interlockSummaryHistory.setInterlockStatusWtyName(base.getInterlockStatusWtyName());//联锁状态-故障状态-名称
+                                //联锁状态
+                                if(interlockSummaryHistory.getInterlockStatus().equals(base.getInterlockStatusTy())){//正常
+                                    interlockSummaryHistory.setInterlockStatusName(base.getInterlockStatusTyName());//当前联锁状态的名称
+                                }else{//故障
+                                    interlockSummaryHistory.setInterlockStatusName(base.getInterlockStatusWtyName());//当前联锁状态的名称
+                                }
+                                summaryHistoryService.save(interlockSummaryHistory);
+                                ArrayList<InterlockDetailHistory> historyList = new ArrayList<>();
+                                for (InterlockDetailTemp item:tempList) {
+                                    item.setSummaryid(interlockSummaryHistory.getId());
+                                    InterlockDetailHistory interlockDetailHistory = InterlockDetailHistoryConvert.INSTANCE.toTempHistory(item);
+                                    interlockDetailHistory.setSummaryOriginId(interlockTemp.getId());
+                                    interlockDetailHistory.setTagTime(tagTime);
+                                    //保存当前0/1的含义
+                                    //旁路状态
+                                    interlockDetailHistory.setBypassYes(base.getBypassYes());//旁路状态-正常状态-值
+                                    interlockDetailHistory.setBypassYesName(base.getBypassYesName());//旁路状态-正常状态-名称
+                                    interlockDetailHistory.setBypassNoName(base.getBypassNoName());//旁路状态-故障状态-名称
+                                    if(interlockDetailHistory.getBypass().equals(base.getBypassYes())){//正常
+                                        interlockDetailHistory.setBypassName(base.getBypassYesName());//当前旁路状态的名称
+                                    }else{//故障
+                                        interlockDetailHistory.setBypassName(base.getBypassNoName());//当前旁路状态的名称
+                                    }
+                                    //仪表状态
+                                    interlockDetailHistory.setInstrumentStatusNormal(base.getInstrumentStatusNormal());//仪表状态-正常状态-值
+                                    interlockDetailHistory.setInstrumentStatusNormalName(base.getInstrumentStatusNormalName());//仪表状态-正常状态-名称
+                                    interlockDetailHistory.setInstrumentStatusAbnormalName(base.getInstrumentStatusAbnormalName());//仪表状态-故障状态-名称
+                                    if(interlockDetailHistory.getInstrumentStatus().equals(base.getInstrumentStatusNormal())){//正常
+                                        interlockDetailHistory.setInstrumentStatusName(base.getInstrumentStatusNormalName());//当前仪表状态的名称
+                                    }else{//故障
+                                        interlockDetailHistory.setInstrumentStatusName(base.getInstrumentStatusAbnormalName());//当前仪表状态的名称
+                                    }
+                                    //控制系统状态
+                                    interlockDetailHistory.setControlSystemStatusNormal(base.getControlSystemStatusNormal());//控制系统状态-正常状态-值
+                                    interlockDetailHistory.setControlSystemStatusNormalName(base.getControlSystemStatusNormalName());//控制系统状态-正常状态-名称
+                                    interlockDetailHistory.setControlSystemStatusAbnormalName(base.getControlSystemStatusAbnormalName());//控制系统状态-故障状态-名称
+                                    if(interlockDetailHistory.getControlSystemStatus().equals(base.getControlSystemStatusNormal())){//正常
+                                        interlockDetailHistory.setControlSystemStatusName(base.getControlSystemStatusNormalName());//当前控制系统状态的名称
+                                    }else{//故障
+                                        interlockDetailHistory.setControlSystemStatusName(base.getControlSystemStatusAbnormalName());//当前控制系统状态的名称
+                                    }
+                                    historyList.add(interlockDetailHistory);
+                                }
+                                detailHistoryService.saveBatch(historyList);
+                            }
+                        }
 
                         // 修改联锁临时表中每个点位值+状态
                         UpdateWrapper<InterlockDetailTemp> upTempDetailQuery = new UpdateWrapper<>();

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

@@ -22,16 +22,20 @@ import org.jeecg.modules.history.vo.InterlockDetailHistoryQueryVO;
 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.interlockUser.service.IInterlockUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.servlet.ModelAndView;
 
+import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
@@ -57,6 +61,10 @@ public class InterlockDetailHistoryController extends JeecgController<InterlockD
 	 @SuppressWarnings("all")
 	 private InterlockDetailMapper interlockDetailMapper;
 
+	 @Autowired
+	 @SuppressWarnings("all")
+	 private IInterlockUserService interlockUserService;
+
 	 /**
 	  * 设置响应结果
 	  *
@@ -77,9 +85,9 @@ public class InterlockDetailHistoryController extends JeecgController<InterlockD
 	 }
 
 
-	 @GetMapping(value = "/sdexportLS")
-	 @ApiOperation("..............手动导出excel")
-	 public void downloadExcel(HttpServletResponse response, InterlockHistoryQueryDTO dto) {
+	 @GetMapping(value = "/sdexportLS1")
+	 @ApiOperation("..............手动导出excel   20240914备份原LLL写的手动导出")
+	 public void downloadExcel1(HttpServletResponse response, InterlockHistoryQueryDTO dto) {
 		 long startTime = System.currentTimeMillis();
 
 		 SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
@@ -303,4 +311,66 @@ public class InterlockDetailHistoryController extends JeecgController<InterlockD
 		return Result.OK(pageList);
 	}
 
+	@GetMapping(value = "/sdexportLS")
+	@ApiOperation("..............手动导出excel")
+	public void downloadExcel(HttpServletRequest request, HttpServletResponse response, InterlockHistoryQueryDTO dto) {
+		long startTime = System.currentTimeMillis();
+
+		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
+		String timestamp = dateFormat.format(new Date());
+		String fileName = String.format("联锁历史数据" + "报表_%s.xlsx", timestamp);
+
+		List<InterlockHistoryDistinctZZXTVO> zzxtvoList = new ArrayList<>();
+		String wiseUser = "";
+		//获取当前用户名
+		Cookie[] cookies = request.getCookies();
+		if (cookies != null) {
+			for (Cookie cookie : cookies) {
+				if (cookie.getName().equals("WISEUser")) {
+					wiseUser = cookie.getValue();
+				}
+			}
+		}
+		InterlockUser interlockUser = interlockUserService.getInterlockUserByUserName(wiseUser);//获取当前用户信息
+		if(interlockUser.getRole().equals("0")){//如果当前用户是系统管理员
+			zzxtvoList = summaryHistoryMapper.getDistinctZZXTSummaryListByAdmin(dto);
+		}else{//如果当前用户是普通用户
+			zzxtvoList = summaryHistoryMapper.getDistinctZZXTSummaryListByUserPermission(dto, wiseUser);
+		}
+
+		Workbook workbook = new XSSFWorkbook();
+		try {
+			workbook = interlockDetailHistoryService.exportXlsToFile1(dto, zzxtvoList, InterlockSummaryHistoryVO.class,"1");
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+
+		// 设置响应头使浏览器能够下载文件
+		try {
+			this.setExcelResponseProp(response, fileName);
+		} catch (UnsupportedEncodingException e) {
+			e.printStackTrace();
+		}
+
+		// 将Excel文件写入响应输出流
+		try {
+			workbook.write(response.getOutputStream());
+		} catch (IOException e) {
+			e.printStackTrace();
+		} finally {
+			try {
+				workbook.close();
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+
+
+		long endTime = System.currentTimeMillis();
+		long duration = endTime - startTime;
+		String log = "手动导出Excel程序运行时间(毫秒):" + duration;
+		System.out.println(log);
+//		 interlockDetailMapper.insertIntoTimeTestLog("手动导出",duration);
+	}
+
 }

+ 52 - 6
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/controller/InterlockSummaryHistoryController.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.history.controller;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
@@ -12,6 +13,9 @@ import javax.servlet.http.HttpServletResponse;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.history.convert.InterlockDetailHistoryConvert;
+import org.jeecg.modules.history.convert.InterlockSummaryHistoryConvert;
+import org.jeecg.modules.history.entity.InterlockDetailHistory;
 import org.jeecg.modules.history.entity.InterlockSummaryHistory;
 import org.jeecg.modules.history.service.IInterlockSummaryHistoryService;
 
@@ -20,6 +24,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.extern.slf4j.Slf4j;
 
+import org.jeecg.modules.temp.entity.InterlockDetailTemp;
+import org.jeecg.modules.temp.entity.InterlockSummaryTemp;
+import org.jeecg.modules.temp.service.IInterlockDetailTempService;
+import org.jeecg.modules.temp.service.IInterlockSummaryTempService;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
 import org.jeecgframework.poi.excel.entity.ExportParams;
@@ -49,7 +57,13 @@ import org.jeecg.common.aspect.annotation.AutoLog;
 public class InterlockSummaryHistoryController extends JeecgController<InterlockSummaryHistory, IInterlockSummaryHistoryService> {
 	@Autowired
 	private IInterlockSummaryHistoryService interlockSummaryHistoryService;
-	
+
+	 @Autowired
+	 private IInterlockDetailTempService detailTempService;
+	 @Autowired
+	 private IInterlockSummaryTempService summaryTempService;
+
+
 	/**
 	 * 分页列表查询
 	 *
@@ -71,7 +85,7 @@ public class InterlockSummaryHistoryController extends JeecgController<Interlock
 		IPage<InterlockSummaryHistory> pageList = interlockSummaryHistoryService.page(page, queryWrapper);
 		return Result.OK(pageList);
 	}
-	
+
 	/**
 	 *   添加
 	 *
@@ -86,7 +100,7 @@ public class InterlockSummaryHistoryController extends JeecgController<Interlock
 		interlockSummaryHistoryService.save(interlockSummaryHistory);
 		return Result.OK("添加成功!");
 	}
-	
+
 	/**
 	 *  编辑
 	 *
@@ -101,7 +115,7 @@ public class InterlockSummaryHistoryController extends JeecgController<Interlock
 		interlockSummaryHistoryService.updateById(interlockSummaryHistory);
 		return Result.OK("编辑成功!");
 	}
-	
+
 	/**
 	 *   通过id删除
 	 *
@@ -116,7 +130,7 @@ public class InterlockSummaryHistoryController extends JeecgController<Interlock
 		interlockSummaryHistoryService.removeById(id);
 		return Result.OK("删除成功!");
 	}
-	
+
 	/**
 	 *  批量删除
 	 *
@@ -131,7 +145,7 @@ public class InterlockSummaryHistoryController extends JeecgController<Interlock
 		this.interlockSummaryHistoryService.removeByIds(Arrays.asList(ids.split(",")));
 		return Result.OK("批量删除成功!");
 	}
-	
+
 	/**
 	 * 通过id查询
 	 *
@@ -174,4 +188,36 @@ public class InterlockSummaryHistoryController extends JeecgController<Interlock
         return super.importExcel(request, response, InterlockSummaryHistory.class);
     }
 
+	 /**
+	  * 测试转化convert
+	  *
+	  * @param summaryId
+	  * @return
+	  */
+	 @ApiOperation(value="测试转化convert", notes="测试转化convert")
+	 @GetMapping(value = "/testSl")
+	 public Result<List<InterlockDetailHistory>> testSl(String summaryId) {
+//		 QueryWrapper<InterlockSummaryTemp> summaryTempQuery = new QueryWrapper<>();
+//		 summaryTempQuery.eq("id",summaryId);
+//		 InterlockSummaryTemp interlockTemp = summaryTempService.getOne(summaryTempQuery);
+
+		 List<InterlockDetailTemp> tempList = detailTempService.selectListBySummaryId(summaryId);
+//		 InterlockSummaryHistory interlockSummaryHistory = InterlockSummaryHistoryConvert.INSTANCE.toTempHistory(interlockTemp);
+//		 interlockSummaryHistory.setSummaryOriginId(interlockTemp.getId());
+//		 interlockSummaryHistory.setTagTime(tagTime);
+//		 summaryHistoryService.save(interlockSummaryHistory);
+		 List<InterlockDetailHistory> historyList = new ArrayList<>();
+		 for (InterlockDetailTemp item:tempList) {
+//			 item.setSummaryid(interlockSummaryHistory.getId());
+			 InterlockDetailHistory interlockDetailHistory = InterlockDetailHistoryConvert.INSTANCE.toTempHistory(item);
+//			 interlockDetailHistory.setSummaryOriginId(interlockTemp.getId());
+//			 interlockDetailHistory.setTagTime(tagTime);
+			 //保存当前0/1的含义
+//                                    interlockDetailHistory
+			 historyList.add(interlockDetailHistory);
+		 }
+		 return Result.OK(historyList);
+	 }
+
+
 }

+ 22 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/entity/InterlockDetailHistory.java

@@ -278,4 +278,26 @@ public class InterlockDetailHistory implements Serializable {
     /**联锁设定值单位*/
     private java.lang.String interlockSetUnit;
 
+    /** 旁路状态-正常状态对应的值 */
+    private java.lang.String bypassYes;
+    /** 旁路状态-正常状态-名称 */
+    private java.lang.String bypassYesName;
+    /** 旁路状态-故障状态-名称 */
+    private java.lang.String bypassNoName;
+
+    /** 仪表状态-正常状态对应的值 */
+    private java.lang.String instrumentStatusNormal;
+    /** 仪表状态-正常状态-名称 */
+    private java.lang.String instrumentStatusNormalName;
+    /** 仪表状态-故障状态-名称 */
+    private java.lang.String instrumentStatusAbnormalName;
+
+    /** 控制系统状态-正常状态对应的值 */
+    private java.lang.String controlSystemStatusNormal;
+    /** 控制系统状态-正常状态-名称 */
+    private java.lang.String controlSystemStatusNormalName;
+    /** 控制系统状态-故障状态-名称 */
+    private java.lang.String controlSystemStatusAbnormalName;
+
+
 }

+ 7 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/entity/InterlockSummaryHistory.java

@@ -117,4 +117,11 @@ public class InterlockSummaryHistory implements Serializable {
     @Excel(name = "联锁状态名称", width = 15)
     @ApiModelProperty(value = "联锁状态名称")
     private java.lang.String interlockStatusName;
+
+    /** 联锁状态-正常状态对应的值 */
+    private java.lang.String interlockStatusTy;
+    /** 联锁状态-正常状态-名称 */
+    private java.lang.String interlockStatusTyName;
+    /** 联锁状态-故障状态-名称 */
+    private java.lang.String interlockStatusWtyName;
 }

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

@@ -30,6 +30,11 @@ public interface InterlockDetailHistoryMapper extends BaseMapper<InterlockDetail
     IPage<InterlockDetailHistoryQueryVO> getPage2(Page<InterlockDetailHistoryQueryVO> page, InterlockDetailQueryDTO dto);
 
     /**
+     * 联锁历史数据详细信息-分页查询    读取含义从详细历史数据表中读取
+     */
+    IPage<InterlockDetailHistoryQueryVO> getPage22(Page<InterlockDetailHistoryQueryVO> page, InterlockDetailQueryDTO dto);
+
+    /**
      * 联锁历史数据——各种逻辑状态分页查询
      */
     IPage<InterlockSummaryHistoryVO> getPage(Page<InterlockSummaryHistoryVO> page, InterlockHistoryQueryDTO dto);
@@ -39,6 +44,11 @@ public interface InterlockDetailHistoryMapper extends BaseMapper<InterlockDetail
      */
     List<InterlockSummaryHistoryVO> getForExport(InterlockHistoryQueryDTO dto);
 
+    /**
+     * 联锁历史数据——各种逻辑状态分页查询——用于手动导出  含义从详细历史数据表中获取
+     */
+    List<InterlockSummaryHistoryVO> getForExport11(@Param("dto") InterlockHistoryQueryDTO dto);
+
     Date getMaxTagTime(InterlockHistoryQueryDTO dto);
     Date getMinTagTime(InterlockHistoryQueryDTO dto);
 
@@ -59,13 +69,27 @@ public interface InterlockDetailHistoryMapper extends BaseMapper<InterlockDetail
      */
     IPage<InterlockSummaryHistoryLimitVO> getPageByAdminUser(Page<InterlockSummaryHistoryLimitVO> page, InterlockHistoryQueryDTO dto);
 
+    /**
+     * 联锁历史数据——各种逻辑状态分页查询   添加权限  普通用户权限  含义读取从详细历史数据表中读取
+     */
+    IPage<InterlockSummaryHistoryLimitVO> getPageByPtUser1(Page<InterlockSummaryHistoryLimitVO> page, InterlockHistoryQueryDTO dto, String wiseUser);
+    /**
+     * 联锁历史数据——各种逻辑状态分页查询   添加权限  普通用户权限   含义读取从详细历史数据表中读取
+     */
+    IPage<InterlockSummaryHistoryLimitVO> getPageByAdminUser1(Page<InterlockSummaryHistoryLimitVO> page, InterlockHistoryQueryDTO dto);
     @Select("select * from interlock_user where username=#{wiseUser}")
     InterlockUser getUserInfoByName(@Param("wiseUser") String wiseUser);
 
     List<String> getAllForExport(InterlockHistoryQueryDTO dto);
 
+    //手动导出  获取历史数据表中数据的原联锁总表id集合
+    List<String> getAllForExport11(@Param("dto") InterlockHistoryQueryDTO dto);
+
     InterlockSummaryHistoryVO getOneInfoForExport(@Param("dto") InterlockHistoryQueryDTO dto,@Param("summaryOriginId") String summaryOriginId);
 
+    //手动导出  如果 联锁 不存在 历史数据中 查询距离begintime最近的一条历史数据?
+    InterlockSummaryHistoryVO getOneInfoForExport11(@Param("dto") InterlockHistoryQueryDTO dto,@Param("summaryOriginId") String summaryOriginId);
+
     List<String> getAllForExport1(InterlockHistoryQueryDTO dto);
 
     List<InterlockSummaryHistoryVO> getForExport1(InterlockHistoryQueryDTO dto);

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

@@ -28,6 +28,15 @@ public interface InterlockSummaryHistoryMapper extends BaseMapper<InterlockSumma
     Integer cocuntTYOrHL(InterlockHistoryQueryDTO dto);
 
     /**
+     * 根据查询条件查联锁状态为“投用”的数量
+     * */
+    Integer cocuntTY11(@Param("dto") InterlockHistoryQueryDTO dto);
+    /**
+     * 根据查询条件查联锁状态为“未投用“的数量
+     * */
+    Integer cocuntWTY11(@Param("dto") InterlockHistoryQueryDTO dto);
+
+    /**
     *   author: dzc
     *   version: 1.0
     *   des: 按日统计 健康等级
@@ -53,4 +62,15 @@ public interface InterlockSummaryHistoryMapper extends BaseMapper<InterlockSumma
     List<InterlockCountDay> getYbStatusListByTagTime(@Param("yesterday") String yesterday);
 
     List<InterlockHistoryDistinctZZXTVO> getDistinctZZXTSummaryList1(InterlockHistoryQueryDTO dto);
+
+    /**
+     * 根据查询条件查所有不重复的系统及其所属装置 系统管理员
+     */
+    List<InterlockHistoryDistinctZZXTVO> getDistinctZZXTSummaryListByAdmin(InterlockHistoryQueryDTO dto);
+
+    /**
+     * 根据查询条件以及用户权限查所有不重复的系统及其所属装置 普通用户
+     */
+    List<InterlockHistoryDistinctZZXTVO> getDistinctZZXTSummaryListByUserPermission(InterlockHistoryQueryDTO dto, String wiseUser);
+
 }

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

@@ -31,6 +31,29 @@
         order by d.create_time desc
     </select>
 
+    <!--联锁历史数据详细信息-分页查询   读取含义从详细历史数据表中读取-->
+    <select id="getPage22" parameterType="org.jeecg.modules.detail.dto.InterlockDetailQueryDTO" resultType="org.jeecg.modules.history.vo.InterlockDetailHistoryQueryVO">
+        select d.id, d.summaryid, d.interlockname, d.interlock_condition, d.interlock_condition_tag, d.description,
+        d.instrument_status, d.interlock_set_value, d.current_value, d.if_bypass, d.bypass, d.input_status,
+        d.output_status, d.mp_status, s.ljgx, s.interlock_out_value, s.tag_time, d.summary_origin_id,
+        d.control_system_status_name as mp_status_name,
+        d.control_system_status_name as input_status_name,
+        d.control_system_status_name as output_status_name,
+        d.bypass_name,
+        d.instrument_status_name,
+        d.instrument_status_normal, d.bypass_yes, s.interlock_status_ty, d.control_system_status_normal,
+        d.interlock_current_unit, d.interlock_set_unit,
+        d.bypass_tag, d.input_status_tag, d.output_status_tag, d.mp_status_tag, s.interlock_out_value_tag, d.instrument_status_tag
+        from interlock_detail_history d
+        left join interlock_summary_history s on d.summaryid = s.id
+        <where>
+            <if test="dto.summaryid != null and dto.summaryid != ''"> and d.summaryid = #{dto.summaryid}</if>
+            <if test="dto.summaryOriginId != null and dto.summaryOriginId != ''"> and d.summary_origin_id = #{dto.summaryOriginId}</if>
+            <if test="dto.interlockConditionTag != null and dto.interlockConditionTag != ''"> and d.interlock_condition_tag like concat('%',#{dto.interlockConditionTag},'%')</if>
+        </where>
+        order by d.create_time desc
+    </select>
+
 <!--    &lt;!&ndash;联锁历史数据详细信息-分页查询   sl修改之前版本&ndash;&gt;-->
 <!--    <select id="getPage2" parameterType="org.jeecg.modules.detail.dto.InterlockDetailQueryDTO" resultType="org.jeecg.modules.history.vo.InterlockDetailHistoryQueryVO">-->
 <!--        select d.id, d.summaryid, d.interlockname, d.interlock_condition, d.interlock_condition_tag, d.description,-->
@@ -140,8 +163,8 @@
         select min(s.tag_time) as min_tag_time
         from interlock_detail_history d left join interlock_summary_history s on d.summaryid = s.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="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>
@@ -198,6 +221,39 @@
         order by s.tag_time desc
     </select>
 
+    <!-- 联锁总历史数据表-分页列表查询(各种逻辑状态)   添加权限  普通用户权限   含义读取从详细历史数据表中读取-->
+    <select id="getPageByPtUser1" resultType="org.jeecg.modules.history.vo.InterlockSummaryHistoryLimitVO">
+        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, d.summary_origin_id, s.interlock_apparatus_id, s.interlock_system_id,
+        s.interlock_status_name, d.bypass_name,
+        d.instrument_status_name, d.control_system_status_name,
+        d.instrument_status_normal, d.bypass_yes, s.interlock_status_ty, d.control_system_status_normal,
+        b.interlock_name as interlock_system_name, b1.interlock_name as interlock_apparatus_name
+        from interlock_detail_history d
+        left join interlock_summary_history s on d.summaryid = s.id
+        inner join interlock_base b on b.id = s.interlock_system_id
+        inner join interlock_base b1 on b1.id = s.interlock_apparatus_id
+        left join (select l.* from interlock_system_limit l where l.interlock_user_id in
+        (select u.id from interlock_user u where u.username=#{wiseUser})) qxnr on qxnr.interlock_system_id = s.interlock_system_id
+        <where>
+            and (qxnr.limit_type='0' or qxnr.limit_type='1')
+            <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 &gt; #{dto.beginTime} </if>
+            <if test="dto.endTime != null"> and s.tag_time &lt; #{dto.endTime} </if>
+            <if test="dto.bypass != null and dto.bypass != ''"> and d.bypass = #{dto.bypass}</if>
+        </where>
+        order by s.tag_time desc
+    </select>
+
     <!-- 联锁总历史数据表-分页列表查询(各种逻辑状态)   添加权限  系统管理员权限-->
     <select id="getPageByAdminUser" resultType="org.jeecg.modules.history.vo.InterlockSummaryHistoryLimitVO">
         select d.id, d.summaryid, d.interlockname, d.interlock_condition, d.interlock_condition_tag, d.instrument_status, d.control_system_status,
@@ -231,6 +287,34 @@
         </where>
         order by s.tag_time desc
     </select>
+    <!-- 联锁总历史数据表-分页列表查询(各种逻辑状态)   添加权限  系统管理员权限    含义读取从详细历史数据表中读取-->
+    <select id="getPageByAdminUser1" resultType="org.jeecg.modules.history.vo.InterlockSummaryHistoryLimitVO">
+        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, d.summary_origin_id, s.interlock_apparatus_id, s.interlock_system_id,
+        s.interlock_status_name, d.bypass_name,
+        d.instrument_status_name, d.control_system_status_name,
+        d.instrument_status_normal, d.bypass_yes, s.interlock_status_ty, d.control_system_status_normal,
+        b.interlock_name as interlock_system_name, b1.interlock_name as interlock_apparatus_name
+        from interlock_detail_history d
+        left join interlock_summary_history s on d.summaryid = s.id
+        inner join interlock_base b on b.id = s.interlock_system_id
+        inner join interlock_base b1 on b1.id = s.interlock_apparatus_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 &gt; #{dto.beginTime} </if>
+            <if test="dto.endTime != null"> and s.tag_time &lt; #{dto.endTime} </if>
+            <if test="dto.bypass != null and dto.bypass != ''"> and d.bypass = #{dto.bypass}</if>
+        </where>
+        order by s.tag_time desc
+    </select>
 
 
     <select id="getAllForExport" resultType="java.lang.String">
@@ -336,4 +420,78 @@
         order by s.tag_time desc
     </select>
 
+
+
+    <!-- 手动导出  获取历史数据表中数据的原联锁总表id集合-->
+    <select id="getAllForExport11" parameterType="org.jeecg.modules.history.dto.InterlockHistoryQueryDTO" 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
+        <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 &gt; #{dto.beginTime} </if>
+            <if test="dto.endTime != null"> and s.tag_time &lt; #{dto.endTime} </if>
+        </where>
+    </select>
+
+    <!-- 联锁总历史数据表查询(各种逻辑状态)——用于手动导出   含义从详细历史数据表中获取 -->
+    <!-- 每个系统的数据 先按联锁总表的生成时间倒序排序,s.create_time desc,  ??保证新增的联锁在最前面; 再按tag_time倒序排序,使最新发生变化的数据在最前面  -->
+    <select id="getForExport11" parameterType="org.jeecg.modules.history.dto.InterlockHistoryQueryDTO" 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,
+        s.interlock_status_name, d.bypass_name,
+        d.instrument_status_name, d.control_system_status_name
+        from interlock_detail_history d left join interlock_summary_history s on d.summaryid = s.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 TO_TIMESTAMP(s.tag_time, 'YYYY-MM-DD HH24:MI:SS') <![CDATA[ >= ]]> #{dto.beginTime} </if>
+            <if test="dto.endTime != null"> and TO_TIMESTAMP(s.tag_time, 'YYYY-MM-DD HH24:MI:SS') <![CDATA[ <= ]]> #{dto.endTime} </if>
+        </where>
+        order by s.tag_time desc
+    </select>
+
+    <!-- 如果 联锁 不存在 历史数据中 查询距离begintime最近的一条历史数据   含义从详细历史数据表中获取 -->
+    <select id="getOneInfoForExport11" 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,
+        s.interlock_status_name, d.bypass_name,
+        d.instrument_status_name, d.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
+        <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>
+
+
 </mapper>

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

@@ -158,4 +158,113 @@
         </where>
         order by s.interlock_apparatus_id
     </select>
+
+
+    <!--    根据查询条件查所有不重复的系统及其所属装置   系统管理员   -->
+    <select id="getDistinctZZXTSummaryListByAdmin" parameterType="org.jeecg.modules.history.dto.InterlockHistoryQueryDTO" 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
+        INNER JOIN
+        interlock_base system_base ON s.interlock_system_id = system_base.id AND system_base.interlock_type = '1'
+        INNER 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">-->
+            <!--                <![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>
+        order by s.interlock_apparatus_id
+    </select>
+
+    <!--    根据查询条件以及用户权限查所有不重复的系统及其所属装置 普通用户      -->
+    <select id="getDistinctZZXTSummaryListByUserPermission" 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
+        INNER JOIN
+        interlock_base system_base ON s.interlock_system_id = system_base.id AND system_base.interlock_type = '1'
+        INNER JOIN
+        interlock_base apparatus_base ON s.interlock_apparatus_id = apparatus_base.id AND apparatus_base.interlock_type = '0'
+        LEFT JOIN (select l.* from interlock_system_limit l where l.interlock_user_id in
+        (select u.id from interlock_user u where u.username=#{wiseUser})) qxnr on qxnr.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">-->
+            <!--                <![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
+            and (qxnr.limit_type='0' or qxnr.limit_type='1')
+        </where>
+        order by s.interlock_apparatus_id
+    </select>
+
+
+    <!--    根据查询条件查联锁状态为“投用”的数量     -->
+    <select id="cocuntTY11" parameterType="org.jeecg.modules.history.dto.InterlockHistoryQueryDTO" resultType="java.lang.Integer">
+        select count(*) from interlock_summary_history
+        <where>
+            and interlock_status=interlock_status_ty
+            <if test="dto.interlockSystemId != null and dto.interlockSystemId != ''"> and interlock_system_id = #{dto.interlockSystemId}</if>
+            <if test="dto.interlockApparatusId != null and dto.interlockApparatusId != ''"> and interlock_apparatus_id = #{dto.interlockApparatusId}</if>
+            <if test="dto.loopHealthLevel != null and dto.loopHealthLevel != ''"> and loop_health_level = #{dto.loopHealthLevel}</if>
+            <if test="dto.beginTime != null">
+                <![CDATA[ AND TO_TIMESTAMP(tag_time, 'YYYY-MM-DD HH24:MI:SS') >= #{dto.beginTime} ]]>
+            </if>
+            <if test="dto.endTime != null">
+                <![CDATA[ AND TO_TIMESTAMP(tag_time, 'YYYY-MM-DD HH24:MI:SS') <= #{dto.endTime} ]]>
+            </if>
+        </where>
+    </select>
+
+    <!--    根据查询条件查联锁状态为“未投用“的数量     -->
+    <select id="cocuntWTY11" parameterType="org.jeecg.modules.history.dto.InterlockHistoryQueryDTO" resultType="java.lang.Integer">
+        select count(*) from interlock_summary_history
+        <where>
+            and interlock_status!=interlock_status_ty
+            <if test="dto.interlockSystemId != null and dto.interlockSystemId != ''"> and interlock_system_id = #{dto.interlockSystemId}</if>
+            <if test="dto.interlockApparatusId != null and dto.interlockApparatusId != ''"> and interlock_apparatus_id = #{dto.interlockApparatusId}</if>
+            <if test="dto.loopHealthLevel != null and dto.loopHealthLevel != ''"> and loop_health_level = #{dto.loopHealthLevel}</if>
+            <if test="dto.beginTime != null">
+                <![CDATA[ AND TO_TIMESTAMP(tag_time, 'YYYY-MM-DD HH24:MI:SS') >= #{dto.beginTime} ]]>
+            </if>
+            <if test="dto.endTime != null">
+                <![CDATA[ AND TO_TIMESTAMP(tag_time, 'YYYY-MM-DD HH24:MI:SS') <= #{dto.endTime} ]]>
+            </if>
+        </where>
+    </select>
+
+
+
+
 </mapper>

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

@@ -63,4 +63,14 @@ public interface IInterlockDetailHistoryService extends IService<InterlockDetail
      * 联锁历史数据——各种逻辑状态分页查询  添加权限
      */
     IPage<InterlockSummaryHistoryLimitVO> getPageByUser(HttpServletRequest request, Page<InterlockSummaryHistoryLimitVO> page, InterlockHistoryQueryDTO dto);
+
+    /**
+     * 导出excel
+     *      * 定时任务导出
+     *      * 手动导出
+     *      修改
+     */
+    public Workbook exportXlsToFile1(InterlockHistoryQueryDTO dto, List<InterlockHistoryDistinctZZXTVO> zzxtvoList, Class<InterlockSummaryHistoryVO> clazz,String type) throws IOException;
+
+
 }

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

@@ -59,7 +59,8 @@ public class InterlockDetailHistoryServiceImpl extends ServiceImpl<InterlockDeta
      * 联锁历史数据详细信息-分页查询
      */
     public IPage<InterlockDetailHistoryQueryVO> getPage2(Page<InterlockDetailHistoryQueryVO> page, InterlockDetailQueryDTO dto){
-        return interlockDetailHistoryMapper.getPage2(page, dto);
+//        return interlockDetailHistoryMapper.getPage2(page, dto);
+        return interlockDetailHistoryMapper.getPage22(page, dto);
     }
 
     /**
@@ -488,12 +489,248 @@ public class InterlockDetailHistoryServiceImpl extends ServiceImpl<InterlockDeta
 //        wiseUser = "admin";
         InterlockUser interlockUser = interlockDetailHistoryMapper.getUserInfoByName(wiseUser);
         if(interlockUser.getRole().equals("0")){//如果是系统管理员
-            return interlockDetailHistoryMapper.getPageByAdminUser(page, dto);
+//            return interlockDetailHistoryMapper.getPageByAdminUser(page, dto);
+            return interlockDetailHistoryMapper.getPageByAdminUser1(page, dto);
         }else{
-            return interlockDetailHistoryMapper.getPageByPtUser(page, dto, wiseUser);
+//            return interlockDetailHistoryMapper.getPageByPtUser(page, dto, wiseUser);
+            return interlockDetailHistoryMapper.getPageByPtUser1(page, dto, wiseUser);
         }
+    }
+
+
+    /**
+     * 导出excel
+     * 定时任务导出
+     * 手动导出
+     * 修改
+     */
+    public Workbook  exportXlsToFile1(InterlockHistoryQueryDTO dto, List<InterlockHistoryDistinctZZXTVO> zzxtvoList, Class<InterlockSummaryHistoryVO> clazz,String type) throws IOException {
+        SXSSFWorkbook workbook = new SXSSFWorkbook();
+        Map<String,CellStyle> cellStyleMap = getCellStyle(workbook);
+        if (zzxtvoList != null) {
+            for (InterlockHistoryDistinctZZXTVO zzxtvo : zzxtvoList) {
+                if(dto.getBeginTime()==null && "1".equals(type)){
+                    Date minTagTime = interlockDetailHistoryMapper.getMinTagTime(dto);
+                    if(minTagTime!=null) dto.setBeginTime(minTagTime);
+                }
+                if(dto.getEndTime()==null && "1".equals(type)){
+                    Date maxTagTime = interlockDetailHistoryMapper.getMaxTagTime(dto);
+                    if(maxTagTime!=null) dto.setEndTime(maxTagTime);
+                }
+                String sheetName =generateSheetName(zzxtvo) ;
+                processSheet1(workbook, cellStyleMap, sheetName, dto, zzxtvo,type);
+            }
+        }
+        return workbook;
+    }
+
+    private SXSSFWorkbook processSheet1(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
+        if ("0".equals(type)){
+            exportList = this.getForExport00(dto);//日报表
+        }else {
+            exportList = this.getForExport11(dto);//手动导出、月报表、年报表
+        }
+
+        System.out.println("系统开始-----------------------------------------------------------------------------------"+zzxtvo.getInterlockSystemName());
+
+
+        Sheet sheet = workbook.createSheet(sheetName);
+
+        // 设置列宽——30或15个字符宽度
+        int[] columnWidths = {30, 30, 30, 15, 15, 15, 15, 15};
+        for (int j = 0; j < columnWidths.length; j++) {
+            sheet.setColumnWidth(j, columnWidths[j] * 256);
+        }
+
+        // 计算投用率
+        int ty = summaryHistoryMapper.cocuntTY11(dto);
+        int wty = summaryHistoryMapper.cocuntWTY11(dto);
+        int total = ty + wty; // 总数量
+        double tyl = (double) ty / total * 100;
+        String tylPercentage = String.format("%.2f%%", tyl); // 将百分比转换为百分数形式,保留两位小数
+
+        //第一行:联锁历史数据报表
+        int rowNum = 0;
+        Row titleRow = sheet.createRow(rowNum++);
+        titleRow.setHeightInPoints(19.8f);
+        Cell titleCell = titleRow.createCell(0);
+        titleCell.setCellValue("联锁历史数据报表");
+        titleCell.setCellStyle(cellStyleMap.get("firstStyle")); // 第一行的样式
+        // 合并第一行的前6列
+        sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 0, 5));
+
+        // 第二行:报表生成时间:
+        Row secondTitleRow = sheet.createRow(rowNum++);
+        // 设置第2行数据
+        String[] s2 = {"报表生成时间:",sdf.format(new Date()),"","","",""};
+        createCellOfRowWithValueStyle(secondTitleRow,s2,cellStyleMap.get("centerAlignStyle2"));
+        // 合并第2行的后5列
+        sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 1, 5));
 
+        // 第3行:装置名称
+        Row thirdTitleRow = sheet.createRow(rowNum++);
+        // 设置第3行数据
+        String[] s3 = {"装置名称:",zzxtvo.getInterlockApparatusName(),"","","",""};
+        CellStyle[] style3 = {cellStyleMap.get("centerAlignStyle"),cellStyleMap.get("centerAlignStyle3"),cellStyleMap.get("centerAlignStyle3"),cellStyleMap.get("centerAlignStyle3"),cellStyleMap.get("centerAlignStyle3"),cellStyleMap.get("centerAlignStyle3")};
+        createCellOfRowWithValueStyleName(thirdTitleRow,s3,style3);
+        // 合并第3行的后5列
+        sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 1, 5));
+
+        // 第四行:系统名称
+        Row fourthTitleRow = sheet.createRow(rowNum++);
+        // 设置第4行数据
+        String[] s4 = {"系统名称:",zzxtvo.getInterlockSystemName(),"","","",""};
+        createCellOfRowWithValueStyleName(fourthTitleRow,s4,style3); //与第三行样式相同style3
+        // 合并第4行的后5列
+        sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 1, 5));
+
+        //第五行:起始时间、结束时间
+        Row fifthTitleRow = sheet.createRow(rowNum++);
+        //设置第5行数据
+        String[] s5 = {"起始时间:",formattedBeginTime,"","结束时间:",formattedEndTime,""};
+        CellStyle[] style5 = {cellStyleMap.get("centerAlignStyle"),cellStyleMap.get("centerAlignStyle3"),cellStyleMap.get("centerAlignStyle3"),cellStyleMap.get("centerAlignStyle"),cellStyleMap.get("centerAlignStyle3"),cellStyleMap.get("centerAlignStyle3")};
+        createCellOfRowWithValueStyleName(fifthTitleRow,s5,style5);
+        // 分别合并第2、3列 和 第5、6列
+        sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 1, 2));
+        sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 4, 5));
+
+        //第六行:连锁数量、未投用联锁数量、投用率统计
+        Row sixTitleRow = sheet.createRow(rowNum++);
+        String[] s6 = {"联锁总数:", String.valueOf(total),"未投用联锁数量:", String.valueOf(wty),"投用率统计:", String.valueOf(tylPercentage)};
+        CellStyle[] style6 = {cellStyleMap.get("centerAlignStyle"),cellStyleMap.get("centerAlignStyle3"),cellStyleMap.get("centerAlignStyle"),cellStyleMap.get("centerAlignStyle3"),cellStyleMap.get("centerAlignStyle"),cellStyleMap.get("centerAlignStyle3")};
+        createCellOfRowWithValueStyleName(sixTitleRow,s6,style6);
+
+        //第七行空白
+        rowNum++;
+
+        //第8行:历史数据
+        Row eightTitleRow = sheet.createRow(rowNum++);
+        //设置第8行数据
+        String[] s8 = {"历史数据:", "","", "","", "回路健康级别:A-健康;B-故障;C-严重故障;D-失效","", ""};
+        CellStyle[] style8 = {cellStyleMap.get("centerAlignStyle1"),cellStyleMap.get("centerAlignStyle1"),cellStyleMap.get("centerAlignStyle1"),cellStyleMap.get("centerAlignStyle1"),cellStyleMap.get("centerAlignStyle1"),cellStyleMap.get("centerAlignStyle9"),cellStyleMap.get("centerAlignStyle9"),cellStyleMap.get("centerAlignStyle9")};
+        createCellOfRowWithValueStyleName(eightTitleRow,s8,style8);
+        // 分别合并第6、7、8列
+        sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 5, 7));
+
+        //第9行:列名
+        Row columnRow= sheet.createRow(rowNum++);
+        String[] s9 = {"时间", "联锁名称", "联锁条件", "仪表状态", "控制系统状态", "旁路状态", "联锁状态", "回路健康级别"};
+        // 各列索引
+        int tagTimeCol= 0;
+        int interlockNameCol = 1;
+        int interlockStatusCol = 6;
+        int loopHealthLevelCol = 7;
+        createCellOfRowWithValueStyle(columnRow,s9,cellStyleMap.get("centerAlignStyle"));
+
+
+        // 合并单元格的起始行索引
+        int startTagTimeRow = 0;
+        int startInterlockNameRow = 0;
+        int startInterlockStatusRow = 0;
+        int startLoopHealthLevelRow = 0;
+
+        for (int idx = 0; idx < exportList.size(); idx++)  {
+            InterlockSummaryHistoryVO record = exportList.get(idx);
+
+            //创建单元格、设置格式、填充数据
+            Row row = sheet.createRow(rowNum);
+            String[] s = {record.getTagTime(), record.getInterlockname(), record.getInterlockConditionTag(), record.getInstrumentStatusName(), record.getControlSystemStatusName(), record.getBypassName(), record.getInterlockStatusName(), record.getLoopHealthLevel()};
+            createCellOfRowWithValueStyle(row,s,cellStyleMap.get("centerAlignStyle3"));
+
+            // 合并 "采集时间" 列单元格
+            if (idx == 0 || !record.getTagTime().equals(exportList.get(idx - 1).getTagTime()) || !record.getInterlockname().equals(exportList.get(idx - 1).getInterlockname()) ) {
+                if (idx > 0 && (rowNum - startTagTimeRow) > 1) {
+                    sheet.addMergedRegion(new CellRangeAddress(startTagTimeRow, rowNum - 1, tagTimeCol, tagTimeCol));
+                }
+                startTagTimeRow = rowNum;
+            }
+
+            // 合并 "联锁名称" 列单元格,基于 "采集时间"
+            if (idx == 0 || !record.getTagTime().equals(exportList.get(idx - 1).getTagTime()) || !record.getInterlockname().equals(exportList.get(idx - 1).getInterlockname()) ) {
+                if (idx > 0 && (rowNum - startInterlockNameRow) > 1) {
+                    sheet.addMergedRegion(new CellRangeAddress(startInterlockNameRow, rowNum - 1, interlockNameCol, interlockNameCol));
+                }
+                startInterlockNameRow = rowNum;
+            }
+
+            // 合并 "联锁状态" 列单元格,基于 "采集时间"
+            if (idx == 0 || !record.getTagTime().equals(exportList.get(idx - 1).getTagTime()) || !record.getInterlockname().equals(exportList.get(idx - 1).getInterlockname())) {
+                if (idx > 0 && (rowNum - startInterlockStatusRow) > 1) {
+                    sheet.addMergedRegion(new CellRangeAddress(startInterlockStatusRow, rowNum - 1, interlockStatusCol, interlockStatusCol));
+                }
+                startInterlockStatusRow = rowNum;
+            }
+
+            // 合并 "回路健康状态" 列单元格,基于 "采集时间"
+            if (idx == 0 || !record.getTagTime().equals(exportList.get(idx - 1).getTagTime()) || !record.getInterlockname().equals(exportList.get(idx - 1).getInterlockname())) {
+                if (idx > 0 && (rowNum - startLoopHealthLevelRow) > 1) {
+                    sheet.addMergedRegion(new CellRangeAddress(startLoopHealthLevelRow, rowNum - 1, loopHealthLevelCol, loopHealthLevelCol));
+                }
+                startLoopHealthLevelRow = rowNum;
+            }
+
+            rowNum++;
+        }
+
+        // 最后一组合并区域的处理
+        // 合并 "采集时间" 列的最后一组
+        if ((rowNum - startTagTimeRow) > 1) {
+            sheet.addMergedRegion(new CellRangeAddress(startTagTimeRow, rowNum - 1, tagTimeCol, tagTimeCol));
+        }
+        // 合并 "联锁名称" 列的最后一组
+        if ((rowNum - startInterlockNameRow) > 1) {
+            sheet.addMergedRegion(new CellRangeAddress(startInterlockNameRow, rowNum - 1, interlockNameCol, interlockNameCol));
+        }
+        // 合并 "联锁状态" 列的最后一组
+        if ((rowNum - startInterlockStatusRow) > 1) {
+            sheet.addMergedRegion(new CellRangeAddress(startInterlockStatusRow, rowNum - 1, interlockStatusCol, interlockStatusCol));
+        }
+        // 合并 "回路健康状态" 列的最后一组
+        if ((rowNum - startLoopHealthLevelRow) > 1) {
+            sheet.addMergedRegion(new CellRangeAddress(startLoopHealthLevelRow, rowNum - 1, loopHealthLevelCol, loopHealthLevelCol));
+        }
+        System.out.println("系统结束-----------------------------------------------------------------------------------"+zzxtvo.getInterlockSystemName());
+
+        return workbook;
+    }
+
+
+    public List<InterlockSummaryHistoryVO> getForExport00(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.getOneInfoForExport11(dto,item);
+                    if (ObjectUtil.isNotNull(historyVO)){
+                        list1.add(historyVO);
+                    }
+                }
+            }
+        }
+
+        return list1;
+    }
+
+    /**
+     * 联锁历史数据——各种逻辑状态分页查询——用于手动导出
+     */
+    public List<InterlockSummaryHistoryVO> getForExport11(InterlockHistoryQueryDTO dto){
 
+//        List<String> summaryList = summaryService.getAllInterlockInfoBySystemId(dto.getInterlockSystemId());//获取联锁总表中该系统下的所有联锁id
+//        List<String> historySummaryList = interlockDetailHistoryMapper.getAllForExport11(dto);//获取历史数据表中数据的原联锁总表id集合
+//        List<InterlockSummaryHistoryVO> list1 = interlockDetailHistoryMapper.getForExport11(dto);//获取某个系统下时间在规定范围内的所有相关联锁历史数据
+        return interlockDetailHistoryMapper.getForExport11(dto);
     }
 
 }

+ 5 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/ssoClient/controller/SSOLoginLogoutController.java

@@ -377,6 +377,11 @@ public class SSOLoginLogoutController {
                     ssoRole = (String) ssoUserInfo.get("ssoRole");
                     usernameSSO = (String) ssoUserInfo.get("username");
                 }
+                if(usernameSSO == null || "".equals(usernameSSO)){
+                    loginResult.setResult(result.error("获取用户名失败,请重新登录"));
+                    loginResult.setUpdate(false);
+                    return loginResult;
+                }
 
 //                if(isHasSSORole.equals("0")){//如果没有SSORole字段,查询一下sso角色
 //                    //获取用户角色 是否是管理员