Commit 63bca7e2 authored by ZWT's avatar ZWT

feat(吉林演示): 松原

1.天气数据接收定时任务,解决代码扫描问题,修改文件读取相关代码,解决资源未关流问题;
2.修改登录验证码生成工具类,解决代码扫描问题,修复随机数不安全问题;
3.删除除主程序启动类外其他启动类模块,解决代码扫描问题;
4.删除自定义httputlis类,解决代码扫描问题,替换部分代码远程调用方法;
5.重构光伏预测模块下载电站实际发电数据导入模板接口,解决代码扫描问题;
6.重构光伏预测模块导入电站实际发电数据接口,解决代码扫描问题;
7.删除公用excel导入导出工具类及poi相关pom依赖,解决代码扫描问题;
8.光伏功率预测模块,增加查询线路列表接口,解决页面接口报错问题;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent e221921a
package pps.core.base.excel;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import pps.core.base.service.BaseLineService;
import pps.core.base.entity.WindPredictionFutureView;
import pps.core.base.entity.WindPredictionHistoryView;
import pps.core.base.mapper.WindPredictionFutureViewMapper;
import pps.core.base.mapper.WindPredictionHistoryViewMapper;
import pps.core.base.service.data.base_excel.WindPredictionExcelData;
import pps.core.common.utils.BaseUtils;
import xstartup.base.XContext;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
/**
......@@ -37,7 +45,83 @@ public class WindPredictionDataListener implements ReadListener<WindPredictionEx
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
BaseLineService bean = context.getBean(BaseLineService.class);
bean.saveWindPredictionHistory(context, cachedDataList, stationId);
this.saveWindPredictionHistory(context, cachedDataList, stationId);
}
public void saveWindPredictionHistory(XContext context, List<WindPredictionExcelData> cachedDataList, String stationId) {
if (CollUtil.isNotEmpty(cachedDataList)) {
List<WindPredictionFutureView> futureList = new ArrayList<>(cachedDataList.size());
List<WindPredictionHistoryView> historyList = new ArrayList<>(cachedDataList.size());
//按日期顺序排序
cachedDataList.sort(Comparator.comparing(WindPredictionExcelData::getDataTime));
//数据分界线
DateTime futureFlag = DateUtil.offsetDay(DateUtil.beginOfDay(CollUtil.getLast(cachedDataList).getDataTime()), -20);
//数据分片
for (WindPredictionExcelData excelData : cachedDataList) {
if (DateUtil.compare(excelData.getDataTime(), futureFlag) >= 0) {
//未来数据
WindPredictionFutureView build = WindPredictionFutureView.builder()
.stationId(stationId)
.dataTime(excelData.getDataTime())
.windDirection(excelData.getWindDirection())
.windSpeed(excelData.getWindSpeed())
.airTemperature(excelData.getAirTemperature())
.humidity(excelData.getHumidity())
.pressure(excelData.getPressure())
.actualWindSpeed(excelData.getActualWindSpeed())
.actualPower(excelData.getActualPower())
.predictedPower(excelData.getPredictedPower())
.build();
//去重
if (futureList.stream()
.noneMatch(item -> DateUtil.compare(item.getDataTime(), build.getDataTime()) == 0)) {
futureList.add(build);
}
} else {
//历史数据
WindPredictionHistoryView build = WindPredictionHistoryView.builder()
.stationId(stationId)
.dataTime(excelData.getDataTime())
.windDirection(excelData.getWindDirection())
.windSpeed(excelData.getWindSpeed())
.airTemperature(excelData.getAirTemperature())
.humidity(excelData.getHumidity())
.pressure(excelData.getPressure())
.actualWindSpeed(excelData.getActualWindSpeed())
.actualPower(excelData.getActualPower())
.predictedPower(excelData.getPredictedPower())
.build();
//去重
if (historyList.stream()
.noneMatch(item -> DateUtil.compare(item.getDataTime(), build.getDataTime()) == 0)) {
historyList.add(build);
}
}
}
//记录
String futureStart = DateUtil.formatDateTime(CollUtil.getFirst(futureList).getDataTime());
String futureEnd = DateUtil.formatDateTime(CollUtil.getLast(futureList).getDataTime());
String historyStart = DateUtil.formatDateTime(CollUtil.getFirst(historyList).getDataTime());
String historyEnd = DateUtil.formatDateTime(CollUtil.getLast(historyList).getDataTime());
//入库
if (CollUtil.isNotEmpty(futureList)) {
WindPredictionFutureViewMapper futureMapper = context.getBean(WindPredictionFutureViewMapper.class);
if (futureList.size() > BaseUtils.BATCH_SIZE) {
List<List<WindPredictionFutureView>> subList = BaseUtils.getSubList(futureList);
subList.forEach(futureMapper::insertBatch);
} else {
futureMapper.insertBatch(futureList);
}
}
if (CollUtil.isNotEmpty(historyList)) {
WindPredictionHistoryViewMapper historyMapper = context.getBean(WindPredictionHistoryViewMapper.class);
if (historyList.size() > BaseUtils.BATCH_SIZE) {
List<List<WindPredictionHistoryView>> subList = BaseUtils.getSubList(historyList);
subList.forEach(historyMapper::batchInsert);
} else {
historyMapper.batchInsert(historyList);
}
}
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment