package com.prolog.eis.service.feign;

import com.prolog.eis.core.dto.area.PortInfoAreaDto;
import com.prolog.eis.core.dto.inboundallot.InboundAllotAreaParamDto;
import com.prolog.eis.core.dto.route.*;
import com.prolog.eis.core.model.base.area.WhArea;
import com.prolog.eis.core.model.base.locator.WhLocator;
import com.prolog.eis.core.model.biz.carry.CarryTask;
import com.prolog.eis.core.model.biz.route.ContainerLocation;
import com.prolog.eis.dto.route.AreaCarryTaskDto;
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.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

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

/**
 * @author dengj
 * @version 1.0
 * @date 2022/10/19 17:57
 */
public interface RouteFeignService {

    /**
     * 创建搬运任务
     * @param descri 任务描述
     * @param carryTask 搬运参数
     * @throws Exception
     */
    void savePath(String descri, CarryTask carryTask) throws Exception;


    /**
     * 创建搬运任务
     * @param containerNo
     * @param taskType
     * @param startRegion
     * @param startLocation
     * @param endRegion
     * @param endLocation
     * @param businessType
     * @param height
     * @param describe
     */
    void createCarryTask(String containerNo, Integer taskType, String startRegion, String startLocation, String endRegion,String endLocation, String businessType,Integer height,String describe,String businessProperty) throws Exception;
    void createCarryTask(String containerNo, Integer taskType, String startRegion, String startLocation, String endRegion,String endLocation, String businessType,Integer height,String describe,String businessProperty,String expand1,String expand2,String expand3) throws Exception;

    CarryTask setCarryTask(String containerNo, Integer taskType, String startRegion, String startLocation, String endRegion,String endLocation, String businessType,Integer height,String describe,String businessProperty,String expand1,String expand2,String expand3) throws Exception;

    /**
     * 搬运任务接口批量生成
     * @param carryTasks
     */
    void createBatchCarry(List<CarryTask> carryTasks) throws Exception;

    /**
     * 搬运任务接口生成并执行
     */
    RestMessage<String> creatCarryTaskAndExecuteNotTx(CarryTask carryTask) throws Exception;


    /**
     * 创建容器点位信息.
     * @param itemContainerReqDto 容器信息
     */
    void createItemContainer(ItemContainerReqDto itemContainerReqDto) throws Exception;

    /**
     * 创建容器点位信息.
     */
    void createItemContainer(String locationNo,String containerNo,String containerType,String businessProperty) throws Exception;

    List<ContainerLocation> findContainerLocationListByContainerList(List<String> containerList) throws Exception;



    /**
     * 入库找区域
     *
     * @param inboundAllotAreaParamDto
     * @return
     * @throws Exception
     */
    List<PortInfoAreaDto> getAllotAreaNew(InboundAllotAreaParamDto inboundAllotAreaParamDto) throws Exception;

    /**
     * 清除容器点位信息.
     * @param containerNo
     */
    void containerOffShelf(String containerNo) throws Exception;


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

    /**
     * 获取区域总货位数.
     * @param areaNo 区域传空，获取所有
     * @return
     */
    Map<String, Integer> findTotalCountByAreaNo(String areaNo) throws Exception;


    /**
     * 获取区域详情
     * @return
     */
    List<WhArea> getAreaByAreaNos(List<String> areaNos) throws Exception;


    /**
     * 获取所有搬运任务回告.
     * @return
     */
    List<CarryTaskCallbackDto> getAllCallBack() throws Exception;


    /**
     * 搬运任务转历史.
     */
    void toCallbackHis(String carryTaskId) throws Exception;


    /**
     * 根据容器编号查询点位
     * @return
     */
    ContainerLocation seachLocationNo(Map<String, Object> containerMap) throws Exception;


    /**
     * 容器移位数
     * @param containerNos
     * @return
     * @throws Exception
     */
    Map<String, Integer> findLocationDeptByContainerList(List<String> containerNos) throws Exception;
    /**
     * 按容器号批量查询容器信息
     * @param containerNos
     * @return
     */
    Map<String, ContainerLocationVo> findLocationByContainerListNew(List<String> containerNos) throws Exception;


    /**
     * 按容器号批量查询容器信息
     * @param containerNos
     * @return
     */
    List<ContainerLocationVo> findLocationByContainerList(List<String> containerNos) throws Exception;

    /**
     * 按容器号批量查询容器信息不校验结果是否为空
     * @param containerNos
     * @return
     */
    List<ContainerLocationVo> findLocationByContainerListNotVail(List<String> containerNos) throws Exception;

    /**
     * 根据点位获取任务数量
     * @param list 查询点位
     * @return key:点位，value:任务数
     */
    Map<String, Integer> getLocNum(List<String> list) throws Exception;

    /**
     * 根据区域查询任务数
     * @param areaNos 查询区域
     * @return key:点位，value:任务数
     */
    Map<String, Integer> getSxkTaskByAreaNos(AreaTaskReqDto areaNos) throws Exception;

    /**
     * 根据起点/终点区域查询容器
     * @param areaNos
     * @return key 容器号  value 容器号对应的区域
     */
    List<ContainerLocation>  findContainerLocationByTargetAreaNos(List<String> areaNos)  throws Exception;

    List<ContainerLocation>  findContainerLocationByAreaNos(List<String> areaNos)  throws Exception;


    /**
     * 条件查询搬运任务
     * @param query
     * @return
     */
    List<CarryTask> listCarryTaskByParam(CarryTask query) throws Exception;

    /**
     * 根据点位查询位置信息
     * @param locationNo
     * @return
     */
    LocationInfoDto locationInfo(String locationNo) throws Exception;


    /**
     * 修改容器点位
     * @param containerNo
     * @throws Exception
     */
    void updateLocByPalletNo(String containerNo, String currentAreaNo, String currentLoc) throws Exception;


    RestMessage<String> checkContainer(Map<String, Object> param) throws Exception;

    ContainerLocationDto findContainerInfoByLocation(Map<String, Object> param) throws Exception;

    boolean checkCarryTask(String locationNo) throws Exception;
    boolean checkContainer(String locationNo) throws Exception;

    /**
     * 查待分区域详情
     * @param dswRequestDto
     * @return
     */
    List<DswAreaDto> queryDswAreaList(DswRequestDto dswRequestDto) throws Exception;


    /**
     * 检查1个区域是否有空货位可以入
     * @return
     */
    Boolean checkAreaIn(String areaNo) throws Exception;


    /**
     * 根据托盘集合查询搬运任务
     * @param containerList
     * @return
     */
    List<CarryTask> findCarryTaskListByContainerList(List<String> containerList) throws Exception;


    /**
     * 根据区域集合查询可用货位 freeCount可用数量
     * @param areaList
     * @return
     */
    List<AreaLocationCountDto> queryAreaLocationCountDtoList(List<String> areaList) throws Exception;

    /**
     * 根据货位查询货位信息
     * @return
     */
    List<WhLocator> getLocatorByLocation(List<String> list);

    /**
     * 查询某些区域的空闲托盘
     * @return
     */
    List<ContainerLocation> findFreeContainerByAreaNo(String areaNos) throws Exception;


    /**
     * 容器下架不管库存
     * @param containerNo
     */
    void containerOffShelfNoStore(String containerNo) throws Exception;


    /**
     * 通过区域根据区域查询出、入数量
     * @param areaNoList
     * @return
     */
    List<AreaInOutCountDto> queryAreaInOutCount(List<String> areaNoList) throws Exception;

    /**
     * 通过区域查询小车数量
     * @param areaNos
     * @return
     */
    List<AreaTaskDto> getAreaDetail(List<String> areaNos)throws Exception;

    List<AreaCarryTaskDto> queryAreaCarryTask(List<String> areaNos)throws Exception;

    /**
     * 通过当前区域和目标区域查询路径是否可达
     * @return
     */
    boolean checkDirectionIsReachable(String sourceAreaNo, String targetAreaNo) throws Exception ;

    boolean createTaskWithAngle(CreateCarryTaskDto carryTask) throws Exception;

    boolean creatCarryTaskWithAngleAndExecute(CreateCarryTaskDto createCarryTaskDto) throws Exception;

    void updateWorkStatus(String containerNo) throws Exception;
}
