入库时判断低深度是否有货物

This commit is contained in:
陆一凡 2025-03-18 12:57:38 +08:00
parent 1760bfd1f4
commit 8fd0e2f310

View File

@ -60,21 +60,6 @@ public class LocationUtils {
query.setWareArea("A");
query.setLocationStatus(LocationStatus.EMPTY.getCode());
List<Location> canUseLocations = locationMapper.selNextLocation(query);
// if(canUseLocations.isEmpty()){
// log.info("A级优先级没有可用库位开始寻找B级库位");
// query.setAreaId(areaId);
// query.setWareArea("B");
// query.setLocationStatus(LocationStatus.EMPTY.getCode());
// List<Location> canUseLocations2 = locationMapper.selNextLocation(query);
// if (canUseLocations2.isEmpty()){
// log.info("A,B级优先级没有可用库位开始寻找C级库位");
// query.setAreaId(areaId);
// query.setWareArea("C");
// query.setLocationStatus(LocationStatus.EMPTY.getCode());
// return locationMapper.selNextLocation(query);
// }
// return canUseLocations2;
// }
return canUseLocations;
} else if (Objects.equals(appOrderIn.getWareHouse(), "B")) {
Location query = new Location();
@ -82,13 +67,6 @@ public class LocationUtils {
query.setWareArea("B");
query.setLocationStatus(LocationStatus.EMPTY.getCode());
List<Location> canUseLocations = locationMapper.selNextLocation(query);
// if(canUseLocations.isEmpty()){
// log.info("B级优先级没有可用库位开始寻找C级库位");
// query.setAreaId(areaId);
// query.setWareArea("C");
// query.setLocationStatus(LocationStatus.EMPTY.getCode());
// return locationMapper.selNextLocation(query);
// }
return canUseLocations;
} else if (Objects.equals(appOrderIn.getWareHouse(), "C")) {
Location query = new Location();
@ -190,36 +168,6 @@ public class LocationUtils {
if(!checkResult.isEmpty()) {
continue; // 库存不为空跳过
}
/* 2 判断同位置不同深度是否有任务 */
// 找出此位置不同深度的库位
// Location queryDifferentDepthLocation = new Location();
// queryDifferentDepthLocation.setAreaId(location.getAreaId());
// queryDifferentDepthLocation.setQueue(location.getQueue());
// queryDifferentDepthLocation.setTunnelId(location.getTunnelId());
// queryDifferentDepthLocation.setLayer(location.getLayer());
// List<Location> differentDepthLocations = locationMapper.selLocations(queryDifferentDepthLocation);
// if(differentDepthLocations == null) {
// continue; // 数据库查询失败
// }
// if(!differentDepthLocations.isEmpty()) {
// // 存在干涉库位检验其是否有未完成的任务
// for (Location differentDepthLocation : differentDepthLocations) {
// // 找出此位置不同深度的库位
// Location queryLocationTask = new Location();
// queryLocationTask.setLocationId(differentDepthLocation.getLocationId());
// List<Task> locationTasks = taskMapper.haveNotCompleteTask(differentDepthLocation.getLocationId());
// if(locationTasks == null) {
// log.info("检查存在干涉库位失败,数据库异常");
// canUse = false;
// break; // 数据库查询失败
// }
// if(!locationTasks.isEmpty()) {
// log.info("检查存在干涉库位失败,此位置有未完成的任务,任务位置{}",differentDepthLocation.getLocationId());
// canUse = false;
// break; // 有任务这个库位不行
// }
// }
// }
if(canUse) {
return location;
}
@ -240,9 +188,6 @@ public class LocationUtils {
}
boolean canUse = true;
for (Location location : canUseLocations) {
// if(location.getDepth() == 1) {
// return location; // 1 深度的不需要检验
// }
/* 校验此位置是否有遮挡 */ /* 如果这位置有库存(可能出现记错导致有库存),或者这位置其他深度(不论深度大小)有任务则不采用此位置 */
/* 1 判断库存 */
Stock checkStock = new Stock();
@ -251,6 +196,30 @@ public class LocationUtils {
if(!checkResult.isEmpty()) {
continue; // 库存不为空跳过
}
// 判断低深度是否有库存
for (int i = 1; i < location.getDepth(); i++) {
Location queryLowDepthLocation = new Location();
queryLowDepthLocation.setLine(location.getLine());
queryLowDepthLocation.setLayer(location.getLayer());
queryLowDepthLocation.setQueue(location.getQueue());
queryLowDepthLocation.setDepth(i);
queryLowDepthLocation.setTunnelId(location.getTunnelId());
List<Location> locations = locationMapper.selLocations(queryLowDepthLocation);
if (locations.get(0).getLocationStatus() == 1) {
log.info("入库时低深度存在占用", locations.get(0).getLocationId());
canUse = false;
}
// 查询是否有库存
Stock queryStock = new Stock();
queryStock.setLocationId(locations.get(0).getLocationId());
List<Stock> stockList = stockMapper.selStocks(queryStock);
if (!stockList.isEmpty()) {
log.info("入库时低深度存在库存", locations.get(0).getLocationId());
canUse = false;
}
}
/* 2 判断同位置不同深度是否有任务 */
// 找出此位置不同深度的库位
Location queryDifferentDepthLocation = new Location();