package com.usky.pm.factory;

import com.usky.common.core.exception.FeignBadRequestException;
import com.usky.pm.RemotePmTaskService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;


/**
 * 用户服务降级处理
 *
 * @author ruoyi
 */
@Component
public class RemotePmTaskFactory implements FallbackFactory<RemotePmTaskService>
{
    private static final Logger log = LoggerFactory.getLogger(RemotePmTaskFactory.class);

    @Override
    public RemotePmTaskService create(Throwable throwable)
    {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemotePmTaskService()
        {
            @Override
            public void dataOverviewJobData() {
                throw new FeignBadRequestException(500,"数据概览数据定时生成异常"+throwable.getMessage());
            }

            @Override
            public void deviceStatus() {
                throw new FeignBadRequestException(500,"定时同步设备状态异常"+throwable.getMessage());
            }

            @Override
            public void deviceOffLineAlarm() {
                throw new FeignBadRequestException(500,"定时同步设备离线告警数据异常"+throwable.getMessage());
            }

            @Override
            public void customInfoStatus() {
                throw new FeignBadRequestException(500,"定时同步客户信息状态异常"+throwable.getMessage());
            }

            @Override
            public void addDeviceInfo(String productCode, String deviceUuid, String deviceId, String deviceName, String installAddress, Integer serviceStatus) {
                throw new FeignBadRequestException(500,"新增设备信息异常"+throwable.getMessage());
            }

            @Override
            public void deleteDeviceInfo(String deviceUuid) {
                throw new FeignBadRequestException(500,"删除设备信息异常"+throwable.getMessage());
            }

        };
    }
}
