diff --git a/IRaCIS.Core.Application/Service/Management/_MapConfig.cs b/IRaCIS.Core.Application/Service/Management/_MapConfig.cs index d40cb6668..85c175636 100644 --- a/IRaCIS.Core.Application/Service/Management/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Management/_MapConfig.cs @@ -163,6 +163,7 @@ namespace IRaCIS.Core.Application.Service CreateMap() .ForMember(d => d.UserTypeShortName, c => c.MapFrom(t => t.UserTypeRole.UserTypeShortName)); + CreateMap(); } } diff --git a/IRaCIS.Core.Application/Service/WorkLoad/DoctorWorkloadService.cs b/IRaCIS.Core.Application/Service/WorkLoad/DoctorWorkloadService.cs index 0c5117cec..57e23df69 100644 --- a/IRaCIS.Core.Application/Service/WorkLoad/DoctorWorkloadService.cs +++ b/IRaCIS.Core.Application/Service/WorkLoad/DoctorWorkloadService.cs @@ -206,7 +206,7 @@ namespace IRaCIS.Core.Application.Service var doctorIntoGroupQueryable = from intoGroup in _enrollRepository.Where(x => x.TrialId == trialId && x.EnrollStatus >= EnrollStatus.ConfirmIntoGroup) - join allocateRule in _taskAllocationRuleRepository.AsQueryable() on intoGroup.Id equals allocateRule.EnrollId + join allocateRule in _taskAllocationRuleRepository.Where(x => x.TrialId == trialId) on intoGroup.Id equals allocateRule.EnrollId join doctor in _doctorRepository.AsQueryable() on intoGroup.DoctorId equals doctor.Id join attachmentItem in _attachmentRepository.AsQueryable() on intoGroup.AttachmentId equals attachmentItem.Id into cc from attachment in cc.DefaultIfEmpty() diff --git a/IRaCIS.Core.Application/TestService.cs b/IRaCIS.Core.Application/TestService.cs index 9f600f640..558eae689 100644 --- a/IRaCIS.Core.Application/TestService.cs +++ b/IRaCIS.Core.Application/TestService.cs @@ -161,24 +161,29 @@ namespace IRaCIS.Core.Application.Service { _userInfo.IsNotNeedInspection = true; - var userList = _userRoleRepository.Where().ToList(); - - foreach (var item in userList.GroupBy(t => t.EMail.Trim())) + if ((await _identityUserRepository.FirstOrDefaultAsync()) == null) { - var emailUserIdList = item.Select(t => t.Id).ToList(); + var userList = _userRoleRepository.Where().ToList(); - var identityUserId = NewId.NextSequentialGuid(); + foreach (var item in userList.GroupBy(t => t.EMail.Trim())) + { + var emailUserIdList = item.Select(t => t.Id).ToList(); - var identityUser = _mapper.Map(item.FirstOrDefault()); + var identityUserId = NewId.NextSequentialGuid(); - identityUser.Id = identityUserId; + var identityUser = _mapper.Map(item.FirstOrDefault()); - await _identityUserRepository.AddAsync(identityUser); + identityUser.Id = identityUserId; - await _userRoleRepository.BatchUpdateNoTrackingAsync(t => emailUserIdList.Contains(t.Id), u => new UserRole() { IdentityUserId = identityUserId }); + await _identityUserRepository.AddAsync(identityUser); + + await _userRoleRepository.BatchUpdateNoTrackingAsync(t => emailUserIdList.Contains(t.Id), u => new UserRole() { IdentityUserId = identityUserId }); + } + + await _identityUserRepository.SaveChangesAsync(); } - await _identityUserRepository.SaveChangesAsync(); + return ResponseOutput.Ok(); } @@ -192,37 +197,43 @@ namespace IRaCIS.Core.Application.Service { _userInfo.IsNotNeedInspection = true; - var list = _trialUserRoleReposiotry.Where().Select(t => new { t.TrialId, t.UserRole.IdentityUserId, t.UserId, t.JoinTime, t.RemoveTime }).ToList(); - - foreach (var item in list.GroupBy(t => new { t.IdentityUserId, t.TrialId })) + if ((await _trialIdentityUserRepository.FirstOrDefaultAsync()) == null) { + var list = _trialUserRoleReposiotry.Where().Select(t => new { t.TrialId, t.UserRole.IdentityUserId, t.UserId, t.JoinTime, t.RemoveTime }).ToList(); - var id = NewId.NextSequentialGuid(); - var userRoleList = item.ToList(); - - var userIdList = item.Select(t => t.UserId).ToList(); - - var first = userRoleList.First(); - - var haveJoin = userRoleList.Any(t => t.JoinTime != null); - - if (haveJoin) + foreach (var item in list.GroupBy(t => new { t.IdentityUserId, t.TrialId })) { - await _trialIdentityUserRepository.AddAsync(new TrialIdentityUser() { Id = id, IdentityUserId = item.Key.IdentityUserId, TrialId = item.Key.TrialId, JoinTime = userRoleList.Min(t => t.JoinTime) }); + + var id = NewId.NextSequentialGuid(); + + var userRoleList = item.ToList(); + + var userIdList = item.Select(t => t.UserId).ToList(); + + var first = userRoleList.First(); + + var haveJoin = userRoleList.Any(t => t.JoinTime != null); + + if (haveJoin) + { + await _trialIdentityUserRepository.AddAsync(new TrialIdentityUser() { Id = id, IdentityUserId = item.Key.IdentityUserId, TrialId = item.Key.TrialId, JoinTime = userRoleList.Min(t => t.JoinTime) }); + + } + else + { + await _trialIdentityUserRepository.AddAsync(new TrialIdentityUser() { Id = id, IdentityUserId = item.Key.IdentityUserId, TrialId = item.Key.TrialId, RemoveTime = userRoleList.Max(t => t.RemoveTime) }); + } + + await _trialUserRoleReposiotry.BatchUpdateNoTrackingAsync(t => t.TrialId == item.Key.TrialId && userIdList.Contains(t.UserId), u => new TrialUserRole() { TrialUserId = id }); } - else - { - await _trialIdentityUserRepository.AddAsync(new TrialIdentityUser() { Id = id, IdentityUserId = item.Key.IdentityUserId, TrialId = item.Key.TrialId, RemoveTime = userRoleList.Max(t => t.RemoveTime) }); - } - - await _trialUserRoleReposiotry.BatchUpdateNoTrackingAsync(t => t.TrialId == item.Key.TrialId && userIdList.Contains(t.UserId), u => new TrialUserRole() { TrialUserId = id }); + await _trialIdentityUserRepository.SaveChangesAsync(); } - await _trialIdentityUserRepository.SaveChangesAsync(); + return ResponseOutput.Ok(); } diff --git a/IRaCIS.Core.Domain/Trial/Enroll.cs b/IRaCIS.Core.Domain/Trial/Enroll.cs index 309f72585..f41341c99 100644 --- a/IRaCIS.Core.Domain/Trial/Enroll.cs +++ b/IRaCIS.Core.Domain/Trial/Enroll.cs @@ -52,6 +52,8 @@ public partial class Enroll : BaseFullAuditEntity public int? Global { get; set; } public int? Downtime { get; set; } + + [Comment("生成账号 加入到项目中后 赋值")] public Guid? DoctorUserId { get; set; } }