lss
2025-06-24 3e870a218efe18db4eeb099632aac12a947a9e92
HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs
@@ -2550,7 +2550,7 @@
            var list = db.Queryable<Location>().Where(a => a.N_CURRENT_NUM == 0 && a.S_AREA_CODE.Trim() == areacode && a.N_LOCK_STATE == 0).ToList();
            if (list.Count > 0)
            {
                FindEndcolByLocList(list);
                FindEndcolByLocListLock(list);
            }
            //查询所有有托盘的排没锁的排
@@ -2862,6 +2862,57 @@
        }
        /// <summary>
        /// 找终点空货位计算排锁
        /// </summary>
        /// <param name="locations"></param>
        /// <returns></returns>
        internal static Location FindEndcolByLocListLock(List<Location> locations)
        {
            try
            {
                var db = new SqlHelper<object>().GetInstance();
                Location end = null;
                //根据终点货位找空闲货位
                var rows = locations.Select(a => a.N_ROW).Distinct().ToList();
                for (int i = 0; i < rows.Count; i++)
                {
                    var rowList = locations.Where(r => r.N_ROW == rows[i]).ToList();
                    if (rowList.Count(a => a.S_LOCK_STATE != "无") == 0 && rowList.Count(a => a.N_CURRENT_NUM == 0) > 0)
                    {
                        Location other = null;
                        //当前排没有锁并且有空位置
                        //先找满位,然后后面一位要么是空,要么不存在
                        var full = rowList.OrderByDescending(a => a.N_COL).Where(a => a.N_CURRENT_NUM == 1).FirstOrDefault();
                        if (full == null)
                        {
                            //没有满位,那就找最小的空位
                            other = rowList.OrderBy(a => a.N_COL).FirstOrDefault();
                        }
                        else
                        {
                            other = rowList.OrderBy(a => a.N_COL).Where(a => a.N_COL > full.N_COL).FirstOrDefault();
                        }
                        if (other != null)
                        {
                            end = other;
                            break;
                        }
                    }
                }
                return end;
            }
            catch (Exception)
            {
                throw;
            }
        }
        /// <summary>
        /// 找起点满货位
        /// </summary>
        /// <param name="locations"></param>