From 3009fb422fdb6af8bb4947074a8711f45566775b Mon Sep 17 00:00:00 2001 From: he <10978375@qq.com> Date: Wed, 18 May 2022 08:58:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Common/MailService.cs | 2 +- .../Service/QC/TrialQCQuestionService.cs | 4 +- .../SiteSurvey/TrialSiteSurveyService.cs | 28 ++++-- .../TrialSiteUser/TrialConfigService.cs | 2 +- .../Common/AuditingData.cs | 98 +++++++++++++++---- 5 files changed, 102 insertions(+), 32 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Common/MailService.cs b/IRaCIS.Core.Application/Service/Common/MailService.cs index f06aa2775..c982d8b33 100644 --- a/IRaCIS.Core.Application/Service/Common/MailService.cs +++ b/IRaCIS.Core.Application/Service/Common/MailService.cs @@ -140,7 +140,7 @@ namespace IRaCIS.Application.Services //中心调研 登陆 public async Task AnolymousSendEmail(string researchProgramNo,string emailAddress, int verificationCode) - { + { var messageToSend = new MimeMessage(); diff --git a/IRaCIS.Core.Application/Service/QC/TrialQCQuestionService.cs b/IRaCIS.Core.Application/Service/QC/TrialQCQuestionService.cs index d66860fef..c817e0e8e 100644 --- a/IRaCIS.Core.Application/Service/QC/TrialQCQuestionService.cs +++ b/IRaCIS.Core.Application/Service/QC/TrialQCQuestionService.cs @@ -157,8 +157,8 @@ namespace IRaCIS.Core.Application.Contracts return ResponseOutput.NotOk("已有QC审核记录,不允许删除问题项"); } - var success = await _trialQcQuestionRepository.BatchDeleteNoTrackingAsync(t => t.Id == trialQCQuestionConfigureId); - return ResponseOutput.Result(success); + var success = await _trialQcQuestionRepository.DeleteFromQueryAsync(t => t.Id == trialQCQuestionConfigureId,true); + return ResponseOutput.Result(true); } diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs index 7d9347d47..65e384976 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs @@ -355,9 +355,23 @@ namespace IRaCIS.Core.Application.Contracts return ResponseOutput.NotOk("已锁定,不允许操作"); } } - var entity = await _trialSiteSurveyRepository.InsertOrUpdateAsync(addOrEditTrialSiteSurvey, true); - return ResponseOutput.Ok(entity.Id.ToString()); + + if (addOrEditTrialSiteSurvey.Id == null) + { + var entity = _mapper.Map(addOrEditTrialSiteSurvey); + await _trialSiteSurveyRepository.AddAsync(entity, true); + return ResponseOutput.Ok(entity.Id.ToString()); + } + else + { + + var entity = await _trialSiteSurveyRepository.Where(t => t.Id == addOrEditTrialSiteSurvey.Id, true).Include(x=>x.ReviewerUser).Include(x=>x.PreliminaryUser).FirstOrDefaultAsync(); + _mapper.Map(addOrEditTrialSiteSurvey, entity); + await _trialSiteSurveyRepository.SaveChangesAsync(); + + } + return ResponseOutput.Ok(true); } @@ -801,12 +815,12 @@ namespace IRaCIS.Core.Application.Contracts if (hasSPMOrCPM) { - await _trialSiteSurveyRepository.BatchUpdateNoTrackingAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.ToSubmit, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.CRCSubmitted }); + await _trialSiteSurveyRepository.UpdatePartialFromQueryAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.ToSubmit, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.CRCSubmitted }); } else { - await _trialSiteSurveyRepository.BatchUpdateNoTrackingAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.ToSubmit, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.SPMApproved }); + await _trialSiteSurveyRepository.UpdatePartialFromQueryAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.ToSubmit, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.SPMApproved }); } @@ -814,7 +828,7 @@ namespace IRaCIS.Core.Application.Contracts else if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM) { - await _trialSiteSurveyRepository.BatchUpdateNoTrackingAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.CRCSubmitted, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.SPMApproved, PreliminaryUserId = _userInfo.Id, PreliminaryTime = DateTime.Now }); + await _trialSiteSurveyRepository.UpdatePartialFromQueryAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.CRCSubmitted, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.SPMApproved, PreliminaryUserId = _userInfo.Id, PreliminaryTime = DateTime.Now }); } else if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.APM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) @@ -831,10 +845,10 @@ namespace IRaCIS.Core.Application.Contracts await SendInviteEmail(new InviteEmailCommand() { TrialId = trialId, RouteUrl = siteSurvyeSubmit.RouteUrl, UserList = needGenerateList }); - await _trialSiteSurveyRepository.BatchUpdateNoTrackingAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.SPMApproved, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.PMCreatedAndLock, ReviewerUserId = _userInfo.Id, ReviewerTime = DateTime.Now }); + await _trialSiteSurveyRepository.UpdatePartialFromQueryAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.SPMApproved, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.PMCreatedAndLock, ReviewerUserId = _userInfo.Id, ReviewerTime = DateTime.Now }); } - + await _trialSiteSurveyRepository.SaveChangesAsync(); return ResponseOutput.Ok(); } diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs index 6be9648d6..a98a41fc9 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs @@ -161,7 +161,7 @@ namespace IRaCIS.Core.Application throw new BusinessValidationFailedException("QC审核问题已被其他QC确认,不允许再次确认"); } - await _trialRepository.UpdatePartialFromQueryAsync(t => t.Id == signConfirmDTO.TrialId, u => new Trial() { QCQuestionConfirmedTime = DateTime.Now, QCQuestionConfirmedUserId = _userInfo.Id, IsQCQuestionConfirmed = true }); + await _trialRepository.UpdatePartialFromQueryAsync(t => t.Id == signConfirmDTO.TrialId, u => new Trial() { QCQuestionConfirmedTime = DateTime.Now, QCQuestionConfirmedUserId = _userInfo.Id, IsQCQuestionConfirmed = true },true); } diff --git a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs index 3125567d3..8351f3949 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs @@ -80,6 +80,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common return new List() { typeof(TrialUser), + typeof(TrialSiteSurvey), typeof(TrialSiteUser), typeof(TrialSite) }; @@ -173,7 +174,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common }); } - // TrialDocument + // 项目文档 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialDocument))) { await InsertInspection(item, type); @@ -202,6 +203,28 @@ namespace IRaCIS.Core.Infra.EFCore.Common }); } + // 项目人员 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialUser))) + { + + var entity = item.Entity as TrialUser; + var user = await _dbContext.Users.Include(x => x.UserTypeRole).FirstOrDefaultAsync(x => x.Id == entity.UserId); + await InsertInspection(item, type, x => new DataInspection + { + TrialId = x.TrialId, + }, new + { + UserRealName = user.FullName, + UserName = user.UserName, + UserType = user.UserTypeRole.UserTypeShortName, + EMail = user.EMail, + Phone = user.Phone, + OrganizationName = user.OrganizationName, + State = entity.IsDeleted ? "退出" : "加入", + }); + } + + // 项目中心人员 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialSiteUser))) { @@ -229,7 +252,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common await InsertInspection(item, type, x => new DataInspection() { GeneralId = x.Id, - }, new { TrialSiteCode = entity.TrialSite.TrialSiteCode, @@ -248,29 +270,65 @@ namespace IRaCIS.Core.Infra.EFCore.Common }); } - // 项目人员 - foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialUser))) + + + // 中心调研表 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialSiteSurvey))) { - - var entity = item.Entity as TrialUser; - var user =await _dbContext.Users.Include(x=>x.UserTypeRole).FirstOrDefaultAsync(x => x.Id == entity.UserId); - await InsertInspection(item, type, x => new DataInspection - { - TrialId=x.TrialId, + var entity = item.Entity as TrialSiteSurvey; + if (entity.TrialSite == null) + { + entity.TrialSite = await _dbContext.TrialSite.Where(x => x.SiteId == entity.SiteId&&x.TrialId== entity.TrialId).FirstOrDefaultAsync(); + } + + if (entity.PreliminaryUser == null) + { + entity.PreliminaryUser = await _dbContext.User.Where(x => x.Id == entity.PreliminaryUserId).FirstOrDefaultAsync(); + } + + if (entity.ReviewerUser == null) + { + entity.ReviewerUser = await _dbContext.User.Where(x => x.Id == entity.ReviewerUserId).FirstOrDefaultAsync(); + } + + await InsertInspection(item, type, x => new DataInspection() + { + GeneralId = x.Id, + + },new { - UserRealName= user.FullName, - UserName= user.UserName, - UserType= user.UserTypeRole.UserTypeShortName, - EMail= user.EMail, - Phone= user.Phone, - OrganizationName= user.OrganizationName, - State=entity.IsDeleted?"退出":"加入", + TrialSiteCode = entity.TrialSite.TrialSiteCode, + TrialSiteAliasName = entity.TrialSite.TrialSiteAliasName, + Phone= entity.Phone, + Email=entity.Email, + PreliminaryUser= entity.PreliminaryUser==null?"": entity.PreliminaryUser.LastName + " / " + entity.PreliminaryUser.FirstName, + ReviewerUser = entity.ReviewerUser == null ? "" : entity.ReviewerUser.LastName + " / " + entity.ReviewerUser.FirstName, + IsDeleted=entity.IsDeleted ? "是" : "否", }); } + // 项目问题 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialQCQuestion))) + { - - + var entity = item.Entity as TrialQCQuestion; + var isQCQuestionConfirmed = await _dbContext.Trial.Where(x => x.Id == entity.TrialId).Select(x => x.IsQCQuestionConfirmed).FirstOrDefaultAsync(); + var paretName = await _dbContext.TrialQCQuestionConfigure.Where(x => x.Id == entity.ParentId).Select(x => x.QuestionName).FirstOrDefaultAsync(); + await InsertInspection(item, type, x => new DataInspection() + { + GeneralId = x.Id, + },new { + QuestionName= entity.QuestionName, + Type= entity.Type, + TypeValue=entity.TypeValue, + ShowOrder=entity.ShowOrder, + IsRequired= entity.IsRequired, + ParentName= paretName, + ParentTriggerValue=entity.ParentTriggerValue, + IsEnable=entity.IsEnable, + IsQCQuestionConfirmed= isQCQuestionConfirmed, + }); + } // 受试者 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(Subject))) @@ -342,8 +400,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common } // 非Dicom文件 - //var noneDicomFile= - if (entitys.Any(x => x.Entity.GetType() == typeof(NoneDicomStudyFile))) { var noneDicomStudyfile = entitys.Where(x => x.Entity.GetType() == typeof(NoneDicomStudyFile)).Select(x => x.Entity).FirstOrDefault() as NoneDicomStudyFile;