diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/LocationAllocationService.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/LocationAllocationService.java index 8565c90..2ca1d37 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/LocationAllocationService.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/LocationAllocationService.java @@ -34,9 +34,10 @@ public interface LocationAllocationService { * 排除巷道,如果这个巷道分配了超过2个库位,那么就不往这边分库位了,避免堵死的情况 * @param roadWays * @param warehouseCode + * @param warehouseCode2 * @return */ - List<Integer> removeRoadWaysByPreLocations(List<Integer> roadWays, String warehouseCode); + List<Integer> removeRoadWaysByPreLocations(List<Integer> roadWays, String zoneCode, String warehouseCode); /** * 获取巷道,根据入库物料均分原则,选取物料最少的巷道 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 9d8a609..c8f2b5c 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 @@ -28,6 +28,7 @@ import org.jeecg.utils.StringUtils; import org.jeecg.utils.constant.QuantityConstant; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -237,16 +238,15 @@ public class LocationAllocationServiceImpl implements LocationAllocationService @Override @Transactional(rollbackFor = Exception.class) public Integer getRoadWay(List<Integer> roadWays, String materialCode, String zoneCode, String warehouseCode) { - if (StringUtils.isEmpty(roadWays)) { + if (CollectionUtils.isEmpty(roadWays)) { throw new JeecgBootException("分配库位错误,没有巷道"); } int roadWay = roadWays.get(0); if (roadWays.size() == 1) { return roadWay; } - - roadWays = locationAllocationService.removeRoadWaysByPreLocations(roadWays, warehouseCode); - if (StringUtils.isEmpty(roadWays)) { + roadWays = locationAllocationService.removeRoadWaysByPreLocations(roadWays, zoneCode, warehouseCode); + if (CollectionUtils.isEmpty(roadWays)) { return roadWay; } // 获取巷道,选取空闲库位最多作为巷道 @@ -288,7 +288,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService @Override @Transactional(rollbackFor = Exception.class) - public List<Integer> removeRoadWaysByPreLocations(List<Integer> roadWays, String warehouseCode) { + public List<Integer> removeRoadWaysByPreLocations(List<Integer> roadWays, String zoneCode, String warehouseCode) { String value = parameterConfigurationService.getValueByCode(QuantityConstant.MAX_ROADWAY_RECEIPT); // 同巷道分配的库位大于等于2时,这个巷道就不能再分了 int maxRoadReceipt = 2; @@ -296,8 +296,8 @@ public class LocationAllocationServiceImpl implements LocationAllocationService maxRoadReceipt = Integer.parseInt(value); } LambdaQueryWrapper<TaskHeader> taskHeaderLambdaQueryWrapper = Wrappers.lambdaQuery(); - taskHeaderLambdaQueryWrapper.lt(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED).ne(TaskHeader::getToLocationCode, - QuantityConstant.EMPTY_STRING); + taskHeaderLambdaQueryWrapper.lt(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED).eq(TaskHeader::getZoneCode, zoneCode) + .ne(TaskHeader::getToLocationCode, QuantityConstant.EMPTY_STRING); List<TaskHeader> taskHeaderList = taskHeaderService.list(taskHeaderLambdaQueryWrapper); if (taskHeaderList.size() != 0) { List<Integer> roadWayList = taskHeaderList.stream().map(TaskHeader::getRoadWay).collect(toList()); @@ -321,14 +321,14 @@ public class LocationAllocationServiceImpl implements LocationAllocationService } Collections.shuffle(roadWays);// 打乱巷道排序 int roadWay = roadWays.get(0); - if (roadWays.size() == 1) { - return roadWay; - } +// if (roadWays.size() == 1) { +// return roadWay; +// } +// roadWays = locationAllocationService.removeRoadWaysByPreLocations(roadWays, zoneCode, warehouseCode); +// if (roadWays.size() == 0) { +// return roadWay; +// } int min = Integer.MAX_VALUE; - roadWays = locationAllocationService.removeRoadWaysByPreLocations(roadWays, warehouseCode); - if (roadWays.size() == 0) { - return roadWay; - } List<InventoryDetail> inventoryDetailList = inventoryDetailService.getInventoryDetailListByMaterialCodeAndZoneCode(materialCode, zoneCode, warehouseCode); if (inventoryDetailList.size() != 0) { List<Integer> roadWayList = inventoryDetailList.stream().map(InventoryDetail::getRoadWay).collect(toList());