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

import com.prolog.framework.common.message.RestMessage;
import com.prolog.upcloud.base.strategy.dto.MoveRuleDTO;
import com.prolog.upcloud.base.strategy.dto.ReplenishRuleDTO;
import com.prolog.upcloud.base.strategy.dto.StrategyDTO;
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.RequestParam;

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

@FeignClient(value = "${prolog.service.strategy}")
public interface StrategyClient {

    /**
     * 查询执行策略
     *
     * @param enterpriseId 企业id
     * @param category     策略分类[上架：InStock,下架:OutStock,补货:Replenishment]
     * @param cargoOwnerId 货主id
     * @param warehouseId  仓库id
     * @return 执行策略
     */
    @GetMapping("/strategy/v1/execute")
    RestMessage<StrategyDTO> getStrategyDTO(@RequestParam("enterpriseId") String enterpriseId, @RequestParam("category") String category, @RequestParam("cargoOwnerId") String cargoOwnerId, @RequestParam("warehouseId") String warehouseId);

    /**
     * 查询执行策略
     *
     * @param enterpriseId  企业id
     * @param category      策略分类[上架：InStock,下架:OutStock,补货:Replenishment]
     * @param cargoOwnerIds 货主id集合
     * @param warehouseId   仓库id
     * @return 执行策略
     */
    @GetMapping("/strategy/v1/execute/batch")
    RestMessage<List<StrategyDTO>> getStrategyDTO(@RequestParam("enterpriseId") String enterpriseId, @RequestParam("category") String category, @RequestParam("cargoOwnerIds") String[] cargoOwnerIds, @RequestParam("warehouseId") String warehouseId);

    /**
     * 查询补货规则
     *
     * @param warehouseId        仓库编码
     * @param srcWarehouseAreaId 源库区
     * @return 补货规则列表
     */
    @GetMapping("/rule/replenish/v1/list")
    RestMessage<List<ReplenishRuleDTO>> getReplenishRuleList(@RequestParam(value = "warehouseId", required = true) String warehouseId, @RequestParam(value = "srcWarehouseAreaId", required = false) String srcWarehouseAreaId, @RequestParam(value = "destWarehouseAreaId", required = false) String destWarehouseAreaId);

    /**
     * 查询补货规则
     */
    @GetMapping("/rule/replenish/v1/listByArray")
    RestMessage<List<ReplenishRuleDTO>> getReplenishRuleListByArray(@RequestParam(value = "warehouseId", required = true) String warehouseId, @RequestParam(value = "srcWarehouseAreaIds", required = false) List<String> srcWarehouseAreaIds, @RequestParam(value = "destWarehouseAreaIds", required = false) List<String> destWarehouseAreaIds);

    /**
     * 查询移库规则
     *
     * @param warehouseId           仓库ID
     * @param srcWarehouseCategory  源库别
     * @param destWarehouseCategory 目的库别
     * @return 移库规则
     */
    @GetMapping("/rule/move/v1/list")
    RestMessage<List<MoveRuleDTO>> getMoveList(@RequestParam(name = "warehouseId") String warehouseId, @RequestParam(name = "srcWarehouseCategory", required = false) String srcWarehouseCategory, @RequestParam(name = "destWarehouseCategory", required = false) String destWarehouseCategory);

    /**
     * 根据编码集合，批量查询业务控制参数设置
     * @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
    );
}
