test(firstleg): cover phase3 container loading flow

This commit is contained in:
2026-08-08 21:34:39 +08:00
parent 2dae8b2029
commit da85e30f33
8 changed files with 644 additions and 15 deletions
@@ -314,7 +314,7 @@ public class SmartLoadingService {
|| !Objects.equals(history.getActionType(), action)
|| itemId != null && !Objects.equals(history.getLoadingPlanItemId(), itemId)
|| history.getAfterSnapshot() == null
|| !history.getAfterSnapshot().contains("\"requestHash\":\"" + requestHash + "\"")) {
|| !sameRequestHash(history.getAfterSnapshot(), requestHash)) {
throw conflict("operationId 已用于不同请求");
}
LoadingPlanEntity plan = repository.plan(planId);
@@ -322,6 +322,15 @@ public class SmartLoadingService {
return view(plan, requireBooking(plan.getContainerBookingId()));
}
private boolean sameRequestHash(String snapshot, String requestHash) {
try {
var value = objectMapper.readTree(snapshot);
return value != null && requestHash.equals(value.path("requestHash").asText());
} catch (JsonProcessingException exception) {
return false;
}
}
private void history(long planId, Long itemId, String action, String from, String to,
String operation, long operatorId, String operatorName) {
history(planId, itemId, action, from, to, operation, null, null, operatorId, operatorName);