洪水预测相关优化

master
cxw 2024-09-29 16:45:40 +08:00
parent 5a59239d75
commit fab8bfec9c
7 changed files with 218 additions and 130 deletions

View File

@ -33,4 +33,6 @@ public interface StPptnRMapper extends BaseMapper<StPptnR> {
List<StPptnR> getStcdLastPptnData(); List<StPptnR> getStcdLastPptnData();
List<Map<String, Object>> getPptnRDataList(@Param("stcd") String stcd, @Param("tm") String tm); List<Map<String, Object>> getPptnRDataList(@Param("stcd") String stcd, @Param("tm") String tm);
List<Map<String, Object>> getPptnRDataListByTask(@Param("resCode") String resCode, @Param("stcd") String stcd, @Param("tm") String tm);
} }

View File

@ -0,0 +1,35 @@
package com.gunshi.project.xyt.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gunshi.core.dateformat.DateFormatString;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.Date;
/**
* : -
*/
@Data
public class StPptnRAverage extends StPptnR {
/**
*
*/
@Schema(description="时段降水量")
private String drp;
/**
*
*/
@Schema(description="时间")
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
private Date tm;
public StPptnRAverage(Date tm, String drp) {
this.tm = tm;
this.drp = drp;
}
}

View File

@ -21,6 +21,7 @@ import com.gunshi.project.xyt.model.ForecastTask;
import com.gunshi.project.xyt.model.ForecastU; import com.gunshi.project.xyt.model.ForecastU;
import com.gunshi.project.xyt.model.ForecastUseparam; import com.gunshi.project.xyt.model.ForecastUseparam;
import com.gunshi.project.xyt.model.StPptnR; import com.gunshi.project.xyt.model.StPptnR;
import com.gunshi.project.xyt.model.StPptnRAverage;
import com.gunshi.project.xyt.model.StRsvrR; import com.gunshi.project.xyt.model.StRsvrR;
import com.gunshi.project.xyt.model.StStbprpB; import com.gunshi.project.xyt.model.StStbprpB;
import com.gunshi.project.xyt.model.StZqrlB; import com.gunshi.project.xyt.model.StZqrlB;
@ -125,7 +126,8 @@ public class ForecastResultsService extends ServiceImpl<ForecastResultsMapper, F
voList = excuteForecast(forecastTask); voList = excuteForecast(forecastTask);
voList.sort(Comparator.comparing(ForecastResultVo::getTm)); voList.sort(Comparator.comparing(ForecastResultVo::getTm));
} catch (Exception e) { } catch (Exception e) {
throw new IllegalArgumentException("数据异常!"); e.printStackTrace();
throw new IllegalArgumentException(e.getMessage());
} }
return voList; return voList;
} }
@ -138,9 +140,19 @@ public class ForecastResultsService extends ServiceImpl<ForecastResultsMapper, F
* @date: 2024-08-05, , 17:14:52 * @date: 2024-08-05, , 17:14:52
*/ */
private List<ForecastResultVo> excuteForecast(ForecastTask forecastTask) throws Exception { private List<ForecastResultVo> excuteForecast(ForecastTask forecastTask) throws Exception {
List<ForecastResultVo> voList = new ArrayList<>();
// 获取配置参数
List<ForecastUseparam> paramList = forecastUseparamService.list(new QueryWrapper<ForecastUseparam>().isNotNull("param_code").isNotNull("param_value"));
if (CollectionUtils.isEmpty(paramList)) {
throw new IllegalArgumentException("温馨提示:当前洪水预报所依赖的数据尚不完整,请检查入参是否缺失。");
}
// 获取系统当前的水库站编码、汛限水位 // 获取系统当前的水库站编码、汛限水位
AttResBase attResBase = attResBaseService.getOne(new QueryWrapper<>()); AttResBase attResBase = attResBaseService.getOne(new QueryWrapper<>());
List<ForecastResultVo> voList = new ArrayList<>(); // 多站点水库面雨量
List<StStbprpB> stbs = stStbprpBService.list(new QueryWrapper<StStbprpB>().eq("res_code", attResBase.getResCode()));
if (CollectionUtils.isEmpty(stbs)) {
return voList;
}
Date nowHourTime = forecastTask.getNowTime(); Date nowHourTime = forecastTask.getNowTime();
Date startTime = forecastTask.getStartTime(); Date startTime = forecastTask.getStartTime();
Date endTime = forecastTask.getEndTime(); Date endTime = forecastTask.getEndTime();
@ -149,30 +161,43 @@ public class ForecastResultsService extends ServiceImpl<ForecastResultsMapper, F
List<StPptnR> pptnRFutureList = new ArrayList<>(); List<StPptnR> pptnRFutureList = new ArrayList<>();
QueryWrapper<StPptnR> qwExisted = new QueryWrapper<>(); QueryWrapper<StPptnR> qwExisted = new QueryWrapper<>();
Boolean isHaveFuturePPtn = true; Boolean isHaveFuturePPtn = true;
for(StStbprpB b : stbs){
String stcd = b.getStcd();
// 如果结束时间在当前时间之前,降雨序列从历史降雨表获取 // 如果结束时间在当前时间之前,降雨序列从历史降雨表获取
if (endTime.compareTo(nowHourTime) <= 0) { if (endTime.compareTo(nowHourTime) <= 0) {
qwExisted = new QueryWrapper<StPptnR>().eq("stcd", attResBase.getStcd()).ge("tm", startTime).le("tm", endTime).orderBy(true, true, "tm"); qwExisted = new QueryWrapper<StPptnR>().eq("stcd", stcd).ge("tm", startTime).le("tm", endTime).orderBy(true, true, "tm");
} else { } else {
qwExisted = new QueryWrapper<StPptnR>().eq("stcd", attResBase.getStcd()).ge("tm", startTime).le("tm", nowHourTime).orderBy(true, true, "tm"); qwExisted = new QueryWrapper<StPptnR>().eq("stcd", stcd).ge("tm", startTime).le("tm", nowHourTime).orderBy(true, true, "tm");
try { try {
// 获取预报数据 // 获取预报数据
pptnRFutureList = getForecastDrpData(nowHourTime, attResBase.getStcd()); pptnRFutureList = getForecastDrpData(nowHourTime, stcd);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
if(stcd.equals(attResBase.getStcd())){
isHaveFuturePPtn = false; isHaveFuturePPtn = false;
}
log.error("该时间无预报数据"); log.error("该时间无预报数据");
} }
} }
List<StPptnR> pptnRExistedList = stPptnRService.list(qwExisted); List<StPptnR> pptnRExistedList = stPptnRService.list(qwExisted);
pptnRAllList.addAll(pptnRExistedList); pptnRAllList.addAll(pptnRExistedList);
pptnRAllList.addAll(pptnRFutureList); pptnRAllList.addAll(pptnRFutureList);
}
if (CollectionUtils.isEmpty(pptnRAllList)) { if (CollectionUtils.isEmpty(pptnRAllList)) {
return voList; return voList;
} }
// 获取配置参数 // 多站点面雨量结果list
List<ForecastUseparam> paramList = forecastUseparamService.list(new QueryWrapper<ForecastUseparam>().isNotNull("param_code").isNotNull("param_value")); List<StPptnR> polyPptnRList = pptnRAllList.stream()
if (CollectionUtils.isEmpty(paramList)) { .collect(Collectors.groupingBy(
throw new IllegalArgumentException("温馨提示:当前洪水预报所依赖的数据尚不完整,请检查入参是否缺失。"); StPptnR::getTm,
} Collectors.mapping(
pptn -> Double.parseDouble(pptn.getDrp()), // 将String转换为double
Collectors.averagingDouble(d -> d) // 计算平均值
)
))
.entrySet().stream()
.map(entry -> new StPptnRAverage(entry.getKey(), String.valueOf(entry.getValue())))
.sorted(Comparator.comparing(StPptnRAverage::getTm))
.collect(Collectors.toList());
double dt = 0.0; double dt = 0.0;
double Wm = 0.0; double Wm = 0.0;
Map<String, String> paramMap = paramList.stream().collect(Collectors.toMap(ForecastUseparam::getParamCode, ForecastUseparam::getParamValue)); Map<String, String> paramMap = paramList.stream().collect(Collectors.toMap(ForecastUseparam::getParamCode, ForecastUseparam::getParamValue));
@ -228,7 +253,7 @@ public class ForecastResultsService extends ServiceImpl<ForecastResultsMapper, F
} }
// 根据降雨数据按照△t的颗粒度均分 // 根据降雨数据按照△t的颗粒度均分
// 筛选时间段内的降雨数据。不包前但包后 // 筛选时间段内的降雨数据。不包前但包后
List<StPptnR> filterList = pptnRAllList.stream().filter(e -> e.getTm().compareTo(period[0]) >= 0).filter(e -> e.getTm().compareTo(period[1]) <= 0).collect(Collectors.toList()); List<StPptnR> filterList = polyPptnRList.stream().filter(e -> e.getTm().compareTo(period[0]) >= 0).filter(e -> e.getTm().compareTo(period[1]) <= 0).collect(Collectors.toList());
Map<String, List<StPptnR>> retMap = new HashMap<>(); Map<String, List<StPptnR>> retMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(filterList)) { if (CollectionUtils.isNotEmpty(filterList)) {
retMap = reorganizePptnRData(filterList, dt, period[0], period[1], nowHourTime, isHaveFuturePPtn); retMap = reorganizePptnRData(filterList, dt, period[0], period[1], nowHourTime, isHaveFuturePPtn);

View File

@ -30,6 +30,10 @@ public class StPptnRService extends ServiceImpl<StPptnRMapper, StPptnR>
public List<Map<String, Object>> getPptnRDataList(String stcd, String tm) { public List<Map<String, Object>> getPptnRDataList(String stcd, String tm) {
return baseMapper.getPptnRDataList(stcd, tm); return baseMapper.getPptnRDataList(stcd, tm);
} }
public List<Map<String, Object>> getPptnRDataListByTask(String resCode, String stcd, String tm) {
return baseMapper.getPptnRDataListByTask(resCode, stcd, tm);
}
} }

View File

@ -4,18 +4,19 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.gunshi.algorithm.RunoffService; import com.gunshi.algorithm.RunoffService;
import com.gunshi.project.xyt.model.AttResBase;
import com.gunshi.project.xyt.model.ForecastK; import com.gunshi.project.xyt.model.ForecastK;
import com.gunshi.project.xyt.model.ForecastPa; import com.gunshi.project.xyt.model.ForecastPa;
import com.gunshi.project.xyt.model.ForecastUseparam; import com.gunshi.project.xyt.model.ForecastUseparam;
import com.gunshi.project.xyt.model.StPptnR; import com.gunshi.project.xyt.model.StPptnR;
import com.gunshi.project.xyt.model.StStbprpB; import com.gunshi.project.xyt.model.StStbprpB;
import com.gunshi.project.xyt.service.AttResBaseService;
import com.gunshi.project.xyt.service.ForecastKService; import com.gunshi.project.xyt.service.ForecastKService;
import com.gunshi.project.xyt.service.ForecastPaService; import com.gunshi.project.xyt.service.ForecastPaService;
import com.gunshi.project.xyt.service.ForecastResultsService; import com.gunshi.project.xyt.service.ForecastResultsService;
import com.gunshi.project.xyt.service.ForecastUseparamService; import com.gunshi.project.xyt.service.ForecastUseparamService;
import com.gunshi.project.xyt.service.StPptnRService; import com.gunshi.project.xyt.service.StPptnRService;
import com.gunshi.project.xyt.service.StStbprpBService; import com.gunshi.project.xyt.service.StStbprpBService;
import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile; import org.springframework.context.annotation.Profile;
@ -70,6 +71,9 @@ public class PaDataTask {
@Autowired @Autowired
private ForecastResultsService forecastResultsService; private ForecastResultsService forecastResultsService;
@Autowired
private AttResBaseService attResBaseService;
/** /**
* @description: 830Pa * @description: 830Pa
* @param * @param
@ -79,7 +83,6 @@ public class PaDataTask {
*/ */
@Async @Async
@Scheduled(cron ="0 30 8 * * ?") @Scheduled(cron ="0 30 8 * * ?")
// @PostConstruct
public void PaDataCalc() throws ParseException { public void PaDataCalc() throws ParseException {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date()); calendar.setTime(new Date());
@ -87,15 +90,18 @@ public class PaDataTask {
// 获取配置参数 // 获取配置参数
List<ForecastUseparam> paramList = forecastUseparamService.list(new QueryWrapper<ForecastUseparam>().isNotNull("param_code").isNotNull("param_value")); List<ForecastUseparam> paramList = forecastUseparamService.list(new QueryWrapper<ForecastUseparam>().isNotNull("param_code").isNotNull("param_value"));
List<ForecastK> kList = forecastKService.list(); List<ForecastK> kList = forecastKService.list();
// 查询所有需要统计pa值的站点 if (CollectionUtils.isEmpty(paramList) || CollectionUtils.isEmpty(kList)) {
List<StStbprpB> stStbprpBList = stStbprpBService.list(new QueryWrapper<StStbprpB>().eq("source", "SK")); return;
if (CollectionUtils.isNotEmpty(stStbprpBList)) { }
// 先删除站点当天的pa假如已经存在的话有另一任务提前算了第二天此处为当天 // 檀树岗使用多个站点的均值作为水库的降雨
forecastPaService.remove(new QueryWrapper<ForecastPa>().eq("tm", sdfDay.format(nowTime))); AttResBase attResBase = attResBaseService.getOne(new QueryWrapper<>());
for (StStbprpB stb : stStbprpBList) { if (ObjectUtils.isNotEmpty(attResBase)) {
String stcd = stb.getStcd(); String resCode = attResBase.getResCode();
String skStcd = attResBase.getStcd();
// 先删除水库当天的pa假如已经存在的话有另一任务提前算了第二天此处为当天
forecastPaService.remove(new QueryWrapper<ForecastPa>().eq("tm", sdfDay.format(nowTime)).eq("stcd", attResBase.getResCode()));
// 获取最新pa // 获取最新pa
ForecastPa forecastPaLast = forecastPaService.getOne(new QueryWrapper<ForecastPa>().eq("stcd", stcd).orderBy(true, false, "tm").last("limit 1")); ForecastPa forecastPaLast = forecastPaService.getOne(new QueryWrapper<ForecastPa>().eq("stcd", skStcd).orderBy(true, false, "tm").last("limit 1"));
if (CollectionUtils.isNotEmpty(paramList) && CollectionUtils.isNotEmpty(kList) && ObjectUtils.isNotEmpty(forecastPaLast) && !forecastPaLast.getTm().equals(sdfDay.format(nowTime))) { if (CollectionUtils.isNotEmpty(paramList) && CollectionUtils.isNotEmpty(kList) && ObjectUtils.isNotEmpty(forecastPaLast) && !forecastPaLast.getTm().equals(sdfDay.format(nowTime))) {
Calendar calendar2 = Calendar.getInstance(); Calendar calendar2 = Calendar.getInstance();
calendar2.setTime(sdfDay.parse(forecastPaLast.getTm())); calendar2.setTime(sdfDay.parse(forecastPaLast.getTm()));
@ -103,7 +109,7 @@ public class PaDataTask {
String searchTm = sdfDay.format(calendar2.getTime()); String searchTm = sdfDay.format(calendar2.getTime());
String lastTm = forecastPaLast.getTm(); String lastTm = forecastPaLast.getTm();
// 获取空缺时间的所有降雨当天8点到第二天8点间的drp和 // 获取空缺时间的所有降雨当天8点到第二天8点间的drp和
List<Map<String, Object>> mapList = stPptnRService.getPptnRDataList(stcd, searchTm); List<Map<String, Object>> mapList = stPptnRService.getPptnRDataListByTask(resCode, skStcd, searchTm);
Map<String, Object> pptnrMap; Map<String, Object> pptnrMap;
if (CollectionUtils.isNotEmpty(mapList)) { if (CollectionUtils.isNotEmpty(mapList)) {
pptnrMap = mapList.stream().collect(Collectors.toMap(map -> (String) map.get("tm"), map -> map.get("drp"))); pptnrMap = mapList.stream().collect(Collectors.toMap(map -> (String) map.get("tm"), map -> map.get("drp")));
@ -126,7 +132,7 @@ public class PaDataTask {
lastTm = sdfDay.format(calendar.getTime()); lastTm = sdfDay.format(calendar.getTime());
double k = kMap.get(Integer.valueOf(lastTm.substring(5, 7))).doubleValue(); double k = kMap.get(Integer.valueOf(lastTm.substring(5, 7))).doubleValue();
double pa = RunoffService.PaCaculate(k, lastPa0, lastPt0, Im); double pa = RunoffService.PaCaculate(k, lastPa0, lastPt0, Im);
forecastPa.setStcd(stcd); forecastPa.setStcd(skStcd);
forecastPa.setTm(lastTm); forecastPa.setTm(lastTm);
forecastPa.setK(new BigDecimal(k).setScale(2, BigDecimal.ROUND_HALF_UP)); forecastPa.setK(new BigDecimal(k).setScale(2, BigDecimal.ROUND_HALF_UP));
forecastPa.setPa0(new BigDecimal(lastPa0)); forecastPa.setPa0(new BigDecimal(lastPa0));
@ -142,7 +148,6 @@ public class PaDataTask {
} }
} }
} }
}
/** /**
* @description: 19245Pa * @description: 19245Pa
@ -155,40 +160,51 @@ public class PaDataTask {
@Scheduled(cron ="0 0/5 20-23 * * ?") @Scheduled(cron ="0 0/5 20-23 * * ?")
public void PaNextDataCalc() throws ParseException { public void PaNextDataCalc() throws ParseException {
Date nowTime = new Date(); Date nowTime = new Date();
// 檀树岗使用多个站点的均值作为水库的降雨
AttResBase attResBase = attResBaseService.getOne(new QueryWrapper<>());
if (ObjectUtils.isNotEmpty(attResBase)) {
// 查询所有需要统计pa值的站点 // 查询所有需要统计pa值的站点
List<StStbprpB> stStbprpBList = stStbprpBService.list(new QueryWrapper<StStbprpB>().eq("source", "SK")); List<StStbprpB> stStbprpBList = stStbprpBService.list(new QueryWrapper<StStbprpB>().eq("res_code", attResBase.getResCode()));
if (CollectionUtils.isNotEmpty(stStbprpBList)) { if(CollectionUtils.isEmpty(stStbprpBList)){
return;
}
// 获取配置参数 // 获取配置参数
List<ForecastUseparam> paramList = forecastUseparamService.list(new QueryWrapper<ForecastUseparam>().isNotNull("param_code").isNotNull("param_value")); List<ForecastUseparam> paramList = forecastUseparamService.list(new QueryWrapper<ForecastUseparam>().isNotNull("param_code").isNotNull("param_value"));
List<ForecastK> kList = forecastKService.list(); List<ForecastK> kList = forecastKService.list();
if (CollectionUtils.isEmpty(paramList) || CollectionUtils.isEmpty(kList)) {
for (StStbprpB stb : stStbprpBList) { return;
String stcd = stb.getStcd(); }
String skStcd = attResBase.getResCode();
// 查询第二天的是否已经生成了 // 查询第二天的是否已经生成了
Calendar calendarNext = Calendar.getInstance(); Calendar calendarNext = Calendar.getInstance();
calendarNext.setTime(nowTime); calendarNext.setTime(nowTime);
calendarNext.add(Calendar.DAY_OF_MONTH, 1); calendarNext.add(Calendar.DAY_OF_MONTH, 1);
String nextTimeStr = sdfDay.format(calendarNext.getTime()); String nextTimeStr = sdfDay.format(calendarNext.getTime());
ForecastPa hasPa = forecastPaService.getOne(new QueryWrapper<ForecastPa>().eq("stcd", stcd).eq("tm", nextTimeStr)); ForecastPa hasPa = forecastPaService.getOne(new QueryWrapper<ForecastPa>().eq("stcd", skStcd).eq("tm", nextTimeStr));
if(ObjectUtils.isNotEmpty(hasPa)){ if (ObjectUtils.isNotEmpty(hasPa)) {
return; return;
} }
// 获取最新pa当天 // 获取最新pa当天
ForecastPa forecastPaLast = forecastPaService.getOne(new QueryWrapper<ForecastPa>().eq("stcd", stcd).eq("tm", sdfDay.format(nowTime)).last("limit 1")); ForecastPa forecastPaLast = forecastPaService.getOne(new QueryWrapper<ForecastPa>().eq("stcd", skStcd).eq("tm", sdfDay.format(nowTime)).last("limit 1"));
if (CollectionUtils.isNotEmpty(paramList) && CollectionUtils.isNotEmpty(kList) && ObjectUtils.isNotEmpty(forecastPaLast)) { if (CollectionUtils.isNotEmpty(paramList) && CollectionUtils.isNotEmpty(kList) && ObjectUtils.isNotEmpty(forecastPaLast)) {
List<StPptnR> listAll = new ArrayList<>();
for (StStbprpB stb : stStbprpBList) {
String stcd = stb.getStcd();
// 获取当天大于08点到执行时间的真实降雨 // 获取当天大于08点到执行时间的真实降雨
List<StPptnR> qwExisted = stPptnRService.list(new QueryWrapper<StPptnR>().eq("stcd", stcd).gt("tm", sdf.parse(eightSdf.format(nowTime))).le("tm", nowTime).orderBy(true, true, "tm")); List<StPptnR> qwExistedStcd = stPptnRService.list(new QueryWrapper<StPptnR>().eq("stcd", stcd).gt("tm", sdf.parse(eightSdf.format(nowTime))).le("tm", nowTime).orderBy(true, true, "tm"));
// 获取当天的预测降雨 // 获取当天的预测降雨
List<StPptnR> pptnRFutureList = forecastResultsService.getForecastDrpData(nowTime, stcd); List<StPptnR> pptnRFutureListStcd = forecastResultsService.getForecastDrpData(nowTime, stcd);
qwExisted.addAll(pptnRFutureList); listAll.addAll(qwExistedStcd);
Double totalDrp = qwExisted.stream().mapToDouble(x -> Double.valueOf(x.getDrp())).sum(); listAll.addAll(pptnRFutureListStcd);
}
Double totalDrp = listAll.stream().mapToDouble(x -> Double.valueOf(x.getDrp())).sum();
ForecastPa forecastPa = new ForecastPa(); ForecastPa forecastPa = new ForecastPa();
Map<Integer, BigDecimal> kMap = kList.stream().collect(Collectors.toMap(ForecastK::getMonth, ForecastK::getKValue)); Map<Integer, BigDecimal> kMap = kList.stream().collect(Collectors.toMap(ForecastK::getMonth, ForecastK::getKValue));
Map<String, String> paramMap = paramList.stream().collect(Collectors.toMap(ForecastUseparam::getParamCode, ForecastUseparam::getParamValue)); Map<String, String> paramMap = paramList.stream().collect(Collectors.toMap(ForecastUseparam::getParamCode, ForecastUseparam::getParamValue));
double Im = Double.parseDouble(paramMap.get("Im"));// 土壤含水量最大值(最大初损值)Im double Im = Double.parseDouble(paramMap.get("Im"));// 土壤含水量最大值(最大初损值)Im
double k = kMap.get(Integer.valueOf(nextTimeStr.substring(5, 7))).doubleValue(); double k = kMap.get(Integer.valueOf(nextTimeStr.substring(5, 7))).doubleValue();
double pa = RunoffService.PaCaculate(k, Double.parseDouble(forecastPaLast.getPa().toString()), totalDrp, Im); double pa = RunoffService.PaCaculate(k, Double.parseDouble(forecastPaLast.getPa().toString()), totalDrp, Im);
forecastPa.setStcd(stcd); forecastPa.setStcd(skStcd);
forecastPa.setTm(nextTimeStr); forecastPa.setTm(nextTimeStr);
forecastPa.setK(new BigDecimal(k).setScale(2, BigDecimal.ROUND_HALF_UP)); forecastPa.setK(new BigDecimal(k).setScale(2, BigDecimal.ROUND_HALF_UP));
forecastPa.setPa0(forecastPaLast.getPa()); forecastPa.setPa0(forecastPaLast.getPa());
@ -199,6 +215,5 @@ public class PaDataTask {
} }
} }
} }
}
} }

View File

@ -15,22 +15,29 @@
</select> </select>
<select id="getPptnRDataList" resultType="java.util.Map"> <select id="getPptnRDataList" resultType="java.util.Map">
SELECT SELECT to_char(tm_start, 'YYYY-MM-DD') tm,
to_char( tm_start, 'YYYY-MM-DD' ) tm,
drp drp
FROM FROM (SELECT date_trunc('day', tm :: TIMESTAMP - INTERVAL '8 hours' - INTERVAL '1 second') + INTERVAL '8 hours' AS tm_start, SUM ( drp ) AS drp
(
SELECT
date_trunc( 'day', tm :: TIMESTAMP - INTERVAL '9 hours' ) + INTERVAL '9 hours' AS tm_start,
SUM ( drp ) AS drp
FROM FROM
st_pptn_r st_pptn_r
WHERE WHERE
stcd = #{stcd} AND tm >= #{tm} stcd = #{stcd}
AND tm >= #{tm}
GROUP BY GROUP BY
date_trunc( 'day', tm :: TIMESTAMP - INTERVAL '9 hours' ) + INTERVAL '9 hours' date_trunc( 'day', tm :: TIMESTAMP - INTERVAL '8 hours' - INTERVAL '1 second') + INTERVAL '8 hours'
ORDER BY ORDER BY
tm_start ASC tm_start ASC) t
) t </select>
<select id="getPptnRDataListByTask" resultType="java.util.Map">
SELECT to_char(tm_start, 'YYYY-MM-DD') tm,
drp
FROM (SELECT date_trunc('day', tm :: TIMESTAMP - INTERVAL '8 hours' - INTERVAL '1 second') + INTERVAL '8 hours' AS tm_start, SUM ( drp ) AS drp
FROM
(SELECT tm, ROUND(AVG (drp), 1) drp FROM st_pptn_r WHERE tm >= #{tm} AND stcd IN (SELECT stcd FROM st_stbprp_b WHERE res_code = #{resCode}) GROUP BY tm) a
GROUP BY
date_trunc( 'day', tm :: TIMESTAMP - INTERVAL '8 hours' - INTERVAL '1 second') + INTERVAL '8 hours'
ORDER BY
tm_start ASC) T
</select> </select>
</mapper> </mapper>

View File

@ -4,7 +4,7 @@
<select id="getStcdLastRsvrData" resultType="com.gunshi.project.xyt.model.StRsvrR"> <select id="getStcdLastRsvrData" resultType="com.gunshi.project.xyt.model.StRsvrR">
SELECT stb.stcd, SELECT stb.stcd,
case UPPER(stb.sttp) when 'RR' then r2.tm when 'ZZ' then r.tm end stm, case UPPER(stb.sttp) when 'RR' then r.tm when 'ZZ' then r2.tm end stm,
stb.source, stb.source,
stb.sttp stb.sttp
FROM public.st_stbprp_b stb FROM public.st_stbprp_b stb