| | |
| | |  |
| | | using HslCommunication.Secs.Types; |
| | | using Microsoft.AspNetCore.Http; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Drawing.Printing; |
| | | using System.Dynamic; |
| | |
| | | |
| | | public virtual PageGridData<StockViewDTO> GetPageData(PageDataOptions options) |
| | | { |
| | | string where = options.ValidatePageOptions(typeof(StockViewDTO).GetProperties()); |
| | | |
| | | //string where = options.ValidatePageOptions(typeof(StockViewDTO).GetProperties()); |
| | | //è·åæåºå段 |
| | | //Dictionary<string, OrderByType> orderbyDic = options.GetPageDataSort(typeof(StockViewDTO).GetProperties()); |
| | | //List<OrderByModel> orderByModels = new List<OrderByModel>(); |
| | |
| | | //} |
| | | int totalCount = 0; |
| | | |
| | | ISugarQueryable<Dt_StockInfo> sugarQueryable1 = _dbBase.Queryable<Dt_StockInfo>(); |
| | | ISugarQueryable<Dt_StockInfo> sugarQueryable1 = _dbBase.Queryable<Dt_StockInfo>().Includes(x=>x.Details); |
| | | ISugarQueryable<Dt_LocationInfo> sugarQueryable = _dbBase.Queryable<Dt_LocationInfo>(); |
| | | |
| | | List<StockViewDTO> list = sugarQueryable1.InnerJoin(sugarQueryable, (b, a) => a.LocationCode == b.LocationCode).WhereIF(!string.IsNullOrEmpty(where), where).Select((b, a) => new StockViewDTO |
| | | List<StockViewDTO> list = sugarQueryable1.InnerJoin(sugarQueryable, (b, a) => a.LocationCode == b.LocationCode).Select((b, a) |
| | | => new StockViewDTO |
| | | { |
| | | LocationCode = b.LocationCode, |
| | | Column = a.Column, |
| | |
| | | StockStatus = b.StockStatus, |
| | | Details = b.Details, |
| | | }).ToPageList(options.Page, options.Rows, ref totalCount); |
| | | |
| | | |
| | | list.ForEach(x => |
| | | { |
| | | x.MaterielCode = string.Join(",", x.Details.Select(x => x.MaterielCode).Distinct()); |
| | | x.BatchNo = string.Join(",", x.Details.Select(x => x.BatchNo).Distinct()); |
| | | } |
| | | ); |
| | | if (options.Wheres.IsNotEmptyOrNull()) |
| | | { |
| | | List<SearchParameters> searchParameters = options.Wheres.DeserializeObject<List<SearchParameters>>(); |
| | | foreach (var item in searchParameters) |
| | | { |
| | | switch (item.Name) |
| | | { |
| | | case "palletCode": |
| | | list = list.Where(x => x.PalletCode.Contains(item.Value)).ToList(); |
| | | break; |
| | | case "locationStatus": |
| | | List<int> locationStatus = item.Value.Split(",").Select(int.Parse).ToList(); |
| | | list = list.Where(x => locationStatus.Contains(x.LocationStatus)).ToList(); |
| | | break; |
| | | case "stockStatus": |
| | | List<int> stockStatus = item.Value.Split(",").Select(int.Parse).ToList(); |
| | | list = list.Where(x => stockStatus.Contains(x.StockStatus)).ToList(); |
| | | break; |
| | | case "materielCode": |
| | | list = list.Where(x => x.MaterielCode.Contains(item.Value)).ToList(); |
| | | break; |
| | | case "batchNo": |
| | | list=list.Where(x => x.BatchNo.Contains(item.Value)).ToList(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | return new PageGridData<StockViewDTO>(totalCount, list); |
| | | |
| | | } |