Commit 9465f72e authored by ZWT's avatar ZWT

feat(能源管理系统): 间开优化定时任务

1.开发间开优化长期间开优化定时任务,完成并网流程绿电消纳优先策略;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent e3a3823b
package pps.core.common.constant;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
/**
* 业务操作常量
*
......@@ -48,6 +51,11 @@ public class BusinessConstant {
*/
public static final String END_OF_DAY_TIME = "23:59";
/**
* 日期标志
*/
public static final DateTime DATE_FLAG = DateUtil.parse("1970-01-02 00:00:00", "yyyy-mm-dd HH:mm:ss");
/*------------------------------字典------------------------------*/
/**
......
......@@ -95,7 +95,6 @@ public class SpaceOptimizeLongCloudServiceImpl implements ISpaceOptimizeLongClou
month = String.valueOf(monthNum);
}
SpaceInstitutionDurationMapper durationMapper = context.getBean(SpaceInstitutionDurationMapper.class);
DateTime dateFlag = DateUtil.parse("1970-01-02 00:00:00", "yyyy-mm-dd HH:mm:ss");
List<SpaceOptimizeLongPeriodView> longPeriodList = new ArrayList<>(32);
List<SpaceOptimizeLongWellheadView> longWellheadList = new ArrayList<>(64);
List<SpaceOptimizeLongDurationView> longDurationList = new ArrayList<>(128);
......@@ -198,29 +197,29 @@ public class SpaceOptimizeLongCloudServiceImpl implements ISpaceOptimizeLongClou
//第一口井的启动时间
if (isFirstWellhead) {
firstStartTime = startTime;
//计算井时间
int endIndex = 0;
//计算井时间
int startIndex = 0;
for (int a = 0, avgPowerSize = avgPowerList.size(); a < avgPowerSize; a++) {
DynamicQueryPlantPredictedPowerOutput predictedPower = avgPowerList.get(a);
if (DateUtil.parse(predictedPower.getHourTime() + predictedPower.getMinTime(), BusinessConstant.TIME_FORMAT).compareTo(startTime) < 0) {
continue;
}
//当日时间段平均光伏出力>第一口井运行负荷时,该时间为第一口井运行时间
//当日时间段平均光伏出力>=第一口井运行负荷时,该时间为第一口井运行时间
if (predictedPower.getPower().compareTo(serviceRating) >= BusinessConstant.ZERO) {
endIndex = a;
startIndex = a;
break;
}
}
DynamicQueryPlantPredictedPowerOutput end = avgPowerList.get(endIndex);
String endTimeString = end.getHourTime() + end.getMinTime();
DynamicQueryPlantPredictedPowerOutput start = avgPowerList.get(startIndex);
String startTimeString = start.getHourTime() + start.getMinTime();
//计算第一次关井时间,按照间开时间段顺延
int startDuration = (int) startTime.between(endTime, DateUnit.MINUTE);
DateTime endTimeOptimize = startTime.offset(DateField.MINUTE, startDuration);
this.createOptimizeLongDuration(longDurationList, duration, longPeriodId, recordId, wellheadId, null,
openWellTime, StringUtils.substringBeforeLast(endTimeString, BusinessConstant.INITIALIZATION_SECOND)
startTimeString, endTimeOptimize.toString(BusinessConstant.MINUTES_FORMAT)
);
//计算
DateTime endTimeOptimize = DateUtil.parse(endTimeString, BusinessConstant.TIME_FORMAT);
//计算时间偏移
DateTime startTimeOptimize = DateUtil.parse(startTimeString, BusinessConstant.TIME_FORMAT);
//取时间间隔(分钟)
between = (int) endTimeOptimize.between(endTime, DateUnit.MINUTE);
if (endTimeOptimize.compareTo(endTime) < 0) {
between = (int) startTimeOptimize.between(startTime, DateUnit.MINUTE);
if (startTimeOptimize.compareTo(startTime) < 0) {
between = ~between + 1;
}
}
......@@ -248,7 +247,7 @@ public class SpaceOptimizeLongCloudServiceImpl implements ISpaceOptimizeLongClou
int openDuration = (int) startTime.between(endTime, DateUnit.MINUTE);
DateTime endTimeOptimize = startTimeOptimize.offset(DateField.MINUTE, openDuration);
String endTimeString;
if (endTimeOptimize.compareTo(dateFlag) > 0) {
if (endTimeOptimize.compareTo(BusinessConstant.DATE_FLAG) > 0) {
endTimeString = BusinessConstant.END_OF_DAY_TIME;
} else {
endTimeString = endTimeOptimize.toString(BusinessConstant.MINUTES_FORMAT);
......@@ -267,14 +266,14 @@ public class SpaceOptimizeLongCloudServiceImpl implements ISpaceOptimizeLongClou
}
} else {
DateTime offset = startTime.offset(DateField.MINUTE, between);
if (offset.compareTo(dateFlag) > 0) {
if (offset.compareTo(BusinessConstant.DATE_FLAG) > 0) {
//如果时间超过当天,舍弃
continue;
}
DateTime endDate = DateUtil.parse(duration.getCloseWellTime() + BusinessConstant.INITIALIZATION_SECOND, BusinessConstant.TIME_FORMAT)
.offset(DateField.MINUTE, between);
String closeWellTime;
if (endDate.compareTo(dateFlag) > 0) {
if (endDate.compareTo(BusinessConstant.DATE_FLAG) > 0) {
closeWellTime = BusinessConstant.END_OF_DAY_TIME;
} else {
closeWellTime = endDate.toString(BusinessConstant.MINUTES_FORMAT);
......@@ -378,14 +377,14 @@ public class SpaceOptimizeLongCloudServiceImpl implements ISpaceOptimizeLongClou
}
} else {
DateTime offset = startTime.offset(DateField.MINUTE, between);
if (offset.compareTo(dateFlag) > 0) {
if (offset.compareTo(BusinessConstant.DATE_FLAG) > 0) {
//如果时间超过当天,舍弃
continue;
}
DateTime endDate = DateUtil.parse(duration.getCloseWellTime() + BusinessConstant.INITIALIZATION_SECOND, BusinessConstant.TIME_FORMAT)
.offset(DateField.MINUTE, between);
String closeWellTime;
if (endDate.compareTo(dateFlag) > 0) {
if (endDate.compareTo(BusinessConstant.DATE_FLAG) > 0) {
closeWellTime = BusinessConstant.END_OF_DAY_TIME;
} else {
closeWellTime = endDate.toString(BusinessConstant.MINUTES_FORMAT);
......
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