From 4b3fd35893972bb05fd7ab89dc624ab805093ff3 Mon Sep 17 00:00:00 2001 From: zs <zhousong@weben-smart.com> Date: 周日, 18 5月 2025 19:47:46 +0800 Subject: [PATCH] Merge branch 'master' of http://222.71.245.114:9086/r/HIA24016N_PipeLineDemo --- HIAWms/server/src/CMS.Plugin.HIAWms.EntityFrameworkCore/Repositories/EfCoreWmsMaterialRepository.cs | 86 ++++++++++++++++++++++++++++++++----------- 1 files changed, 64 insertions(+), 22 deletions(-) diff --git a/HIAWms/server/src/CMS.Plugin.HIAWms.EntityFrameworkCore/Repositories/EfCoreWmsMaterialRepository.cs b/HIAWms/server/src/CMS.Plugin.HIAWms.EntityFrameworkCore/Repositories/EfCoreWmsMaterialRepository.cs index 72d311a..5ccf656 100644 --- a/HIAWms/server/src/CMS.Plugin.HIAWms.EntityFrameworkCore/Repositories/EfCoreWmsMaterialRepository.cs +++ b/HIAWms/server/src/CMS.Plugin.HIAWms.EntityFrameworkCore/Repositories/EfCoreWmsMaterialRepository.cs @@ -2,8 +2,10 @@ using System.Linq; using System.Linq.Dynamic.Core; using System.Linq.Expressions; +using CMS.Plugin.HIAWms.Domain.WmsAreas; using CMS.Plugin.HIAWms.Domain.WmsMaterials; using CMS.Plugin.HIAWms.EntityFrameworkCore.Extensions; +using CmsQueryExtensions.Extension; using Microsoft.EntityFrameworkCore; using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; @@ -30,13 +32,28 @@ .IncludeDetails() .Where(x => !x.IsDeleted) .OrderBy(t => t.Sort) - .FirstOrDefaultAsync(t => t.MaterialCode == name, GetCancellationToken(cancellationToken)); + .FirstOrDefaultAsync(t => t.MaterialNo == name, GetCancellationToken(cancellationToken)); + } + + /// <summary> + /// 查找型号 + /// </summary> + /// <param name="model"></param> + /// <param name="cancellationToken"></param> + /// <returns></returns> + public virtual async Task<WmsMaterial> FindByModelAsync(string model, CancellationToken cancellationToken = default) + { + return await (await GetDbSetAsync()) + .IncludeDetails() + .Where(x => !x.IsDeleted) + .OrderBy(t => t.Sort) + .FirstOrDefaultAsync(t => t.MaterialModel == model, GetCancellationToken(cancellationToken)); } /// <inheritdoc /> - public async Task<bool> NameExistAsync(string materialCode, Guid? id = null) + public async Task<bool> NameExistAsync(string MaterialNo, Guid? id = null) { - return await (await GetDbSetAsync()).WhereIf(id.HasValue, p => p.Id != id).Where(x => !x.IsDeleted).AnyAsync(x => x.MaterialCode == materialCode); + return await (await GetDbSetAsync()).WhereIf(id.HasValue, p => p.Id != id).Where(x => !x.IsDeleted).AnyAsync(x => x.MaterialNo == MaterialNo); } /// <inheritdoc /> @@ -55,42 +72,55 @@ } /// <inheritdoc /> - public async Task<List<WmsMaterial>> GetListAsync(WmsMaterial? material, string sorting = null, int maxResultCount = int.MaxValue, int skipCount = 0, string filter = null, Specification<WmsMaterial> 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<WmsMaterial>> GetListAsync(FunReturnResultModel<Expression<Func<WmsMaterial, bool>>> whereConditions, string sorting = null, int maxResultCount = int.MaxValue, int skipCount = 0, bool includeDetails = false, CancellationToken cancellationToken = default) { - specification ??= new WmsMaterialSpecification(); return await (await GetDbSetAsync()) .IncludeDetails(includeDetails) - .Where(specification.ToExpression()) - .WhereIf(!filter.IsNullOrWhiteSpace(), u => u.MaterialCode.Contains(filter)) - .WhereIf(!string.IsNullOrEmpty(material.MaterialName), u => u.MaterialName.Contains(material.MaterialName)) - .WhereIf(!string.IsNullOrEmpty(material.MaterialCode), u => u.MaterialName.Contains(material.MaterialCode)) - .WhereIf(material.MaterialType > 0, u => u.MaterialType == material.MaterialType) - .WhereIf(material.PurchaseType > 0, u => u.PurchaseType == material.PurchaseType) + .WhereIf(whereConditions != null, whereConditions.data) .Where(x => !x.IsDeleted) - .OrderBy(sorting.IsNullOrEmpty() ? nameof(WmsMaterial.Sort) : sorting) + .OrderByDescending(x => x.CreationTime) .PageBy(skipCount, maxResultCount) .ToListAsync(GetCancellationToken(cancellationToken)); } /// <summary> - /// 获取总数 + /// 获取物料基础列表 /// </summary> /// <param name="material"></param> - /// <param name="filter"></param> - /// <param name="specification"></param> /// <param name="cancellationToken"></param> /// <returns></returns> - public async Task<long> GetCountAsync(WmsMaterial? material, string filter = null, Specification<WmsMaterial> specification = null, CancellationToken cancellationToken = default) + public async Task<List<WmsMaterial>> GetMaterialListAsync(WmsMaterial? material, CancellationToken cancellationToken = default) { - specification ??= new WmsMaterialSpecification(); - return await (await GetQueryableAsync()) - .Where(specification.ToExpression()) + return await (await GetDbSetAsync()) .WhereIf(!string.IsNullOrEmpty(material.MaterialName), u => u.MaterialName.Contains(material.MaterialName)) - .WhereIf(!string.IsNullOrEmpty(material.MaterialCode), u => u.MaterialName.Contains(material.MaterialCode)) - .WhereIf(material.MaterialType > 0, u => u.MaterialType == material.MaterialType) + .WhereIf(!string.IsNullOrEmpty(material.MaterialNo), u => u.MaterialNo.Contains(material.MaterialNo)) + .WhereIf(!string.IsNullOrEmpty(material.MaterialTypeCode), u => u.MaterialTypeCode == material.MaterialTypeCode) .WhereIf(material.PurchaseType > 0, u => u.PurchaseType == material.PurchaseType) .Where(x => !x.IsDeleted) - .WhereIf(!filter.IsNullOrWhiteSpace(), u => u.MaterialCode.Contains(filter)) + .ToListAsync(GetCancellationToken(cancellationToken)); + } + + /// <summary> + /// 获取总数物料基础信息 + /// </summary> + /// <param name="whereConditions"></param> + /// <param name="cancellationToken"></param> + /// <returns></returns> + public async Task<long> GetCountAsync(FunReturnResultModel<Expression<Func<WmsMaterial, bool>>> whereConditions, CancellationToken cancellationToken = default) + { + return await (await GetQueryableAsync()) + .WhereIf(whereConditions != null, whereConditions.data) + .Where(x => !x.IsDeleted) .CountAsync(cancellationToken: GetCancellationToken(cancellationToken)); } @@ -100,4 +130,16 @@ return (await GetQueryableAsync()) .Where(x => !x.IsDeleted).IncludeDetails(); } + + /// <summary> + /// 获取物料表 + /// </summary> + /// <param name="cancellationToken"></param> + /// <returns></returns> + public async Task<List<WmsMaterial>> GetListForSelectAsync(CancellationToken cancellationToken = default) + { + return await (await GetDbSetAsync()) + .Where(x => !x.IsDeleted) + .ToListAsync(GetCancellationToken(cancellationToken)); + } } -- Gitblit v1.9.3