fix(firstleg): resolve loading list lifecycle by plan

This commit is contained in:
2026-08-31 15:26:47 +08:00
parent 0122ad314b
commit c9792b1f63
7 changed files with 137 additions and 5 deletions
@@ -12,6 +12,7 @@ import com.baiyue.firstleg.dto.LoadingListDtos.PreloadSummary;
import com.baiyue.firstleg.dto.LoadingListDtos.ConfirmPreloadRequest;
import com.baiyue.firstleg.dto.LoadingListDtos.PreloadConfirmationResponse;
import com.baiyue.firstleg.dto.LoadingListDtos.TransportUpdateRequest;
import com.baiyue.firstleg.dto.LoadingListDtos.LifecycleResolution;
import com.baiyue.firstleg.service.FirstlegScopeGuard;
import com.baiyue.firstleg.service.LoadingListService;
import io.swagger.v3.oas.annotations.Operation;
@@ -60,6 +61,17 @@ public class PlatformLoadingListController {
return ApiResponse.success(service.preloadDetail(planId, warehouseId));
}
@Operation(summary = "解析装柜计划当前详情阶段",
description = "按稳定 planId 返回 PRELOAD 或 LOADING_LIST,供页面在计划完成后受控切换详情接口。")
@GetMapping("/loading-plans/{planId}/lifecycle")
@PreAuthorize("hasAuthority('platform:firstleg:preload:list')")
public ApiResponse<LifecycleResolution> lifecycle(
@AuthenticationPrincipal AuthenticatedUser user, @PathVariable @Positive long planId,
@RequestParam @Positive long warehouseId) {
FirstlegScopeGuard.platform(user);
return ApiResponse.success(service.lifecycle(planId, warehouseId));
}
@Operation(summary = "修改装柜运输字段", description = "已推送且仍为 EDITING 的预装清单可补录或修改集装箱号与航次;LOADING 阶段按稳定柜次身份规则维护,不能清空已创建 PDA 任务的柜号。")
@PatchMapping("/loading-plans/{planId}/transport")
@PreAuthorize("hasAuthority('platform:firstleg:preload:edit')")
@@ -115,6 +115,17 @@ public final class LoadingListDtos {
) {
}
public record LifecycleResolution(
Long planId,
Long containerBookingId,
Long warehouseId,
String planNo,
String planStatus,
String detailResource,
String requiredPermission
) {
}
public record PreloadSummary(
Long planId,
Long containerBookingId,
@@ -16,6 +16,7 @@ import com.baiyue.firstleg.dto.LoadingListDtos.TransportUpdateRequest;
import com.baiyue.firstleg.dto.LoadingListDtos.BusinessDocument;
import com.baiyue.firstleg.dto.LoadingListDtos.DocumentAttachRequest;
import com.baiyue.firstleg.dto.LoadingListDtos.DocumentCompleteRequest;
import com.baiyue.firstleg.dto.LoadingListDtos.LifecycleResolution;
import com.baiyue.firstleg.client.LoadingDocumentFileClient;
import com.baiyue.firstleg.entity.ContainerDocumentEntity;
import com.baiyue.firstleg.mapper.LoadingListQueryMapper.AggregateRow;
@@ -97,20 +98,38 @@ public class LoadingListService {
AggregateRow row = requirePlan(planId);
requireWarehouse(row, warehouseId);
if (!PRELOAD_STATUSES.contains(row.getPlanStatus())) {
throw notFound("预装清单不存在");
throw conflict("装柜计划已离开预装详情阶段");
}
return repository.preloadDetail(row);
}
public LifecycleResolution lifecycle(long planId, long warehouseId) {
AggregateRow row = requirePlan(planId);
requireWarehouse(row, warehouseId);
if (PRELOAD_STATUSES.contains(row.getPlanStatus())) {
return lifecycle(row, "PRELOAD", "platform:firstleg:preload:list");
}
if ("COMPLETED".equals(row.getPlanStatus())) {
return lifecycle(row, "LOADING_LIST", "platform:firstleg:loading-list:list");
}
throw conflict("装柜计划处于未知生命周期阶段");
}
public ConfirmedDetail confirmedDetail(long planId, long warehouseId) {
AggregateRow row = requirePlan(planId);
requireWarehouse(row, warehouseId);
if (!"COMPLETED".equals(row.getPlanStatus())) {
throw notFound("装柜清单不存在");
throw conflict("装柜计划尚未进入正式装柜清单阶段");
}
return repository.confirmedDetail(row);
}
private static LifecycleResolution lifecycle(AggregateRow row, String resource,
String permission) {
return new LifecycleResolution(row.getPlanId(), row.getContainerBookingId(),
row.getWarehouseId(), row.getPlanNo(), row.getPlanStatus(), resource, permission);
}
public BusinessDocument containerClearance(long bookingId) {
requireBookingPlan(bookingId);
return document(repository.document(bookingId, DESTINATION_CLEARANCE));
@@ -554,7 +573,7 @@ public class LoadingListService {
throw badRequest("warehouseId必须大于0");
}
if (!java.util.Objects.equals(row.getWarehouseId(), warehouseId)) {
throw notFound("装柜计划不属于当前仓库");
throw new BizException(ResultCode.FORBIDDEN, "装柜计划不属于当前仓库");
}
}