From be9f869e46e9e2adc43766d8f9d8bd8725a8d421 Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Thu, 30 May 2024 18:38:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=EF=BC=9A=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=9C=88=E6=8A=A5=E5=8F=91=E7=94=B5=E9=87=8F=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=EF=BC=8C=E6=97=A5=E5=B8=B8=E7=BB=B4=E6=8A=A4=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/basic/mapper/PersonManagemetMapper.java | 6 +- .../report/controller/MonthReportController.java | 3 +- .../service/IOperStationMonthReportService.java | 2 +- .../impl/OperStationMonthReportServiceImpl.java | 356 +++++++++++---------- 4 files changed, 186 insertions(+), 181 deletions(-) diff --git a/hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/mapper/PersonManagemetMapper.java b/hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/mapper/PersonManagemetMapper.java index fdbaf20..c2f6819 100644 --- a/hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/mapper/PersonManagemetMapper.java +++ b/hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/mapper/PersonManagemetMapper.java @@ -6,6 +6,7 @@ import com.hnac.hzims.basic.vo.PersonManagemetExportVo; import com.hnac.hzims.basic.vo.PersonManagemetVo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import org.springblade.core.datascope.annotation.UserDataAuth; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; import java.util.Date; @@ -18,16 +19,17 @@ import java.util.List; */ @Mapper public interface PersonManagemetMapper extends UserDataScopeBaseMapper { - + @UserDataAuth List getPersonManagemetEntity( @Param(value = "type")String type, @Param(value = "deadStartTime") Date deadStartTime, @Param(value = "deadTime")Date deadTime, @Param(value = "name")String name, @Param(value = "unitName")String unitName, @Param(value = "sex")String sex, @Param(value = "job")String job, @Param(value = "academicTitle")String academicTitle, @Param(value = "status")Integer status, @Param(value = "current")Integer current, @Param(value = "size")Integer size) ; + Integer getCountByPersonManagemetEntity( @Param(value = "type")String type, @Param(value = "deadStartTime") Date deadStartTime, @Param(value = "deadTime")Date deadTime, @Param(value = "name")String name, @Param(value = "unitName")String unitName, @Param(value = "sex")String sex, @Param(value = "job")String job, @Param(value = "academicTitle")String academicTitle, @Param(value = "status")Integer status, @Param(value = "current")Integer current, @Param(value = "size")Integer size) ; - + @UserDataAuth List exportPersonManagemet( @Param(value = "type")String type, @Param(value = "deadStartTime") Date deadStartTime, @Param(value = "deadTime")Date deadTime, @Param(value = "name")String name, @Param(value = "unitName")String unitName, @Param(value = "sex")String sex, @Param(value = "job")String job, diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/MonthReportController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/MonthReportController.java index 01bd8fb..7ed52aa 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/MonthReportController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/MonthReportController.java @@ -129,7 +129,8 @@ public class MonthReportController { // LocalDate endDate = DateUtil.getLastDayByYearMonth(yearAndMonth); // return R.data(taskMonthService.getStationMonthReport(startDate,endDate,deptId.toString())); R deptR = sysClient.getDept(deptId); - return R.data(operStationMonthReportService.getStationMonthReport(yearAndMonth, BeanUtil.copy(deptR.getData(),DeptVO.class))); +// return R.data(operStationMonthReportService.getStationMonthReport(yearAndMonth, BeanUtil.copy(deptR.getData(),DeptVO.class))); + return R.success("月报测试"); } @GetMapping("/test") diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/IOperStationMonthReportService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/IOperStationMonthReportService.java index 33f9805..7dbd987 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/IOperStationMonthReportService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/IOperStationMonthReportService.java @@ -14,7 +14,7 @@ public interface IOperStationMonthReportService { * @param yearAndMonth * @return */ - StationReportAllVO getStationMonthReport(String yearAndMonth, DeptVO deptVO); +// StationReportAllVO getStationMonthReport(String yearAndMonth, DeptVO deptVO); /** * 获取电站月报 * @param yearAndMonth diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/OperStationMonthReportServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/OperStationMonthReportServiceImpl.java index 3983c33..416a1d9 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/OperStationMonthReportServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/OperStationMonthReportServiceImpl.java @@ -128,181 +128,181 @@ public class OperStationMonthReportServiceImpl implements IOperStationMonthRepor **/ private static final String STATION_REPORT_OUTSIDE = "1"; - @Override - public StationReportAllVO getStationMonthReport(String yearAndMonth, DeptVO deptVO) { - StationReportAllVO stationReportAllVo = new StationReportAllVO(); - stationReportAllVo.setStationName(deptVO.getDeptName()); - stationReportAllVo.setYearMonth(YearMonth.parse(yearAndMonth).format(DateTimeFormatter.ofPattern("yyyy年MM月"))); - //处理请求参数 - Map params = new HashMap<>(); - //使用预定义实例来转换 - DateTimeFormatter fmt = DateTimeFormatter.ISO_LOCAL_DATE; - LocalDate startDate = DateUtil.getFirstDayByYearMonth(yearAndMonth); - LocalDate endDate = DateUtil.getLastDayByYearMonth(yearAndMonth); - params.put("startDate", fmt.format(startDate)); - params.put("endDate", fmt.format(endDate)); - - List deptIdList = new ArrayList<>(); - deptIdList.add(deptVO.getId()); - //获取下属机构 - R> childDeptListR = sysClient.getDeptChild(deptVO.getId()); - if (childDeptListR.isSuccess() && CollectionUtil.isNotEmpty(childDeptListR.getData())) { - deptIdList.addAll(childDeptListR.getData().stream().map(Dept::getId).collect(Collectors.toList())); - } - params.put("deptId", deptIdList); - - //获取机构及子机构下的站点 - List stationEntityList = stationService.list(new LambdaQueryWrapper() {{ - in(StationEntity::getRefDept, deptIdList); - }}); - - //监控线程执行完后返回结果 - CountDownLatch countDownLatch = new CountDownLatch(POOL_QUANTITY); - long startMillis = System.currentTimeMillis(); - //电站发电情况 - pool.execute(() -> { - try { - List powerList = new ArrayList<>(); - stationEntityList.forEach(stationEntity -> { - List stationReportVOList = mainSystemMonitoringService.getElectricSituation(yearAndMonth, stationEntity.getCode()); - powerList.addAll(stationReportVOList); - }); - stationReportAllVo.setStationReportVOList(powerList); - } finally { - countDownLatch.countDown(); - log.info("电站发电耗时:"+(System.currentTimeMillis()-startMillis)+"ms"); - System.out.print("电站发电耗时:"+(System.currentTimeMillis()-startMillis)+"ms"); - } - }); - //值班情况 - pool.execute(() -> { - try { -// List dutyReportVOList = iImsDutyMainService.getDutyMainStatisticsByClassId(params); -// stationReportAllVo.setDutyReportVOList(dutyReportVOList); - } finally { - countDownLatch.countDown(); - log.info("值班情况耗时:"+(System.currentTimeMillis()-startMillis)+"ms"); - System.out.print("值班情况耗时:"+(System.currentTimeMillis()-startMillis)+"ms"); - } - }); - //日常维护 - pool.execute(() -> { - try { - List maintenanceList = operMaintenanceTaskService.getMaintenanceStatisticsByDisposer(params); - stationReportAllVo.setMaintenanceReportVOList(maintenanceList); - } finally { - countDownLatch.countDown(); - log.info("日常维护:"+(System.currentTimeMillis()-startMillis)+"ms"); - System.out.print("日常维护:"+(System.currentTimeMillis()-startMillis)+"ms"); - } - }); - //检修 - pool.execute(() -> { - try { -// List accessList = operAccessTaskService.getAccessTaskByName(params); -// stationReportAllVo.setAccessReportVOList(accessList); - } finally { - countDownLatch.countDown(); - log.info("检修:"+(System.currentTimeMillis()-startMillis)+"ms"); - System.out.print("检修:"+(System.currentTimeMillis()-startMillis)+"ms"); - } - }); - //缺陷 - pool.execute(() -> { - try { - List defectList = operDefectService.getFaultByFaultCode(params); - stationReportAllVo.setDefectReportsVOList(defectList); - } finally { - countDownLatch.countDown(); - log.info("缺陷:"+(System.currentTimeMillis()-startMillis)+"ms"); - System.out.print("缺陷:"+(System.currentTimeMillis()-startMillis)+"ms"); - } - }); - //两票统计 - pool.execute(() -> { - try { - String deptIds = deptIdList.stream().map(deptId -> deptId.toString()).collect(Collectors.joining(",")); - TicketStatisticDTO ticketStatisticDTO = new TicketStatisticDTO(); - ticketStatisticDTO.setStartDate(fmt.format(startDate)); - ticketStatisticDTO.setEndDate(fmt.format(endDate)); - ticketStatisticDTO.setDeptIds(deptIds); - List ticketVOS = ticketInfoAllClient.getTicketReportStatistic(ticketStatisticDTO); - stationReportAllVo.setTicketInfoStatisticVOList(ticketVOS); - } finally { - countDownLatch.countDown(); - log.info("两票统计:"+(System.currentTimeMillis()-startMillis)+"ms"); - System.out.print("两票统计:"+(System.currentTimeMillis()-startMillis)+"ms"); - } - }); - //巡检 - pool.execute(() -> { - try { - List taskReportVOS = taskReportClient.getInspectTaskReport(params); - this.fillInspectProblem(startDate, endDate, deptIdList, taskReportVOS); - stationReportAllVo.setInspectReportVOList(taskReportVOS); - } finally { - countDownLatch.countDown(); - log.info("巡检:"+(System.currentTimeMillis()-startMillis)+"ms"); - System.out.print("巡检:"+(System.currentTimeMillis()-startMillis)+"ms"); - } - }); - //智能诊断 - pool.execute(() -> { - if (CollectionUtil.isNotEmpty(stationEntityList)) { - StatisticStatusDTO statisticStatusDTO = new StatisticStatusDTO(); - List stationIds = stationEntityList.stream().map(StationEntity::getCode).collect(Collectors.toList()); - String[] stationIdArray = new String[stationIds.size()]; - stationIds.toArray(stationIdArray); - statisticStatusDTO.setStationIds(stationIdArray); - statisticStatusDTO.setThreshold(0.3f); - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - statisticStatusDTO.setStart(formatter.format(LocalDateTime.of(startDate, LocalTime.MIN))); - statisticStatusDTO.setEnd(formatter.format(LocalDateTime.of(endDate, LocalTime.MAX))); - R>> diagnoseResult = diagnoseClient.getStatisticStatus(statisticStatusDTO); - List diagnoseConclusionList = new ArrayList<>(); - if (diagnoseResult.isSuccess()) { - Map> statisticStatusVOList = diagnoseResult.getData(); - statisticStatusVOList.forEach((k, v) -> { - if (v.size() > 5) { - v = v.subList(0, 5); - } - String diagnoseConclusion = v.stream().map(s -> { - String riskLevel = ""; - if (s.getSeverity() >= 3) { - riskLevel = "高风险"; - } else if (s.getSeverity() == 2) { - riskLevel = "一般"; - } else if (s.getSeverity() == 1) { - riskLevel = "低风险"; - } - String c = "发生在" + s.getOrd() + "的" + s.getName() + ",风险等级:" + riskLevel + ",最后一次出现的时间:" + s.getLastBeginTime() + ";";//,持续时长:"+s.getLongTime()+" - return c; - }).collect(Collectors.joining("\n")); - if (StringUtil.isNotBlank(diagnoseConclusion)) { - StationEntity stationEntity = stationService.getById(k); - if (ObjectUtil.isNotEmpty(stationEntity)) { - diagnoseConclusion = stationEntity.getName() + "本月智能诊断服务预警前五位的可能存在风险的故障信息:\n" + diagnoseConclusion; - diagnoseConclusionList.add(diagnoseConclusion); - } - } - }); - stationReportAllVo.setDiagnoseConclusion(diagnoseConclusionList.stream().collect(Collectors.joining("\n"))); - stationReportAllVo.setStatisticStatusVOList(statisticStatusVOList); - } - } - countDownLatch.countDown(); - }); - //所有模板数据获取完成后释放锁 - try { - countDownLatch.await(); - } catch (InterruptedException e) { - e.printStackTrace(); - Thread.currentThread().interrupt(); - } - //小结 - this.getStationReportConclusion(stationReportAllVo, params); - return stationReportAllVo; - } +// @Override +// public StationReportAllVO getStationMonthReport(String yearAndMonth, DeptVO deptVO) { +// StationReportAllVO stationReportAllVo = new StationReportAllVO(); +// stationReportAllVo.setStationName(deptVO.getDeptName()); +// stationReportAllVo.setYearMonth(YearMonth.parse(yearAndMonth).format(DateTimeFormatter.ofPattern("yyyy年MM月"))); +// //处理请求参数 +// Map params = new HashMap<>(); +// //使用预定义实例来转换 +// DateTimeFormatter fmt = DateTimeFormatter.ISO_LOCAL_DATE; +// LocalDate startDate = DateUtil.getFirstDayByYearMonth(yearAndMonth); +// LocalDate endDate = DateUtil.getLastDayByYearMonth(yearAndMonth); +// params.put("startDate", fmt.format(startDate)); +// params.put("endDate", fmt.format(endDate)); +// +// List deptIdList = new ArrayList<>(); +// deptIdList.add(deptVO.getId()); +// //获取下属机构 +// R> childDeptListR = sysClient.getDeptChild(deptVO.getId()); +// if (childDeptListR.isSuccess() && CollectionUtil.isNotEmpty(childDeptListR.getData())) { +// deptIdList.addAll(childDeptListR.getData().stream().map(Dept::getId).collect(Collectors.toList())); +// } +// params.put("deptId", deptIdList); +// +// //获取机构及子机构下的站点 +// List stationEntityList = stationService.list(new LambdaQueryWrapper() {{ +// in(StationEntity::getRefDept, deptIdList); +// }}); +// +// //监控线程执行完后返回结果 +// CountDownLatch countDownLatch = new CountDownLatch(POOL_QUANTITY); +// long startMillis = System.currentTimeMillis(); +// //电站发电情况 +// pool.execute(() -> { +// try { +// List powerList = new ArrayList<>(); +// stationEntityList.forEach(stationEntity -> { +// List stationReportVOList = mainSystemMonitoringService.getElectricSituation(yearAndMonth, stationEntity.getCode()); +// powerList.addAll(stationReportVOList); +// }); +// stationReportAllVo.setStationReportVOList(powerList); +// } finally { +// countDownLatch.countDown(); +// log.info("电站发电耗时:"+(System.currentTimeMillis()-startMillis)+"ms"); +// System.out.print("电站发电耗时:"+(System.currentTimeMillis()-startMillis)+"ms"); +// } +// }); +// //值班情况 +// pool.execute(() -> { +// try { +//// List dutyReportVOList = iImsDutyMainService.getDutyMainStatisticsByClassId(params); +//// stationReportAllVo.setDutyReportVOList(dutyReportVOList); +// } finally { +// countDownLatch.countDown(); +// log.info("值班情况耗时:"+(System.currentTimeMillis()-startMillis)+"ms"); +// System.out.print("值班情况耗时:"+(System.currentTimeMillis()-startMillis)+"ms"); +// } +// }); +// //日常维护 +// pool.execute(() -> { +// try { +// List maintenanceList = operMaintenanceTaskService.getMaintenanceStatisticsByDisposer(params); +// stationReportAllVo.setMaintenanceReportVOList(maintenanceList); +// } finally { +// countDownLatch.countDown(); +// log.info("日常维护:"+(System.currentTimeMillis()-startMillis)+"ms"); +// System.out.print("日常维护:"+(System.currentTimeMillis()-startMillis)+"ms"); +// } +// }); +// //检修 +// pool.execute(() -> { +// try { +//// List accessList = operAccessTaskService.getAccessTaskByName(params); +//// stationReportAllVo.setAccessReportVOList(accessList); +// } finally { +// countDownLatch.countDown(); +// log.info("检修:"+(System.currentTimeMillis()-startMillis)+"ms"); +// System.out.print("检修:"+(System.currentTimeMillis()-startMillis)+"ms"); +// } +// }); +// //缺陷 +// pool.execute(() -> { +// try { +// List defectList = operDefectService.getFaultByFaultCode(params); +// stationReportAllVo.setDefectReportsVOList(defectList); +// } finally { +// countDownLatch.countDown(); +// log.info("缺陷:"+(System.currentTimeMillis()-startMillis)+"ms"); +// System.out.print("缺陷:"+(System.currentTimeMillis()-startMillis)+"ms"); +// } +// }); +// //两票统计 +// pool.execute(() -> { +// try { +// String deptIds = deptIdList.stream().map(deptId -> deptId.toString()).collect(Collectors.joining(",")); +// TicketStatisticDTO ticketStatisticDTO = new TicketStatisticDTO(); +// ticketStatisticDTO.setStartDate(fmt.format(startDate)); +// ticketStatisticDTO.setEndDate(fmt.format(endDate)); +// ticketStatisticDTO.setDeptIds(deptIds); +// List ticketVOS = ticketInfoAllClient.getTicketReportStatistic(ticketStatisticDTO); +// stationReportAllVo.setTicketInfoStatisticVOList(ticketVOS); +// } finally { +// countDownLatch.countDown(); +// log.info("两票统计:"+(System.currentTimeMillis()-startMillis)+"ms"); +// System.out.print("两票统计:"+(System.currentTimeMillis()-startMillis)+"ms"); +// } +// }); +// //巡检 +// pool.execute(() -> { +// try { +// List taskReportVOS = taskReportClient.getInspectTaskReport(params); +// this.fillInspectProblem(startDate, endDate, deptIdList, taskReportVOS); +// stationReportAllVo.setInspectReportVOList(taskReportVOS); +// } finally { +// countDownLatch.countDown(); +// log.info("巡检:"+(System.currentTimeMillis()-startMillis)+"ms"); +// System.out.print("巡检:"+(System.currentTimeMillis()-startMillis)+"ms"); +// } +// }); +// //智能诊断 +// pool.execute(() -> { +// if (CollectionUtil.isNotEmpty(stationEntityList)) { +// StatisticStatusDTO statisticStatusDTO = new StatisticStatusDTO(); +// List stationIds = stationEntityList.stream().map(StationEntity::getCode).collect(Collectors.toList()); +// String[] stationIdArray = new String[stationIds.size()]; +// stationIds.toArray(stationIdArray); +// statisticStatusDTO.setStationIds(stationIdArray); +// statisticStatusDTO.setThreshold(0.3f); +// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); +// statisticStatusDTO.setStart(formatter.format(LocalDateTime.of(startDate, LocalTime.MIN))); +// statisticStatusDTO.setEnd(formatter.format(LocalDateTime.of(endDate, LocalTime.MAX))); +// R>> diagnoseResult = diagnoseClient.getStatisticStatus(statisticStatusDTO); +// List diagnoseConclusionList = new ArrayList<>(); +// if (diagnoseResult.isSuccess()) { +// Map> statisticStatusVOList = diagnoseResult.getData(); +// statisticStatusVOList.forEach((k, v) -> { +// if (v.size() > 5) { +// v = v.subList(0, 5); +// } +// String diagnoseConclusion = v.stream().map(s -> { +// String riskLevel = ""; +// if (s.getSeverity() >= 3) { +// riskLevel = "高风险"; +// } else if (s.getSeverity() == 2) { +// riskLevel = "一般"; +// } else if (s.getSeverity() == 1) { +// riskLevel = "低风险"; +// } +// String c = "发生在" + s.getOrd() + "的" + s.getName() + ",风险等级:" + riskLevel + ",最后一次出现的时间:" + s.getLastBeginTime() + ";";//,持续时长:"+s.getLongTime()+" +// return c; +// }).collect(Collectors.joining("\n")); +// if (StringUtil.isNotBlank(diagnoseConclusion)) { +// StationEntity stationEntity = stationService.getById(k); +// if (ObjectUtil.isNotEmpty(stationEntity)) { +// diagnoseConclusion = stationEntity.getName() + "本月智能诊断服务预警前五位的可能存在风险的故障信息:\n" + diagnoseConclusion; +// diagnoseConclusionList.add(diagnoseConclusion); +// } +// } +// }); +// stationReportAllVo.setDiagnoseConclusion(diagnoseConclusionList.stream().collect(Collectors.joining("\n"))); +// stationReportAllVo.setStatisticStatusVOList(statisticStatusVOList); +// } +// } +// countDownLatch.countDown(); +// }); +// //所有模板数据获取完成后释放锁 +// try { +// countDownLatch.await(); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// Thread.currentThread().interrupt(); +// } +// //小结 +// this.getStationReportConclusion(stationReportAllVo, params); +// return stationReportAllVo; +// } @Override public StationRunReportAllVO getStationMonthReportV2(String yearAndMonth, DeptVO deptVO) { StationRunReportAllVO stationReportAllVo = new StationRunReportAllVO(); @@ -1217,8 +1217,10 @@ public class OperStationMonthReportServiceImpl implements IOperStationMonthRepor //日常维护任务统计 if (CollectionUtil.isNotEmpty(stationReportAllVo.getMaintenanceReportVOList())) { List maintenanceReportVOList = stationReportAllVo.getMaintenanceReportVOList(); - int completeTaskNum = maintenanceReportVOList.stream().filter(vo -> Func.isNotEmpty(vo.getCompleteNum())).mapToInt(RunReportVO::getCompleteNum).sum(); - int incompleteTaskNum = maintenanceReportVOList.stream().filter(vo -> Func.isNotEmpty(vo.getIncompleteNum())).mapToInt(RunReportVO::getIncompleteNum).sum(); + int completeTaskNum = maintenanceReportVOList.stream().filter(vo ->"合计".equals(vo.getUserName())) + .filter(vo -> Func.isNotEmpty(vo.getCompleteNum())).mapToInt(RunReportVO::getCompleteNum).sum(); + int incompleteTaskNum = maintenanceReportVOList.stream().filter(vo ->"合计".equals(vo.getUserName())) + .filter(vo -> Func.isNotEmpty(vo.getIncompleteNum())).mapToInt(RunReportVO::getIncompleteNum).sum(); if (completeTaskNum == 0 && incompleteTaskNum == 0) { conclusion.append("2、无日常维护任务;\r\n"); } else {