package com.ruoyi.integration.api.factory; import com.ruoyi.common.core.domain.R; import com.ruoyi.integration.api.feignClient.IntegrationClient; import com.ruoyi.integration.api.model.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.cloud.openfeign.FallbackFactory; import org.springframework.stereotype.Component; /** * 充电桩服务降级处理 * * @author ruoyi */ @Component public class IntegrationFallbackFactory implements FallbackFactory { private static final Logger log = LoggerFactory.getLogger(IntegrationFallbackFactory.class); @Override public IntegrationClient create(Throwable throwable) { log.error("充电桩调用失败:{}", throwable.getMessage()); return new IntegrationClient() { @Override public R onlineReply(OnlineReply onlineReply) { return R.fail("登录认证应答调用失败:" + throwable.getMessage()); } @Override public R pong(Pong pong) { return R.fail("心跳包应答调用失败:" + throwable.getMessage()); } @Override public R billingModeVerifyReply(BillingModeVerifyReply billingModeVerifyReply) { return R.fail("计费模型验证请求应答调用失败:" + throwable.getMessage()); } @Override public R acquisitionBillingModeReply(AcquisitionBillingModeReply acquisitionBillingModeReply) { return R.fail("计费模型验证请求应答调用失败:" + throwable.getMessage()); } @Override public R readRealTimeMonitoringData(ReadRealTimeMonitoringData readRealTimeMonitoringData) { return R.fail("读取实时监测数据调用失败:" + throwable.getMessage()); } // @Override // public R endCharge(EndCharge endCharge) { // return R.fail("充电结束调用失败:" + throwable.getMessage()); // } @Override public R platformConfirmationCharging(PlatformConfirmationCharging platformConfirmationCharging) { return R.fail("运营平台确认启动充电调用失败:" + throwable.getMessage()); } @Override public R platformStartCharging(PlatformStartCharging platformStartCharging) { return R.fail("运营平台远程控制启机调用失败:" + throwable.getMessage()); } @Override public R platformStopCharging(PlatformStopCharging platformStopCharging) { return R.fail("运营平台远程停机调用失败:" + throwable.getMessage()); } @Override public R confirmTransactionRecord(ConfirmTransactionRecord confirmTransactionRecord) { return R.fail("交易记录确认调用失败:" + throwable.getMessage()); } @Override public R updateBalance(UpdateBalance updateBalance) { return R.fail("远程账户余额更新调用失败:" + throwable.getMessage()); } @Override public R synchronizeOfflineCard(SynchronizeOfflineCard synchronizeOfflineCard) { return R.fail("离线卡数据同步调用失败:" + throwable.getMessage()); } @Override public R clearOfflineCard(ClearOfflineCard clearOfflineCard) { return R.fail("离线卡数据清除调用失败:" + throwable.getMessage()); } @Override public R queryOfflineCard(QueryOfflineCard queryOfflineCard) { return R.fail("离线卡数据查询调用失败:" + throwable.getMessage()); } @Override public R workingParameterSetting(WorkingParameterSetting workingParameterSetting) { return R.fail("充电桩工作参数设置调用失败:" + throwable.getMessage()); } @Override public R timingSetting(TimingSetting timingSetting) { return R.fail("对时设置调用失败:" + throwable.getMessage()); } @Override public R setupBillingModel(SetupBillingModel setupBillingModel) { return R.fail("计费模型设置调用失败:" + throwable.getMessage()); } @Override public R openOrCloseGroundLock(OpenOrCloseGroundLock openOrCloseGroundLock) { return R.fail("遥控地锁升锁与降锁命令 (下行)调用失败:" + throwable.getMessage()); } @Override public R platformRestart(PlatformRestart platformRestart) { return R.fail("远程重启调用失败:" + throwable.getMessage()); } @Override public R platformRemoteUpdate(PlatformRemoteUpdate platformRemoteUpdate) { return R.fail("远程更新调用失败:" + throwable.getMessage()); } @Override public R setupBillingModel1(String deviceId) { return R.fail("远程更新硬件:" + throwable.getMessage()); } }; } }