|
@@ -1,10 +1,12 @@
|
|
package com.jiayue.insu.inclientqn.service.client;
|
|
package com.jiayue.insu.inclientqn.service.client;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
+import cn.hutool.core.date.DatePattern;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import com.jiayue.insu.inclientqn.constant.CommonStant;
|
|
import com.jiayue.insu.inclientqn.constant.CommonStant;
|
|
|
|
+import com.jiayue.insu.inclientqn.entity.BackForeForecastData;
|
|
import com.jiayue.insu.inclientqn.entity.BackForeUsForecastData;
|
|
import com.jiayue.insu.inclientqn.entity.BackForeUsForecastData;
|
|
import com.jiayue.insu.inclientqn.entity.BackStatData;
|
|
import com.jiayue.insu.inclientqn.entity.BackStatData;
|
|
import com.jiayue.insu.inclientqn.inenum.ElectricFieldTypeEnum;
|
|
import com.jiayue.insu.inclientqn.inenum.ElectricFieldTypeEnum;
|
|
@@ -219,46 +221,74 @@ public class BackDataGenService {
|
|
|
|
|
|
RequestVo requestVo = null;
|
|
RequestVo requestVo = null;
|
|
|
|
|
|
- if (CollectionUtil.isNotEmpty(backForeUsForecastDatas) && backForeUsForecastDatas.size() < 16) {
|
|
|
|
|
|
+ if (CollectionUtil.isNotEmpty(backForeUsForecastDatas) && backForeUsForecastDatas.size() == 16) {
|
|
|
|
|
|
- boolean checkDate = true;
|
|
|
|
-
|
|
|
|
- long step = 900000L;
|
|
|
|
|
|
+ Collections.sort(backForeUsForecastDatas, Comparator.comparing(BackForeUsForecastData::getForecastTime));
|
|
|
|
+ StringBuilder content = new StringBuilder();
|
|
|
|
+ String header = StrUtil.format(headerTemplate, el, DateUtil.parse(DateUtil.now()).toString("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
+ String labelStart = StrUtil.format("<{}>" + CommonStant.LINE_CONSTANT, QNHLEnum.DATA_STAT_TYPE_UltraShortTermForecastReport.getCode());
|
|
|
|
+ String labelEnd = StrUtil.format("</{}>" + CommonStant.LINE_CONSTANT, QNHLEnum.DATA_STAT_TYPE_UltraShortTermForecastReport.getCode());
|
|
|
|
+ String title = "@" + CommonStant.SPACE1_CONSTANT + "序号" + CommonStant.SPACE4_CONSTANT + "时间"
|
|
|
|
+ + CommonStant.SPACE4_CONSTANT + "功率预测" + CommonStant.SPACE4_CONSTANT + "预计开机容量" + CommonStant.SPACE4_CONSTANT + "风速"
|
|
|
|
+ + CommonStant.SPACE4_CONSTANT + "风向" + CommonStant.SPACE4_CONSTANT + "温度" + CommonStant.SPACE4_CONSTANT + "湿度" + CommonStant.SPACE4_CONSTANT + "气压"
|
|
|
|
+ + CommonStant.LINE_CONSTANT;
|
|
|
|
+ content.append(header);
|
|
|
|
+ content.append(labelStart);
|
|
|
|
+ content.append(title);
|
|
|
|
|
|
- long startTime = signTime + step;
|
|
|
|
|
|
+ String template = "# {}" + CommonStant.SPACE4_CONSTANT + "{}" + CommonStant.SPACE4_CONSTANT + "{}" + CommonStant.SPACE4_CONSTANT + "{}" + CommonStant.SPACE4_CONSTANT + "null"
|
|
|
|
+ + CommonStant.SPACE4_CONSTANT + "null" + CommonStant.SPACE4_CONSTANT + "null" + CommonStant.SPACE4_CONSTANT + "null" + CommonStant.SPACE4_CONSTANT + "null"
|
|
|
|
+ + CommonStant.LINE_CONSTANT;
|
|
|
|
|
|
- long endTime = signTime + step * 15;
|
|
|
|
|
|
+ for (int i = 0; i < backForeUsForecastDatas.size(); i++) {
|
|
|
|
|
|
- for (long i = startTime; i < endTime; i = i + step) {
|
|
|
|
- long finalI = i;
|
|
|
|
- List<BackForeUsForecastData> filter = backForeUsForecastDatas.stream().filter(b -> b.getForecastTime().equals(LocalDateTimeUtil.of(finalI))).collect(Collectors.toList());
|
|
|
|
- if (CollectionUtil.isEmpty(filter)) {
|
|
|
|
- checkDate = false;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ BackForeUsForecastData b = backForeUsForecastDatas.get(i);
|
|
|
|
+ String format = LocalDateTimeUtil.format(b.getForecastTime(), DatePattern.PURE_DATETIME_PATTERN);
|
|
|
|
+ String dataContent = StrUtil.format(template, i, format, b.getForecastValue(), b.getForecastOpenCap());
|
|
|
|
+ content.append(dataContent);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ content.append(labelEnd);
|
|
|
|
+
|
|
|
|
+ requestVo = RequestVo.UPLOAD_FORE(el, content.toString(), signTime);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return requestVo;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public RequestVo genForeForecast(String el, long signTime, List<BackForeForecastData> backForeForecastDatas) throws Exception {
|
|
|
|
+
|
|
|
|
+ RequestVo requestVo = null;
|
|
|
|
+
|
|
|
|
+ if (CollectionUtil.isNotEmpty(backForeForecastDatas)) {
|
|
|
|
+
|
|
|
|
+ boolean checkDate = true;
|
|
|
|
+
|
|
|
|
+
|
|
if (checkDate) {
|
|
if (checkDate) {
|
|
- Collections.sort(backForeUsForecastDatas, Comparator.comparing(BackForeUsForecastData::getForecastTime));
|
|
|
|
|
|
+ Collections.sort(backForeForecastDatas, Comparator.comparing(BackForeForecastData::getForecastTime));
|
|
StringBuilder content = new StringBuilder();
|
|
StringBuilder content = new StringBuilder();
|
|
String header = StrUtil.format(headerTemplate, el, DateUtil.parse(DateUtil.now()).toString("yyyy-MM-dd HH:mm:ss"));
|
|
String header = StrUtil.format(headerTemplate, el, DateUtil.parse(DateUtil.now()).toString("yyyy-MM-dd HH:mm:ss"));
|
|
String labelStart = StrUtil.format("<{}>" + CommonStant.LINE_CONSTANT, QNHLEnum.DATA_STAT_TYPE_UltraShortTermForecastReport.getCode());
|
|
String labelStart = StrUtil.format("<{}>" + CommonStant.LINE_CONSTANT, QNHLEnum.DATA_STAT_TYPE_UltraShortTermForecastReport.getCode());
|
|
String labelEnd = StrUtil.format("</{}>" + CommonStant.LINE_CONSTANT, QNHLEnum.DATA_STAT_TYPE_UltraShortTermForecastReport.getCode());
|
|
String labelEnd = StrUtil.format("</{}>" + CommonStant.LINE_CONSTANT, QNHLEnum.DATA_STAT_TYPE_UltraShortTermForecastReport.getCode());
|
|
String title = "@" + CommonStant.SPACE1_CONSTANT + "序号" + CommonStant.SPACE4_CONSTANT + "时间"
|
|
String title = "@" + CommonStant.SPACE1_CONSTANT + "序号" + CommonStant.SPACE4_CONSTANT + "时间"
|
|
- + CommonStant.SPACE4_CONSTANT + "功率预测" + CommonStant.SPACE4_CONSTANT + "预计开机容量" + CommonStant.SPACE4_CONSTANT + "风速"
|
|
|
|
- + CommonStant.SPACE4_CONSTANT + "风向" + CommonStant.SPACE4_CONSTANT + "温度" + CommonStant.SPACE4_CONSTANT + "湿度" + CommonStant.SPACE4_CONSTANT + "气压"
|
|
|
|
|
|
+ + CommonStant.SPACE4_CONSTANT + "功率预测" + CommonStant.SPACE4_CONSTANT + "预计开机容量"
|
|
+ CommonStant.LINE_CONSTANT;
|
|
+ CommonStant.LINE_CONSTANT;
|
|
content.append(header);
|
|
content.append(header);
|
|
content.append(labelStart);
|
|
content.append(labelStart);
|
|
content.append(title);
|
|
content.append(title);
|
|
|
|
|
|
- String template = "# {}" + CommonStant.SPACE4_CONSTANT + "{}" + CommonStant.SPACE4_CONSTANT + "{}" + CommonStant.SPACE4_CONSTANT + "null" + CommonStant.SPACE4_CONSTANT + "null"
|
|
|
|
- + CommonStant.SPACE4_CONSTANT + "null" + CommonStant.SPACE4_CONSTANT + "null" + CommonStant.SPACE4_CONSTANT + "null" + CommonStant.SPACE4_CONSTANT + "null"
|
|
|
|
|
|
+ String template = "# {}" + CommonStant.SPACE4_CONSTANT + "{}" + CommonStant.SPACE4_CONSTANT + "{}" + CommonStant.SPACE4_CONSTANT + "{}"
|
|
+ CommonStant.LINE_CONSTANT;
|
|
+ CommonStant.LINE_CONSTANT;
|
|
|
|
|
|
- for (int i = 0; i < backForeUsForecastDatas.size(); i++) {
|
|
|
|
|
|
+ for (int i = 0; i < backForeForecastDatas.size(); i++) {
|
|
|
|
|
|
- BackForeUsForecastData b = backForeUsForecastDatas.get(i);
|
|
|
|
- String dataContent = String.format(template, i,b.getForecastValue(),b.getForecastOpenCap());
|
|
|
|
|
|
+ BackForeForecastData b = backForeForecastDatas.get(i);
|
|
|
|
+ String format = LocalDateTimeUtil.format(b.getForecastTime(), DatePattern.PURE_DATETIME_PATTERN);
|
|
|
|
+ String dataContent = StrUtil.format(template, i, format, b.getForecastValue(), b.getForecastOpenCap());
|
|
content.append(dataContent);
|
|
content.append(dataContent);
|
|
}
|
|
}
|
|
|
|
|