fix(firstleg): persist ocean container allocation

This commit is contained in:
2026-08-08 21:49:41 +08:00
parent da85e30f33
commit 789d97675b
4 changed files with 75 additions and 38 deletions
@@ -167,7 +167,11 @@ public class OceanBookingService {
String action = "ALLOCATE_CONTAINER";
Detail replay = claimOrReplay(id, operatorId, action, key, hash(action, id, request));
if (replay != null) return replay;
requiredVersion(id, request.expectedVersion());
OceanBookingEntity booking = requiredVersion(id, request.expectedVersion());
if (!Set.of(OceanBookingStatus.SUBMITTED.name(), OceanBookingStatus.CONFIRMED.name(),
OceanBookingStatus.CHANGE_PENDING.name()).contains(booking.getStatus())) {
throw conflict("当前订舱状态不可分配柜次");
}
OceanBookingContainerRequirementEntity requirement = repository.requirement(id, request.requirementId());
if (requirement == null) throw new BizException(ResultCode.NOT_FOUND, "箱型需求不存在");
ContainerBookingEntity container = repository.containerBooking(request.containerBookingId());
@@ -179,7 +183,7 @@ public class OceanBookingService {
OceanBookingContainerAllocationEntity allocation = new OceanBookingContainerAllocationEntity();
allocation.setId(IdWorker.getId()); allocation.setOceanBookingId(id);
allocation.setRequirementId(request.requirementId()); allocation.setContainerBookingId(request.containerBookingId());
allocation.setAllocatedBy(operatorId); allocation.setAllocatedByName(name);
allocation.setAllocatedBy(operatorId); allocation.setAllocatedByName(name); allocation.setAllocatedAt(LocalDateTime.now());
try { repository.insert(allocation); } catch (DuplicateKeyException ex) { throw conflict("柜次已被其他订舱占用"); }
return complete(id, operatorId, action, key, detail(id));
}