fix(dispatch): use supported capacity for default draft groups

This commit is contained in:
2026-10-15 18:45:05 +08:00
parent cda5f3dc32
commit 2631bd3af4
3 changed files with 40 additions and 3 deletions
@@ -211,7 +211,7 @@ public class DispatchService {
if (existing.size() > 1) throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "存在多个装车分组,请明确选择目标分组");
if (existing.size() == 1) boundContainer = existing.get(0);
else {
boundContainer = new DispatchDraftContainer(); boundContainer.setId(IdWorker.getId()); boundContainer.setDraftId(draft.getId()); boundContainer.setDraftToken(request.draftToken()); boundContainer.setSequenceNo(1); boundContainer.setCapacity(500); boundContainer.setCreatedAt(LocalDateTime.now()); boundContainer.setUpdatedAt(LocalDateTime.now()); draftContainers.insert(boundContainer);
boundContainer = new DispatchDraftContainer(); boundContainer.setId(IdWorker.getId()); boundContainer.setDraftId(draft.getId()); boundContainer.setDraftToken(request.draftToken()); boundContainer.setSequenceNo(1); boundContainer.setCapacity(30); boundContainer.setCreatedAt(LocalDateTime.now()); boundContainer.setUpdatedAt(LocalDateTime.now()); draftContainers.insert(boundContainer);
}
}
if (boundContainer == null || !request.draftToken().equals(boundContainer.getDraftToken()) || !Objects.equals(boundContainer.getDraftId(), draft.getId())) throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "装车托盘不存在");
@@ -335,7 +335,9 @@ public class DispatchService {
actualGroups.add(container.getId());
var group = groups.get(container.getId());
if (group == null) throw new ResponseStatusException(HttpStatus.CONFLICT, "草稿分组已变化,请重新加载");
if (container.getCapacity() == null || bound.size() > container.getCapacity())
if (container.getCapacity() == null || !Set.of(15, 30).contains(container.getCapacity()))
throw new ResponseStatusException(HttpStatus.CONFLICT, "车辆大小仅支持15托或30托");
if (bound.size() > container.getCapacity())
throw new ResponseStatusException(HttpStatus.CONFLICT, "装车分组超过车型托位容量");
Set<String> actual = new HashSet<>();
Set<String> customers = new HashSet<>();