package com.hdkj.lt.feign.fallback;

import com.hdkj.lt.core.bizms.modle.dto.StateEstimation;
import com.hdkj.lt.core.bizms.modle.request.StateEstimationEquipRequest;
import com.hdkj.lt.feign.IMeasurementApiClient;
import com.hdkj.lt.modle.dto.measurement.*;
import com.hdkj.lt.modle.vo.measurement.*;
import com.hdkj.hussar.ApiResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.Map;

/**
 * @author rj
 * @date 2025/5/24 下午3:24
 * @description
 */
@Slf4j
@Component
public class MeasurementApiClientFallBack implements FallbackFactory<IMeasurementApiClient> {

    @Override
    public IMeasurementApiClient create(Throwable cause) {
        return new IMeasurementApiClient() {
            @Override
            public ApiResponse<MeasurementTokenVO> getAccessToken(MeasurementTokenDTO measurementTokenDTO) {
                log.error("量测-getAccessToken 远程调用服务异常, 参数:{}", measurementTokenDTO);
                return ApiResponse.fail(String.format("量测-getAccessToken 远程调用服务异常：%s", cause.getMessage()));
            }

            @Override
            public ApiResponse<ContainDeviceMeasurementVO> getTelesignalCommonQuery(ContainDeviceMeasurementDTO containDeviceMeasurementDTO) {
                log.error("量测-getContainDeviceMeasurement 远程调用服务异常, 参数:{}", containDeviceMeasurementDTO);
                return ApiResponse.fail(String.format("量测-getContainDeviceMeasurement 远程调用服务异常：%s", cause.getMessage()));
            }

            @Override
            public ApiResponse<DistributionTransformerVO> getTelemetryCommonQuery(DistributionTransformerDTO distributionTransformerDTO) {
                log.error("量测-getDistributionTransformer 远程调用服务异常, 参数:{}", distributionTransformerDTO);
                return ApiResponse.fail(String.format("量测-getDistributionTransformer 远程调用服务异常：%s", cause.getMessage()));
            }

            @Override
            public ApiResponse<Map<String, BigDecimal>> queryPeriodByCommonQuery(StateEstimationEquipRequest request) {
                log.error("量测-queryPeriodByCommonQuery 远程调用服务异常, 参数:{}", request);
                return ApiResponse.fail(String.format("量测-queryPeriodByCommonQuery 远程调用服务异常：%s", cause.getMessage()));
            }

            @Override
            public ApiResponse<StateEstimation> queryByFeederSaveCommonQuery(StateEstimationEquipRequest request) {
                log.error("量测-queryPeriodByCommonQuery 远程调用服务异常, 参数:{}", request);
                return ApiResponse.fail(String.format("量测-queryPeriodByCommonQuery 远程调用服务异常：%s", cause.getMessage()));
            }

            @Override
            public ApiResponse saveQuery(DistributionReceiveVO request) {
                log.error("量测-queryPeriodByCommonQuery 远程调用服务异常, 参数:{}", request);
                return ApiResponse.fail(String.format("量测-queryPeriodByCommonQuery 远程调用服务异常：%s", cause.getMessage()));

            }

            @Override
            public ApiResponse<RecordsVO> queryCommonQueryByDay(DistributionTransformerDTO distributionTransformerDTO) {
                log.error("量测-queryPeriodByCommonQuery 远程调用服务异常, 参数:{}", distributionTransformerDTO);
                return ApiResponse.fail(String.format("量测-queryPeriodByCommonQuery 远程调用服务异常：%s", cause.getMessage()));

            }
        };
    }
}
