Ver Fonte

库位阻挡与任务阻挡

LZH há 1 ano atrás
pai
commit
204e8838d7

+ 183 - 96
warewms-ams/src/main/java/com/ruoyi/ams/business/BusinessServiceImpl.java

@@ -281,124 +281,211 @@ public class BusinessServiceImpl implements IBusinessService {
     @Override
     public BaseLocationInfo zoneLocationAllocation(List<BaseLocationInfo> locationInfoList, String locationType
             , String type, AsnSoStrategy asnSoStrategy, Long token) {
+//        BaseLocationInfo locationInfo = null;
+//        if (type.equals("ASN")) {
+//            //入库
+//            if (locationType.equals("locationFrom")) {
+//                for (BaseLocationInfo b : locationInfoList) {
+//                    if (!b.getStockStatus().equals("00")) {
+//                        continue;
+//                    }
+//                    if (!redisCache.lockCacheObject(RedisKey.LOCK_LOCATION + b.getId(), b.getId().toString(), token)) {
+//                        continue;
+//                    }
+//                    locationInfo = b;
+//                    break;
+//                }
+//                if (locationInfo == null) {
+//                    throw new ServiceException("入库起始库位没有可以分配的空库位", token);
+//                }
+//            } else {
+//                for (BaseLocationInfo b : locationInfoList) {
+//                    if (!b.getStockStatus().equals("00") || !b.getIsEmpty().equals("Y") || redisCache.checkIsLock(RedisKey.LOCK_LOCATION + b.getId())) {
+//                        continue;
+//                    }
+//                    if (!redisCache.lockCacheObject(RedisKey.LOCK_LOCATION + b.getId(), b.getId().toString(), token)) {
+//                        continue;
+//                    }
+//                    locationInfo = b;
+//                    break;
+//                }
+//                if (locationInfo == null) {
+//                    throw new ServiceException("入库目标点没有可以分配的库位", token);
+//                }
+//            }
+//        } else if (type.equals("SO")) {
+//            //起始库位
+//            if (locationType.equals("locationFrom")) {
+//                for (BaseLocationInfo b : locationInfoList) {
+//                    if (!b.getStockStatus().equals("00") || !b.getIsEmpty().equals("N") || redisCache.checkIsLock(RedisKey.LOCK_LOCATION + b.getId())) {
+//                        continue;
+//                    }
+//                    if (!redisCache.lockCacheObject(RedisKey.LOCK_LOCATION + b.getId(), b.getId().toString(), token)) {
+//                        continue;
+//                    }
+//                    locationInfo = b;
+//                    break;
+//                }
+//                if (locationInfo == null) {
+//                    throw new ServiceException("出库起始点没有可以分配的库存!", token);
+//                }
+//
+//            } else { //目标库位
+//                for (BaseLocationInfo b : locationInfoList) {
+//                    if (!b.getStockStatus().equals("00") || !b.getIsEmpty().equals("Y") || redisCache.checkIsLock(RedisKey.LOCK_LOCATION + b.getId())) {
+//                        continue;
+//                    }
+//                    if (!redisCache.lockCacheObject(RedisKey.LOCK_LOCATION + b.getId(), b.getId().toString(), token)) {
+//                        continue;
+//                    }
+//                    locationInfo = b;
+//                    break;
+//                }
+//                if (locationInfo == null) {
+//                    throw new ServiceException("出库目标点没有可以分配的库位", token);
+//                }
+//            }
+//        } else { //移库
+//            if (locationType.equals("locationFrom")) {
+//
+//                for (BaseLocationInfo b : locationInfoList) {
+//                    if (!b.getStockStatus().equals("00") || redisCache.checkIsLock(RedisKey.LOCK_LOCATION + b.getId())) {
+//                        continue;
+//                    }
+//                    if (!redisCache.lockCacheObject(RedisKey.LOCK_LOCATION + b.getId(), b.getId().toString(), token)) {
+//                        continue;
+//                    }
+//                    locationInfo = b;
+//                    break;
+//                }
+//
+//                //进行判断
+//                if (locationInfo == null) {
+//                    throw new ServiceException("移库起始点没有可以分配的库位", token);
+//                }
+//
+//            } else {
+//                for (BaseLocationInfo b : locationInfoList) {
+//                    if (!b.getStockStatus().equals("00") || !b.getIsEmpty().equals("Y") || redisCache.checkIsLock(RedisKey.LOCK_LOCATION + b.getId())) {
+//                        continue;
+//                    }
+//                    if (!redisCache.lockCacheObject(RedisKey.LOCK_LOCATION + b.getId(), b.getId().toString(), token)) {
+//                        continue;
+//                    }
+//                    locationInfo = b;
+//                    break;
+//                }
+//
+//                //进行判断
+//                if (locationInfo == null) {
+//                    throw new ServiceException("移库目标点没有可以分配的库位", token);
+//                }
+//            }
+//        }
+//        return locationInfo;
         BaseLocationInfo locationInfo = null;
-        if (type.equals("ASN")) {
-            //入库
+        String fromMsg = "";
+        String toMsg = "";
+        if (type.equals("ASN")) { // 入库
             if (locationType.equals("locationFrom")) {
-                for (BaseLocationInfo b : locationInfoList) {
-                    if (!b.getStockStatus().equals("00")) {
-                        continue;
-                    }
-                    if (!redisCache.lockCacheObject(RedisKey.LOCK_LOCATION + b.getId(), b.getId().toString(), token)) {
-                        continue;
-                    }
-                    locationInfo = b;
-                    break;
-                }
-                if (locationInfo == null) {
-                    throw new ServiceException("入库起始库位没有可以分配的空库位", token);
-                }
-            } else {
-                for (BaseLocationInfo b : locationInfoList) {
-                    if (!b.getStockStatus().equals("00") || !b.getIsEmpty().equals("Y") || redisCache.checkIsLock(RedisKey.LOCK_LOCATION + b.getId())) {
-                        continue;
-                    }
-                    // 第六层不能放数量超过2的货
-                    int boxNum = Integer.parseInt(asnSoStrategy.getAsnHeightLimit());
-                    if (b.getShiftNo().equals("6")) {
-                        if (boxNum > 2) continue;
-                    } else {
-                        // 其他层数放置箱子数量不能超过6
-                        if (boxNum > 6) {
-                            log.error("入库箱数量不能超过6!");
-                            continue;
-                        }
-                    }
-                    if (!redisCache.lockCacheObject(RedisKey.LOCK_LOCATION + b.getId(), b.getId().toString(), token)) {
-                        continue;
-                    }
-                    locationInfo = b;
-                    break;
-                }
-                if (locationInfo == null) {
-                    throw new ServiceException("入库目标点没有可以分配的库位", token);
-                }
+            } else { //目标库位
             }
-        } else if (type.equals("SO")) {
-            //起始库位
+        } else if (type.equals("SO")) { // 出库
             if (locationType.equals("locationFrom")) {
-                for (BaseLocationInfo b : locationInfoList) {
-                    if (!b.getStockStatus().equals("00") || !b.getIsEmpty().equals("N") || redisCache.checkIsLock(RedisKey.LOCK_LOCATION + b.getId())) {
-                        continue;
-                    }
-                    if (!redisCache.lockCacheObject(RedisKey.LOCK_LOCATION + b.getId(), b.getId().toString(), token)) {
-                        continue;
-                    }
-                    // 判断起始库位上的库存质检状态是否可以出库
-                    boolean con = invLotLocIdService.verifyInventoryCanOutbound(b.getId().toString());
-                    if (!con) {
-                        continue;
-                    }
-                    locationInfo = b;
-                    break;
-                }
-                if (locationInfo == null) {
-                    throw new ServiceException("出库起始点没有可以分配的库存!", token);
-                }
-
             } else { //目标库位
-                for (BaseLocationInfo b : locationInfoList) {
-                    if (!b.getStockStatus().equals("00") || !b.getIsEmpty().equals("Y") || redisCache.checkIsLock(RedisKey.LOCK_LOCATION + b.getId())) {
-                        continue;
-                    }
-                    if (!redisCache.lockCacheObject(RedisKey.LOCK_LOCATION + b.getId(), b.getId().toString(), token)) {
-                        continue;
-                    }
-                    locationInfo = b;
-                    break;
-                }
-                if (locationInfo == null) {
-                    throw new ServiceException("出库目标点没有可以分配的库位", token);
-                }
             }
         } else { //移库
             if (locationType.equals("locationFrom")) {
+            } else {
+            }
+        }
+        if (locationType.equals("locationFrom")) {
+            for (BaseLocationInfo b : locationInfoList) {
+            }
+            locationInfo = checkTheSameColumnLocation(locationInfoList, token, false);
+            if (locationInfo == null) {
+                if (type.equals("ASN")) { // 入库
+                    fromMsg = "起始点没有可以分配的库存!";
+                } else if (type.equals("SO")) { // 出库
+                    fromMsg = "起始点没有可以分配的库存!";
+                } else { //移库
+                    fromMsg = "起始点没有可以分配的库位";
+                }
+                throw new ServiceException(fromMsg, token);
+            }
+        } else {
+            for (BaseLocationInfo b : locationInfoList) {
+            }
+            locationInfo = checkTheSameColumnLocation(locationInfoList, token, true);
+            if (locationInfo == null) {
+                if (type.equals("ASN")) { // 入库
+                    toMsg = "目标点没有可以分配的库位";
+                } else if (type.equals("SO")) { // 出库
+                    toMsg = "目标点没有可以分配的库位";
+                } else { //移库
+                    toMsg = "目标点没有可以分配的库位";
+                }
+                throw new ServiceException(toMsg, token);
+            }
+        }
+        return locationInfo;
+    }
 
-                for (BaseLocationInfo b : locationInfoList) {
-                    if (!b.getStockStatus().equals("00") || redisCache.checkIsLock(RedisKey.LOCK_LOCATION + b.getId())) {
+    /**
+     * 校验同列任务任务状态和阻挡
+     *
+     * @param basLocationList
+     * @param token
+     * @param isReleaseGoods  是否目标点位
+     * @return
+     */
+    public BaseLocationInfo checkTheSameColumnLocation(List<BaseLocationInfo> basLocationList, Long token, boolean isReleaseGoods) {
+        boolean isBlock = false; // 是否阻挡
+        BaseLocationInfo basLocation = null;
+        //筛选2次 第2次去除同列占用和阻挡条件 todo 先筛选一次吧
+        for (int i = 0; i < 1 && basLocation == null; i++) {
+            for (BaseLocationInfo location : basLocationList) {
+                //如果库位类型不为地堆则不用判断同列占用和阻挡
+                if (location.getLocationType().equals("2")) {
+                    isBlock = true;
+                }
+
+                //只有第一次判断同列任务占用和阻挡
+                if (i == 0 && isBlock) {
+                    //同列是否有任务
+                    List<BaseLocationInfo> occupyByLocs = baseLocationInfoMapper.queryByListOccupyByLoc(location);
+                    if (occupyByLocs.size() > 0) {
                         continue;
                     }
-                    if (!redisCache.lockCacheObject(RedisKey.LOCK_LOCATION + b.getId(), b.getId().toString(), token)) {
+                    //同列前方是否有阻挡
+                    List<BaseLocationInfo> inStockByLocs = baseLocationInfoMapper.queryByListInStockByLoc(location);
+                    if (inStockByLocs.size() > 0) {
                         continue;
                     }
-                    locationInfo = b;
-                    break;
-                }
-
-                //进行判断
-                if (locationInfo == null) {
-                    throw new ServiceException("移库起始点没有可以分配的库位", token);
                 }
-
-            } else {
-                for (BaseLocationInfo b : locationInfoList) {
-                    if (!b.getStockStatus().equals("00") || !b.getIsEmpty().equals("Y") || redisCache.checkIsLock(RedisKey.LOCK_LOCATION + b.getId())) {
+                // 是否目标点
+                if (!isReleaseGoods) {
+                    if (!location.getStockStatus().equals(Constant.STOCK_STATUS.STOCK00.getValue())
+                            || redisCache.checkIsLock(RedisKey.LOCK_LOCATION + location.getId())) {
                         continue;
                     }
-                    if (!redisCache.lockCacheObject(RedisKey.LOCK_LOCATION + b.getId(), b.getId().toString(), token)) {
+                } else {
+                    if (!location.getStockStatus().equals(Constant.STOCK_STATUS.STOCK00.getValue())
+                            || !location.getIsEmpty().equals(Constant.IS_YES.Y.name())
+                            || redisCache.checkIsLock(RedisKey.LOCK_LOCATION + location.getId())) {
                         continue;
                     }
-                    locationInfo = b;
-                    break;
                 }
-
-                //进行判断
-                if (locationInfo == null) {
-                    throw new ServiceException("移库目标点没有可以分配的库位", token);
+                if (!redisCache.lockCacheObject(RedisKey.LOCK_LOCATION + location.getId()
+                        , location.getId().toString()
+                        , token)) {
+                    continue;
                 }
+                basLocation = location;
+                break;
             }
         }
-        return locationInfo;
+        return basLocation;
     }
 
     @Override

+ 18 - 0
warewms-base/src/main/java/com/ruoyi/base/mapper/BaseLocationInfoMapper.java

@@ -34,6 +34,24 @@ public interface BaseLocationInfoMapper {
      */
     BaseLocationInfo selectBaseLocationInfoByLocationNo(@Param("locationNo") String locationNo, @Param("warehouseId") Long wrehouseId);
 
+    /**
+     * 根据库位返回同库区同列目标占用的库位list
+     * 同列是否已经存在任务
+     *
+     * @param baseLocationInfo
+     * @return
+     */
+    List<BaseLocationInfo> queryByListOccupyByLoc(BaseLocationInfo baseLocationInfo);
+
+    /**
+     * 根据库位返回同库区同列目标有货的库位list
+     * 同列前方是否有阻挡
+     *
+     * @param baseLocationInfo
+     * @return
+     */
+    List<BaseLocationInfo> queryByListInStockByLoc(BaseLocationInfo baseLocationInfo);
+
     /**
      * 查询库位信息列表
      *

+ 22 - 0
warewms-base/src/main/resources/mapper/base/BaseLocationInfoMapper.xml

@@ -185,6 +185,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         order by location_no
     </select>
 
+    <!--根据库位返回同库区同列目标占用的库位list 同列是否已经存在任务-->
+    <select id="queryByListOccupyByLoc" resultMap="BaseLocationInfoResult" parameterType="BaseLocationInfo">
+        select *
+        from base_location_info
+        where stock_status = '10' and location_type ='2'
+          and zone_id = #{zoneId}
+          and col_no = #{colNo}
+          and col_index != #{colIndex}
+
+    </select>
+
+    <!--根据库位返回同库区同列目标有货的库位list 同列前方是否有阻挡    -->
+    <select id="queryByListInStockByLoc" resultMap="BaseLocationInfoResult" parameterType="BaseLocationInfo">
+        select *
+        from base_location_info
+        where is_empty = 'N' and location_type ='2'
+          and zone_id = #{zoneId}
+          and col_no = #{colNo}
+          and col_index > #{colIndex}
+
+    </select>
+
     <select id="selectBaseLocationInfoByLocationNo" parameterType="BaseLocationInfo" resultMap="BaseLocationInfoResult">
         <include refid="selectBaseLocationInfoVo"/>
         where location_no = #{locationNo} and warehouse_id = #{warehouseId}