package com.prolog.cs.biz.inbound.service.impl.mq;

import com.alibaba.fastjson.JSONObject;
import com.prolog.cs.biz.inbound.service.MqInBoundProducer;
import com.prolog.entity.EisLog;
import com.prolog.entity.vo.ContainerTailgatingRequestVO;
import com.prolog.entity.vo.InBoundRequestVO;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

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

import static com.prolog.constant.RabbitMqConstant.*;


@Service
public class RabbitMqInBoundProducerImpl implements MqInBoundProducer {

    @Resource
    private RabbitTemplate rabbitTemplate;

    @Override
    public void inBoundRequest(List<InBoundRequestVO> list) {
        rabbitTemplate.convertAndSend(WMS2EIS_INBOUND_REQUEST_EXCHANGE, WMS2EIS_INBOUND_REQUEST_ROUTING_KEY, JSONObject.toJSONString(list));
    }

    @Override
    public void containerTailgatingRequest(List<ContainerTailgatingRequestVO> list) {
        rabbitTemplate.convertAndSend(WMS2EIS_CONTAINER_TAILGATING_REQUEST_EXCHANGE, WMS2EIS_CONTAINER_TAILGATING_REQUEST_ROUTING_KEY, JSONObject.toJSONString(list));
    }

    @Override
    public void saveEisLog(EisLog log) {
        rabbitTemplate.convertAndSend(WMS2EIS_SAVE_LOG_EXCHANGE, WMS2EIS_SAVE_LOG_ROUTING_KEY, JSONObject.toJSONString(log));
    }
}
