根据现场设备情况,一层偏差3毫米,优先分配排列,后层深,先将低层2深度排列库位占满才分配高层库位
This commit is contained in:
parent
6ae0891cf7
commit
6af6bd1209
|
|
@ -127,6 +127,8 @@ public class StackerTaskServiceImpl implements IStackerTaskService {
|
|||
.eq(TAppLocation::getEquipmentId, equipmentId);
|
||||
// 查询库位
|
||||
List<TAppLocation> locationList = appLocationService.list(queryWrapper);
|
||||
// 计算当前设备的最大深度(默认2)
|
||||
int maxDepth = locationList.stream().mapToInt(TAppLocation::getLDepth).max().orElse(2);
|
||||
List<TAppLocation> candidateLocationList = locationList.stream().filter(item -> {
|
||||
boolean filterResult = item.getIsWorking() == 0 && item.getIsLock() == 0 && item.getIsOccupy() == 0;
|
||||
if (locationFilter != null) {
|
||||
|
|
@ -141,8 +143,9 @@ public class StackerTaskServiceImpl implements IStackerTaskService {
|
|||
}
|
||||
}
|
||||
return filterResult;
|
||||
}).sorted(Comparator.comparingInt(TAppLocation::getLDepth).reversed())
|
||||
.sorted(Comparator.comparingInt(location -> location.getLCol() + location.getLLayer()))
|
||||
})
|
||||
.sorted(Comparator.comparingInt(TAppLocation::getLLayer).reversed()
|
||||
.thenComparingInt(TAppLocation::getLCol).reversed())
|
||||
.toList();
|
||||
// 判断是否输入了subArea
|
||||
if (locationFilter != null && StringUtils.isNotEmpty(locationFilter.getSubArea())) {
|
||||
|
|
@ -154,26 +157,59 @@ public class StackerTaskServiceImpl implements IStackerTaskService {
|
|||
candidateLocationList = new ArrayList<>(firstList);// 先添加符合subArea的库位
|
||||
candidateLocationList.addAll(lastList);// 再添加不符合subArea的库位
|
||||
}
|
||||
// 找一个空闲的库位
|
||||
|
||||
// 第一轮:只尝试最大深度(例如 2 深度)库位
|
||||
for (TAppLocation candidateLocation : candidateLocationList) {
|
||||
if (!Objects.equals(candidateLocation.getLDepth(), maxDepth)) {
|
||||
continue; // 只处理最大深度
|
||||
}
|
||||
if (candidateLocation.getIsWorking() == 1 || candidateLocation.getIsLock() == 1
|
||||
|| candidateLocation.getIsOccupy() == 1) {
|
||||
continue;
|
||||
}
|
||||
if (isMaxDepthAvailable(locationList, candidateLocation)) {
|
||||
try {
|
||||
// 尝试锁定库位,锁定成功就返回
|
||||
// 申请当前库位,如果成功则返回
|
||||
if (appLocationService.update(new LambdaUpdateWrapper<TAppLocation>()
|
||||
.set(TAppLocation::getIsOccupy, 1)
|
||||
.set(TAppLocation::getVehicleId, requestVehicleId)
|
||||
.eq(TAppLocation::getLocationId, candidateLocation.getLocationId())
|
||||
.eq(TAppLocation::getIsOccupy, 0))) {
|
||||
// 当前库位可用
|
||||
targetLocation = candidateLocation;
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("锁定库位{}失败。", candidateLocation.getLocationId());
|
||||
log.error("请求库位{}失败.", candidateLocation.getLocationId());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (targetLocation != null) {
|
||||
// 找到了目标库位
|
||||
break;
|
||||
}
|
||||
|
||||
// 第二轮:若最大深度库位都不可用,再尝试其它深度(如 1 深度)库位
|
||||
for (TAppLocation candidateLocation : candidateLocationList) {
|
||||
if (Objects.equals(candidateLocation.getLDepth(), maxDepth)) {
|
||||
continue; // 第一轮已经尝试
|
||||
}
|
||||
if (candidateLocation.getIsWorking() == 1 || candidateLocation.getIsLock() == 1
|
||||
|| candidateLocation.getIsOccupy() == 1) {
|
||||
continue;
|
||||
}
|
||||
if (isMaxDepthAvailable(locationList, candidateLocation)) {
|
||||
try {
|
||||
// 申请当前库位,如果成功则返回
|
||||
if (appLocationService.update(new LambdaUpdateWrapper<TAppLocation>()
|
||||
.set(TAppLocation::getIsOccupy, 1)
|
||||
.set(TAppLocation::getVehicleId, requestVehicleId)
|
||||
.eq(TAppLocation::getLocationId, candidateLocation.getLocationId())
|
||||
.eq(TAppLocation::getIsOccupy, 0))) {
|
||||
targetLocation = candidateLocation;
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("请求库位{}失败.", candidateLocation.getLocationId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user