优化
This commit is contained in:
+2
-1
@@ -43,7 +43,8 @@ public interface WarehousePalletLocationClient {
|
|||||||
BigDecimal totalVolumeCbm, BigDecimal palletCapacityCbm, String palletType,
|
BigDecimal totalVolumeCbm, BigDecimal palletCapacityCbm, String palletType,
|
||||||
LocalDateTime expiresAt, boolean measurementCompleted) {}
|
LocalDateTime expiresAt, boolean measurementCompleted) {}
|
||||||
record ConfirmRequest(long tenantId, long warehouseId, String sourceService, long businessId,
|
record ConfirmRequest(long tenantId, long warehouseId, String sourceService, long businessId,
|
||||||
long operatorId, BigDecimal totalVolumeCbm, BigDecimal palletCapacityCbm) {}
|
long operatorId, BigDecimal totalVolumeCbm, BigDecimal palletCapacityCbm,
|
||||||
|
int packageCount) {}
|
||||||
record ReleaseRequest(long tenantId, String sourceService, long businessId, long operatorId,
|
record ReleaseRequest(long tenantId, String sourceService, long businessId, long operatorId,
|
||||||
String reason) {}
|
String reason) {}
|
||||||
record SelectiveReleaseRequest(long tenantId, String sourceService, long businessId,
|
record SelectiveReleaseRequest(long tenantId, String sourceService, long businessId,
|
||||||
|
|||||||
+1
-1
@@ -52,7 +52,7 @@ public class MeasurementLocationOccupationService {
|
|||||||
WarehousePalletLocationClient.BatchResult occupied = requireSuccess(call(() -> warehouse.confirm(
|
WarehousePalletLocationClient.BatchResult occupied = requireSuccess(call(() -> warehouse.confirm(
|
||||||
internalToken, new WarehousePalletLocationClient.ConfirmRequest(resourceTenantId, warehouseId,
|
internalToken, new WarehousePalletLocationClient.ConfirmRequest(resourceTenantId, warehouseId,
|
||||||
SOURCE_SERVICE, inboundId, operatorId, volume,
|
SOURCE_SERVICE, inboundId, operatorId, volume,
|
||||||
properties.getDefaultPalletCapacityCbm()))), "测量完成后库位占用失败");
|
properties.getDefaultPalletCapacityCbm(), packageCount))), "测量完成后库位占用失败");
|
||||||
allocations.replace(tenantId, inboundId, warehouseId, resourceTenantId,
|
allocations.replace(tenantId, inboundId, warehouseId, resourceTenantId,
|
||||||
properties.getDefaultPalletCapacityCbm(), packageCount, occupied);
|
properties.getDefaultPalletCapacityCbm(), packageCount, occupied);
|
||||||
} catch (RuntimeException failure) {
|
} catch (RuntimeException failure) {
|
||||||
|
|||||||
+2
@@ -65,6 +65,7 @@ class MeasurementLocationOccupationServiceTest {
|
|||||||
verify(warehouse).confirm(org.mockito.ArgumentMatchers.eq("internal-token"), confirm.capture());
|
verify(warehouse).confirm(org.mockito.ArgumentMatchers.eq("internal-token"), confirm.capture());
|
||||||
assertThat(confirm.getValue().tenantId()).isEqualTo(PLATFORM_RESOURCE_TENANT);
|
assertThat(confirm.getValue().tenantId()).isEqualTo(PLATFORM_RESOURCE_TENANT);
|
||||||
assertThat(confirm.getValue().businessId()).isEqualTo(INBOUND);
|
assertThat(confirm.getValue().businessId()).isEqualTo(INBOUND);
|
||||||
|
assertThat(confirm.getValue().packageCount()).isEqualTo(20);
|
||||||
|
|
||||||
verify(allocations, times(2)).replace(
|
verify(allocations, times(2)).replace(
|
||||||
org.mockito.ArgumentMatchers.eq(BUSINESS_TENANT),
|
org.mockito.ArgumentMatchers.eq(BUSINESS_TENANT),
|
||||||
@@ -96,6 +97,7 @@ class MeasurementLocationOccupationServiceTest {
|
|||||||
ArgumentCaptor.forClass(WarehousePalletLocationClient.ConfirmRequest.class);
|
ArgumentCaptor.forClass(WarehousePalletLocationClient.ConfirmRequest.class);
|
||||||
verify(warehouse).confirm(org.mockito.ArgumentMatchers.eq("internal-token"), confirm.capture());
|
verify(warehouse).confirm(org.mockito.ArgumentMatchers.eq("internal-token"), confirm.capture());
|
||||||
assertThat(confirm.getValue().tenantId()).isEqualTo(PLATFORM_RESOURCE_TENANT);
|
assertThat(confirm.getValue().tenantId()).isEqualTo(PLATFORM_RESOURCE_TENANT);
|
||||||
|
assertThat(confirm.getValue().packageCount()).isEqualTo(20);
|
||||||
|
|
||||||
verify(allocations, times(2)).replace(
|
verify(allocations, times(2)).replace(
|
||||||
org.mockito.ArgumentMatchers.eq(BUSINESS_TENANT),
|
org.mockito.ArgumentMatchers.eq(BUSINESS_TENANT),
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ public final class PalletAllocationDtos {
|
|||||||
@Min(1) long businessId,
|
@Min(1) long businessId,
|
||||||
@Min(1) long operatorId,
|
@Min(1) long operatorId,
|
||||||
@NotNull @DecimalMin(value = "0", inclusive = false) @Digits(integer = 12, fraction = 6) BigDecimal totalVolumeCbm,
|
@NotNull @DecimalMin(value = "0", inclusive = false) @Digits(integer = 12, fraction = 6) BigDecimal totalVolumeCbm,
|
||||||
@NotNull @DecimalMin(value = "0", inclusive = false) @Digits(integer = 12, fraction = 6) BigDecimal palletCapacityCbm
|
@NotNull @DecimalMin(value = "0", inclusive = false) @Digits(integer = 12, fraction = 6) BigDecimal palletCapacityCbm,
|
||||||
|
@Min(1) int packageCount
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -110,9 +110,13 @@ public class PalletLocationAllocationService {
|
|||||||
}
|
}
|
||||||
active.sort(Comparator.comparingLong(LocationDtos.ActiveResource::reservationId));
|
active.sort(Comparator.comparingLong(LocationDtos.ActiveResource::reservationId));
|
||||||
List<LocationDtos.OccupancyTarget> targets = new ArrayList<>(active.size());
|
List<LocationDtos.OccupancyTarget> targets = new ArrayList<>(active.size());
|
||||||
|
int perAllocation = (int) Math.ceil((double) request.packageCount() / active.size());
|
||||||
|
int remainingPackages = request.packageCount();
|
||||||
for (int index = 0; index < active.size(); index++) {
|
for (int index = 0; index < active.size(); index++) {
|
||||||
|
int allocatedPackages = Math.min(perAllocation, remainingPackages);
|
||||||
|
remainingPackages -= allocatedPackages;
|
||||||
targets.add(new LocationDtos.OccupancyTarget(active.get(index).reservationId(),
|
targets.add(new LocationDtos.OccupancyTarget(active.get(index).reservationId(),
|
||||||
split.allocations().get(index).allocatedVolumeCbm(), null));
|
split.allocations().get(index).allocatedVolumeCbm(), allocatedPackages));
|
||||||
}
|
}
|
||||||
List<LocationDtos.OccupancyResult> occupied = locationResourceService.confirmOccupied(
|
List<LocationDtos.OccupancyResult> occupied = locationResourceService.confirmOccupied(
|
||||||
new LocationDtos.ConfirmCommand(request.tenantId(), request.warehouseId(), request.sourceService(),
|
new LocationDtos.ConfirmCommand(request.tenantId(), request.warehouseId(), request.sourceService(),
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ class PalletAllocationDtosValidationTest {
|
|||||||
assertThat(validator.validate(new PalletAllocationDtos.ReserveRequest(0L, 20L, "FIRSTLEG", 88L,
|
assertThat(validator.validate(new PalletAllocationDtos.ReserveRequest(0L, 20L, "FIRSTLEG", 88L,
|
||||||
"RK-001", "measure-88", 9L, BigDecimal.ONE, BigDecimal.ONE, "STANDARD", expiresAt, true))).isEmpty();
|
"RK-001", "measure-88", 9L, BigDecimal.ONE, BigDecimal.ONE, "STANDARD", expiresAt, true))).isEmpty();
|
||||||
assertThat(validator.validate(new PalletAllocationDtos.ConfirmRequest(0L, 20L, "FIRSTLEG", 88L,
|
assertThat(validator.validate(new PalletAllocationDtos.ConfirmRequest(0L, 20L, "FIRSTLEG", 88L,
|
||||||
9L, BigDecimal.ONE, BigDecimal.ONE))).isEmpty();
|
9L, BigDecimal.ONE, BigDecimal.ONE, 20))).isEmpty();
|
||||||
assertThat(validator.validate(new PalletAllocationDtos.ReleaseRequest(0L, "FIRSTLEG", 88L, 9L,
|
assertThat(validator.validate(new PalletAllocationDtos.ReleaseRequest(0L, "FIRSTLEG", 88L, 9L,
|
||||||
"入库补偿"))).isEmpty();
|
"入库补偿"))).isEmpty();
|
||||||
assertThat(validator.validate(new PalletAllocationDtos.SelectiveReleaseRequest(0L, "FIRSTLEG", 88L,
|
assertThat(validator.validate(new PalletAllocationDtos.SelectiveReleaseRequest(0L, "FIRSTLEG", 88L,
|
||||||
|
|||||||
Reference in New Issue
Block a user