| | |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Concurrent; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | |
| | | 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); |
| | |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var allFactoryAreas = stockViews.SelectMany(sv => sv.Details) |
| | | .Select(x => x.FactoryArea) |
| | | .GroupBy(x => x) |
| | | .ToList(); |
| | | if (allFactoryAreas.Count >= 2) |
| | | { |
| | | return content.Error($"è¯·éæ©åä¸ååºåºåçåºåè¿è¡çç¹ï¼å½åæ¶å{allFactoryAreas.Count}个ä¸åçååº"); |
| | | } |
| | | List<int> ids = stockViews.Select(x => x.StockId).ToList(); |
| | | //è·ååºå |
| | | List<Dt_StockInfo> stockInfos = _stockRepository.Db.Queryable<Dt_StockInfo>().Where(x => ids.Contains(x.Id)).Includes(x => x.Details).ToList(); |
| | |
| | | return content.Error($"æªæ¾å°{item.PalletCode}åºåæç»æ°æ®"); |
| | | } |
| | | Dt_LocationInfo? locationInfo = locationInfos.FirstOrDefault(x => x.LocationCode == item.LocationCode); |
| | | if (locationInfo == null && (locationInfo.EnableStatus == EnableStatusEnum.Disable.ObjToInt() || locationInfo.EnableStatus != EnableStatusEnum.Normal.ObjToInt()) && locationInfo.LocationStatus != LocationStatusEnum.InStock.ObjToInt() && item.StockStatus != StockStatusEmun.å
¥åºå®æ.ObjToInt()) |
| | | if (locationInfo == null || (locationInfo.EnableStatus == EnableStatusEnum.Disable.ObjToInt() || locationInfo.EnableStatus != EnableStatusEnum.Normal.ObjToInt()) || locationInfo.LocationStatus != LocationStatusEnum.InStock.ObjToInt() || item.StockStatus != StockStatusEmun.å
¥åºå®æ.ObjToInt()) |
| | | { |
| | | content.Error($"{item.PalletCode}è´§ä½æåºåç¶æä¸æ»¡è¶³åºåºæ¡ä»¶"); |
| | | return content.Error($"{item.PalletCode}è´§ä½æåºåç¶æä¸æ»¡è¶³åºåºæ¡ä»¶"); |
| | | } |
| | | } |
| | | List<Dt_Task> tasks = GetTasks(stockInfos, TaskTypeEnum.OutInventory,outStation); |