//package com.ruoyi.dataprocess.mqtt.client.listener;
//
//import com.alibaba.fastjson.JSONArray;
//import com.alibaba.fastjson.JSONObject;
//import com.ruoyi.common.core.constant.TdEngineConstants;
//import com.ruoyi.common.core.domain.R;
//import com.ruoyi.common.core.enums.ResultEnums;
//import com.ruoyi.common.core.utils.SpringUtils;
//import com.ruoyi.common.core.utils.StringUtils;
//import com.ruoyi.dataprocess.common.SpringBeanUtils;
//import com.ruoyi.dataprocess.mapper.HwDeviceMapper;
//import com.ruoyi.dataprocess.mqtt.client.config.MqttConfiguration;
//import com.ruoyi.dataprocess.service.IDataProcessService;
//import com.ruoyi.system.api.RemoteFileService;
//import com.ruoyi.system.api.factory.RemoteFileFallbackFactory;
//import com.ruoyi.tdengine.api.RemoteTdEngineService;
//import com.ruoyi.tdengine.api.domain.TdField;
//import net.dreamlu.iot.mqtt.codec.MqttPublishMessage;
//import net.dreamlu.iot.mqtt.core.client.IMqttClientMessageListener;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import org.springframework.stereotype.Controller;
//import org.springframework.stereotype.Service;
//import org.tio.core.ChannelContext;
//
//import javax.annotation.PostConstruct;
//import javax.annotation.Resource;
//import java.nio.ByteBuffer;
//import java.nio.charset.StandardCharsets;
//import java.util.List;
//
///**
// * 客户端消息监听的另一种方式
// *
// * @author L.cm
// */
//@Service
//public class MqttClientMessageListener implements IMqttClientMessageListener {
//    private static final Logger logger = LoggerFactory.getLogger(MqttClientMessageListener.class);
//
//    private IDataProcessService dataProcessService;
//
////    @PostConstruct
////    public void init() {
////        remoteTdEngineService = SpringBeanUtils.getBean(RemoteTdEngineService.class);
////        System.out.println("--***-"+remoteTdEngineService);
////
////    }
//
//    @Override
//    public void onMessage(ChannelContext context, String topic, MqttPublishMessage message, ByteBuffer payload) {
//        String payloadString = new String(payload.array(), StandardCharsets.UTF_8);
//        System.out.println("paa:" + topic);
////        System.out.println("data"+dataProcessService);
//        if(dataProcessService == null){
//            dataProcessService = SpringBeanUtils.getBean(IDataProcessService.class);
//        }
////        if(topic.startsWith(MqttConfiguration))
//        dataProcessService.processBusinessData(payloadString);
//        logger.info("topic:{} payload:{}", topic, payloadString);
//    }
//
//
//}
//
