| | |
| | | using System.Linq.Dynamic.Core; |
| | | using System.Linq.Expressions; |
| | | using CMS.Plugin.HIAWms.Domain.WmsMaterialStocks; |
| | | using CMS.Plugin.HIAWms.Domain.WmsTask; |
| | | using CMS.Plugin.HIAWms.EntityFrameworkCore.Extensions; |
| | | using CmsQueryExtensions.Extension; |
| | | using DatabaseSchemaReader.Filters; |
| | | using Microsoft.EntityFrameworkCore; |
| | | using SqlKata; |
| | |
| | | .WhereIf(stock?.ContainerType > 0, u => u.ContainerType == stock.ContainerType) |
| | | .WhereIf(!string.IsNullOrEmpty(stock?.MaterialBatch), u => u.MaterialBatch == stock.MaterialBatch) |
| | | .WhereIf(!string.IsNullOrEmpty(stock?.SupplierCode), u => u.SupplierCode == stock.SupplierCode) |
| | | .WhereIf(!string.IsNullOrEmpty(stock?.MaterialModel), u => u.MaterialModel.Contains(stock.MaterialModel)) |
| | | .WhereIf(!string.IsNullOrEmpty(stock?.MaterialModel), u => u.MaterialModel==stock.MaterialModel) |
| | | .WhereIf(!string.IsNullOrEmpty(stock?.PlaceNo), u => u.PlaceNo == stock.PlaceNo) |
| | | .WhereIf(stock.PlaceStatus > 0, u => u.PlaceStatus == stock.PlaceStatus) |
| | | .WhereIf(stock?.StorageTypeNo > 0, u => u.StorageTypeNo == stock.StorageTypeNo) |
| | |
| | | .ToListAsync(GetCancellationToken(cancellationToken)); |
| | | |
| | | var groupedData = materialList |
| | | .GroupBy(x => new { x.MaterialNo, x.PlaceNo, x.ContainerNo}) |
| | | .GroupBy(x => new { x.MaterialNo, x.PlaceNo, x.ContainerNo,x.MaterialModel}) |
| | | .Select(g => new WmsMaterialStock |
| | | { |
| | | MaterialNo = g.Key.MaterialNo, |
| | |
| | | PlaceStatus = g.First().PlaceStatus, |
| | | StorageTypeNo = g.First().StorageTypeNo, |
| | | MaterialBatch = g.First().MaterialBatch, |
| | | MaterialModel = g.First().MaterialModel, |
| | | MaterialModel = g.Key.MaterialModel, |
| | | AreaCode = g.First().AreaCode, |
| | | AreaName = g.First().AreaName, |
| | | CheckStatus = g.First().CheckStatus, |
| | |
| | | .WhereIf(!string.IsNullOrEmpty(stock?.AreaName), u => u.AreaName.Contains(stock.AreaName)) |
| | | .WhereIf(stock.IsLock > 0, u => u.IsLock == stock.IsLock) |
| | | .Where(u => !u.IsDeleted) |
| | | .OrderByDescending(x=>x.InStockTime) |
| | | .ToListAsync(); |
| | | return baseQuery; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 查询库存明细 |
| | | /// </summary> |
| | | /// <param name="whereConditions"></param> |
| | | /// <param name="sorting"></param> |
| | | /// <param name="maxResultCount"></param> |
| | | /// <param name="skipCount"></param> |
| | | /// <param name="includeDetails"></param> |
| | | /// <param name="cancellationToken"></param> |
| | | /// <returns></returns> |
| | | public async Task<List<WmsMaterialStock>> GetStockDetailListAsync(FunReturnResultModel<Expression<Func<WmsMaterialStock, bool>>> whereConditions, string sorting = null, int maxResultCount = int.MaxValue, int skipCount = 0, bool includeDetails = false, CancellationToken cancellationToken = default) |
| | | { |
| | | return await (await GetDbSetAsync()) |
| | | .IncludeDetails(includeDetails) |
| | | .WhereIf(whereConditions != null, whereConditions.data) |
| | | .Where(x => !x.IsDeleted) |
| | | .OrderBy(x=>x.PlaceNo) |
| | | .ThenByDescending(x => x.CreationTime) |
| | | .PageBy(skipCount, maxResultCount) |
| | | .ToListAsync(GetCancellationToken(cancellationToken)); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取总数库存管理 |
| | | /// </summary> |
| | | /// <param name="whereConditions"></param> |
| | | /// <param name="cancellationToken"></param> |
| | | /// <returns></returns> |
| | | public async Task<long> GetDetailCountAsync(FunReturnResultModel<Expression<Func<WmsMaterialStock, bool>>> whereConditions, CancellationToken cancellationToken = default) |
| | | { |
| | | return await (await GetQueryableAsync()) |
| | | .WhereIf(whereConditions != null, whereConditions.data) |
| | | .Where(x => !x.IsDeleted) |
| | | .CountAsync(cancellationToken: GetCancellationToken(cancellationToken)); |
| | | } |
| | | |
| | | |
| | | /// <inheritdoc /> |
| | | public override async Task<IQueryable<WmsMaterialStock>> WithDetailsAsync() |
| | | { |