1
heshaofeng
2026-03-25 37454e625df68d40897112b2e8c2e3cf4d7163e3
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs
@@ -4,6 +4,7 @@
using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
using SqlSugar;
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
@@ -43,12 +44,47 @@
            WebResponseContent content = new WebResponseContent();
            try
            {
                var stockInfos = _stockRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletType == PalletTypeEnum.Empty.ObjToInt() && x.StockStatus == StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt()).WhereIF(locationType != 0, x => x.LocationType == locationType).Take(num).ToList();
                Dictionary<string, SqlSugar.OrderByType> orderByDict = new Dictionary<string, SqlSugar.OrderByType>()
                {
                     { nameof(Dt_LocationInfo.Layer), SqlSugar.OrderByType.Asc },
                     { nameof(Dt_LocationInfo.Row), SqlSugar.OrderByType.Asc },
                     { nameof(Dt_LocationInfo.Column), SqlSugar.OrderByType.Asc },
                     { nameof(Dt_LocationInfo.Depth), SqlSugar.OrderByType.Desc },
                };
                if (stockInfos.Count() == 0)
                var query = _stockRepository.Db.Queryable<Dt_StockInfo>()
                    .Where(x => x.PalletType == PalletTypeEnum.Empty.ObjToInt()
                             && x.StockStatus == StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt())
                    .WhereIF(locationType != 0, x => x.LocationType == locationType)
                    .LeftJoin<Dt_LocationInfo>((s, l) => s.LocationCode == l.LocationCode);
                if (query.Count() == 0)
                {
                    return WebResponseContent.Instance.Error("鏈壘鍒扮┖鎵樼洏搴撳瓨");
                }
                bool isFirstOrder = true;
                foreach (var item in orderByDict)
                {
                    string fieldName = item.Key.Equals("Column", StringComparison.OrdinalIgnoreCase)
                        ? $"l.[{item.Key}]"
                        : $"l.{item.Key}";
                    string sortSql = $"{fieldName} {(item.Value == SqlSugar.OrderByType.Asc ? "ASC" : "DESC")}";
                    if (isFirstOrder)
                    {
                        query = query.OrderBy(sortSql);
                        isFirstOrder = false;
                    }
                    else
                    {
                        query = query.OrderBy(sortSql);
                    }
                }
                var stockInfos = await query.Take(num).ToListAsync();
                foreach (var stockInfo in stockInfos)
                {
                    Dt_LocationInfo locationInfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == stockInfo.LocationCode);
@@ -97,6 +133,8 @@
            }
        }
        /// <summary>
        /// 鍑哄簱浠诲姟鏁版嵁澶勭悊