package com.bz.rmcp.dap.mq;

import com.alibaba.fastjson.JSON;
import com.bz.rmcp.dap.model.DeviceOrigDataDTO;
import com.bz.rmcp.dap.model.OfflineData;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
 * @author linqingwei 数据接收
 * @date 2021-08-03 17:37
 */
@Slf4j
@Component
public class DeviceDataConsumer  {
    //@RabbitListener(queues = "MqConstant.SYNC_ORG_QUEUE")
    public void receive(Message message, Channel channel) throws IOException {
        String msg = new String(message.getBody(),StandardCharsets.UTF_8);
        log.info("DeviceDataConsumer receive：{}", msg);
        DeviceOrigDataDTO data = JSON.parseObject(msg, DeviceOrigDataDTO.class);

        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
    }
}
