feat(wms): 优化批次分配逻辑

- 新增死锁检测功能,判断任务执行顺序是否会产生死锁
- 如果存在死锁,使用拓扑排序找出可行的批次分配方案
- 如果不存在死锁,按 processId 合并任务生成批次组
- 优化了代码结构,提高了可读性和可维护性
This commit is contained in:
2025-08-14 17:59:32 +08:00
parent 96da503d0a
commit 1aee9a5f65
2 changed files with 124 additions and 15 deletions

View File

@@ -1,8 +1,10 @@
package com.klp.controller;
import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import com.klp.domain.vo.BatchGroupVo;
import lombok.RequiredArgsConstructor;
@@ -119,8 +121,8 @@ public class WmsBatchController extends BaseController {
.collect(java.util.stream.Collectors.groupingBy(BatchGroupVo::getProcessId));
// 合并相同processId的批次组
List<BatchGroupVo> mergedBatches = new java.util.ArrayList<>();
java.util.concurrent.atomic.AtomicInteger groupCounter = new java.util.concurrent.atomic.AtomicInteger(1);
List<BatchGroupVo> mergedBatches = new ArrayList<>();
AtomicInteger groupCounter = new AtomicInteger(1);
groupedByProcessId.forEach((processId, groups) -> {
// 创建一个新的合并后的批次组