优化
This commit is contained in:
@@ -39,7 +39,8 @@ public final class PalletAllocationDtos {
|
||||
@Min(1) long businessId,
|
||||
@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 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));
|
||||
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++) {
|
||||
int allocatedPackages = Math.min(perAllocation, remainingPackages);
|
||||
remainingPackages -= allocatedPackages;
|
||||
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(
|
||||
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,
|
||||
"RK-001", "measure-88", 9L, BigDecimal.ONE, BigDecimal.ONE, "STANDARD", expiresAt, true))).isEmpty();
|
||||
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,
|
||||
"入库补偿"))).isEmpty();
|
||||
assertThat(validator.validate(new PalletAllocationDtos.SelectiveReleaseRequest(0L, "FIRSTLEG", 88L,
|
||||
|
||||
Reference in New Issue
Block a user