zs
2025-05-19 1225fbcf6dd197c39853e2cb0f70c7318836abcb
HIAWms/server/src/CMS.Plugin.HIAWms.EntityFrameworkCore/Repositories/EfCoreWmsStoreRepository.cs
@@ -1,6 +1,8 @@
using System.Linq.Dynamic.Core;
using System.Linq.Expressions;
using CMS.Plugin.HIAWms.Domain.WmsStores;
using CMS.Plugin.HIAWms.EntityFrameworkCore.Extensions;
using CmsQueryExtensions.Extension;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
@@ -51,21 +53,41 @@
        return sort + 1;
    }
    /// <inheritdoc />
    public async Task<List<WmsStore>> GetListAsync(WmsStore? store, string sorting = null, int maxResultCount = int.MaxValue, int skipCount = 0, string filter = null, Specification<WmsStore> 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<WmsStore>> GetListAsync(FunReturnResultModel<Expression<Func<WmsStore, bool>>> whereConditions, string sorting = null, int maxResultCount = int.MaxValue, int skipCount = 0, bool includeDetails = false, CancellationToken cancellationToken = default)
    {
        specification ??= new WmsStoreSpecification();
        return await (await GetDbSetAsync())
            .IncludeDetails(includeDetails)
            .Where(specification.ToExpression())
            .WhereIf(whereConditions != null, whereConditions.data)
            .Where(x => !x.IsDeleted)
            .WhereIf(!filter.IsNullOrWhiteSpace(), u => u.StoreCode.Contains(filter))
            .WhereIf(!string.IsNullOrEmpty(store.StoreCode),u=>u.StoreCode.Contains(store.StoreCode))
            .WhereIf(!string.IsNullOrEmpty(store.StoreName),u=>u.StoreName.Contains(store.StoreName))
            .OrderBy(sorting.IsNullOrEmpty() ? nameof(WmsStore.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<WmsStore, bool>>> whereConditions, CancellationToken cancellationToken = default)
    {
        return await (await GetQueryableAsync())
            .WhereIf(whereConditions != null, whereConditions.data)
            .Where(x => !x.IsDeleted)
            .CountAsync(cancellationToken: GetCancellationToken(cancellationToken));
    }
    /// <summary>
    /// 查询仓库列表
@@ -80,17 +102,17 @@
    }
    /// <inheritdoc />
    public async Task<long> GetCountAsync(WmsStore? store, string filter = null, Specification<WmsStore> specification = null, CancellationToken cancellationToken = default)
    {
        specification ??= new WmsStoreSpecification();
        return await (await GetQueryableAsync())
            .Where(specification.ToExpression())
            .Where(x => !x.IsDeleted)
            .WhereIf(!filter.IsNullOrWhiteSpace(), u => u.StoreCode.Contains(filter))
            .WhereIf(!string.IsNullOrEmpty(store.StoreCode), u => u.StoreCode.Contains(store.StoreCode))
            .WhereIf(!string.IsNullOrEmpty(store.StoreName), u => u.StoreName.Contains(store.StoreName))
            .CountAsync(cancellationToken: GetCancellationToken(cancellationToken));
    }
    //public async Task<long> GetCountAsync(WmsStore? store, string filter = null, Specification<WmsStore> specification = null, CancellationToken cancellationToken = default)
    //{
    //    specification ??= new WmsStoreSpecification();
    //    return await (await GetQueryableAsync())
    //        .Where(specification.ToExpression())
    //        .Where(x => !x.IsDeleted)
    //        .WhereIf(!filter.IsNullOrWhiteSpace(), u => u.StoreCode.Contains(filter))
    //        .WhereIf(!string.IsNullOrEmpty(store.StoreCode), u => u.StoreCode.Contains(store.StoreCode))
    //        .WhereIf(!string.IsNullOrEmpty(store.StoreName), u => u.StoreName.Contains(store.StoreName))
    //        .CountAsync(cancellationToken: GetCancellationToken(cancellationToken));
    //}
    /// <inheritdoc />
    public override async Task<IQueryable<WmsStore>> WithDetailsAsync()