diff --git a/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs b/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs index 8ebd6e3a6..da9df6202 100644 --- a/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs +++ b/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs @@ -566,6 +566,7 @@ namespace IRaCIS.Application.Services }); await _inspectionService.AddListInspectionRecordAsync(datas); await _repository.AddAsync(stat); + //await _subjectVisitRepository.AddRangeAsync() await _repository.AddRangeAsync(subjectVisits); await _repository.SaveChangesAsync(); return ResponseOutput.Ok(); diff --git a/IRaCIS.Core.Domain/Common/JsonConvert.cs b/IRaCIS.Core.Domain/Common/JsonConvert.cs index d6d77c826..81a9a6345 100644 --- a/IRaCIS.Core.Domain/Common/JsonConvert.cs +++ b/IRaCIS.Core.Domain/Common/JsonConvert.cs @@ -10,7 +10,7 @@ namespace IRaCIS.Core.Domain.Common public static class JJsonConvert { /// <summary> - /// 将对象序列化成Json字符串 + /// 将对象序列化成稽查需要的Json字符串 /// </summary> /// <param name="obj">需要序列化的对象</param> /// <param name="jsonConverterArray"></param> diff --git a/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs b/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs index 339b8c31b..c4f700149 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs @@ -53,9 +53,9 @@ namespace IRaCIS.Core.Infra.EFCore Task<int> CountAsync(Expression<Func<TEntity, bool>> whereLambda = null, bool ignoreQueryFilters = false); - ValueTask<TEntity> AddAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default); + ValueTask<TEntity> AddAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default,bool isSaveAudit=false); - Task<IEnumerable<TEntity>> AddRangeAsync(IEnumerable<TEntity> entities); + Task<IEnumerable<TEntity>> AddRangeAsync(IEnumerable<TEntity> entities, bool isSaveAudit = false); //Task<bool> AddRangeAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default); // 不建议使用,使用跟踪,然后save 部分字段更新,此种方式是更新所有字段 diff --git a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs index 9154b68a7..00a798172 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs @@ -19,6 +19,7 @@ using Microsoft.Data.SqlClient; using Newtonsoft.Json; using IRaCIS.Core.Infra.EFCore.Dto; using Newtonsoft.Json.Linq; +using IRaCIS.Core.Domain.Common; namespace IRaCIS.Core.Infra.EFCore { @@ -42,28 +43,24 @@ namespace IRaCIS.Core.Infra.EFCore } - #region 异步 EF 跟踪 添加 - - - - public async Task<IEnumerable<TEntity>> AddRangeAsync(IEnumerable<TEntity> entities) + public async Task<IEnumerable<TEntity>> AddRangeAsync(IEnumerable<TEntity> entities,bool isSaveAudit=false) { foreach (var addEntity in entities) { - await AddAsync(addEntity); + await AddAsync(addEntity, isSaveAudit); } return entities; } /// <summary>EF跟踪方式 添加</summary> - public async ValueTask<TEntity> AddAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default) + public async ValueTask<TEntity> AddAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default,bool isSaveAudit=false) { await _dbSet.AddAsync(entity).ConfigureAwait(false); - await AddInspectionAsync(entity); + await AddInspectionAsync(entity, isSaveAudit); if (autoSave) { @@ -583,7 +580,7 @@ namespace IRaCIS.Core.Infra.EFCore } - private async Task AddInspectionAsync(TEntity entity) + private async Task AddInspectionAsync(TEntity entity,bool isSaveAudit=false) { List<DataInspection> datas = new List<DataInspection>(); @@ -602,7 +599,7 @@ namespace IRaCIS.Core.Infra.EFCore IsSign = false, CreateTime = createtime, Identification = "Init|Subject|Status|Subject", - JsonDetail = JsonConvert.SerializeObject(entity) + JsonDetail = entity.ToJcJson() }); } await AddListInspectionRecordAsync(datas);