From 66922f8e7b6a5b732d170ecfc14ad9bb04f904f0 Mon Sep 17 00:00:00 2001
From: hang <872297557@qq.com>
Date: Thu, 26 Dec 2024 09:27:05 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9token=20=E5=90=8D=E5=AD=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../IRaCIS.Core.Application.xml | 8 +++++
.../Service/Inspection/InspectionService.cs | 3 +-
.../Service/Management/UserService.cs | 6 ++--
.../SiteSurvey/TrialSiteUserSurveyService.cs | 2 +-
.../TrialSiteUser/TrialExternalUserService.cs | 2 +-
.../TrialSiteUser/TrialMaintenanceService.cs | 14 ++++-----
IRaCIS.Core.Application/TestService.cs | 31 ++++++++++++++++++-
IRaCIS.Core.Domain/Management/User.cs | 22 +++++++------
.../SiteSurvey/TrialSiteUserSurvey.cs | 1 +
.../TrialSiteUser/TrialExternalUser.cs | 2 ++
10 files changed, 67 insertions(+), 24 deletions(-)
diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
index e7d3651f1..b818934c9 100644
--- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
+++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
@@ -13130,6 +13130,14 @@
+
+
+ 外部人员 中心调研人员维护
+
+
+
+
+
维护临床数据 --一定要在同步表前同步数据才行
diff --git a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs
index 336fe4ff1..878b4b125 100644
--- a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs
+++ b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs
@@ -12,6 +12,7 @@ namespace IRaCIS.Core.Application.Service.Inspection
public class InspectionService(IRepository _dataInspectionRepository,
IRepository _dictionaryRepository,
IRepository _trialSignRepository,
+ IRepository _identityUserRepository,
IRepository _userRoleRepository,
IRepository _trialSiteRepository,
IRepository _trialRepository,
@@ -257,7 +258,7 @@ namespace IRaCIS.Core.Application.Service.Inspection
/// 验证用户签名信息 ///
public async Task VerifySignatureAsync(SignDTO signDTO)
{
- var user = await _userRoleRepository.FirstOrDefaultAsync(u => u.UserName == signDTO.UserName && u.Password == signDTO.PassWord);
+ var user = await _identityUserRepository.FirstOrDefaultAsync(u => u.UserName == signDTO.UserName && u.Password == signDTO.PassWord);
if (user == null)
{
throw new BusinessValidationFailedException(_localizer["User_CheckNameOrPw"]);
diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs
index edda8af69..d811fe95e 100644
--- a/IRaCIS.Core.Application/Service/Management/UserService.cs
+++ b/IRaCIS.Core.Application/Service/Management/UserService.cs
@@ -1095,9 +1095,9 @@ namespace IRaCIS.Core.Application.Service
IdentityUserId = t.IdentityUserId,
UserTypeEnum = t.UserTypeEnum,
UserTypeId = t.UserTypeId,
- IsTestUser = t.IsTestUser,
- IsZhiZhun = t.IsZhiZhun,
- FullName = t.FullName,
+ IsTestUser = t.IdentityUser.IsTestUser,
+ IsZhiZhun = t.IdentityUser.IsZhiZhun,
+ FullName = t.IdentityUser.FullName,
PermissionStr = t.UserTypeRole.PermissionStr,
UserName = t.UserName,
UserTypeShortName = t.UserTypeRole.UserTypeShortName,
diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs
index 2f4008ac8..5a7511442 100644
--- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs
+++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs
@@ -110,7 +110,7 @@ namespace IRaCIS.Core.Application.Contracts
//$"该用户在系统中账户名为:{existSysUser.LastName + " / " + existSysUser.FirstName} ,与填写信息存在不一致项, 现将界面信息修改为与系统一致,可进行保存"
return ResponseOutput.NotOk(_localizer["TrialSiteUser_InconsistentInfo", existSysUser.UserTypeRole.UserTypeShortName, existSysUser.EMail, existSysUser.LastName + " / " + existSysUser.FirstName, existSysUser.Phone],
- new { Id = optEntity.Id, existSysUser.LastName, existSysUser.FirstName, existSysUser.Phone, existSysUser.IsTestUser, existSysUser.IsZhiZhun }, ApiResponseCodeEnum.NeedTips);
+ new { Id = optEntity.Id, existSysUser.LastName, existSysUser.FirstName, existSysUser.Phone }, ApiResponseCodeEnum.NeedTips);
}
}
diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs
index b3e8a683d..be1375300 100644
--- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs
+++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs
@@ -278,7 +278,7 @@ namespace IRaCIS.Core.Application.Service
await _trialUserRoleRepository.AddAsync(new TrialUserRole() { TrialId = trialId, TrialUserId = findTrialUser.Id, UserId = findUserRoleId, JoinTime = DateTime.Now });
- await _userRoleRepository.BatchUpdateNoTrackingAsync(t => t.IdentityUserId == userId, u => new UserRole() { Status = UserStateEnum.Enable });
+ await _userRoleRepository.BatchUpdateNoTrackingAsync(t => t.IdentityUserId == userId, u => new UserRole() { IsUserRoleDisabled =false });
await _trialExternalUseRepository.BatchUpdateNoTrackingAsync(t => t.Id == userInfo.Id, u => new TrialExternalUser() { IsJoin = true });
diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs
index f9466fa40..1c8f654a7 100644
--- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs
+++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs
@@ -58,7 +58,7 @@ namespace IRaCIS.Core.Application.Service
TrialUserRoleList = t.TrialUserRoleList.Select(ur => new TrialIdentityUserRoleDto()
{
Id = ur.Id,
- UserTypeShortName=ur.UserRole.UserTypeRole.UserTypeShortName,
+ UserTypeShortName = ur.UserRole.UserTypeRole.UserTypeShortName,
IsDeleted = ur.IsDeleted,
CreateTime = ur.CreateTime,
UpdateTime = ur.UpdateTime
@@ -132,10 +132,10 @@ namespace IRaCIS.Core.Application.Service
var query = _userRoleRepository.Where(t => t.UserTypeEnum != UserTypeEnum.SuperAdmin)
//正式或者培训的项目 不能允许测试用户(必须正式用户) 同时必须是内部的用户
- .WhereIf(trialType == TrialType.OfficialTrial || trialType == TrialType.Training, t => t.IsTestUser == false && t.IsZhiZhun)
+ .WhereIf(trialType == TrialType.OfficialTrial || trialType == TrialType.Training, t => t.IsTestUser == false && t.IdentityUser.IsZhiZhun)
//测试项目 可以加入 测试用户 或者内部正式用户
- .WhereIf(trialType == TrialType.NoneOfficial, t => t.IsTestUser == true || (t.IsTestUser == false && t.IsZhiZhun))
+ .WhereIf(trialType == TrialType.NoneOfficial, t => t.IsTestUser == true || (t.IsTestUser == false && t.IdentityUser.IsZhiZhun))
.Where(t => userTypeEnums.Contains(t.UserTypeEnum))
.WhereIf(inQuery.UserTypeEnum != null, t => t.UserTypeEnum == inQuery.UserTypeEnum)
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.UserRealName), t => t.IdentityUser.FullName.Contains(inQuery.UserRealName))
@@ -144,14 +144,14 @@ namespace IRaCIS.Core.Application.Service
.Select(t => new TrialUserRoleScreeningDto()
{
Id = t.Id,
- TrialId=inQuery.TrialId,
+ TrialId = inQuery.TrialId,
IdentityUserId = t.IdentityUserId,
EMail = t.IdentityUser.EMail,
FullName = t.IdentityUser.FullName,
OrganizationName = t.IdentityUser.OrganizationName,
Phone = t.IdentityUser.Phone,
UserName = t.IdentityUser.UserName,
- UserTypeShortName=t.UserTypeRole.UserTypeShortName,
+ UserTypeShortName = t.UserTypeRole.UserTypeShortName,
IsSelect = t.UserRoleTrials.Any(t => t.TrialId == inQuery.TrialId),
});
@@ -213,8 +213,8 @@ namespace IRaCIS.Core.Application.Service
var query = _trialUseRoleRepository.Where(t => t.TrialId == inQuery.TrialId).IgnoreQueryFilters()
.Where(t => t.UserRole.UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator || t.UserRole.UserTypeEnum == UserTypeEnum.CRA)
.WhereIf(inQuery.UserTypeId != null, t => t.UserRole.UserTypeId == inQuery.UserTypeId)
- .WhereIf(!string.IsNullOrWhiteSpace(inQuery.UserRealName), t => (t.UserRole.FullName).Contains(inQuery.UserRealName))
- .WhereIf(!string.IsNullOrWhiteSpace(inQuery.OrganizationName), t => t.UserRole.OrganizationName.Contains(inQuery.OrganizationName))
+ .WhereIf(!string.IsNullOrWhiteSpace(inQuery.UserRealName), t => (t.UserRole.IdentityUser.FullName).Contains(inQuery.UserRealName))
+ .WhereIf(!string.IsNullOrWhiteSpace(inQuery.OrganizationName), t => t.UserRole.IdentityUser.OrganizationName.Contains(inQuery.OrganizationName))
.ProjectTo(_mapper.ConfigurationProvider, new { trialSiteId = inQuery.TrialSiteId });
return await query.ToPagedListAsync(inQuery);
diff --git a/IRaCIS.Core.Application/TestService.cs b/IRaCIS.Core.Application/TestService.cs
index 558eae689..8cb13ca0f 100644
--- a/IRaCIS.Core.Application/TestService.cs
+++ b/IRaCIS.Core.Application/TestService.cs
@@ -26,6 +26,7 @@ using MiniExcelLibs;
using NPOI.SS.Formula.Functions;
using NPOI.XWPF.UserModel;
using System.Globalization;
+using System.Reflection.Metadata.Ecma335;
using System.Runtime.InteropServices;
using System.Text;
@@ -233,11 +234,39 @@ namespace IRaCIS.Core.Application.Service
await _trialIdentityUserRepository.SaveChangesAsync();
}
-
+
return ResponseOutput.Ok();
}
+ ///
+ /// 外部人员 中心调研人员维护
+ ///
+ ///
+ ///
+ ///
+ [UnitOfWork]
+ public async Task ExternalTrialUser(
+ [FromServices] IRepository _trialSiteUserSurveyRepository,
+ [FromServices] IRepository _trialExternalUserReposiotry,
+ [FromServices] IRepository _userRoleRepository)
+ {
+ var list = _userRoleRepository.Select(t => new { t.Id, t.IdentityUserId }).ToList();
+
+ foreach (var item in list.GroupBy(t => t.IdentityUserId))
+ {
+ var userRoleIdList = item.Select(t => t.Id).ToList();
+
+ var identityUserId = item.Key;
+
+ await _trialSiteUserSurveyRepository.BatchUpdateNoTrackingAsync(t => userRoleIdList.Contains(t.SystemUserId.Value), u => new TrialSiteUserSurvey() { SystemUserId = identityUserId });
+
+ await _trialExternalUserReposiotry.BatchUpdateNoTrackingAsync(t => userRoleIdList.Contains(t.SystemUserId), u => new TrialExternalUser() { SystemUserId = identityUserId });
+
+ }
+
+ return ResponseOutput.Ok();
+ }
[LowerCamelCaseJson]
diff --git a/IRaCIS.Core.Domain/Management/User.cs b/IRaCIS.Core.Domain/Management/User.cs
index bb10f9ffb..6a26dbb5e 100644
--- a/IRaCIS.Core.Domain/Management/User.cs
+++ b/IRaCIS.Core.Domain/Management/User.cs
@@ -32,19 +32,22 @@ public class UserRole : BaseFullAuditEntity
#endregion
- #region ûϢ
+ public string UserName { get; set; }
+ public string EMail { get; set; }
+ public string FirstName { get; set; }
+
+ public string LastName { get; set; }
+
+ #region ɾûϢ
public int Code { get; set; }
public string UserCode { get; set; }
- public string UserName { get; set; }
- public string EMail { get; set; }
+
[StringLength(1000)]
public string EmailToken { get; set; }
- public string FirstName { get; set; }
-
- public string LastName { get; set; }
+
public string Password { get; set; }
@@ -82,6 +85,9 @@ public class UserRole : BaseFullAuditEntity
public DateTime? LastLoginTime { get; set; }
+ [Comment("ɾ")]
+ public bool SuperAdmin { get; set; }
+
#endregion
@@ -96,10 +102,6 @@ public class UserRole : BaseFullAuditEntity
#region ֶ
- [Comment("ɾ")]
- public bool SuperAdmin { get; set; }
-
-
public Guid IdentityUserId { get; set; }
public bool IsUserRoleDisabled { get; set; }
diff --git a/IRaCIS.Core.Domain/SiteSurvey/TrialSiteUserSurvey.cs b/IRaCIS.Core.Domain/SiteSurvey/TrialSiteUserSurvey.cs
index 6382ed7ce..cd8dc791a 100644
--- a/IRaCIS.Core.Domain/SiteSurvey/TrialSiteUserSurvey.cs
+++ b/IRaCIS.Core.Domain/SiteSurvey/TrialSiteUserSurvey.cs
@@ -27,6 +27,7 @@ public class TrialSiteUserSurvey : BaseFullAuditEntity
public string OrganizationName { get; set; } = string.Empty;
+ [Comment("IdentityUser 表的用户Id")]
public Guid? SystemUserId { get; set; }
public bool IsGenerateAccount { get; set; }
diff --git a/IRaCIS.Core.Domain/TrialSiteUser/TrialExternalUser.cs b/IRaCIS.Core.Domain/TrialSiteUser/TrialExternalUser.cs
index de1dbd244..caaefcc3a 100644
--- a/IRaCIS.Core.Domain/TrialSiteUser/TrialExternalUser.cs
+++ b/IRaCIS.Core.Domain/TrialSiteUser/TrialExternalUser.cs
@@ -21,6 +21,8 @@ public class TrialExternalUser : BaseFullAuditEntity
public string LastName { get; set; } = String.Empty;
public string OrganizationName { get; set; } = String.Empty;
public bool IsSystemUser { get; set; }
+
+ [Comment("IdentityUser 表的用户Id")]
public Guid SystemUserId { get; set; }
public bool IsJoin { get; set; }
public DateTime? ExpireTime { get; set; }