fix:任务拆解

This commit is contained in:
2026-07-15 14:59:05 +08:00
parent a066ec3637
commit 90c4a9e8e9
16 changed files with 206 additions and 9 deletions

View File

@@ -185,6 +185,12 @@
<version>${revision}</version> <version>${revision}</version>
</dependency> </dependency>
<dependency>
<groupId>cn.nl.cloud</groupId>
<artifactId>nl-spring-boot-starter-execute</artifactId>
<version>${revision}</version>
</dependency>
<dependency> <dependency>
<groupId>com.github.xiaoymin</groupId> <groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId> <artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>

View File

@@ -43,4 +43,28 @@ public interface RpcConstants {
*/ */
String TASK_PREFIX = RPC_API_PREFIX + "/task"; String TASK_PREFIX = RPC_API_PREFIX + "/task";
/**
* lms 服务名
*
* 注意,需要保证和 spring.application.name 保持一致
*/
String LMS_NAME = "lms-server";
/**
* lms 服务的前缀
*/
String LMS_PREFIX = RPC_API_PREFIX + "/lms";
/**
* wms 服务名
*
* 注意,需要保证和 spring.application.name 保持一致
*/
String WMS_NAME = "wms-server";
/**
* wms 服务的前缀
*/
String WMS_PREFIX = RPC_API_PREFIX + "/wms";
} }

View File

@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.nl.cloud</groupId>
<artifactId>nl-framework</artifactId>
<version>${revision}</version>
</parent>
<artifactId>nl-spring-boot-starter-execute</artifactId>
<name>${project.artifactId}</name>
<dependencies>
<dependency>
<groupId>cn.nl.cloud</groupId>
<artifactId>nl-common</artifactId>
</dependency>
<!-- Spring 核心 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<optional>true</optional>
</dependency>
<!-- Spring 核心 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!-- RPC 远程调用相关 -->
<dependency>
<groupId>cn.nl.cloud</groupId>
<artifactId>nl-spring-boot-starter-rpc</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<scope>provided</scope> <!-- 设置为 provided主要是 PageParam 使用到 -->
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,10 @@
package cn.code.nl.framework.execute.biz;
/**
*
* @Author: liyongde
* @Date: 2026/7/15 14:54
*/
public interface TaskCommonApi {
void doHandlePicked();
}

View File

@@ -0,0 +1,16 @@
package cn.code.nl.framework.execute.biz.lms;
import cn.code.nl.framework.common.enums.RpcConstants;
import cn.code.nl.framework.execute.biz.TaskCommonApi;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
/**
* lms通用API
* @Author: liyongde
* @Date: 2026/7/15 14:39
*/
@FeignClient(name = RpcConstants.LMS_NAME, primary = false) // TODO 芋艿fallbackFactory =
@Tag(name = "RPC 服务 - lms任务")
public interface LmsTaskCommonApi extends TaskCommonApi {
}

View File

@@ -0,0 +1,6 @@
/**
* 业务实现的API
* @Author: liyongde
* @Date: 2026/7/15 14:38
*/
package cn.code.nl.framework.execute.biz;

View File

@@ -0,0 +1,16 @@
package cn.code.nl.framework.execute.biz.wms;
import cn.code.nl.framework.common.enums.RpcConstants;
import cn.code.nl.framework.execute.biz.TaskCommonApi;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
/**
*
* @Author: liyongde
* @Date: 2026/7/15 14:48
*/
@FeignClient(name = RpcConstants.WMS_NAME, primary = false) // TODO 芋艿fallbackFactory =
@Tag(name = "RPC 服务 - wms任务")
public interface WmsTaskCommonApi extends TaskCommonApi {
}

View File

@@ -0,0 +1,28 @@
package cn.code.nl.framework.execute.core;
/**
* 抽象类任务契约
* LMS/WMS子类遵守
*
* @Author: liyongde
* @Date: 2026/7/15 11:21
*/
public abstract class AbstractTask {
// ========== 取货完成、完成、取消的逻辑 ==========
public void doHandlePicked(Long taskId) {
// 子类实现取货完成业务
}
public abstract void doHandleFinish(Long taskId);
public abstract void doHandleCancel(Long taskId);
/**
* 二次请求
* @param taskId任务id
*/
public Long againApply(Long taskId) {
return null;
}
}

View File

@@ -0,0 +1,6 @@
/**
* 任务模板父类
* @Author: liyongde
* @Date: 2026/7/15 11:03
*/
package cn.code.nl.framework.execute;

View File

@@ -30,6 +30,7 @@
<module>nl-spring-boot-starter-biz-tenant</module> <module>nl-spring-boot-starter-biz-tenant</module>
<module>nl-spring-boot-starter-biz-data-permission</module> <module>nl-spring-boot-starter-biz-data-permission</module>
<module>nl-spring-boot-starter-biz-ip</module> <module>nl-spring-boot-starter-biz-ip</module>
<module>nl-spring-boot-starter-execute</module>
</modules> </modules>
<artifactId>nl-framework</artifactId> <artifactId>nl-framework</artifactId>

View File

@@ -32,6 +32,10 @@
<artifactId>nl-module-lms-api</artifactId> <artifactId>nl-module-lms-api</artifactId>
<version>${revision}</version> <version>${revision}</version>
</dependency> </dependency>
<dependency>
<groupId>cn.nl.cloud</groupId>
<artifactId>nl-spring-boot-starter-execute</artifactId>
</dependency>
<!-- 业务组件 --> <!-- 业务组件 -->
<dependency> <dependency>

View File

@@ -0,0 +1,25 @@
package cn.code.nl.module.lms;
import cn.code.nl.framework.execute.core.AbstractTask;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* 案例代码
* @Author: liyongde
* @Date: 2026/7/15 14:30
*/
@Slf4j
@Component
public class DemoTask extends AbstractTask {
@Override
public void doHandleFinish(Long taskId) {
}
@Override
public void doHandleCancel(Long taskId) {
}
}

View File

@@ -44,6 +44,11 @@
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency>
<groupId>cn.nl.cloud</groupId>
<artifactId>nl-spring-boot-starter-execute</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@@ -20,19 +20,17 @@ public enum TransportTaskStatusEnum {
EXECUTING("60", "执行中"), EXECUTING("60", "执行中"),
PICKED("61", "已取货搬运中"), PICKED("65", "已取货搬运中"),
FINISHED_CALLBACK_PENDING("67", "外部完成待业务处理"), FINISHED_CALLBACK_PENDING("75", "外部完成待业务处理"),
CANCEL_EXTERNAL_PENDING("68", "外部取消"), CANCEL_CALLBACK_PENDING("85", "外部取消待业务处理"),
CANCEL_CALLBACK_PENDING("69", "外部取消待业务处理"), FINISHED("79", "完成"),
FINISHED("70", "完成"), CANCELLED("89", "取消"),
CANCELLED("80", "取消"), FAILED("99", "失败");
FAILED("90", "失败");
private final String code; private final String code;
private final String name; private final String name;

View File

@@ -34,7 +34,7 @@ public class TaskEventProducer {
message.setEventId(UUID.randomUUID().toString()); message.setEventId(UUID.randomUUID().toString());
} }
String destination = TOPIC + ":" + message.getOwnerService(); String destination = TOPIC + "_" + message.getOwnerService();
try { try {
rocketMQTemplate.syncSend(destination, message); rocketMQTemplate.syncSend(destination, message);
log.info("MQ 发送成功, destination={}, taskId={}, eventType={}", log.info("MQ 发送成功, destination={}, taskId={}, eventType={}",

View File

@@ -105,6 +105,7 @@ public class TransportTaskFeedbackServiceImpl implements TransportTaskFeedbackSe
/** /**
* 处理取货完成(61):更新状态 + 同步 HTTP 回调 LMS/WMS * 处理取货完成(61):更新状态 + 同步 HTTP 回调 LMS/WMS
* ownerService 服务提供商
*/ */
private void handlePicked(TransportTaskDO task, AcsFeedbackReqDTO reqDTO) { private void handlePicked(TransportTaskDO task, AcsFeedbackReqDTO reqDTO) {
if (!isAllowedFrom(task.getTaskStatus(), "60", "61")) { if (!isAllowedFrom(task.getTaskStatus(), "60", "61")) {