package com.chinaitop.depot.intelligent.rocketMQ.listenerMQ;

/*import com.alibaba.fastjson.JSON;
import com.chinaitop.depot.intelligent.grainsituation.mapper.TWarningThresholdHistoryMapper;
import com.chinaitop.depot.intelligent.grainsituation.model.TWarningThresholdHistory;
import com.chinaitop.depot.intelligent.grainsituation.service.TWarningThresholdHistoryService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;*/

/**
 * @author qingsong.han
 * @description:
 * @create 2022-04-24 14:31
 */
/*@Slf4j
@Component
public class WarningThresholdHistoryListener {

    @Resource
    private TWarningThresholdHistoryMapper tWarningThresholdHistoryMapper;
    @Resource
    private TWarningThresholdHistoryService tWarningThresholdHistoryService;

    // topic需要和生产者的topic一致，consumerGroup属性是必须指定的，内容可以随意
    // selectorExpression的意思指的就是tag，默认为“*”，不设置的话会监听所有消息
    @Service
    @RocketMQMessageListener(topic = "smart_grp_yn", selectorExpression = "t_warning_threshold_history_c", consumerGroup = "t_warning_threshold_history_c")
    public class WarningAdd implements RocketMQListener<ArrayList<TWarningThresholdHistory>> {
        // 监听到消息就会执行此方法
        @Override
        public void onMessage(ArrayList<TWarningThresholdHistory> tWarningThresholdHistorieList) {
            log.info("tWarningThresholdHistoriesList insert: {}", JSON.toJSONString(tWarningThresholdHistorieList));
            tWarningThresholdHistoryMapper.insertBatch(tWarningThresholdHistorieList);
        }
        // inside class
    }

    @Service
    @RocketMQMessageListener(topic = "smart_grp_yn", selectorExpression = "t_warning_threshold_history_u", consumerGroup = "t_warning_threshold_history_u")
    public class WarningUpdate implements RocketMQListener<ArrayList<TWarningThresholdHistory>> {
        // 监听到消息就会执行此方法
        @Override
        public void onMessage(ArrayList<TWarningThresholdHistory> tWarningThresholdHistoriesList) {
            log.info("tWarningThresholdHistoriesList update: {}", JSON.toJSONString(tWarningThresholdHistoriesList));
            tWarningThresholdHistoriesList.forEach(ls -> tWarningThresholdHistoryService.updateById(ls));
        }
        // inside class
    }

// java class
}*/
