Test #1

Merged
admin merged 1726 commits from test into main 2026-09-17 11:52:45 +08:00
3 changed files with 33 additions and 1 deletions
Showing only changes of commit daf0ee2acd - Show all commits
@@ -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);