//package cn.cecep.talroad.util;
//
//import cn.cecep.talroad.common.core.utils.StringUtils;
//import cn.cecep.talroad.service.IBasDeviceService;
//import cn.cecep.talroad.service.strategy.StrategyFactory;
//import cn.cecep.talroad.vo.FactoryDeviceVo;
//import com.rabbitmq.client.Channel;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.amqp.core.Message;
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
//import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
///**
// * @Auther: cjh
// * @Date: 2023-04-17 11:02
// * @Class: MsgReceiver
// * @Deseription: 产量统计消息消费
// * @Version V1.0
// */
//@Slf4j
//@Component
//public class YieldConsumer implements ChannelAwareMessageListener {
//
//    @Autowired
//    private IBasDeviceService basDeviceService;
//    @Autowired
//    private StrategyFactory strategyFactory;
//
//    @Override
//    @RabbitListener(queues = "yield-queue")
//    public void onMessage(Message message, Channel channel) throws Exception {
//        String deviceId = new String(message.getBody());
//        try {
//            FactoryDeviceVo vo = basDeviceService.selectFactoryDeviceVoByDeviceId(deviceId);
//
//            //拼接策略服务名称
//            String strategyName = StringUtils.upperCase(vo.getIndustry() + vo.getDeviceType() + vo.getDeviceType());
//            log.info("开始消费者-产量统计-行业："+vo.getIndustry()+",设备类型:"+vo.getDeviceType());
//            //执行策略，处理设备状态
//            strategyFactory.getByName(strategyName).doCheckProcessYield(vo);
//
//        } catch (Exception e) {
//            log.error("MsgReceiver.onMessage##设备ID:"+ deviceId+"##异常信息:"+ e.getMessage());
//        } finally {
//            //ACK 手动签收消息，告诉对方消息签收成功,唯一标识ID
//            Long deliverTag = message.getMessageProperties().getDeliveryTag();
//            channel.basicAck(deliverTag, false);
//        }
//    }
//}
