| | |
| | | using SqlSugar; |
| | | using WIDESEA_Common.StockEnum; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.BaseServices; |
| | |
| | | |
| | | public PageGridData<StockInfoDetailWithPalletDto> GetPageData2(PageDataOptions options) |
| | | { |
| | | // 1. è·ååºç¡åé¡µæ°æ® |
| | | PageGridData<Dt_StockInfoDetail> pageData = base.GetPageData(options); |
| | | List<Dt_StockInfoDetail> filteredDetails = pageData.Rows.ToList(); // å
æ·è´åå§æ°æ® |
| | | string wheres = ValidatePageOptions(options); |
| | | |
| | | var sugarQueryable = Db.Queryable<Dt_StockInfoDetail>().InnerJoin<Dt_StockInfo>((detail, item) => detail.StockId == item.Id) |
| | | .Where((detail, item) =>item.StockStatus==StockStatusEmun.å
¥åºå®æ.ObjToInt()); |
| | | |
| | | Dictionary<string, SqlSugar.OrderByType> orderbyDic = GetPageDataSort(options, TProperties); |
| | | List<OrderByModel> orderByModels = new List<OrderByModel>(); |
| | | foreach (var item in orderbyDic) |
| | | { |
| | | if (item.Key.ToLower() == "id") |
| | | { |
| | | OrderByModel orderByModel = new() |
| | | { |
| | | FieldName = "detail."+item.Key, |
| | | OrderByType = item.Value |
| | | }; |
| | | orderByModels.Add(orderByModel); |
| | | } |
| | | else |
| | | { |
| | | OrderByModel orderByModel = new() |
| | | { |
| | | FieldName = item.Key, |
| | | OrderByType = item.Value |
| | | }; |
| | | orderByModels.Add(orderByModel); |
| | | } |
| | | |
| | | } |
| | | int totalCount = 0; |
| | | List<SearchParameters> searchParametersList = new List<SearchParameters>(); |
| | | |
| | | |
| | | if (!string.IsNullOrEmpty(options.Wheres)) |
| | | { |
| | | try |
| | | { |
| | | List<SearchParameters> searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>(); |
| | | if (searchParametersList?.Any() == true) |
| | | searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>(); |
| | | if (searchParametersList != null && searchParametersList.Any()) |
| | | { |
| | | foreach (var param in searchParametersList) |
| | | { |
| | |
| | | if (param.Name.Equals(nameof(Dt_StockInfo.PalletCode).FirstLetterToLower(), StringComparison.OrdinalIgnoreCase) |
| | | && !string.IsNullOrEmpty(param.Value?.ToString())) |
| | | { |
| | | // ä¼åï¼æ¹éæ¥è¯¢ï¼å¦ææå¤ä¸ªæçç ï¼è¿éä¹å¯ä»¥æ©å±ï¼ |
| | | string palletCode = param.Value.ToString().Trim(); |
| | | var targetStock = _stockinfoRepository.QueryFirst(x => x.PalletCode == palletCode); |
| | | |
| | | // ç©ºå¼æ ¡éªï¼æªæ¾å°å¯¹åºæççåºåï¼ç´æ¥è¿æ»¤ä¸ºç©º |
| | | if (targetStock != null) |
| | | { |
| | | filteredDetails = filteredDetails.Where(x => x.StockId == targetStock.Id).ToList(); |
| | | } |
| | | else |
| | | { |
| | | filteredDetails = new List<Dt_StockInfoDetail>(); |
| | | } |
| | | break; // å个æçç æ¥è¯¢ï¼å¹é
åéåºå¾ªç¯ |
| | | sugarQueryable = sugarQueryable.Where((detail, item) => item.PalletCode.Contains(param.Value)); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | List<int> stockIds = filteredDetails.Select(detail => detail.StockId).Distinct().ToList(); |
| | | var stockDict = _stockinfoRepository.QueryData(x => stockIds.Contains(x.Id)) |
| | | .ToDictionary(x => x.Id, x => x.PalletCode ?? "æ æçç¼å·"); |
| | | var data = sugarQueryable |
| | | .WhereIF(!wheres.IsNullOrEmpty(), wheres) |
| | | .OrderBy(orderByModels) |
| | | .Select((detail, item) => new StockInfoDetailWithPalletDto |
| | | { |
| | | Id = detail.Id, |
| | | StockId = detail.StockId, |
| | | MaterielCode = detail.MaterielCode, |
| | | MaterielName = detail.MaterielName, |
| | | OrderNo = detail.OrderNo, |
| | | BatchNo = detail.BatchNo, |
| | | ProductionDate = detail.ProductionDate, |
| | | EffectiveDate = detail.EffectiveDate, |
| | | SerialNumber = detail.SerialNumber, |
| | | StockQuantity = detail.StockQuantity, |
| | | OutboundQuantity = detail.OutboundQuantity, |
| | | Status = detail.Status, |
| | | Unit = detail.Unit, |
| | | InboundOrderRowNo = detail.InboundOrderRowNo, |
| | | SupplyCode = detail.SupplyCode, |
| | | WarehouseCode = detail.WarehouseCode, |
| | | Barcode = detail.Barcode, |
| | | BusinessType = detail.BusinessType, |
| | | Remark = detail.Remark, |
| | | Creater = detail.Creater, |
| | | CreateDate = detail.CreateDate, |
| | | Modifier = detail.Modifier, |
| | | ModifyDate = detail.ModifyDate, |
| | | PalletCode = item.PalletCode |
| | | }) |
| | | .ToPageList(options.Page, options.Rows, ref totalCount); |
| | | |
| | | List<StockInfoDetailWithPalletDto> dtoList = filteredDetails |
| | | .Select(detail => new StockInfoDetailWithPalletDto |
| | | { |
| | | Id = detail.Id, |
| | | StockId = detail.StockId, |
| | | MaterielCode = detail.MaterielCode, |
| | | MaterielName = detail.MaterielName, |
| | | OrderNo = detail.OrderNo, |
| | | BatchNo = detail.BatchNo, |
| | | ProductionDate = detail.ProductionDate, |
| | | EffectiveDate = detail.EffectiveDate, |
| | | SerialNumber = detail.SerialNumber, |
| | | StockQuantity = detail.StockQuantity, |
| | | OutboundQuantity = detail.OutboundQuantity, |
| | | Status = detail.Status, |
| | | Unit = detail.Unit, |
| | | InboundOrderRowNo = detail.InboundOrderRowNo, |
| | | SupplyCode = detail.SupplyCode, |
| | | WarehouseCode = detail.WarehouseCode, |
| | | Barcode = detail.Barcode, |
| | | BusinessType = detail.BusinessType, |
| | | Remark = detail.Remark, |
| | | Creater = detail.Creater, |
| | | CreateDate = detail.CreateDate, |
| | | Modifier = detail.Modifier, |
| | | ModifyDate = detail.ModifyDate, |
| | | PalletCode = stockDict.TryGetValue(detail.StockId, out var palletCode) ? palletCode : "æ æçç¼å·" |
| | | }) |
| | | .ToList(); |
| | | |
| | | return new PageGridData<StockInfoDetailWithPalletDto> |
| | | { |
| | | Rows = dtoList.Where(x=>x.PalletCode != "æ æçç¼å·").ToList(), |
| | | Total = pageData.Total, |
| | | Summary = pageData.Summary |
| | | }; |
| | | return new PageGridData<StockInfoDetailWithPalletDto>(totalCount, data); |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |