lss
2025-07-07 ba528c7a15058967ee3af7364035209aa0048025
HH.WCS.Mobox3/HH.WCS.Mobox3.DaYang/wms/LocationHelper.cs
@@ -64,8 +64,8 @@
            var db = new SqlHelper<object>().GetInstance();
            Location location = null;
            List<Location> list = Locations.Values.ToList();
            string areaCode = "";
            string areaCode = "YCLLKQ";
            try
            {
                ////根据起点获取托盘和托盘物料绑定关系
@@ -82,26 +82,15 @@
                //}
                //托盘入库,相同物料内测排的货位
                var Locs = GetLocByItemCode(areaCode, itemCode, new int[] { 1, 4 }).OrderByDescending(b => b.N_COL).ToList();
                var Locs = GetLocByItemCode(areaCode, itemCode, 1).OrderByDescending(b => b.N_COL).ToList();
                if (Locs.Count > 0)
                {
                    //内测排有货位,判断外侧排是否有货位
                    for (int i = Locs.Count - 1; i >= 0; i--)
                    {
                        int row = 0;
                        //判断外侧排
                        switch (list[i].N_ROW)
                        {
                            case 1:
                                row = 2;
                                break;
                            case 4:
                                row = 3;
                                break;
                        }
                        //寻找外侧货位
                        var OutLoc = db.Queryable<Location>().Where(a => a.S_AREA_CODE == Locs[i].S_AREA_CODE && a.N_LAYER == Locs[i].N_LAYER && a.N_ROW == row && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0).First();
                        var OutLoc = db.Queryable<Location>().Where(a => a.S_AREA_CODE == Locs[i].S_AREA_CODE && a.N_LAYER == Locs[i].N_LAYER && a.N_POS == 2 && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0&&a.N_ROADWAY == Locs[i].N_ROADWAY).First();
                        if (OutLoc != null)
                        {
                            location = OutLoc;
@@ -138,27 +127,33 @@
        /// <param name="row">货位排</param>
        /// <param name="ItemCode">物料编码</param>
        /// <returns></returns>
        internal static List<Location> GetLocByItemCodeOrderyTime(string areaCode, string ItemCode)
        internal static Location GetLocByItemCodeOrderyTime(string areaCode, string ItemCode)
        {
            List<Location> locs;
            Location loc = null;
            var db = new SqlHelper<object>().GetInstance();
            try
            {
                locs = db.Queryable<Location>()
                   .LeftJoin<LocCntrRel>((a, b) => a.S_CODE == b.S_LOC_CODE)
                   .LeftJoin<CntrItemDetail>((a, b, c) => b.S_CNTR_CODE == c.S_CNTR_CODE)
                   .Where((a, b, c) => a.N_CURRENT_NUM > 0 && a.N_LOCK_STATE == 0 && a.S_AREA_CODE == areaCode
                    && c.S_ITEM_CODE == ItemCode && a.N_LOCK_STATE == 0)
                   .GroupBy((a, b, c) => new { a.S_CODE, c.T_INBOUND_TIME ,a.N_POS })
                   .OrderBy((a, b, c) => c.T_INBOUND_TIME)
                   .OrderByDescending((a, b, c) => a.N_POS)
                   .ToList();
                var loc1 = db.Queryable<Location>()
                    .LeftJoin<LocCntrRel>((a, b) => a.S_CODE == b.S_LOC_CODE)
                    .LeftJoin<CntrItemDetail>((a, b, c) => b.S_CNTR_CODE == c.S_CNTR_CODE)
                    .Where((a, b, c) => a.N_CURRENT_NUM > 0 && a.N_LOCK_STATE == 0 && a.S_AREA_CODE == areaCode
                     && c.S_ITEM_CODE == ItemCode && a.N_LOCK_STATE == 0)
                    .GroupBy((a, b, c) => new { a.S_CODE, c.T_INBOUND_TIME, a.N_POS })
                    .OrderBy((a, b, c) => c.T_INBOUND_TIME)
                    .OrderByDescending((a, b, c) => a.N_POS)
                    .Select((a, b, c) => new
                    {
                        S_CODE = a.S_CODE,
                        T_INBOUND_TIME = c.T_INBOUND_TIME,
                        N_POS = a.N_POS
                    })
                    .ToList();
                // var LocCodes = loc1.Select(a => a.S_CODE).First();
                loc = db.Queryable<Location>().Where(a => a.S_CODE == loc1.First().S_CODE).First();
                return locs;
                return loc;
            }
            catch (Exception ex)
            {
@@ -175,7 +170,7 @@
        /// <param name="row">货位排</param>
        /// <param name="ItemCode">物料编码</param>
        /// <returns></returns>
        internal static List<Location> GetLocByItemCode(string areaCode, string ItemCode, int[] row)
        internal static List<Location> GetLocByItemCode(string areaCode, string ItemCode, int pos)
        {
            List<Location> locs;
            var db = new SqlHelper<object>().GetInstance();
@@ -184,7 +179,7 @@
                var queryable = db.Queryable<Location>()
                   .LeftJoin<LocCntrRel>((a, b) => a.S_CODE == b.S_LOC_CODE)
                   .LeftJoin<CntrItemDetail>((a, b, c) => b.S_CNTR_CODE == c.S_CNTR_CODE)
                   .Where((a, b, c) => a.N_CURRENT_NUM > 0 && a.N_LOCK_STATE == 0 && a.S_AREA_CODE == areaCode && row.Contains(a.N_ROW) && c.S_ITEM_CODE == ItemCode && a.N_LOCK_STATE == 0);
                   .Where((a, b, c) => a.N_CURRENT_NUM > 0 && a.N_LOCK_STATE == 0 && a.S_AREA_CODE == areaCode && a.N_POS == pos && c.S_ITEM_CODE == ItemCode && a.N_LOCK_STATE == 0);
                locs = queryable.ToList();