lss
2025-06-04 adbeeccfcddddbba49718136a1ebb3429ab3b7ae
HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/wms/LocationHelper.cs
@@ -3,6 +3,7 @@
using NLog.Fluent;
using SqlSugar;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -300,6 +301,34 @@
        }
        /// <summary>
        /// 分配电梯货位
        /// </summary>
        /// <returns></returns>
        internal static Location GetElevatorLoc()
        {
            var db = new SqlHelper<object>().GetInstance();
            Location location = new Location();
            //查找全部电梯,分配任务最少的电梯
            var devices = Settings.deviceInfos.Where(a => a.deviceType == 2 && a.enable == 1).ToList();
            string[] state = new string[] { "执行中", "开始取货", "取货完成" };
            Dictionary<int, string> dics = new Dictionary<int, string>();
            foreach (var deviceInfo in devices)
            {
                int mst = db.Queryable<WCSTask>().Where(a => a.S_TYPE.Contains("电梯") && state.Contains(a.S_B_STATE)).Count();
                dics.Add(mst, deviceInfo.TN_Location);
            }
            if (dics.Count > 0)
            {
                var dic = dics.OrderBy(a => a.Key).First();
                location = db.Queryable<Location>().Where(a => a.S_CODE == dic.Value).First();
                if (location == null)
                {
                    LogHelper.Info($"根据货位编码:{dic.Value},未找到对应货位");
                }
            }
            return location;
        }
        /// <summary>
        /// 根据物料编码,仓库编码获取托盘数量
        /// </summary>
        /// <param name="areaCode">库区编码,合肥佳通业务为不包含这个库区</param>
@@ -478,15 +507,15 @@
        }
        /// <summary>
        /// 根据货位集合获取 没有容器 没有锁的货位
        /// 根据货位获取货位信息
        /// </summary>
        /// <param name="loc"></param>
        /// <returns></returns>
        internal static List<Location> GetLocListEmptyFree(List<string> loc)
        internal static Location GetLocByLoc(string loc)
        {
            //1.0 查货位容器表
            var db = new SqlHelper<object>().GetInstance();
            var list = db.Queryable<Location>().Where(a => loc.Contains(a.S_CODE) && a.N_CURRENT_NUM == 0 && a.S_LOCK_STATE.Trim() == "无").ToList();
            var list = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == loc).First();
            return list;
        }