| | |
| | | using SqlSugar; |
| | | using WIDESEA_Common.StockEnum; |
| | | using System.Collections.Generic; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseRepository; |
| | |
| | | |
| | | public PageGridData<StockInfoDetailWithPalletDto> GetPageData2(PageDataOptions options) |
| | | { |
| | | // 1. è·ååºç¡åé¡µæ°æ® |
| | | ISugarQueryable<Dt_StockInfoDetail> sugarQueryable1 = BaseDal.Db.Queryable<Dt_StockInfoDetail>(); |
| | | ISugarQueryable<Dt_StockInfo> sugarQueryable = BaseDal.Db.Queryable<Dt_StockInfo>(); |
| | | |
| | | 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) |
| | | { |
| | | sugarQueryable1 = sugarQueryable1.Where(x => x.StockId == targetStock.Id); |
| | | } |
| | | break; |
| | | sugarQueryable = sugarQueryable.Where((detail, item) => item.PalletCode.Contains(param.Value)); |
| | | } |
| | | } |
| | | } |
| | |
| | | catch (Exception ex) |
| | | { |
| | | } |
| | | } |
| | | EntityProperties.ValidatePageOptions(options, ref sugarQueryable1); |
| | | ISugarQueryable<StockInfoDetailWithPalletDto> list = sugarQueryable1.InnerJoin(sugarQueryable, (b, a) => a.Id == b.StockId).Select((b, a) => new StockInfoDetailWithPalletDto |
| | | { |
| | | Id = b.Id, |
| | | StockId = b.StockId, |
| | | MaterielCode = b.MaterielCode, |
| | | MaterielName = b.MaterielName, |
| | | OrderNo = b.OrderNo, |
| | | BatchNo = b.BatchNo, |
| | | ProductionDate = b.ProductionDate, |
| | | EffectiveDate = b.EffectiveDate, |
| | | SerialNumber = b.SerialNumber, |
| | | StockQuantity = b.StockQuantity, |
| | | OutboundQuantity = b.OutboundQuantity, |
| | | Status = b.Status, |
| | | Unit = b.Unit, |
| | | InboundOrderRowNo = b.InboundOrderRowNo, |
| | | SupplyCode = b.SupplyCode, |
| | | WarehouseCode = b.WarehouseCode, |
| | | Barcode = b.Barcode, |
| | | BusinessType = b.BusinessType, |
| | | Remark = b.Remark, |
| | | Creater = b.Creater, |
| | | CreateDate = b.CreateDate, |
| | | Modifier = b.Modifier, |
| | | ModifyDate = b.ModifyDate, |
| | | PalletCode = a.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); |
| | | |
| | | |
| | | int totalCount = 0; |
| | | var stockViewDTOs = list.ToPageList(options.Page, options.Rows, ref totalCount); |
| | | return new PageGridData<StockInfoDetailWithPalletDto>(totalCount, stockViewDTOs); |
| | | |
| | | return new PageGridData<StockInfoDetailWithPalletDto>(totalCount, data); |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |