Browse Source

修正:统计月报发电量数据,日常维护数据

zhongwei
ty 8 months ago
parent
commit
be9f869e46
  1. 6
      hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/mapper/PersonManagemetMapper.java
  2. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/MonthReportController.java
  3. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/IOperStationMonthReportService.java
  4. 356
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/OperStationMonthReportServiceImpl.java

6
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<PersonManagemetEntity> {
@UserDataAuth
List<PersonManagemetVo> 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<PersonManagemetExportVo> 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,

3
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<Dept> 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")

2
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

356
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<String, Object> 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<Long> deptIdList = new ArrayList<>();
deptIdList.add(deptVO.getId());
//获取下属机构
R<List<Dept>> 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<StationEntity> stationEntityList = stationService.list(new LambdaQueryWrapper<StationEntity>() {{
in(StationEntity::getRefDept, deptIdList);
}});
//监控线程执行完后返回结果
CountDownLatch countDownLatch = new CountDownLatch(POOL_QUANTITY);
long startMillis = System.currentTimeMillis();
//电站发电情况
pool.execute(() -> {
try {
List<StationReportVO> powerList = new ArrayList<>();
stationEntityList.forEach(stationEntity -> {
List<StationReportVO> 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<DutyReportVO> 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<MaintenanceReportVO> 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<AccessRunReportVO> 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<DefectReportsVO> 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<TicketInfoStatisticVO> 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<TaskReportVO> 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<String> 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<Map<String, List<StatisticStatusVO>>> diagnoseResult = diagnoseClient.getStatisticStatus(statisticStatusDTO);
List<String> diagnoseConclusionList = new ArrayList<>();
if (diagnoseResult.isSuccess()) {
Map<String, List<StatisticStatusVO>> 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<String, Object> 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<Long> deptIdList = new ArrayList<>();
// deptIdList.add(deptVO.getId());
// //获取下属机构
// R<List<Dept>> 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<StationEntity> stationEntityList = stationService.list(new LambdaQueryWrapper<StationEntity>() {{
// in(StationEntity::getRefDept, deptIdList);
// }});
//
// //监控线程执行完后返回结果
// CountDownLatch countDownLatch = new CountDownLatch(POOL_QUANTITY);
// long startMillis = System.currentTimeMillis();
// //电站发电情况
// pool.execute(() -> {
// try {
// List<StationReportVO> powerList = new ArrayList<>();
// stationEntityList.forEach(stationEntity -> {
// List<StationReportVO> 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<DutyReportVO> 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<MaintenanceReportVO> 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<AccessRunReportVO> 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<DefectReportsVO> 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<TicketInfoStatisticVO> 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<TaskReportVO> 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<String> 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<Map<String, List<StatisticStatusVO>>> diagnoseResult = diagnoseClient.getStatisticStatus(statisticStatusDTO);
// List<String> diagnoseConclusionList = new ArrayList<>();
// if (diagnoseResult.isSuccess()) {
// Map<String, List<StatisticStatusVO>> 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<RunReportVO> 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 {

Loading…
Cancel
Save