package com.ruoyi.order.api.factory;
|
|
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.order.api.feignClient.ChargingOrderAccountingStrategyClient;
|
import com.ruoyi.order.api.feignClient.ChargingOrderClient;
|
import com.ruoyi.order.api.model.TChargingOrder;
|
import com.ruoyi.order.api.model.TChargingOrderAccountingStrategy;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
import org.springframework.stereotype.Component;
|
|
import java.util.List;
|
import java.util.Map;
|
import java.util.Set;
|
|
/**
|
* 充电订单服务降级处理
|
*
|
* @author ruoyi
|
*/
|
@Component
|
public class ChargingOrderAccountingStrategyFallbackFactory implements FallbackFactory<ChargingOrderAccountingStrategyClient>
|
{
|
private static final Logger log = LoggerFactory.getLogger(ChargingOrderAccountingStrategyFallbackFactory.class);
|
|
@Override
|
public ChargingOrderAccountingStrategyClient create(Throwable throwable) {
|
log.error("充电订单调用失败:{}", throwable.getMessage());
|
return new ChargingOrderAccountingStrategyClient() {
|
|
|
@Override
|
public R<List<List<Map<String, Object>>>> getTotalElectricQuantity(Integer days, Set<Integer> siteIds) {
|
return R.fail("获取给定天数每天的充电量统计数据失败:" + throwable.getMessage());
|
}
|
|
@Override
|
public R<List<Double>> getDailyChargingDegree(Integer days, Set<Integer> siteIds) {
|
return R.fail("获取给定天数每天的充电度数失败:" + throwable.getMessage());
|
}
|
|
@Override
|
public R<List<TChargingOrderAccountingStrategy>> getChargingOrderAccountingStrategyByOrderId(Long chargingOrderId) {
|
return R.fail("根据订单id查询充电明细失败:" + throwable.getMessage());
|
}
|
};
|
}
|
}
|