schangxiang@126.com
2025-05-13 25246d39da4b74b54a844b36d8a50752917b81cc
HIAWms/server/src/CMS.Plugin.HIAWms.EntityFrameworkCore/Repositories/EfCoreWmsMaterialStockRepository.cs
@@ -73,33 +73,10 @@
    }
    /// <inheritdoc />
    public async Task<List<WmsMaterialStock>> GetListAsync(WmsMaterialStock? stock, DateTime? startTime = null, DateTime? endTime = null, string sorting = null, int maxResultCount = int.MaxValue, int skipCount = 0, string filter = null, Specification<WmsMaterialStock> specification = null, bool includeDetails = false, CancellationToken cancellationToken = default)
    public async Task<List<WmsMaterialStock>> GetListAsync(FunReturnResultModel<Expression<Func<WmsMaterialStock, bool>>> whereConditions, string sorting = null, int maxResultCount = int.MaxValue, int skipCount = 0, bool includeDetails = false, CancellationToken cancellationToken = default)
    {
        specification ??= new WmsMaterialStockSpecification();
        var baseQuery = (await GetDbSetAsync())
        .IncludeDetails(includeDetails)
        .WhereIf(!filter.IsNullOrWhiteSpace(),
            u => u.MaterialNo.Contains(filter) ||
                 u.MaterialName.Contains(filter) ||
                 u.MaterialBatch.Contains(filter) ||
                 u.PlaceNo.Contains(filter) ||
                 u.AreaName.Contains(filter))
        .WhereIf(!string.IsNullOrEmpty(stock?.MaterialNo), u => u.MaterialNo.Contains(stock.MaterialNo))
        .WhereIf(!string.IsNullOrEmpty(stock?.MaterialName), u => u.MaterialName.Contains(stock.MaterialName))
        .WhereIf(!string.IsNullOrEmpty(stock?.ContainerNo), u => u.ContainerNo == stock.ContainerNo)
        .WhereIf(stock?.ContainerStatus > 0, u => u.ContainerStatus == stock.ContainerStatus)
        .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==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)
        .WhereIf(!string.IsNullOrEmpty(stock?.AreaCode), u => u.AreaCode == stock.AreaCode)
        .WhereIf(!string.IsNullOrEmpty(stock?.AreaName), u => u.AreaName.Contains(stock.AreaName))
        .WhereIf(stock.IsLock > 0, u => u.IsLock == stock.IsLock)
        .WhereIf(startTime.HasValue, u => u.InStockTime >= startTime.Value)
        .WhereIf(endTime.HasValue, u => u.InStockTime <= endTime.Value)
        .IncludeDetails(includeDetails).WhereIf(whereConditions != null, whereConditions.data)
        .Where(u => !u.IsDeleted)
        .AsQueryable();
@@ -157,32 +134,10 @@
    }
    /// <inheritdoc />
    public async Task<long> GetCountAsync(WmsMaterialStock? stock, DateTime? startTime = null, DateTime? endTime = null, string filter = null, Specification<WmsMaterialStock> specification = null, CancellationToken cancellationToken = default)
    public async Task<long> GetCountAsync(FunReturnResultModel<Expression<Func<WmsMaterialStock, bool>>> whereConditions, CancellationToken cancellationToken = default)
    {
        specification ??= new WmsMaterialStockSpecification();
        var baseQuery = (await GetQueryableAsync())
            .WhereIf(!filter.IsNullOrWhiteSpace(),
            u => u.MaterialNo.Contains(filter) ||
                 u.MaterialName.Contains(filter) ||
                 u.MaterialBatch.Contains(filter) ||
                 u.PlaceNo.Contains(filter) ||
                 u.AreaName.Contains(filter))
            .WhereIf(!string.IsNullOrEmpty(stock?.MaterialNo), u => u.MaterialNo.Contains(stock.MaterialNo))
            .WhereIf(!string.IsNullOrEmpty(stock?.MaterialName), u => u.MaterialName.Contains(stock.MaterialName))
            .WhereIf(!string.IsNullOrEmpty(stock?.ContainerNo), u => u.ContainerNo == stock.ContainerNo)
            .WhereIf(stock?.ContainerStatus > 0, u => u.ContainerStatus == stock.ContainerStatus)
            .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?.PlaceNo), u => u.PlaceNo == stock.PlaceNo)
            .WhereIf(stock.PlaceStatus > 0, u => u.PlaceStatus == stock.PlaceStatus)
            .WhereIf(stock?.StorageTypeNo > 0, u => u.StorageTypeNo == stock.StorageTypeNo)
            .WhereIf(!string.IsNullOrEmpty(stock?.AreaCode), u => u.AreaCode == stock.AreaCode)
            .WhereIf(!string.IsNullOrEmpty(stock?.AreaName), u => u.AreaName.Contains(stock.AreaName))
            .WhereIf(stock.IsLock > 0, u => u.IsLock == stock.IsLock)
            .WhereIf(startTime.HasValue, u => u.InStockTime >= startTime.Value)
            .WhereIf(endTime.HasValue, u => u.InStockTime <= endTime.Value)
           .WhereIf(whereConditions != null, whereConditions.data)
            .Where(u => !u.IsDeleted)
            .AsQueryable();