package com.prolog.eis.feign;

import com.prolog.eis.core.dto.area.PortInfoAreaDto;
import com.prolog.eis.core.dto.inboundallot.InboundAllotAreaParamDto;
import com.prolog.eis.core.dto.mcs.StationDto;
import com.prolog.eis.core.dto.route.*;
import com.prolog.eis.core.model.biz.carry.CarryTask;
import com.prolog.eis.core.model.biz.carry.CarryTaskCallback;
import com.prolog.eis.core.model.biz.route.ContainerLocation;
import com.prolog.eis.router.dto.AreaTaskDto;
import com.prolog.eis.router.vo.ContainerLocationVo;
import com.prolog.framework.common.message.RestMessage;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

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

@FeignClient(value = "${prolog.service.route:service-ai-eis-route}")
public interface PlgFeignRouteClient {

    /**
     * 入库找区域
     *
     * @param dto
     * @return
     * @throws Exception
     */
    @RequestMapping(method = RequestMethod.POST, value = "/api/v1/route/inbound/findAreaNew")
    RestMessage<List<PortInfoAreaDto>> getAllotAreaNew(@RequestBody InboundAllotAreaParamDto dto) throws Exception;


    /**
     * 查询所有搬运任务回告数据
     */
    @RequestMapping(method = RequestMethod.POST, value = "/api/v1/route/carry/findAllCallback")
    RestMessage<List<CarryTaskCallbackDto>> findAllCallback();

    /**
     * 回告任务转历史
     *
     * @param carryTaskCallback 搬运任务
     * @return
     */
    @PostMapping("/api/v1/route/carry/toCallbackHisNotTx")
    RestMessage<String> toCallbackHis(@RequestBody CarryTaskCallback carryTaskCallback);

    @ApiOperation(value = "根据容器集合查询位置以及货位", notes = "根据容器集合查询位置以及货位")
    @PostMapping("/api/v1/route/location/findLocationByContainerList")
    RestMessage<List<ContainerLocationVo>> findLocationByContainerList(@RequestBody List<String> containerList);

    @ApiOperation(value = "通过区域查询容器任务", notes = "通过区域查询容器任务")
    @PostMapping("/api/v1/route/location/areaContainerCount")
    RestMessage<List<AreaContainerCountDto>> areaContainerCount(@RequestBody List<AreaOrJointPointDto> areaOrJointPointDto);

    @ApiOperation(value = "创建搬运任务", notes = "创建搬运任务")
    @PostMapping("/api/v1/route/carry/createTask")
    RestMessage<String> createCarry(@RequestBody CarryTask carryTask);

    @ApiOperation(value = "搬运任务接口批量生成", notes = "搬运任务接口批量生成")
    @PostMapping("/api/v1/route/carry/createBatchCarry")
    RestMessage<String> createBatchCarry(@RequestBody List<CarryTask> carryTaskList);

    @ApiOperation(value = "根据容器编号查询点位", notes = "根据容器编号查询点位")
    @PostMapping("/api/v1/route/location/seachLocationNo")
    RestMessage<List<ContainerLocation>> seachLocationNo(@RequestBody Map<String,Object> params);

    /**
     * 生成容器点位信息
     *
     * @param reqDto
     * @return
     * @throws Exception
     */
    @ApiOperation(value = "商品点位容器创建", notes = "空托点位容器创建")
    @PostMapping("/api/v1/route/item/createItemContainer")
    RestMessage<String> createItemContainer(@RequestBody ItemContainerReqDto reqDto) throws Exception;


    /**
     * 根据终点区域查询任务
     *
     * @param areaNos
     * @return
     */
    @PostMapping("/api/v1/route/location/findContainerLocationByTargetAreaNos")
    RestMessage<List<ContainerLocation>> findContainerLocationByTargetAreaNos(@RequestBody List<String> areaNos);

    /**
     * 通过区域根据区域查询出、入数量
     *
     * @param areaNoList
     * @return
     */
    @PostMapping("/api/v1/route/containerarea/queryAreaInOut")
    RestMessage<List<AreaInOutCountDto>> queryAreaInOutCount(@RequestBody List<String> areaNoList);

    /**
     * String id = String.valueOf(param.get("id"));
     * Map<String, Object> map = (Map<String, Object>) param.get("map");
     *
     * @param param
     * @return
     */
    @PostMapping("/api/v1/route/location/updateLoc")
    RestMessage<String> updateLoc(@RequestBody Map<String, Object> param);


    /**
     * 判断当前点位是否有容器
     *
     * @param json
     * @return
     */
    @PostMapping("/api/v1/route/location/checkContainerNew")
    RestMessage<String> checkContainerNew(@RequestBody String json);

    @ApiOperation(value = "查询托盘搬运任务", notes = "查询托盘搬运任务")
    @PostMapping("/api/v1/route/carry/getContainerCarry")
    public RestMessage<List<CarryTaskDto>> getContainerCarry(@RequestBody String json);
    /**
     *  根据区域查询任务
     *
     * @param areaNos
     * @return
     */
    @PostMapping("/api/v1/route/location/findContainerLocationByAreaNos")
    RestMessage<List<ContainerLocation>> findContainerLocationByAreaNos(@RequestBody List<String> areaNos);
    /**
     * 查询某些区域的托盘数量,，返回Map对象Key=区域，Value=托盘数量
     *
     * @param areaNos 区域多个以英文,分隔
     * @return
     */
    @PostMapping("/api/v1/route/location/findAreaNoAndContainerCountMap")
    RestMessage<Map<String, StationDto>> findAreaNoAndContainerCountMap(@RequestParam(value = "areaNos") String areaNos);

    /**
     * 根据托盘集合查询搬运任务
     *
     * @param containerList
     * @return
     */
    @PostMapping("/api/v1/route/carry/findCarryTaskListByContainerList")
    RestMessage<List<CarryTask>> findCarryTaskListByContainerList(@RequestBody List<String> containerList);

    /**
     * 容器下架（不管库存）
     * param json
     */
    @PostMapping("/api/v1/route/location/containerOffShelfNoStore")
    RestMessage<String> containerOffShelfNoStore(@RequestBody Map<String, Object> containerMap);

    /**
     * 查待分区域详情
     *
     * @param dswRequestDto
     * @return
     */
    @PostMapping("/api/v1/route/carry/queryDswAreaList")
    RestMessage<List<DswAreaDto>> queryDswAreaList(@RequestBody DswRequestDto dswRequestDto);


    /**
     * 根据区域集合查询可用货位 freeCount可用数量
     *
     * @param areaList
     * @return
     */
    @PostMapping("/api/v1/route/containerarea/queryAreaLocationCountDtoList")
    RestMessage<List<AreaLocationCountDto>> queryAreaLocationCountDtoList(@RequestBody List<String> areaList);

    /**
     * 查询某些区域的空闲托盘
     * @param areaNos
     * @return
     */
    @PostMapping("/api/v1/route/location/findFreeContainerByAreaNo")
    RestMessage<List<ContainerLocation>> findFreeContainerByAreaNo(@RequestParam(value = "areaNos", required = false) String areaNos);



    /**
     * 通过多个托盘查询点位信息
     *
     * @param containerList
     * @return
     */
    @PostMapping("/api/v1/route/location/findContainerLocationListByContainerList")
    RestMessage<List<ContainerLocation>> findContainerLocationListByContainerList(@RequestBody List<String> containerList);

    /**
     * 点位清除
     * @return 网络传输对象
     */
    @RequestMapping(method = RequestMethod.POST,value ="/api/v1/route/location/containerOffShelfNotTx")
    RestMessage<String> containerOffShelf(@RequestBody Map<String,Object> params) throws Exception;


    /**
     * 根据点位获取任务数量
     * @param list 查询点位
     */
    @PostMapping("/api/v1/route/location/getLocNum")
    RestMessage<List<AreaTaskRespDto>> getLocNum(@RequestBody List<String> list);

    /**
     * 根据区域查询任务数
     * @param areaNos 查询区域
     */
    @PostMapping("/sxktask/getSxkTaskByAreaNos")
    RestMessage<List<AreaTaskRespDto>> getSxkTaskByAreaNos(@RequestBody AreaTaskReqDto areaNos);


    /**
     * 条件查询搬运任务
     * @param query
     * @return
     */
    @PostMapping("/api/v1/route/carry/listCarryTaskByParam")
    RestMessage<List<CarryTask>> listCarryTaskByParam(@RequestBody CarryTask query);

    /**
     * 根据点位查询位置信息
     */
    @PostMapping("/api/v1/route/location/locationInfo")
    RestMessage<String> locationInfo(@RequestBody Map<String,Object> json);


    /**
     * 修改容器点位
     * @param paramMap key:palletNo 容器号, map 点位信息
     * @param
     * @return
     */
    @PostMapping("/api/v1/route/location/updateLocByPalletNo")
    RestMessage<String> updateLocByPalletNo(@RequestBody Map<String, Object> paramMap);


    /**
     * 检查1个区域是否有空货位可以入
     * @return
     */
    @PostMapping("/api/v1/route/containerarea/check-area-in")
    RestMessage<Boolean> checkAreaIn(@RequestParam(value = "areaNo") String areaNo);


    /**
     * 判断当前点位是否有容器
     */
    @PostMapping("/api/v1/route/location/checkContainer")
    RestMessage<String> checkContainer(@RequestBody Map<String,Object> json);


    /**
     * 判断有无结束点位为传入点位的任务
     */
    @PostMapping("/api/v1/route/location/checkCarryTask")
    RestMessage<String> checkCarryTask(@RequestBody Map<String,Object> json);


    @PostMapping("/api/v1/route/location/findContainerInfoByLocation")
    RestMessage<String> findContainerInfoByLocation(@RequestBody Map<String,Object> json);

    /**
     * 查询区域的小车数量
     * @param areaNos
     * @return
     */
    @PostMapping("/api/v1/route/carry/getAreaDetail")
    RestMessage<List<AreaTaskDto>> getAreaDetail(@RequestBody List<String> areaNos);

    /**
     * 通过当前区域和目标区域查询路径是否可达
     * @return
     */
    @PostMapping("/api/v1/route/direction/checkDirectionIsReachable")
    RestMessage checkDirectionIsReachable(@RequestParam(value = "sourceAreaNo", required = false) String sourceAreaNo,@RequestParam(value = "targetAreaNo", required = false) String targetAreaNo);

    /**
     * 根据终点区域集合查询搬运任务
     *
     * @param endRegionList
     * @return
     */
    @PostMapping("/api/v1/route/carry/findCarryTaskListByEndRegionList")
    RestMessage<List<CarryTask>> findCarryTaskListByEndRegionList(List<String> endRegionList);
}
