package com.usky.agbox.service.mqtt.info;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.usky.agbox.service.job.patrolAgbox;
import com.usky.agbox.service.mqtt.MqttStrategy;
import com.usky.agbox.service.vo.MqttBaseVO;
import com.usky.common.core.util.JsonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @author zyj
 * @date 2022/12/6 15:07
 */
@Service("info")
public class Info implements MqttStrategy {
    @Autowired
    private patrolAgbox PatrolAgbox;

    public String disposeMessage(MqttBaseVO mqttBaseVO) {

        try {
            JSONObject map_data = JSONObject.parseObject(mqttBaseVO.getData().toString());
            JSONObject eventVO = new JSONObject();
            eventVO.put("deviceId",map_data.get("deviceId"));
            PatrolAgbox.updateHeart(eventVO.toJSONString());
            System.out.println("FInfoReceiver消费者收到消息： " + mqttBaseVO.getData().toString());
        } catch (Exception e){
            e.printStackTrace();
        }

        return null;
    }


}
