杨前锦
2025-05-15 91443c26b77da527c0dfc4d6c3e45e349e581ecf
HH.WCS.Mobox3/HH.WCS.Mobox3.YNJT_BZP/wms/WMSHelper.cs
@@ -419,25 +419,35 @@
            return result;
        }
       /// <summary>
       /// 获取空托开始货位
       /// </summary>
       /// <param name="trayType"></param>
       /// <returns></returns>
        public static Location GetEmptyTrayStartLoc(int trayType)
        /// <summary>
        /// 获取空托开始货位
        /// </summary>
        /// <param name="trayType"></param>
        /// <param name="exclude">是否排除母拖缓存位 0.不排除 1.排除</param>
        /// <returns></returns>
        public static Location GetEmptyTrayStartLoc(int trayType ,int exclude = 1)
        {
            Location result = null;
            try
            {
                // 1、查询当前库区-排-物料 有托盘的货位
                var db = new SqlHelper<object>().GetInstance();
                result = db.Queryable<Location>()
                var query = db.Queryable<Location>()
                     .LeftJoin<LocCntrRel>((a, b) => a.S_CODE == b.S_LOC_CODE)
                     .LeftJoin<Container>((a, b, c) => b.S_CNTR_CODE == c.S_CODE)
                     .LeftJoin<CntrItemRel>((a,b,c,d) => c.S_CODE == d.S_CNTR_CODE)
                     .Where((a, b, c, d) => a.S_AREA_CODE == Settings.storeAreaCode && (trayType == 0 && a.N_CURRENT_NUM == 1 || trayType > 0 && a.N_CURRENT_NUM > 0) && a.N_LOCK_STATE == 0 && (a.C_ENABLE != "禁用" && a.C_ENABLE != "N") && c.N_TYPE == trayType && d.S_ITEM_CODE == null)
                     .OrderByDescending((a, b, c, d) => a.N_LAYER)
                     .First();
                     .LeftJoin<CntrItemRel>((a, b, c, d) => c.S_CODE == d.S_CNTR_CODE)
                     .Where((a, b, c, d) => a.S_AREA_CODE == Settings.storeAreaCode && (trayType == 0 && a.N_CURRENT_NUM == 1 || trayType > 0 && a.N_CURRENT_NUM > 0) && a.N_LOCK_STATE == 0 && (a.C_ENABLE != "禁用" && a.C_ENABLE != "N") && c.N_TYPE == trayType && d.S_ITEM_CODE == null);
                if (exclude == 1)
                {
                    query = query.Where((a, b, c, d) => a.S_CODE != Settings.baseTrayInBufferLoc);
                }
                else
                {
                    query = query.OrderByDescending((a, b, c, d) => a.S_CODE == Settings.baseTrayInBufferLoc);
                }
                result = query.OrderByDescending((a, b, c, d) => a.N_LAYER).First();
            }
            catch (Exception ex)
            {
@@ -488,8 +498,9 @@
        /// </summary>
        /// <param name="itemCode"></param>
        /// <param name="jbLoc"></param>
        /// <param name="trayCode"></param>
        /// <returns></returns>
        public static Location GetoutStockStartLoc(string itemCode ,string jbLoc = null)
        public static Location GetoutStockStartLoc(string itemCode ,string trayCode = null ,string jbLoc = null)
        {
            LogHelper.Info("【获取出库开始货位】", "WMS");
            var db = new SqlHelper<object>().GetInstance();
@@ -511,6 +522,11 @@
                                    && c.S_EXPIRATION_TIME != null
                                    );
                if (trayCode != null)
                {
                    query = query.Where((a, b, c) => c.S_CNTR_CODE == trayCode);
                }
                if (jbLoc != null) 
                {
                    List<int> roadwayList = new List<int>();