Commit cdd83c0a6f7d956ea06a7e388350c2278b33cbd4
1 parent
4192eb86
1. 优化库位分配,解决数组越界问题
2. 如果已经分配库位,那么返回当前库位。
Showing
2 changed files
with
22 additions
and
3 deletions
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/LocationAllocationServiceImpl.java
@@ -123,6 +123,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService | @@ -123,6 +123,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService | ||
123 | if (roadWays == null || roadWays.size() == 0) { | 123 | if (roadWays == null || roadWays.size() == 0) { |
124 | throw new JeecgBootException("分配库位时, 巷道为空"); | 124 | throw new JeecgBootException("分配库位时, 巷道为空"); |
125 | } | 125 | } |
126 | + Collections.shuffle(roadWays); | ||
126 | Integer roadWay = locationAllocationService.getRoadWay(roadWays, warehouseCode); | 127 | Integer roadWay = locationAllocationService.getRoadWay(roadWays, warehouseCode); |
127 | // 优先找外侧库位 | 128 | // 优先找外侧库位 |
128 | LambdaQueryWrapper<Location> locationLambda = Wrappers.lambdaQuery(); | 129 | LambdaQueryWrapper<Location> locationLambda = Wrappers.lambdaQuery(); |
@@ -176,6 +177,10 @@ public class LocationAllocationServiceImpl implements LocationAllocationService | @@ -176,6 +177,10 @@ public class LocationAllocationServiceImpl implements LocationAllocationService | ||
176 | roadWays = locationList.stream().map(Location::getRoadWay).distinct().collect(toList()); | 177 | roadWays = locationList.stream().map(Location::getRoadWay).distinct().collect(toList()); |
177 | } | 178 | } |
178 | String lastString = "ORDER BY high asc, layer asc, id asc limit 1"; | 179 | String lastString = "ORDER BY high asc, layer asc, id asc limit 1"; |
180 | + if (roadWays == null || roadWays.size() == 0) { | ||
181 | + throw new JeecgBootException("分配库位时, 巷道为空"); | ||
182 | + } | ||
183 | + Collections.shuffle(roadWays); | ||
179 | Integer roadWay = locationAllocationService.getRoadWay(roadWays, warehouseCode); | 184 | Integer roadWay = locationAllocationService.getRoadWay(roadWays, warehouseCode); |
180 | LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery(); | 185 | LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery(); |
181 | locationLambdaQueryWrapper.eq(Location::getZoneCode, zoneCode).eq(Location::getWarehouseCode, warehouseCode).eq(Location::getRoadWay, roadWay) | 186 | locationLambdaQueryWrapper.eq(Location::getZoneCode, zoneCode).eq(Location::getWarehouseCode, warehouseCode).eq(Location::getRoadWay, roadWay) |
@@ -194,11 +199,18 @@ public class LocationAllocationServiceImpl implements LocationAllocationService | @@ -194,11 +199,18 @@ public class LocationAllocationServiceImpl implements LocationAllocationService | ||
194 | @Override | 199 | @Override |
195 | @Transactional(rollbackFor = Exception.class) | 200 | @Transactional(rollbackFor = Exception.class) |
196 | public Integer getRoadWay(List<Integer> roadWays, String warehouseCode) { | 201 | public Integer getRoadWay(List<Integer> roadWays, String warehouseCode) { |
202 | + if (StringUtils.isEmpty(roadWays)) { | ||
203 | + throw new JeecgBootException("分配库位错误,没有巷道"); | ||
204 | + } | ||
205 | + int roadWay = roadWays.get(0); | ||
197 | if (roadWays.size() == 1) { | 206 | if (roadWays.size() == 1) { |
198 | - return roadWays.get(0); | 207 | + return roadWay; |
199 | } | 208 | } |
200 | roadWays = locationAllocationService.removeRoadWaysByPreLocations(roadWays, warehouseCode); | 209 | roadWays = locationAllocationService.removeRoadWaysByPreLocations(roadWays, warehouseCode); |
201 | - int roadWay = getRoadWayByMaxFreeLocation(roadWays, warehouseCode); | 210 | + if (StringUtils.isEmpty(roadWays)) { |
211 | + return roadWay; | ||
212 | + } | ||
213 | + roadWay = getRoadWayByMaxFreeLocation(roadWays, warehouseCode); | ||
202 | return roadWay; | 214 | return roadWay; |
203 | } | 215 | } |
204 | 216 |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/WcsServiceImpl.java
@@ -119,6 +119,7 @@ public class WcsServiceImpl implements WcsService { | @@ -119,6 +119,7 @@ public class WcsServiceImpl implements WcsService { | ||
119 | String height = warecellDomain.getHeight(); | 119 | String height = warecellDomain.getHeight(); |
120 | String taskNo = warecellDomain.getTaskNo(); | 120 | String taskNo = warecellDomain.getTaskNo(); |
121 | String locationCode = null; | 121 | String locationCode = null; |
122 | + Integer preTaskNo = 0; | ||
122 | List<Integer> roadWays = warecellDomain.getRoadWays(); | 123 | List<Integer> roadWays = warecellDomain.getRoadWays(); |
123 | if (height == null) { | 124 | if (height == null) { |
124 | return Result.error("分配库位时,高度为空"); | 125 | return Result.error("分配库位时,高度为空"); |
@@ -139,6 +140,13 @@ public class WcsServiceImpl implements WcsService { | @@ -139,6 +140,13 @@ public class WcsServiceImpl implements WcsService { | ||
139 | } | 140 | } |
140 | int taskType = taskHeader.getTaskType(); | 141 | int taskType = taskHeader.getTaskType(); |
141 | String containerCode = taskHeader.getContainerCode(); | 142 | String containerCode = taskHeader.getContainerCode(); |
143 | + String toLocationCode = taskHeader.getToLocationCode(); | ||
144 | + if (StringUtils.isNotEmpty(toLocationCode)) { | ||
145 | + WcsTask wcsTask2 = new WcsTask(); | ||
146 | + wcsTask2.setToLocationCode(toLocationCode); | ||
147 | + wcsTask2.setPreTaskNo(String.valueOf(preTaskNo)); | ||
148 | + return Result.OK(wcsTask2); | ||
149 | + } | ||
142 | Container container = containerService.getContainerByCode(containerCode, warehouseCode); | 150 | Container container = containerService.getContainerByCode(containerCode, warehouseCode); |
143 | if (container == null) { | 151 | if (container == null) { |
144 | return Result.error("分配库位时,任务托盘为空"); | 152 | return Result.error("分配库位时,任务托盘为空"); |
@@ -228,7 +236,6 @@ public class WcsServiceImpl implements WcsService { | @@ -228,7 +236,6 @@ public class WcsServiceImpl implements WcsService { | ||
228 | // 修改任务明细目标库位 | 236 | // 修改任务明细目标库位 |
229 | Location location = locationService.getLocationByCode(locationCode, warehouseCode); | 237 | Location location = locationService.getLocationByCode(locationCode, warehouseCode); |
230 | int rowFlag = location.getRowFlag().intValue(); | 238 | int rowFlag = location.getRowFlag().intValue(); |
231 | - Integer preTaskNo = 0; | ||
232 | // 如果是外侧库位,那么就要判断该库位对应的内侧库位是不是有托盘 | 239 | // 如果是外侧库位,那么就要判断该库位对应的内侧库位是不是有托盘 |
233 | if (rowFlag == QuantityConstant.ROW_OUT) { | 240 | if (rowFlag == QuantityConstant.ROW_OUT) { |
234 | Location insideLocation = locationService.getInsideNear(location); | 241 | Location insideLocation = locationService.getInsideNear(location); |