装柜修改
This commit is contained in:
+6
-4
@@ -108,13 +108,15 @@ public class PalletLocationAllocationService {
|
||||
if (active.size() != split.palletCount()) {
|
||||
throw new BizException(ResultCode.CONFLICT, "活动预占数量与托盘拆分数量不一致");
|
||||
}
|
||||
if (active.size() > request.packageCount()) {
|
||||
throw new BizException(ResultCode.CONFLICT, "托盘数量超过入库单总箱数,无法为每个托盘分配至少一箱");
|
||||
}
|
||||
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();
|
||||
int basePackageCount = request.packageCount() / active.size();
|
||||
int remainder = request.packageCount() % active.size();
|
||||
for (int index = 0; index < active.size(); index++) {
|
||||
int allocatedPackages = Math.min(perAllocation, remainingPackages);
|
||||
remainingPackages -= allocatedPackages;
|
||||
int allocatedPackages = basePackageCount + (index < remainder ? 1 : 0);
|
||||
targets.add(new LocationDtos.OccupancyTarget(active.get(index).reservationId(),
|
||||
split.allocations().get(index).allocatedVolumeCbm(), allocatedPackages));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user