package com.prolog.cs.biz.inbound.remote;

import com.prolog.framework.bz.core.collection.ValidList;
import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.core.pojo.Page;
import com.prolog.upcloud.base.inventory.dto.DeviceContainerItemStockDTO;
import com.prolog.upcloud.base.inventory.model.WmsInvStockLot;
import com.prolog.upcloud.base.inventory.vo.*;
import com.prolog.upcloud.base.strategy.dto.stock.StockLocatorDTO;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
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;

@FeignClient(value = "${prolog.service.inventory}")
public interface StockResource {

    @GetMapping("stock-lot/getExpireStock")
    RestMessage<List<WmsInvStockLot>> getExpireStockList(@RequestParam("enterpriseId") String enterpriseId, @RequestParam("warehouseId") String warehouseId);

    @PostMapping("stock-lot/lockStockLot")
    RestMessage lockStockLot(StockLotLockVO vo);

    @PostMapping("stock-lot/unLockStockLot")
    RestMessage unLockStockLot(com.prolog.upcloud.base.wh.operate.vo.StockLotLockVO vo);


    @GetMapping("stock-lot/listByIds")
    RestMessage<List<WmsInvStockLot>> getStockListByIds(@RequestParam(name = "ids") String[] ids);

    /**
     * 移库
     *
     * @param invStock 移库
     * @return 执行结果
     */
    @PostMapping("stock/v1/move")
    RestMessage moveStock(List<InvStockMove> invStock);

    /**
     * 取消移库
     *
     * @param cancel 移库信息
     * @return 执行结果
     */
    @PostMapping("stock/v1/move/cancel")
    RestMessage moveStockCancel(InvStockCancel cancel);

    /**
     * 移库确认
     *
     * @param check 移库单编码
     * @return 执行结果
     */
    @PostMapping("stock/v1/move/check")
    RestMessage moveStockCheck(InvStockCheckMove check);

    /**
     * 移位
     *
     * @param invStock 移位
     * @return 执行结果
     */
    @PostMapping("stock/v1/move/locator")
    RestMessage moveLocatorStock(List<InvStockMove> invStock);

    /**
     * 损溢-库存暂用
     *
     * @param invStock 损溢
     * @return 执行结果
     */
    @PostMapping("stock/v1/adjust")
    RestMessage adjustStock(@RequestBody List<InvStockAdjust> invStock);


    @PostMapping("stock/v1/adjustComfirm")
    RestMessage adjustStockComfirm(@RequestBody List<InvStockAdjust> invStock);

    /**
     * 损溢-库存修改
     *
     * @param check
     * @return
     */
    @PostMapping("stock/v1/adjust/check")
    RestMessage adjustStockCheck(@RequestBody InvStockCheck check);

    /**
     * 补货
     *
     * @param invStock 补货
     * @return 执行结果
     */
    @PostMapping("stock/v1/replenish")
    RestMessage<Object> replenishStock(List<InvStockMove> invStock);

    /**
     * 补货确认
     *
     * @param check 补货单编码
     * @return 执行结果
     */
    @PostMapping("stock/v1/replenish/check")
    RestMessage replenishStockCheck(InvStockCheckMove check);

    /**
     * 批量获取批次信息
     *
     * @param batchIds 批次号集合
     * @return 批次信息
     */
    @GetMapping("batch-number/v1/basic/list")
    RestMessage<List<BatchNumberListVO>> getBatchNumberBasicInfo(@RequestParam("batchIds") String[] batchIds);

    /**
     * 根据条件查询商品货位列表
     *
     * @param warehouseId  仓库
     * @param cargoOwnerId 货主
     * @param itemId       商品
     * @return 货位列表
     */
    @GetMapping("/stock-lot/v1/locators")
    RestMessage<List<StockLocatorDTO>> getItemLocators(@RequestParam("warehouseId") String warehouseId, @RequestParam("cargoOwnerId") String cargoOwnerId, @RequestParam("itemId") String itemId, @RequestParam("status") String status);

    /**
     * 查询多个商品可用库存信息
     *
     * @param qtyQueries 多个商品批次信息
     * @return 可用库存信息
     */
    @PostMapping("stock/v1/qty/avl-list")
    RestMessage<List<WmsInvStockQtyVO>> getAvailableQuantityList(@RequestBody List<WmsInvStockQtyQueryVO> qtyQueries);

    /**
     * 查询商品可用库存信息
     *
     * @param qtyQueries 多个商品批次信息
     * @return 可用库存信息
     */
    @GetMapping("stock/v1/qty/avl")
    RestMessage<List<WmsInvStockQtyVO>> getAvailableQuantity(@RequestParam Map<String, Object> qtyQueries);

    /**
     * 批号调整
     */

    @PostMapping("batch-number/v1/update")
    public RestMessage updateBatchNumber(@RequestBody ValidList<InvStockBatchNumberUpdate> batchNumbers);

    /**
     * 损溢取消
     *
     * @param stockCancel 损溢单编码
     * @return 执行结果
     */
    @PostMapping("stock/v1/adjust/cancel")
    public RestMessage adjustCancel(@RequestBody InvStockCancel stockCancel);

    /**
     * 取消养护预占
     *
     * @param cancel 养护信息
     * @return 执行结果
     */
    @PostMapping("stock/v1/maintain/cancel")
    RestMessage maintainCancel(InvStockCancel cancel);

    /**
     * 库存货权变更
     *
     * @param stockChanges 库存货权变更列表
     * @return 库存货权变更结果
     */
    @PostMapping("stock/v1/change")
    RestMessage<List<StockChangeResultVO>> change(@RequestBody @Validated ValidList<InvStockChange> stockChanges);

    /**
     * 货权转换确认
     *
     * @param check 货权转换编码
     * @return 执行结果
     */
    @PostMapping("stock/v1/change/check")
    @ApiOperation(value = "货权转换确认")
    public RestMessage changeStockCheck(@Validated @RequestBody InvStockCheckMove check);

    /**
     * 货权转换取消
     *
     * @param stockCancel 货权转换编码
     * @return 执行结果
     */
    @PostMapping("stock/v1/change/cancel")
    @ApiOperation(value = "货权转换取消")
    public RestMessage changeCancel(@RequestBody InvStockCancel stockCancel);

    /**
     * 补货取消取消
     *
     * @param stockCancel 补货单明细编码
     * @return 执行结果
     */
    @PostMapping("stock/v1/replenish/cancel")
    @ApiOperation(value = "补货取消")
    RestMessage<Object> replenishCancel(@RequestBody InvStockCancel stockCancel);

    @PostMapping("batch-number/v1/gen")
    RestMessage<List<InvStockBatchNumberResult>> genBatchNumber(@RequestBody ValidList<InvStockBatchNumber> batchNumbers);

    @GetMapping("/stock/limit-locator")
    RestMessage<List<StockLocatorDTO>> getLocatorIdLimit(@RequestParam Map<String, Object> paramsVO);

    /**
     * 查询立库托盘商品库存信息
     *
     * @param enterpriseId  企业标识
     * @param warehouseId   仓库id
     * @param cargoOwnerId  货物所有者id
     * @param containerCode 容器代码
     * @param pageNum       页面num
     * @param pageSize      页面大小
     * @return {@link RestMessage}<{@link Page}<{@link DeviceContainerItemStockDTO}>>
     */
    @GetMapping("/stock-lot/getDeviceContainerItemStockPage")
    RestMessage<Page<DeviceContainerItemStockDTO>> getDeviceContainerItemStockPage(@RequestParam(value = "enterpriseId", required = false) String enterpriseId, @RequestParam("warehouseId") String warehouseId, @RequestParam("cargoOwnerId") String cargoOwnerId, @RequestParam("containerCode") String containerCode, @RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize);

    /**
     * 查询商品库存-根据托盘号
     * @param wmsInvStockLot wmsInvStockLot
     * @return RestMessage<Page<WmsInvStockLot>> rest
     */
    @PostMapping("/stock/queryStockList")
    RestMessage<List<WmsInvStockLot>> queryStockList(@RequestBody WmsInvStockLot wmsInvStockLot);

    @PostMapping("/stock/pre/v1/update/locator")
    RestMessage<String> updateLocator(
            @RequestBody List<Map<String, Object>> updateLocatorVos
    );

    /**
     * 通用 调用第三方接口，需要在通用参照中的integrationUrl中配置
     * @param vo {@link AskIntegrationVo}
     * @return {@link RestMessage}<{@link Object}>
     */
    @PostMapping("/integration/v1/ask")
    RestMessage<Object> askIntegration(@RequestBody AskIntegrationVo vo);

    @PostMapping("/stock-lot/v1/byContainerCode")
    @ApiOperation("根据托盘查询库存信息")
    RestMessage<Map<String, List<WmsInvStockQtyVO>>> listStockLotByContainerCode(
            @RequestBody ByContainerVo vo
    );
}
