|
|
|
@ -15,10 +15,7 @@ import com.hnac.hzims.hzimsweather.feign.IHeWeatherWeatherClient;
|
|
|
|
|
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherHourlyResponse; |
|
|
|
|
import com.hnac.hzims.message_alarm.constants.AlarmConstants; |
|
|
|
|
import com.hnac.hzims.message_alarm.dto.*; |
|
|
|
|
import com.hnac.hzims.message_alarm.entity.PlanConfigInfo; |
|
|
|
|
import com.hnac.hzims.message_alarm.entity.PlanInfo; |
|
|
|
|
import com.hnac.hzims.message_alarm.entity.PlanParamInfo; |
|
|
|
|
import com.hnac.hzims.message_alarm.entity.PlanResultInfo; |
|
|
|
|
import com.hnac.hzims.message_alarm.entity.*; |
|
|
|
|
import com.hnac.hzims.message_alarm.mapper.PlanInfoMapper; |
|
|
|
|
import com.hnac.hzims.message_alarm.service.*; |
|
|
|
|
import com.hnac.hzims.message_alarm.util.HttpClientUtils; |
|
|
|
@ -72,6 +69,9 @@ public class PlanInfoServiceImpl extends ServiceImpl<PlanInfoMapper, PlanInfo> i
|
|
|
|
|
IPlanResultInfoService planResultInfoService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
IPlanFlowResultInfoService planFlowResultInfoService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
IBaseInfoClient baseInfoClient; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
@ -176,12 +176,45 @@ public class PlanInfoServiceImpl extends ServiceImpl<PlanInfoMapper, PlanInfo> i
|
|
|
|
|
|
|
|
|
|
//将预报计算结果返回 后续作为调度计算的入参使用
|
|
|
|
|
result.setPlanResultInfos(planResultInfos); |
|
|
|
|
|
|
|
|
|
Map<String,Map<String, Double>> dealResult=dealResult(config,planInfo,calResults); |
|
|
|
|
dealReportResult(result.getReport(),dealResult); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
log.info("===预报干预出参planResultInfos====:{}", result.getPlanResultInfos()); |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void dealReportResult(List<ReportVo> report,Map<String,Map<String, Double>> map){ |
|
|
|
|
log.info("===dealReportResult====report:{}", report); |
|
|
|
|
|
|
|
|
|
Map<String, Double> mnllMap=map.get("mnllMap"); |
|
|
|
|
log.info("===dealReportResult====mnllMap:{}", mnllMap); |
|
|
|
|
|
|
|
|
|
Map<String, Double> ftrkMap=map.get("ftrkMap"); |
|
|
|
|
log.info("===dealReportResult====ftrkMap:{}", ftrkMap); |
|
|
|
|
|
|
|
|
|
for(ReportVo vo:report){ |
|
|
|
|
String key=vo.getTime()+":00"; |
|
|
|
|
log.info("===dealReportResult====key:{}", key); |
|
|
|
|
|
|
|
|
|
// Map<String, Double> jlsMap=map.get("jlsMap");
|
|
|
|
|
if(mnllMap!=null) { |
|
|
|
|
vo.setSimulatedFlow(mnllMap.get(key) != null ? String.valueOf(mnllMap.get(key)) : "-"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// if(jlsMap!=null) {
|
|
|
|
|
// vo.setRunoffDepth(jlsMap.get(key) != null ? String.valueOf(jlsMap.get(key)) : "-");
|
|
|
|
|
// }
|
|
|
|
|
if(ftrkMap!=null) { |
|
|
|
|
vo.setReverseFlow(ftrkMap.get(key) != null ? String.valueOf(ftrkMap.get(key)) : "-"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private ForecastVo forecastByHuman(Long id) { |
|
|
|
|
ForecastVo forecastVo = new ForecastVo(); |
|
|
|
|
IncomingWaterForecastVo incomingWaterForecastVo = new IncomingWaterForecastVo(); |
|
|
|
@ -218,7 +251,9 @@ public class PlanInfoServiceImpl extends ServiceImpl<PlanInfoMapper, PlanInfo> i
|
|
|
|
|
ZoneId zoneId = ZoneId.systemDefault(); |
|
|
|
|
List<PlanResultInfo> planResultInfos = planResultInfoService.list(new QueryWrapper<PlanResultInfo>().eq("plan_id", id).orderByAsc("time")); |
|
|
|
|
log.info("==预报方案结果==:{}", planResultInfos); |
|
|
|
|
this.getIncomingWaterForecast(incomingWaterForecastVo, planParamInfo.getStcd(), Date.from(startTime.atZone(zoneId).toInstant()), Date.from(endTime.atZone(zoneId).toInstant()), planResultInfos, BigDecimal.valueOf(planParamInfo.getSt()), formatter,reportVoList,indexMap); |
|
|
|
|
this.getIncomingWaterForecast(incomingWaterForecastVo, planParamInfo.getStcd(), |
|
|
|
|
Date.from(startTime.atZone(zoneId).toInstant()), Date.from(endTime.atZone(zoneId).toInstant()), |
|
|
|
|
planResultInfos, BigDecimal.valueOf(planParamInfo.getSt()), formatter,reportVoList,indexMap); |
|
|
|
|
forecastVo.setIncomingWaterForecastVo(incomingWaterForecastVo); |
|
|
|
|
log.info("==预报方案reportVoList==:{}", reportVoList); |
|
|
|
|
forecastVo.setReport(reportVoList); |
|
|
|
@ -397,7 +432,7 @@ public class PlanInfoServiceImpl extends ServiceImpl<PlanInfoMapper, PlanInfo> i
|
|
|
|
|
forecastDataVo.setRz(planResultInfo.getWaterLevel() != null ? String.valueOf(planResultInfo.getWaterLevel()) : "-"); |
|
|
|
|
forecastDataVo.setDrp(planResultInfo.getRainFall() != null ? String.valueOf(planResultInfo.getRainFall()) : "-"); |
|
|
|
|
forecastDataVo.setInFlow(planResultInfo.getIncomeFall() != null ? String.valueOf(planResultInfo.getIncomeFall()) : "-"); |
|
|
|
|
forecastDataVo.setOutFlow(planResultInfo.getPowerFlow() != null ? st.add(BigDecimal.valueOf(planResultInfo.getPowerFlow())).toString() : "-"); |
|
|
|
|
forecastDataVo.setOutFlow(planResultInfo.getPowerFlow() != null ? st.add(planResultInfo.getPowerFlow()).toString() : "-"); |
|
|
|
|
forecastDataVoList.add(forecastDataVo); |
|
|
|
|
|
|
|
|
|
TimeValueVo valueVo = new TimeValueVo(); |
|
|
|
@ -486,9 +521,11 @@ public class PlanInfoServiceImpl extends ServiceImpl<PlanInfoMapper, PlanInfo> i
|
|
|
|
|
log.info(config.getStnm()+"==获取历史负荷数据==:{}",load); |
|
|
|
|
log.info(config.getStnm()+"==获取负荷和数据==:{}",load1); |
|
|
|
|
Map<String, String> drpMap = new HashMap<>(); |
|
|
|
|
if (CollectionUtils.isNotEmpty(drpsignageList)) { |
|
|
|
|
for (Map<String, String> map : drpsignageList) { |
|
|
|
|
drpMap.put(map.get("time"), map.get("drp")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
log.info(config.getStnm()+"==获取历史雨量数据Map==:{}",drpMap); |
|
|
|
|
Map<String, String> loadMap = new HashMap<>(); |
|
|
|
|
if (CollectionUtils.isNotEmpty(load1)) { |
|
|
|
@ -498,13 +535,13 @@ public class PlanInfoServiceImpl extends ServiceImpl<PlanInfoMapper, PlanInfo> i
|
|
|
|
|
List<HisDataResultDTO> dtoList = new ArrayList<>(); |
|
|
|
|
if (CollectionUtils.isNotEmpty(rzsignageList)) { |
|
|
|
|
Map<String, String> finalLoadMap = loadMap; |
|
|
|
|
rzsignageList.stream().forEach(list->{ |
|
|
|
|
rzsignageList.stream().forEach(item->{ |
|
|
|
|
HisDataResultDTO dto = new HisDataResultDTO(); |
|
|
|
|
String time = list.get("time"); |
|
|
|
|
String time = item.get("time"); |
|
|
|
|
//时间
|
|
|
|
|
dto.setTime(time); |
|
|
|
|
//水位
|
|
|
|
|
dto.setRz(list.get("rz")); |
|
|
|
|
dto.setRz(item.get("rz")); |
|
|
|
|
//雨量
|
|
|
|
|
dto.setDrp(drpMap.get(time)); |
|
|
|
|
//负荷
|
|
|
|
@ -618,8 +655,8 @@ public class PlanInfoServiceImpl extends ServiceImpl<PlanInfoMapper, PlanInfo> i
|
|
|
|
|
planResultInfo.setPlanId(planInfo.getId()); |
|
|
|
|
planResultInfo.setStcd(stcd); |
|
|
|
|
planResultInfo.setTime(LocalDateTime.parse(tm, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"))); |
|
|
|
|
planResultInfo.setRainFall(entry.getValue()); |
|
|
|
|
planResultInfo.setIncomeFall(ybllMap.get(tm)); |
|
|
|
|
planResultInfo.setRainFall(new BigDecimal(entry.getValue().toString())); |
|
|
|
|
planResultInfo.setIncomeFall(new BigDecimal(ybllMap.get(tm).toString())); |
|
|
|
|
planResultInfos.add(planResultInfo); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -628,6 +665,79 @@ public class PlanInfoServiceImpl extends ServiceImpl<PlanInfoMapper, PlanInfo> i
|
|
|
|
|
planResultInfoService.saveBatch(planResultInfos); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Map<String,Map<String, Double>> dealResult(PlanConfigInfo config,PlanInfo planInfo,List<CalResultDTO> calResults) { |
|
|
|
|
log.info("====dealResult==="); |
|
|
|
|
|
|
|
|
|
List<PlanFlowResultInfo> planFlowResultInfos=new ArrayList<>(); |
|
|
|
|
Map<String,Map<String, Double>> res=new HashMap<>(); |
|
|
|
|
//获取发电调度结果
|
|
|
|
|
for (CalResultDTO calResult : calResults) { |
|
|
|
|
String forecastStationName = calResult.getForecastStationName(); |
|
|
|
|
String stnm = config.getStnm(); |
|
|
|
|
String stcd = config.getStcd(); |
|
|
|
|
if (stnm.equals(forecastStationName)) { |
|
|
|
|
RsvrResultDTO rsvrResult = calResult.getRsvrResult(); |
|
|
|
|
ForecastCalResultDTO forecastCalResult = rsvrResult.getForecastCalResult(); |
|
|
|
|
List<ProcessValueDTO> processValues = forecastCalResult.getProcessValues(); |
|
|
|
|
if (CollectionUtils.isNotEmpty(processValues)) { |
|
|
|
|
//模拟流量Map
|
|
|
|
|
Map<String, Double> mnllMap = new HashMap<>(); |
|
|
|
|
//反推入库Map
|
|
|
|
|
Map<String, Double> ftrkMap = new HashMap<>(); |
|
|
|
|
//径流深Map
|
|
|
|
|
// Map<String, Double> jlsMap = new HashMap<>();
|
|
|
|
|
for (ProcessValueDTO processValue : processValues) { |
|
|
|
|
String valueName = processValue.getValueName(); |
|
|
|
|
List<ValueDataDTO> valueDatas = processValue.getValueDatas(); |
|
|
|
|
if ("反推入库".equals(valueName)) { |
|
|
|
|
for(ValueDataDTO dto:valueDatas){ |
|
|
|
|
ftrkMap.put(dto.getTm(),dto.getValue()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if ("模拟流量".equals(valueName)) { |
|
|
|
|
for(ValueDataDTO dto:valueDatas){ |
|
|
|
|
mnllMap.put(dto.getTm(),dto.getValue()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// if ("径流深".equals(valueName)) {
|
|
|
|
|
// for(ValueDataDTO dto:valueDatas){
|
|
|
|
|
// jlsMap.put(dto.getTm(),dto.getValue());
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.info("====dealResult===mnllMap:{}",mnllMap); |
|
|
|
|
res.put("mnllMap",mnllMap); |
|
|
|
|
// res.put("jlsMap",jlsMap);
|
|
|
|
|
log.info("====dealResult===ftrkMap:{}",ftrkMap); |
|
|
|
|
res.put("ftrkMap",ftrkMap); |
|
|
|
|
|
|
|
|
|
for (Map.Entry<String, Double> entry : mnllMap.entrySet()) { |
|
|
|
|
String tm = entry.getKey(); |
|
|
|
|
PlanFlowResultInfo planResultInfo = new PlanFlowResultInfo(); |
|
|
|
|
planResultInfo.setPlanId(planInfo.getId()); |
|
|
|
|
planResultInfo.setStcd(stcd); |
|
|
|
|
planResultInfo.setTime(LocalDateTime.parse(tm, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"))); |
|
|
|
|
planResultInfo.setSimulatedFlow(new BigDecimal(entry.getValue().toString())); |
|
|
|
|
planResultInfo.setReverseFlow(new BigDecimal(ftrkMap.get(tm).toString())); |
|
|
|
|
planFlowResultInfos.add(planResultInfo); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//保存 反推入库 模拟流量
|
|
|
|
|
if(planFlowResultInfos!=null && !planFlowResultInfos.isEmpty()) { |
|
|
|
|
planFlowResultInfoService.saveBatch(planFlowResultInfos); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return res; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private PlanInfo savePlanInfo(PlanConfigInfo config) { |
|
|
|
|
LocalDateTime now = LocalDateTime.now(); |
|
|
|
|
String timeStr = now.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")); |
|
|
|
@ -728,19 +838,56 @@ public class PlanInfoServiceImpl extends ServiceImpl<PlanInfoMapper, PlanInfo> i
|
|
|
|
|
|
|
|
|
|
ZoneId zoneId = ZoneId.systemDefault(); |
|
|
|
|
List<PlanResultInfo> planResultInfos = planResultInfoService.list(new QueryWrapper<PlanResultInfo>().eq("plan_id", id).orderByAsc("time")); |
|
|
|
|
this.getIncomingWaterForecast(incomingWaterForecastVo,planParamInfo.getStcd(),Date.from(startTime.atZone(zoneId).toInstant()),Date.from(endTime.atZone(zoneId).toInstant()),planResultInfos,BigDecimal.valueOf(planParamInfo.getSt()),formatter,reportVoList,indexMap); |
|
|
|
|
this.getIncomingWaterForecast(incomingWaterForecastVo,planParamInfo.getStcd(),Date.from(startTime.atZone(zoneId).toInstant()), |
|
|
|
|
Date.from(endTime.atZone(zoneId).toInstant()), |
|
|
|
|
planResultInfos,BigDecimal.valueOf(planParamInfo.getSt()),formatter,reportVoList,indexMap); |
|
|
|
|
|
|
|
|
|
PowerPlantOptimizationVo powerPlantOptimizationVo = new PowerPlantOptimizationVo(); |
|
|
|
|
powerPlantOptimizationVo.setStationCode(planParamInfo.getStationCode()); |
|
|
|
|
powerPlantOptimizationVo.setStationName(planParamInfo.getStationName()); |
|
|
|
|
this.getPowerPlantOptimization(powerPlantOptimizationVo,startTime.format(formatter),endTime.format(formatter),planResultInfos,reportVoList,indexMap); |
|
|
|
|
this.getPowerPlantOptimization(powerPlantOptimizationVo,startTime.format(formatter),endTime.format(formatter),planResultInfos, |
|
|
|
|
reportVoList,indexMap); |
|
|
|
|
forecastVo.setIncomingWaterForecastVo(incomingWaterForecastVo); |
|
|
|
|
forecastVo.setPowerPlantOptimizationVo(powerPlantOptimizationVo); |
|
|
|
|
|
|
|
|
|
List<PlanFlowResultInfo> planFlowResultInfos = planFlowResultInfoService.list(new QueryWrapper<PlanFlowResultInfo>().eq("plan_id", id).orderByAsc("time")); |
|
|
|
|
dealPlanFlow(planFlowResultInfos,reportVoList); |
|
|
|
|
|
|
|
|
|
forecastVo.setReport(reportVoList); |
|
|
|
|
return forecastVo; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void getIncomingWaterForecast(IncomingWaterForecastVo vo, String stcd, Date startTime, Date endTime, List<PlanResultInfo> planResultInfos, BigDecimal st, DateTimeFormatter formatter,List<ReportVo> reportVoList,Map<String,Integer> indexMap){ |
|
|
|
|
|
|
|
|
|
private void dealPlanFlow(List<PlanFlowResultInfo> planFlowResultInfos,List<ReportVo> reportVoList){ |
|
|
|
|
if(planFlowResultInfos!=null && !planFlowResultInfos.isEmpty()) { |
|
|
|
|
for (ReportVo vo : reportVoList) { |
|
|
|
|
String time = vo.getTime(); |
|
|
|
|
PlanFlowResultInfo info = getPlanFlowResultInfoByTime(time, planFlowResultInfos); |
|
|
|
|
if (info != null) { |
|
|
|
|
String reverseFlow = info.getReverseFlow() != null ? String.valueOf(info.getReverseFlow()) : "-"; |
|
|
|
|
String simulatedFlow = info.getSimulatedFlow() != null ? String.valueOf(info.getSimulatedFlow()) : "-"; |
|
|
|
|
vo.setSimulatedFlow(simulatedFlow); |
|
|
|
|
vo.setReverseFlow(reverseFlow); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private PlanFlowResultInfo getPlanFlowResultInfoByTime(String time,List<PlanFlowResultInfo> planFlowResultInfos){ |
|
|
|
|
DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd HH"); |
|
|
|
|
for(PlanFlowResultInfo info:planFlowResultInfos){ |
|
|
|
|
LocalDateTime dateTime=info.getTime(); |
|
|
|
|
if(time.equals(df.format(dateTime))){ |
|
|
|
|
return info; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void getIncomingWaterForecast(IncomingWaterForecastVo vo, String stcd, Date startTime, |
|
|
|
|
Date endTime, List<PlanResultInfo> planResultInfos, BigDecimal st, |
|
|
|
|
DateTimeFormatter formatter,List<ReportVo> reportVoList, |
|
|
|
|
Map<String,Integer> indexMap){ |
|
|
|
|
R<List<Map<String, String>>> rz = null; |
|
|
|
|
if (gbyStcd.equals(stcd)) { |
|
|
|
|
rz = baseInfoClient.getHistoryDataBySignage(gbyStcdZc, startTime, endTime, "hour", "rz"); |
|
|
|
@ -773,7 +920,7 @@ public class PlanInfoServiceImpl extends ServiceImpl<PlanInfoMapper, PlanInfo> i
|
|
|
|
|
log.info("{}==发电流量==:{}",stcd,planResultInfo.getPowerFlow()); |
|
|
|
|
log.info("{}==生态流量==:{}",stcd,st); |
|
|
|
|
forecastDataVo.setInFlow(planResultInfo.getIncomeFall()!=null?String.valueOf(planResultInfo.getIncomeFall()):"-"); |
|
|
|
|
forecastDataVo.setOutFlow(planResultInfo.getPowerFlow()!=null?st.add(BigDecimal.valueOf(planResultInfo.getPowerFlow())).toString():"-"); |
|
|
|
|
forecastDataVo.setOutFlow(planResultInfo.getPowerFlow()!=null?st.add(planResultInfo.getPowerFlow()).toString():"-"); |
|
|
|
|
log.info("{}==预报入库流量==:{}",stcd,forecastDataVo.getInFlow()); |
|
|
|
|
log.info("{}==预报入库流量==:{}",stcd,forecastDataVo.getOutFlow()); |
|
|
|
|
forecastDataVoList.add(forecastDataVo); |
|
|
|
@ -781,7 +928,8 @@ public class PlanInfoServiceImpl extends ServiceImpl<PlanInfoMapper, PlanInfo> i
|
|
|
|
|
vo.setPowerTotal(String.format("%.3f", sum)); |
|
|
|
|
vo.setStMaxPowerTime(maxPowerTime.getTime().format(formatter)); |
|
|
|
|
vo.setStMaxPower(maxPowerTime.getUnitLoad()); |
|
|
|
|
this.getReport(rzsignageList,drpsignageList,forecastDataVoList,null,null,reportVoList,indexMap); |
|
|
|
|
this.getReport(rzsignageList,drpsignageList,forecastDataVoList,null,null, |
|
|
|
|
reportVoList,indexMap); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -855,7 +1003,10 @@ public class PlanInfoServiceImpl extends ServiceImpl<PlanInfoMapper, PlanInfo> i
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void getReport(List<Map<String,String>> signageList,List<Map<String,String>> drpsignageList,List<ForecastDataVo> forecastRes, List<TimeValueVo> loadForecastRes,List<TimeValueVo> actualLoad,List<ReportVo> reportVoList,Map<String,Integer> indexMap){ |
|
|
|
|
private void getReport(List<Map<String,String>> signageList,List<Map<String,String>> drpsignageList, |
|
|
|
|
List<ForecastDataVo> forecastRes, List<TimeValueVo> loadForecastRes, |
|
|
|
|
List<TimeValueVo> actualLoad,List<ReportVo> reportVoList, |
|
|
|
|
Map<String,Integer> indexMap){ |
|
|
|
|
log.info("==预报indexMap==:{}", indexMap); |
|
|
|
|
if (signageList!=null&&!signageList.isEmpty()){ |
|
|
|
|
signageList.forEach(item->{ |
|
|
|
|