xuhy
2024-09-25 ca825fdfe67223b2eb8a3f9c14b4e60e2339efc6
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/factory/SendMessageFallbackFactory.java
@@ -6,6 +6,8 @@
import com.ruoyi.integration.api.model.ChargingHandshake;
import com.ruoyi.integration.api.model.PlatformStartCharging;
import com.ruoyi.integration.api.model.PlatformStopCharging;
import io.seata.core.exception.TransactionException;
import io.seata.tm.api.GlobalTransactionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
@@ -29,12 +31,24 @@
    
            @Override
            public String platformStartCharging(PlatformStartCharging platformStartCharging) {
                throw new RuntimeException("远程启机失败" + throwable.getMessage());
                // 手动进行全局事务回滚
                try {
                    GlobalTransactionContext.getCurrent().rollback();
                } catch (TransactionException e) {
                    throw new RuntimeException(e);
                }
                return "远程启机失败";
            }
    
            @Override
            public String platformStopCharging(PlatformStopCharging platformStopCharging) {
                throw new RuntimeException("远程停机失败" + throwable.getMessage());
                // 手动进行全局事务回滚
                try {
                    GlobalTransactionContext.getCurrent().rollback();
                } catch (TransactionException e) {
                    throw new RuntimeException(e);
                }
                return "远程停机失败";
            }
        };
    }