From 42eae556e826944a75afdba03de139ed87d92426 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 20 Jul 2023 09:25:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=AD=E5=BF=83=E8=B0=83?= =?UTF-8?q?=E7=A0=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SiteSurvey/TrialSiteSurveyService.cs | 73 +++++-------------- 1 file changed, 18 insertions(+), 55 deletions(-) diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs index 26d48ddf0..bc25e676f 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs @@ -559,40 +559,14 @@ namespace IRaCIS.Core.Application.Contracts var messageToSend = new MimeMessage(); - if (await _repository.AnyAsync(t => t.State == TrialSiteSurveyEnum.PMCreatedAndLock && t.Id == trialSiteSurveyId)) { //---中心调研已锁定,不允许操作。 return ResponseOutput.NotOk(_localizer["TrialSiteSurvey_Locked"]); } - - if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM) + if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager ) { - //SPM 给填表人发 - messageToSend.To.Add(new MailboxAddress(String.Empty, survey.Email)); - - survey.State = TrialSiteSurveyEnum.ToSubmit; - } - else if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.APM) - { - var hasSPMOrCPM = await _trialSiteSurveyRepository.AnyAsync(t => t.TrialId == trialSiteSubmitBackCommand.TrialId && t.Trial.TrialUserList.Any(u => u.User.UserTypeEnum == UserTypeEnum.SPM || u.User.UserTypeEnum == UserTypeEnum.CPM)); - - if (hasSPMOrCPM) - { - - //PM 给SPM发 (初审人) - user = await _userRepository.FirstOrDefaultAsync(t => t.Id == survey.PreliminaryUserId); - - messageToSend.To.Add(new MailboxAddress(String.Empty, survey.PreliminaryUserId == null ? survey.Email : user.EMail)); - - survey.State = TrialSiteSurveyEnum.CRCSubmitted; - - survey.ReviewerUserId = null; - survey.ReviewerTime = null; - } - else - { //没有SPM 给填表人发 messageToSend.To.Add(new MailboxAddress(String.Empty, survey.Email)); @@ -604,7 +578,6 @@ namespace IRaCIS.Core.Application.Contracts survey.ReviewerTime = null; - } } @@ -649,9 +622,6 @@ namespace IRaCIS.Core.Application.Contracts await _IMailVerificationService.SiteSurveyRejectEmail(messageToSend); - - - await _trialSiteSurveyRepository.SaveChangesAsync(); return ResponseOutput.Ok(); @@ -674,24 +644,9 @@ namespace IRaCIS.Core.Application.Contracts return ResponseOutput.NotOk(_localizer["TrialSiteSurvey_Locked"]); } - if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM) - { - await _repository.BatchUpdateAsync(t => t.Id == trialSiteSurveyId, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.ToSubmit }); - } - else if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.APM) - { - var hasSPMOrCPM = await _trialSiteSurveyRepository.AnyAsync(t => t.TrialId == trialId && t.Trial.TrialUserList.Any(u => u.User.UserTypeEnum == UserTypeEnum.SPM || u.User.UserTypeEnum == UserTypeEnum.CPM)); - if (hasSPMOrCPM) - { - await _trialSiteSurveyRepository.BatchUpdateNoTrackingAsync(t => t.Id == trialSiteSurveyId, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.CRCSubmitted }); + await _trialSiteSurveyRepository.BatchUpdateNoTrackingAsync(t => t.Id == trialSiteSurveyId, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.ToSubmit }); - } - else - { - await _trialSiteSurveyRepository.BatchUpdateNoTrackingAsync(t => t.Id == trialSiteSurveyId, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.ToSubmit }); - } - } return ResponseOutput.Ok(); } @@ -736,21 +691,29 @@ namespace IRaCIS.Core.Application.Contracts var trialSiteSurvey = (await _trialSiteSurveyRepository.Where(t => t.Id == trialSiteSurveyId).FirstOrDefaultAsync()).IfNullThrowException(); - var siteUserList = await _trialSiteUserSurveyRepository.Where(t => t.TrialSiteSurvey.TrialId==trialId && t.TrialSiteSurvey.SiteId == trialSiteSurvey.SiteId && t.TrialSiteSurvey.IsDeleted==false).Select(t => - new { t.TrialSiteSurveyId, t.IsGenerateAccount, t.IsGenerateSuccess, t.UserTypeId, - UserTypeEnum= (UserTypeEnum?) t.UserTypeRole.UserTypeEnum , t.TrialRoleName.Code,t.Email }).ToListAsync(); + var siteUserList = await _trialSiteUserSurveyRepository.Where(t => t.TrialSiteSurvey.TrialId == trialId && t.TrialSiteSurvey.SiteId == trialSiteSurvey.SiteId && t.TrialSiteSurvey.IsDeleted == false).Select(t => + new + { + t.TrialSiteSurveyId, + t.IsGenerateAccount, + t.IsGenerateSuccess, + t.UserTypeId, + UserTypeEnum = (UserTypeEnum?)t.UserTypeRole.UserTypeEnum, + t.TrialRoleName.Code, + t.Email + }).ToListAsync(); - - if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.Undefined) + + if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.Undefined) { //是第一次 - if(!siteUserList.Any(t=>t.IsGenerateSuccess)) + if (!siteUserList.Any(t => t.IsGenerateSuccess)) { var currentUserList = siteUserList.Where(t => t.TrialSiteSurveyId == trialSiteSurveyId).ToList(); - if(!currentUserList.Any(t=>t.Code=="1") || !currentUserList.Any(t => t.Code == "5")) + if (!currentUserList.Any(t => t.Code == "1") || !currentUserList.Any(t => t.Code == "5")) { throw new BusinessValidationFailedException("本次提交,必须有CRC和影像阅片人信息"); } @@ -762,7 +725,7 @@ namespace IRaCIS.Core.Application.Contracts else if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) { - foreach (var group in (siteUserList.Where(t=>t.IsGenerateAccount && t.TrialSiteSurveyId==trialSiteSurveyId) + foreach (var group in (siteUserList.Where(t => t.IsGenerateAccount && t.TrialSiteSurveyId == trialSiteSurveyId) .GroupBy(t => new { t.Email, t.IsGenerateAccount, t.UserTypeId }))) { if (group.Count() > 1)