package com.prolog.eis.feign;

import com.prolog.eis.core.dto.area.PortInfoAreaDto;
import com.prolog.eis.core.model.base.area.AreaReserve;
import com.prolog.eis.core.model.ctrl.across.CarAcrossConfig;
import com.prolog.eis.core.model.ctrl.across.CarAcrossDirectionConfig;
import com.prolog.eis.core.model.ctrl.area.DeviceAreaConfig;
import com.prolog.eis.core.model.ctrl.area.PortInfo;
import com.prolog.eis.core.model.ctrl.area.StationDoneArea;
import com.prolog.eis.core.model.ctrl.area.TemplateConfigure;
import com.prolog.eis.core.model.ctrl.basis.DispatchSwitch;
import com.prolog.eis.core.model.ctrl.basis.ProbeTaskConfig;
import com.prolog.eis.core.model.ctrl.carry.AutoCarryConfig;
import com.prolog.eis.core.model.ctrl.ctu.CtuCoefficient;
import com.prolog.framework.common.message.RestMessage;
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;

/**
 * @Author clarence_she
 * @Date 2021/9/16
 **/
@FeignClient(value = "${prolog.service.control:upcloud-base-wh-control}")
public interface BizControlServiceClient {

    @PostMapping(value = "/eisAutoCarry/updateById")
    RestMessage<String> updateAutoCarryById(@RequestBody Map<String, Object> param) throws Exception;

    @GetMapping("/sxcardirection/sel-byStatus")
    RestMessage<List<String>> selByStatus(@RequestParam(value = "status", required = false) Integer status);

    //源区域，目标区域，提升机编号查询结果
    @PostMapping("/sxcardirection/sx-dictionary-list")
    RestMessage<List<CarAcrossDirectionConfig>> sxDictionaryList(@RequestParam(value = "sourceAreaNo", required = false) String sourceArea,
                                                                 @RequestParam(value = "targetAreaNo", required = false) String tarArea,
                                                                 @RequestParam(value = "hoistNo", required = false) String hoistNo);

    @PostMapping("/eisSxCarAcrossConfigService/layer/list")
    RestMessage<List<CarAcrossConfig>> listCarAcrossConfig();

    @PostMapping("/registry/value")
    RestMessage<String> getValueByCode(@RequestParam(value = "regCode", required = false) String regCode);

    @PostMapping("/sxcardirection/list")
    RestMessage<List<CarAcrossDirectionConfig>> listCarAcrossDirection();

    //查询可发起探测配置
    @PostMapping("/probeTaskConfig/preProbeTask")
    RestMessage<List<ProbeTaskConfig>> preProbeTask();

    //查询要修复的探测配置
    @PostMapping("/probeTaskConfig/fixedProbeTask")
    RestMessage<List<ProbeTaskConfig>> fixedProbeTask();

    //更新探测配置
    @PostMapping("/probeTaskConfig/updateConfig")
    RestMessage<?> updateConfig(@RequestBody String json);

    /**
     * 根据开关编码获取开关
     *
     * @param switchCode
     * @return
     */
    @GetMapping("/dispatchswitch/getSwitchByCode")
    RestMessage<Boolean> getSwitchByCode(@RequestParam(value = "switchCode", required = true) String switchCode);

    /**
     * EIS根据开关编码获取开关信息
     * @param json
     * @return
     * @throws Exception
     */
    @PostMapping("/dispatchswitch/getSwitchByCode")
    RestMessage<DispatchSwitch> getSwitch(@RequestBody String json) throws Exception;

    /**
     * 根据条件查询探测配置
     *
     * @param json
     * @return
     */
    @PostMapping("/probeTaskConfig/findProbeTaskConfig")
    RestMessage<ProbeTaskConfig> findProbeTaskConfig(@RequestBody String json);

    /**
     * 根据条件获取自动搬运配置
     *
     * @param param
     * @return
     */
    @PostMapping(value = "/eisAutoCarry/listByMap")
    RestMessage<List<AutoCarryConfig>> listAutoCarryByMap(@RequestBody Map<String, Object> param);

    /**
     * 根据条件获取作业位完成区域
     *
     * @param param
     * @return
     */
    @PostMapping(value = "/eisStationDoneArea/listByMap")
    RestMessage<List<StationDoneArea>> listStationDoneAreaByMap(@RequestBody Map<String, Object> param);

    /**
     * 根据条件查询设备区域信息
     *
     * @param param
     * @return
     */
    @PostMapping("/deviceArea/listByParam")
    RestMessage<List<DeviceAreaConfig>> listByParam(@RequestBody Map<String, Object> param);

    /**
     * 根据参数获取出入口资料
     *
     * @param param
     * @return
     */
    @PostMapping("/eisPortInfoService/getPortByParam")
    RestMessage<List<PortInfo>> getPortByParam(@RequestBody Map<String, Object> param);

    /**
     * 根据编号获取出入口配置
     *
     * @param portNo
     * @return
     */
    @PostMapping("/eisPortInfoAreaService/getPortAreaByPortNo")
    RestMessage<List<PortInfoAreaDto>> getPortAreaByPortNo(@RequestParam("portNo") String portNo);

    /**
     * 根据参数获取区域预留货位
     * @param param
     * @return
     */
    @PostMapping("/eisAreaReserve/listAreaReserveByParam")
    RestMessage<List<AreaReserve>> listAreaReserveByParam(@RequestBody Map<String, Object> param);

    @ApiOperation(value = "EIS根据区域集合查询预留货位数")
    @PostMapping("/searchApi/areaReserveByNos")
    RestMessage<List<AreaReserve>> areaReserveByNos(@RequestBody List<String> areaNos);

    @PostMapping("/eisTemplateConfigure/findTemplateConfigure")
    RestMessage<TemplateConfigure> findTemplateConfigure(@RequestBody String areaNo);

    /**
     * 查询CTU计算系数
     * @return
     */
    @PostMapping("/eisCtuCoefficient/findCtuCoefficientList")
    RestMessage<List<CtuCoefficient>> findCtuCoefficientList();
}
