‘liusuyi’
2023-10-08 157c26f5188c7ed62a4547f7e3b5a5a3e3ed7729
src/main/java/com/ard/alarm/stealelec/service/StealElecAlarmService.java
@@ -3,15 +3,14 @@
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.ard.alarm.stealelec.domain.ArdAlarmStealelec;
import com.ard.utils.mqtt.MqttConsumer;
import com.ard.utils.http.HttpUtils;
import com.ard.utils.mqtt.MqttProducer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -26,8 +25,7 @@
@Slf4j(topic = "stealAlarm")
@Service
public class StealElecAlarmService {
    @Resource
    RestTemplate restTemplate;
    @Value("${spring.stealelec.url}")
    private String stealElecUrl;
    @Value("${spring.stealelec.enabled}")
@@ -49,7 +47,7 @@
            if (!enabled) {
                return;
            }
            String allAlarmData = restTemplate.getForObject(stealElecUrl, String.class);
            String allAlarmData = HttpUtils.sendGet(stealElecUrl);
            //剔除所有\符号
            String message = allAlarmData.replaceAll("\\\\", "");
            //剔除整个字符串首尾双引号
@@ -70,7 +68,7 @@
                    if (tempList.contains(wd.getId())) {
                        continue;
                    }
                    MqttConsumer.publish(2, false, "stealelec", JSON.toJSONString(wd));
                    MqttProducer.publish(2, false, "stealelec", JSON.toJSONString(wd));
                    tempList.add(wd.getId());
                }
            }