|
|
@@ -9,7 +9,7 @@ import com.shkpr.service.aimodelpower.commtools.ModelPredictorUtil;
|
|
|
import com.shkpr.service.aimodelpower.constants.LogFlagBusiType;
|
|
|
import com.shkpr.service.aimodelpower.constants.ModelPredictorTaskStatus;
|
|
|
import com.shkpr.service.aimodelpower.dbdao.services.intef.OrgConfigService;
|
|
|
-import com.shkpr.service.aimodelpower.dbdao.services.intef.WaterVolumePredictHourService;
|
|
|
+import com.shkpr.service.aimodelpower.dbdao.services.intef.WaterVolumePredictService;
|
|
|
import com.shkpr.service.aimodelpower.dto.ModelPredictorResult;
|
|
|
import com.shkpr.service.aimodelpower.dto.ModelPredictorTask;
|
|
|
import com.shkpr.service.aimodelpower.dto.OrgConfig;
|
|
|
@@ -24,6 +24,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -73,29 +74,31 @@ public class ModelPredictor {
|
|
|
final
|
|
|
OrgConfigService orgConfigService;
|
|
|
final
|
|
|
- WaterVolumePredictHourService waterVolumePredictHourService;
|
|
|
+ WaterVolumePredictService waterVolumePredictService;
|
|
|
final
|
|
|
AsyncRequestUtil asyncRequestUtil;
|
|
|
|
|
|
public ModelPredictor(@Qualifier("taskExecutor") ThreadPoolTaskExecutor taskScheduler, ObjectMapper objectMapper
|
|
|
, PredictProperties predictProperties, OrgConfigService orgConfigService
|
|
|
- , WaterVolumePredictHourService waterVolumePredictHourService, AsyncRequestUtil asyncRequestUtil) {
|
|
|
+ , WaterVolumePredictService waterVolumePredictService, AsyncRequestUtil asyncRequestUtil) {
|
|
|
this.taskScheduler = taskScheduler;
|
|
|
this.objectMapper = objectMapper;
|
|
|
this.predictProperties = predictProperties;
|
|
|
this.orgConfigService = orgConfigService;
|
|
|
- this.waterVolumePredictHourService = waterVolumePredictHourService;
|
|
|
+ this.waterVolumePredictService = waterVolumePredictService;
|
|
|
this.asyncRequestUtil = asyncRequestUtil;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 预测日水量
|
|
|
*
|
|
|
- * @param nextDays 往后预测天数
|
|
|
+ * @param previousDays 往前回溯天数
|
|
|
+ * @param nextDays 往后预测天数
|
|
|
+ * @param orgName 组织名称
|
|
|
*/
|
|
|
- public void predictDayWater(int nextDays) {
|
|
|
+ public void predictDayWater(int previousDays, int nextDays, String orgName) {
|
|
|
//计算开始和结束日期
|
|
|
- LocalDate startTime = LocalDate.now();
|
|
|
+ LocalDate startTime = LocalDate.now().minusDays(previousDays);
|
|
|
LocalDate endTime = LocalDate.now().plusDays(nextDays);
|
|
|
|
|
|
//关闭的组织名称
|
|
|
@@ -108,6 +111,8 @@ public class ModelPredictor {
|
|
|
|
|
|
//遍历组织配置
|
|
|
orgConfigs.forEach(orgConfig -> {
|
|
|
+ if (orgName != null && !Objects.equals(orgConfig.getOrgName(), orgName)) return;
|
|
|
+
|
|
|
long begin = System.currentTimeMillis();
|
|
|
|
|
|
//请求参数
|
|
|
@@ -149,11 +154,13 @@ public class ModelPredictor {
|
|
|
/**
|
|
|
* 预测小时水量
|
|
|
*
|
|
|
- * @param nextDays 往后预测天数
|
|
|
+ * @param previousDays 往前回溯天数
|
|
|
+ * @param nextDays 往后预测天数
|
|
|
+ * @param orgName 组织名称
|
|
|
*/
|
|
|
- public void predictHourWater(int nextDays) {
|
|
|
+ public void predictHourWater(int previousDays, int nextDays, String orgName) {
|
|
|
//计算开始日期
|
|
|
- LocalDate startTime = LocalDate.now();
|
|
|
+ LocalDate startTime = LocalDate.now().minusDays(previousDays);
|
|
|
|
|
|
//关闭的组织名称
|
|
|
List<String> closeOrgNames = predictProperties.getCloseOrgNames();
|
|
|
@@ -165,6 +172,8 @@ public class ModelPredictor {
|
|
|
|
|
|
//遍历组织配置
|
|
|
for (OrgConfig orgConfig : orgConfigs) {
|
|
|
+ if (orgName != null && !Objects.equals(orgConfig.getOrgName(), orgName)) continue;
|
|
|
+
|
|
|
//遍历预测天数
|
|
|
for (int i = 0; i <= nextDays; i++) {
|
|
|
long begin = System.currentTimeMillis();
|
|
|
@@ -212,11 +221,13 @@ public class ModelPredictor {
|
|
|
/**
|
|
|
* 预测分钟水量
|
|
|
*
|
|
|
- * @param nextDays 往后预测天数
|
|
|
+ * @param previousDays 往前回溯天数
|
|
|
+ * @param nextDays 往后预测天数
|
|
|
+ * @param orgName 组织名称
|
|
|
*/
|
|
|
- public void predictMinuteWater(int nextDays) {
|
|
|
+ public void predictMinuteWater(int previousDays, int nextDays, String orgName) {
|
|
|
//计算开始和结束日期
|
|
|
- LocalDate startTime = LocalDate.now();
|
|
|
+ LocalDate startTime = LocalDate.now().minusDays(previousDays);
|
|
|
LocalDate endTime = LocalDate.now().plusDays(nextDays);
|
|
|
|
|
|
//关闭的组织名称
|
|
|
@@ -229,18 +240,20 @@ public class ModelPredictor {
|
|
|
|
|
|
//遍历组织配置
|
|
|
for (OrgConfig orgConfig : orgConfigs) {
|
|
|
+ if (orgName != null && !Objects.equals(orgConfig.getOrgName(), orgName)) continue;
|
|
|
+
|
|
|
LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
|
|
|
, String.format("开始执行预测分钟水量 组织名称:%s,开始日期:%s,结束日期:%s",
|
|
|
orgConfig.getOrgName(), startTime, endTime));
|
|
|
long begin = System.currentTimeMillis();
|
|
|
|
|
|
//读取小时预测数据
|
|
|
- List<WaterVolumePredictHour> hours = waterVolumePredictHourService.findHour(startTime, endTime, orgConfig.getOrgId());
|
|
|
+ List<WaterVolumePredictHour> hours = waterVolumePredictService.findHour(startTime, endTime, orgConfig.getOrgId());
|
|
|
//计算分钟预测数据
|
|
|
List<WaterVolumePredictHour> minutes = ModelPredictorUtil.calcMinuteWater(hours);
|
|
|
|
|
|
//执行批量合并
|
|
|
- Boolean upserted = waterVolumePredictHourService.upsertAllMinute(minutes);
|
|
|
+ Boolean upserted = waterVolumePredictService.upsertAllMinute(minutes);
|
|
|
|
|
|
long end = System.currentTimeMillis();
|
|
|
LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
|
|
|
@@ -437,7 +450,7 @@ public class ModelPredictor {
|
|
|
long begin = System.currentTimeMillis();
|
|
|
|
|
|
//执行同步
|
|
|
- Boolean synced = waterVolumePredictHourService.syncStatusAndEnergy(startTime, endTime);
|
|
|
+ Boolean synced = waterVolumePredictService.syncStatusAndEnergy(startTime, endTime);
|
|
|
|
|
|
long end = System.currentTimeMillis();
|
|
|
LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
|