Commit 2097085c7d9bc3a93eaf40120aae99a23dcb0f16

Authored by 曾湘平
2 parents ff6a5336 4ce8c79a

Merge remote-tracking branch 'origin/develop' into develop

huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/LocationAllocationService.java
... ... @@ -34,9 +34,10 @@ public interface LocationAllocationService {
34 34 * 排除巷道,如果这个巷道分配了超过2个库位,那么就不往这边分库位了,避免堵死的情况
35 35 * @param roadWays
36 36 * @param warehouseCode
  37 + * @param warehouseCode2
37 38 * @return
38 39 */
39   - List<Integer> removeRoadWaysByPreLocations(List<Integer> roadWays, String warehouseCode);
  40 + List<Integer> removeRoadWaysByPreLocations(List<Integer> roadWays, String zoneCode, String warehouseCode);
40 41  
41 42 /**
42 43 * 获取巷道,根据入库物料均分原则,选取物料最少的巷道
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/LocationAllocationServiceImpl.java
... ... @@ -28,6 +28,7 @@ import org.jeecg.utils.StringUtils;
28 28 import org.jeecg.utils.constant.QuantityConstant;
29 29 import org.springframework.stereotype.Service;
30 30 import org.springframework.transaction.annotation.Transactional;
  31 +import org.springframework.util.CollectionUtils;
31 32  
32 33 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
33 34 import com.baomidou.mybatisplus.core.metadata.IPage;
... ... @@ -135,7 +136,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
135 136 if (roadWays == null || roadWays.size() == 0) {
136 137 throw new JeecgBootException("分配库位时, 可用巷道为空");
137 138 }
138   - Collections.shuffle(roadWays);
  139 +// Collections.shuffle(roadWays);
139 140 Integer roadWay = locationAllocationService.getRoadWay(roadWays, materialCode, zoneCode, warehouseCode);
140 141 // 优先找外侧库位
141 142 LambdaQueryWrapper<Location> locationLambda = Wrappers.lambdaQuery();
... ... @@ -215,7 +216,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
215 216 if (roadWays == null || roadWays.size() == 0) {
216 217 throw new JeecgBootException("分配库位时, 可用巷道为空");
217 218 }
218   - Collections.shuffle(roadWays);
  219 +// Collections.shuffle(roadWays);
219 220 Integer roadWay = locationAllocationService.getRoadWay(roadWays, materialCode, zoneCode, warehouseCode);
220 221 LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery();
221 222 locationLambdaQueryWrapper.eq(Location::getZoneCode, zoneCode).eq(Location::getWarehouseCode, warehouseCode).eq(Location::getRoadWay, roadWay)
... ... @@ -237,16 +238,15 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
237 238 @Override
238 239 @Transactional(rollbackFor = Exception.class)
239 240 public Integer getRoadWay(List<Integer> roadWays, String materialCode, String zoneCode, String warehouseCode) {
240   - if (StringUtils.isEmpty(roadWays)) {
  241 + if (CollectionUtils.isEmpty(roadWays)) {
241 242 throw new JeecgBootException("分配库位错误,没有巷道");
242 243 }
243 244 int roadWay = roadWays.get(0);
244 245 if (roadWays.size() == 1) {
245 246 return roadWay;
246 247 }
247   -
248   - roadWays = locationAllocationService.removeRoadWaysByPreLocations(roadWays, warehouseCode);
249   - if (StringUtils.isEmpty(roadWays)) {
  248 + roadWays = locationAllocationService.removeRoadWaysByPreLocations(roadWays, zoneCode, warehouseCode);
  249 + if (CollectionUtils.isEmpty(roadWays)) {
250 250 return roadWay;
251 251 }
252 252 // 获取巷道,选取空闲库位最多作为巷道
... ... @@ -288,7 +288,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
288 288  
289 289 @Override
290 290 @Transactional(rollbackFor = Exception.class)
291   - public List<Integer> removeRoadWaysByPreLocations(List<Integer> roadWays, String warehouseCode) {
  291 + public List<Integer> removeRoadWaysByPreLocations(List<Integer> roadWays, String zoneCode, String warehouseCode) {
292 292 String value = parameterConfigurationService.getValueByCode(QuantityConstant.MAX_ROADWAY_RECEIPT);
293 293 // 同巷道分配的库位大于等于2时,这个巷道就不能再分了
294 294 int maxRoadReceipt = 2;
... ... @@ -296,8 +296,8 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
296 296 maxRoadReceipt = Integer.parseInt(value);
297 297 }
298 298 LambdaQueryWrapper<TaskHeader> taskHeaderLambdaQueryWrapper = Wrappers.lambdaQuery();
299   - taskHeaderLambdaQueryWrapper.lt(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED).ne(TaskHeader::getToLocationCode,
300   - QuantityConstant.EMPTY_STRING);
  299 + taskHeaderLambdaQueryWrapper.lt(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED).eq(TaskHeader::getZoneCode, zoneCode)
  300 + .ne(TaskHeader::getToLocationCode, QuantityConstant.EMPTY_STRING);
301 301 List<TaskHeader> taskHeaderList = taskHeaderService.list(taskHeaderLambdaQueryWrapper);
302 302 if (taskHeaderList.size() != 0) {
303 303 List<Integer> roadWayList = taskHeaderList.stream().map(TaskHeader::getRoadWay).collect(toList());
... ... @@ -319,16 +319,16 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
319 319 if (roadWays == null || roadWays.size() == 0) {
320 320 throw new JeecgBootException("分配库位时, 巷道为空");
321 321 }
322   - Collections.shuffle(roadWays);
  322 + Collections.shuffle(roadWays);// 打乱巷道排序
323 323 int roadWay = roadWays.get(0);
324   - if (roadWays.size() == 1) {
325   - return roadWay;
326   - }
  324 +// if (roadWays.size() == 1) {
  325 +// return roadWay;
  326 +// }
  327 +// roadWays = locationAllocationService.removeRoadWaysByPreLocations(roadWays, zoneCode, warehouseCode);
  328 +// if (roadWays.size() == 0) {
  329 +// return roadWay;
  330 +// }
327 331 int min = Integer.MAX_VALUE;
328   - roadWays = locationAllocationService.removeRoadWaysByPreLocations(roadWays, warehouseCode);
329   - if (roadWays.size() == 0) {
330   - return roadWay;
331   - }
332 332 List<InventoryDetail> inventoryDetailList = inventoryDetailService.getInventoryDetailListByMaterialCodeAndZoneCode(materialCode, zoneCode, warehouseCode);
333 333 if (inventoryDetailList.size() != 0) {
334 334 List<Integer> roadWayList = inventoryDetailList.stream().map(InventoryDetail::getRoadWay).collect(toList());
... ...