From 20ca11322c7a11f8442c24fe9c521f614a54583e Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期二, 07 一月 2025 14:22:29 +0800
Subject: [PATCH] 氧气优化调度

---
 shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunPredictModuleTask.java |   50 +++++++++++++++++++++++++++++++-------------------
 1 files changed, 31 insertions(+), 19 deletions(-)

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 a8e3732..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,23 +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.RoutingConstant;
-import com.iailab.module.shasteel.mq.consumer.AlarmMessage;
-import com.iailab.module.shasteel.mq.consumer.PredictFinishMessage;
+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 javax.annotation.Resource;
-import java.util.Calendar;
+import java.util.*;
 
 /**
  * 执行模块预测定时任务
- *
+ * 1、高炉
+ * 2、焦炉
+ * 3、转炉
+ * 	3.1、氧气
+ * 	3.2、蒸汽
+ * 4、氮气
  */
 @Component("runPredictModuleTask")
 public class RunPredictModuleTask implements ITask {
@@ -25,25 +28,34 @@
 
     @Autowired
     private MdkApi mdkApi;
+
     @Autowired
     private RabbitTemplate rabbitTemplate;
 
-
     @Override
     public void run(String params) {
-        logger.info("runPredictModuleTask定时任务正在执行,参数为:{}",params );
+        logger.info("runPredictModuleTask定时任务正在执行,参数为:{}", params);
         try {
             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(PredictFinishMessage.EXCHANGE, PredictFinishMessage.PREDICTFINISH_ROUTING_KEY, mdkPredictModuleRespDTO);
-
+            calendar.set(Calendar.SECOND, 0);
+            calendar.set(Calendar.MILLISECOND, 0);
+            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();

--
Gitblit v1.9.3