package com.sptg.device.api.feigns.fallback;

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.beans.ResultEnum;
import com.sptg.common.core.entity.DispatchTask;
import com.sptg.device.api.dto.AccessCardSimpleDto;
import com.sptg.device.api.dto.DeviceDto;
import com.sptg.device.api.dto.FaceInfoDto;
import com.sptg.device.api.entity.Device;
import com.sptg.device.api.entity.DeviceRemoteInfo;
import com.sptg.device.api.feigns.DeviceFeign;
import com.sptg.device.api.vo.DeviceVO;
import com.sptg.device.api.vo.ManualPushDevicesTask;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

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

/**
 * title: DeviceFeignFallbackFactory
 * description:
 *
 *
 *
 */
@Component
@Slf4j
public class DeviceFeignFallbackFactory implements FallbackFactory<DeviceFeign> {
    @Override
    public DeviceFeign create(Throwable cause) {
        return new DeviceFeign() {

            @Override
            public void heartbeat(Device device) {
                log.error(cause.getMessage());
            }

            @Override
            public ResultBean<Page<Device>> pagingQuery(PageBean<Device, DeviceDto> pageBean) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR,pageBean);
            }

            @Override
            public ResultBean<Page<Device>> pagingByResidentialIds(DeviceDto deviceDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> addEntity(DeviceDto dto) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> addThirdEntity(DeviceDto dto) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> completeEntity(DeviceDto dto) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public Device getEntityById(Long id) {
                log.error(cause.getMessage());
                return null;
            }

            @Override
            public Device getEntityBySerialNumber(String serialNumber) {
                log.error(cause.getMessage());
                return null;
            }

            @Override
            public Device getEntityByFactory(String factory) {
                log.error(cause.getMessage());
                return null;
            }

            @Override
            public ResultBean<Boolean> editEntity(DeviceDto dto) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> batchEditEntity(DeviceDto dto) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public List<Device> getListByXqId(Long xqId) {
                log.error(cause.getMessage());
                return new ArrayList<>(0);
            }

            @Override
            public List<Device> getListByIds(List<Long> idList) {
                log.error(cause.getMessage());
                return new ArrayList<>(0);
            }

            @Override
            public ResultBean<Boolean> openDoor(Device device) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> formatData(DeviceDto deviceDto) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> dhFormatData(Device device) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> restart(Device device) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> checkOnline(Device device) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> restore(Device device) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> syncData(DeviceDto dto) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> dhSyncData(DeviceDto dto) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> pushOpenDoorPwd(DispatchTask task, Map<String,String> map) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> pushTestOpenDoorPwd(DispatchTask task, Map<String,String> map) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> removeOpenDoorPwd(DispatchTask task, Map<String,String> map) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> pushUserFace(DispatchTask task, Map<String,String> map) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> deleteUserFaceBatch(List<FaceInfoDto> faceInfoDtoList) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> issueUserFaceBatch(List<FaceInfoDto> faceInfoDtoList) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> pushUserFaceToUniversalDevices(DispatchTask task, Integer operType, Map<String,String> map) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> deleteUserFaceToUniversalDevices(DispatchTask task, Map<String, String> map) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> manualPushUserFaceToDevices(ManualPushDevicesTask task) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> pushTestFace(DispatchTask task) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> pushCard(DispatchTask task) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> pushCardToNoDh(DispatchTask task) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> pushCardsToDHDevice(DispatchTask task) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> pushCardToUniversalDevices(DispatchTask task, Integer operType) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> pushCardToUniversalDevicesBatch(List<AccessCardSimpleDto> accessCardSimpleDtoList) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> manualPushUserCardToDevices(ManualPushDevicesTask task) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> removeCard(DispatchTask task) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> removePushCard(DispatchTask task) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> removePushCardBatch(List<AccessCardSimpleDto> accessCardSimpleDtoList) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> startOrClearEvacuate(Long xqId, Long time) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public void pushCallAccount(DispatchTask task) {
                log.error(cause.getMessage());
            }

            @Override
            public void deleteAdvert(DispatchTask task) {
                log.error(cause.getMessage());
            }

            @Override
            public List<Device> getListByEstateUser(Long xqId, Long unitId) {
                log.error(cause.getMessage());
                return new ArrayList<>(0);
            }

            @Override
            public List<Device> getListByCondition(DeviceVO deviceVO) {
                log.error(cause.getMessage());
                return new ArrayList<>(0);
            }

            @Override
            public List<Device> getListByOrgPosition(DeviceVO deviceVO) {
                return null;
            }

            @Override
            public List<Device> getListByUnitIds(List<Long> idList) {
                log.error(cause.getMessage());
                return new ArrayList<>(0);
            }

            @Override
            public List<Device> getSpecialListByPathUse(Long xqId, Integer pathUse) {
                log.error(cause.getMessage());
                return new ArrayList<>(0);
            }

            @Override
            public Device getByOldId(String oldId) {
                log.error(cause.getMessage());
                return null;
            }

            @Override
            public long getOfflineDeviceAccount(Device dto) {
                log.error(cause.getMessage());
                return 0;
            }

            @Override
            public List<Device> getDeviceByPathUseAndType(Long xqId, Long unitId, Integer pathUse, Integer type) {
                log.error(cause.getMessage());
                return null;
            }

            @Override
            public ResultBean<Boolean> relateEntity(DeviceDto dto) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> disable(DeviceDto deviceDto) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> obtainInfo(Device device) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Page<Device>> getPageByCondition(PageBean<Device, DeviceDto> pageBean) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> addGridEntity(Map<String,Object> deviceList) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public boolean updateEntity(Device item) {
                log.error(cause.getMessage());
                return false;
            }

            @Override
            public boolean updateDeviceList(List<Device> deviceList) {
                log.error(cause.getMessage());
                return false;
            }

            @Override
            public List<Device> getListBySerialNumbers(String serialNumbers) {
                log.error(cause.getMessage());
                return null;
            }
        };
    }
}
