From d21b8c024c684ddf9df4e65762862393ce6e69ff Mon Sep 17 00:00:00 2001 From: he <10978375@qq.com> Date: Fri, 6 May 2022 17:37:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/StudyController.cs | 2 +- .../Service/Visit/SubjectVisitService.cs | 3 +- .../Service/Visit/VisitPlanService.cs | 4 +- .../Triggers/SubjectVisitTrigger.cs | 2 +- .../Common/AuditingData.cs | 60 +++++++++++++++---- .../Repository/Repository.cs | 7 +-- 6 files changed, 56 insertions(+), 22 deletions(-) diff --git a/IRaCIS.Core.API/Controllers/StudyController.cs b/IRaCIS.Core.API/Controllers/StudyController.cs index 90b1117f..2a5aa961 100644 --- a/IRaCIS.Core.API/Controllers/StudyController.cs +++ b/IRaCIS.Core.API/Controllers/StudyController.cs @@ -231,7 +231,7 @@ namespace IRaCIS.Api.Controllers Dictionary keyValuePairs = new Dictionary(); keyValuePairs.Add("StyudCode", studycode); data.JsonDetail = _inspectionService.AddJsonItem(data.JsonDetail, keyValuePairs); - await _inspectionService.AddInspectionRecordAsync(data); + //await _inspectionService.AddInspectionRecordAsync(data); } catch (Exception e) { diff --git a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs index ed16dcb5..4189d9db 100644 --- a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs +++ b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs @@ -137,7 +137,8 @@ namespace IRaCIS.Core.Application.Services return ResponseOutput.NotOk("This visit is OutPlanPreviousVisitId and couldn't be deleted."); } - await _subjectVisitRepository.SoftDeleteFromQueryAsync(s => s.Id == id); + await _subjectVisitRepository.DeleteFromQueryAsync(s => s.Id == id,true); + return ResponseOutput.Ok(); } diff --git a/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs b/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs index c0739a5e..27f1c173 100644 --- a/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs +++ b/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs @@ -277,7 +277,7 @@ namespace IRaCIS.Application.Services SubjectId = y.Id, Id = guid, VisitName = x.VisitName, - + TrialId= trialId, BlindName = x.BlindName, IsBaseLine = x.IsBaseLine, IsUrgent = false, @@ -292,7 +292,7 @@ namespace IRaCIS.Application.Services await _repository.AddRangeAsync(subjectVisits); //访视计划 整体状态变更为 确认 - await _visitStageRepository.BatchUpdateNoTrackingAsync(u => u.TrialId == trialId, t => new VisitStage() { IsConfirmed = true, IsHaveFirstConfirmed = true }); + await _visitStageRepository.UpdatePartialFromQueryAsync(u => u.TrialId == trialId&&u.IsConfirmed==false, t => new VisitStage() { IsConfirmed = true, IsHaveFirstConfirmed = true }); await _visitStageRepository.SaveChangesAsync(); return ResponseOutput.Ok(); diff --git a/IRaCIS.Core.Application/Triggers/SubjectVisitTrigger.cs b/IRaCIS.Core.Application/Triggers/SubjectVisitTrigger.cs index a9c1b57d..89365b0f 100644 --- a/IRaCIS.Core.Application/Triggers/SubjectVisitTrigger.cs +++ b/IRaCIS.Core.Application/Triggers/SubjectVisitTrigger.cs @@ -89,7 +89,7 @@ namespace IRaCIS.Core.Application.Triggers //// 这里是触发器的位置 //await _subjectVisitRepository.AddListInspectionRecordAsync(datas); - await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == subjectVisitId && t.SubmitState == SubmitStateEnum.ToSubmit, + await _subjectVisitRepository.UpdatePartialFromQueryAsync(t => t.Id == subjectVisitId && t.SubmitState == SubmitStateEnum.ToSubmit, u => new SubjectVisit() { VisitExecuted = 0, SVENDTC = null, SVSTDTC = null, SubmitState = SubmitStateEnum.None }); } } diff --git a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs index 1723c8de..4381e573 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs @@ -47,15 +47,24 @@ namespace IRaCIS.Core.Infra.EFCore.Common /// 传入实体对象 /// public async Task IncomingEntitys(List entitys) - { + { // 新增 await InsertAddEntitys(entitys.Where(x => x.State == EntityState.Added).ToList(), "Add"); // 修改 - await InsertAddEntitys(entitys.Where(x => x.State == EntityState.Modified).ToList(), "Update"); + await InsertAddEntitys(entitys.Where(x => x.State == EntityState.Modified&&(!typeof(ISoftDelete).IsAssignableFrom(x.Entity.GetType()) + || !(bool)x.Entity.GetType().GetProperty("IsDeleted").GetValue(x.Entity)) + ).ToList(), "Update"); // 删除 - await InsertAddEntitys(entitys.Where(x => x.State == EntityState.Deleted).ToList(), "Deleted"); + await InsertAddEntitys(entitys.Where(x => x.State == EntityState.Deleted + ||((typeof(ISoftDelete).IsAssignableFrom(x.Entity.GetType())&& (bool)x.Entity.GetType().GetProperty("IsDeleted").GetValue(x.Entity))) + ).ToList(), "Deleted"); + + + + //var value = data.GetType().GetProperty(item).GetValue(data); + //entitys.Where(x=>x.Entity.is) } /// @@ -84,6 +93,15 @@ namespace IRaCIS.Core.Infra.EFCore.Common }); } + // 访视计划 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(VisitStage))) + { + await InsertInspection(item, type, x => new DataInspection() + { + VisitStageId = x.Id, + }); + } + // TrialDocument foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialDocument))) { @@ -117,15 +135,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common }); } - // 访视计划 - foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(VisitStage))) - { - await InsertInspection(item, type, x => new DataInspection() - { - VisitStageId = x.Id, - }); - } - // 既往手术史 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(PreviousSurgery))) @@ -161,9 +170,12 @@ namespace IRaCIS.Core.Infra.EFCore.Common await InsertInspection(item, type, x => new DataInspection() { GeneralId = x.Id, + + }); } + // 序列 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(DicomSeries))) { @@ -172,12 +184,34 @@ namespace IRaCIS.Core.Infra.EFCore.Common await InsertInspection(item, type, x => new DataInspection() { GeneralId = x.Id, - },new { + }, new + { StudyCode = entity.DicomStudy.StudyCode, Modalities = entity.DicomStudy.Modalities, + }); } + // 非Dicom + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(NoneDicomStudy))) + { + await InsertInspection(item, type, x => new DataInspection() + { + GeneralId = x.Id, + }); + } + + // 非Dicom文件 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(NoneDicomStudyFile))) + { + await InsertInspection(item, type, x => new DataInspection() + { + GeneralId = x.Id, + }); + } + + + //质疑 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(QCChallenge))) { diff --git a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs index 205a2f3e..30fce872 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs @@ -594,7 +594,6 @@ namespace IRaCIS.Core.Infra.EFCore item.Json = await SetEnum(dto.TrialId, item.Identification, item.Json); item.Json = await SetDataInspectionDateType(item.Identification, item.Json); } - return dto.Items.Select(x => x.Json).ToList(); } @@ -610,7 +609,7 @@ namespace IRaCIS.Core.Infra.EFCore public async Task SetDataInspectionDateType(string identification, string json) { var list = await (from parent in _dbContext.FrontAuditConfig.AsQueryable().Where(x => x.Identification == identification) - join child in _dbContext.FrontAuditConfig.AsQueryable().Where(x => x.EnumType == "Date") on parent.Id equals child.ParentId + join child in _dbContext.FrontAuditConfig.AsQueryable().Where(x => x.EnumType == "Date" && x.IsEnable.HasValue && x.IsEnable.Value) on parent.Id equals child.ParentId select new DateDto() { Code = child.Code, @@ -665,7 +664,7 @@ namespace IRaCIS.Core.Infra.EFCore public async Task GetInspectionEnumValue(string identification, string json) { var list = await (from u in _dbContext.FrontAuditConfig.Where(x => x.Identification == identification) - join p in _dbContext.FrontAuditConfig.Where(x => x.EnumType == "Foreign") on u.Id equals p.ParentId + join p in _dbContext.FrontAuditConfig.Where(x => x.EnumType == "Foreign" && x.IsEnable.HasValue && x.IsEnable.Value) on u.Id equals p.ParentId select new { Key = p.Code, @@ -721,7 +720,7 @@ namespace IRaCIS.Core.Infra.EFCore public async Task SetEnum(Guid trilaid, string identification, string json) { var list = await (from u in _dbContext.FrontAuditConfig.Where(x => x.Identification == identification) - join p in _dbContext.FrontAuditConfig.Where(x => x.Code != "AuditState" && x.EnumType == "Dictionary") on u.Id equals p.ParentId + join p in _dbContext.FrontAuditConfig.Where(x => x.Code != "AuditState" && x.EnumType == "Dictionary"&&x.IsEnable.HasValue&& x.IsEnable.Value) on u.Id equals p.ParentId select new { Key = p.Code,