package com.xhpc.common.api.factory;

import com.xhpc.common.api.PowerPileService;
import com.xhpc.common.core.domain.R;
import com.xhpc.common.data.down.StartChargingData;
import com.xhpc.common.data.redis.CacheRateModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Set;

@Component
public class PowerPileFallbackFactory implements FallbackFactory<PowerPileService> {

    private static final Logger logger = LoggerFactory.getLogger(PowerPileFallbackFactory.class);


    @Override
    public PowerPileService create(Throwable cause) {

        logger.error("充电桩服务调用失败:{} //fallback", cause.getMessage());
        return new PowerPileService() {
            @Override
            public R startCharging(StartChargingData startChargingData) {

                return R.fail(3886,"启动充电失败:" + cause.getMessage());
            }

            @Override
            public R startChargingCapacity(StartChargingData startChargingData) {
                return R.fail(3886,"启动充电失败:" + cause.getMessage());
            }

            @Override
            public R refreshBalance(StartChargingData balanceRefreshData) {

                return R.fail(3886,"刷新余额失败:" + cause.getMessage());
            }

            @Override
            public R stopCharging(String orderNo, String pileNo, String connectorId, String version) {

                return R.fail(3886,"停止充电失败:" + cause.getMessage());
            }

            @Override
            public R addPileWhitelist(Long stationId, String version, Set<String> pileNoSet) {

                return R.fail(3886,"增加充电桩白名单失败:" + cause.getMessage());
            }

            @Override
            public R deletePileWhitelist(Long stationId, Set<String> pileNoSet) {

                return R.fail(3886,"删除充电桩白名单失败:" + cause.getMessage());
            }

            @Override
            public R setStationRateModel(Long stationId, Long rateModelId, CacheRateModel rateModel) {

                return R.fail(3886,"设置电站费率模型失败:" + cause.getMessage());
            }

            @Override
            public R configTimeNRateModel(String pileNo) {

                return R.fail(3886,"校时校费失败:" + cause.getMessage());
            }

            @Override
            public R pileSoftwareUpgrade(String pileNo) {

                return R.fail(3886,"更新桩程序失败:" + cause.getMessage());
            }

            @Override
            public R pileReboot(String pileNo) {

                return R.fail(3886,"重启桩程序失败:" + cause.getMessage());
            }

            @Override
            public R getNotificationStationInfo(Long stationId) {
                return R.fail(500,"组装场站信息失败:" + cause.getMessage());
            }

            @Override
            public R addNotificationStationInfo(Long stationId) {
                return R.fail(500,"生成场站推送数据信息失败:" + cause.getMessage());
            }

            @Override
            public R queryStationStats(Long stationId, String startTime, String endTime) {
                return R.fail(500,"统计场站信息失败:" + cause.getMessage());
            }

            @Override
            public R querySupEquipmentStatsInfo(Long stationId, String startTime, String endTime) {
                return R.fail(500,"查询充电设备运行统计信息失败:" + cause.getMessage());
            }

            @Override
            public R queryConnectorStatsInfo(Long stationId, String startTime, String endTime) {
                return R.fail(500,"查询充电设备接口运行统计计信息失败:" + cause.getMessage());
            }

            @Override
            public R getNotificationStationFee(Long stationId) {
                return R.fail(500,"获取场站费率失败:" + cause.getMessage());
            }

            @Override
            public R getSuperviseQueryStationPowerInfo(String[] stationIDs, String dataTime,String replace) {
                return R.fail(500,"查询充电站功率统信息失败:" + cause.getMessage());
            }

            @Override
            public R getSuperviseQueryEquipmentPowerInfo(String stationID, String dataTime,String replace) {
                return R.fail(500,"查询充电设备功率统计信息失败:" + cause.getMessage());
            }

            @Override
            public R getSuperviseQueryAccidentInfo(String lastQueryTime,String replace) {
                return R.fail(500,"查充电事故信息失败:" + cause.getMessage());
            }

            @Override
            public R getSuperviseNotificationOperationStatusInfo(String replace) {
                return R.fail(500,"推送充电站用能统计信息失败:" + cause.getMessage());
            }

            @Override
            public R getSuperviseNotificationRealtimePowerInfo(String operatorIdEvcs, String replace) {
                return R.fail(500,"推送充电站实时功率失败:" + cause.getMessage());
            }

            @Override
            public R pileConfigSettings(String pileNo, String powerNumber) {
                return R.fail(500,"推送充电桩工作参数设置失败:" + cause.getMessage());
            }

        };
    }

}
