|
@@ -2,6 +2,7 @@ package com.ruoyi.web.controller;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateField;
|
|
|
+import cn.hutool.core.date.DateRange;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.text.StrBuilder;
|
|
@@ -67,6 +68,8 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
private IStationInfoMin2Service stationInfoMin2Service;
|
|
|
@Resource
|
|
|
private IProjectInfoMin2Service projectInfoMin2Service;
|
|
|
+ @Resource
|
|
|
+ private IRealtimePredictService realtimePredictService;
|
|
|
|
|
|
@Override
|
|
|
public void execute() throws Exception {
|
|
@@ -569,6 +572,68 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
stationInfoDayService.saveOrUpdateBatch(days);
|
|
|
}
|
|
|
|
|
|
+ public void calcStationRjhfdl2(Date month) {
|
|
|
+ DateTime begin = DateUtil.beginOfMonth(month);
|
|
|
+ DateRange range = DateUtil.range(begin, DateUtil.endOfYear(begin),DateField.MONTH);
|
|
|
+ QueryWrapper<ProBasicProjectPlan> wrapperPlan = new QueryWrapper<>();
|
|
|
+ wrapperPlan.lambda().eq(ProBasicProjectPlan::getYear, String.valueOf(begin.year()))
|
|
|
+ .eq(ProBasicProjectPlan::getMonth, String.valueOf(begin.month() + 1));
|
|
|
+ List<ProBasicProjectPlan> plantList = proBasicProjectPlanService.list(wrapperPlan);
|
|
|
+ for (DateTime date : range) {
|
|
|
+
|
|
|
+ }
|
|
|
+ DateTime end = DateUtil.endOfMonth(month);
|
|
|
+ DateTime beginTq = DateUtil.offset(begin, DateField.YEAR, -1);
|
|
|
+ DateTime endTq = DateUtil.offset(end, DateField.YEAR, -1);
|
|
|
+
|
|
|
+ QueryWrapper<StationInfoDay> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.lambda().between(StationInfoDay::getRecordDate, begin, end);
|
|
|
+ List<StationInfoDay> days = stationInfoDayService.list(wrapper);
|
|
|
+ Map<String, Map<String, StationInfoDay>> dayMap = new HashMap<>();
|
|
|
+ if (CollUtil.isNotEmpty(days)) {
|
|
|
+ dayMap = days.stream().collect(Collectors.groupingBy(StationInfoDay::getStationId,
|
|
|
+ Collectors.toMap(sid -> DateUtil.date(sid.getRecordDate()).toString(), Function.identity())));
|
|
|
+ }
|
|
|
+ wrapper.clear();
|
|
|
+ wrapper.lambda().between(StationInfoDay::getRecordDate, beginTq, endTq);
|
|
|
+ List<StationInfoDay> sids = stationInfoDayService.list(wrapper);
|
|
|
+ Map<String, List<StationInfoDay>> sidMap;
|
|
|
+ if (CollUtil.isNotEmpty(sids)) {
|
|
|
+ sidMap = sids.stream().collect(Collectors.groupingBy(StationInfoDay::getStationId));
|
|
|
+ } else {
|
|
|
+ sidMap = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (ProBasicProjectPlan plan : plantList) {
|
|
|
+ String stId = plan.getWindpowerstationId();
|
|
|
+ Map<String, StationInfoDay> daym = dayMap.get(stId);
|
|
|
+ if (daym == null) daym = new HashMap<>();
|
|
|
+ if (sidMap == null) {
|
|
|
+ for (StationInfoDay day : daym.values()) {
|
|
|
+ day.setJhfdl(plan.getGeneratingCapacity() / daym.size());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //去年月发电量
|
|
|
+ List<StationInfoDay> sidList = sidMap.get(stId);
|
|
|
+ double rfdlSum = sidList.stream().mapToDouble(StationInfoDay::getRfdl).sum();
|
|
|
+ double v = plan.getGeneratingCapacity() / rfdlSum;
|
|
|
+ for (StationInfoDay sid : sidList) {
|
|
|
+ DateTime time = DateUtil.offset(sid.getRecordDate(), DateField.YEAR, 1);
|
|
|
+ StationInfoDay day = daym.get(time.toString());
|
|
|
+ if (day == null) {
|
|
|
+ day = new StationInfoDay();
|
|
|
+ day.setStationId(stId);
|
|
|
+ day.setRecordDate(time);
|
|
|
+ days.add(day);
|
|
|
+ }
|
|
|
+ day.setJhfdl(v * sid.getRfdl());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ stationInfoDayService.saveOrUpdateBatch(days);
|
|
|
+ }
|
|
|
+
|
|
|
public void calcStationZhcyRfDlSameDay() {
|
|
|
//date当天零点
|
|
|
DateTime time0 = DateUtil.beginOfDay(DateUtil.date());
|
|
@@ -4835,6 +4900,60 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
});
|
|
|
predictExaminService.saveBatch(peList);
|
|
|
}
|
|
|
+ public void predictExaminBc(List<String> stIds,Date date) {
|
|
|
+ List<RealtimePredict> peList = new ArrayList<>();
|
|
|
+ for (String stId : stIds) {
|
|
|
+ RealtimePredict examin = new RealtimePredict();
|
|
|
+ examin.setModelId("1");
|
|
|
+ examin.setPredictType("ZCQ");
|
|
|
+ examin.setDeviceType("project");
|
|
|
+ examin.setTime(date);
|
|
|
+ examin.setSiteId(stId);
|
|
|
+ examin.setPredictEnergy(0.0);
|
|
|
+ examin.setId("ZCQ_1_"+stId+date.toString());
|
|
|
+ peList.add(examin);
|
|
|
+ }
|
|
|
+ realtimePredictService.saveBatch(peList);
|
|
|
+ }
|
|
|
+ public void predictcdqBc(Date date) {
|
|
|
+ List<RealtimePredict> peList = new ArrayList<>();
|
|
|
+ RealtimePredict examin = new RealtimePredict();
|
|
|
+ examin.setModelId("1");
|
|
|
+ examin.setPredictType("ZCQ");
|
|
|
+ examin.setDeviceType("project");
|
|
|
+ examin.setTime(date);
|
|
|
+// examin.setSiteId(stId);
|
|
|
+ examin.setPredictEnergy(0.0);
|
|
|
+// examin.setId("ZCQ_1_"+stId+date.toString());
|
|
|
+ peList.add(examin);
|
|
|
+ realtimePredictService.saveBatch(peList);
|
|
|
+ }
|
|
|
+ public void zcqycbc(List<String> stIds,Date date) {
|
|
|
+ List<PredictExamin> peList = new ArrayList<>();
|
|
|
+ for (String stId : stIds) {
|
|
|
+ //短期
|
|
|
+ PredictExamin examin = new PredictExamin();
|
|
|
+ examin.setModelId("1");
|
|
|
+ examin.setPredictType("DQ");
|
|
|
+ examin.setDeviceType("station");
|
|
|
+ examin.setTime(date);
|
|
|
+ examin.setSiteId(stId);
|
|
|
+ examin.setExaminScore(30.0);
|
|
|
+ examin.setAccuracyRate(91.0);
|
|
|
+ peList.add(examin);
|
|
|
+ //超短期
|
|
|
+ PredictExamin e = new PredictExamin();
|
|
|
+ e.setModelId("1");
|
|
|
+ e.setPredictType("CDQ");
|
|
|
+ e.setDeviceType("station");
|
|
|
+ e.setTime(date);
|
|
|
+ e.setSiteId(stId);
|
|
|
+ e.setExaminScore(30.0);
|
|
|
+ e.setAccuracyRate(91.0);
|
|
|
+ peList.add(e);
|
|
|
+ }
|
|
|
+ predictExaminService.saveBatch(peList);
|
|
|
+ }
|
|
|
|
|
|
public void calcPredictExamin(Date date) {
|
|
|
DateTime end = DateUtil.beginOfDay(date);
|
|
@@ -4898,6 +5017,68 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
predictExaminService.saveBatch(peList);
|
|
|
}
|
|
|
|
|
|
+ public void calcPredictExamin2(Date date) {
|
|
|
+ DateTime end = DateUtil.beginOfDay(date);
|
|
|
+ DateTime begin = DateUtil.offsetDay(end, -1);
|
|
|
+ //实际功率
|
|
|
+ List<PointInfo> entityGl = getEntity("AGC001", "booster");
|
|
|
+ getSnapDataByEntity(entityGl, begin, end, 15 * 60);
|
|
|
+ Map<String, PointInfo> glpisMap = entityGl.stream().collect(Collectors.toMap(PointInfo::getStationId, Function.identity()));
|
|
|
+ //短期 predictType + "_" + modelId + "_" + sstId + t
|
|
|
+ QueryWrapper<RealtimePredict> dqWrapper = new QueryWrapper<>();
|
|
|
+ dqWrapper.eq("device_type", "station").eq("predict_type", "DQ")
|
|
|
+ .gt("time", begin).le("time", end).orderByAsc("time");
|
|
|
+ List<RealtimePredict> dqList = realtimePredictService.list(dqWrapper);
|
|
|
+ Map<String, List<RealtimePredict>> dqMap = dqList.stream().collect(Collectors.groupingBy(RealtimePredict::getSiteId));
|
|
|
+ //超短期
|
|
|
+ List<HistoryPredict> cdqList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < 6; i++) {
|
|
|
+ DateTime hour = DateUtil.offsetHour(begin, 4 * i);
|
|
|
+ DateTime hour2 = DateUtil.offsetHour(hour, 4);
|
|
|
+ QueryWrapper<HistoryPredict> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.eq("device_type", "station").eq("predict_type", "CDQ").eq("data_time", hour)
|
|
|
+ .between("predict_time", hour, hour2).orderByAsc("data_time");
|
|
|
+ List<HistoryPredict> predicts = historyPredictService.list(wrapper);
|
|
|
+ cdqList.addAll(predicts);
|
|
|
+ }
|
|
|
+ QueryWrapper<HistoryPredict> cdqWrapper = new QueryWrapper<>();
|
|
|
+ cdqWrapper.eq("device_type", "station").eq("predict_type", "CDQ").eq("data_time", begin).orderByAsc("data_time");
|
|
|
+ Map<String, List<HistoryPredict>> cdqMap = cdqList.stream().collect(Collectors.groupingBy(HistoryPredict::getSiteId));
|
|
|
+
|
|
|
+ List<PredictExamin> peList = new ArrayList<>();
|
|
|
+ dqMap.forEach((stId, hps) -> {
|
|
|
+ //短期
|
|
|
+ List<Double> predictPower = hps.stream().map(RealtimePredict::getPredictPower).collect(Collectors.toList());
|
|
|
+ PointInfo glinfo = glpisMap.get(stId);
|
|
|
+ List<Double> actualPower = glinfo.getPointDatas().stream().map(PointData::getValue).collect(Collectors.toList());
|
|
|
+ Double installCapacity = glinfo.getSpare2() * 1000;
|
|
|
+ RealtimePredict predict = hps.get(0);
|
|
|
+ PredictExamin examin = new PredictExamin();
|
|
|
+ examin.setModelId(predict.getModelId());
|
|
|
+ examin.setPredictType("DQ");
|
|
|
+ examin.setDeviceType(predict.getDeviceType());
|
|
|
+ examin.setTime(begin);
|
|
|
+ examin.setSiteId(predict.getSiteId());
|
|
|
+ examin.setExaminScore(calcExaminScore(predictPower, actualPower, installCapacity));
|
|
|
+ examin.setAccuracyRate(calcAccuracyRate(predictPower, actualPower, installCapacity));
|
|
|
+ peList.add(examin);
|
|
|
+ //超短期
|
|
|
+ List<HistoryPredict> cdqhps = cdqMap.get(stId);
|
|
|
+ if (CollUtil.isEmpty(cdqhps)) return;
|
|
|
+ List<Double> predictPowerCdq = cdqhps.stream().map(HistoryPredict::getPredictPower).collect(Collectors.toList());
|
|
|
+ PredictExamin e = new PredictExamin();
|
|
|
+ e.setModelId(predict.getModelId());
|
|
|
+ e.setPredictType("CDQ");
|
|
|
+ e.setDeviceType(predict.getDeviceType());
|
|
|
+ e.setTime(begin);
|
|
|
+ e.setSiteId(predict.getSiteId());
|
|
|
+ e.setExaminScore(calcExaminScore(predictPowerCdq, actualPower, installCapacity));
|
|
|
+ e.setAccuracyRate(calcAccuracyRate(predictPowerCdq, actualPower, installCapacity));
|
|
|
+ peList.add(e);
|
|
|
+ });
|
|
|
+ predictExaminService.saveBatch(peList);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 计算功率日预测曲线最大误差值
|
|
|
*
|