修改中心调研

Uat_Study
hang 2023-07-20 09:25:09 +08:00
parent a61b20ace6
commit 42eae556e8
1 changed files with 18 additions and 55 deletions

View File

@ -559,40 +559,14 @@ namespace IRaCIS.Core.Application.Contracts
var messageToSend = new MimeMessage();
if (await _repository.AnyAsync<TrialSiteSurvey>(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<TrialSiteSurvey>(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)