Commit e23c5aa5 authored by ZWT's avatar ZWT

feat(零碳): 长庆演示系统新增功能

1.新建油田配置表同时生成相关代码及mapper文件,修改部分第三方数据抽取定时任务,增加针对不同井场开关控制逻辑,同时修改首页页面展示逻辑,通过油田配置功能区分不同首页展示功能;
2.新建定时任务配置表同时生成相关代码及mapper文件,定时任务模块增加mybatis配置,用以操作数据库,修改部分第三方数据抽取定时任务,修改使用方式使其脱离框架方便动态控制;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent 5d1fbbfb
......@@ -159,170 +159,6 @@ public class BaseWeatherCloudServiceImpl implements IBaseWeatherCloudService {
return XServiceResult.OK;
}
/**
* 数据拆分
*
* @param jsonObject json对象
* @param plantMap 植物地图
* @param deleteList 删除列表
* @param create 创造
* @param end 结束
* @param batchList 批次列表
* @param timeList 时间表
*/
private void dataFractionation(JSONObject jsonObject, Map<String, List<BasePhotovoltaicPlantView>> plantMap, List<PlantPredictedPowerDataEnt> deleteList,
DateTime create, DateTime end, List<PlantPredictedPowerDataEnt> batchList, List<String> timeList) {
Map<String, List<DailyData>> cityDataMap = new HashMap<>(16);
for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (value instanceof JSONArray) {
cityDataMap.put(key, ((JSONArray) value).toJavaList(DailyData.class));
}
}
for (String cityCode : cityDataMap.keySet()) {
if (!plantMap.containsKey(cityCode)) {
continue;
}
List<DailyData> dailyDataList = cityDataMap.get(cityCode);
List<BasePhotovoltaicPlantView> plantViewList = plantMap.get(cityCode);
//删除数据
for (BasePhotovoltaicPlantView plantView : plantViewList) {
deleteList.add(PlantPredictedPowerDataEnt.builder()
.plantId(plantView.getId())
.createTime(create)
.endTime(end)
.build());
}
//遍历预测数据列表
for (DailyData dailyData : dailyDataList) {
for (BasePhotovoltaicPlantView plant : plantViewList) {
List<PlantPredictedPowerDataEnt> allList = new ArrayList<>(32);
List<PlantPredictedPowerDataEnt> objList = new ArrayList<>(16);
DateTime dateTime = DateTime.of(dailyData.getDateTime());
int hours = 0;
String plantId = plant.getId();
DateTime date;
for (int i = 0; i < 8; i++) {
//判断小时数与查到的小时数,如果查到的小时数小,判断为第二天
int hour = LocalTime.parse(dailyData.getHourTimeArray().get(i)).getHour();
if (hours >= hour) {
dateTime = DateUtil.offsetDay(dateTime, 1);
}
hours = hour;
int wind = 0;
if (CollUtil.isNotEmpty(dailyData.getWindDirectionArray())) {
if (i < dailyData.getWindDirectionArray().size()) {
WindDirection windDirection = WindDirection.findByValue(dailyData.getWindDirectionArray().get(i));
if (Objects.nonNull(windDirection)) {
wind = windDirection.getValue();
}
}
}
PlantPredictedPowerDataEnt dao = this.getPlantPredictedPowerEnt(plantId,
this.int2Str(hours),
new BigDecimal(CharSequenceUtil.replace(dailyData.getTemperatureArray().get(i), "℃", "")),
new BigDecimal(CharSequenceUtil.replace(dailyData.getWindSpeedArray().get(i), "m/s", "")),
new BigDecimal(wind),
new BigDecimal(CharSequenceUtil.replace(dailyData.getPressureArray().get(i), "hPa", "")),
new BigDecimal(CharSequenceUtil.replace(dailyData.getHumidityArray().get(i), "%", "")),
String.valueOf(dateTime.year()),
this.int2Str(dateTime.month() + 1),
this.int2Str(dateTime.dayOfMonth())
);
// 5.执行SQL
allList.add(dao);
PlantPredictedPowerDataEnt isExit = objList.stream().filter(item ->
CharSequenceUtil.equals(item.getYearTime(), dao.getYearTime()) &&
CharSequenceUtil.equals(item.getMonthTime(), dao.getMonthTime()) &&
CharSequenceUtil.equals(item.getDayTime(), dao.getDayTime()) &&
CharSequenceUtil.equals(item.getHourTime(), dao.getHourTime()))
.findFirst()
.orElse(null);
if (Objects.isNull(isExit)) {
objList.add(dao);
}
}
// 原站点时间结构为:08:00 11:00 14:00 17:00 20:00 23:00 02:00 05:00
// 两条数据中间差了两个小时,使用上下两条数据推算出中间差掉的两个小时
for (int i = 0; i < objList.size() - 1; i++) {
for (int y = 1; y < 3; y++) {
PlantPredictedPowerDataEnt dataEnt = objList.get(i);
date = DateTime.of(dataEnt.getDataDate(), "yyyy-MM-dd HH:mm");
String hourString;
Integer hourTime = Integer.valueOf(dataEnt.getHourTime());
if (hourTime.equals(23)) {
date = DateUtil.offsetDay(date, 1);
hourString = "0" + (y - 1);
} else {
if ((hourTime + y) < 10) {
hourString = "0" + (hourTime + y);
} else {
hourString = String.valueOf(hourTime + y);
}
}
PlantPredictedPowerDataEnt nextData = objList.get(i + 1);
BigDecimal valueOf = BigDecimal.valueOf(0.3 * y);
PlantPredictedPowerDataEnt dao = this.getPlantPredictedPowerEnt(plantId,
hourString,
this.compute(dataEnt.getTemperature(), nextData.getTemperature(), valueOf),
this.compute(dataEnt.getWindSpeed(), nextData.getWindSpeed(), valueOf),
dataEnt.getWindDirection(),
this.compute(dataEnt.getPressure(), nextData.getPressure(), valueOf),
this.compute(dataEnt.getHumidity(), nextData.getHumidity(), valueOf),
String.valueOf(date.year()),
this.int2Str(date.month() + 1),
this.int2Str(date.dayOfMonth())
);
// 5.执行SQL
allList.add(dao);
}
}
//入库
List<PlantPredictedPowerDataEnt> sortList = allList.stream()
.sorted(Comparator.comparing(PlantPredictedPowerDataEnt::getDataDate))
.collect(Collectors.toList());
for (int i = 0; i < sortList.size(); i++) {
PlantPredictedPowerDataEnt item = sortList.get(i);
batchList.add(item);
if (i < sortList.size() - 1) {
for (int y = 0; y < timeList.size(); y++) {
PlantPredictedPowerDataEnt dao = XCopyUtils.copyNewObject(item);
dao.setMinTime(timeList.get(y));
dao.setDataDate(dao.getYearTime() + '-' + dao.getMonthTime() + '-' + dao.getDayTime() + ' ' + dao.getHourTime() + ':' + dao.getMinTime());
PlantPredictedPowerDataEnt nextData = sortList.get(i + 1);
BigDecimal valueOf = BigDecimal.valueOf(0.3 * (y + 1));
dao.setTemperature(this.compute(Objects.isNull(item.getTemperature()) ? BigDecimal.ZERO : item.getTemperature(),
Objects.isNull(nextData.getTemperature()) ? BigDecimal.ZERO : nextData.getTemperature(),
valueOf));
dao.setHumidity(this.compute(Objects.isNull(item.getHumidity()) ? BigDecimal.ZERO : item.getHumidity(),
Objects.isNull(nextData.getHumidity()) ? BigDecimal.ZERO : nextData.getHumidity(),
valueOf));
dao.setWindSpeed(this.compute(Objects.isNull(item.getWindSpeed()) ? BigDecimal.ZERO : item.getWindSpeed(),
Objects.isNull(nextData.getWindSpeed()) ? BigDecimal.ZERO : nextData.getWindSpeed(),
valueOf));
dao.setPressure(this.compute(Objects.isNull(item.getPressure()) ? BigDecimal.ZERO : item.getPressure(),
Objects.isNull(nextData.getPressure()) ? BigDecimal.ZERO : nextData.getPressure(),
valueOf));
dao.setPlaneIrradiance(this.compute(Objects.isNull(item.getPlaneIrradiance()) ? BigDecimal.ZERO : item.getPlaneIrradiance(),
Objects.isNull(nextData.getPlaneIrradiance()) ? BigDecimal.ZERO : nextData.getPlaneIrradiance(),
valueOf));
dao.setHorizontalIrradiance(this.compute(Objects.isNull(item.getHorizontalIrradiance()) ? BigDecimal.ZERO : item.getHorizontalIrradiance(),
Objects.isNull(nextData.getHorizontalIrradiance()) ? BigDecimal.ZERO : nextData.getHorizontalIrradiance(),
valueOf));
dao.setPower(this.compute(Objects.isNull(item.getPower()) ? BigDecimal.ZERO : item.getPower(),
Objects.isNull(nextData.getPower()) ? BigDecimal.ZERO : nextData.getPower(),
valueOf));
batchList.add(dao);
}
}
}
}
}
}
}
/**
* 天气数据接收Cloud模块--天气Api数据处理
*
......@@ -518,6 +354,169 @@ public class BaseWeatherCloudServiceImpl implements IBaseWeatherCloudService {
.build());
}
/**
* 数据拆分
*
* @param jsonObject json对象
* @param plantMap 植物地图
* @param deleteList 删除列表
* @param create 创造
* @param end 结束
* @param batchList 批次列表
* @param timeList 时间表
*/
private void dataFractionation(JSONObject jsonObject, Map<String, List<BasePhotovoltaicPlantView>> plantMap, List<PlantPredictedPowerDataEnt> deleteList,
DateTime create, DateTime end, List<PlantPredictedPowerDataEnt> batchList, List<String> timeList) {
Map<String, List<DailyData>> cityDataMap = new HashMap<>(16);
for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (value instanceof JSONArray) {
cityDataMap.put(key, ((JSONArray) value).toJavaList(DailyData.class));
}
}
for (String cityCode : cityDataMap.keySet()) {
if (!plantMap.containsKey(cityCode)) {
continue;
}
List<DailyData> dailyDataList = cityDataMap.get(cityCode);
List<BasePhotovoltaicPlantView> plantViewList = plantMap.get(cityCode);
//删除数据
for (BasePhotovoltaicPlantView plantView : plantViewList) {
deleteList.add(PlantPredictedPowerDataEnt.builder()
.plantId(plantView.getId())
.createTime(create)
.endTime(end)
.build());
}
//遍历预测数据列表
for (DailyData dailyData : dailyDataList) {
for (BasePhotovoltaicPlantView plant : plantViewList) {
List<PlantPredictedPowerDataEnt> allList = new ArrayList<>(32);
List<PlantPredictedPowerDataEnt> objList = new ArrayList<>(16);
DateTime dateTime = DateTime.of(dailyData.getDateTime());
int hours = 0;
String plantId = plant.getId();
DateTime date;
for (int i = 0; i < 8; i++) {
//判断小时数与查到的小时数,如果查到的小时数小,判断为第二天
int hour = LocalTime.parse(dailyData.getHourTimeArray().get(i)).getHour();
if (hours >= hour) {
dateTime = DateUtil.offsetDay(dateTime, 1);
}
hours = hour;
int wind = 0;
if (CollUtil.isNotEmpty(dailyData.getWindDirectionArray())) {
if (i < dailyData.getWindDirectionArray().size()) {
WindDirection windDirection = WindDirection.findByValue(dailyData.getWindDirectionArray().get(i));
if (Objects.nonNull(windDirection)) {
wind = windDirection.getValue();
}
}
}
PlantPredictedPowerDataEnt dao = this.getPlantPredictedPowerEnt(plantId,
this.int2Str(hours),
new BigDecimal(CharSequenceUtil.replace(dailyData.getTemperatureArray().get(i), "℃", "")),
new BigDecimal(CharSequenceUtil.replace(dailyData.getWindSpeedArray().get(i), "m/s", "")),
new BigDecimal(wind),
new BigDecimal(CharSequenceUtil.replace(dailyData.getPressureArray().get(i), "hPa", "")),
new BigDecimal(CharSequenceUtil.replace(dailyData.getHumidityArray().get(i), "%", "")),
String.valueOf(dateTime.year()),
this.int2Str(dateTime.month() + 1),
this.int2Str(dateTime.dayOfMonth())
);
// 5.执行SQL
allList.add(dao);
PlantPredictedPowerDataEnt isExit = objList.stream().filter(item ->
CharSequenceUtil.equals(item.getYearTime(), dao.getYearTime()) &&
CharSequenceUtil.equals(item.getMonthTime(), dao.getMonthTime()) &&
CharSequenceUtil.equals(item.getDayTime(), dao.getDayTime()) &&
CharSequenceUtil.equals(item.getHourTime(), dao.getHourTime()))
.findFirst()
.orElse(null);
if (Objects.isNull(isExit)) {
objList.add(dao);
}
}
// 原站点时间结构为:08:00 11:00 14:00 17:00 20:00 23:00 02:00 05:00
// 两条数据中间差了两个小时,使用上下两条数据推算出中间差掉的两个小时
for (int i = 0; i < objList.size() - 1; i++) {
for (int y = 1; y < 3; y++) {
PlantPredictedPowerDataEnt dataEnt = objList.get(i);
date = DateTime.of(dataEnt.getDataDate(), "yyyy-MM-dd HH:mm");
String hourString;
Integer hourTime = Integer.valueOf(dataEnt.getHourTime());
if (hourTime.equals(23)) {
date = DateUtil.offsetDay(date, 1);
hourString = "0" + (y - 1);
} else {
if ((hourTime + y) < 10) {
hourString = "0" + (hourTime + y);
} else {
hourString = String.valueOf(hourTime + y);
}
}
PlantPredictedPowerDataEnt nextData = objList.get(i + 1);
BigDecimal valueOf = BigDecimal.valueOf(0.3 * y);
PlantPredictedPowerDataEnt dao = this.getPlantPredictedPowerEnt(plantId,
hourString,
this.compute(dataEnt.getTemperature(), nextData.getTemperature(), valueOf),
this.compute(dataEnt.getWindSpeed(), nextData.getWindSpeed(), valueOf),
dataEnt.getWindDirection(),
this.compute(dataEnt.getPressure(), nextData.getPressure(), valueOf),
this.compute(dataEnt.getHumidity(), nextData.getHumidity(), valueOf),
String.valueOf(date.year()),
this.int2Str(date.month() + 1),
this.int2Str(date.dayOfMonth())
);
// 5.执行SQL
allList.add(dao);
}
}
//入库
List<PlantPredictedPowerDataEnt> sortList = allList.stream()
.sorted(Comparator.comparing(PlantPredictedPowerDataEnt::getDataDate))
.collect(Collectors.toList());
for (int i = 0; i < sortList.size(); i++) {
PlantPredictedPowerDataEnt item = sortList.get(i);
batchList.add(item);
if (i < sortList.size() - 1) {
for (int y = 0; y < timeList.size(); y++) {
PlantPredictedPowerDataEnt dao = XCopyUtils.copyNewObject(item);
dao.setMinTime(timeList.get(y));
dao.setDataDate(dao.getYearTime() + '-' + dao.getMonthTime() + '-' + dao.getDayTime() + ' ' + dao.getHourTime() + ':' + dao.getMinTime());
PlantPredictedPowerDataEnt nextData = sortList.get(i + 1);
BigDecimal valueOf = BigDecimal.valueOf(0.3 * (y + 1));
dao.setTemperature(this.compute(Objects.isNull(item.getTemperature()) ? BigDecimal.ZERO : item.getTemperature(),
Objects.isNull(nextData.getTemperature()) ? BigDecimal.ZERO : nextData.getTemperature(),
valueOf));
dao.setHumidity(this.compute(Objects.isNull(item.getHumidity()) ? BigDecimal.ZERO : item.getHumidity(),
Objects.isNull(nextData.getHumidity()) ? BigDecimal.ZERO : nextData.getHumidity(),
valueOf));
dao.setWindSpeed(this.compute(Objects.isNull(item.getWindSpeed()) ? BigDecimal.ZERO : item.getWindSpeed(),
Objects.isNull(nextData.getWindSpeed()) ? BigDecimal.ZERO : nextData.getWindSpeed(),
valueOf));
dao.setPressure(this.compute(Objects.isNull(item.getPressure()) ? BigDecimal.ZERO : item.getPressure(),
Objects.isNull(nextData.getPressure()) ? BigDecimal.ZERO : nextData.getPressure(),
valueOf));
dao.setPlaneIrradiance(this.compute(Objects.isNull(item.getPlaneIrradiance()) ? BigDecimal.ZERO : item.getPlaneIrradiance(),
Objects.isNull(nextData.getPlaneIrradiance()) ? BigDecimal.ZERO : nextData.getPlaneIrradiance(),
valueOf));
dao.setHorizontalIrradiance(this.compute(Objects.isNull(item.getHorizontalIrradiance()) ? BigDecimal.ZERO : item.getHorizontalIrradiance(),
Objects.isNull(nextData.getHorizontalIrradiance()) ? BigDecimal.ZERO : nextData.getHorizontalIrradiance(),
valueOf));
dao.setPower(this.compute(Objects.isNull(item.getPower()) ? BigDecimal.ZERO : item.getPower(),
Objects.isNull(nextData.getPower()) ? BigDecimal.ZERO : nextData.getPower(),
valueOf));
batchList.add(dao);
}
}
}
}
}
}
}
/**
* 获取电厂预测功率ent
*
......
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