From d73f651939c3d29a895ff732e4c1cb575283feb5 Mon Sep 17 00:00:00 2001
From: zengxiangping <318732054@qq.com>
Date: Fri, 3 Nov 2023 16:55:26 +0800
Subject: [PATCH] 分配库位巷道为空时,换一个方法获取巷道

---
 huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/LocationAllocationServiceImpl.java    |  6 ++----
 huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/service/ILocationService.java         |  2 ++
 huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/service/impl/LocationServiceImpl.java | 13 +++++++++++++
 3 files changed, 17 insertions(+), 4 deletions(-)

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 9fd2ba2..97a1b54 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
@@ -103,8 +103,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService 
     public String doubleRk(String zoneCode, List<Integer> roadWays, int high, String warehouseCode, List<String> locationTypeCodeList, String materialAreaCode,
         String materialCode) {
         if (roadWays == null || roadWays.size() < 1) {
-            List<Location> locationList = locationService.getLocationListByZoneCode(zoneCode, warehouseCode);
-            roadWays = locationList.stream().map(Location::getRoadWay).distinct().collect(toList());
+            roadWays = locationService.getRoadWayByZoneCode(zoneCode,warehouseCode);
         }
         String value = parameterConfigurationService.getValueByCode(QuantityConstant.DOUBLE_FORK_RESERVE_LOCATION);
         int reserveNumber = 4;
@@ -192,8 +191,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService 
     public String singleRk(String zoneCode, List<Integer> roadWays, int high, String warehouseCode, List<String> locationTypeCodeList, String materialAreaCode,
         String materialCode) {
         if (roadWays == null || roadWays.size() < 1) {
-            List<Location> locationList = locationService.getLocationListByZoneCode(zoneCode, warehouseCode);
-            roadWays = locationList.stream().map(Location::getRoadWay).distinct().collect(toList());
+            roadWays = locationService.getRoadWayByZoneCode(zoneCode,warehouseCode);
         }
         List<Integer> removeRoadWays = new ArrayList<>();
         // 寻找可用巷道,空闲的空库位低于设定值,那么这个巷道就不能用来分配库位
diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/service/ILocationService.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/service/ILocationService.java
index eaced59..6db0055 100644
--- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/service/ILocationService.java
+++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/service/ILocationService.java
@@ -27,6 +27,8 @@ public interface ILocationService extends IService<Location> {
 
     List<Location> getLocationListByZoneCode(String zoneCode, String warehouseCode);
 
+    List<Integer> getRoadWayByZoneCode(String zoneCode, String warehouseCode);
+
     boolean updateStatus(String locationCode, String status, String warehouseCode);
 
     boolean updateContainerCodeAndStatus(String locationCode, String containerCode, String status, String warehouseCode);
diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/service/impl/LocationServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/service/impl/LocationServiceImpl.java
index 52ae20f..9398f9a 100644
--- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/service/impl/LocationServiceImpl.java
+++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/service/impl/LocationServiceImpl.java
@@ -7,6 +7,7 @@ import java.util.stream.Collectors;
 
 import javax.annotation.Resource;
 
+import cn.hutool.core.collection.CollUtil;
 import org.apache.commons.collections4.ListUtils;
 import org.apache.shiro.util.CollectionUtils;
 import org.jeecg.common.api.vo.Result;
@@ -113,6 +114,18 @@ public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> i
     }
 
     @Override
+    public List<Integer> getRoadWayByZoneCode(String zoneCode, String warehouseCode) {
+        LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery();
+        locationLambdaQueryWrapper.eq(Location::getZoneCode, zoneCode).eq(Location::getEnable, QuantityConstant.STATUS_ENABLE)
+            .eq(Location::getWarehouseCode, warehouseCode).select(Location::getRoadWay).groupBy(Location::getRoadWay);
+        List<Location> locationList = locationService.list(locationLambdaQueryWrapper);
+        if (CollectionUtils.isEmpty(locationList)) {
+            return CollUtil.newArrayList();
+        }
+        return locationList.stream().map(Location::getRoadWay).collect(Collectors.toList());
+    }
+
+    @Override
     @Transactional
     public boolean updateStatus(String locationCode, String status, String warehouseCode) {
         LambdaUpdateWrapper<Location> updateWrapper = Wrappers.lambdaUpdate();
--
libgit2 0.22.2