修改退出改为加入

Uat_Study
hang 2023-08-18 14:44:36 +08:00
parent 8c5cca7ba5
commit b6403580de
1 changed files with 23 additions and 25 deletions

View File

@ -286,7 +286,7 @@ namespace IRaCIS.Core.Application.Contracts
{
//找到最新的调研表
var currentLatest = await _trialSiteSurveyRepository.Where(t => t.TrialId == userInfo.TrialId && t.SiteId == userInfo.SiteId,true)
var currentLatest = await _trialSiteSurveyRepository.Where(t => t.TrialId == userInfo.TrialId && t.SiteId == userInfo.SiteId, true)
.Include(u => u.TrialSiteEquipmentSurveyList).Include(u => u.TrialSiteUserSurveyList).OrderByDescending(t => t.CreateTime).FirstOrDefaultAsync();
if (currentLatest == null)
@ -333,7 +333,7 @@ namespace IRaCIS.Core.Application.Contracts
copy.TrialSiteEquipmentSurveyList.ForEach(t => { t.Id = Guid.Empty; t.CreateTime = DateTime.Now; });
//锁定了的话,就不拷贝
if(currentLatest.State!= TrialSiteSurveyEnum.PMCreatedAndLock)
if (currentLatest.State != TrialSiteSurveyEnum.PMCreatedAndLock)
{
copy.TrialSiteUserSurveyList = currentLatest.TrialSiteUserSurveyList.Clone().Where(t => t.IsHistoryUser == false).ToList();
copy.TrialSiteUserSurveyList.ForEach(t => { t.Id = Guid.Empty; t.IsGenerateSuccess = false; t.CreateTime = DateTime.Now; });
@ -408,7 +408,7 @@ namespace IRaCIS.Core.Application.Contracts
{
//有可能填表人提交了但是此时PM手动对人员信息进行了更改此时需要将数据同步下选择在这里同步是因为 不想改动 中心人员哪里的两个接口的逻辑)
var find = await _trialSiteSurveyRepository.FirstOrDefaultAsync(t => t.Id == trialSiteSurveyId,true);
var find = await _trialSiteSurveyRepository.FirstOrDefaultAsync(t => t.Id == trialSiteSurveyId, true);
if (find.State != TrialSiteSurveyEnum.PMCreatedAndLock && find.IsDeleted != true)
@ -697,16 +697,16 @@ namespace IRaCIS.Core.Application.Contracts
var trialId = siteSurvyeSubmit.TrialId;
var trialSiteSurveyId = siteSurvyeSubmit.TrialSiteSurveyId;
var trialSiteSurvey = (await _trialSiteSurveyRepository.Where(t => t.Id == trialSiteSurveyId,false,true).FirstOrDefaultAsync()).IfNullThrowException();
var trialSiteSurvey = (await _trialSiteSurveyRepository.Where(t => t.Id == trialSiteSurveyId, false, true).FirstOrDefaultAsync()).IfNullThrowException();
if (trialSiteSurvey.IsDeleted == true || trialSiteSurvey.State==TrialSiteSurveyEnum.PMCreatedAndLock)
if (trialSiteSurvey.IsDeleted == true || trialSiteSurvey.State == TrialSiteSurveyEnum.PMCreatedAndLock)
{
throw new BusinessValidationFailedException("当前调研表已废除,或者调研表状态已锁定,不允许操作");
}
var siteUserList = await _trialSiteUserSurveyRepository.Where(t => t.TrialSiteSurveyId == trialSiteSurveyId)
.Where(t=>!(t.IsHistoryUser && t.IsHistoryUserDeleted==true))
.Where(t => !(t.IsHistoryUser && t.IsHistoryUserDeleted == true))
.Select(t =>
new
{
@ -717,7 +717,7 @@ namespace IRaCIS.Core.Application.Contracts
UserTypeEnum = (UserTypeEnum?)t.UserTypeRole.UserTypeEnum,
t.TrialRoleCode,
t.Email,
}). ToListAsync();
}).ToListAsync();
if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.Undefined)
@ -849,14 +849,14 @@ namespace IRaCIS.Core.Application.Contracts
//判断TrialUser中是否存在 不存在就插入
var findTrialUser = await _trialUserRepository.FirstOrDefaultAsync(t => t.TrialId == trialId && t.UserId == userId, true);
if (findTrialUser==null)
if (findTrialUser == null)
{
await _repository.AddAsync(new TrialUser() { TrialId = trialId, UserId = userId, JoinTime = DateTime.Now });
await _mailVerificationService.SiteSurveyUserJoinEmail(trialId, userId, joinCommand.BaseUrl, joinCommand.RouteUrl);
}
else if(findTrialUser.IsDeleted==true)
else if (findTrialUser.IsDeleted == true)
{
await _trialUserRepository.UpdatePartialFromQueryAsync(t => t.TrialId == trialId && t.UserId == userId, c => new TrialUser()
{
@ -868,18 +868,17 @@ namespace IRaCIS.Core.Application.Contracts
await _mailVerificationService.SiteSurveyUserJoinEmail(trialId, userId, joinCommand.BaseUrl, joinCommand.RouteUrl);
}
if (!await _repository.AnyAsync<TrialSiteUser>(t => t.TrialId == trialId && t.UserId == userId && t.SiteId == siteId, true))
var findTrialSiteUser = await _trialSiteUserRepository.FirstOrDefaultAsync(t => t.TrialId == trialId && t.UserId == userId && t.SiteId == siteId, true);
if (findTrialSiteUser == null)
{
await _repository.AddAsync(new TrialSiteUser() { TrialId = trialId, SiteId = siteId, UserId = userId });
}
else
{
await _trialSiteUserRepository.UpdatePartialFromQueryAsync(t => t.TrialId == trialId && t.UserId == userId && t.SiteId == siteId, c => new TrialSiteUser()
{
IsDeleted = false,
DeletedTime = null,
});
findTrialSiteUser.IsDeleted = false;
findTrialSiteUser.DeletedTime = null;
}
await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == userId, u => new User() { Status = UserStateEnum.Enable });
@ -1017,18 +1016,17 @@ namespace IRaCIS.Core.Application.Contracts
}
if (!await _repository.AnyAsync<TrialSiteUser>(t => t.TrialId == trialId && t.UserId == userId && t.SiteId == siteId, true))
var findTrialSiteUser = await _trialSiteUserRepository.FirstOrDefaultAsync(t => t.TrialId == trialId && t.UserId == userId && t.SiteId == siteId, true);
if (findTrialSiteUser == null)
{
await _repository.AddAsync(new TrialSiteUser() { TrialId = trialId, SiteId = siteId, UserId = userId });
}
else
{
await _trialSiteUserRepository.UpdatePartialFromQueryAsync(t => t.TrialId == trialId && t.UserId == userId && t.SiteId == siteId, c => new TrialSiteUser()
{
IsDeleted = false,
DeletedTime = null,
});
findTrialSiteUser.IsDeleted = false;
findTrialSiteUser.DeletedTime = null;
}
await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == userId, u => new User() { Status = UserStateEnum.Enable });