This commit is contained in:
2026-08-27 13:35:52 +08:00
parent 3975759458
commit a79999d97c
9 changed files with 155 additions and 1 deletions
@@ -182,7 +182,8 @@ public class LoadingDeliveryService {
}
loadingModelBridge.requireCompleted(tenantId, target.sourceInboundId());
completionGate.requireReleasedBooking(tenantId, target.sourceInboundId());
requireCompletedPicking(tenantId, target.sourceInboundId());
// The cabinet PDA task is the source of truth while settling. The inbound-level
// picking review is completed after this transition and must not gate it here.
requireCompletionEvidence(tenantId, evidenceInboundId);
if (repository.completeLoadedChild(tenantId, target.sourceInboundId(), operatorId,
request.expectedVersion()) != 1) throw concurrent();
@@ -160,6 +160,7 @@ export async function run(context) {
channelCode, warehouseId,
billOfLadingNo: `BL-${suffix}`.slice(0, 128),
shippingCompanyId: id(bookingAgent.id), shippingCompanyName: bookingAgent.name,
carrierCode: 'MATSON',
bookingAgentId: id(bookingAgent.id), bookingAgentName: bookingAgent.name,
vesselName: `验收船-${suffix}`.slice(0, 128), voyageNo: `V-${suffix}`.slice(0, 64),
departurePortCode: 'CNSZX', departurePortName: '深圳',
@@ -176,6 +176,7 @@ export async function run(context) {
channelCode: initial?.summary?.channelCode,
billOfLadingNo: `P3BL-${suffix}`.slice(0, 128),
shippingCompanyId: id(shippingCarrier.id), shippingCompanyName: shippingCarrier.name,
carrierCode: 'MATSON',
bookingAgentId: id(supplier.id), bookingAgentName: supplier.name,
vesselName: `P3VESSEL-${suffix}`.slice(0, 128), voyageNo: `P3V-${suffix}`.slice(0, 64),
departurePortCode: 'CNSZX', departurePortName: '深圳', destinationPortCode: 'USLAX',
+12
View File
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0">
<localRepository>D:/firstlegRepo</localRepository>
<mirrors>
<mirror>
<id>central-direct</id>
<name>Maven Central</name>
<url>https://repo.maven.apache.org/maven2</url>
<mirrorOf>external:*</mirrorOf>
</mirror>
</mirrors>
</settings>
@@ -0,0 +1,82 @@
package com.baiyue.warehouse.controller;
import com.baiyue.common.core.api.ApiResponse;
import com.baiyue.common.core.api.PageResult;
import com.baiyue.common.core.api.ResultCode;
import com.baiyue.common.core.exception.BizException;
import com.baiyue.common.security.AuthenticatedUser;
import com.baiyue.warehouse.security.OverseasWarehousePermissions;
import com.baiyue.warehouse.dto.PalletRequests;
import com.baiyue.warehouse.entity.WarehousePalletEntity;
import com.baiyue.warehouse.service.WarehouseResourceService;
import com.baiyue.warehouse.service.DomesticWarehouseDirectory;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import jakarta.validation.Valid;
import java.util.List;
/** Exposes the domestic authoritative directory as read-only overseas resource options. */
@RestController
@RequestMapping("/api/platform/v1/warehouse-admin")
@Tag(name = "Platform overseas warehouse directory")
public class PlatformWarehouseDirectoryController {
private final DomesticWarehouseDirectory directory;
private final WarehouseResourceService resources;
public PlatformWarehouseDirectoryController(DomesticWarehouseDirectory directory,
WarehouseResourceService resources) {
this.directory = directory;
this.resources = resources;
}
@GetMapping("/pallets")
@PreAuthorize("hasAuthority('" + OverseasWarehousePermissions.PALLET_LIST + "')")
@Operation(summary = "Page public pallets across warehouses",
description = "Required authority: " + OverseasWarehousePermissions.PALLET_LIST)
public ApiResponse<PageResult<WarehousePalletEntity>> pallets(
@AuthenticationPrincipal AuthenticatedUser user,
@Valid PalletRequests.QueryRequest query) {
requirePlatform(user);
return ApiResponse.success(resources.publicPallets(WarehouseResourceService.PUBLIC_RESOURCE_SCOPE, query));
}
@GetMapping
@PreAuthorize("hasAuthority('" + OverseasWarehousePermissions.WAREHOUSE_LIST + "')")
@Operation(summary = "Page shared overseas receiving warehouses",
description = "Required authority: " + OverseasWarehousePermissions.WAREHOUSE_LIST)
public ApiResponse<PageResult<WarehouseOption>> warehouses(
@AuthenticationPrincipal AuthenticatedUser user,
@RequestParam(defaultValue = "1") long page,
@RequestParam(defaultValue = "200") long size) {
requirePlatform(user);
if (page < 1 || size < 1 || size > 200) {
throw new BizException(ResultCode.BAD_REQUEST, "分页参数无效");
}
List<WarehouseOption> all = directory.options().stream()
.map(value -> new WarehouseOption(value.warehouseId(), 0L, value.warehouseCode(),
value.warehouseName(), "OVERSEAS", value.status()))
.toList();
long from = Math.min((page - 1) * size, all.size());
long to = Math.min(from + size, all.size());
long pages = all.isEmpty() ? 0 : (all.size() + size - 1) / size;
return ApiResponse.success(new PageResult<>(all.subList((int) from, (int) to),
page, size, all.size(), pages));
}
private static void requirePlatform(AuthenticatedUser user) {
if (user == null || !"PLATFORM".equals(user.appCode())
|| user.tenantId() == null || user.tenantId() != 0L) {
throw new BizException(ResultCode.FORBIDDEN, "仅允许平台端访问");
}
}
public record WarehouseOption(long id, long customerId, String warehouseCode,
String warehouseName, String warehouseType, String status) { }
}
@@ -146,6 +146,18 @@ public class WarehouseResourceRepository {
return PageResult.from(pallets.selectPage(new Page<>(query.page(), query.size()), wrapper));
}
public PageResult<WarehousePalletEntity> pagePublicPallets(long customerId,
PalletRequests.QueryRequest query) {
var wrapper = new LambdaQueryWrapper<WarehousePalletEntity>()
.eq(WarehousePalletEntity::getCustomerId, customerId)
.eq(StringUtils.hasText(query.palletType()), WarehousePalletEntity::getPalletType, query.palletType())
.eq(StringUtils.hasText(query.status()), WarehousePalletEntity::getStatus, query.status())
.eq(query.locationId() != null, WarehousePalletEntity::getLocationId, query.locationId())
.like(StringUtils.hasText(query.keyword()), WarehousePalletEntity::getPalletCode, query.keyword())
.orderByDesc(WarehousePalletEntity::getCreatedAt);
return PageResult.from(pallets.selectPage(new Page<>(query.page(), query.size()), wrapper));
}
public void deletePallet(long id) {
pallets.deleteById(id);
}
@@ -218,6 +218,11 @@ public class WarehouseResourceService {
return repository.pagePallets(customerId, warehouseId, query);
}
public PageResult<WarehousePalletEntity> publicPallets(long customerId,
PalletRequests.QueryRequest query) {
return repository.pagePublicPallets(customerId, query);
}
@Transactional
public void deletePallet(long customerId, long warehouseId, long id) {
WarehousePalletEntity pallet = requirePallet(customerId, warehouseId, id);
@@ -0,0 +1,33 @@
package com.baiyue.warehouse.controller;
import com.baiyue.common.security.AuthenticatedUser;
import com.baiyue.warehouse.dto.SharedWarehouseReference;
import com.baiyue.warehouse.service.DomesticWarehouseDirectory;
import com.baiyue.warehouse.service.WarehouseResourceService;
import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.Set;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
class PlatformWarehouseDirectoryControllerTest {
@Test
void pagesPublicSharedWarehouseOptions() {
DomesticWarehouseDirectory directory = mock(DomesticWarehouseDirectory.class);
when(directory.options()).thenReturn(List.of(
new SharedWarehouseReference(21L, "US-LAX", "洛杉矶仓", "ACTIVE")));
var controller = new PlatformWarehouseDirectoryController(directory, mock(WarehouseResourceService.class));
var user = new AuthenticatedUser(1L, 0L, 0L, 2L,
"tester", "PLATFORM", "PLATFORM", Set.of());
var page = controller.warehouses(user, 1, 200).data();
assertEquals(1, page.total());
assertEquals(21L, page.records().get(0).id());
assertEquals(0L, page.records().get(0).customerId());
assertEquals("OVERSEAS", page.records().get(0).warehouseType());
}
}
@@ -32,6 +32,13 @@ class WarehouseResourcePermissionContractTest {
assertPermission(methods.get("deletePallet"), PREFIX + "pallet:delete");
}
@Test
void warehouseDirectoryUsesCanonicalListAuthority() throws Exception {
assertPermission(PlatformWarehouseDirectoryController.class.getDeclaredMethod(
"warehouses", com.baiyue.common.security.AuthenticatedUser.class, long.class, long.class),
PREFIX + "warehouse:list");
}
private static void assertPermission(Method method, String authority) {
PreAuthorize preAuthorize = method.getAnnotation(PreAuthorize.class);
Operation operation = method.getAnnotation(Operation.class);