From ffbf0d068b53fa2d3209dd6d6a6ab9472e564de2 Mon Sep 17 00:00:00 2001 From: liriming <1343021927@qq.com> Date: 星期二, 25 二月 2025 11:06:17 +0800 Subject: [PATCH] ansteel --- /dev/null | 117 ----------------------------- ansteel-biz/src/main/java/com/iailab/module/ansteel/mq/common/constant/RoutingConstant.java | 2 pom.xml | 95 ----------------------- ansteel-biz/pom.xml | 5 + 4 files changed, 9 insertions(+), 210 deletions(-) diff --git a/ansteel-biz/pom.xml b/ansteel-biz/pom.xml index 9eca65e..b2f5458 100644 --- a/ansteel-biz/pom.xml +++ b/ansteel-biz/pom.xml @@ -111,6 +111,11 @@ <version>2.3.2</version> </dependency> + <dependency> + <groupId>com.iailab</groupId> + <artifactId>iailab-common-mq</artifactId> + </dependency> + </dependencies> <build> diff --git a/ansteel-biz/src/main/java/com/iailab/module/ansteel/mq/common/constant/RoutingConstant.java b/ansteel-biz/src/main/java/com/iailab/module/ansteel/mq/common/constant/RoutingConstant.java index 2fbd6ab..16340d9 100644 --- a/ansteel-biz/src/main/java/com/iailab/module/ansteel/mq/common/constant/RoutingConstant.java +++ b/ansteel-biz/src/main/java/com/iailab/module/ansteel/mq/common/constant/RoutingConstant.java @@ -2,7 +2,7 @@ public interface RoutingConstant { - String EXCHANGE = "FastShasteel"; + String EXCHANGE = "FastAnsteel"; // 预测模型完成路由 String Iailab_Model_PredictFinish = "Iailab.Model.PredictFinish"; diff --git a/ansteel-biz/src/main/java/com/iailab/module/ansteel/mq/config/QueueModelAlarmConfig.java b/ansteel-biz/src/main/java/com/iailab/module/ansteel/mq/config/QueueModelAlarmConfig.java deleted file mode 100644 index 037a125..0000000 --- a/ansteel-biz/src/main/java/com/iailab/module/ansteel/mq/config/QueueModelAlarmConfig.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.iailab.module.ansteel.mq.config; - -import com.iailab.module.shasteel.mq.common.constant.RoutingConstant; -import org.springframework.amqp.core.Binding; -import org.springframework.amqp.core.BindingBuilder; -import org.springframework.amqp.core.Queue; -import org.springframework.amqp.core.TopicExchange; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * 绑定队列 - * - * @author lirm - * @Description - * @createTime 2024年11月27日 - */ -@Configuration -public class QueueModelAlarmConfig { - // 队列名称 - public final static String QUEUE_NAME = "IaiabFastShateel.Model.Alarm"; - - @Bean - public Queue alarmQueue() { - return new Queue(QUEUE_NAME); - } - - @Bean - TopicExchange alarmExchange() { - return new TopicExchange(RoutingConstant.EXCHANGE); - } - - // 注意通配符*和#的用法 - @Bean - Binding bindingExchangeMessageAlarm() { - return BindingBuilder.bind(alarmQueue()).to(alarmExchange()).with(RoutingConstant.Iailab_Model_Alarm); - } -} diff --git a/ansteel-biz/src/main/java/com/iailab/module/ansteel/mq/config/QueuePredictFinishConfig.java b/ansteel-biz/src/main/java/com/iailab/module/ansteel/mq/config/QueuePredictFinishConfig.java deleted file mode 100644 index 03fbb0d..0000000 --- a/ansteel-biz/src/main/java/com/iailab/module/ansteel/mq/config/QueuePredictFinishConfig.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.iailab.module.ansteel.mq.config; - -import com.iailab.module.shasteel.mq.common.constant.RoutingConstant; -import org.springframework.amqp.core.Binding; -import org.springframework.amqp.core.BindingBuilder; -import org.springframework.amqp.core.Queue; -import org.springframework.amqp.core.TopicExchange; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * @author lirm - * @Description - * @createTime 2024年11月27日 - */ -@Configuration -public class QueuePredictFinishConfig { - // 队列名称 - public final static String QUEUE_NAME = "IaiabFastShateel.Model.PredictFinish"; - - @Bean - public Queue predictFinishQueue() { - return new Queue(QueuePredictFinishConfig.QUEUE_NAME); - } - - @Bean - TopicExchange predictFinishExchange() { - return new TopicExchange(RoutingConstant.EXCHANGE); - } - - // 注意通配符*和#的用法 - @Bean - Binding bindingExchangeMessagePF() { - return BindingBuilder.bind(predictFinishQueue()).to(predictFinishExchange()).with(RoutingConstant.Iailab_Model_PredictFinish); - } -} diff --git a/ansteel-biz/src/main/java/com/iailab/module/ansteel/mq/consumer/ModelAlarmConsumer.java b/ansteel-biz/src/main/java/com/iailab/module/ansteel/mq/consumer/ModelAlarmConsumer.java deleted file mode 100644 index 871d7cb..0000000 --- a/ansteel-biz/src/main/java/com/iailab/module/ansteel/mq/consumer/ModelAlarmConsumer.java +++ /dev/null @@ -1,165 +0,0 @@ -package com.iailab.module.ansteel.mq.consumer; - -import com.alibaba.fastjson.JSONObject; -import com.iailab.framework.common.util.date.DateUtils; -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.ScheduleTriggerMethodEnum; -import com.iailab.module.shasteel.mq.common.constant.CommonConstant; -import com.iailab.module.shasteel.mq.config.QueueModelAlarmConfig; -import lombok.extern.slf4j.Slf4j; -import org.springframework.amqp.core.Message; -import org.springframework.amqp.rabbit.annotation.RabbitListener; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -/** - * 监听报警信息 - * - * @author PanZhibao - * @Description - * @createTime 2024年12月11日 - */ -@Slf4j -@Component -public class ModelAlarmConsumer { - - @Resource - private McsApi mcsApi; - - @Resource - private MdkApi mdkApi; - - /** - * 事件标识 - */ - private final String EVENT_FLAG = "GasAlarm"; - - /** - * 监听报警信息,执行调度 - * - * @param message - */ - @RabbitListener(queues = QueueModelAlarmConfig.QUEUE_NAME) - public void listen(Message message) { - String routingKey = message.getMessageProperties().getReceivedRoutingKey(); - log.info("routingKey:" + routingKey); - String messageBody = new String(message.getBody()); - log.info("messageBody:" + messageBody); - JSONObject messageJson = JSONObject.parseObject(messageBody); - if (CollectionUtils.isEmpty(messageJson)) { - return; - } - // 查找需要执行的调度方案 - List<StScheduleSchemeDTO> scheduleSchemeList = mcsApi.listScheduleScheme(ScheduleTriggerMethodEnum.EVENT.getCode(), routingKey); - for(StScheduleSchemeDTO stScheduleSchemeDTO : scheduleSchemeList){ - MdkScheduleReqDTO mdkScheduleReqDTO = new MdkScheduleReqDTO(); - mdkScheduleReqDTO.setScheduleCode(stScheduleSchemeDTO.getCode()); - mdkScheduleReqDTO.setScheduleTime(stScheduleSchemeDTO.getScheduleTime()); - MdkScheduleRespDTO mdkScheduleRespDTO = mdkApi.doSchedule(mdkScheduleReqDTO);//执行调度方案 - if(mdkScheduleRespDTO == null){ - return; - } - AlarmMessageRespDTO alarmRespDTO = (AlarmMessageRespDTO)messageJson.get("AlarmMessageRespDTO"); - alarmRespDTO.setId(UUID.randomUUID().toString()); - alarmRespDTO.setAlarmTime(DateUtils.parse(messageJson.get("predictTime").toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); - mcsApi.createAlarmMessage(alarmRespDTO); - Map<String, Object> result = mdkScheduleRespDTO.getResult(); - switch (mdkScheduleRespDTO.getScheduleCode()) { - case CommonConstant.OXYGEN_ONE_CODE://氧气班平衡计划方案 - if(!result.containsKey("faAdvice") || !result.containsKey("yingDiAdvice") || !result.containsKey("yingZhongAdvice") - || !result.containsKey("hongAdvice") || !result.containsKey("RunAdvice")){ - return; - } - for (String key : result.keySet()) { - if ("faAdvice".equals(key) && !"".equals(result.get("faAdvice").toString())) { - ScheduleSuggestRespDTO suggestRespDTO = new ScheduleSuggestRespDTO(); - suggestRespDTO.setId(UUID.randomUUID().toString()); - suggestRespDTO.setScheduleObj(stScheduleSchemeDTO.getScheduleObj()); - suggestRespDTO.setContent(result.get("faAdvice").toString());//法夜空建议送出量建议 - suggestRespDTO.setSchemeId(stScheduleSchemeDTO.getId()); - mcsApi.createScheduleSuggest(suggestRespDTO); - }else if ("yingDiAdvice".equals(key) && !"".equals(result.get("yingDiAdvice").toString())) { - ScheduleSuggestRespDTO suggestRespDTO = new ScheduleSuggestRespDTO(); - suggestRespDTO.setId(UUID.randomUUID().toString()); - suggestRespDTO.setScheduleObj(stScheduleSchemeDTO.getScheduleObj()); - suggestRespDTO.setContent(result.get("yingDiAdvice").toString());//盈德低压建议送出量建议 - suggestRespDTO.setSchemeId(stScheduleSchemeDTO.getId()); - mcsApi.createScheduleSuggest(suggestRespDTO); - }else if ("yingZhongAdvice".equals(key) && !"".equals(result.get("yingZhongAdvice").toString())) { - ScheduleSuggestRespDTO suggestRespDTO = new ScheduleSuggestRespDTO(); - suggestRespDTO.setId(UUID.randomUUID().toString()); - suggestRespDTO.setScheduleObj(stScheduleSchemeDTO.getScheduleObj()); - suggestRespDTO.setContent(result.get("yingZhongAdvice").toString());//盈德中压建议送出量建议 - suggestRespDTO.setSchemeId(stScheduleSchemeDTO.getId()); - mcsApi.createScheduleSuggest(suggestRespDTO); - }else if ("hongAdvice".equals(key) && !"".equals(result.get("hongAdvice").toString())) { - ScheduleSuggestRespDTO suggestRespDTO = new ScheduleSuggestRespDTO(); - suggestRespDTO.setId(UUID.randomUUID().toString()); - suggestRespDTO.setScheduleObj(stScheduleSchemeDTO.getScheduleObj()); - suggestRespDTO.setContent(result.get("hongAdvice").toString());//宏昌建议送出量建议 - suggestRespDTO.setSchemeId(stScheduleSchemeDTO.getId()); - mcsApi.createScheduleSuggest(suggestRespDTO); - }else if ("RunAdvice".equals(key) && !"".equals(result.get("RunAdvice").toString())) { - ScheduleSuggestRespDTO suggestRespDTO = new ScheduleSuggestRespDTO(); - suggestRespDTO.setId(UUID.randomUUID().toString()); - suggestRespDTO.setScheduleObj(stScheduleSchemeDTO.getScheduleObj()); - suggestRespDTO.setContent(result.get("RunAdvice").toString());//润忠建议送出量建议 - suggestRespDTO.setSchemeId(stScheduleSchemeDTO.getId()); - mcsApi.createScheduleSuggest(suggestRespDTO); - } - } - break; - case CommonConstant.OXYGEN_TWO_CODE://氧气系统优化调度决策方案 - if(!result.containsKey("yingdiAdvice") || !result.containsKey("faAdvice") || !result.containsKey("hongAdvice") - || !result.containsKey("RunAdvice")){ - return; - } - for (String key : result.keySet()) { - if ("yingdiAdvice".equals(key) && !"".equals(result.get("yingdiAdvice").toString())) { - ScheduleSuggestRespDTO suggestRespDTO = new ScheduleSuggestRespDTO(); - suggestRespDTO.setId(UUID.randomUUID().toString()); - suggestRespDTO.setScheduleObj(stScheduleSchemeDTO.getScheduleObj()); - suggestRespDTO.setContent(result.get("yingdiAdvice").toString());//盈德中压建议调整量建议 - suggestRespDTO.setSchemeId(stScheduleSchemeDTO.getId()); - mcsApi.createScheduleSuggest(suggestRespDTO); - }else if ("faAdvice".equals(key) && !"".equals(result.get("faAdvice").toString())) { - ScheduleSuggestRespDTO suggestRespDTO = new ScheduleSuggestRespDTO(); - suggestRespDTO.setId(UUID.randomUUID().toString()); - suggestRespDTO.setScheduleObj(stScheduleSchemeDTO.getScheduleObj()); - suggestRespDTO.setContent(result.get("faAdvice").toString());//法夜空建议调整量建议 - suggestRespDTO.setSchemeId(stScheduleSchemeDTO.getId()); - mcsApi.createScheduleSuggest(suggestRespDTO); - }else if ("hongAdvice".equals(key) && !"".equals(result.get("hongAdvice").toString())) { - ScheduleSuggestRespDTO suggestRespDTO = new ScheduleSuggestRespDTO(); - suggestRespDTO.setId(UUID.randomUUID().toString()); - suggestRespDTO.setScheduleObj(stScheduleSchemeDTO.getScheduleObj()); - suggestRespDTO.setContent(result.get("hongAdvice").toString());//宏昌建议调整量建议 - suggestRespDTO.setSchemeId(stScheduleSchemeDTO.getId()); - mcsApi.createScheduleSuggest(suggestRespDTO); - }else if ("RunAdvice".equals(key) && !"".equals(result.get("RunAdvice").toString())) { - ScheduleSuggestRespDTO suggestRespDTO = new ScheduleSuggestRespDTO(); - suggestRespDTO.setId(UUID.randomUUID().toString()); - suggestRespDTO.setScheduleObj(stScheduleSchemeDTO.getScheduleObj()); - suggestRespDTO.setContent(result.get("RunAdvice").toString());//润忠建议调整量建议 - suggestRespDTO.setSchemeId(stScheduleSchemeDTO.getId()); - mcsApi.createScheduleSuggest(suggestRespDTO); - } - } - break; - default: - break; - } - } - } -} \ No newline at end of file diff --git a/ansteel-biz/src/main/java/com/iailab/module/ansteel/mq/consumer/ModelPredictFinish2Consumer.java b/ansteel-biz/src/main/java/com/iailab/module/ansteel/mq/consumer/ModelPredictFinish2Consumer.java deleted file mode 100644 index c1dac4f..0000000 --- a/ansteel-biz/src/main/java/com/iailab/module/ansteel/mq/consumer/ModelPredictFinish2Consumer.java +++ /dev/null @@ -1,150 +0,0 @@ -package com.iailab.module.ansteel.mq.consumer; - -import com.alibaba.fastjson.JSONObject; -import com.iailab.framework.common.util.date.DateUtils; -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.ScheduleTriggerMethodEnum; -import com.iailab.module.shasteel.mq.common.constant.CommonConstant; -import com.iailab.module.shasteel.mq.config.QueuePredictFinishConfig; -import lombok.extern.slf4j.Slf4j; -import org.springframework.amqp.core.Message; -import org.springframework.amqp.rabbit.annotation.RabbitListener; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -/** - * 监听报警信息 - * - * @author PanZhibao - * @Description - * @createTime 2024年12月11日 - */ -@Slf4j -@Component -public class ModelPredictFinish2Consumer { - - @Resource - private McsApi mcsApi; - - @Resource - private MdkApi mdkApi; - - /** - * 监听预测完成,执行调度 - * - * @param message - */ - @RabbitListener(queues = QueuePredictFinishConfig.QUEUE_NAME) - public void listen(Message message) { - String routingKey = message.getMessageProperties().getReceivedRoutingKey(); - log.info("routingKey:" + routingKey); - String messageBody = new String(message.getBody()); - log.info("messageBody:" + messageBody); - JSONObject messageJson = JSONObject.parseObject(messageBody); - if (CollectionUtils.isEmpty(messageJson)) { - return; - } - // 查找需要执行的调度方案 - List<StScheduleSchemeDTO> scheduleSchemeList = mcsApi.listScheduleScheme(ScheduleTriggerMethodEnum.EVENT.getCode(), routingKey); - for(StScheduleSchemeDTO stScheduleSchemeDTO : scheduleSchemeList){ - MdkScheduleReqDTO mdkScheduleReqDTO = new MdkScheduleReqDTO(); - mdkScheduleReqDTO.setScheduleCode(stScheduleSchemeDTO.getCode()); - mdkScheduleReqDTO.setScheduleTime(stScheduleSchemeDTO.getScheduleTime()); - MdkScheduleRespDTO mdkScheduleRespDTO = mdkApi.doSchedule(mdkScheduleReqDTO);//执行调度方案 - if(mdkScheduleRespDTO == null){ - return; - } - Map<String, Object> result = mdkScheduleRespDTO.getResult(); - switch (mdkScheduleRespDTO.getScheduleCode()) { - case CommonConstant.COMPRESSOR_CODE://压缩空气调度方案 - if(!result.containsKey("pressureWarning") || !result.containsKey("dispatchStart") || !result.containsKey("dispatchEnd")){ - return; - } - for (String key : result.keySet()) { - if("pressureWarning".equals(key) && !"".equals(result.get("pressureWarning").toString())){ - AlarmMessageRespDTO alarmRespDTO = new AlarmMessageRespDTO(); - alarmRespDTO.setId(UUID.randomUUID().toString()); - alarmRespDTO.setContent(result.get("pressureWarning").toString());//压力预警信息 - alarmRespDTO.setAlarmTime(DateUtils.parse(messageJson.get("predictTime").toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); - mcsApi.createAlarmMessage(alarmRespDTO); - }else if("dispatchStart".equals(key) && !"".equals(result.get("dispatchStart").toString())){ - ScheduleSuggestRespDTO suggestRespDTO = new ScheduleSuggestRespDTO(); - suggestRespDTO.setId(UUID.randomUUID().toString()); - suggestRespDTO.setScheduleObj(stScheduleSchemeDTO.getScheduleObj()); - suggestRespDTO.setContent(result.get("dispatchStart").toString());//空压机启动调度建议 - suggestRespDTO.setSchemeId(stScheduleSchemeDTO.getId()); - mcsApi.createScheduleSuggest(suggestRespDTO); - }else if("dispatchEnd".equals(key) && !"".equals(result.get("dispatchEnd").toString())){ - ScheduleSuggestRespDTO suggestRespDTO = new ScheduleSuggestRespDTO(); - suggestRespDTO.setId(UUID.randomUUID().toString()); - suggestRespDTO.setScheduleObj(stScheduleSchemeDTO.getScheduleObj()); - suggestRespDTO.setContent(result.get("dispatchClose").toString());//空压机关停调度建议 - suggestRespDTO.setSchemeId(stScheduleSchemeDTO.getId()); - mcsApi.createScheduleSuggest(suggestRespDTO); - } - } - break; - case CommonConstant.STEAM_CODE://蒸汽调度方案 - if(!result.containsKey("daxinWarning") || !result.containsKey("jinfengWarning") || !result.containsKey("zhuanlu1Warning") - || !result.containsKey("zhuanlu2Warning") || !result.containsKey("jinfengAdvice") || !result.containsKey("daxinAdvice")){ - return; - } - for (String key : result.keySet()) { - if ("daxinWarning".equals(key) && !"".equals(result.get("daxinWarning").toString())) { - AlarmMessageRespDTO alarmRespDTO = new AlarmMessageRespDTO(); - alarmRespDTO.setId(UUID.randomUUID().toString()); - alarmRespDTO.setContent(result.get("daxinWarning").toString());//大新预警 - alarmRespDTO.setAlarmTime(DateUtils.parse(messageJson.get("predictTime").toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); - mcsApi.createAlarmMessage(alarmRespDTO); - }else if ("jinfengWarning".equals(key) && !"".equals(result.get("jinfengWarning").toString())) { - AlarmMessageRespDTO alarmRespDTO = new AlarmMessageRespDTO(); - alarmRespDTO.setId(UUID.randomUUID().toString()); - alarmRespDTO.setContent(result.get("jinfengWarning").toString());//锦丰预警 - alarmRespDTO.setAlarmTime(DateUtils.parse(messageJson.get("predictTime").toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); - mcsApi.createAlarmMessage(alarmRespDTO); - }else if ("zhuanlu1Warning".equals(key) && !"".equals(result.get("zhuanlu1Warning").toString())) { - AlarmMessageRespDTO alarmRespDTO = new AlarmMessageRespDTO(); - alarmRespDTO.setId(UUID.randomUUID().toString()); - alarmRespDTO.setContent(result.get("zhuanlu1Warning").toString());//转炉一预警 - alarmRespDTO.setAlarmTime(DateUtils.parse(messageJson.get("predictTime").toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); - mcsApi.createAlarmMessage(alarmRespDTO); - }else if ("zhuanlu2Warning".equals(key) && !"".equals(result.get("zhuanlu2Warning").toString())) { - AlarmMessageRespDTO alarmRespDTO = new AlarmMessageRespDTO(); - alarmRespDTO.setId(UUID.randomUUID().toString()); - alarmRespDTO.setContent(result.get("zhuanlu2Warning").toString());//转炉二预警 - alarmRespDTO.setAlarmTime(DateUtils.parse(messageJson.get("predictTime").toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); - mcsApi.createAlarmMessage(alarmRespDTO); - }else if ("jinfengAdvice".equals(key) && !"".equals(result.get("jinfengAdvice").toString())) { - ScheduleSuggestRespDTO suggestRespDTO = new ScheduleSuggestRespDTO(); - suggestRespDTO.setId(UUID.randomUUID().toString()); - suggestRespDTO.setScheduleObj(stScheduleSchemeDTO.getScheduleObj()); - suggestRespDTO.setContent(result.get("jinfengAdvice").toString());//锦丰调度建议 - suggestRespDTO.setSchemeId(stScheduleSchemeDTO.getId()); - mcsApi.createScheduleSuggest(suggestRespDTO); - }else if ("daxinAdvice".equals(key) && !"".equals(result.get("daxinAdvice").toString())) { - ScheduleSuggestRespDTO suggestRespDTO = new ScheduleSuggestRespDTO(); - suggestRespDTO.setId(UUID.randomUUID().toString()); - suggestRespDTO.setScheduleObj(stScheduleSchemeDTO.getScheduleObj()); - suggestRespDTO.setContent(result.get("daxinAdvice").toString());//大新调度建议 - suggestRespDTO.setSchemeId(stScheduleSchemeDTO.getId()); - mcsApi.createScheduleSuggest(suggestRespDTO); - } - } - break; - default: - break; - } - } - } -} \ No newline at end of file diff --git a/ansteel-biz/src/main/java/com/iailab/module/ansteel/mq/consumer/ModelPredictFinishConsumer.java b/ansteel-biz/src/main/java/com/iailab/module/ansteel/mq/consumer/ModelPredictFinishConsumer.java deleted file mode 100644 index a614a12..0000000 --- a/ansteel-biz/src/main/java/com/iailab/module/ansteel/mq/consumer/ModelPredictFinishConsumer.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.iailab.module.ansteel.mq.consumer; - -import com.alibaba.fastjson.JSONObject; -import com.iailab.framework.common.util.date.DateUtils; -import com.iailab.module.model.api.mcs.McsApi; -import com.iailab.module.model.api.mcs.dto.AlarmConfigRespDTO; -import com.iailab.module.model.api.mcs.dto.AlarmMessageRespDTO; -import com.iailab.module.model.api.mcs.dto.PreDataJsonReqVO; -import com.iailab.module.shasteel.mq.common.constant.CommonConstant; -import com.iailab.module.shasteel.mq.common.constant.RoutingConstant; -import com.iailab.module.shasteel.mq.config.QueuePredictFinishConfig; -import lombok.extern.slf4j.Slf4j; -import org.springframework.amqp.core.Message; -import org.springframework.amqp.rabbit.annotation.RabbitListener; -import org.springframework.amqp.rabbit.core.RabbitTemplate; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * 监听预测完成 - * - * @author PanZhibao - * @Description - * @createTime 2024年12月11日 - */ -@Slf4j -@Component -public class ModelPredictFinishConsumer { - - @Resource - private McsApi mcsApi; - - @Resource - private RabbitTemplate rabbitTemplate; - - /** - * 监听预测完成,产生预警消息 - * - * @param message - */ - @RabbitListener(queues = QueuePredictFinishConfig.QUEUE_NAME) - public void listen(Message message) { - try { - String routingKey = message.getMessageProperties().getReceivedRoutingKey(); - log.info("routingKey:" + routingKey); - String messageBody = new String(message.getBody()); - log.info("messageBody:" + messageBody); - JSONObject messageJson = JSONObject.parseObject(messageBody); - if (CollectionUtils.isEmpty(messageJson)) { - return; - } - List<AlarmConfigRespDTO> configList = mcsApi.listAlarmConfig(new HashMap<String, Object>()); - if (CollectionUtils.isEmpty(configList)) { - return; - } - List<String> outputIdList = new ArrayList<>(); - configList.forEach(item -> { - 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); - Map<String, List<Object[]>> preData = mcsApi.getPreDataCur(reqVO); - if (CollectionUtils.isEmpty(preData)) { - return; - } - List<Object[]> result = preData.get(item.getOutId()); - int toIndex = result.size(); - if (toIndex <= 0) { - return; - } - int fromIndex = result.size() - item.getCompLength(); - List<Object[]> predictList = result.subList(fromIndex, toIndex); - for (Object[] data : predictList) { - BigDecimal dataValue = new BigDecimal(Double.parseDouble(data[1].toString())).setScale(2, BigDecimal.ROUND_HALF_UP); - if (!(dataValue.compareTo(item.getLowerLimit()) >= 0 && dataValue.compareTo(item.getUpperLimit()) <= 0)) { - AlarmMessageRespDTO alarmMessage = new AlarmMessageRespDTO(); - alarmMessage.setConfigId(item.getId()); - if (dataValue.compareTo(item.getLowerLimit()) < 0) { - alarmMessage.setAlarmType(CommonConstant.EXCEEDING_LOWER_LIMIT);//超下限 - } else if (dataValue.compareTo(item.getUpperLimit()) > 0) { - alarmMessage.setAlarmType(CommonConstant.EXCEEDING_UPPER_LIMIT);//超上限 - } - alarmMessage.setAlarmTime(DateUtils.parse(data[0].toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); - StringBuffer sb = new StringBuffer(); - sb.append(data[0]); - sb.append(" "); - sb.append(item.getAlarmObj()); - if ("1".equals(alarmMessage.getAlarmType())) { - sb.append(CommonConstant.EXCEEDING_LOWER_LIMIT); - } else if ("2".equals(alarmMessage.getAlarmType())) { - sb.append(CommonConstant.EXCEEDING_UPPER_LIMIT); - } - sb.append(dataValue); - sb.append(item.getUnit()); - alarmMessage.setContent(sb.toString()); - System.out.println("预警消息=" + alarmMessage); - rabbitTemplate.convertAndSend(RoutingConstant.EXCHANGE, RoutingConstant.Iailab_Model_Alarm, alarmMessage); - break; - } - } - System.out.println(preData); - }); - } catch (Exception e) { - return; - } - - } -} \ No newline at end of file diff --git a/pom.xml b/pom.xml index c4d6eb2..ff99171 100644 --- a/pom.xml +++ b/pom.xml @@ -154,17 +154,10 @@ <version>${revision}</version> </dependency> - <!-- Spring 核心 --> - <dependency> - <!-- 用于生成自定义的 Spring @ConfigurationProperties 配置类的说明文件 --> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-configuration-processor</artifactId> - <version>${spring.boot.version}</version> - </dependency> - + <!-- 消息队列相关 --> <dependency> <groupId>com.iailab</groupId> - <artifactId>iailab-common-env</artifactId> + <artifactId>iailab-common-mq</artifactId> <version>${revision}</version> </dependency> @@ -182,12 +175,6 @@ </dependency> <dependency> - <groupId>com.iailab</groupId> - <artifactId>iailab-common-websocket</artifactId> - <version>${revision}</version> - </dependency> - - <dependency> <groupId>org.springdoc</groupId> <!-- 接口文档 UI:默认 --> <artifactId>springdoc-openapi-ui</artifactId> <version>${springdoc.version}</version> @@ -197,22 +184,12 @@ <artifactId>knife4j-openapi3-spring-boot-starter</artifactId> <version>${knife4j.version}</version> </dependency> - <dependency> - <groupId>com.github.xiaoymin</groupId> <!-- 接口文档 UI:knife4j【网关专属】 --> - <artifactId>knife4j-gateway-spring-boot-starter</artifactId> - <version>${knife4j.version}</version> - </dependency> <!-- DB 相关 --> <dependency> <groupId>com.iailab</groupId> <artifactId>iailab-common-mybatis</artifactId> <version>${revision}</version> - </dependency> - <dependency> - <groupId>org.springdoc</groupId> - <artifactId>springdoc-openapi-webflux-ui</artifactId> - <version>${springdoc.version}</version> </dependency> <dependency> @@ -225,11 +202,7 @@ <artifactId>mybatis-plus-boot-starter</artifactId> <version>${mybatis-plus.version}</version> </dependency> - <dependency> - <groupId>com.baomidou</groupId> - <artifactId>mybatis-plus-generator</artifactId> <!-- 代码生成器,使用它解析表结构 --> - <version>${mybatis-plus-generator.version}</version> - </dependency> + <dependency> <groupId>com.baomidou</groupId> <artifactId>dynamic-datasource-spring-boot-starter</artifactId> <!-- 多数据源 --> @@ -279,29 +252,11 @@ <version>${redisson.version}</version> </dependency> - <dependency> - <groupId>com.dameng</groupId> - <artifactId>DmJdbcDriver18</artifactId> - <version>${dm8.jdbc.version}</version> - </dependency> - <!-- RPC 远程调用相关 --> <dependency> <groupId>com.iailab</groupId> <artifactId>iailab-common-rpc</artifactId> <version>${revision}</version> - </dependency> - - <dependency> - <groupId>com.baomidou</groupId> - <artifactId>lock4j-redisson-spring-boot-starter</artifactId> - <version>${lock4j.version}</version> - <exclusions> - <exclusion> - <artifactId>redisson-spring-boot-starter</artifactId> - <groupId>org.redisson</groupId> - </exclusion> - </exclusions> </dependency> <!-- 监控相关 --> @@ -372,38 +327,11 @@ <version>${easyexcel.verion}</version> </dependency> - <dependency> - <groupId>org.apache.tika</groupId> - <artifactId>tika-core</artifactId> <!-- 文件类型的识别 --> - <version>${tika-core.version}</version> - </dependency> - - <dependency> - <groupId>org.apache.velocity</groupId> - <artifactId>velocity-engine-core</artifactId> - <version>${velocity.version}</version> - </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>${fastjson.version}</version> - </dependency> - - <dependency> - <groupId>cn.smallbun.screw</groupId> - <artifactId>screw-core</artifactId> <!-- 实现数据库文档 --> - <version>${screw.version}</version> - <exclusions> - <exclusion> - <groupId>org.freemarker</groupId> - <artifactId>freemarker</artifactId> <!-- 移除 Freemarker 依赖,采用 Velocity 作为模板引擎 --> - </exclusion> - <exclusion> - <groupId>com.alibaba</groupId> - <artifactId>fastjson</artifactId> <!-- 最新版screw-core1.0.5依赖fastjson1.2.73存在漏洞,移除。 --> - </exclusion> - </exclusions> </dependency> <dependency> @@ -413,26 +341,9 @@ </dependency> <dependency> - <groupId>com.google.inject</groupId> - <artifactId>guice</artifactId> - <version>${guice.version}</version> - </dependency> - - <dependency> <groupId>com.alibaba</groupId> <artifactId>transmittable-thread-local</artifactId> <!-- 解决 ThreadLocal 父子线程的传值问题 --> <version>${transmittable-thread-local.version}</version> - </dependency> - - <dependency> - <groupId>commons-net</groupId> - <artifactId>commons-net</artifactId> <!-- 解决 ftp 连接 --> - <version>${commons-net.version}</version> - </dependency> - <dependency> - <groupId>com.jcraft</groupId> - <artifactId>jsch</artifactId> <!-- 解决 sftp 连接 --> - <version>${jsch.version}</version> </dependency> <dependency> -- Gitblit v1.9.3