diff --git a/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs b/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs index 8ebd6e3a..da9df620 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 d6d77c82..81a9a634 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 { /// - /// 将对象序列化成Json字符串 + /// 将对象序列化成稽查需要的Json字符串 /// /// 需要序列化的对象 /// diff --git a/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs b/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs index 339b8c31..c4f70014 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 CountAsync(Expression> whereLambda = null, bool ignoreQueryFilters = false); - ValueTask AddAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default); + ValueTask AddAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default,bool isSaveAudit=false); - Task> AddRangeAsync(IEnumerable entities); + Task> AddRangeAsync(IEnumerable entities, bool isSaveAudit = false); //Task AddRangeAsync(IEnumerable 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 9154b68a..00a79817 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> AddRangeAsync(IEnumerable entities) + public async Task> AddRangeAsync(IEnumerable entities,bool isSaveAudit=false) { foreach (var addEntity in entities) { - await AddAsync(addEntity); + await AddAsync(addEntity, isSaveAudit); } return entities; } /// EF跟踪方式 添加 - public async ValueTask AddAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default) + public async ValueTask 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 datas = new List(); @@ -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);