沙钢智慧能源系统后端代码
liriming
2024-12-05 bd1e8ac967b82b347ce9fe1408366b9829ff94eb
shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/PredictFinishConsumer.java
@@ -1,6 +1,5 @@
package com.iailab.module.shasteel.mq.consumer;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.iailab.framework.common.util.date.DateUtils;
import com.iailab.module.model.api.mcs.McsApi;
@@ -9,14 +8,15 @@
import com.iailab.module.model.api.mcs.dto.PreDataJsonReqVO;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * @author lirm
@@ -31,17 +31,12 @@
    private McsApi mcsApi;
    @Resource
    private RabbitTemplate rabbitTemplate;
    @Resource
    private AlarmConsumer alarmConsumer;
    @RabbitHandler
    public void process(PredictFinishMessage finishMessage) throws InterruptedException {
    public void process(JSONObject json) throws InterruptedException {
        System.out.println("测试消费模型预测完成RabbitMQ消息----------------------");
        Thread.sleep(5000);
        List<AlarmConfigRespDTO> configList = mcsApi.listAlarmConfig(new HashMap<String, Object>());
        if (!CollectionUtils.isEmpty(configList)) {
            List<String> OutputIdList = new ArrayList<>();
@@ -50,7 +45,7 @@
            });
            configList.forEach(item -> {
                PreDataJsonReqVO reqVO = new PreDataJsonReqVO();
                reqVO.setPredictTime(finishMessage.getPredictTime());
                reqVO.setPredictTime(DateUtils.parse(json.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)) {
@@ -78,6 +73,7 @@
                                content.put("overLimitTime", data[0]);
                                content.put("overLimitValue", dataValue);
                                alarmMessageRespDTO.setContent(JSONObject.toJSONString(content));
                                System.out.println("预警消息=" + alarmMessageRespDTO);
                                alarmMessage.setAlarmMessageRespDTO(alarmMessageRespDTO);
                                try {
                                    alarmConsumer.process(alarmMessage);