fix: 是否启用acs连接
This commit is contained in:
@@ -18,6 +18,12 @@
|
|||||||
<artifactId>nl-common</artifactId>
|
<artifactId>nl-common</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.nl.cloud</groupId>
|
||||||
|
<artifactId>nl-module-infra-api</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Spring 核心 -->
|
<!-- Spring 核心 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package cn.code.nl.framework.execute.config;
|
|||||||
|
|
||||||
import cn.code.nl.framework.execute.biz.api.lms.LmsTaskCommonApi;
|
import cn.code.nl.framework.execute.biz.api.lms.LmsTaskCommonApi;
|
||||||
import cn.code.nl.framework.execute.biz.api.wms.WmsTaskCommonApi;
|
import cn.code.nl.framework.execute.biz.api.wms.WmsTaskCommonApi;
|
||||||
|
import cn.code.nl.module.infra.api.config.ConfigApi;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
|
|
||||||
@@ -13,6 +14,6 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
|
|||||||
* @Date: 2026/7/15
|
* @Date: 2026/7/15
|
||||||
*/
|
*/
|
||||||
@AutoConfiguration
|
@AutoConfiguration
|
||||||
@EnableFeignClients(clients = {LmsTaskCommonApi.class, WmsTaskCommonApi.class})
|
@EnableFeignClients(clients = {LmsTaskCommonApi.class, WmsTaskCommonApi.class, ConfigApi.class})
|
||||||
public class NlExecuteRpcAutoConfiguration {
|
public class NlExecuteRpcAutoConfiguration {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +1,24 @@
|
|||||||
package cn.code.nl.framework.common.util.http;
|
package cn.code.nl.framework.execute.util.http;
|
||||||
|
|
||||||
import cn.code.nl.framework.common.exception.ServerException;
|
|
||||||
import cn.code.nl.framework.common.exception.ServiceException;
|
import cn.code.nl.framework.common.exception.ServiceException;
|
||||||
import cn.code.nl.framework.common.pojo.AcsBaseRespDTO;
|
import cn.code.nl.framework.common.pojo.AcsBaseRespDTO;
|
||||||
import cn.code.nl.framework.common.pojo.CommonResult;
|
import cn.code.nl.framework.common.util.http.HttpUtils;
|
||||||
import cn.code.nl.framework.common.util.json.JsonUtils;
|
import cn.code.nl.framework.common.util.json.JsonUtils;
|
||||||
import cn.code.nl.framework.common.util.spring.SpringUtils;
|
import cn.code.nl.framework.common.util.spring.SpringUtils;
|
||||||
|
import cn.code.nl.module.infra.api.config.ConfigApi;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.net.*;
|
||||||
import java.net.ConnectException;
|
|
||||||
import java.net.NoRouteToHostException;
|
|
||||||
import java.net.SocketException;
|
|
||||||
import java.net.SocketTimeoutException;
|
|
||||||
import java.net.UnknownHostException;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ACS 调用工具
|
* ACS 调用工具
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class AcsUtil {
|
public class AcsUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,9 +35,9 @@ public class AcsUtil {
|
|||||||
* 发送 POST 请求并解析响应
|
* 发送 POST 请求并解析响应
|
||||||
*
|
*
|
||||||
* @param serverAddress ACS 服务地址
|
* @param serverAddress ACS 服务地址
|
||||||
* @param api API 路径
|
* @param api API 路径
|
||||||
* @param request 请求参数
|
* @param request 请求参数
|
||||||
* @param responseType 响应类型
|
* @param responseType 响应类型
|
||||||
* @return 响应对象
|
* @return 响应对象
|
||||||
*/
|
*/
|
||||||
public static <T> T post(String serverAddress, String api, Object request, Class<T> responseType) {
|
public static <T> T post(String serverAddress, String api, Object request, Class<T> responseType) {
|
||||||
@@ -71,29 +69,13 @@ public class AcsUtil {
|
|||||||
* 获取 ACS 开关配置
|
* 获取 ACS 开关配置
|
||||||
*/
|
*/
|
||||||
private static String getAcsSwitchConfigValue() {
|
private static String getAcsSwitchConfigValue() {
|
||||||
Object configApi;
|
|
||||||
try {
|
try {
|
||||||
configApi = SpringUtils.getBean("configApi");
|
ConfigApi configApi = SpringUtils.getBean("configApi");
|
||||||
} catch (RuntimeException ex) {
|
String checkedData = configApi.getConfigValueByKey(ACS_SWITCH_CONFIG_KEY).getCheckedData();
|
||||||
return null;
|
return ObjectUtil.isEmpty(checkedData) ? ACS_DISABLED : checkedData;
|
||||||
}
|
} catch (Exception ex) {
|
||||||
try {
|
log.error("获取 ACS 开关配置失败", ex);
|
||||||
Object result = configApi.getClass()
|
return ACS_DISABLED;
|
||||||
.getMethod("getConfigValueByKey", String.class)
|
|
||||||
.invoke(configApi, ACS_SWITCH_CONFIG_KEY);
|
|
||||||
if (result instanceof CommonResult<?> commonResult) {
|
|
||||||
Object data = commonResult.getCheckedData();
|
|
||||||
return data instanceof String value ? value : null;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
} catch (InvocationTargetException ex) {
|
|
||||||
Throwable targetException = ex.getTargetException();
|
|
||||||
if (targetException instanceof RuntimeException runtimeException) {
|
|
||||||
throw runtimeException;
|
|
||||||
}
|
|
||||||
throw new ServerException(500, "获取 ACS 开关配置失败");
|
|
||||||
} catch (ReflectiveOperationException ex) {
|
|
||||||
throw new ServerException(500, "获取 ACS 开关配置失败");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2,8 +2,8 @@ package cn.code.nl.module.task.manage;
|
|||||||
|
|
||||||
import cn.code.nl.framework.common.exception.ServiceException;
|
import cn.code.nl.framework.common.exception.ServiceException;
|
||||||
import cn.code.nl.framework.common.pojo.CommonResult;
|
import cn.code.nl.framework.common.pojo.CommonResult;
|
||||||
import cn.code.nl.framework.common.util.http.AcsUtil;
|
|
||||||
import cn.code.nl.framework.common.util.json.JsonUtils;
|
import cn.code.nl.framework.common.util.json.JsonUtils;
|
||||||
|
import cn.code.nl.framework.execute.util.http.AcsUtil;
|
||||||
import cn.code.nl.module.infra.api.config.ConfigApi;
|
import cn.code.nl.module.infra.api.config.ConfigApi;
|
||||||
import cn.code.nl.module.task.dal.dataobject.transporttask.TransportTaskDO;
|
import cn.code.nl.module.task.dal.dataobject.transporttask.TransportTaskDO;
|
||||||
import cn.code.nl.module.task.dal.mysql.transporttask.TransportTaskMapper;
|
import cn.code.nl.module.task.dal.mysql.transporttask.TransportTaskMapper;
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package cn.code.nl.module.task.manage;
|
|||||||
|
|
||||||
import cn.code.nl.framework.common.exception.ServiceException;
|
import cn.code.nl.framework.common.exception.ServiceException;
|
||||||
import cn.code.nl.framework.common.pojo.CommonResult;
|
import cn.code.nl.framework.common.pojo.CommonResult;
|
||||||
import cn.code.nl.framework.common.util.http.AcsUtil;
|
|
||||||
import cn.code.nl.framework.common.util.json.JsonUtils;
|
import cn.code.nl.framework.common.util.json.JsonUtils;
|
||||||
|
import cn.code.nl.framework.execute.util.http.AcsUtil;
|
||||||
import cn.code.nl.module.infra.api.config.ConfigApi;
|
import cn.code.nl.module.infra.api.config.ConfigApi;
|
||||||
import cn.code.nl.module.task.dal.dataobject.transporttask.TransportTaskDO;
|
import cn.code.nl.module.task.dal.dataobject.transporttask.TransportTaskDO;
|
||||||
import cn.code.nl.module.task.enums.TaskOperationTypeEnum;
|
import cn.code.nl.module.task.enums.TaskOperationTypeEnum;
|
||||||
|
|||||||
Reference in New Issue
Block a user