修改site关联

This commit is contained in:
2024-06-03 14:37:38 +08:00
parent 4db3860ade
commit 0e23719c7b
101 changed files with 354 additions and 3290 deletions
@@ -36,10 +36,11 @@ namespace IRaCIS.Core.Application.Contracts
public class TrialSiteForSelect
{
public Guid TrialSiteId => Id;
public Guid Id { get; set; }
public Guid TrialId { get; set; }
public Guid SiteId { get; set; }
public Guid? SiteId { get; set; }
public string TrialSiteCode { get; set; } = string.Empty;
@@ -78,7 +79,7 @@ namespace IRaCIS.Core.Application.Contracts
{
[NotDefault]
public Guid TrialId { get; set; }
public Guid? SiteId { get; set; }
public Guid? TrialSiteId { get; set; }
public Guid? UserTypeId { get; set; }
@@ -101,7 +102,7 @@ namespace IRaCIS.Core.Application.Contracts
{
[NotDefault]
public Guid TrialId { get; set; }
public Guid? SiteId { get; set; }
public Guid? TrialSiteId { get; set; }
public Guid? UserTypeId { get; set; }
@@ -133,7 +134,7 @@ namespace IRaCIS.Core.Application.Contracts
public bool IsDeleted { get; set; }
public Guid Id { get; set; }
public Guid TrialId { get; set; }
public Guid SiteId { get; set; }
public Guid TrialSiteId { get; set; }
public DateTime CreateTime { get; set; }
public Guid CreateUserId { get; set; }
public DateTime UpdateTime { get; set; }
@@ -187,7 +188,7 @@ namespace IRaCIS.Core.Application.Contracts
{
public Guid TrialId { get; set; }
public Guid SiteId { get; set; }
public Guid TrialSiteId { get; set; }
public Guid TrialSiteSurveyId { get; set; }
}
@@ -197,7 +198,7 @@ namespace IRaCIS.Core.Application.Contracts
{
public Guid TrialId { get; set; }
public Guid SiteId { get; set; }
public Guid TrialSiteId { get; set; }
/////<summary> UserName</summary>
//public string UserName { get; set; }
@@ -251,7 +252,7 @@ namespace IRaCIS.Core.Application.Contracts
{
public Guid TrialId { get; set; }
public Guid SiteId { get; set; }
public Guid TrialSiteId { get; set; }
public bool IsUpdate { get; set; }
@@ -271,7 +272,7 @@ namespace IRaCIS.Core.Application.Contracts
{
public Guid? Id { get; set; }
public Guid TrialId { get; set; }
public Guid SiteId { get; set; }
public Guid TrialSiteId { get; set; }
public string UserName { get; set; } = string.Empty;
public string Phone { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
@@ -342,7 +343,7 @@ namespace IRaCIS.Core.Application.Contracts
[NotDefault]
public Guid TrialId { get; set; }
public Guid? SiteId { get; set; }
public Guid? TrialSiteId { get; set; }
public string UserKeyInfo { get; set; } = string.Empty;
@@ -150,7 +150,7 @@ namespace IRaCIS.Core.Application.Contracts
public string UserTypeStr { get; set; }
[JsonIgnore]
public Guid SiteId { get; set; }
public Guid TrialSiteId { get; set; }
[JsonIgnore]
public UserTypeEnum UserTypeEnum { get; set; } = UserTypeEnum.Undefined;
@@ -196,13 +196,13 @@ namespace IRaCIS.Core.Application.Contracts
TrialSiteSurvey? currentEntity = null;
var userList = await _trialSiteUserRepository.Where(t => t.TrialId == userInfo.TrialId && t.SiteId == userInfo.SiteId, false, true).ProjectTo<TrialSiteUserSurvey>(_mapper.ConfigurationProvider).ToListAsync();
var userList = await _trialSiteUserRepository.Where(t => t.TrialId == userInfo.TrialId && t.TrialSiteId == userInfo.TrialSiteId, false, true).ProjectTo<TrialSiteUserSurvey>(_mapper.ConfigurationProvider).ToListAsync();
//普通登录
if (userInfo.IsUpdate == false)
{
var dbEntityList = await _trialSiteSurveyRepository.Where(t => t.TrialId == userInfo.TrialId && t.SiteId == userInfo.SiteId).ToListAsync();
var dbEntityList = await _trialSiteSurveyRepository.Where(t => t.TrialId == userInfo.TrialId && t.TrialSiteId == userInfo.TrialSiteId).ToListAsync();
//没有记录 new一份
@@ -236,7 +236,7 @@ namespace IRaCIS.Core.Application.Contracts
{
await UnlockSyncSiteUserAsync(userInfo.TrialId, userInfo.SiteId, currentEntity.Id, userList);
await UnlockSyncSiteUserAsync(userInfo.TrialId, userInfo.TrialSiteId, currentEntity.Id, userList);
}
@@ -250,7 +250,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.TrialSiteId == userInfo.TrialSiteId, true)
.Include(u => u.TrialSiteEquipmentSurveyList).Include(u => u.TrialSiteUserSurveyList).OrderByDescending(t => t.CreateTime).FirstOrDefaultAsync();
if (currentLatest == null)
@@ -344,7 +344,7 @@ namespace IRaCIS.Core.Application.Contracts
private async Task UnlockSyncSiteUserAsync(Guid trialId, Guid siteId, Guid trialSiteSurveyId, List<TrialSiteUserSurvey> userList)
{
var existList = await _trialSiteUserSurveyRepository.Where(t => t.IsHistoryUser && t.TrialSiteSurvey.TrialId == trialId && t.TrialSiteSurvey.SiteId == siteId, true).ToListAsync();
var existList = await _trialSiteUserSurveyRepository.Where(t => t.IsHistoryUser && t.TrialSiteSurvey.TrialId == trialId && t.TrialSiteSurvey.TrialSiteId == siteId, true).ToListAsync();
foreach (var item in userList)
{
@@ -379,10 +379,10 @@ namespace IRaCIS.Core.Application.Contracts
if (find.State != TrialSiteSurveyEnum.PMCreatedAndLock && find.IsDeleted != true)
{
var userList = await _trialSiteUserRepository.Where(t => t.TrialId == find.TrialId && t.SiteId == find.SiteId, false, true).ProjectTo<TrialSiteUserSurvey>(_mapper.ConfigurationProvider).ToListAsync();
var userList = await _trialSiteUserRepository.Where(t => t.TrialId == find.TrialId && t.TrialSiteId == find.TrialSiteId, false, true).ProjectTo<TrialSiteUserSurvey>(_mapper.ConfigurationProvider).ToListAsync();
await UnlockSyncSiteUserAsync(find.TrialId, find.SiteId, find.Id, userList);
await UnlockSyncSiteUserAsync(find.TrialId, find.TrialSiteId, find.Id, userList);
}
@@ -460,7 +460,7 @@ namespace IRaCIS.Core.Application.Contracts
public async Task<PageOutput<TrialSiteSurveyView>> GetTrialSiteSurveyList(TrialSiteSurveyQueryDTO surveyQueryDTO)
{
var trialSiteSurveyQueryable = _trialSiteSurveyRepository.Where(t => t.TrialId == surveyQueryDTO.TrialId).IgnoreQueryFilters()
.WhereIf(surveyQueryDTO.SiteId != null, t => t.SiteId == surveyQueryDTO.SiteId)
.WhereIf(surveyQueryDTO.TrialSiteId != null, t => t.TrialSiteId == surveyQueryDTO.TrialSiteId)
.WhereIf(surveyQueryDTO.IsDeleted != null, t => t.IsDeleted == surveyQueryDTO.IsDeleted)
.WhereIf(!string.IsNullOrWhiteSpace(surveyQueryDTO.UserKeyInfo), t => t.UserName.Contains(surveyQueryDTO.UserKeyInfo) || t.Phone.Contains(surveyQueryDTO.UserKeyInfo) || t.Email.Contains(surveyQueryDTO.UserKeyInfo))
.WhereIf(surveyQueryDTO.State != null, t => t.State == surveyQueryDTO.State)
@@ -480,7 +480,7 @@ namespace IRaCIS.Core.Application.Contracts
{
var trialSiteSurveyQueryable = _trialSiteSurveyRepository
.Where(t => t.Id != inQuery.TrialSiteSurveyId)
.Where(t => t.TrialId == inQuery.TrialId && t.SiteId == inQuery.SiteId).IgnoreQueryFilters()
.Where(t => t.TrialId == inQuery.TrialId && t.TrialSiteId == inQuery.TrialSiteId).IgnoreQueryFilters()
.ProjectTo<TrialSiteSurveySelectView>(_mapper.ConfigurationProvider);
return await trialSiteSurveyQueryable.ToListAsync();
@@ -496,10 +496,10 @@ namespace IRaCIS.Core.Application.Contracts
var groupSelectIdQuery =
_trialSiteSurveyRepository.Where(t => t.TrialId == queryParam.TrialId)
.WhereIf(queryParam.SiteId != null, t => t.SiteId == queryParam.SiteId)
.WhereIf(queryParam.TrialSiteId != null, t => t.TrialSiteId == queryParam.TrialSiteId)
.WhereIf(!string.IsNullOrEmpty(queryParam.FormWriterKeyInfo), t => (t.UserName).Contains(queryParam.FormWriterKeyInfo) || t.Email.Contains(queryParam.FormWriterKeyInfo) || t.Phone.Contains(queryParam.FormWriterKeyInfo))
.GroupBy(t => t.SiteId)
.GroupBy(t => t.TrialSiteId)
.Select(g => g.OrderByDescending(u => u.CreateTime).Select(t => t.Id).First());
@@ -611,7 +611,7 @@ namespace IRaCIS.Core.Application.Contracts
var trialInfo = await _repository.FirstOrDefaultAsync<Trial>(t => t.Id == trialSiteSubmitBackCommand.TrialId);
var siteInfo = await _trialSiteRepository.FirstOrDefaultAsync(t => t.TrialId == trialSiteSubmitBackCommand.TrialId && t.SiteId == survey.SiteId, true);
var siteInfo = await _trialSiteRepository.FirstOrDefaultAsync(t => t.TrialId == trialSiteSubmitBackCommand.TrialId && t.Id == survey.TrialSiteId, true);
//主题
@@ -778,10 +778,10 @@ namespace IRaCIS.Core.Application.Contracts
var needQuitUserList = allUserList.Where(t => t.IsHistoryUser && t.IsHistoryUserOriginDeleted == false && t.IsHistoryUserDeleted == true).ToList();
await DealSiteUserQuitSiteAsync(trialId, trialSiteSurvey.SiteId, needQuitUserList);
await DealSiteUserQuitSiteAsync(trialId, trialSiteSurvey.TrialSiteId, needQuitUserList);
//将历史锁定的调研表废弃
await _trialSiteSurveyRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trialId && t.SiteId == trialSiteSurvey.SiteId && t.State == TrialSiteSurveyEnum.PMCreatedAndLock && t.Id != trialSiteSurveyId, z => new TrialSiteSurvey() { IsDeleted = true });
await _trialSiteSurveyRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trialId && t.TrialSiteId == trialSiteSurvey.TrialSiteId && t.State == TrialSiteSurveyEnum.PMCreatedAndLock && t.Id != trialSiteSurveyId, z => new TrialSiteSurvey() { IsDeleted = true });
}
await _trialSiteSurveyRepository.SaveChangesAsync();
@@ -867,7 +867,7 @@ namespace IRaCIS.Core.Application.Contracts
var trialId = joinCommand.TrialId;
var userId = (Guid)userInfo.SystemUserId;
var siteId = trialSiteSurvey.SiteId;
var trialSiteId = trialSiteSurvey.TrialSiteId;
@@ -893,11 +893,11 @@ namespace IRaCIS.Core.Application.Contracts
await _mailVerificationService.SiteSurveyUserJoinEmail(trialId, userId, joinCommand.BaseUrl, joinCommand.RouteUrl);
}
var findTrialSiteUser = await _trialSiteUserRepository.FirstOrDefaultAsync(t => t.TrialId == trialId && t.UserId == userId && t.SiteId == siteId, true);
var findTrialSiteUser = await _trialSiteUserRepository.FirstOrDefaultAsync(t => t.TrialId == trialId && t.UserId == userId && t.TrialSiteId == trialSiteId, true);
if (findTrialSiteUser == null)
{
await _repository.AddAsync(new TrialSiteUser() { TrialId = trialId, SiteId = siteId, UserId = userId });
await _repository.AddAsync(new TrialSiteUser() { TrialId = trialId, TrialSiteId = trialSiteId, UserId = userId });
}
else
@@ -928,7 +928,7 @@ namespace IRaCIS.Core.Application.Contracts
var userIdList = list.Select(t => t.SystemUserId).ToList();
await _trialSiteUserRepository.UpdatePartialFromQueryAsync(t => t.TrialId == trialId && t.SiteId == siteId && userIdList.Contains(t.UserId), c => new TrialSiteUser()
await _trialSiteUserRepository.UpdatePartialFromQueryAsync(t => t.TrialId == trialId && t.TrialSiteId == siteId && userIdList.Contains(t.UserId), c => new TrialSiteUser()
{
IsDeleted = true,
DeletedTime = DateTime.Now,
@@ -988,7 +988,7 @@ namespace IRaCIS.Core.Application.Contracts
}
var userId = sysUserInfo.Id;
var siteId = item.SiteId;
var trialSiteId = item.TrialSiteId;
//判断是否加入到项目
var findTrialUser = await _trialUserRepository.FirstOrDefaultAsync(t => t.TrialId == trialId && t.UserId == userId, true);
@@ -1012,11 +1012,11 @@ namespace IRaCIS.Core.Application.Contracts
}
var findTrialSiteUser = await _trialSiteUserRepository.FirstOrDefaultAsync(t => t.TrialId == trialId && t.UserId == userId && t.SiteId == siteId, true);
var findTrialSiteUser = await _trialSiteUserRepository.FirstOrDefaultAsync(t => t.TrialId == trialId && t.UserId == userId && t.TrialSiteId == trialSiteId, true);
if (findTrialSiteUser == null)
{
await _repository.AddAsync(new TrialSiteUser() { TrialId = trialId, SiteId = siteId, UserId = userId });
await _repository.AddAsync(new TrialSiteUser() { TrialId = trialId, TrialSiteId = trialSiteId, UserId = userId });
}
else