根据现场设备情况,一层偏差3毫米,优先分配排列,后层深,先将低层2深度排列库位占满才分配高层库位
This commit is contained in:
parent
6ae0891cf7
commit
6af6bd1209
|
|
@ -127,6 +127,8 @@ public class StackerTaskServiceImpl implements IStackerTaskService {
|
||||||
.eq(TAppLocation::getEquipmentId, equipmentId);
|
.eq(TAppLocation::getEquipmentId, equipmentId);
|
||||||
// 查询库位
|
// 查询库位
|
||||||
List<TAppLocation> locationList = appLocationService.list(queryWrapper);
|
List<TAppLocation> locationList = appLocationService.list(queryWrapper);
|
||||||
|
// 计算当前设备的最大深度(默认2)
|
||||||
|
int maxDepth = locationList.stream().mapToInt(TAppLocation::getLDepth).max().orElse(2);
|
||||||
List<TAppLocation> candidateLocationList = locationList.stream().filter(item -> {
|
List<TAppLocation> candidateLocationList = locationList.stream().filter(item -> {
|
||||||
boolean filterResult = item.getIsWorking() == 0 && item.getIsLock() == 0 && item.getIsOccupy() == 0;
|
boolean filterResult = item.getIsWorking() == 0 && item.getIsLock() == 0 && item.getIsOccupy() == 0;
|
||||||
if (locationFilter != null) {
|
if (locationFilter != null) {
|
||||||
|
|
@ -141,8 +143,9 @@ public class StackerTaskServiceImpl implements IStackerTaskService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return filterResult;
|
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();
|
.toList();
|
||||||
// 判断是否输入了subArea
|
// 判断是否输入了subArea
|
||||||
if (locationFilter != null && StringUtils.isNotEmpty(locationFilter.getSubArea())) {
|
if (locationFilter != null && StringUtils.isNotEmpty(locationFilter.getSubArea())) {
|
||||||
|
|
@ -154,26 +157,59 @@ public class StackerTaskServiceImpl implements IStackerTaskService {
|
||||||
candidateLocationList = new ArrayList<>(firstList);// 先添加符合subArea的库位
|
candidateLocationList = new ArrayList<>(firstList);// 先添加符合subArea的库位
|
||||||
candidateLocationList.addAll(lastList);// 再添加不符合subArea的库位
|
candidateLocationList.addAll(lastList);// 再添加不符合subArea的库位
|
||||||
}
|
}
|
||||||
// 找一个空闲的库位
|
|
||||||
|
// 第一轮:只尝试最大深度(例如 2 深度)库位
|
||||||
for (TAppLocation candidateLocation : candidateLocationList) {
|
for (TAppLocation candidateLocation : candidateLocationList) {
|
||||||
|
if (!Objects.equals(candidateLocation.getLDepth(), maxDepth)) {
|
||||||
|
continue; // 只处理最大深度
|
||||||
|
}
|
||||||
if (candidateLocation.getIsWorking() == 1 || candidateLocation.getIsLock() == 1
|
if (candidateLocation.getIsWorking() == 1 || candidateLocation.getIsLock() == 1
|
||||||
|| candidateLocation.getIsOccupy() == 1) {
|
|| candidateLocation.getIsOccupy() == 1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (isMaxDepthAvailable(locationList, candidateLocation)) {
|
if (isMaxDepthAvailable(locationList, candidateLocation)) {
|
||||||
try {
|
try {
|
||||||
// 尝试锁定库位,锁定成功就返回
|
// 申请当前库位,如果成功则返回
|
||||||
if (appLocationService.update(new LambdaUpdateWrapper<TAppLocation>()
|
if (appLocationService.update(new LambdaUpdateWrapper<TAppLocation>()
|
||||||
.set(TAppLocation::getIsOccupy, 1)
|
.set(TAppLocation::getIsOccupy, 1)
|
||||||
.set(TAppLocation::getVehicleId, requestVehicleId)
|
.set(TAppLocation::getVehicleId, requestVehicleId)
|
||||||
.eq(TAppLocation::getLocationId, candidateLocation.getLocationId())
|
.eq(TAppLocation::getLocationId, candidateLocation.getLocationId())
|
||||||
.eq(TAppLocation::getIsOccupy, 0))) {
|
.eq(TAppLocation::getIsOccupy, 0))) {
|
||||||
// 当前库位可用
|
|
||||||
targetLocation = candidateLocation;
|
targetLocation = candidateLocation;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} 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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -430,14 +466,14 @@ public class StackerTaskServiceImpl implements IStackerTaskService {
|
||||||
// int times = 0;
|
// int times = 0;
|
||||||
// MesApiResponse response = null;
|
// MesApiResponse response = null;
|
||||||
// do {
|
// do {
|
||||||
// Thread.sleep(15000L * times);
|
// Thread.sleep(15000L * times);
|
||||||
// response = externalApiService.invokeOrderInCB(orderInCBReq);
|
// response = externalApiService.invokeOrderInCB(orderInCBReq);
|
||||||
// times++;
|
// times++;
|
||||||
// } while (response.getCode() != 0 && times <= 10);
|
// } while (response.getCode() != 0 && times <= 10);
|
||||||
// if (response.getCode() != 0) {
|
// if (response.getCode() != 0) {
|
||||||
// log.error("[wms]上报失败");
|
// log.error("[wms]上报失败");
|
||||||
// } else {
|
// } else {
|
||||||
// log.info("[wms]上报成功");
|
// log.info("[wms]上报成功");
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -545,24 +581,24 @@ public class StackerTaskServiceImpl implements IStackerTaskService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// for (TAppOrderOut orderOut : orderOuts) {
|
// for (TAppOrderOut orderOut : orderOuts) {
|
||||||
// OrderOutCBReq orderOutCBReq = new OrderOutCBReq();
|
// OrderOutCBReq orderOutCBReq = new OrderOutCBReq();
|
||||||
// orderOutCBReq.setTaskId(orderOut.getOrderId());
|
// orderOutCBReq.setTaskId(orderOut.getOrderId());
|
||||||
// orderOutCBReq.setVehicleNo(vehicleId);
|
// orderOutCBReq.setVehicleNo(vehicleId);
|
||||||
// orderOutCBReq.setResult(OrderOutCBEnums.COMPLETE.getCode());
|
// orderOutCBReq.setResult(OrderOutCBEnums.COMPLETE.getCode());
|
||||||
// orderOutCBReq.setResultMessage("出库完成");
|
// orderOutCBReq.setResultMessage("出库完成");
|
||||||
|
|
||||||
// int times = 0;
|
// int times = 0;
|
||||||
// MesApiResponse response = null;
|
// MesApiResponse response = null;
|
||||||
// do {
|
// do {
|
||||||
// response = externalApiService.invokeOrderOutCB(orderOutCBReq);
|
// response = externalApiService.invokeOrderOutCB(orderOutCBReq);
|
||||||
// times++;
|
// times++;
|
||||||
// Thread.sleep(15000L * times);
|
// Thread.sleep(15000L * times);
|
||||||
// } while (response.getCode() != 0 && times <= 10);
|
// } while (response.getCode() != 0 && times <= 10);
|
||||||
// if (response.getCode() != 0) {
|
// if (response.getCode() != 0) {
|
||||||
// log.error("[WMS]上报失败");
|
// log.error("[WMS]上报失败");
|
||||||
// } else {
|
// } else {
|
||||||
// log.info("[WMS]上报成功");
|
// log.info("[WMS]上报成功");
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user