package com.sptg.device.api.feigns;

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.common.core.beans.PageBean;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.entity.DispatchTask;
import com.sptg.device.api.dto.*;
import com.sptg.device.api.entity.Device;
import com.sptg.device.api.entity.DeviceRemoteInfo;
import com.sptg.device.api.feigns.fallback.DeviceFeignFallbackFactory;
import com.sptg.device.api.vo.DeviceVO;
import com.sptg.device.api.vo.ManualPushDevicesTask;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

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

/**
 * title: DeviceFeign
 * package: com.sptg.device.api.feigns
 * description: 设备对外服务接口
 *
 *
 *
 */
@FeignClient(value = "smart-house-device",fallbackFactory = DeviceFeignFallbackFactory.class)
public interface DeviceFeign {

    /**
     * 设备心跳检查
     * @param device 设备信息
     */
    @PostMapping(value = "/device/heartbeat")
    void heartbeat(@RequestBody Device device);

    /**
     * 功能描述: 分页查询设备信息
     * @param pageBean 设备数据传输对象
     * @return ResultBean<Page>
     *
     *
     */@PostMapping(value = "/device/pagingQuery")
    ResultBean<Page<Device>> pagingQuery(@RequestBody PageBean<Device,DeviceDto> pageBean);

    @PostMapping(value = "/device/pagingByResidentialIds")
    ResultBean<Page<Device>> pagingByResidentialIds(@RequestBody DeviceDto deviceDto);

    /**
     * 功能描述: 添加设备
     * @param dto 设备信息
     * @return ResultBean<Boolean>
     *
     *
     */
    @PostMapping(value = "/device/addEntity")
    ResultBean<Boolean> addEntity(@RequestBody DeviceDto dto);

    /**
     * 功能描述: 添加亲邻设备
     * @param dto 设备信息
     * @return ResultBean<Boolean>
     *
     *
     */
    @PostMapping(value = "/device/third/addEntity")
    ResultBean<Boolean> addThirdEntity(@RequestBody DeviceDto dto);

    /**
     * 功能描述: 完善设备
     * 针对设备需要在平台上补充小区信息的情况，比如平台未添加设备时，设备就已经开机了
     * @param dto 设备信息
     * @return ResultBean<Boolean>
     *
     *
     */
    @PostMapping(value = "/device/completeEntity")
    ResultBean<Boolean> completeEntity(@RequestBody DeviceDto dto);
	/**
     * 功能描述: 获取设备信息
     * @param id 设备Id
     * @return Device
     *
     *
     */

    @GetMapping(value = "/device/get/{id}")
    Device getEntityById(@PathVariable(value = "id") Long id);

    /**
     * 功能描述: 根据设备序列号获取设备信息
     * @param serialNumber 设备序列号
     * @return Device
     *
     *
     */
    @GetMapping(value = "/device/getBySerialNumber")
    Device getEntityBySerialNumber(@RequestParam(value = "serialNumber") String serialNumber);

    /**
     * 功能描述: 根据设备厂家获取设备信息
     * @param factory 厂家
     * @return Device
     *
     *
     */
    @GetMapping(value = "/device/getByFactory")
    Device getEntityByFactory(@RequestParam(value = "factory") String factory);

    /**
     * 功能描述: 修改设备
     * @param dto 设备信息
     * @return ResultBean<Boolean>
     *
     *
     */
    @PostMapping(value = "/device/editEntity")
    ResultBean<Boolean> editEntity(@RequestBody DeviceDto dto);

    /**
     * 功能描述: 批量修改
     * @param dto 设备信息
     * @return ResultBean<Boolean>
     *
     *
     */
    @PostMapping(value = "/device/batchEditEntity")
    ResultBean<Boolean> batchEditEntity(@RequestBody DeviceDto dto);

    /**
     * 功能描述: 获取指定小区下的所有设备
     * @param xqId 小区Id
     * @return List<Device>
     *
     *
     */
    @GetMapping(value = "/device/getListByXqId/{xqId}")
    List<Device> getListByXqId(@PathVariable(value = "xqId") Long xqId);

    /**
     * 功能描述: 根据Id列表获取设备信息
     * @param idList Id列表
     * @return List<Device>
     *
     *
     */
    @PostMapping(value = "/device/getListByIds")
    List<Device> getListByIds(@RequestBody List<Long> idList);

    /**
     * 功能描述: 设备开门
     * @param device { id:设备Id,必填 }
     * @return ResultBean<Boolean>
     *
     *
     */
    @PostMapping(value = "/device/openDoor")
    ResultBean<Boolean> openDoor(@RequestBody Device device);

    /**
     * 功能描述: 设备格式化
     * @param deviceDto { id:设备Id,必填 }
     * @return ResultBean<Boolean>
     *
     *
     */
    @PostMapping(value = "/device/formatData")
    ResultBean<Boolean> formatData(@RequestBody DeviceDto deviceDto);

    /**
     * 功能描述: 大豪设备格式化
     * @param device { id:设备Id,必填 }
     * @return ResultBean<Boolean>
     *
     *
     */
    @PostMapping(value = "/device/dh/formatData")
    ResultBean<Boolean> dhFormatData(@RequestBody Device device);

    /**
     * 功能描述: 设备重启
     * @param device { id:设备Id,必填 }
     * @return ResultBean<Boolean>
     *
     *
     */
    @PostMapping(value = "/device/restart")
    ResultBean<Boolean> restart(@RequestBody Device device);


    /**
     * 功能描述: 设备重启
     * @param device { id:设备Id,必填 }
     * @return ResultBean<Boolean>
     *
     *
     */
    @PostMapping(value = "/device/checkOnline")
    ResultBean<Boolean> checkOnline(@RequestBody Device device);


    /**
     * 功能描述: 设备远程恢复版本
     * @param device { id:设备Id,必填 }
     * @return ResultBean<Boolean>
     *
     *
     */
    @PostMapping(value = "/device/restore")
    ResultBean<Boolean> restore(@RequestBody Device device);

    /**
     * 同步设备数据
     * @param dto 设备信息
     * @return ResultBean<Boolean>
     */
    @PostMapping(value = "/device/sync/data")
    ResultBean<Boolean> syncData(@RequestBody DeviceDto dto);

    /**
     * 同步大豪设备数据
     * @param dto 设备信息
     * @return ResultBean<Boolean>
     */
    @PostMapping(value = "dh/device/sync/data")
    ResultBean<Boolean> dhSyncData(@RequestBody DeviceDto dto);

    /**
     * 下发开门密码
     * @param task 任务
     * @return ResultBean<Boolean>
     */
    @PostMapping(value = "/device/pushOpenDoorPwd")
    ResultBean<Boolean> pushOpenDoorPwd(@RequestBody DispatchTask task, @RequestParam Map<String,String> map);

    /**
     * 下发测试开门密码
     * @param task 任务
     * @return ResultBean<Boolean>
     */
    @PostMapping(value = "/device/pushTestOpenDoorPwd")
    ResultBean<Boolean> pushTestOpenDoorPwd(@RequestBody DispatchTask task,@RequestParam Map<String,String> map);

    /**
     * 删除开门密码
     * @param task 任务
     * @return ResultBean<Boolean>
     */
    @PostMapping(value = "/device/removeOpenDoorPwd")
    ResultBean<Boolean> removeOpenDoorPwd(@RequestBody DispatchTask task,@RequestParam Map<String,String> map);

    /**
     * 下发人脸到住户所住区域的所有设备，包括特定授权设备
     * @param task 任务
     * @return ResultBean<Boolean>
     */
    @PostMapping(value = "/device/pushUserFace")
    ResultBean<Boolean> pushUserFace(@RequestBody DispatchTask task, @RequestParam Map<String,String> map);

    /**
     * 批量删除人脸到住户所住区域的所有设备，包括特定授权设备
     * @param faceInfoDtoList 任务
     * @return ResultBean<Boolean>
     */
    @PostMapping(value = "/device/deleteUserFaceBatch")
    ResultBean<Boolean> deleteUserFaceBatch(@RequestBody List<FaceInfoDto> faceInfoDtoList);

    /**
     * 批量设置人脸到住户所住区域的所有设备，包括特定授权设备
     * @param faceInfoDtoList 任务
     * @return ResultBean<Boolean>
     */
    @PostMapping(value = "/device/issueUserFaceBatch")
    ResultBean<Boolean> issueUserFaceBatch(@RequestBody List<FaceInfoDto> faceInfoDtoList);

    /**
     * 下发人脸到住户所住区域的通用设备，不包括特定授权设备
     * @param task 任务
     * @return ResultBean<Boolean>
     */
    @PostMapping(value = "/device/pushUserFaceToUniversalDevices/{operType}")
    ResultBean<Boolean> pushUserFaceToUniversalDevices(@RequestBody DispatchTask task, @PathVariable(value = "operType") Integer operType, @RequestParam Map<String,String> map);

    /**
     * 下发人脸到住户所住区域的通用设备，不包括特定授权设备
     * @param task 任务
     * @return ResultBean<Boolean>
     */
    @PostMapping(value = "/device/deleteUserFaceToUniversalDevices")
    ResultBean<Boolean> deleteUserFaceToUniversalDevices(@RequestBody DispatchTask task, @RequestParam Map<String,String> map);

    /**
     * 手动下发人脸到指定设备上
     * @param task 任务
     * @return ResultBean<Boolean>
     */
    @PostMapping(value = "/device/manualPushUserFaceToDevices")
    ResultBean<Boolean> manualPushUserFaceToDevices(@RequestBody ManualPushDevicesTask task);

    /**
     * 下发测试人脸
     * @param task 任务
     * @return ResultBean<Boolean>
     */
    @PostMapping(value = "/device/pushTestFace")
    ResultBean<Boolean> pushTestFace(@RequestBody DispatchTask task);


    /**
     * 下发卡号
     * @param task 任务
     * @return ResultBean<Boolean>
     */
    @PostMapping(value = "/device/pushCard")
    ResultBean<Boolean> pushCard(@RequestBody DispatchTask task);

    /**
     * 下发卡号，排除大豪设备
     * @param task 任务
     * @return ResultBean<Boolean>
     */
    @PostMapping(value = "/device/pushCardToNoDh")
    ResultBean<Boolean> pushCardToNoDh(@RequestBody DispatchTask task);

    /**
     * 下发卡号到一台设备上
     * @param task 任务
     * @return ResultBean<Boolean>
     */
    @PostMapping(value = "/device/pushCardsToDHDevice")
    ResultBean<Boolean> pushCardsToDHDevice(@RequestBody DispatchTask task);

    /**
     * 下发卡号
     * @param task 任务
     * @return ResultBean<Boolean>
     */
    @PostMapping(value = "/device/pushCardToUniversalDevices/{operType}")
    ResultBean<Boolean> pushCardToUniversalDevices(@RequestBody DispatchTask task, @PathVariable(value = "operType") Integer operType);

    @PostMapping(value = "/device/pushCardToUniversalDevicesBatch")
    ResultBean<Boolean> pushCardToUniversalDevicesBatch(@RequestBody List<AccessCardSimpleDto> accessCardSimpleDtoList);


    /**
     * 下发卡号
     * @param task 任务
     * @return ResultBean<Boolean>
     */
    @PostMapping(value = "/device/manualPushUserCardToDevices")
    ResultBean<Boolean> manualPushUserCardToDevices(@RequestBody ManualPushDevicesTask task);

    /**
     * 删除卡号
     * @param task 任务
     * @return ResultBean<Boolean>
     */
    @PostMapping(value = "/device/removeCard")
    ResultBean<Boolean> removeCard(@RequestBody DispatchTask task);

    /**
     * 删除已下发的卡号
     * @param task 任务
     * @return ResultBean<Boolean>
     */
    @PostMapping(value = "/device/removePushCard")
    ResultBean<Boolean> removePushCard(@RequestBody DispatchTask task);

    /**
     * 批量删除已下发的卡号
     * @param accessCardSimpleDtoList
     * @return ResultBean<Boolean>
     */
    @PostMapping(value = "/device/removePushCardBatch")
    ResultBean<Boolean> removePushCardBatch(@RequestBody List<AccessCardSimpleDto> accessCardSimpleDtoList);

    /**
     * 开启或关闭紧急疏散模式
     * @param xqId 小区Id
     * @param time 0 : 关闭紧急疏散，当前毫秒值 : 开启紧急疏散
     * @return ResultBean<Boolean>
     */
    @GetMapping(value = "/device/evacuate/{xqId}/{time}")
    ResultBean<Boolean> startOrClearEvacuate(@PathVariable(value = "xqId")Long xqId,@PathVariable(value = "time")Long time);

    /**
     * 下发视频对讲账号
     * @param task 下发任务
     */
    @PostMapping(value = "/device/pushCallAccount")
    void pushCallAccount(@RequestBody DispatchTask task);

    /**
     * 删除设备广告
     * @param task 下发任务
     */
    @PostMapping(value = "/device/deleteAdvert")
    void deleteAdvert(@RequestBody DispatchTask task);

    /**
     * 获取住户可访问的设备列表
     * @param xqId 住户所属小区Id
     * @param unitId 住户所属单元Id
     * @return List<Device>
     */
    @GetMapping(value = "/device/getListByEstateUser/{xqId}/{unitId}")
    List<Device> getListByEstateUser(@PathVariable(value = "xqId")Long xqId, @PathVariable(value = "unitId")Long unitId);

    /**
     * 获取住户可访问的指定条件的设备列表
     * @return List<Device>
     */
    @PostMapping(value = "/device/getListByCondition")
    List<Device> getListByCondition(@RequestBody DeviceVO deviceVO);

    /**
     * 获取账户可访问的指定机构路径的设备列表
     * @return List<Device>
     */
    @PostMapping(value = "/device/getListByOrgPosition")
    List<Device> getListByOrgPosition(@RequestBody DeviceVO deviceVO);

    /**
     * 根据单元Id列表获取设备
     * @param idList 单元Id列表
     * @return List<Device>
     */
    @PostMapping(value = "/device/getListByUnitIds")
    List<Device> getListByUnitIds(@RequestBody List<Long> idList);

    /**
     * 获取住户可访问的特殊授权设备列表
     * @param pathUse 设备位置用途，10：用于放置一般授权设备，11用于放置特殊授权设备
     * @return List<Device>
     */
    @GetMapping(value = "/device/getSpecialListByPathUse/{pathUse}")
    List<Device> getSpecialListByPathUse(@PathVariable(value = "xqId")Long xqId, @PathVariable(value = "pathUse") Integer pathUse);

    @GetMapping(value = "/device/getByOldId/{oldId}")
    Device getByOldId(@PathVariable(value = "oldId") String oldId);

    @GetMapping(value = "/device/getOfflineDeviceAccount")
    long getOfflineDeviceAccount(@RequestBody Device device);

    @GetMapping(value = "/device/getDeviceByPathUseAndType/{xqId}/{unitId}/{pathUse}/{type}")
    List<Device> getDeviceByPathUseAndType(@PathVariable(value = "xqId")Long xqId, @PathVariable(value = "unitId") Long unitId, @PathVariable(value = "pathUse") Integer pathUse, @PathVariable(value = "type") Integer type);

    /**
     * 设备关联小区
     * @param dto
     * @return
     */
    @PostMapping(value = "/device/relateEntity")
    ResultBean<Boolean> relateEntity(@RequestBody DeviceDto dto);

    /**
     * 功能描述: 禁用设备
     * @param device { id:设备Id,必填 }
     * @return ResultBean<Boolean>
     *
     *
     */
    @PostMapping(value = "/device/disable")
    ResultBean<Boolean> disable(@RequestBody DeviceDto device);

    /**
     * 功能描述: 下发设备远程获取信息指令
     * @param device { id:设备Id,必填 }
     * @return ResultBean<Boolean>
     *
     *
     */
    @PostMapping(value = "/device/info/obtain")
    ResultBean<Boolean> obtainInfo(@RequestBody Device device);

    /**
     * 功能描述: 分页获取指定条件的设备
     * @param pageBean
     * @return ResultBean<Page<Device>>
     *
     *
     */
    @PostMapping(value = "/device/page/getByCondition")
    ResultBean<Page<Device>> getPageByCondition(@RequestBody PageBean<Device,DeviceDto> pageBean);

    /**
     * 功能描述: 数字社区门禁设备推送到物业系统
     * @param deviceList 设备信息
     * @return ResultBean<Boolean>
     *
     *
     */
    @PostMapping(value = "/device/grid/addEntity")
    ResultBean<Boolean> addGridEntity(@RequestBody Map<String,Object> deviceList);

    @PostMapping(value = "/device/updateEntity")
    boolean updateEntity(@RequestBody Device item);

    @PostMapping(value = "/device/updateDeviceList")
    boolean updateDeviceList(@RequestBody List<Device> deviceList);

    @PostMapping(value = "/device/getListBySerialNumbers")
    List<Device> getListBySerialNumbers(@RequestParam(value = "serialNumbers") String serialNumbers);
}
