Commit 1b7eb0d86d61af13789d3615524e4c46e2c191ae
1 parent
1f277271
fix: 优化库位分配
Showing
2 changed files
with
16 additions
and
15 deletions
src/main/java/com/huaheng/api/wcs/service/warecellAllocation/LocationAllocationServiceImpl.java
... | ... | @@ -99,17 +99,16 @@ public class LocationAllocationServiceImpl implements LocationAllocationService |
99 | 99 | * 双伸位库位入库分配库位 |
100 | 100 | */ |
101 | 101 | private String doubleRk(String area, List<String> roadWays, int high, String warehouseCode, List<String> locationTypeCodeList, String materialAreaCode, Integer frequencyLocation, Integer onlyEmptyContainer) { |
102 | - //巷道为空的话 | |
102 | + // 如果巷道为空,获取所有巷道 | |
103 | 103 | if (roadWays == null || roadWays.isEmpty()) { |
104 | 104 | List<Location> locationList = locationService.list(new LambdaQueryWrapper<Location>().eq(Location::getArea, area)); |
105 | 105 | roadWays = locationList.stream().map(Location::getRoadway).distinct().collect(toList()); |
106 | 106 | } |
107 | - //双伸位预留库位数 | |
107 | + // 获取双伸位预留库位数 | |
108 | 108 | String value = configService.getKey(QuantityConstant.DOUBLE_FORK_RESERVE_LOCATION); |
109 | - int reserveNumber = 0; | |
110 | - if (StringUtils.isNotEmpty(value)) { | |
111 | - reserveNumber = Integer.parseInt(value); | |
112 | - } | |
109 | + int reserveNumber = StringUtils.isNotEmpty(value) ? Integer.parseInt(value) : 0; | |
110 | + | |
111 | + // 移除不符合条件的巷道 | |
113 | 112 | List<String> removeRoadWays = new ArrayList<>(); |
114 | 113 | for (String roadWay : roadWays) { |
115 | 114 | LambdaQueryWrapper<Location> wrapper = Wrappers.lambdaQuery(); |
... | ... | @@ -139,11 +138,12 @@ public class LocationAllocationServiceImpl implements LocationAllocationService |
139 | 138 | } |
140 | 139 | roadWays.removeAll(removeRoadWays); |
141 | 140 | Collections.shuffle(roadWays); |
141 | + // 如果没有符合条件的巷道,返回提示信息 | |
142 | 142 | if (roadWays.isEmpty()) { |
143 | 143 | return "可能是双伸位巷道保留库位数不够了"; |
144 | 144 | } |
145 | 145 | |
146 | - //查外侧的库位 | |
146 | + // 查找外侧的库位 | |
147 | 147 | String roadWay = roadWays.get(0); |
148 | 148 | LambdaQueryWrapper<Location> locationLambda = Wrappers.lambdaQuery(); |
149 | 149 | locationLambda.eq(Location::getArea, area). |
... | ... | @@ -188,7 +188,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService |
188 | 188 | if (locationList != null) { |
189 | 189 | locationList.removeAll(removeLocaationList); |
190 | 190 | } |
191 | - //如果没有外侧库位可分配了,再查内侧的库位 | |
191 | + // 如果没有外侧库位可分配了,再查内侧的库位 | |
192 | 192 | if (locationList == null || locationList.isEmpty()) { |
193 | 193 | locationLambda = Wrappers.lambdaQuery(); |
194 | 194 | locationLambda.eq(Location::getArea, area). |
... | ... | @@ -233,6 +233,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService |
233 | 233 | locationList.removeAll(removeLocaationList); |
234 | 234 | } |
235 | 235 | } |
236 | + // 如果没有符合条件的库位可分配,返回null | |
236 | 237 | if (locationList == null || locationList.isEmpty()) { |
237 | 238 | return null; |
238 | 239 | } |
... | ... |
src/main/java/com/huaheng/api/wcs/service/warecellAllocation/WarecellAllocationServiceImpl.java
... | ... | @@ -130,7 +130,7 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService |
130 | 130 | return AjaxResult.error("宽为空"); |
131 | 131 | } |
132 | 132 | if (StringUtils.isNull(warecellDomain.getHeight()) || "0".equals(warecellDomain.getHeight())) { |
133 | - return AjaxResult.error("高为空"); | |
133 | + return AjaxResult.error("高为空或0"); | |
134 | 134 | } |
135 | 135 | return warecellAllocationService.verticalWarehouseAllocation(warecellDomain); |
136 | 136 | } |
... | ... | @@ -140,7 +140,7 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService |
140 | 140 | public AjaxResult<?> verticalWarehouseAllocation(WarecellDomain warecellDomain) { |
141 | 141 | String warehouseCode = warecellDomain.getWarehouseCode(); |
142 | 142 | String area = warecellDomain.getArea(); |
143 | - String locationCode = null; | |
143 | + String locationCode; | |
144 | 144 | String height = warecellDomain.getHeight(); |
145 | 145 | String taskNo = warecellDomain.getTaskNo(); |
146 | 146 | List<String> roadWays = warecellDomain.getRoadWays(); |
... | ... | @@ -474,10 +474,10 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService |
474 | 474 | if (locationTypeList.isEmpty()) { |
475 | 475 | return AjaxResult.error("没有区域可分配"); |
476 | 476 | } |
477 | - List<String> codeList = new ArrayList<>(); | |
478 | - for (LocationType locationType : locationTypeList) { | |
479 | - codeList.add(locationType.getCode()); | |
480 | - } | |
477 | + //List<String> codeList = new ArrayList<>(); | |
478 | + //for (LocationType locationType : locationTypeList) { | |
479 | + // codeList.add(locationType.getCode()); | |
480 | + //} | |
481 | 481 | |
482 | 482 | //定位库位List |
483 | 483 | List<String> positioningLocationCodeList = null; |
... | ... | @@ -507,7 +507,7 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService |
507 | 507 | LambdaQueryWrapper<Location> locationLambda = Wrappers.lambdaQuery(); |
508 | 508 | locationLambda.last(locatingRules[0]); |
509 | 509 | List<Location> locationList = locationService.list(locationLambda); |
510 | - List<String> locationCodeList = locationTypeList.stream().map(t -> t.getCode()).collect(Collectors.toList()); | |
510 | + List<String> locationCodeList = locationTypeList.stream().map(LocationType::getCode).collect(Collectors.toList()); | |
511 | 511 | List<Location> newLocation = locationList.stream().filter(t -> locationCodeList.contains(t.getLocationType())).collect(Collectors.toList()); |
512 | 512 | if (!newLocation.isEmpty()) { |
513 | 513 | positioningLocationCodeList.add(newLocation.get(0).getCode()); |
... | ... |