Commit cdd83c0a6f7d956ea06a7e388350c2278b33cbd4

Authored by 肖超群
1 parent 4192eb86

1. 优化库位分配,解决数组越界问题

2. 如果已经分配库位,那么返回当前库位。
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 123 if (roadWays == null || roadWays.size() == 0) {
124 124 throw new JeecgBootException("分配库位时, 巷道为空");
125 125 }
  126 + Collections.shuffle(roadWays);
126 127 Integer roadWay = locationAllocationService.getRoadWay(roadWays, warehouseCode);
127 128 // 优先找外侧库位
128 129 LambdaQueryWrapper<Location> locationLambda = Wrappers.lambdaQuery();
... ... @@ -176,6 +177,10 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
176 177 roadWays = locationList.stream().map(Location::getRoadWay).distinct().collect(toList());
177 178 }
178 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 184 Integer roadWay = locationAllocationService.getRoadWay(roadWays, warehouseCode);
180 185 LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery();
181 186 locationLambdaQueryWrapper.eq(Location::getZoneCode, zoneCode).eq(Location::getWarehouseCode, warehouseCode).eq(Location::getRoadWay, roadWay)
... ... @@ -194,11 +199,18 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
194 199 @Override
195 200 @Transactional(rollbackFor = Exception.class)
196 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 206 if (roadWays.size() == 1) {
198   - return roadWays.get(0);
  207 + return roadWay;
199 208 }
200 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 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 119 String height = warecellDomain.getHeight();
120 120 String taskNo = warecellDomain.getTaskNo();
121 121 String locationCode = null;
  122 + Integer preTaskNo = 0;
122 123 List<Integer> roadWays = warecellDomain.getRoadWays();
123 124 if (height == null) {
124 125 return Result.error("分配库位时,高度为空");
... ... @@ -139,6 +140,13 @@ public class WcsServiceImpl implements WcsService {
139 140 }
140 141 int taskType = taskHeader.getTaskType();
141 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 150 Container container = containerService.getContainerByCode(containerCode, warehouseCode);
143 151 if (container == null) {
144 152 return Result.error("分配库位时,任务托盘为空");
... ... @@ -228,7 +236,6 @@ public class WcsServiceImpl implements WcsService {
228 236 // 修改任务明细目标库位
229 237 Location location = locationService.getLocationByCode(locationCode, warehouseCode);
230 238 int rowFlag = location.getRowFlag().intValue();
231   - Integer preTaskNo = 0;
232 239 // 如果是外侧库位,那么就要判断该库位对应的内侧库位是不是有托盘
233 240 if (rowFlag == QuantityConstant.ROW_OUT) {
234 241 Location insideLocation = locationService.getInsideNear(location);
... ...