修改托盘库库位选择逻辑,改为从中间的43,44列向两边扩散,先左后右

This commit is contained in:
李宇奇 2025-09-23 22:32:48 +08:00
parent 6b19b888c6
commit 7f00983377

View File

@ -1,4 +1,4 @@
package com.wms_main.service.business.serviceImpl; package com.wms_main.service.business.serviceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@ -148,10 +148,11 @@ public class StackerTaskServiceImpl implements IStackerTaskService {
} }
} }
return filterResult; return filterResult;
}).sorted(Comparator.comparingInt(TAppLocation::getLRow) }).collect(Collectors.toList());
.thenComparingInt(TAppLocation::getLCol) int maxCol = locationList.stream().mapToInt(TAppLocation::getLCol).max().orElse(86);
.thenComparingInt(TAppLocation::getLLayer)) candidateLocationList.sort(Comparator.comparingInt(TAppLocation::getLRow)
.toList(); .thenComparingInt(loc -> computeColOrder(loc.getLCol(), maxCol))
.thenComparingInt(TAppLocation::getLLayer));
// 若指定了 subArea则基于上述排序优先同 subArea 的库位 // 若指定了 subArea则基于上述排序优先同 subArea 的库位
if (locationFilter != null && StringUtils.isNotEmpty(locationFilter.getSubArea())) { if (locationFilter != null && StringUtils.isNotEmpty(locationFilter.getSubArea())) {
@ -349,6 +350,17 @@ public class StackerTaskServiceImpl implements IStackerTaskService {
} }
return result; return result;
} }
/**
* 列排序权重以列数中点为中心86列 => 中点在43/44之间
* 先靠近中点的列优先等距时优先左侧43再右侧44
* 计算采用整数运算distance2 = |col*2 - (maxCol + 1)|
*/
private int computeColOrder(int col, int maxCol) {
int centerTimes2 = maxCol + 1; // 偶数列的两个中心之和如86=>87
int distance2 = Math.abs(col * 2 - centerTimes2); // 与中心的距离×2
int side = (col <= centerTimes2 / 2) ? 0 : 1; // 左侧优先43 44
return distance2 * 2 + side; // 组合为稳定的权重
}
/** /**
* 找到最空闲的那台设备 * 找到最空闲的那台设备