|
@@ -18,6 +18,7 @@ import com.cpp.web.service.datafactory.SftpChannelService;
|
|
import com.cpp.web.service.regulation.TempShortRegulationDetailService;
|
|
import com.cpp.web.service.regulation.TempShortRegulationDetailService;
|
|
import com.cpp.web.service.regulation.TempShortRegulationService;
|
|
import com.cpp.web.service.regulation.TempShortRegulationService;
|
|
import com.cpp.web.service.station.ElectricFieldService;
|
|
import com.cpp.web.service.station.ElectricFieldService;
|
|
|
|
+import com.cpp.web.service.station.ForecastPowerShortTermSendService;
|
|
import com.cpp.web.service.station.ForecastPowerShortTermStationService;
|
|
import com.cpp.web.service.station.ForecastPowerShortTermStationService;
|
|
import com.cpp.web.utils.CppFileUtil;
|
|
import com.cpp.web.utils.CppFileUtil;
|
|
import com.cpp.web.utils.DateTimeUtil;
|
|
import com.cpp.web.utils.DateTimeUtil;
|
|
@@ -59,6 +60,8 @@ public class RgulationSendJob {
|
|
ElectricFieldService electricFieldService;
|
|
ElectricFieldService electricFieldService;
|
|
@Autowired
|
|
@Autowired
|
|
SftpChannelService sftpChannelService;
|
|
SftpChannelService sftpChannelService;
|
|
|
|
+ @Autowired
|
|
|
|
+ ForecastPowerShortTermSendService forecastPowerShortTermSendService;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 生成调控下发文件定时任务
|
|
* 生成调控下发文件定时任务
|
|
@@ -69,17 +72,17 @@ public class RgulationSendJob {
|
|
// 判断调控截止时间
|
|
// 判断调控截止时间
|
|
String dqEndTime = iSysConfigService.selectConfigByKey("dqEndTime");
|
|
String dqEndTime = iSysConfigService.selectConfigByKey("dqEndTime");
|
|
if (!StrUtil.isBlankIfStr(dqEndTime)) {
|
|
if (!StrUtil.isBlankIfStr(dqEndTime)) {
|
|
- Date tkDate = DateTimeUtil.getDayStartTime(System.currentTimeMillis());
|
|
|
|
- QueryWrapper<TempShortRegulation> tempShortRegulationQueryWrapper = new QueryWrapper<>();
|
|
|
|
- tempShortRegulationQueryWrapper.eq("tk_date", tkDate);
|
|
|
|
- tempShortRegulationQueryWrapper.eq("regulation_status_enum", RegulationStatusEnum.E2.name());
|
|
|
|
- // 查找调控主表当日未下发的记录
|
|
|
|
- List<TempShortRegulation> tempShortRegulationList = tempShortRegulationService.list(tempShortRegulationQueryWrapper);
|
|
|
|
- // 存在未下发的记录就执行下发任务
|
|
|
|
- if (!tempShortRegulationList.isEmpty()){
|
|
|
|
- // 生成截止时间
|
|
|
|
- Date dqEndDate = DateUtils.parseDate(DateFormatUtils.format(new Date(), "yyyy-MM-dd " + dqEndTime), "yyyy-MM-dd HH:mm");
|
|
|
|
- if (new Date().before(dqEndDate)) {
|
|
|
|
|
|
+ // 生成截止时间
|
|
|
|
+ Date dqEndDate = DateUtils.parseDate(DateFormatUtils.format(new Date(), "yyyy-MM-dd " + dqEndTime), "yyyy-MM-dd HH:mm");
|
|
|
|
+ if (new Date().after(dqEndDate)) {
|
|
|
|
+ Date tkDate = DateTimeUtil.getDayStartTime(System.currentTimeMillis());
|
|
|
|
+ QueryWrapper<TempShortRegulation> tempShortRegulationQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ tempShortRegulationQueryWrapper.eq("tk_date", tkDate)
|
|
|
|
+ .and(wrapper -> wrapper.eq("regulation_status_enum", RegulationStatusEnum.E1.name()).or().eq("regulation_status_enum", RegulationStatusEnum.E3.name()));
|
|
|
|
+ // 查找调控主表当日未下发的记录
|
|
|
|
+ List<TempShortRegulation> tempShortRegulationList = tempShortRegulationService.list(tempShortRegulationQueryWrapper);
|
|
|
|
+ // 存在未下发的记录就执行下发任务
|
|
|
|
+ if (!tempShortRegulationList.isEmpty()) {
|
|
// 超过截止时间就执行调控下发,获取当天将要下发的调控记录
|
|
// 超过截止时间就执行调控下发,获取当天将要下发的调控记录
|
|
QueryWrapper<TempShortRegulationDetail> tempShortRegulationDetailQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<TempShortRegulationDetail> tempShortRegulationDetailQueryWrapper = new QueryWrapper<>();
|
|
// 当日调控
|
|
// 当日调控
|
|
@@ -109,6 +112,7 @@ public class RgulationSendJob {
|
|
String vmFileName = "";
|
|
String vmFileName = "";
|
|
// 定义下发状态
|
|
// 定义下发状态
|
|
String isSend = RegulationStatusEnum.E3.name();
|
|
String isSend = RegulationStatusEnum.E3.name();
|
|
|
|
+ List<ForecastPowerShortTermStation> tempStationList = new ArrayList<>();
|
|
try {
|
|
try {
|
|
List<TempShortRegulationDetail> shortRegulationDetailList = tempShortRegulationDetailGroup.get(stationCode);
|
|
List<TempShortRegulationDetail> shortRegulationDetailList = tempShortRegulationDetailGroup.get(stationCode);
|
|
Map<Long, BigDecimal> tkMap = new HashMap<>();
|
|
Map<Long, BigDecimal> tkMap = new HashMap<>();
|
|
@@ -117,7 +121,7 @@ public class RgulationSendJob {
|
|
}
|
|
}
|
|
|
|
|
|
// 获取该场站的原始值
|
|
// 获取该场站的原始值
|
|
- List<ForecastPowerShortTermStation> tempStationList = forecastPowerShortTermStationList.stream().filter(s -> s.getStationCode().equals(stationCode)).collect(Collectors.toList());
|
|
|
|
|
|
+ tempStationList = forecastPowerShortTermStationList.stream().filter(s -> s.getStationCode().equals(stationCode)).collect(Collectors.toList());
|
|
tempStationList.sort(Comparator.comparing(ForecastPowerShortTermStation::getTime));
|
|
tempStationList.sort(Comparator.comparing(ForecastPowerShortTermStation::getTime));
|
|
for (ForecastPowerShortTermStation forecastPowerShortTermStation : tempStationList) {
|
|
for (ForecastPowerShortTermStation forecastPowerShortTermStation : tempStationList) {
|
|
// 遍历原始值每个点位,如果该点位存在调控值,则替换原始值。
|
|
// 遍历原始值每个点位,如果该点位存在调控值,则替换原始值。
|
|
@@ -143,7 +147,7 @@ public class RgulationSendJob {
|
|
// 获取临时存储文件路径
|
|
// 获取临时存储文件路径
|
|
String tempCreateFilePath = CppFileUtil.getTempCreateFilePath();
|
|
String tempCreateFilePath = CppFileUtil.getTempCreateFilePath();
|
|
File dirFile = FileUtil.mkdir(tempCreateFilePath);
|
|
File dirFile = FileUtil.mkdir(tempCreateFilePath);
|
|
- if (dirFile==null) {
|
|
|
|
|
|
+ if (dirFile == null) {
|
|
throw new RuntimeException("创建文件夹tempCreateFile失败");
|
|
throw new RuntimeException("创建文件夹tempCreateFile失败");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -159,11 +163,26 @@ public class RgulationSendJob {
|
|
isSend = RegulationStatusEnum.E1.name();
|
|
isSend = RegulationStatusEnum.E1.name();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error(stationCode + "生成调控下发文件定时任务失败", e);
|
|
log.error(stationCode + "生成调控下发文件定时任务失败", e);
|
|
- }
|
|
|
|
- finally {
|
|
|
|
|
|
+ } finally {
|
|
|
|
+ if (!tempStationList.isEmpty()) {
|
|
|
|
+ // 插入下发调控表
|
|
|
|
+ List<ForecastPowerShortTermSend> forecastPowerShortTermSendList = new ArrayList<>();
|
|
|
|
+ // 将调控后的数据拷贝到下发集合中
|
|
|
|
+ for (ForecastPowerShortTermStation forecastPowerShortTermStation : tempStationList) {
|
|
|
|
+ ForecastPowerShortTermSend newSend = new ForecastPowerShortTermSend();
|
|
|
|
+ newSend.setStationCode(forecastPowerShortTermStation.getStationCode());
|
|
|
|
+ newSend.setFpValue(forecastPowerShortTermStation.getFpValue());
|
|
|
|
+ newSend.setTime(forecastPowerShortTermStation.getTime());
|
|
|
|
+ newSend.setForecastHowLongAgo(forecastPowerShortTermStation.getForecastHowLongAgo());
|
|
|
|
+ newSend.setCapacity(forecastPowerShortTermStation.getCapacity());
|
|
|
|
+ newSend.setOpenCapacity(forecastPowerShortTermStation.getOpenCapacity());
|
|
|
|
+ forecastPowerShortTermSendList.add(newSend);
|
|
|
|
+ }
|
|
|
|
+ forecastPowerShortTermSendService.saveBatch(forecastPowerShortTermSendList);
|
|
|
|
+ }
|
|
// 更新调控主表下发状态
|
|
// 更新调控主表下发状态
|
|
UpdateWrapper<TempShortRegulation> regulationUpdateWrapper = new UpdateWrapper<>();
|
|
UpdateWrapper<TempShortRegulation> regulationUpdateWrapper = new UpdateWrapper<>();
|
|
- regulationUpdateWrapper.eq("station_code",stationCode).eq("tk_date",tkDate).set("regulation_status_enum",isSend);
|
|
|
|
|
|
+ regulationUpdateWrapper.eq("station_code", stationCode).eq("tk_date", tkDate).set("regulation_status_enum", isSend);
|
|
tempShortRegulationService.update(regulationUpdateWrapper);
|
|
tempShortRegulationService.update(regulationUpdateWrapper);
|
|
// 删除本地文件
|
|
// 删除本地文件
|
|
if (!StrUtil.isBlankIfStr(vmFileName)) {
|
|
if (!StrUtil.isBlankIfStr(vmFileName)) {
|