diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/LocationAllocationServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/LocationAllocationServiceImpl.java index 7d32058..582b8bd 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/LocationAllocationServiceImpl.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/LocationAllocationServiceImpl.java @@ -123,6 +123,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService if (roadWays == null || roadWays.size() == 0) { throw new JeecgBootException("分配库位时, 巷道为空"); } + Collections.shuffle(roadWays); Integer roadWay = locationAllocationService.getRoadWay(roadWays, warehouseCode); // 优先找外侧库位 LambdaQueryWrapper<Location> locationLambda = Wrappers.lambdaQuery(); @@ -176,6 +177,10 @@ public class LocationAllocationServiceImpl implements LocationAllocationService roadWays = locationList.stream().map(Location::getRoadWay).distinct().collect(toList()); } String lastString = "ORDER BY high asc, layer asc, id asc limit 1"; + if (roadWays == null || roadWays.size() == 0) { + throw new JeecgBootException("分配库位时, 巷道为空"); + } + Collections.shuffle(roadWays); Integer roadWay = locationAllocationService.getRoadWay(roadWays, warehouseCode); LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery(); locationLambdaQueryWrapper.eq(Location::getZoneCode, zoneCode).eq(Location::getWarehouseCode, warehouseCode).eq(Location::getRoadWay, roadWay) @@ -194,11 +199,18 @@ public class LocationAllocationServiceImpl implements LocationAllocationService @Override @Transactional(rollbackFor = Exception.class) public Integer getRoadWay(List<Integer> roadWays, String warehouseCode) { + if (StringUtils.isEmpty(roadWays)) { + throw new JeecgBootException("分配库位错误,没有巷道"); + } + int roadWay = roadWays.get(0); if (roadWays.size() == 1) { - return roadWays.get(0); + return roadWay; } roadWays = locationAllocationService.removeRoadWaysByPreLocations(roadWays, warehouseCode); - int roadWay = getRoadWayByMaxFreeLocation(roadWays, warehouseCode); + if (StringUtils.isEmpty(roadWays)) { + return roadWay; + } + roadWay = getRoadWayByMaxFreeLocation(roadWays, warehouseCode); return roadWay; } diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/WcsServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/WcsServiceImpl.java index 6c62c6a..9039620 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/WcsServiceImpl.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/WcsServiceImpl.java @@ -119,6 +119,7 @@ public class WcsServiceImpl implements WcsService { String height = warecellDomain.getHeight(); String taskNo = warecellDomain.getTaskNo(); String locationCode = null; + Integer preTaskNo = 0; List<Integer> roadWays = warecellDomain.getRoadWays(); if (height == null) { return Result.error("分配库位时,高度为空"); @@ -139,6 +140,13 @@ public class WcsServiceImpl implements WcsService { } int taskType = taskHeader.getTaskType(); String containerCode = taskHeader.getContainerCode(); + String toLocationCode = taskHeader.getToLocationCode(); + if (StringUtils.isNotEmpty(toLocationCode)) { + WcsTask wcsTask2 = new WcsTask(); + wcsTask2.setToLocationCode(toLocationCode); + wcsTask2.setPreTaskNo(String.valueOf(preTaskNo)); + return Result.OK(wcsTask2); + } Container container = containerService.getContainerByCode(containerCode, warehouseCode); if (container == null) { return Result.error("分配库位时,任务托盘为空"); @@ -228,7 +236,6 @@ public class WcsServiceImpl implements WcsService { // 修改任务明细目标库位 Location location = locationService.getLocationByCode(locationCode, warehouseCode); int rowFlag = location.getRowFlag().intValue(); - Integer preTaskNo = 0; // 如果是外侧库位,那么就要判断该库位对应的内侧库位是不是有托盘 if (rowFlag == QuantityConstant.ROW_OUT) { Location insideLocation = locationService.getInsideNear(location);