From b7245f9d1308595e1405d11ffb524d96a2c8a7a8 Mon Sep 17 00:00:00 2001 From: liriming <1343021927@qq.com> Date: 星期三, 08 一月 2025 18:25:29 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleGasTask.java | 105 +++++ shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleOnaOptTask.java | 144 ++++++++ shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelAlarmConsumer.java | 7 shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirTask.java | 70 +++ shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirIndexMonthTask.java | 87 ++++ pom.xml | 2 shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirRatioTask.java | 72 ++++ shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirIndexWeekTask.java | 71 +++ /dev/null | 20 - shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinish2Consumer.java | 8 shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunPredictModuleTask.java | 36 + shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleSteamTask.java | 130 +++++++ shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinishConsumer.java | 6 shasteel-biz/src/main/resources/application.yaml | 28 shasteel-biz/src/main/resources/application-prod.yaml | 50 +- shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirDispatchTask.java | 133 +++++++ shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirIndexClassTask.java | 73 ++++ 17 files changed, 956 insertions(+), 86 deletions(-) diff --git a/pom.xml b/pom.xml index 600c853..e1794de 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ <properties> - <revision>0.0.1</revision> + <revision>1.0.0</revision> <!-- Maven 相关 --> <java.version>1.8</java.version> <maven.compiler.source>${java.version}</maven.compiler.source> diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunPredictModuleTask.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunPredictModuleTask.java index 507a523..9365cfc 100644 --- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunPredictModuleTask.java +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunPredictModuleTask.java @@ -1,19 +1,26 @@ package com.iailab.module.shasteel.job.task; +import com.iailab.framework.common.util.date.DateUtils; import com.iailab.module.model.api.mdk.MdkApi; -import com.iailab.module.model.api.mdk.dto.MdkPredictModuleRespDTO; import com.iailab.module.model.api.mdk.dto.MdkPredictReqDTO; import com.iailab.module.shasteel.mq.common.constant.RoutingConstant; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.Calendar; +import java.util.*; /** * 执行模块预测定时任务 + * 1、高炉 + * 2、焦炉 + * 3、转炉 + * 3.1、氧气 + * 3.2、蒸汽 + * 4、氮气 */ @Component("runPredictModuleTask") public class RunPredictModuleTask implements ITask { @@ -32,14 +39,23 @@ Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); - - MdkPredictReqDTO dto = new MdkPredictReqDTO(); - dto.setPredictTime(calendar.getTime()); - dto.setModuleType(params); - MdkPredictModuleRespDTO mdkPredictModuleRespDTO = mdkApi.predictModule(dto); - logger.info(params + "模块预测完成," + mdkPredictModuleRespDTO); - rabbitTemplate.convertAndSend(RoutingConstant.EXCHANGE, RoutingConstant.Iailab_Model_PredictFinish, mdkPredictModuleRespDTO); - + Date predictTime = calendar.getTime(); + if (StringUtils.isEmpty(params)) { + logger.info("参数为空"); + return; + } + List<String> moduleTypeList = Arrays.asList(params.split(",")); + moduleTypeList.forEach(type -> { + MdkPredictReqDTO dto = new MdkPredictReqDTO(); + dto.setPredictTime(predictTime); + dto.setModuleType(type); + mdkApi.predictModule(dto); + logger.info(type + "模块预测完成。"); + Map<String, Object> msg = new HashMap<>(); + msg.put("moduleType", type); + msg.put("predictTime", DateUtils.format(predictTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); + rabbitTemplate.convertAndSend(RoutingConstant.EXCHANGE, RoutingConstant.Iailab_Model_PredictFinish, msg); + }); } catch (Exception ex) { logger.error("runPredictModuleTask运行异常"); ex.printStackTrace(); diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirDispatchTask.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirDispatchTask.java new file mode 100644 index 0000000..74a9c66 --- /dev/null +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirDispatchTask.java @@ -0,0 +1,133 @@ +package com.iailab.module.shasteel.job.task; + +import com.iailab.module.model.api.mcs.McsApi; +import com.iailab.module.model.api.mcs.dto.AlarmMessageRespDTO; +import com.iailab.module.model.api.mcs.dto.ScheduleSuggestRespDTO; +import com.iailab.module.model.api.mcs.dto.StScheduleSchemeDTO; +import com.iailab.module.model.api.mdk.MdkApi; +import com.iailab.module.model.api.mdk.dto.MdkScheduleReqDTO; +import com.iailab.module.model.api.mdk.dto.MdkScheduleRespDTO; +import com.iailab.module.model.enums.CommonConstant; +import com.iailab.module.model.enums.ScheduleTriggerMethodEnum; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 压缩空气优化调度 + * 定时触发 30 0/2 * * * ? + * 压力低于下限预警信息 pressureLWarning + * 压力高于上限预警信息 pressureHWarning + * 空压机启动调度建议 dispatchStart + * 空压机关停调度建议 dispatchClose + * + * @author PanZhibao + * @Description + * @createTime 2025年01月07日 + */ +@Component("runScheduleAirDispatchTask") +public class RunScheduleAirDispatchTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Autowired + private McsApi mcsApi; + + @Autowired + private MdkApi mdkApi; + + @Override + public void run(String params) { + logger.info("RunScheduleAirDispatchTask,参数为:{}", params); + try { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + Date scheduleTime = calendar.getTime(); + if (StringUtils.isEmpty(params)) { + logger.info("参数为空"); + return; + } + + // 根据条件查找方案 + List<StScheduleSchemeDTO> schemeList = mcsApi.listScheduleScheme(ScheduleTriggerMethodEnum.JOB.getCode(), params); + if (CollectionUtils.isEmpty(schemeList)) { + logger.info("方案为空"); + return; + } + + StScheduleSchemeDTO scheme = schemeList.get(0); + MdkScheduleReqDTO dto = new MdkScheduleReqDTO(); + dto.setScheduleTime(scheduleTime); + dto.setScheduleCode(scheme.getCode()); + MdkScheduleRespDTO mdkScheduleRespDTO = mdkApi.doSchedule(dto); + if (!CommonConstant.MDK_STATUS_100.equals(mdkScheduleRespDTO.getStatusCode())) { + logger.info("调度结果异常,STATUS=" + mdkScheduleRespDTO.getStatusCode()); + return; + } + + // 保存预警信息 + if (mdkScheduleRespDTO.getResult().get("pressureLWarning") != null && + StringUtils.isNotEmpty(mdkScheduleRespDTO.getResult().get("pressureLWarning").toString())) { + String pressureLWarning = mdkScheduleRespDTO.getResult().get("pressureLWarning").toString(); + AlarmMessageRespDTO alarm = new AlarmMessageRespDTO(); + alarm.setTitle("压力低于下限预警"); + alarm.setContent(pressureLWarning); + alarm.setAlarmObj(scheme.getScheduleObj()); + alarm.setAlarmType("低于下限"); + alarm.setAlarmTime(scheduleTime); + mcsApi.createAlarmMessage(alarm); + } + + + if (mdkScheduleRespDTO.getResult().get("pressureHWarning") != null && + StringUtils.isNotEmpty(mdkScheduleRespDTO.getResult().get("pressureHWarning").toString())) { + String pressureHWarning = mdkScheduleRespDTO.getResult().get("pressureHWarning").toString(); + AlarmMessageRespDTO alarm = new AlarmMessageRespDTO(); + alarm.setTitle("压力高于上限预警"); + alarm.setContent(pressureHWarning); + alarm.setAlarmObj(scheme.getScheduleObj()); + alarm.setAlarmType("高于上限"); + alarm.setAlarmTime(scheduleTime); + mcsApi.createAlarmMessage(alarm); + } + + // 保存调度建议 + if (mdkScheduleRespDTO.getResult().get("dispatchStart") != null && + StringUtils.isNotEmpty(mdkScheduleRespDTO.getResult().get("dispatchStart").toString())) { + String dispatchStart = mdkScheduleRespDTO.getResult().get("dispatchStart").toString(); + ScheduleSuggestRespDTO suggest = new ScheduleSuggestRespDTO(); + suggest.setTitle("空压机启动调度建议"); + suggest.setContent(dispatchStart); + suggest.setScheduleObj(scheme.getScheduleObj()); + suggest.setScheduleTime(scheduleTime); + suggest.setSort(0); + mcsApi.createScheduleSuggest(suggest); + } + + if (mdkScheduleRespDTO.getResult().get("dispatchClose") != null && + StringUtils.isNotEmpty(mdkScheduleRespDTO.getResult().get("dispatchClose").toString())) { + String dispatchClose = mdkScheduleRespDTO.getResult().get("dispatchClose").toString(); + ScheduleSuggestRespDTO suggest = new ScheduleSuggestRespDTO(); + suggest.setTitle("空压机关停调度建议"); + suggest.setContent(dispatchClose); + suggest.setScheduleObj(scheme.getScheduleObj()); + suggest.setScheduleTime(scheduleTime); + suggest.setSort(0); + mcsApi.createScheduleSuggest(suggest); + } + + logger.info(params + "调度方案执行完成"); + } catch (Exception ex) { + logger.error("RunScheduleAirDispatchTask运行异常"); + ex.printStackTrace(); + } + logger.info("RunScheduleAirDispatchTask运行完成"); + } +} \ No newline at end of file diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirIndexClassTask.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirIndexClassTask.java new file mode 100644 index 0000000..fd97999 --- /dev/null +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirIndexClassTask.java @@ -0,0 +1,73 @@ +package com.iailab.module.shasteel.job.task; + +import com.iailab.module.model.api.mcs.McsApi; +import com.iailab.module.model.api.mcs.dto.StScheduleSchemeDTO; +import com.iailab.module.model.api.mdk.MdkApi; +import com.iailab.module.model.api.mdk.dto.MdkScheduleReqDTO; +import com.iailab.module.model.api.mdk.dto.MdkScheduleRespDTO; +import com.iailab.module.model.enums.ScheduleTriggerMethodEnum; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 压缩空气运行指标(班) + * 8*60=480 数据 + * 每班更新,20 0 0,8,16 * * ? * + * + * @author PanZhibao + * @Description + * @createTime 2025年01月03日 + */ +@Component("runScheduleAirIndexClassTask") +public class RunScheduleAirIndexClassTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private McsApi mcsApi; + + @Autowired + private MdkApi mdkApi; + + @Override + public void run(String params) { + logger.info("RunScheduleAirIndexClassTask,参数为:{}", params); + try { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + Date scheduleTime = calendar.getTime(); + if (StringUtils.isEmpty(params)) { + logger.info("参数为空"); + return; + } + // 根据条件查找方案 + List<StScheduleSchemeDTO> schemeList = mcsApi.listScheduleScheme(ScheduleTriggerMethodEnum.JOB.getCode(), params); + if (CollectionUtils.isEmpty(schemeList)) { + logger.info("方案为空"); + return; + } + for (StScheduleSchemeDTO scheme : schemeList) { + MdkScheduleReqDTO dto = new MdkScheduleReqDTO(); + dto.setScheduleTime(scheduleTime); + dto.setScheduleCode(scheme.getCode()); + MdkScheduleRespDTO mdkScheduleRespDTO = mdkApi.doSchedule(dto); + // 结果写入测点 + mdkApi.scheduleModelOut(mdkScheduleRespDTO); + } + logger.info(params + "调度方案执行完成"); + } catch (Exception ex) { + logger.error("RunScheduleAirIndexClassTask运行异常"); + ex.printStackTrace(); + } + logger.info("RunScheduleAirIndexClassTask运行完成"); + } +} \ No newline at end of file diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirIndexMonthTask.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirIndexMonthTask.java new file mode 100644 index 0000000..1d66298 --- /dev/null +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirIndexMonthTask.java @@ -0,0 +1,87 @@ +package com.iailab.module.shasteel.job.task; + +import com.iailab.module.model.api.mcs.McsApi; +import com.iailab.module.model.api.mcs.dto.StScheduleSchemeDTO; +import com.iailab.module.model.api.mdk.MdkApi; +import com.iailab.module.model.api.mdk.dto.MdkScheduleReqDTO; +import com.iailab.module.model.api.mdk.dto.MdkScheduleRespDTO; +import com.iailab.module.model.enums.ScheduleTriggerMethodEnum; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.temporal.ChronoUnit; +import java.util.*; + +/** + * 压缩空气运行指标(月) + * 动态数据长度,月初到当天 + * 每天更新,10 0 0 1/1 * ? + * + * @author PanZhibao + * @Description + * @createTime 2024年12月31日 + */ +@Component("runScheduleAirIndexMonthTask") +public class RunScheduleAirIndexMonthTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private McsApi mcsApi; + + @Autowired + private MdkApi mdkApi; + + @Override + public void run(String params) { + logger.info("RunScheduleAirIndexMonthTask,参数为:{}", params); + try { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + Date scheduleTime = calendar.getTime(); + if (StringUtils.isEmpty(params)) { + logger.info("参数为空"); + return; + } + // 根据条件查找方案 + List<StScheduleSchemeDTO> schemeList = mcsApi.listScheduleScheme(ScheduleTriggerMethodEnum.JOB.getCode(), params); + if (CollectionUtils.isEmpty(schemeList)) { + logger.info("方案为空"); + return; + } + + for (StScheduleSchemeDTO scheme : schemeList) { + MdkScheduleReqDTO dto = new MdkScheduleReqDTO(); + dto.setScheduleTime(scheduleTime); + dto.setScheduleCode(scheme.getCode()); + LocalDateTime now = LocalDateTime.now(); + LocalDate startOfMonth = LocalDate.now().withDayOfMonth(1); + LocalDateTime startOfMonthAtMidnight = startOfMonth.atStartOfDay(); + long timeDifference = ChronoUnit.MINUTES.between(startOfMonthAtMidnight, now); + Map<Integer, Integer> dynamicDataLength = new HashMap<>(); + dynamicDataLength.put(1, (int) timeDifference); + dynamicDataLength.put(2, (int) timeDifference); + dynamicDataLength.put(3, (int) timeDifference); + dto.setDynamicDataLength( dynamicDataLength); + Map<String, String> dynamicSettings = new HashMap<>(); + dynamicSettings.put("embedDim", String.valueOf(timeDifference)); + dto.setDynamicSettings(dynamicSettings); + MdkScheduleRespDTO mdkScheduleRespDTO = mdkApi.doSchedule(dto); + // 结果写入测点 + mdkApi.scheduleModelOut(mdkScheduleRespDTO); + } + logger.info(params + "调度方案执行完成"); + } catch (Exception ex) { + logger.error("RunScheduleAirIndexMonthTask运行异常"); + ex.printStackTrace(); + } + logger.info("RunScheduleAirIndexMonthTask运行完成"); + } +} \ No newline at end of file diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirIndexWeekTask.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirIndexWeekTask.java new file mode 100644 index 0000000..4887b8f --- /dev/null +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirIndexWeekTask.java @@ -0,0 +1,71 @@ +package com.iailab.module.shasteel.job.task; + +import com.iailab.module.model.api.mcs.McsApi; +import com.iailab.module.model.api.mcs.dto.StScheduleSchemeDTO; +import com.iailab.module.model.api.mdk.MdkApi; +import com.iailab.module.model.api.mdk.dto.MdkScheduleReqDTO; +import com.iailab.module.model.api.mdk.dto.MdkScheduleRespDTO; +import com.iailab.module.model.enums.ScheduleTriggerMethodEnum; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.*; + +/** + * 压缩空气运行指标(周) + * 最近7天的数据 + * 每天更新,20 0 0 1/1 * ? + * + * @author PanZhibao + * @Description + * @createTime 2025年01月03日 + */ +@Component("runScheduleAirIndexWeekTask") +public class RunScheduleAirIndexWeekTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Resource + private McsApi mcsApi; + + @Autowired + private MdkApi mdkApi; + + @Override + public void run(String params) { + logger.info("RunScheduleAirIndexWeekTask,参数为:{}", params); + try { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + Date scheduleTime = calendar.getTime(); + if (StringUtils.isEmpty(params)) { + logger.info("参数为空"); + return; + } + // 根据条件查找方案 + List<StScheduleSchemeDTO> schemeList = mcsApi.listScheduleScheme(ScheduleTriggerMethodEnum.JOB.getCode(), params); + if (CollectionUtils.isEmpty(schemeList)) { + logger.info("方案为空"); + return; + } + for (StScheduleSchemeDTO scheme : schemeList) { + MdkScheduleReqDTO dto = new MdkScheduleReqDTO(); + dto.setScheduleTime(scheduleTime); + dto.setScheduleCode(scheme.getCode()); + MdkScheduleRespDTO mdkScheduleRespDTO = mdkApi.doSchedule(dto); + // 结果写入测点 + mdkApi.scheduleModelOut(mdkScheduleRespDTO); + } + logger.info(params + "调度方案执行完成"); + } catch (Exception ex) { + logger.error("RunScheduleAirIndexWeekTask运行异常"); + ex.printStackTrace(); + } + logger.info("RunScheduleAirIndexWeekTask运行完成"); + } +} \ No newline at end of file diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirRatioTask.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirRatioTask.java new file mode 100644 index 0000000..c377516 --- /dev/null +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirRatioTask.java @@ -0,0 +1,72 @@ +package com.iailab.module.shasteel.job.task; + +import com.iailab.module.model.api.mcs.McsApi; +import com.iailab.module.model.api.mcs.dto.StScheduleSchemeDTO; +import com.iailab.module.model.api.mdk.MdkApi; +import com.iailab.module.model.api.mdk.dto.MdkScheduleReqDTO; +import com.iailab.module.model.api.mdk.dto.MdkScheduleRespDTO; +import com.iailab.module.model.enums.ScheduleTriggerMethodEnum; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 压缩空气产消比例 + * 定时触发,30 0/1 * * * ? + * + * @author PanZhibao + * @Description + * @createTime 2025年01月06日 + */ +@Component("runScheduleAirRatioTask") +public class RunScheduleAirRatioTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Autowired + private McsApi mcsApi; + + @Autowired + private MdkApi mdkApi; + + @Override + public void run(String params) { + logger.info("RunScheduleAirRatioTask,参数为:{}", params); + try { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + Date scheduleTime = calendar.getTime(); + if (StringUtils.isEmpty(params)) { + logger.info("参数为空"); + return; + } + + // 根据条件查找方案 + List<StScheduleSchemeDTO> schemeList = mcsApi.listScheduleScheme(ScheduleTriggerMethodEnum.JOB.getCode(), params); + if (CollectionUtils.isEmpty(schemeList)) { + logger.info("方案为空"); + return; + } + for (StScheduleSchemeDTO scheme : schemeList) { + MdkScheduleReqDTO dto = new MdkScheduleReqDTO(); + dto.setScheduleTime(scheduleTime); + dto.setScheduleCode(scheme.getCode()); + MdkScheduleRespDTO mdkScheduleRespDTO = mdkApi.doSchedule(dto); + // 结果写入测点 + mdkApi.scheduleModelOut(mdkScheduleRespDTO); + } + logger.info(params + "调度方案执行完成"); + } catch (Exception ex) { + logger.error("RunScheduleAirRatioTask运行异常"); + ex.printStackTrace(); + } + logger.info("RunScheduleAirRatioTask运行完成"); + } +} \ No newline at end of file diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirTask.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirTask.java new file mode 100644 index 0000000..9090253 --- /dev/null +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleAirTask.java @@ -0,0 +1,70 @@ +package com.iailab.module.shasteel.job.task; + +import com.iailab.module.model.api.mcs.McsApi; +import com.iailab.module.model.api.mcs.dto.StScheduleSchemeDTO; +import com.iailab.module.model.api.mdk.MdkApi; +import com.iailab.module.model.api.mdk.dto.MdkScheduleReqDTO; +import com.iailab.module.model.api.mdk.dto.MdkScheduleRespDTO; +import com.iailab.module.model.enums.ScheduleTriggerMethodEnum; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.*; + +/** + * 压空,计算机组比功率,计算结果写入测点 + * 定时触发,5 0/1 * * * ? + * + * @author PanZhibao + * @Description + * @createTime 2024年12月31日 + */ +@Component("runScheduleAirTask") +public class RunScheduleAirTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Autowired + private McsApi mcsApi; + + @Autowired + private MdkApi mdkApi; + + @Override + public void run(String params) { + logger.info("RunScheduleAirTask,参数为:{}", params); + try { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + Date scheduleTime = calendar.getTime(); + if (StringUtils.isEmpty(params)) { + logger.info("参数为空"); + return; + } + + // 根据条件查找方案 + List<StScheduleSchemeDTO> schemeList = mcsApi.listScheduleScheme(ScheduleTriggerMethodEnum.JOB.getCode(), params); + if (CollectionUtils.isEmpty(schemeList)) { + logger.info("方案为空"); + return; + } + for (StScheduleSchemeDTO scheme : schemeList) { + MdkScheduleReqDTO dto = new MdkScheduleReqDTO(); + dto.setScheduleTime(scheduleTime); + dto.setScheduleCode(scheme.getCode()); + MdkScheduleRespDTO mdkScheduleRespDTO = mdkApi.doSchedule(dto); + // 结果写入测点 + mdkApi.scheduleModelOut(mdkScheduleRespDTO); + } + logger.info(params + "调度方案执行完成"); + } catch (Exception ex) { + logger.error("RunScheduleAirTask运行异常"); + ex.printStackTrace(); + } + logger.info("RunScheduleAirTask运行完成"); + } +} \ No newline at end of file diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleGasTask.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleGasTask.java new file mode 100644 index 0000000..02082c4 --- /dev/null +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleGasTask.java @@ -0,0 +1,105 @@ +package com.iailab.module.shasteel.job.task; + +import com.iailab.module.model.api.mcs.McsApi; +import com.iailab.module.model.api.mcs.dto.ScheduleSuggestRespDTO; +import com.iailab.module.model.api.mcs.dto.StScheduleSchemeDTO; +import com.iailab.module.model.api.mdk.MdkApi; +import com.iailab.module.model.api.mdk.dto.MdkScheduleReqDTO; +import com.iailab.module.model.api.mdk.dto.MdkScheduleRespDTO; +import com.iailab.module.model.enums.CommonConstant; +import com.iailab.module.model.enums.ScheduleTriggerMethodEnum; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 煤气调度 + * 高炉煤气调整量 adjustBFG + * 焦炉煤气调整量 adjustCOG + * 转炉煤气调整量 adjustLDG + * 高炉煤气调度建议 adviceBFG + * 焦炉煤气调度建议 adviceCOG + * 转炉煤气调度建议 adviceLDG + * 机组的煤气(折高)流量 gasConsumption + * 机组的负荷率 loadRates + * 机组的气耗 gasVolume + * + * @author PanZhibao + * @Description + * @createTime 2025年01月08日 + */ +@Component("runScheduleGasTask") +public class RunScheduleGasTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Autowired + private McsApi mcsApi; + + @Autowired + private MdkApi mdkApi; + + @Override + public void run(String params) { + logger.info("RunScheduleGasTask,参数为:{}", params); + try { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + Date scheduleTime = calendar.getTime(); + if (StringUtils.isEmpty(params)) { + logger.info("参数为空"); + return; + } + + // 根据条件查找方案 + List<StScheduleSchemeDTO> schemeList = mcsApi.listScheduleScheme(ScheduleTriggerMethodEnum.JOB.getCode(), params); + if (CollectionUtils.isEmpty(schemeList)) { + logger.info("方案为空"); + return; + } + StScheduleSchemeDTO scheme = schemeList.get(0); + MdkScheduleReqDTO dto = new MdkScheduleReqDTO(); + dto.setScheduleTime(scheduleTime); + dto.setScheduleCode(scheme.getCode()); + MdkScheduleRespDTO mdkScheduleRespDTO = mdkApi.doSchedule(dto); + if (!CommonConstant.MDK_STATUS_100.equals(mdkScheduleRespDTO.getStatusCode())) { + logger.info("调度结果异常,STATUS=" + mdkScheduleRespDTO.getStatusCode()); + return; + } + Object adviceBFG = mdkScheduleRespDTO.getResult().get("adviceBFG"); + saveScheduleSuggest("高炉煤气调度建议", adviceBFG, scheme.getScheduleObj(), scheduleTime); + Object adviceCOG = mdkScheduleRespDTO.getResult().get("adviceCOG"); + saveScheduleSuggest("焦炉煤气调度建议", adviceCOG, scheme.getScheduleObj(), scheduleTime); + Object adviceLDG = mdkScheduleRespDTO.getResult().get("adviceLDG"); + saveScheduleSuggest("转炉煤气调度建议", adviceLDG, scheme.getScheduleObj(), scheduleTime); + // 结果写入测点 + mdkApi.scheduleModelOut(mdkScheduleRespDTO); + logger.info(params + "调度方案执行完成"); + } catch (Exception ex) { + logger.error("RunScheduleGasTask运行异常"); + ex.printStackTrace(); + } + logger.info("RunScheduleGasTask运行完成"); + } + + private void saveScheduleSuggest(String title, Object content, String scheduleObj, Date scheduleTime) { + if (content == null || StringUtils.isBlank(content.toString()) || "0".equals(content.toString())) { + logger.info(title + "content为空"); + return; + } + ScheduleSuggestRespDTO suggest = new ScheduleSuggestRespDTO(); + suggest.setTitle(title); + suggest.setContent(content.toString()); + suggest.setScheduleObj(scheduleObj); + suggest.setScheduleTime(scheduleTime); + suggest.setSort(0); + mcsApi.createScheduleSuggest(suggest); + } +} \ No newline at end of file diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleOnaOptTask.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleOnaOptTask.java new file mode 100644 index 0000000..365de8a --- /dev/null +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleOnaOptTask.java @@ -0,0 +1,144 @@ +package com.iailab.module.shasteel.job.task; + +import com.iailab.module.model.api.mcs.McsApi; +import com.iailab.module.model.api.mcs.dto.AlarmMessageRespDTO; +import com.iailab.module.model.api.mcs.dto.ScheduleSuggestRespDTO; +import com.iailab.module.model.api.mcs.dto.StScheduleSchemeDTO; +import com.iailab.module.model.api.mdk.MdkApi; +import com.iailab.module.model.api.mdk.dto.MdkScheduleReqDTO; +import com.iailab.module.model.api.mdk.dto.MdkScheduleRespDTO; +import com.iailab.module.model.enums.CommonConstant; +import com.iailab.module.model.enums.ScheduleTriggerMethodEnum; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.*; + +/** + * 06 + * 氧气班平衡计划 + * 法夜空建议送出量 faAdvice + * 盈德低压建议送出量 yingDiAdvice + * 盈德中压建议送出量 yingZhongAdvice + * 宏昌建议送出量 hongAdvice + * 润忠建议送出量 RunAdvice + * 调整值 adviceValues + * + * 05 + * 氧气系统优化调度决策 + * 盈德中压建议调整量 yingdiAdvice + * 法夜空建议调整量 faAdvice + * 宏昌建议调整量 hongAdvice + * 润忠建议调整量 RunAdvice + * + * 01 + * 氮气预警模型 + * 预警信号 advice + * + * @author PanZhibao + * @Description + * @createTime 2025年01月07日 + */ +@Component("runScheduleOnaOptTask") +public class RunScheduleOnaOptTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Autowired + private McsApi mcsApi; + + @Autowired + private MdkApi mdkApi; + + private Map<String, StScheduleSchemeDTO> schemeMap = new HashMap<>(); + + private static final String CODE06 = "06"; + + private static final String CODE05 = "05"; + + private static final String CODE01 = "01"; + + @Override + public void run(String params) { + logger.info("RunScheduleOnaOptTask,参数为:{}", params); + try { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + Date scheduleTime = calendar.getTime(); + if (StringUtils.isEmpty(params)) { + logger.info("参数为空"); + return; + } + + // 根据条件查找方案 + List<StScheduleSchemeDTO> schemeList = mcsApi.listScheduleScheme(ScheduleTriggerMethodEnum.JOB.getCode(), params); + if (CollectionUtils.isEmpty(schemeList)) { + logger.info("方案为空"); + return; + } + schemeMap.clear(); + Map<String, MdkScheduleRespDTO> resultMap = new HashMap<String, MdkScheduleRespDTO>(); + schemeList.forEach(item -> { + schemeMap.put(item.getCode(), item); + StScheduleSchemeDTO scheme = schemeList.get(0); + MdkScheduleReqDTO dto = new MdkScheduleReqDTO(); + dto.setScheduleTime(scheduleTime); + dto.setScheduleCode(scheme.getCode()); + MdkScheduleRespDTO mdkScheduleRespDTO = mdkApi.doSchedule(dto); + resultMap.put(item.getCode(), mdkScheduleRespDTO); + }); + if (CollectionUtils.isEmpty(resultMap)) { + logger.info("resultMap为空"); + return; + } + for (Map.Entry<String, MdkScheduleRespDTO> entry : resultMap.entrySet()) { + if (!CommonConstant.MDK_STATUS_100.equals(entry.getValue().getStatusCode())) { + logger.info("调度结果异常,STATUS=" + entry.getValue().getStatusCode()); + continue; + } + + if (entry.getKey().equals(CODE06)) { + // 氧气班平衡计划,建议值写入测点 + mdkApi.scheduleModelOut(entry.getValue()); + } else if (entry.getKey().equals(CODE05)) { + String scheduleObj = schemeMap.get(CODE05).getScheduleObj(); + // double[] adviceValues = (double[]) entry.getValue().getResult().get("adviceValues"); + String yingdiAdvice = entry.getValue().getResult().get("yingdiAdvice").toString(); + saveScheduleSuggest("盈德中压建议调整量", yingdiAdvice, scheduleObj, scheduleTime); + String faAdvice = entry.getValue().getResult().get("faAdvice").toString(); + saveScheduleSuggest("法夜空建议调整量", faAdvice, scheduleObj, scheduleTime); + String hongAdvice = entry.getValue().getResult().get("hongAdvice").toString(); + saveScheduleSuggest("宏昌建议调整量", hongAdvice, scheduleObj, scheduleTime); + String runAdvice = entry.getValue().getResult().get("RunAdvice").toString(); + saveScheduleSuggest("宏昌建议调整量", runAdvice, scheduleObj, scheduleTime); + } else if (entry.getKey().equals(CODE01)) { + String scheduleObj = schemeMap.get(CODE01).getScheduleObj(); + String advice = entry.getValue().getResult().get("advice").toString(); + saveScheduleSuggest("氮气预警", advice, scheduleObj, scheduleTime); + } + } + logger.info(params + "调度方案执行完成"); + } catch (Exception ex) { + logger.error("RunScheduleOnaOptTask运行异常"); + ex.printStackTrace(); + } + logger.info("RunScheduleOnaOptTask运行完成"); + } + + private void saveScheduleSuggest(String title, String content, String scheduleObj, Date scheduleTime) { + if (StringUtils.isBlank(content)) { + return; + } + ScheduleSuggestRespDTO suggest = new ScheduleSuggestRespDTO(); + suggest.setTitle(title); + suggest.setContent(content); + suggest.setScheduleObj(scheduleObj); + suggest.setScheduleTime(scheduleTime); + suggest.setSort(0); + mcsApi.createScheduleSuggest(suggest); + } +} \ No newline at end of file diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleSteamTask.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleSteamTask.java new file mode 100644 index 0000000..aca64a9 --- /dev/null +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunScheduleSteamTask.java @@ -0,0 +1,130 @@ +package com.iailab.module.shasteel.job.task; + +import com.iailab.module.model.api.mcs.McsApi; +import com.iailab.module.model.api.mcs.dto.AlarmMessageRespDTO; +import com.iailab.module.model.api.mcs.dto.ScheduleSuggestRespDTO; +import com.iailab.module.model.api.mcs.dto.StScheduleSchemeDTO; +import com.iailab.module.model.api.mdk.MdkApi; +import com.iailab.module.model.api.mdk.dto.MdkScheduleReqDTO; +import com.iailab.module.model.api.mdk.dto.MdkScheduleRespDTO; +import com.iailab.module.model.enums.CommonConstant; +import com.iailab.module.model.enums.ScheduleTriggerMethodEnum; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 蒸汽调度 + * + * 参考点压力信号 pressure_flag + * 锦丰调度建议 jinfengAdvice + * 大新调度建议 daxinAdvice + * 大新预警 daxinWarning + * 锦丰预警 jinfengWarning + * 转炉一预警 zhuanlu1Warning + * 转炉二预警 zhuanlu2Warning + * + * @author PanZhibao + * @Description + * @createTime 2025年01月08日 + */ +@Component("runScheduleSteamTask") +public class RunScheduleSteamTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Autowired + private McsApi mcsApi; + + @Autowired + private MdkApi mdkApi; + + @Override + public void run(String params) { + logger.info("RunScheduleSteamTask,参数为:{}", params); + try { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + Date scheduleTime = calendar.getTime(); + if (StringUtils.isEmpty(params)) { + logger.info("参数为空"); + return; + } + + // 根据条件查找方案 + List<StScheduleSchemeDTO> schemeList = mcsApi.listScheduleScheme(ScheduleTriggerMethodEnum.JOB.getCode(), params); + if (CollectionUtils.isEmpty(schemeList)) { + logger.info("方案为空"); + return; + } + StScheduleSchemeDTO scheme = schemeList.get(0); + MdkScheduleReqDTO dto = new MdkScheduleReqDTO(); + dto.setScheduleTime(scheduleTime); + dto.setScheduleCode(scheme.getCode()); + MdkScheduleRespDTO mdkScheduleRespDTO = mdkApi.doSchedule(dto); + if (!CommonConstant.MDK_STATUS_100.equals(mdkScheduleRespDTO.getStatusCode())) { + logger.info("调度结果异常,STATUS=" + mdkScheduleRespDTO.getStatusCode()); + return; + } + + Object jinfengAdvice = mdkScheduleRespDTO.getResult().get("jinfengAdvice"); + saveScheduleSuggest("锦丰调度建议", jinfengAdvice, scheme.getScheduleObj(), scheduleTime); + + Object daxinAdvice = mdkScheduleRespDTO.getResult().get("daxinAdvice"); + saveScheduleSuggest("大新调度建议", daxinAdvice, scheme.getScheduleObj(), scheduleTime); + + Object daxinWarning = mdkScheduleRespDTO.getResult().get("daxinWarning"); + saveAlarmMessage("大新预警", daxinWarning, scheme.getScheduleObj(), scheduleTime); + + Object jinfengWarning = mdkScheduleRespDTO.getResult().get("jinfengWarning"); + saveAlarmMessage("锦丰预警", jinfengWarning, scheme.getScheduleObj(), scheduleTime); + + Object zhuanlu1Warning = mdkScheduleRespDTO.getResult().get("zhuanlu1Warning"); + saveAlarmMessage("转炉一预警", zhuanlu1Warning, scheme.getScheduleObj(), scheduleTime); + + Object zhuanlu2Warning = mdkScheduleRespDTO.getResult().get("zhuanlu2Warning"); + saveAlarmMessage("转炉二预警", zhuanlu2Warning, scheme.getScheduleObj(), scheduleTime); + + logger.info(params + "调度方案执行完成"); + } catch (Exception ex) { + logger.error("RunScheduleSteamTask运行异常"); + ex.printStackTrace(); + } + logger.info("RunScheduleSteamTask运行完成"); + } + + private void saveScheduleSuggest(String title, Object content, String scheduleObj, Date scheduleTime) { + if (content == null || StringUtils.isBlank(content.toString()) || "0".equals(content.toString())) { + logger.info(title + "content为空"); + return; + } + ScheduleSuggestRespDTO suggest = new ScheduleSuggestRespDTO(); + suggest.setTitle(title); + suggest.setContent(content.toString()); + suggest.setScheduleObj(scheduleObj); + suggest.setScheduleTime(scheduleTime); + suggest.setSort(0); + mcsApi.createScheduleSuggest(suggest); + } + + private void saveAlarmMessage(String title, Object content, String alarmObj, Date scheduleTime) { + if (content == null || StringUtils.isBlank(content.toString()) || "0".equals(content.toString())) { + logger.info(title + "content为空"); + return; + } + AlarmMessageRespDTO alarm = new AlarmMessageRespDTO(); + alarm.setTitle(title); + alarm.setContent(content.toString()); + alarm.setAlarmObj(alarmObj); + alarm.setAlarmType(""); + alarm.setAlarmTime(scheduleTime); + mcsApi.createAlarmMessage(alarm); + } +} \ No newline at end of file diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/common/enums/TriggerConditionEnum.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/common/enums/TriggerConditionEnum.java deleted file mode 100644 index 7057ea8..0000000 --- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/common/enums/TriggerConditionEnum.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.iailab.module.shasteel.mq.common.enums; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * @author lirm - * @Description - * @createTime 2024年12月19日 - */ -@Getter -@AllArgsConstructor -public enum TriggerConditionEnum { - - EVENT("1"), - - REGULAR("2"); - - private String code; -} diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelAlarmConsumer.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelAlarmConsumer.java index 6e0cdce..846333f 100644 --- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelAlarmConsumer.java +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelAlarmConsumer.java @@ -9,8 +9,8 @@ import com.iailab.module.model.api.mdk.MdkApi; import com.iailab.module.model.api.mdk.dto.MdkScheduleReqDTO; import com.iailab.module.model.api.mdk.dto.MdkScheduleRespDTO; +import com.iailab.module.model.enums.ScheduleTriggerMethodEnum; import com.iailab.module.shasteel.mq.common.constant.CommonConstant; -import com.iailab.module.shasteel.mq.common.enums.TriggerConditionEnum; import com.iailab.module.shasteel.mq.config.QueueModelAlarmConfig; import lombok.extern.slf4j.Slf4j; import org.springframework.amqp.core.Message; @@ -62,10 +62,7 @@ return; } // 查找需要执行的调度方案 - Map<String, Object> params = new HashMap<>(); - params.put("trigger_method", TriggerConditionEnum.EVENT); - params.put("trigger_condition", routingKey); - List<StScheduleSchemeDTO> scheduleSchemeList = mcsApi.listScheduleScheme(params);//根据触发条件获取调度方案列表 + List<StScheduleSchemeDTO> scheduleSchemeList = mcsApi.listScheduleScheme(ScheduleTriggerMethodEnum.EVENT.getCode(), routingKey); for(StScheduleSchemeDTO stScheduleSchemeDTO : scheduleSchemeList){ MdkScheduleReqDTO mdkScheduleReqDTO = new MdkScheduleReqDTO(); mdkScheduleReqDTO.setScheduleCode(stScheduleSchemeDTO.getCode()); diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinish2Consumer.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinish2Consumer.java index 60df985..8b11383 100644 --- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinish2Consumer.java +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinish2Consumer.java @@ -10,9 +10,8 @@ import com.iailab.module.model.api.mdk.MdkApi; import com.iailab.module.model.api.mdk.dto.MdkScheduleReqDTO; import com.iailab.module.model.api.mdk.dto.MdkScheduleRespDTO; +import com.iailab.module.model.enums.ScheduleTriggerMethodEnum; import com.iailab.module.shasteel.mq.common.constant.CommonConstant; -import com.iailab.module.shasteel.mq.common.enums.TriggerConditionEnum; -import com.iailab.module.shasteel.mq.config.QueueModelAlarmConfig; import com.iailab.module.shasteel.mq.config.QueuePredictFinishConfig; import lombok.extern.slf4j.Slf4j; import org.springframework.amqp.core.Message; @@ -59,10 +58,7 @@ return; } // 查找需要执行的调度方案 - Map<String, Object> params = new HashMap<>(); - params.put("trigger_method", TriggerConditionEnum.EVENT); - params.put("trigger_condition", routingKey); - List<StScheduleSchemeDTO> scheduleSchemeList = mcsApi.listScheduleScheme(params);//根据触发条件获取调度方案列表 + List<StScheduleSchemeDTO> scheduleSchemeList = mcsApi.listScheduleScheme(ScheduleTriggerMethodEnum.EVENT.getCode(), routingKey); for(StScheduleSchemeDTO stScheduleSchemeDTO : scheduleSchemeList){ MdkScheduleReqDTO mdkScheduleReqDTO = new MdkScheduleReqDTO(); mdkScheduleReqDTO.setScheduleCode(stScheduleSchemeDTO.getCode()); diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinishConsumer.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinishConsumer.java index a989569..802d502 100644 --- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinishConsumer.java +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinishConsumer.java @@ -60,14 +60,14 @@ if (CollectionUtils.isEmpty(configList)) { return; } - List<String> OutputIdList = new ArrayList<>(); + List<String> outputIdList = new ArrayList<>(); configList.forEach(item -> { - OutputIdList.add(item.getOutId()); + outputIdList.add(item.getOutId()); }); configList.forEach(item -> { PreDataJsonReqVO reqVO = new PreDataJsonReqVO(); reqVO.setPredictTime(DateUtils.parse(messageJson.get("predictTime").toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); - reqVO.setOutputIdList(OutputIdList); + reqVO.setOutputIdList(outputIdList); Map<String, List<Object[]>> preData = mcsApi.getPreDataCur(reqVO); if (CollectionUtils.isEmpty(preData)) { return; diff --git a/shasteel-biz/src/main/resources/application-prod.yaml b/shasteel-biz/src/main/resources/application-prod.yaml index 3e0a3d3..61e48d0 100644 --- a/shasteel-biz/src/main/resources/application-prod.yaml +++ b/shasteel-biz/src/main/resources/application-prod.yaml @@ -1,34 +1,34 @@ --- #################### 数据库相关配置 #################### spring: datasource: - druid: # Druid 【监控】相关的全局配置 + druid: web-stat-filter: enabled: true stat-view-servlet: enabled: true - allow: # 设置白名单,不填则允许所有访问 + allow: url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 + login-username: login-password: filter: stat: enabled: true - log-slow-sql: true # 慢 SQL 记录 + log-slow-sql: true slow-sql-millis: 100 merge-sql: true wall: config: multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 1 # 初始连接数 - min-idle: 1 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 + dynamic: + druid: + initial-size: 1 + min-idle: 1 + max-active: 20 + max-wait: 600000 + time-between-eviction-runs-millis: 60000 + min-evictable-idle-time-millis: 300000 + max-evictable-idle-time-millis: 900000 + validation-query: SELECT 1 FROM DUAL test-while-idle: true test-on-borrow: false test-on-return: false @@ -39,32 +39,30 @@ username: root password: Iailab@2019 - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 redis: - host: 127.0.0.1 # 地址 - port: 6379 # 端口 - database: 8 # 数据库索引 - password: 123456 # 密码,建议生产环境开启 + host: 127.0.0.1 + port: 6379 + database: 8 + password: 123456 --- #################### 平台相关配置 #################### -# 平台配置项,设置当前项目所有自定义的配置 iailab: - env: # 多环境的配置项 + env: tag: ${HOSTNAME} captcha: - enable: false # 本地环境,暂时关闭图片验证码,方便登录等接口的测试 + enable: false security: mock-enable: true - access-log: # 访问日志的配置项 + access-log: enable: false - sms-code: # 短信验证码相关的配置项 + sms-code: expire-times: 10m send-frequency: 1m send-maximum-quantity-per-day: 10 - begin-code: 9999 # 这里配置 9999 的原因是,测试方便。 - end-code: 9999 # 这里配置 9999 的原因是,测试方便。 + begin-code: 9999 + end-code: 9999 token: base-url: http://127.0.0.1:48080/admin-api/system tenant-id: 172 diff --git a/shasteel-biz/src/main/resources/application.yaml b/shasteel-biz/src/main/resources/application.yaml index 392f692..a58b237 100644 --- a/shasteel-biz/src/main/resources/application.yaml +++ b/shasteel-biz/src/main/resources/application.yaml @@ -8,36 +8,34 @@ cloud: nacos: - server-addr: localhost:8848 # Nacos 服务器地址 + server-addr: localhost:8848 username: nacos password: nacos - discovery: # 【配置中心】配置项 + discovery: namespace: ${spring.profiles.active} - group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP + group: DEFAULT_GROUP metadata: - version: 1.0.0 # 服务实例的版本号,可用于灰度发布 - config: # 【注册中心】配置项 + version: 1.0.0 + config: namespace: ${spring.profiles.active} - group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP + group: DEFAULT_GROUP main: - allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 - allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 + allow-circular-references: true + allow-bean-definition-overriding: true config: import: - - optional:classpath:application-${spring.profiles.active}.yaml # 加载【本地】配置 - - optional:nacos:${spring.application.name}-${spring.profiles.active}.yaml # 加载【Nacos】的配置 + - optional:classpath:application-${spring.profiles.active}.yaml + - optional:nacos:${spring.application.name}-${spring.profiles.active}.yaml - # Servlet 配置 servlet: - # 文件上传相关配置项 multipart: - max-file-size: 16MB # 单个文件大小 - max-request-size: 32MB # 设置总上传的文件大小 + max-file-size: 16MB + max-request-size: 32MB mvc: pathmatch: - matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 + matching-strategy: ANT_PATH_MATCHER # Jackson 配置项 jackson: -- Gitblit v1.9.3