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

import com.prolog.cs.biz.outbound.model.vo.InfTaskOutBackVO;
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.model.WmsInvBatchNumbers;
import com.prolog.upcloud.base.inventory.model.WmsInvStockPre;
import com.prolog.upcloud.base.inventory.vo.*;
import io.swagger.annotations.ApiOperation;
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;
import java.util.Set;

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

	/**
	 * 查询商品所有库位库存
	 * @param cargoOwnerId
	 * @param warehouseId
	 * @param itemId
	 * @param pageSize
	 * @param pageNum
	 * @return
	 */
	@GetMapping("/locator/stocks")
	RestMessage<Page<WmsInvStockLotVO>> queryItemInvStockLotList(@RequestParam(value = "cargoOwnerId") String cargoOwnerId,
																 @RequestParam(value = "warehouseId") String warehouseId,
																 @RequestParam(value = "itemId") String itemId,
																 @RequestParam(value = "pageSize")Integer pageSize,
																 @RequestParam(value = "pageNum") Integer pageNum
	);

    /**
     * 创建波次下发任务
     *
     * @param wavesIds
     * @return
     */
    @PostMapping("/wave")
    void createWaveByID(@RequestBody List<String> wavesIds);

	@PostMapping("/stock/v1/out")
	RestMessage outStock(@RequestBody ValidList<InvStockOut> invStock);

	@PostMapping("/stock/v1/out/check")
	RestMessage outStockCheck(@RequestBody InvStockCheckOut invStockCheck);

	@PostMapping("/stock/v2/out/check")
	RestMessage outPartStockCheck(@RequestBody InvStockPartCheckOut invStockCheck);

	@PostMapping("/stock/v1/out/adjust")
	RestMessage redAdjustStock(@RequestBody ValidList<InvStockOut> invStock);

	@PostMapping("/stock/pre/v1/queryInvStockPre")
	List<WmsInvStockPre> queryInvStockPreList(@RequestBody WmsInvStockPre wmsInvStockPre);

	/**
	 * 查询商品库存批次基础信息列表
	 * @param batchIds
	 * @return
	 */
	@GetMapping("/batch-number/v1/basic/list")
	RestMessage<List<BatchNumberListVO>> getBatchNumberBasicInfo(@RequestParam("batchIds") String[] batchIds);

	/**
	 * 出库取消
	 * @return
	 */
	@PostMapping("/stock/v1/out/cancel")
	public RestMessage outCancel(@RequestBody InvStockCancelOut stockCancel);

	/**
	 * 补货取消
	 *
	 * @param stockCancel 移库单编码
	 * @return 执行结果
	 */
	@PostMapping("/stock/v1/replenish/cancel")
	public RestMessage replenishCancel(@RequestBody InvStockCancel stockCancel);

	/**
	 * 任务试算
	 *
	 * @param invStockWave invStockWave
	 * @return 执行结果
	 */
	@PostMapping("/stock/v1/waveTaskTrial")
	public String waveTaskTrial(@RequestBody InvStockWave invStockWave);

	/**
	 * 任务试算，注意：该接口逻辑复杂，不能再高频，主流程使用
	 *
	 * @param invStockWave invStockWave
	 * @return 执行结果
	 */
	@PostMapping("/stock/v1/tryWaveTask")
	public RestMessage<StockWaveResultVO> tryWaveTask(@RequestBody InvStockWave invStockWave);

	/**
	 * 批量查询批次信息
	 *
	 * @param itemId
	 * @return
	 */
	@PostMapping("/batch-number/v1/getBatchInfosByItems")
	RestMessage<List<WmsInvBatchNumbers>> getBatchInfosByItems(@RequestBody String[] itemId);

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

	@PostMapping("stock/v1/qty/avl-list")
	public RestMessage<List<WmsInvStockQtyVO>> getAvailableQuantityList(@RequestBody List<WmsInvStockQtyQueryVO> qtyQueries);

	@PostMapping("stock/v1/queryDeviceStockList")
	public RestMessage<List<WmsInvStockQtyVO>> queryDeviceStockList(@RequestBody WmsInvStockQtyQueryVO qtyQueryVO);

	@PostMapping("stock/v2/queryDeviceStockList")
	public RestMessage<List<WmsInvStockQtyVO>> queryDeviceStockListV2(@RequestBody WmsInvStockQtyQueryVO qtyQueryVO);

	@PostMapping("stock/v3/queryDeviceStockList")
	public RestMessage<List<WmsInvStockQtyVO>> queryDeviceStockListV3(@RequestBody WmsInvStockQtyQueryVO qtyQueryVO);

	@PostMapping("stock/v1/qty/quantityList")
	public RestMessage<List<WmsInvStockQtyVO>> getQuantityList(@RequestBody QuantityListVo qtyQueries);

	//快速获取多个商品批次库存-不获取商品名等显示字段
	@PostMapping("v1/qty/avl-list-quick")
	public RestMessage<List<WmsInvStockQtyVO>> getAvailableQuantityListQuick(@RequestBody List<WmsInvStockQtyQueryVO> qtyQueries);

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

	/**
	 * 回传托盘拣货明细信息，更新库存预占
	 *
	 * @param recordList 完成单据的货位信息集合
	 * @return RestMessage 执行结果
	 */
	@PostMapping("/stock/v1/infTaskOutBack")
	public RestMessage infTaskOutBack(@RequestBody List<InfTaskOutBackVO> recordList);

	@PostMapping("/integration/v1/ask")
	public RestMessage<?> askIntegration(@RequestBody AskIntegrationVo vo);

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

	@ApiOperation("查询已存在库存及补货预占的货位")
	@PostMapping("stock/v1/queryExistsLocatorList")
	public Set<String> queryExistsLocatorList(@RequestBody Map<String, Object> param);

	@ApiOperation("修改预占表中的托盘号->大货位预占后立库被动补货无托盘导致的错误")
	@PostMapping("/stock/pre/v1/update/container")
	public RestMessage<String> updateContainerCode(
			@RequestBody List<UpdateLocatorVo> updateLocatorVos
	);

	/**
	 * 分页获取单个商品库存列表
	 * @param cargoOwnerId
	 * @return
	 */
	@GetMapping("/stock/v1/qty/avl-page")
	RestMessage<Page<WmsInvStockQtyVO>> getAvailableQuantityPage(@RequestParam(value = "cargoOwnerId") String cargoOwnerId,
																 @RequestParam(value = "warehouseId") String warehouseId,
																 @RequestParam(value = "billId") String billId,
																 @RequestParam(value = "billDId") String billDId,
																 @RequestParam(value = "itemId") String itemId,
																 @RequestParam(value = "manufacturerLotNum") String manufacturerLotNum,
																 @RequestParam(value = "locatorId") String locatorId
																 );

	/**
	 * 批量查询批次信息
	 *
	 * @param manufacturerLotNums
	 * @return
	 */
	@PostMapping("/batch-number/get-by-manufacturerLotNums")
	RestMessage<List<WmsInvBatchNumbers>> getListByManufacturerLotNums( @RequestParam(value = "manufacturerLotNums") String manufacturerLotNums);
}
