fix:框架

This commit is contained in:
2026-07-15 16:31:42 +08:00
parent 2b7ddc2313
commit d47c911a0c
11 changed files with 47 additions and 264 deletions

View File

@@ -0,0 +1,16 @@
package cn.code.nl.framework.execute.config;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
/**
* 任务执行模块自动配置
* 扫描框架包下的 Spring 组件(如 TaskCommonApiFactory、TaskFactory 等)
*
* @Author: liyongde
* @Date: 2026/7/15
*/
@AutoConfiguration
@ComponentScan(basePackages = "cn.code.nl.framework.execute")
public class NlExecuteAutoConfiguration {
}

View File

@@ -0,0 +1,18 @@
package cn.code.nl.framework.execute.config;
import cn.code.nl.framework.execute.biz.lms.LmsTaskCommonApi;
import cn.code.nl.framework.execute.biz.wms.WmsTaskCommonApi;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* 任务执行模块 RPC 配置
* 在框架层注册 Feign Client确保引用此框架的模块自动拥有对应的 Bean
*
* @Author: liyongde
* @Date: 2026/7/15
*/
@AutoConfiguration
@EnableFeignClients(clients = {LmsTaskCommonApi.class, WmsTaskCommonApi.class})
public class NlExecuteRpcAutoConfiguration {
}

View File

@@ -6,7 +6,7 @@ import cn.code.nl.framework.execute.biz.TaskCommonApi;
import cn.code.nl.framework.execute.biz.lms.LmsTaskCommonApi;
import cn.code.nl.framework.execute.biz.wms.WmsTaskCommonApi;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
@@ -23,10 +23,10 @@ import java.util.Map;
@Component
public class TaskCommonApiFactory {
@Resource
@Autowired(required = false)
private LmsTaskCommonApi lmsTaskCommonApi;
@Resource
@Autowired(required = false)
private WmsTaskCommonApi wmsTaskCommonApi;
/**
@@ -35,12 +35,16 @@ public class TaskCommonApiFactory {
private final Map<String, TaskCommonApi> apiMap = new HashMap<>();
/**
* 初始化映射关系
* 初始化映射关系(仅注册当前模块已配置的 Feign Client
*/
@PostConstruct
public void init() {
apiMap.put(RpcConstants.LMS_NAME, lmsTaskCommonApi);
apiMap.put(RpcConstants.WMS_NAME, wmsTaskCommonApi);
if (lmsTaskCommonApi != null) {
apiMap.put(RpcConstants.LMS_NAME, lmsTaskCommonApi);
}
if (wmsTaskCommonApi != null) {
apiMap.put(RpcConstants.WMS_NAME, wmsTaskCommonApi);
}
}
/**

View File

@@ -0,0 +1,2 @@
cn.code.nl.framework.execute.config.NlExecuteAutoConfiguration
cn.code.nl.framework.execute.config.NlExecuteRpcAutoConfiguration