package com.zd.system.api.chemical.factory;


import com.zd.common.core.domain.R;
import com.zd.system.api.chemical.RemoteStockService;
import com.zd.system.api.domain.InventoryTag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import javax.validation.constraints.NotNull;

/**
 * @author Administrator
 */
@Component
public class RemoteStockFallbackFactory implements FallbackFactory<RemoteStockService> {
    private static final Logger logger = LoggerFactory.getLogger(RemoteStockFallbackFactory.class);

    @Override
    public RemoteStockService create(Throwable throwable) {
        logger.error("化学品服务调用失败:{}", throwable.getMessage());
        return new RemoteStockService() {
            @Override
            public R<Boolean> rfidCheck(InventoryTag tag) {
                logger.error("保存调用失败:{}" ,throwable.getMessage());
                return R.fail("保存调用失败:" + throwable.getMessage());
            }

            @Override
            public void expireCheck() {
                logger.error("化学品库存过期调度失败：{}" ,throwable.getMessage());
            }

            @Override
            public void checkOvertime() {
                logger.error("化学品领用超时调度失败：{}" ,throwable.getMessage());
            }

            @Override
            public void indicatorMonitoring() {
                logger.error("定时监测实验室化学品存放风险指标：{}" , throwable.getMessage());
            }

            @Override
            public void queryUplinkResult() {
                logger.error("定时监测四医大短信上行结果异常：{}" , throwable.getMessage());
            }

            @Override
            public R sendSydSms(String content, Integer purpose, Long lockApplyId, @NotNull String... phones) {
                logger.error("四医大短信调用失败:{}" ,throwable.getMessage());
                return R.fail("四医大短信调用失败:" + throwable.getMessage());
            }

            @Override
            public void sendPhoneBySyd() {
                logger.error("四医大短信告警方案阶梯式通知流程调用失败:{}" ,throwable.getMessage());
            }
        };
    }
}
