package com.dxhy.erp.rabbitmq;

import cn.hutool.core.codec.Base64;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.dxhy.erp.entity.alltax.TaxesSaleRequestInfo;
import com.dxhy.erp.service.AllTaxesSaleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @author user
 */
@Component
@Slf4j
public class Receiver {
    @Resource
    private AllTaxesSaleService allTaxesSaleService;

    /**
     * 导出消费者
     *
     * @param message
     *            导出数据
     */
    @RabbitHandler
    @RabbitListener(queues = "${TO_SALE_COUNT_ITEM:TO_SALE_COUNT_ITEM}")
    public void handleMessage(String message) {
        try {
            log.debug("销项汇总项目分类接收的消息为" + message);
            JSONObject jsonObject = JSONObject.parseObject(message);
            TaxesSaleRequestInfo req = JSONObject.toJavaObject(jsonObject, TaxesSaleRequestInfo.class);
            allTaxesSaleService.countByItem(req.getParam());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
