diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/RunReportDataAnalyseDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/RunReportDataAnalyseDTO.java index 6a9b4da..92c7949 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/RunReportDataAnalyseDTO.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/business/dto/RunReportDataAnalyseDTO.java @@ -17,17 +17,18 @@ import java.util.List; public class RunReportDataAnalyseDTO implements Serializable { /** - * 设备编号 - */ - private String emCode; - - /** * 设备名称 */ @JSONField(name = "name") private String emName; /** + * 机组序号 + */ + @JSONField(serialize = false) + private Integer deviceOrder; + + /** * 发电量数据 */ private List power; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/RunMonthController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/RunMonthController.java index 9801a20..a3a905f 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/RunMonthController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/RunMonthController.java @@ -5,6 +5,7 @@ import com.hnac.hzims.operational.report.entity.RunMonthEntity; import com.hnac.hzims.operational.report.service.RunMonthService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; import org.springblade.core.tool.api.R; import org.springframework.web.bind.annotation.GetMapping; @@ -54,4 +55,12 @@ public class RunMonthController { @RequestParam("stationCode") String stationCode){ runMonthService.export(mon,stationCode); } + + @GetMapping("/generateAnalyseResult") + @ApiOperation(value = "生成分析结果",notes = "生成分析结果") + @ApiOperationSupport(order = 5) + public R generateAnalyseResult(@RequestParam @ApiParam("查询月份") String month, @RequestParam @ApiParam("站点编号") String stationCode) { + runMonthService.generateAnalyseResult(month,stationCode); + return R.success("调用成功!"); + } } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/RunMonthService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/RunMonthService.java index 416d45d..8f484f7 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/RunMonthService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/RunMonthService.java @@ -16,4 +16,12 @@ public interface RunMonthService extends IService { Boolean generate(String mon, String stationCode); Boolean check(String stationCode); + + /** + * 生成分析结果 + * @param month 月份 + * @param stationCode 站点编号 + * @return 大模型调用结果 + */ + Boolean generateAnalyseResult(String month,String stationCode); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java index 803c856..02b3e28 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java @@ -23,6 +23,7 @@ import com.hnac.hzims.operational.report.entity.RunMonthEntity; import com.hnac.hzims.operational.report.mapper.RunMonthMapper; import com.hnac.hzims.operational.report.service.RunMonthReportService; import com.hnac.hzims.operational.report.service.RunMonthService; +import com.hnac.hzims.operational.report.utils.SetNameFormatterUtil; import com.hnac.hzims.operational.report.vo.*; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.service.IStationService; @@ -285,7 +286,7 @@ public class RunMonthServiceImpl extends ServiceImpl this.smartReportGeneratePower(mon,stationCode),"运行月报分析结论").start(); return save; } @@ -313,7 +314,11 @@ public class RunMonthServiceImpl extends ServiceImpl analyseDTOList = analyseVOList.stream() + .sorted(Comparator.comparing(RunReportDataAnalyseDTO::getDeviceOrder)) + .collect(Collectors.toList()); + analyseRequest.setAnalyseDTOS(analyseDTOList); dataAnalyseClient.smartReportGeneratePower(analyseRequest); } @@ -332,14 +337,43 @@ public class RunMonthServiceImpl extends ServiceImpl runDatas = rundatas.stream().map(RunDataVo::getDeviceName).distinct().collect(Collectors.toList()); List alarmDatas = alarms.stream().map(RunAlarmVo::getDeviceName).distinct().collect(Collectors.toList()); Collection unionDeviceNames = CollectionUtils.union(runDatas, alarmDatas); + // 过滤掉设备名称无法获取机组设备的字段以及值为空的字段 unionDeviceNames.forEach(deviceName -> { - Optional exist = analyseVOList.stream().filter(vo -> deviceName.equals(vo.getEmName())).findFirst(); - if(!exist.isPresent()) { - // 若该设备未新增接受数据对象,则新增之后填充数据 - RunReportDataAnalyseDTO analyseVO = this.createDeviceAnalyse(deviceName, month); - analyseVOList.add(analyseVO); + Integer deviceOrder = SetNameFormatterUtil.getSetOrder(deviceName); + if(Func.isNotEmpty(deviceOrder)) { + String formateDevice = deviceOrder + "#机组"; + Optional exist = analyseVOList.stream().filter(a -> formateDevice.equals(a.getEmName())).findFirst(); + if(!exist.isPresent()) { + // 若该设备未新增接受数据对象,则新增之后填充数据 + RunReportDataAnalyseDTO analyseVO = this.createDeviceAnalyse(formateDevice, month, deviceOrder); + analyseVOList.add(analyseVO); + } + List runDataVos = rundatas.stream().filter(data -> deviceName.equals(data.getDeviceName())).collect(Collectors.toList()); + Double power = runDataVos.stream().collect(Collectors.summingDouble(RunDataVo::getGenerate)); + Double runHours = runDataVos.stream().collect(Collectors.summingDouble(RunDataVo::getRunHours)); + RunReportDataAnalyseDTO analyseDTO = analyseVOList.stream().filter(a -> formateDevice.equals(a.getEmName())).findFirst().get(); + PowerDataDTO powerDataDTO = analyseDTO.getPower().stream().filter(p -> req.getMonth().equals(p.getDate())).findFirst().get(); + // 发电量赋值 + if(Func.isNotEmpty(powerDataDTO)) { + if(Func.isNotEmpty(power)) { + powerDataDTO.setValue(Optional.ofNullable(powerDataDTO.getValue()).orElse(0.0) + power); + } + if(Func.isNotEmpty(runHours)) { + powerDataDTO.setRunTime(Optional.ofNullable(powerDataDTO.getRunTime()).orElse(0.0) + runHours); + } + } + // 告警信息 + List soeDataDTOS = alarms.stream().filter(a -> deviceName.equals(a.getDeviceName())).map(alarm -> { + SoeDataDTO soeDataDTO = new SoeDataDTO(); + soeDataDTO.setDate(month); + soeDataDTO.setName(alarm.getContent()); + soeDataDTO.setTimes(alarm.getCount()); + return soeDataDTO; + }).collect(Collectors.toList()); + if(CollectionUtil.isNotEmpty(soeDataDTOS)) { + analyseDTO.getSoe().addAll(soeDataDTOS); + } } - this.fillDeviceAnalyse(deviceName,req.getMonth(),rundatas,alarms,analyseVOList); }); } } @@ -348,11 +382,13 @@ public class RunMonthServiceImpl extends ServiceImpl powerDataDTOS = Lists.newArrayList(); List runTimeDataDTOS = Lists.newArrayList(); @@ -368,37 +404,37 @@ public class RunMonthServiceImpl extends ServiceImpl rundatas,List alarms,List analyseVOList) { - Optional runDataVo = rundatas.stream().filter(d -> deviceName.equals(d.getDeviceName())).findFirst(); - List soeDataDTOS = alarms.stream().filter(a -> deviceName.equals(a.getDeviceName())).map(alarm -> { - SoeDataDTO soeDataDTO = new SoeDataDTO(); - soeDataDTO.setDate(month); - soeDataDTO.setName(alarm.getContent()); - soeDataDTO.setTimes(alarm.getCount()); - return soeDataDTO; - }).collect(Collectors.toList()); - RunReportDataAnalyseDTO analyseVO = analyseVOList.stream().filter(vo -> deviceName.equals(vo.getEmName())).findFirst().get(); - if(runDataVo.isPresent()) { - // 补充发电量、运行时长 - Optional powerData = analyseVO.getPower().stream().filter(p -> month.equals(p.getDate())).findFirst(); - if(powerData.isPresent()) { - powerData.get().setValue(runDataVo.get().getGenerate()); - powerData.get().setRunTime(runDataVo.get().getRunHours()); - } - } - if(Func.isNotEmpty(soeDataDTOS)) { - // 补充告警 - analyseVO.getSoe().addAll(soeDataDTOS); - } - } +// /** +// * 填充大模型分析所需参数 +// * @param deviceName 设备名称 +// * @param month 月报数据月份 +// * @param rundatas 月报运行数据 +// * @param alarms 月报告警报表数据 +// * @param analyseVOList 待填充的设备分析传参对象 +// */ +// private void fillDeviceAnalyse(String deviceName,String formateDeviceName,String month,List rundatas,List alarms,List analyseVOList) { +// Optional runDataVo = rundatas.stream().filter(d -> deviceName.equals(d.getDeviceName())).findFirst(); +// List soeDataDTOS = alarms.stream().filter(a -> deviceName.equals(a.getDeviceName())).map(alarm -> { +// SoeDataDTO soeDataDTO = new SoeDataDTO(); +// soeDataDTO.setDate(month); +// soeDataDTO.setName(alarm.getContent()); +// soeDataDTO.setTimes(alarm.getCount()); +// return soeDataDTO; +// }).collect(Collectors.toList()); +// RunReportDataAnalyseDTO analyseVO = analyseVOList.stream().filter(vo -> deviceName.equals(vo.getEmName())).findFirst().get(); +// if(runDataVo.isPresent()) { +// // 补充发电量、运行时长 +// Optional powerData = analyseVO.getPower().stream().filter(p -> month.equals(p.getDate())).findFirst(); +// if(powerData.isPresent()) { +// powerData.get().setValue(); +// powerData.get().setRunTime(runDataVo.get().getRunHours()); +// } +// } +// if(Func.isNotEmpty(soeDataDTOS)) { +// // 补充告警 +// analyseVO.getSoe().addAll(soeDataDTOS); +// } +// } /** * 先删除原先月报数据 @@ -797,6 +833,12 @@ public class RunMonthServiceImpl extends ServiceImpl parts = Func.toStrList("#", setNameFormatter); + if(CollectionUtil.isNotEmpty(parts)) { + Optional orderOptional = parts.stream().map(SetNameFormatterUtil::disassemblyOrder).filter(Func::isNotEmpty).findFirst(); + return orderOptional.orElse(null); + } + return null; + } + + /** + * 根据字符串拆解出对应的序号 + * @param part 待拆解的字符串 + * @return + */ + public static Integer disassemblyOrder(String part) { + part = part.trim(); + if(Func.isNotEmpty(part) && Character.isDigit(part.charAt(part.length() - 1))) { + return Character.getNumericValue(part.charAt(part.length() - 1)); + } + return null; + } +}