aijinhui
2023-10-07 2b29a4a26019e3d1692c4b4c76746dba9fac7b22
ard-work/src/main/java/com/ruoyi/utils/mqtt/MqttConsumerCallback.java
@@ -69,12 +69,18 @@
    public void messageArrived(String topic, MqttMessage message) {
        try {
            // subscribe后得到的消息会执行到这里面
            log.debug("接收消息 【主题】:" + topic + " 【内容】:" + new String(message.getPayload()));
            log.debug("接收消息 【主题】:" + topic + " 【内容】:" + new String(message.getPayload(), StandardCharsets.UTF_8));
            //进行业务处理(接收报警数据)
            GlobalAlarmServiceImpl globalAlarmService = SpringUtils.getBean(GlobalAlarmServiceImpl.class);
            globalAlarmService.receiveAlarm(topic, new String(message.getPayload(), StandardCharsets.UTF_8));
            if (topic.equals("minioEvent"))
            {
                IStorageMinioEventService storageMinioEventService = SpringUtils.getBean(IStorageMinioEventService.class);
                storageMinioEventService.parseStorageMinioEvent(new String(message.getPayload(), StandardCharsets.UTF_8));
            }
            if (topic.equals("radarWellData"))
            {
                System.out.println(new String(message.getPayload(), StandardCharsets.UTF_8));
                IStorageMinioEventService storageMinioEventService = SpringUtils.getBean(IStorageMinioEventService.class);
                storageMinioEventService.parseStorageMinioEvent(new String(message.getPayload(), StandardCharsets.UTF_8));
            }
@@ -92,10 +98,10 @@
            if (null != topic && null != qos) {
                if (client.isConnected()) {
                    client.subscribe(topic, qos);
                    log.info("mqtt连接成功,客户端ID:" + PropertiesUtil.MQTT_CLIENT_ID);
                    log.info("mqtt连接成功" );
                    log.info("--订阅主题::" + Arrays.toString(topic));
                } else {
                    log.info("mqtt连接失败,客户端ID:" + PropertiesUtil.MQTT_CLIENT_ID);
                    log.info("mqtt连接失败");
                }
            }
        } catch (Exception e) {