package com.njcn.device.pq.api;

import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.device.biz.pojo.dto.PollutionLineDTO;
import com.njcn.device.pq.api.fallback.LineFeignClientFallbackFactory;
import com.njcn.device.pq.pojo.dto.*;
import com.njcn.device.pq.pojo.param.DataParam;
import com.njcn.device.pq.pojo.param.LineBaseQueryParam;
import com.njcn.device.pq.pojo.param.OnlineRateParam;
import com.njcn.device.pq.pojo.po.Line;
import com.njcn.device.pq.pojo.po.LineDetail;
import com.njcn.device.biz.pojo.po.Overlimit;
import com.njcn.device.pq.pojo.po.line.LineInfoVO;
import com.njcn.device.pq.pojo.vo.*;
import io.swagger.annotations.ApiImplicitParam;
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;
import java.util.Set;

/**
 * @author denghuajun
 * @date 2022/2/28
 */
@FeignClient(
        value = ServerInfo.DEVICE,
        path = "/line",
        fallbackFactory = LineFeignClientFallbackFactory.class,
        contextId = "line")
    public interface LineFeignClient {

    /**
     * 获取终端状态信息
     *
     * @param id              监测点id
     * @param searchBeginTime 起始时间
     * @param searchEndTime   结束时间
     * @return 终端状态信息
     */
    @PostMapping("/getComFlagInfoData")
    HttpResult<CommunicateVO> getComFlagInfoData(@RequestParam("id") String id,
                                                 @RequestParam("searchBeginTime") String searchBeginTime,
                                                 @RequestParam("searchEndTime") String searchEndTime);

    /**
     * 根据监测点id获取 终端id
     *
     * @param id 监测点id
     * @return 终端id
     */
    @PostMapping("getLineIdByDevId")
    HttpResult<String> getLineIdByDevId(@RequestParam("id") String id);

    /**
     * 根据监测点id获取限值
     *
     * @param id 监测点id
     * @return 获取限值
     */
    @PostMapping("getOverLimitData")
    HttpResult<Overlimit> getOverLimitData(@RequestParam("id") String id);

    /**
     * 根据监测点id获取监测点详情
     *
     * @param id 监测点id
     * @return 监测点详情
     */
    @PostMapping("getLineDetailData")
    HttpResult<LineDetailDataVO> getLineDetailData(@RequestParam("id") String id);

    /**
     * 根据监测点id获取装置详情
     *
     * @param id 装置id
     * @return 装置详情
     */
    @PostMapping("getDeviceDetailData")
    HttpResult<DeviceVO> getDeviceDetailData(@RequestParam("id") String id);

    /**
     * 根据监测点id获取监测点越限
     *
     * @param id 监测点id
     * @return 监测点越限详情
     */
    @PostMapping("getLineOverLimitData")
    HttpResult<LineOverLimitVO> getLineOverLimitData(@RequestParam("id") String id);


    /**
     * 获取投运在线的监测点的限值
     *
     * @param serverName 服务名称
     * @param deptId     部门id
     * @return 监测点越限详情
     */
    @PostMapping("/getAllLineOverLimit")
    HttpResult<List<Overlimit>> getAllLineOverLimit(@RequestParam("serverName") String serverName, @RequestParam(value = "deptId", required = false) String deptId);

    /**
     * 获取变电站详情
     *
     * @param id 变电站id
     * @return 结果
     */
    @PostMapping("getSubstationData")
    HttpResult<List<SubstationDetailVO>> getSubstationData(@RequestBody List<String> id);

    /**
     * 根据变电站id获取子节数据
     *
     * @param id 变电站id
     * @return 结果
     */
    @PostMapping("getSubIndexLineDetail")
    HttpResult<List<Line>> getSubIndexLineDetail(@RequestParam("id") String id);

    /**
     * 获取所有监测点
     * @param id 监测点集合
     * @return 结果
     */
    @PostMapping("getAllLine")
    HttpResult<List<LineDeviceStateVO>> getAllLine(@RequestBody List<String> id);

    /**
     * 获取终端状态
     * @param id id
     * @return 结果
     */
    @PostMapping("getDeviceState")
    HttpResult<Integer> getDeviceState(@RequestParam("id") String id);

    /**
     * 获取变电站信息
     * @param id id
     * @return 结果
     */
    @PostMapping("getSubstationInfo")
    HttpResult<PollutionSubstationDTO> getSubstationInfo(@RequestParam("id") String id);

    /**
     * 获取监测点信息
     * @param  pollutionParamDTO 监测点对象
     * @return 结果
     */
    @PostMapping("getLineInfo")
    HttpResult<List<PollutionLineDTO>> getLineInfo(@RequestBody PollutionParamDTO pollutionParamDTO);


    @PostMapping("getLineSubGdDetail")
    HttpResult<LineDetailVO> getLineSubGdDetail(@RequestParam("id") String id);

    @PostMapping("getLineInfoVO")
    HttpResult<LineInfoVO> getLineInfoVO(@RequestParam("id") String id);

    /**
     * 获取告警变电站信息
     * @param list 变电站集合
     * @return 结果
     */
    @PostMapping("getWarningSub")
    HttpResult<List<WarningSubstationDTO>> getWarningSub(@RequestParam("list") List<String> list);

    /**
     * 获取监测点信息
     * @param pollutionParamDTO 实体
     * @return 结果
     */
    @PostMapping("getOverLimitLineInfo")
    HttpResult<List<OverLimitLineDTO>> getOverLimitLineInfo(@RequestBody PollutionParamDTO pollutionParamDTO);

    /**
     * 获取生成limitRate的监测点
     * @return 监测点id集合
     */
    @PostMapping("getLineList")
    HttpResult<List<String>> getLineList();

    /**
     * 获取监测点限值
     * @param  pollutionParamDTO 监测点id集合
     * @return 监测点限值信息
     */
    @PostMapping("getOverLimitByList")
    HttpResult<List<Overlimit>> getOverLimitByList(@RequestBody PollutionParamDTO pollutionParamDTO);


    /**
     * 区域监测点以及上级一些信息
     * @param  list 监测点id集合
     * @return AreaLineInfoVO
     */
    @PostMapping("getBaseLineAreaInfo")
    HttpResult<List<AreaLineInfoVO>> getBaseLineAreaInfo(@RequestBody List<String> list);

    /**
     * 获取丰富的监测点信息(扩展模糊查询)
     * @param  lineBaseQueryParam 监测点参数
     * @return AreaLineInfoVO
     */
    @PostMapping("getRichLineInfo")
    HttpResult<List<AreaLineInfoVO>> getRichLineInfo(@RequestBody LineBaseQueryParam lineBaseQueryParam);

    /**
     * 获取监测点基本信息
     * @param  list 监测点id集合
     * @return Line
     */
    @PostMapping("getBaseLineList")
    HttpResult<List<Line>> getBaseLineList(@RequestBody List<String> list);

    /**
     * 功能描述: 获取指定条件的监测点信息
     * @param  list 监测点id集合
     * @author xy
     * @date 2022/7/8 14:24
     * @return 监测点详情集合
     */
    @PostMapping("getLineDetail")
    HttpResult<List<LineDetail>> getLineDetail(@RequestBody(required = false) List<String> list);

    /**
     * 功能描述: 获取指定条件的装置id(实际装置、投运、稳态或者双系统)
     * @author xy
     * @date 2022/7/8 14:24
     * @return 装置id集合
     */
    @PostMapping("getDeviceList")
    HttpResult<List<String>> getDeviceList();

    /**
     * 功能描述: 获取指定条件的监测点id(实际装置、投运、稳态或者双系统)
     * @author xy
     * @date 2022/7/8 14:24
     * @return 装置id集合
     */
    @PostMapping("getRunLineIdsList")
    HttpResult<List<String>> getRunLineIdsList();

    /**
     * 获取当前状态在线的监测点数量
     * @param lineIds 监测点集合
     * @return  在线的监测点数量
     * @author cdf
     * @date 2022/8/1
     */
    @PostMapping("getOnLineCount")
    HttpResult<Integer> getOnLineCount(@RequestBody List<String> lineIds);


    /**
     * 获取当前状态在线和离线的监测点
     * @param lineBaseQueryParam 监测点查询参数
     * @return  在线的监测点id集
     * @author cdf
     * @date 2022/8/1
     */
    @PostMapping("getOnOrUnLine")
    HttpResult<List<String>> getOnOrUnLine(@RequestBody LineBaseQueryParam lineBaseQueryParam);

    /**
     * 获取监测点设备id
     * @param lineIds 监测点集合
     * @return  监测点设备id
     * @author cdf
     * @date 2022/8/1
     */
    @PostMapping("getOnLineDevLine")
    HttpResult<List<OnlineLineDTO>> getOnLineDevLine(@RequestBody List<String> lineIds);

    /**
     * @Description: 获取变电站和监测点的关系（分稳态暂态）
     * @Param: [devDataType] 0：暂态 1：稳态
     * @return: com.njcn.common.pojo.response.HttpResult<java.util.Map<java.lang.String,java.util.List<java.lang.String>>>
     * @Author: clam
     * @Date: 2022/10/20
     */
    @PostMapping("getLineBySubstationRelation")
    HttpResult<Map<String,List<String>>> getLineBySubstationRelation(@RequestParam("devDataType") Integer devDataType);

    /**
     * 获取监测点基础详情
     * @param lineIds 监测点id集合
     * @return 监测点详情信息
     * @author cdf
     * @date 2022/10/26
     */
    @PostMapping("getLineDetailList")
    HttpResult<List<LineDetailDataVO>> getLineDetailList(@RequestBody List<String> lineIds);

    /**
     * @param subIndex
     * @Description: 获取变电站下终端数
     * @Param: [subIndex]
     * @return: java.lang.Integer
     * @Author: clam
     * @Date: 2022/11/9
     */
    @PostMapping("/getDeviceCountBySubstation")
    HttpResult<Integer> getDeviceCountBySubstation(@RequestParam("subIndex") String subIndex);
    /**
     * @param subIndex
     * @Description: 获取变电站下监测点数
     * @Param: [subIndex]
     * @return: java.lang.Integer
     * @Author: clam
     * @Date: 2022/11/9
     */
    @PostMapping("/getLineCountBySubstation")
    HttpResult<Integer> getLineCountBySubstation(@RequestParam("subIndex") String subIndex);

    /**
     * 监测点数据完整率（谐波专用）
     */
    @PostMapping("/getOnIntegrityByIds")
    HttpResult<List<RStatIntegrityVO>> getOnIntegrityByIds(@RequestBody OnlineRateParam param);

    @PostMapping("getOnIntegrityByIdsAndTime")
    HttpResult<List<RStatIntegrityVO>> getOnIntegrityByIdsAndTime(@RequestBody LineBaseQueryParam param);


    /**
     * @Description: 根据监测点id获取监测点集合
     * @param ids
     * @Author: wr
     * @Date: 2023/11/8 15:55
     */
    @PostMapping("/getLineDetailByIds")
    HttpResult<List<LineDetailVO.Detail>> getLineDetailByIds(@RequestBody List<String> ids);


    @PostMapping("/updateDeviceRunFlag")
    void updateDeviceRunFlag(@RequestParam("deviceId")String deviceId, @RequestParam("status")Integer status);

    @PostMapping("/updateLineRunFlag")
    void updateLineRunFlag(@RequestParam("lineId")String lineId, @RequestParam("status")Integer status);

    @PostMapping("/getDeptDeviceDetailData")
    HttpResult<List<LineDetailVO.Detail>> getDeptDeviceDetailData(@RequestBody DataParam param);

    @PostMapping("/getNoDataLine")
    HttpResult<List<LineDetailVO.noDataLineInfo>> getNoDataLine();

    @PostMapping("/getReportLineInfo")
    HttpResult<List<ReportLineInfoVo>> getReportLineInfo(@RequestBody List<String> ids);

    /**
     * 根据监测点名称和电网侧变电站名称模糊搜索
     * @param param
     * @return
     */
    @PostMapping("/getByName")
    HttpResult<List<LineDetail>> getByName(@RequestBody LineBaseQueryParam param);

    @GetMapping("/getLevelMonitorIdByDept")
    HttpResult<List<String>> getLevelMonitorIdByDept(@RequestParam("level") String level,@RequestParam("deptId")String deptId);

    @GetMapping("/getMonitorByObjId")
    HttpResult<List<LineDetail>> getMonitorByObjId(@RequestParam("objId") String objId);

    @PostMapping("/getPowerStationByMonitorIds")
    HttpResult<List<PollutionSubstationDTO>> getPowerStationByMonitorIds(@RequestBody List<String> ids);

    @PostMapping("/getDevListByLineIdList")
    HttpResult<Set<String>> getDevListByLineIdList(@RequestBody List<String> list);
}
