fix(firstleg): refresh recommendation capacity
This commit is contained in:
@@ -368,6 +368,13 @@ public class SmartLoadingService {
|
||||
if (!visitedGroups.add(candidate.coLoadGroupId()) || StringUtils.hasText(candidate.blockReason())) {
|
||||
continue;
|
||||
}
|
||||
GroupSnapshot currentGroup = group(candidate.accountId(), candidate.inboundId());
|
||||
if (currentGroup == null || !"ACTIVE".equals(currentGroup.status())
|
||||
|| currentGroup.lockedPlanId() != null
|
||||
|| !groupFits(booking, repository.items(planId), currentGroup,
|
||||
availableCandidates(booking))) {
|
||||
continue;
|
||||
}
|
||||
LoadingPlanEntity current = repository.plan(planId);
|
||||
assignGroup(planId, new AssignGroupRequest(candidate.inboundId(), current.getVersion(),
|
||||
"REC-GRP-" + sha256(operation + '|' + candidate.coLoadGroupId()).substring(0, 48)),
|
||||
@@ -640,8 +647,7 @@ public class SmartLoadingService {
|
||||
if (!"ACTIVE".equals(group.status()) || group.lockedPlanId() != null) {
|
||||
throw conflict("同柜不可拆组已锁定或已消费");
|
||||
}
|
||||
List<Candidate> available = repository.candidates(booking.getWarehouseId()).stream()
|
||||
.filter(candidate -> sameChannel(booking, candidate) && sameCustomerScope(booking, candidate)).toList();
|
||||
List<Candidate> available = availableCandidates(booking);
|
||||
Map<Long, List<Candidate>> result = new LinkedHashMap<>();
|
||||
for (Member member : group.members()) {
|
||||
if (!repository.activeItemsByInbound(member.tenantId(), member.inboundId()).isEmpty()) {
|
||||
@@ -663,6 +669,11 @@ public class SmartLoadingService {
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<Candidate> availableCandidates(ContainerBookingEntity booking) {
|
||||
return repository.candidates(booking.getWarehouseId()).stream()
|
||||
.filter(candidate -> sameChannel(booking, candidate) && sameCustomerScope(booking, candidate)).toList();
|
||||
}
|
||||
|
||||
private boolean groupFits(ContainerBookingEntity booking, List<LoadingPlanItemEntity> planItems,
|
||||
GroupSnapshot group, List<Candidate> available) {
|
||||
if (booking.getCapacityCbm() == null || booking.getMaxWeightKg() == null) return false;
|
||||
|
||||
Reference in New Issue
Block a user