优化
This commit is contained in:
@@ -192,7 +192,14 @@ public class ContainerService {
|
||||
if (repository.containerNoExists(containerNo, id)) throw conflict("集装箱号已存在");
|
||||
try {
|
||||
if (repository.updateTransport(id, containerNo, voyageNo, request.version(),
|
||||
operatorId, operatorName) != 1) throw conflict("货柜状态或版本已变化,请刷新后重试");
|
||||
operatorId, operatorName) != 1) {
|
||||
ContainerTransportHistoryEntity concurrent = transportHistories == null ? null
|
||||
: transportHistories.selectOperation(id, operatorId, operationId);
|
||||
if (concurrent != null && requestHash.equals(concurrent.getRequestHash())) {
|
||||
return required(id);
|
||||
}
|
||||
throw conflict("货柜状态或版本已变化,请刷新后重试");
|
||||
}
|
||||
} catch (DuplicateKeyException ex) { throw conflict("集装箱号已存在"); }
|
||||
ContainerTransportHistoryEntity history = new ContainerTransportHistoryEntity();
|
||||
history.setContainerBookingId(id); history.setBeforeContainerNo(current.getContainerNo());
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.baiyue.firstleg.dto.ContainerDtos.OceanBookingLinkRequest;
|
||||
import com.baiyue.firstleg.dto.ContainerDtos.OceanBookingUnlinkRequest;
|
||||
import com.baiyue.firstleg.dto.ContainerDtos.TransportUpdateRequest;
|
||||
import com.baiyue.firstleg.entity.ContainerBookingEntity;
|
||||
import com.baiyue.firstleg.entity.ContainerTransportHistoryEntity;
|
||||
import com.baiyue.firstleg.entity.LoadingPlanEntity;
|
||||
import com.baiyue.firstleg.entity.LoadingPickTaskEntity;
|
||||
import com.baiyue.firstleg.mapper.ContainerTransportHistoryMapper;
|
||||
|
||||
@@ -625,6 +625,30 @@ class SmartLoadingServiceTest {
|
||||
assertThat(updated.getValue().getWarehouseRemark()).isEqualTo("装柜时注意外箱");
|
||||
}
|
||||
|
||||
@Test
|
||||
void unchangedQuantityAndCargoSnapshotDoNotWriteAdjustmentHistory() {
|
||||
LoadingPlanEntity plan = plan("LOADING", 2);
|
||||
LoadingPlanItemEntity line = item(8, 9, 20, 2);
|
||||
line.setGrossWeightKg(new BigDecimal("4.00"));
|
||||
line.setNetWeightKg(new BigDecimal("3.0"));
|
||||
line.setVolumeCbm(new BigDecimal("1.000"));
|
||||
line.setPalletCount(0);
|
||||
when(repository.plan(1L)).thenReturn(plan);
|
||||
when(repository.item(1L, 8L)).thenReturn(line);
|
||||
when(repository.booking(99L)).thenReturn(booking());
|
||||
when(repository.candidate(1L, 100L, 10L, 20L)).thenReturn(candidate(10));
|
||||
when(repository.items(1L)).thenReturn(List.of(line));
|
||||
|
||||
Plan result = service.adjust(1L, 8L,
|
||||
new AdjustRequest(2, 2, 0, "adjust-noop"), 7L, "u");
|
||||
|
||||
assertThat(result.version()).isEqualTo(2);
|
||||
verify(repository, never()).touch(anyLong(), anyInt(), anyLong(), anyString());
|
||||
verify(repository, never()).update(any(LoadingPlanItemEntity.class));
|
||||
verify(repository, never()).insert(any(LoadingPlanHistoryEntity.class));
|
||||
verify(loadingPickService, never()).sync(anyLong(), any(LoadingPlanItemEntity.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void pickedQuantityConflictPrecedesCandidateAvailabilityValidation() {
|
||||
LoadingPlanEntity plan = plan("LOADING", 2);
|
||||
|
||||
Reference in New Issue
Block a user