package com.prolog.cs.biz.outbound.resource;

import com.prolog.framework.common.message.RestMessage;
import com.prolog.upcloud.base.strategy.dto.StrategyDTO;
import com.prolog.upcloud.base.strategy.model.BillSortRuleVO;
import com.prolog.upcloud.base.strategy.model.BusinessControl;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2021-04-21.
 */
@FeignClient(value = "${prolog.service.strategy}")
public interface StrategyResource {

    /**
     * 根据编码,查询业务控制参数设置
     * @param regCode
     * @param warehouseId
     * @param cargoOwnerId
     * @param enterpriseId
     * @return
     */
    @GetMapping( "registry/by-code")
    RestMessage<BusinessControl> getControlByCode(@RequestParam(value = "regCode")String regCode,@RequestParam(value = "warehouseId") String warehouseId,@RequestParam(value = "cargoOwnerId") String cargoOwnerId,@RequestParam(value = "enterpriseId") String enterpriseId,@RequestParam(value = "bldgId") String bldgId);

    /**
     * 根据编码集合，批量查询业务控制参数设置
     * @param regCodes
     * @param warehouseId
     * @param cargoOwnerId
     * @param enterpriseId
     * @return
     */
    @GetMapping( "registry/by-codes")
    RestMessage<Map<String,BusinessControl>> getControlByCodes(
            @RequestParam(value = "regCodes")String regCodes[],
            @RequestParam(value = "warehouseId") String warehouseId,
            @RequestParam(value = "cargoOwnerId") String cargoOwnerId,
            @RequestParam(value = "enterpriseId") String enterpriseId,
            @RequestParam(value = "bldgId")String bldgId
    );

    /**
     * 查询执行策略
     *
     * @param enterpriseId 企业id
     * @param category     策略类型
     * @param cargoOwnerId 货主
     * @param warehouseId  仓库id
     * @return
     */

    @GetMapping("/strategy/v1/execute")
    RestMessage<StrategyDTO> getStrategyDTO(@RequestParam(value = "enterpriseId") String enterpriseId,
                                            @RequestParam(value = "category") String category,
                                            @RequestParam(value = "cargoOwnerId") String cargoOwnerId,
                                            @RequestParam(value = "warehouseId") String warehouseId);

    @PostMapping("/rule/queryBillSortRuleList")
    RestMessage<List<BillSortRuleVO>> queryBillSortRuleList(@RequestBody BillSortRuleVO billSortRuleVO);
}
