wangxinhui
2025-01-06 801ddd3be4d6bf8553cac870435bb5092eca6b60
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockViewService.cs
@@ -1,7 +1,9 @@

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;
@@ -35,7 +37,8 @@
        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>();
@@ -50,10 +53,11 @@
            //}
            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,
@@ -75,8 +79,41 @@
                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);
        }