package com.prolog.upcloud.base.wh.operate.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static com.prolog.constant.RabbitMqConstant.*;
import static com.prolog.cs.biz.outbound.model.tms.TmsConstant.*;


/**
 * 此配置是用于RabbitMQ没配置队列和交换时自动创建以下队列及交换机
 *
 * @author 鄢菁KingYan
 * @date 2022/06/13
 */
@Configuration
public class RabbitQueueConfig {

    @Bean
    public Queue inBoundRequestQueue() {
        return new Queue(WMS2EIS_INBOUND_REQUEST_QUEUE);
    }

    @Bean
    public Queue outBoundRequestQueue() {
        return new Queue(WMS2EIS_OUTBOUND_REQUEST_QUEUE);
    }

    @Bean
    public Queue upgradePriorityQueue() {
        return new Queue(WMS2EIS_UPGRADE_PRIORITY_QUEUE);
    }

    @Bean
    public Queue cancelTasksQueue() {
        return new Queue(WMS2EIS_CANCEL_TASKS_QUEUE);
    }

    @Bean
    public Queue operationCompleteQueue() {
        return new Queue(WMS2EIS_OPERATION_COMPLETE_QUEUE);
    }

    @Bean
    public Queue inventoryAuditQueue() {
        return new Queue(WMS2EIS_INVENTORY_AUDIT_QUEUE);
    }

    @Bean
    public Queue inventoryLockQueue() {
        return new Queue(WMS2EIS_INVENTORY_LOCK_QUEUE);
    }

    @Bean
    public Queue containerTailgatingRequestQueue() {
        return new Queue(WMS2EIS_CONTAINER_TAILGATING_REQUEST_QUEUE);
    }

    @Bean
    public Queue saveShipBillQueue() {
        return new Queue(WMS2TMS_SAVE_SHIP_BILL_QUEUE);
    }

    @Bean
    public Queue saveShipBillPackageQueue() {
        return new Queue(WMS2TMS_SAVE_SHIP_BILL_PACKAGE_QUEUE);
    }

    @Bean
    public Queue eis2wmsGspTaskCallbackQueue() {
        return new Queue(EIS2WMS_GSP_TASK_CALLBACK_QUEUE);
    }


    @Bean
    public DirectExchange inBoundRequestExchange() {
        return new DirectExchange(WMS2EIS_INBOUND_REQUEST_EXCHANGE);
    }

    @Bean
    public DirectExchange outBoundRequestExchange() {
        return new DirectExchange(WMS2EIS_OUTBOUND_REQUEST_EXCHANGE);
    }

    @Bean
    public DirectExchange upgradePriorityExchange() {
        return new DirectExchange(WMS2EIS_UPGRADE_PRIORITY_EXCHANGE);
    }

    @Bean
    public DirectExchange cancelTasksExchange() {
        return new DirectExchange(WMS2EIS_CANCEL_TASKS_EXCHANGE);
    }

    @Bean
    public DirectExchange operationCompleteExchange() {
        return new DirectExchange(WMS2EIS_OPERATION_COMPLETE_EXCHANGE);
    }

    @Bean
    public DirectExchange inventoryAuditExchange() {
        return new DirectExchange(WMS2EIS_INVENTORY_AUDIT_EXCHANGE);
    }

    @Bean
    public DirectExchange inventoryLockExchange() {
        return new DirectExchange(WMS2EIS_INVENTORY_LOCK_EXCHANGE);
    }

    @Bean
    public DirectExchange containerTailgatingRequestExchange() {
        return new DirectExchange(WMS2EIS_CONTAINER_TAILGATING_REQUEST_EXCHANGE);
    }

    @Bean
    public DirectExchange saveShipBillExchange() {
        return new DirectExchange(WMS2TMS_SAVE_SHIP_BILL_EXCHANGE);
    }

    @Bean
    public DirectExchange saveShipBillPackageExchange() {
        return new DirectExchange(WMS2TMS_SAVE_SHIP_BILL_PACKAGE_EXCHANGE);
    }

    @Bean
    public DirectExchange eis2wmsGspTaskCallbackExchange() {
        return new DirectExchange(EIS2WMS_GSP_TASK_CALLBACK_EXCHANGE);
    }


    @Bean
    Binding bindingInBoundRequestExchange(Queue inBoundRequestQueue, DirectExchange inBoundRequestExchange) {
        return BindingBuilder.bind(inBoundRequestQueue).to(inBoundRequestExchange).with(WMS2EIS_INBOUND_REQUEST_ROUTING_KEY);
    }

    @Bean
    Binding bindingOutBoundRequestExchange(Queue outBoundRequestQueue, DirectExchange outBoundRequestExchange) {
        return BindingBuilder.bind(outBoundRequestQueue).to(outBoundRequestExchange).with(WMS2EIS_OUTBOUND_REQUEST_ROUTING_KEY);
    }

    @Bean
    Binding bindingUpgradePriorityExchange(Queue upgradePriorityQueue, DirectExchange upgradePriorityExchange) {
        return BindingBuilder.bind(upgradePriorityQueue).to(upgradePriorityExchange).with(WMS2EIS_UPGRADE_PRIORITY_ROUTING_KEY);
    }

    @Bean
    Binding bindingCancelTasksQueueExchange(Queue cancelTasksQueue, DirectExchange cancelTasksExchange) {
        return BindingBuilder.bind(cancelTasksQueue).to(cancelTasksExchange).with(WMS2EIS_CANCEL_TASKS_ROUTING_KEY);
    }

    @Bean
    Binding bindingOperationCompleteExchange(Queue operationCompleteQueue, DirectExchange operationCompleteExchange) {
        return BindingBuilder.bind(operationCompleteQueue).to(operationCompleteExchange).with(WMS2EIS_OPERATION_COMPLETE_ROUTING_KEY);
    }

    @Bean
    Binding bindingInventoryAuditExchange(Queue inventoryAuditQueue, DirectExchange inventoryAuditExchange) {
        return BindingBuilder.bind(inventoryAuditQueue).to(inventoryAuditExchange).with(WMS2EIS_INVENTORY_AUDIT_ROUTING_KEY);
    }

    @Bean
    Binding bindingInventoryLockExchange(Queue inventoryLockQueue, DirectExchange inventoryLockExchange) {
        return BindingBuilder.bind(inventoryLockQueue).to(inventoryLockExchange).with(WMS2EIS_INVENTORY_LOCK_ROUTING_KEY);
    }

    @Bean
    Binding bindingContainerTailgatingRequestExchange(Queue containerTailgatingRequestQueue, DirectExchange containerTailgatingRequestExchange) {
        return BindingBuilder.bind(containerTailgatingRequestQueue).to(containerTailgatingRequestExchange).with(WMS2EIS_CONTAINER_TAILGATING_REQUEST_ROUTING_KEY);
    }

    @Bean
    Binding bindingSaveShipBillExchange(Queue saveShipBillQueue, DirectExchange saveShipBillExchange) {
        return BindingBuilder.bind(saveShipBillQueue).to(saveShipBillExchange).with(WMS2TMS_SAVE_SHIP_BILL_ROUTING_KEY);
    }

    @Bean
    Binding bindingSaveShipBillPackageExchange(Queue saveShipBillPackageQueue, DirectExchange saveShipBillPackageExchange) {
        return BindingBuilder.bind(saveShipBillPackageQueue).to(saveShipBillPackageExchange).with(WMS2TMS_SAVE_SHIP_BILL_PACKAGE_ROUTING_KEY);
    }

    @Bean
    Binding bindingEis2wmsGspTaskCallbackExchange(Queue eis2wmsGspTaskCallbackQueue, DirectExchange eis2wmsGspTaskCallbackExchange) {
        return BindingBuilder.bind(eis2wmsGspTaskCallbackQueue).to(eis2wmsGspTaskCallbackExchange).with(EIS2WMS_GSP_TASK_CALLBACK_ROUTING_KEY);
    }

}
