package com.dxhy.common.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.dxhy.common.rabbitmq.RabbitMqSender;
import com.dxhy.common.service.CustomsLogService;
import com.dxhy.common.vo.CustomsLog;

import cn.hutool.core.codec.Base64;
import lombok.extern.slf4j.Slf4j;

/**
 * @author jiaohongyang
 */
@Service("customsLogService")
@Slf4j
public class CustomsLogServiceImpl implements CustomsLogService {
    @Resource
    private RabbitMqSender rabbitLogsSender;

    /**
     * 海关缴款书日志存储
     *
     * @param customsLog
     *            日志信息
     * @return 是否成功
     */
    @Override
    public boolean toCustomsLog(List<CustomsLog> customsLog) {
        try {
            String json = JSON.toJSONString(customsLog);
            rabbitLogsSender.sendCustomsLogs(Base64.encode(json));
            return true;
        } catch (Exception e) {
            log.debug("缴款书操作记录生成日志异常：{}" + e.getMessage());
            return false;
        }
    }

}
