Browse Source

更新版本

pull/1/head
学 赵 1 year ago
parent
commit
47a20fd857
  1. 10
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/SettleAccount.HttpApi.Host.csproj
  2. 104
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/BaseDomainServices/BaseDomainService.cs
  3. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs
  4. 57
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/ISettleAccountBranchEfCoreRepository.cs
  5. 119
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountBQEfCoreRepository.cs

10
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/SettleAccount.HttpApi.Host.csproj

@ -1,4 +1,4 @@

<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\common.props" />
@ -12,11 +12,11 @@
<DockerfileContext>..\..\..\..</DockerfileContext>
<TargetFramework>net5.0</TargetFramework>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<<<<<<< HEAD
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
=======
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
>>>>>>> 1c2946500765850db29fa7d216f5e55e2e4de888
</PropertyGroup>
<ItemGroup>

104
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<Material, Guid> _materialRepository;
private readonly ISettleAccountBQEfCoreRepository<MaterialRelationship, Guid> _relationshipRepository;
private readonly ISettleAccountBQEfCoreRepository<Bom, Guid> _bomshipRepository;
public BaseDomainService(
IGuidGenerator guidGenerator,
IObjectMapper objectMapper,
ISettleAccountBQEfCoreRepository<Material, Guid> materialRepository,
ISettleAccountBQEfCoreRepository<MaterialRelationship, Guid> relationshipRepository,
ISettleAccountBQEfCoreRepository<Bom, Guid> bomshipRepository
//IExcelImportAppService excelImportService,
//ISnowflakeIdGenerator snowflakeIdGenerator,
//ICommonManager commonManager
)
{
_materialRepository = materialRepository;
_relationshipRepository = relationshipRepository;
_bomshipRepository = bomshipRepository;
}
public async Task<List<string>> CheckBase<TEntity>(List<TEntity> p_list ,BASE_CONF p_config) where TEntity : ISBASE
{
List<string> errorList = new List<string>();
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<List<string>> CheckBase<TEntity>(List<TEntity> p_list, BASE_CONF p_config) where TEntity : ISBASE;
}
}

2
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
{
/// <summary>
/// 所有业务单据基类

57
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<TEntity, TKey>
: IWinEfCoreRepository<TEntity, TKey>
, ITransientDependency
where TEntity : class, IEntity<TKey>
}
{
Task<string> GetPropertyValueAsync(Func<Task<TEntity>> factory, string propertyName);
Task<string> GetPropertyValueAsync(Func<Task<TEntity>> factory, IEnumerable<string> propertyNames, char separator);
Task<List<TEntity>> GetAllAsync(
bool includeDetails = false,
CancellationToken cancellationToken = default);
Task<long> GetCountAsync(
CancellationToken cancellationToken = default);
Task<long> GetCountByFilterAsync(
List<FilterCondition> filters,
CancellationToken cancellationToken = default);
Task<List<TEntity>> GetListByFilterAsync(
List<FilterCondition> filters,
string sorting = null,
int maxResultCount = int.MaxValue,
int skipCount = 0,
bool includeDetails = false,
CancellationToken cancellationToken = default);
}
}

119
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<TEntity, TKey> :
SettleAccountEfCoreRepository<TEntity, TKey>,
ISettleAccountBQEfCoreRepository<TEntity, TKey>,
ITransientDependency
where TEntity : class, IBranch<TKey>, IEntity<TKey>
{
private readonly IDbContextProvider<SettleAccountDbContext> _dbContextProvider;
public SettleAccountBQEfCoreRepository(IDbContextProvider<SettleAccountDbContext> 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<List<TEntity>> 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<long> GetCountAsync(CancellationToken cancellationToken = default)
{
return await this.GetQueryable()
//.Where(p => p.BranchId.Equals(branchId))
.LongCountAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<long> GetCountByFilterAsync( List<FilterCondition> filters,
CancellationToken cancellationToken = default)
{
return await this.GetQueryable()
//.Where(p => p.BranchId.Equals(branchId))
.WhereIf(filters?.Count != 0, filters.ToLambda<TEntity>())
.LongCountAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<List<TEntity>> GetListByFilterAsync( List<FilterCondition> 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<TEntity>());
//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));
}
}
}
Loading…
Cancel
Save