| | |
| | | using System; |
| | | using System.Linq.Dynamic.Core; |
| | | using System.Linq.Expressions; |
| | | using CMS.Plugin.HIAWms.Domain.WmsAreas; |
| | | using CMS.Plugin.HIAWms.EntityFrameworkCore.Extensions; |
| | | using CmsQueryExtensions.Extension; |
| | | using DatabaseSchemaReader.Filters; |
| | | using MathNet.Numerics; |
| | | using Microsoft.EntityFrameworkCore; |
| | |
| | | return sort + 1; |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public async Task<List<WmsArea>> GetListAsync(WmsArea? area, string sorting = null, int maxResultCount = int.MaxValue, int skipCount = 0, string filter = null, Specification<WmsArea> specification = null, bool includeDetails = false, CancellationToken cancellationToken = default) |
| | | /// <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<WmsArea>> GetListAsync(FunReturnResultModel<Expression<Func<WmsArea, bool>>> whereConditions, string sorting = null, int maxResultCount = int.MaxValue, int skipCount = 0, bool includeDetails = false, CancellationToken cancellationToken = default) |
| | | { |
| | | specification ??= new WmsAreaSpecification(); |
| | | return await (await GetDbSetAsync()) |
| | | .IncludeDetails(includeDetails) |
| | | .Where(specification.ToExpression()) |
| | | .WhereIf(!filter.IsNullOrWhiteSpace(), u => u.AreaNo.Contains(filter)) |
| | | .WhereIf(!string.IsNullOrEmpty(area.AreaNo), u => u.AreaNo.Contains(area.AreaNo)) |
| | | .WhereIf(!string.IsNullOrEmpty(area.AreaName), u => u.AreaNo.Contains(area.AreaName)) |
| | | .WhereIf(!string.IsNullOrEmpty(area.StoreCode), u => u.AreaNo == area.StoreCode) |
| | | .WhereIf(area.AreaStatus > 0, u => u.AreaStatus == area.AreaStatus) |
| | | .WhereIf(area.AreaType > 0, u => u.AreaType == area.AreaType) |
| | | .WhereIf(whereConditions != null, whereConditions.data) |
| | | .Where(x => !x.IsDeleted) |
| | | .OrderBy(sorting.IsNullOrEmpty() ? nameof(WmsArea.Sort) : sorting) |
| | | .OrderByDescending(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> GetCountAsync(FunReturnResultModel<Expression<Func<WmsArea, bool>>> whereConditions, CancellationToken cancellationToken = default) |
| | | { |
| | | return await (await GetQueryableAsync()) |
| | | .WhereIf(whereConditions != null, whereConditions.data) |
| | | .Where(x => !x.IsDeleted) |
| | | .CountAsync(cancellationToken: GetCancellationToken(cancellationToken)); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public async Task<long> GetCountAsync(WmsArea? area, string filter = null, Specification<WmsArea> specification = null, CancellationToken cancellationToken = default) |
| | | { |
| | | specification ??= new WmsAreaSpecification(); |
| | | return await (await GetQueryableAsync()) |
| | | .Where(specification.ToExpression()) |
| | | .WhereIf(!filter.IsNullOrWhiteSpace(), u => u.AreaNo.Contains(filter)) |
| | | .WhereIf(!string.IsNullOrEmpty(area.AreaNo), u => u.AreaNo.Contains(area.AreaNo)) |
| | | .WhereIf(!string.IsNullOrEmpty(area.AreaName), u => u.AreaNo.Contains(area.AreaName)) |
| | | .WhereIf(!string.IsNullOrEmpty(area.StoreCode), u => u.AreaNo == area.StoreCode) |
| | | .WhereIf(area.AreaStatus > 0, u => u.AreaStatus == area.AreaStatus) |
| | | .WhereIf(area.AreaType > 0, u => u.AreaType == area.AreaType) |
| | | .Where(x => !x.IsDeleted) |
| | | .CountAsync(cancellationToken: GetCancellationToken(cancellationToken)); |
| | | } |
| | | //public async Task<long> GetCountAsync(WmsArea? area, string filter = null, Specification<WmsArea> specification = null, CancellationToken cancellationToken = default) |
| | | //{ |
| | | // specification ??= new WmsAreaSpecification(); |
| | | // return await (await GetQueryableAsync()) |
| | | // .Where(specification.ToExpression()) |
| | | // .WhereIf(!filter.IsNullOrWhiteSpace(), u => u.AreaNo.Contains(filter)) |
| | | // .WhereIf(!string.IsNullOrEmpty(area.AreaNo), u => u.AreaNo.Contains(area.AreaNo)) |
| | | // .WhereIf(!string.IsNullOrEmpty(area.AreaName), u => u.AreaNo.Contains(area.AreaName)) |
| | | // .WhereIf(!string.IsNullOrEmpty(area.StoreCode), u => u.AreaNo == area.StoreCode) |
| | | // .WhereIf(area.AreaStatus > 0, u => u.AreaStatus == area.AreaStatus) |
| | | // .WhereIf(area.AreaType > 0, u => u.AreaType == area.AreaType) |
| | | // .Where(x => !x.IsDeleted) |
| | | // .CountAsync(cancellationToken: GetCancellationToken(cancellationToken)); |
| | | //} |
| | | |
| | | /// <inheritdoc /> |
| | | public override async Task<IQueryable<WmsArea>> WithDetailsAsync() |