package net.northking.cctp.executePlan.feign;

import io.swagger.annotations.ApiOperation;
import net.northking.cctp.common.feign.FeignCctpConfig;
import net.northking.cctp.common.http.ResultWrapper;
import net.northking.cctp.executePlan.dto.planBatch.AppDetailDto;
import net.northking.cctp.executePlan.dto.planBatch.SceneCaseStopDto;
import net.northking.cctp.executePlan.dto.planEntrust.DeviceListDto;
import net.northking.cctp.executePlan.dto.planEntrust.EngineInfoListDto;
import net.northking.cctp.executePlan.dto.planSceneCase.AtuSceneNextNodeDto;
import net.northking.cctp.executePlan.dto.planSceneCase.AtuSceneNodeExecDto;
import net.northking.cctp.executePlan.dto.planSceneCase.SceneFirstNodeDto;
import net.northking.cctp.executePlan.dto.planTask.*;
import net.northking.cctp.executePlan.feign.dto.DictCatalogSearchDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

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

/**
 * <p>Title: PublicFeignClient</p>
 * <p>Description: 公共Feign客户端，无需token</p>
 *
 * @Author chenjianfeng
 * @Version V1.0
 * @Date 2022/12/09
 * <p>Copyright (c) 京北方信息技术股份有限公司 Corporation 2022 . All rights reserved.</p>
 */
@FeignClient(name = "gateway", configuration = {FeignCctpConfig.class})
public interface PublicFeignClient {

    /**
     * 获取场景下一调度节点
     * @param reqSceneNextNodeDto 请求参数
     * @return 结果
     */
    @PostMapping(value = "/atu-script-case/pub/scene/getNextNode")
    ResultWrapper<AtuSceneNodeExecDto> getNextNode(@RequestBody @Validated AtuSceneNextNodeDto reqSceneNextNodeDto);

    /**
     * 终止调度
     * @param sceneCaseStopDto 终止参数
     * @return 结果
     */
    @ApiOperation(value = "终止调度")
    @PostMapping(value = "/atu-script-case/pub/scene/stopCase")
    ResultWrapper<String> stopCase(@RequestBody @Validated SceneCaseStopDto sceneCaseStopDto);


    /**
     * 根据设备类型申请引擎
     * @param deviceListDto 设备列表
     * @return 结果
     */
    @ApiOperation(value = "根据设备类型申请引擎")
    @PostMapping(value = "/cctp-device-mgr/pub/query/engineByType",
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
            consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    List<EngineInfoListDto> queryEngineByType(@RequestBody List<DeviceListDto> deviceListDto);

    /**
     * 根据移动设备id查询设备类型
     * @param deviceIds 设备id集合
     * @return 结果集
     */
    @ApiOperation(value = "根据移动设备id查询设备类型")
    @PostMapping(value = "/cctp-device-mgr/pub/query/deviceTypeByIds")
    ResultWrapper<Map<String,List<String>>> queryDeviceType(@RequestBody List<String> deviceIds);


    /**
     * 查询离线设备
     * @param deviceIds 设备ID集合
     * @return 离线设备ID集合
     */
    @ApiOperation(value = "查询离线设备")
    @PostMapping(value = "/cctp-device-mgr/pub/device/check/status")
    List<Map<String, Object>> queryDeviceStatus(@RequestBody List<String> deviceIds);

    /**
     * 查询脚本输入项信息
     * @param queryDto 查询参数 环境id集合+脚本id集合
     * @return 查询结果
     */
    @ApiOperation(value = "查询脚本输入项信息")
    @PostMapping(value = "/atu-script-case/pub/AtuInputSets/queryByEnvIdAndScriptId")
    ResultWrapper<List<AtuPlanInputDto>> queryInputByEnvIdAndScriptId(@RequestBody AtuPlanInputQueryDto queryDto);

    /**
     * 查询脚本详细信息
     * @param scriptIdSet 脚本id集合
     * @return 结果集
     */
    @ApiOperation(value = "查询脚本详细信息")
    @PostMapping(value = "/atu-script-case/pub/script/queryScriptDetailMap")
    ResultWrapper<Map<String, AtuScriptDetailDto>> queryScriptDetailMap(@RequestBody Set<String> scriptIdSet);

    /**
     * 获取场景首节点信息
     * @param sceneFirstNodeDto
     * @return
     */
    @ApiOperation(value = "获取场景首节点")
    @PostMapping(value = "/atu-script-case/pub/scene/getFirstNode")
    public ResultWrapper<AtuSceneNodeExecDto> getFirstNode(@RequestBody @Validated SceneFirstNodeDto sceneFirstNodeDto);

    /**
     * 查询获取字典条目
     *
     * @param searchDto 字典code集合
     * @return 数据列表
     */
    @ApiOperation(value = "获取字典条目")
    @PostMapping(value = "/cctp-platform/pub/query/dict-catalog-item",
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
            consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResultWrapper<Map<String, Object>> query(@RequestBody DictCatalogSearchDto searchDto);


    @ApiOperation(value = "查询单元格的引用（pub）")
    @PostMapping(value = "/atu-data-mgr/pub/query/selectDataUrlAndTreeName")
    public QuoteData selectDataUrlAndTreeName(@RequestBody QuoteData quoteData);

    @ApiOperation("根据id集合查询app信息")
    @PostMapping("/atu-script-case/pub/apps/queryByIds")
    public ResultWrapper<List<AppDetailDto>> queryAppByIds(@RequestBody List<String> ids);

    @ApiOperation(value = "执行计划根据规则名称取值")
    @GetMapping(value = "/atu-data-mgr/pub/dataRule/getRuleDataByName")
    ResultWrapper<String> getRuleDataByName(@RequestParam(value = "ruleName") String ruleName,
                                            @RequestParam(value = "proId") String proId) throws Exception;
}
