diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/SettleAccount.HttpApi.Host.csproj b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/SettleAccount.HttpApi.Host.csproj index 1672c209..d83c1464 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/SettleAccount.HttpApi.Host.csproj +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/SettleAccount.HttpApi.Host.csproj @@ -1,4 +1,4 @@ - + @@ -12,11 +12,11 @@ ..\..\..\.. net5.0 True -<<<<<<< HEAD + false -======= - false ->>>>>>> 1c2946500765850db29fa7d216f5e55e2e4de888 + + + diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/BaseDomainServices/BaseDomainService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/BaseDomainServices/BaseDomainService.cs new file mode 100644 index 00000000..f2c00079 --- /dev/null +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/BaseDomainServices/BaseDomainService.cs @@ -0,0 +1,104 @@ +using SettleAccount.Bases; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Caching; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.Domain.Services; +using Volo.Abp.Guids; +using Volo.Abp.ObjectMapping; +using Win.Sfs.SettleAccount.Boms; +using Win.Sfs.SettleAccount.CommonManagers; +using Win.Sfs.SettleAccount.Entities.ImportMap; +using Win.Sfs.SettleAccount.Entities.Materials; +using Win.Sfs.SettleAccount.FISes; +using Win.Sfs.SettleAccount.MaterialRelationships; + +namespace Win.Sfs.SettleAccount.Bases.DomainServices +{ + public class BaseDomainService:DomainService, ICheck + { + private readonly ISettleAccountBQEfCoreRepository _materialRepository; + private readonly ISettleAccountBQEfCoreRepository _relationshipRepository; + private readonly ISettleAccountBQEfCoreRepository _bomshipRepository; + + public BaseDomainService( + IGuidGenerator guidGenerator, + IObjectMapper objectMapper, + ISettleAccountBQEfCoreRepository materialRepository, + ISettleAccountBQEfCoreRepository relationshipRepository, + ISettleAccountBQEfCoreRepository bomshipRepository + //IExcelImportAppService excelImportService, + //ISnowflakeIdGenerator snowflakeIdGenerator, + //ICommonManager commonManager + ) + { + _materialRepository = materialRepository; + _relationshipRepository = relationshipRepository; + _bomshipRepository = bomshipRepository; + } + + public async Task> CheckBase(List p_list ,BASE_CONF p_config) where TEntity : ISBASE + + { + List errorList = new List(); + var partList= p_list.Select(p=>p.LU).Distinct().ToList(); + + if (p_config.IsBom == true) + { + var bomList =await _bomshipRepository.ToListAsync(); + var query=from itm in partList join itm1 in bomList on itm equals itm1.ParentItemCode + into temp + from tm in temp.DefaultIfEmpty() + where tm == null + select itm; + + foreach(var itm1 in query.ToList()) + { + errorList.Add(itm1); + } + } + if (p_config.IsMaterial == true) + { + + var materialList = await _materialRepository.ToListAsync(); + var query = from itm in partList + join itm1 in materialList on itm equals itm1.MaterialCode + into temp + from tm in temp.DefaultIfEmpty() + where tm == null + select itm; + foreach (var partcode in query.ToList()) + { + errorList.Add(partcode); + } + } + if (p_config.IsRelationShip == true) + { + var materialList =await _relationshipRepository.ToListAsync(); + var query = from itm in partList + join itm1 in materialList on itm equals itm1.SettleMaterialCode + into temp + from tm in temp.DefaultIfEmpty() + where tm == null + select itm; + + foreach (var partcode in query.ToList()) + { + errorList.Add(partcode); + } + } + return errorList; + } + + + } + public interface ICheck + { + Task> CheckBase(List p_list, BASE_CONF p_config) where TEntity : ISBASE; + } + + +} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs index 1b2083b7..a9222561 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; using Win.Sfs.SettleAccount.Entities.SettleAccountDomain; using static System.Runtime.CompilerServices.RuntimeHelpers; -namespace Win.Sfs.SettleAccount.Bases +namespace SettleAccount.Bases { /// /// 所有业务单据基类 diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/ISettleAccountBranchEfCoreRepository.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/ISettleAccountBranchEfCoreRepository.cs index b44b500d..ddc476d9 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/ISettleAccountBranchEfCoreRepository.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/ISettleAccountBranchEfCoreRepository.cs @@ -11,10 +11,8 @@ using System.Data.Common; using System.Data; using System.Data.SqlClient; - - - - +using System.Threading; +using Win.Sfs.Shared.Filter; namespace Win.Sfs.SettleAccount { @@ -29,7 +27,52 @@ namespace Win.Sfs.SettleAccount - DbCommand CreateCommand(string commandText, CommandType commandType, params DbParameter[] parameters); - } + + } + + public interface ISettleAccountBQEfCoreRepository + : IWinEfCoreRepository + , ITransientDependency + where TEntity : class, IEntity -} \ No newline at end of file + { + Task GetPropertyValueAsync(Func> factory, string propertyName); + + Task GetPropertyValueAsync(Func> factory, IEnumerable propertyNames, char separator); + Task> GetAllAsync( + + bool includeDetails = false, + CancellationToken cancellationToken = default); + + Task GetCountAsync( + + CancellationToken cancellationToken = default); + + Task GetCountByFilterAsync( + + List filters, + CancellationToken cancellationToken = default); + + + Task> GetListByFilterAsync( + + List filters, + string sorting = null, + int maxResultCount = int.MaxValue, + int skipCount = 0, + bool includeDetails = false, + CancellationToken cancellationToken = default); + + + + } + + + + + + + + + +} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountBQEfCoreRepository.cs b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountBQEfCoreRepository.cs new file mode 100644 index 00000000..bae890c5 --- /dev/null +++ b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountBQEfCoreRepository.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.Common; +using System.Data.SqlClient; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Storage; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Domain.Entities; +using Volo.Abp.EntityFrameworkCore; +using Win.Sfs.Shared; +using Win.Sfs.Shared.DomainBase; +using Win.Sfs.Shared.Filter; +using Win.Sfs.Shared.RepositoryBase; + +namespace Win.Sfs.SettleAccount.Repository +{ + public class SettleAccountBQEfCoreRepository : + SettleAccountEfCoreRepository, + ISettleAccountBQEfCoreRepository, + ITransientDependency + where TEntity : class, IBranch, IEntity + { + + private readonly IDbContextProvider _dbContextProvider; + + + + public SettleAccountBQEfCoreRepository(IDbContextProvider dbContextProvider) : + base(dbContextProvider) + { + + _dbContextProvider = dbContextProvider; + + } + public SettleAccountBQEfCoreRepository() : base(null) + { + + } + + public DbCommand CreateCommand(string commandText, CommandType commandType, params DbParameter[] parameters) + { + var command = DbContext.Database.GetDbConnection().CreateCommand(); + + command.CommandText = commandText; + command.CommandType = commandType; + command.Transaction = DbContext.Database.CurrentTransaction?.GetDbTransaction(); + + foreach (var parameter in parameters) + { + command.Parameters.Add(parameter); + } + + return command; + } + + public async Task EnsureConnectionOpenAsync(CancellationToken cancellationToken = default) + { + var connection = DbContext.Database.GetDbConnection(); + + if (connection.State != ConnectionState.Open) + { + await connection.OpenAsync(cancellationToken); + } + } + public virtual async Task> GetAllAsync( bool includeDetails = false, + CancellationToken cancellationToken = default) + { + var query = includeDetails ? this.WithDetails() : this.GetQueryable(); + + //query = query.Where(p => p.BranchId.Equals(branchId)); + + return await query.ToListAsync(cancellationToken: cancellationToken); + } + + public virtual async Task GetCountAsync(CancellationToken cancellationToken = default) + { + return await this.GetQueryable() + //.Where(p => p.BranchId.Equals(branchId)) + .LongCountAsync(GetCancellationToken(cancellationToken)); + + } + + public virtual async Task GetCountByFilterAsync( List filters, + CancellationToken cancellationToken = default) + { + return await this.GetQueryable() + //.Where(p => p.BranchId.Equals(branchId)) + .WhereIf(filters?.Count != 0, filters.ToLambda()) + .LongCountAsync(GetCancellationToken(cancellationToken)); + } + + public virtual async Task> GetListByFilterAsync( List filters, + string sorting = null, + int maxResultCount = int.MaxValue, int skipCount = 0, bool includeDetails = false, + CancellationToken cancellationToken = default) + { + var query = includeDetails ? this.WithDetails() : this.GetQueryable(); + // query = query.Where(p => p.BranchId.Equals(branchId)); + var entities = query.WhereIf(filters?.Count != 0, filters.ToLambda()); + //2021-07-02 设置sorting首字母大小,因设置了驼峰规则,不匹配“ var memberProp = typeof(T).GetProperty(propertyName);”反射 + if(!string.IsNullOrEmpty(sorting)) + { + sorting = sorting.Substring(0, 1).ToUpper() + sorting.Substring(1); + } + entities = GetSortingQueryable(entities, sorting); + return await entities.PageBy(skipCount, maxResultCount) + .ToListAsync(GetCancellationToken(cancellationToken)); + + + } + + } + + +}