fix: 任务并发控制

This commit is contained in:
2026-07-27 10:44:51 +08:00
parent ed0b18a4af
commit 25ea2a248f
27 changed files with 333 additions and 36 deletions

View File

@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import jakarta.validation.Valid;
import java.util.List;
/**
* Task 服务 RPC API 接口
@@ -45,4 +46,14 @@ public interface TransportTaskApi {
@GetMapping(PREFIX + "/getTaskByCode")
@Operation(summary = "根据 taskCode 查询任务")
CommonResult<TaskInfoDTO> getTaskByCode(@RequestParam("taskCode") String taskCode);
@GetMapping(PREFIX + "/getRunningTaskByMaterialId")
@Operation(summary = "根据 materialId 和 ownerService 查询运行中任务")
CommonResult<List<TaskInfoDTO>> getRunningTaskByMaterialId(@RequestParam("materialId") Long materialId,
@RequestParam("ownerService") String ownerService);
@GetMapping(PREFIX + "/getRunningTaskByMaterialCode")
@Operation(summary = "根据 materialCode 和 ownerService 查询运行中任务")
CommonResult<List<TaskInfoDTO>> getRunningTaskByMaterialCode(@RequestParam("materialCode") String materialCode,
@RequestParam("ownerService") String ownerService);
}

View File

@@ -91,6 +91,14 @@ public class TaskInfoDTO implements Serializable {
* 载具编码2
*/
private String vehicleCode2;
/**
* 物料id
*/
private Long materialId;
/**
* 物料编码
*/
private String materialCode;
/**
* 车号
*/

View File

@@ -21,14 +21,6 @@ public class TransportTaskCreateReqDTO {
@NotEmpty(message = "业务归属服务不能为空")
private String ownerService;
@Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "业务类型不能为空")
private String bizType;
@Schema(description = "业务侧标识", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "业务侧标识不能为空")
private String bizId;
@Schema(description = "业务回调处理器编码", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "业务回调处理器编码不能为空")
private String handleCode;
@@ -59,6 +51,12 @@ public class TransportTaskCreateReqDTO {
@Schema(description = "载具编码2")
private String vehicleCode2;
@Schema(description = "物料id")
private Long materialId;
@Schema(description = "物料编码")
private String materialCode;
@Schema(description = "优先级")
private String priority;

View File

@@ -0,0 +1,12 @@
package cn.code.nl.module.task.message;
/**
* 全局锁的key 或 前缀
* @Author: liyongde
* @Date: 2026/7/27 10:16
*/
public interface LockKeyConstants {
/** 任务状态变更消费锁前缀 */
String TASK_STATUS_CHANGE_LOCK_KEY = "task:task-status-change:";
}