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

import com.prolog.cs.basic.warehouse.model.BaseWmsWarehouseLocator;
import com.prolog.cs.basic.warehouse.model.BaseWmsWhContainer;
import com.prolog.cs.biz.inbound.service.impl.CommonRemoteService;
import com.prolog.cs.biz.inbound.vo.StrategyQueryVO;
import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.core.pojo.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 公共请求处理 如上传,下载,打印 远程调用等等等
 * 
 * @author Xiong
 *
 */
@Api(tags = "公共请求")
@RestController
@RequestMapping("/common")
public class CommonRemoteController {

	@Resource
	private CommonRemoteService commonRemoteService;

	/**
	 * 获取货位
	 */
	@ApiOperation("获取货位")
	@GetMapping("/getLocatorList")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "warehouseLocatorCode", value = "库位编码", required = false, dataType = "String"),
			@ApiImplicitParam(name = "warehouseLocatorName", value = "库位名称", required = false, dataType = "String"),
			@ApiImplicitParam(name = "warehouseId", value = "仓库id", required = false, dataType = "String"),
			@ApiImplicitParam(name = "pageNum", value = "当前页码", required = false, dataType = "Integer"),
			@ApiImplicitParam(name = "pageSize", value = "每页数量", required = false, dataType = "Integer") })
	public RestMessage<Object> getLocatorList(String warehouseId, String warehouseLocatorCode,
			String warehouseLocatorName, Integer pageSize, Integer pageNum) {
		return RestMessage.newInstance(true, "getLocatorList", commonRemoteService.getLocatorList(warehouseId,
				warehouseLocatorCode, warehouseLocatorName, pageNum, pageSize));
	}

	/**
	 * 获取容器
	 */
	@ApiOperation(value = "获取容器")
	@ApiImplicitParams({ @ApiImplicitParam(name = "warehouseId", value = "仓库id", required = true, dataType = "String"),
			@ApiImplicitParam(name = "containerCode", value = "容器编码", required = false, dataType = "String"),
			@ApiImplicitParam(name = "containerType", value = "容器类型", required = false, dataType = "String"),
			@ApiImplicitParam(name = "pageNum", value = "当前页码", required = false, dataType = "Integer"),
			@ApiImplicitParam(name = "pageSize", value = "每页数量", required = false, dataType = "Integer") })
	@GetMapping("/getContainerPage")
	public RestMessage<Page<BaseWmsWhContainer>> getContainerPage(String containerCode, String containerType,
			String warehouseId, Integer pageSize, Integer pageNum) {
		return RestMessage.newInstance(true, "getContainerPage",
				commonRemoteService.getContainerPage(containerCode, containerType, warehouseId, pageSize, pageNum));
	}

	/**
	 * 根据策略获取货位
	 */
	@ApiOperation(value = "策略获取货位")
	@PostMapping("/getStrategyLocatorList")
	public RestMessage<List<BaseWmsWarehouseLocator>> getStrategyLocatorList(
			@RequestBody StrategyQueryVO strategyQueryVO) {
		return RestMessage.newInstance(true, "getStrategyLocatorList",
				commonRemoteService.getStrategyLocatorList(strategyQueryVO));
	}
	
	/**
	 * 货位限定(推荐库区)
	 */
	@ApiOperation(value = "策略获取库区")
	@PostMapping("/getStrategyAreaList")
	public RestMessage<List<Map<String,Object>>> getStrategyAreaList(
			@RequestBody StrategyQueryVO strategyQueryVO) {
		return RestMessage.newInstance(true, "getStrategyLocatorList",
				commonRemoteService.getStrategyAreaList(strategyQueryVO));
	}
	
}
