|
@@ -12,7 +12,10 @@ import org.apache.shiro.SecurityUtils;
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
+import org.jeecg.modules.base.entity.InterlockBase;
|
|
|
+import org.jeecg.modules.base.mapper.InterlockBaseMapper;
|
|
|
import org.jeecg.modules.detail.dto.InterlockDetailQueryDTO;
|
|
|
+import org.jeecg.modules.history.convert.InterlockSummaryHistoryConvert;
|
|
|
import org.jeecg.modules.history.dto.InterlockHistoryQueryDTO;
|
|
|
import org.jeecg.modules.history.entity.InterlockDetailHistory;
|
|
|
import org.jeecg.modules.history.entity.InterlockSummaryHistory;
|
|
@@ -20,6 +23,7 @@ import org.jeecg.modules.history.mapper.InterlockDetailHistoryMapper;
|
|
|
import org.jeecg.modules.history.mapper.InterlockSummaryHistoryMapper;
|
|
|
import org.jeecg.modules.history.service.IInterlockDetailHistoryService;
|
|
|
import org.jeecg.modules.history.vo.InterlockDetailHistoryQueryVO;
|
|
|
+import org.jeecg.modules.history.vo.InterlockHistoryDistinctZZXTVO;
|
|
|
import org.jeecg.modules.history.vo.InterlockSummaryHistoryVO;
|
|
|
import org.jeecg.modules.summary.entity.InterlockSummary;
|
|
|
import org.jeecg.modules.summary.mapper.InterlockSummaryMapper;
|
|
@@ -39,7 +43,11 @@ import java.io.File;
|
|
|
import java.io.FileInputStream;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
+import java.text.DateFormat;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Description: 联锁详细信息历史数据表
|
|
@@ -56,6 +64,9 @@ public class InterlockDetailHistoryServiceImpl extends ServiceImpl<InterlockDeta
|
|
|
@Autowired
|
|
|
@SuppressWarnings("all")
|
|
|
private InterlockSummaryHistoryMapper summaryHistoryMapper;
|
|
|
+ @Autowired
|
|
|
+ @SuppressWarnings("all")
|
|
|
+ private InterlockBaseMapper interlockBaseMapper;
|
|
|
|
|
|
@Value("${jeecg.path.upload}")
|
|
|
private String upLoadPath;
|
|
@@ -74,9 +85,6 @@ public class InterlockDetailHistoryServiceImpl extends ServiceImpl<InterlockDeta
|
|
|
return interlockDetailHistoryMapper.getPage(page, dto);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 联锁历史数据——各种逻辑状态分页查询——用于手动导出
|
|
|
*/
|
|
@@ -89,70 +97,101 @@ public class InterlockDetailHistoryServiceImpl extends ServiceImpl<InterlockDeta
|
|
|
*/
|
|
|
public ModelAndView exportXls1(InterlockHistoryQueryDTO dto, Class<InterlockSummaryHistoryVO> clazz, String title) {
|
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String formattedBeginTime = "";
|
|
|
+ String formattedEndTime = "";
|
|
|
+ if(dto.getBeginTime()!=null) formattedBeginTime = sdf.format(dto.getBeginTime());
|
|
|
+ if(dto.getEndTime()!=null) formattedEndTime = sdf.format(dto.getEndTime());
|
|
|
+
|
|
|
+
|
|
|
+ List<Map<String, Object>> list = new ArrayList<>();
|
|
|
+ List<InterlockHistoryDistinctZZXTVO> zzxtvoList = summaryHistoryMapper.getDistinctZZXTSummaryList(dto);
|
|
|
|
|
|
- //按装置、系统分sheet
|
|
|
- if(dto.getInterlockSystemId()!=null && !"".equals(dto.getInterlockSystemId())){
|
|
|
- //一个系统
|
|
|
+ for (InterlockHistoryDistinctZZXTVO zzxtvo : zzxtvoList){
|
|
|
+ dto.setInterlockSystemId(zzxtvo.getInterlockSystemId());//系统id
|
|
|
List<InterlockSummaryHistoryVO> exportList = interlockDetailHistoryMapper.getForExport(dto);
|
|
|
- ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
|
|
- mv.addObject(NormalExcelConstants.FILE_NAME, title);//此处设置的filename无效 ,前端会重更新设置一下
|
|
|
- mv.addObject(NormalExcelConstants.CLASS, clazz);
|
|
|
- ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title);
|
|
|
- exportParams.setImageBasePath(upLoadPath);
|
|
|
- mv.addObject(NormalExcelConstants.PARAMS,exportParams);
|
|
|
- mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
|
|
|
- return mv;
|
|
|
- }else if(dto.getInterlockApparatusId()!=null && !"".equals(dto.getInterlockApparatusId())){
|
|
|
- //一个装置,多个系统
|
|
|
- List<Map<String, Object>> list = new ArrayList<>();
|
|
|
+ if(exportList!=null){
|
|
|
+ exportList.stream().map(i->{
|
|
|
+ return zh(i);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ String sheetName = zzxtvo.getInterlockApparatusName()+ "-"+zzxtvo.getInterlockSystemName();
|
|
|
+
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put(NormalExcelConstants.CLASS, InterlockSummaryHistoryVO.class);
|
|
|
|
|
|
+ // 计算投用率
|
|
|
InterlockHistoryQueryDTO dto1 = new InterlockHistoryQueryDTO();
|
|
|
- dto1.setInterlockApparatusId(dto.getInterlockApparatusId());//装置id
|
|
|
- List<InterlockSummaryHistory> summaryList = summaryHistoryMapper.getDistinctZZXTSummaryList(dto1);
|
|
|
-
|
|
|
- int i = 1;
|
|
|
- for (InterlockSummaryHistory summaryHistory : summaryList){
|
|
|
- dto.setInterlockSystemId(summaryHistory.getInterlockSystemId());//系统id
|
|
|
- List<InterlockSummaryHistoryVO> exportList = interlockDetailHistoryMapper.getForExport(dto);
|
|
|
-
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put(NormalExcelConstants.CLASS, InterlockSummaryHistoryVO.class);
|
|
|
- map.put(NormalExcelConstants.PARAMS, new ExportParams(summaryHistory.getInterlockApparatusId()+ "-"+summaryHistory.getInterlockSystemId() , "第"+ i+ "页"));
|
|
|
- map.put(NormalExcelConstants.DATA_LIST, exportList);
|
|
|
- list.add(map);
|
|
|
- i++;
|
|
|
+ dto1 = InterlockSummaryHistoryConvert.INSTANCE.toInterlockStatus(dto,"1"); // 1投用
|
|
|
+ int ty = summaryHistoryMapper.cocuntTYOrHL(dto1);
|
|
|
+ dto1.setInterlockStatus("0"); // 0未投用
|
|
|
+ int wty = summaryHistoryMapper.cocuntTYOrHL(dto1);
|
|
|
+ int total = ty + wty; // 总数量
|
|
|
+ double tyl = (double) ty / total * 100;
|
|
|
+
|
|
|
+ // 总回路数
|
|
|
+ InterlockHistoryQueryDTO dto2 = new InterlockHistoryQueryDTO();
|
|
|
+ dto2 = InterlockSummaryHistoryConvert.INSTANCE.toLoopHealthLevel(dto,"A");
|
|
|
+ int loopHealthLevelA = summaryHistoryMapper.cocuntTYOrHL(dto2);
|
|
|
+ dto2.setLoopHealthLevel("B");
|
|
|
+ int loopHealthLevelB = summaryHistoryMapper.cocuntTYOrHL(dto2);
|
|
|
+ dto2.setLoopHealthLevel("C");
|
|
|
+ int loopHealthLevelC = summaryHistoryMapper.cocuntTYOrHL(dto2);
|
|
|
+ int loopHealthLevel = loopHealthLevelA*3 + loopHealthLevelB*2 + loopHealthLevelC*1;
|
|
|
+
|
|
|
+ String secondTitle = " 投用率:" + tyl + "%" + " 总回路数:" + loopHealthLevel + " 导出人:" + sysUser.getRealname();
|
|
|
+ if(dto.getBeginTime() !=null && dto.getEndTime() == null){
|
|
|
+ secondTitle = "起始时间:" + formattedBeginTime + secondTitle;
|
|
|
+ }else if(dto.getBeginTime() ==null && dto.getEndTime() != null){
|
|
|
+ secondTitle = "结束时间:" + formattedEndTime + secondTitle;
|
|
|
+ }else if(dto.getBeginTime() !=null && dto.getEndTime() != null){
|
|
|
+ secondTitle = "起始时间:" + formattedBeginTime + " 结束时间:" + formattedEndTime + secondTitle;
|
|
|
}
|
|
|
+ ExportParams exportParams=new ExportParams(title + "报表", secondTitle, sheetName);
|
|
|
+ exportParams.setImageBasePath(upLoadPath);
|
|
|
+ map.put(NormalExcelConstants.PARAMS, exportParams);
|
|
|
+ map.put(NormalExcelConstants.DATA_LIST, exportList);
|
|
|
+ list.add(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
|
|
+ mv.addObject(NormalExcelConstants.FILE_NAME, title);//此处设置的filename无效 ,前端会重更新设置一下
|
|
|
+ mv.addObject(NormalExcelConstants.MAP_LIST, list);
|
|
|
+ return mv;
|
|
|
+ }
|
|
|
|
|
|
- ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
|
|
- mv.addObject(NormalExcelConstants.FILE_NAME, title);//此处设置的filename无效 ,前端会重更新设置一下
|
|
|
- mv.addObject(NormalExcelConstants.MAP_LIST, list);
|
|
|
- return mv;
|
|
|
- }else {
|
|
|
- //多个装置,多个系统
|
|
|
- List<Map<String, Object>> list = new ArrayList<>();
|
|
|
-
|
|
|
- List<InterlockSummaryHistory> summaryList = summaryHistoryMapper.getDistinctZZXTSummaryList(new InterlockHistoryQueryDTO());
|
|
|
-
|
|
|
- int i = 1;
|
|
|
- for (InterlockSummaryHistory summaryHistory : summaryList){
|
|
|
- dto.setInterlockSystemId(summaryHistory.getInterlockSystemId());//系统id
|
|
|
- List<InterlockSummaryHistoryVO> exportList = interlockDetailHistoryMapper.getForExport(dto);
|
|
|
-
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put(NormalExcelConstants.CLASS, InterlockSummaryHistoryVO.class);
|
|
|
- map.put(NormalExcelConstants.PARAMS, new ExportParams(summaryHistory.getInterlockApparatusId()+ "-"+summaryHistory.getInterlockSystemId() , "第"+ i+ "页"));
|
|
|
- map.put(NormalExcelConstants.DATA_LIST, exportList);
|
|
|
- list.add(map);
|
|
|
- i++;
|
|
|
- }
|
|
|
|
|
|
- ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
|
|
- mv.addObject(NormalExcelConstants.FILE_NAME, title);//此处设置的filename无效 ,前端会重更新设置一下
|
|
|
- mv.addObject(NormalExcelConstants.MAP_LIST, list);
|
|
|
- return mv;
|
|
|
+ private InterlockSummaryHistoryVO zh(InterlockSummaryHistoryVO vo){
|
|
|
+ //仪表状态 0正常1故障
|
|
|
+ if(vo.getInstrumentStatus()!=null){
|
|
|
+ if(vo.getInstrumentStatus().equals("0")) vo.setInstrumentStatus("正常");
|
|
|
+ else if(vo.getInstrumentStatus().equals("1")) vo.setInstrumentStatus("故障");
|
|
|
+ }
|
|
|
+ //控制系统状态 0正常1非正常
|
|
|
+ if(vo.getControlSystemStatus()!=null){
|
|
|
+ if(vo.getControlSystemStatus().equals("0")) vo.setControlSystemStatus("正常");
|
|
|
+ else if(vo.getControlSystemStatus().equals("1")) vo.setControlSystemStatus("非正常");
|
|
|
+ }
|
|
|
+ //联锁状态 0未投用1投用
|
|
|
+ if(vo.getInterlockStatus()!=null){
|
|
|
+ if(vo.getInterlockStatus().equals("0")) vo.setInterlockStatus("未投用");
|
|
|
+ else if(vo.getInterlockStatus().equals("1")) vo.setInterlockStatus("投用");
|
|
|
}
|
|
|
+ //旁路状态 1是0否
|
|
|
+ if(vo.getBypass()!=null){
|
|
|
+ if(vo.getBypass().equals("0")) vo.setBypass("是");
|
|
|
+ else if(vo.getBypass().equals("1")) vo.setBypass("否");
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
}
|