package com.xhpc.common.api.factory;

import com.xhpc.common.api.ChargingStationService;
import com.xhpc.common.core.domain.R;
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;

/**
 * 场站服务
 * @author yuyang
 * @date 2023-09-12 9:52
 */
@Component
public class ChargingStationServiceFactory implements FallbackFactory<ChargingStationService> {


    private static final Logger logger = LoggerFactory.getLogger(ChargingStationServiceFactory.class);
    /**
     * Returns an instance of the fallback appropriate for the given cause.
     *
     * @param cause cause of an exception.
     * @return fallback
     */
    @Override
    public ChargingStationService create(Throwable cause) {
        logger.error("场站服务调用失败：{}//fallback", cause.getMessage());

        return new ChargingStationService() {
            @Override
            public R getChargingStationServiceById(Long stationId) {
                return R.fail(500,"场站查询信息接口失败:" + cause.getMessage());
            }

            @Override
            public R getChargingPileSerialNumber(String serialNumber) {
                return R.fail(500,"监管平台推送调控需求失败:" + cause.getMessage());
            }

            @Override
            public R addRequirementInfo(String name, String area, String code, String list, String requireDate, String releaseTime, String deliveryTime) {
                return R.fail(500,"监管平台推送调控任务失败:" + cause.getMessage());
            }

            @Override
            public R addNotificationTask(String taskName, String taskCode, String demandDate, String stationID, String operatorID, String equipmentOwnerID, String eleNo, String list, String deliveryTime) {
                return R.fail(500,"调控任务接口失败:" + cause.getMessage());
            }

            @Override
            public R getXhpcRateTimeOrder(Long rateModelId, String startTime, String endTime,String serialNumber) {
                return R.fail(3886,"查询该充电订单时段失败");
            }

            @Override
            public R getCrossDayXhpcRateTimeOrder(Long rateModelId, String startTime, String endTime,String serialNumber) {
                return R.fail(3886,"查询该充电订单时段失败");
            }
        };
    }
}
