From 006afc56d50a41e28e14737c53b27e894ed61617 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 19 Aug 2025 14:29:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=97=E8=A1=A8=E8=BF=87?= =?UTF-8?q?=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Recurring/IRRecurringConsumer.cs | 2 +- .../Service/Common/ExcelExportService.cs | 6 +- .../Service/Management/UserService.cs | 8 + .../UltrasonicDicomService.cs | 2 +- .../TrialSiteUser/PersonalWorkstation.cs | 78 ++++----- .../Service/TrialSiteUser/TrialService.cs | 6 +- .../Service/Visit/PatientService.cs | 12 +- IRaCIS.Core.Application/TestService.cs | 157 ++++++++++-------- IRaCIS.Core.Domain/Trial/Trial.cs | 2 +- .../AuthUser/IUserInfo.cs | 1 + IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs | 2 + 11 files changed, 157 insertions(+), 119 deletions(-) diff --git a/IRaCIS.Core.Application/MassTransit/Recurring/IRRecurringConsumer.cs b/IRaCIS.Core.Application/MassTransit/Recurring/IRRecurringConsumer.cs index a4146fd0b..6b2a0dc99 100644 --- a/IRaCIS.Core.Application/MassTransit/Recurring/IRRecurringConsumer.cs +++ b/IRaCIS.Core.Application/MassTransit/Recurring/IRRecurringConsumer.cs @@ -69,7 +69,7 @@ namespace IRaCIS.Core.Application.MassTransit.Recurring var userId = trialUser.UserId; - var doctorCriterionList = await _trialReadingCriterionRepository.Where(t => t.IsSigned && t.IsConfirm && t.TrialId == trialId && t.Trial.TrialUserList.Any(t => t.UserId == userId)) + var doctorCriterionList = await _trialReadingCriterionRepository.Where(t => t.IsSigned && t.IsConfirm && t.TrialId == trialId && t.Trial.TrialUserRoleList.Any(t => t.UserId == userId)) .Select(c => new { diff --git a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs index 0011eefb0..dbd6b8a12 100644 --- a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs +++ b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs @@ -165,9 +165,9 @@ namespace IRaCIS.Core.Application.Service.Common .WhereIf(!string.IsNullOrEmpty(inQuery.Code), o => o.TrialCode.Contains(inQuery.Code)) .WhereIf(!string.IsNullOrEmpty(inQuery.ResearchProgramNo), o => o.ResearchProgramNo.Contains(inQuery.ResearchProgramNo)) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.ExperimentName), o => o.ExperimentName.Contains(inQuery.ExperimentName)) - .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.Admin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.OP, t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId && t.IsDeleted == false) && t.IsDeleted == false) + .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.Admin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.OP, t => t.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId && t.IsDeleted == false) && t.IsDeleted == false) .WhereIf(inQuery.CriterionType != null, o => o.TrialReadingCriterionList.Any(t => t.CriterionType == inQuery.CriterionType && t.IsSigned && t.IsConfirm)) - .WhereIf(!string.IsNullOrEmpty(inQuery.PM_EMail), o => o.TrialUserList.Any(t => t.UserRole.EMail.Contains(inQuery.PM_EMail) && (t.UserRole.UserTypeEnum == UserTypeEnum.ProjectManager || t.UserRole.UserTypeEnum == UserTypeEnum.APM))) + .WhereIf(!string.IsNullOrEmpty(inQuery.PM_EMail), o => o.TrialUserRoleList.Any(t => t.UserRole.EMail.Contains(inQuery.PM_EMail) && (t.UserRole.UserTypeEnum == UserTypeEnum.ProjectManager || t.UserRole.UserTypeEnum == UserTypeEnum.APM))) .Select(t => new TrialToBeDoneDto() { TrialId = t.Id, @@ -228,7 +228,7 @@ namespace IRaCIS.Core.Application.Service.Common IR_ReadingCriterionList = isIR ? t.TrialReadingCriterionList.Where(t => t.IsConfirm && t.IsSigned).OrderBy(t => t.CriterionName).Select(t => t.CriterionName).ToList() : null, - IR_PMEmailList = isIR ? t.TrialUserList.Where(t => t.UserRole.UserTypeEnum == UserTypeEnum.ProjectManager || t.UserRole.UserTypeEnum == UserTypeEnum.APM).OrderBy(t => t.UserRole.EMail).Select(t => t.UserRole.EMail).ToList() : null, + IR_PMEmailList = isIR ? t.TrialUserRoleList.Where(t => t.UserRole.UserTypeEnum == UserTypeEnum.ProjectManager || t.UserRole.UserTypeEnum == UserTypeEnum.APM).OrderBy(t => t.UserRole.EMail).Select(t => t.UserRole.EMail).ToList() : null, IR_TotalReadCount = isIR ? t.VisitTaskList.Where(t => t.DoctorUserId == _userInfo.UserRoleId && t.TaskState == TaskState.Effect && t.ReadingTaskState == ReadingTaskState.HaveSigned).Count() : 0, diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index 0dfd535de..b620a4954 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -16,6 +16,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; using Org.BouncyCastle.Utilities.Encoders; using Panda.DynamicWebApi.Attributes; +using System.Linq; using System.Text.RegularExpressions; using ZiggyCreatures.Caching.Fusion; @@ -474,6 +475,13 @@ namespace IRaCIS.Core.Application.Service .WhereIf(inQuery.UserState != null, t => t.Status == inQuery.UserState) .WhereIf(inQuery.IsTestUser != null, t => t.IsTestUser == inQuery.IsTestUser) .WhereIf(inQuery.IsZhiZhun != null, t => t.IsZhiZhun == inQuery.IsZhiZhun) + + //OA 不能看admin + .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.OA, t => !t.UserRoleList.Any(t => t.UserTypeEnum == UserTypeEnum.Admin || t.UserTypeEnum == UserTypeEnum.SuperAdmin)) + + //GA 只能看有该课题组的用户,并且不是admin oa + .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.GA, t => !t.UserRoleList.Any(t => t.UserTypeEnum == UserTypeEnum.Admin || t.UserTypeEnum == UserTypeEnum.SuperAdmin || t.UserTypeEnum == UserTypeEnum.OA) + && t.IdentityUserHospitalGroupList.Any(t => _userInfo.HospitalGroupIdList.Contains(t.HospitalGroupId))) .ProjectTo(_mapper.ConfigurationProvider); return await userQueryable.ToPagedListAsync(inQuery); diff --git a/IRaCIS.Core.Application/Service/Third-partyProject/UltrasonicDicomService.cs b/IRaCIS.Core.Application/Service/Third-partyProject/UltrasonicDicomService.cs index 56a4d4e6f..3bdf7862b 100644 --- a/IRaCIS.Core.Application/Service/Third-partyProject/UltrasonicDicomService.cs +++ b/IRaCIS.Core.Application/Service/Third-partyProject/UltrasonicDicomService.cs @@ -41,7 +41,7 @@ namespace IRaCIS.Core.Application.Service.Third_partyProject .WhereIf(!string.IsNullOrEmpty(inQuery.Code), o => o.TrialCode.Contains(inQuery.Code)) .WhereIf(!string.IsNullOrEmpty(inQuery.ResearchProgramNo), o => o.ResearchProgramNo.Contains(inQuery.ResearchProgramNo)) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.ExperimentName), o => o.ExperimentName.Contains(inQuery.ExperimentName)) - .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin, t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId && t.IsDeleted == false) && t.IsDeleted == false) + .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin, t => t.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId && t.IsDeleted == false) && t.IsDeleted == false) .Select(t => new TrialListDTO_UltrasonicDicom() { TrialId = t.Id, diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs index 8f3a0e639..ecdd9623c 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs @@ -37,7 +37,7 @@ namespace IRaCIS.Core.Application { return await _trialRepository .Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.APM, c => c.TrialSiteSurveyList.Where(t => t.State == TrialSiteSurveyEnum.SPMApproved).Count() > 0) .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM, c => c.TrialSiteSurveyList.Where(t => t.State == TrialSiteSurveyEnum.CRCSubmitted).Count() > 0) .ProjectTo(_mapper.ConfigurationProvider, new { userTypeEnumInt = _userInfo.UserTypeEnumInt, userId = _userInfo.UserRoleId }) @@ -73,7 +73,7 @@ namespace IRaCIS.Core.Application var query = _trialRepository .Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Select(t => new CheckToBeDoneDto() { TrialId = t.Id, @@ -94,11 +94,11 @@ namespace IRaCIS.Core.Application var result = await query.ToPagedListAsync(inQuery, defalutSortArray); var totalToBeCheckedCount = await _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.Trial.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(u => u.CheckState == CheckStateEnum.ToCheck).CountAsync(); var totalToBeRepliedCount = await _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.Trial.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(u => u.CheckState == CheckStateEnum.CVIng && u.CheckChallengeDialogList.OrderByDescending(t => t.CreateTime).First().UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator).CountAsync(); @@ -120,7 +120,7 @@ namespace IRaCIS.Core.Application { var query = _visitTaskReReadingRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.OriginalReReadingTask.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.OriginalReReadingTask.Trial.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.OriginalReReadingTask.ReReadingApplyState == ReReadingApplyState.DocotorHaveApplyed) .GroupBy(t => new { t.OriginalReReadingTask.Trial.ExperimentName, t.OriginalReReadingTask.Trial.ResearchProgramNo, t.OriginalReReadingTask.Trial.TrialCode, t.OriginalReReadingTask.TrialId }) .Select(g => new ReReadingApplyToBeDoneDto() @@ -141,7 +141,7 @@ namespace IRaCIS.Core.Application var toBeApprovalCount = _visitTaskReReadingRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.OriginalReReadingTask.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.OriginalReReadingTask.Trial.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.OriginalReReadingTask.ReReadingApplyState == ReReadingApplyState.DocotorHaveApplyed).Count(); return ResponseOutput.Ok(result, new { TotalToBeApprovalCount = toBeApprovalCount }); @@ -162,7 +162,7 @@ namespace IRaCIS.Core.Application [FromServices] IRepository _trialRepository) { var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Select(t => new ReviewerSelectToBeDoneDto() { TrialId = t.Id, @@ -180,7 +180,7 @@ namespace IRaCIS.Core.Application var toBeApprovalCount = await _enrollRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.Trial.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(u => u.EnrollStatus == EnrollStatus.HasCommittedToCRO).CountAsync(); return ResponseOutput.Ok(result, new { ToBeApprovalCount = toBeApprovalCount }); ; @@ -198,7 +198,7 @@ namespace IRaCIS.Core.Application { var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Select(t => new GetPMClinicalDataToBeDoneListOutDto() { TrialId = t.Id, @@ -218,7 +218,7 @@ namespace IRaCIS.Core.Application var all = await _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Select(t => new GetPMClinicalDataToBeDoneListOutDto() { @@ -247,7 +247,7 @@ namespace IRaCIS.Core.Application [FromServices] IRepository _trialRepository) { var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Select(t => new ReviewerSelectToBeDoneDto() { TrialId = t.Id, @@ -266,7 +266,7 @@ namespace IRaCIS.Core.Application var toBeApprovalCount = await _enrollRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.Trial.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(u => u.EnrollStatus == EnrollStatus.HasCommittedToCRO).CountAsync(); return ResponseOutput.Ok(result, new { TotalToBeApprovalCount = toBeApprovalCount }); ; @@ -287,7 +287,7 @@ namespace IRaCIS.Core.Application { var query = _visitTaskReReadingRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.OriginalReReadingTask.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.OriginalReReadingTask.Trial.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.OriginalReReadingTask.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed) .GroupBy(t => new { t.OriginalReReadingTask.Trial.ExperimentName, t.OriginalReReadingTask.Trial.ResearchProgramNo, t.OriginalReReadingTask.Trial.TrialCode, t.OriginalReReadingTask.TrialId }) .Select(g => new ReReadingApprovalToBeDoneDto() @@ -308,7 +308,7 @@ namespace IRaCIS.Core.Application var toBeApprovalCount = _visitTaskReReadingRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.OriginalReReadingTask.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.OriginalReReadingTask.Trial.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.OriginalReReadingTask.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed).Count(); return ResponseOutput.Ok(result, new { TotalToBeApprovalCount = toBeApprovalCount }); @@ -335,7 +335,7 @@ namespace IRaCIS.Core.Application { var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) //.Where(t => t.clinicalDataTrialSets.Any(t => t.ClinicalDataLevel == ClinicalLevel.Subject && t.IsConfirm)) .Select(t => new ImageClinicalDataToBeDoneDto() { @@ -377,7 +377,7 @@ namespace IRaCIS.Core.Application { var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) //.Where(t => t.clinicalDataTrialSets.Any(t => t.ClinicalDataLevel == ClinicalLevel.Subject && t.IsConfirm)) .Select(t => new ImageClinicalDataToBeDoneDto() { @@ -438,7 +438,7 @@ namespace IRaCIS.Core.Application { var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Select(t => new ImageQuestionToBeDoneDto() { TrialId = t.Id, @@ -463,7 +463,7 @@ namespace IRaCIS.Core.Application var toBeDealedCount = _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.Trial.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(c => c.TrialSite.CRCUserList.Any(u => u.UserId == _userInfo.UserRoleId)) .SelectMany(c => c.QCChallengeList) .Where(u => u.IsClosed == false && u.LatestReplyUser.UserTypeEnum == UserTypeEnum.IQC).Count(); @@ -486,7 +486,7 @@ namespace IRaCIS.Core.Application { var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Select(t => new ImageCheckQuestionToBeDoneDto() { TrialId = t.Id, @@ -509,7 +509,7 @@ namespace IRaCIS.Core.Application var toBeDealedCount = _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.Trial.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(c => c.TrialSite.CRCUserList.Any(u => u.UserId == _userInfo.UserRoleId)) .Where(u => u.CheckState == CheckStateEnum.CVIng && u.CheckChallengeState == CheckChanllengeTypeEnum.PMWaitCRCReply).Count(); @@ -532,7 +532,7 @@ namespace IRaCIS.Core.Application { var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Select(t => new ImageReUploadToBeDoneDto() { TrialId = t.Id, @@ -555,7 +555,7 @@ namespace IRaCIS.Core.Application var result = await query.ToPagedListAsync(inQuery, defalutSortArray); var toBeDealedCount = _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.Trial.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(u => (u.SubmitState == SubmitStateEnum.ToSubmit && u.IsPMBackOrReReading) || (u.IsQCConfirmedReupload)).Count(); return ResponseOutput.Ok(result, new { TotalToBeReUploadCount = toBeDealedCount }); @@ -579,7 +579,7 @@ namespace IRaCIS.Core.Application { var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId) && (t.IsUrgent || t.IsSubjectExpeditedView || t.IsEnrollementQualificationConfirm || t.IsPDProgressView)) + .Where(t => t.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId) && (t.IsUrgent || t.IsSubjectExpeditedView || t.IsEnrollementQualificationConfirm || t.IsPDProgressView)) .Select(t => new ImageSubmittedToBeDoneDto() { TrialId = t.Id, @@ -605,7 +605,7 @@ namespace IRaCIS.Core.Application var toBeDealedCount = _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.Trial.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(c => c.TrialSite.CRCUserList.Any(u => u.UserId == _userInfo.UserRoleId)) .Where(u => u.SubmitState == SubmitStateEnum.ToSubmit).Count(); @@ -635,7 +635,7 @@ namespace IRaCIS.Core.Application { var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.QCProcessEnum != TrialQCProcess.NotAudit) .Select(t => new ImageQualityToBeDoneDto() { @@ -665,12 +665,12 @@ namespace IRaCIS.Core.Application var toBeClaimedCount = _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId) && t.SubmitState == SubmitStateEnum.Submitted && t.AuditState != AuditStateEnum.QCPassed && t.AuditState != AuditStateEnum.QCFailed) + .Where(t => t.Trial.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId) && t.SubmitState == SubmitStateEnum.Submitted && t.AuditState != AuditStateEnum.QCPassed && t.AuditState != AuditStateEnum.QCFailed) .Where(u => u.CurrentActionUserId == null && (u.PreliminaryAuditUserId == null || (u.PreliminaryAuditUserId != _userInfo.UserRoleId && u.ReviewAuditUserId == null))).Count(); var toBeReviwedCount = _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.Trial.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(u => u.CurrentActionUserId == _userInfo.UserRoleId).Count(); @@ -693,7 +693,7 @@ namespace IRaCIS.Core.Application { var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Select(t => new ImageQuestionToBeDoneDto() { TrialId = t.Id, @@ -714,7 +714,7 @@ namespace IRaCIS.Core.Application var toBeDealedCount = _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.Trial.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .SelectMany(c => c.QCChallengeList) .Where(u => u.CreateUserId == _userInfo.UserRoleId && u.IsClosed == false && u.LatestReplyUser.UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator).Count(); @@ -747,7 +747,7 @@ namespace IRaCIS.Core.Application { - var newQuery = _trialReadingCriterionRepository.Where(t => t.IsSigned && t.IsConfirm && t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + var newQuery = _trialReadingCriterionRepository.Where(t => t.IsSigned && t.IsConfirm && t.Trial.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Select(c => new IRImageReadingToBeDoneDto() { TrialId = c.TrialId, @@ -857,7 +857,7 @@ namespace IRaCIS.Core.Application var result = await newQuery.ToPagedListAsync(inQuery, defalutSortArray); var toBeDealedCount = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .SelectMany(t => t.VisitTaskList) .Where(t => t.DoctorUserId == _userInfo.UserRoleId && t.ReadingTaskState != ReadingTaskState.HaveSigned && t.TaskState == TaskState.Effect && t.TrialReadingCriterion.IsSigned == true && t.TrialReadingCriterion.IsConfirm == true) // 前序 不存在 未一致性核查未通过的 @@ -885,7 +885,7 @@ namespace IRaCIS.Core.Application { var query = _taskMedicalReviewRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.Trial.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.IsClosedDialog == false && t.VisitTask.TaskState == TaskState.Effect && t.IsInvalid == false && t.VisitTask.DoctorUserId == _userInfo.UserRoleId) .GroupBy(t => new { @@ -929,7 +929,7 @@ namespace IRaCIS.Core.Application var toBeDealedCount = _taskMedicalReviewRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.Trial.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.IsClosedDialog == false && t.VisitTask.DoctorUserId == _userInfo.UserRoleId) .Where(u => u.LatestReplyUser.UserTypeEnum == UserTypeEnum.MIM) //.Where(u => u.ReadingMedicalReviewDialogList.OrderByDescending(l => l.CreateTime).First().UserTypeEnumInt == (int)UserTypeEnum.MIM) @@ -962,7 +962,7 @@ namespace IRaCIS.Core.Application #region 废弃不能对包含聚合或子查询的表达式执行聚合函数 var query = _taskMedicalReviewRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.Trial.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.IsClosedDialog == false && t.VisitTask.TaskState == TaskState.Effect && t.IsInvalid == false && t.MedicalManagerUserId == _userInfo.UserRoleId) .GroupBy(t => new { @@ -1000,7 +1000,7 @@ namespace IRaCIS.Core.Application var toBeReplyedQuery = _taskMedicalReviewRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.Trial.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.IsClosedDialog == false && t.VisitTask.TaskState == TaskState.Effect && t.IsInvalid == false && t.MedicalManagerUserId == _userInfo.UserRoleId) .Where(u => u.LatestReplyUser.UserTypeEnum == UserTypeEnum.IndependentReviewer && u.AuditState == MedicalReviewAuditState.Auditing); @@ -1008,7 +1008,7 @@ namespace IRaCIS.Core.Application var toBeReplyedCount = toBeReplyedQuery.Count(); var tobeReviewedCount = _taskMedicalReviewRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => t.Trial.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.IsClosedDialog == false && t.VisitTask.TaskState == TaskState.Effect && t.IsInvalid == false && t.MedicalManagerUserId == _userInfo.UserRoleId) .Where(u => u.AuditState != MedicalReviewAuditState.HaveSigned && u.LatestReplyUser.UserTypeEnum != UserTypeEnum.IndependentReviewer).Count(); @@ -1075,9 +1075,9 @@ namespace IRaCIS.Core.Application .WhereIf(!string.IsNullOrEmpty(inQuery.Code), o => o.TrialCode.Contains(inQuery.Code)) .WhereIf(!string.IsNullOrEmpty(inQuery.ResearchProgramNo), o => o.ResearchProgramNo.Contains(inQuery.ResearchProgramNo)) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.ExperimentName), o => o.ExperimentName.Contains(inQuery.ExperimentName)) - .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.Admin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.OP, t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId && t.IsDeleted == false) && t.IsDeleted == false) + .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.Admin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.OP, t => t.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId && t.IsDeleted == false) && t.IsDeleted == false) .WhereIf(inQuery.CriterionType != null, o => o.TrialReadingCriterionList.Any(t => t.CriterionType == inQuery.CriterionType && t.IsSigned && t.IsConfirm)) - .WhereIf(!string.IsNullOrEmpty(inQuery.PM_EMail), o => o.TrialUserList.Any(t => t.UserRole.EMail.Contains(inQuery.PM_EMail) && (t.UserRole.UserTypeEnum == UserTypeEnum.ProjectManager || t.UserRole.UserTypeEnum == UserTypeEnum.APM))) + .WhereIf(!string.IsNullOrEmpty(inQuery.PM_EMail), o => o.TrialUserRoleList.Any(t => t.UserRole.EMail.Contains(inQuery.PM_EMail) && (t.UserRole.UserTypeEnum == UserTypeEnum.ProjectManager || t.UserRole.UserTypeEnum == UserTypeEnum.APM))) .Select(t => new TrialToBeDoneDto() { TrialId = t.Id, @@ -1138,7 +1138,7 @@ namespace IRaCIS.Core.Application IR_ReadingCriterionList = isIR ? t.TrialReadingCriterionList.Where(t => t.IsConfirm && t.IsSigned).OrderBy(t => t.CriterionName).Select(t => t.CriterionName).ToList() : null, - IR_PMEmailList = isIR ? t.TrialUserList.Where(t => t.UserRole.UserTypeEnum == UserTypeEnum.ProjectManager || t.UserRole.UserTypeEnum == UserTypeEnum.APM).OrderBy(t => t.UserRole.EMail).Select(t => t.UserRole.EMail).ToList() : null, + IR_PMEmailList = isIR ? t.TrialUserRoleList.Where(t => t.UserRole.UserTypeEnum == UserTypeEnum.ProjectManager || t.UserRole.UserTypeEnum == UserTypeEnum.APM).OrderBy(t => t.UserRole.EMail).Select(t => t.UserRole.EMail).ToList() : null, IR_TotalReadCount = isIR ? t.VisitTaskList.Where(t => t.DoctorUserId == _userInfo.UserRoleId && t.TaskState == TaskState.Effect && t.ReadingTaskState == ReadingTaskState.HaveSigned).Count() : 0, diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs index e2f032e06..ede9f0c4f 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs @@ -90,7 +90,7 @@ namespace IRaCIS.Core.Application.Service .WhereIf(multiModalityIdSelectCount > 0, t => t.TrialDicList.Count(t => t.KeyName == StaticData.Modality) == multiModalityIdSelectCount) .WhereIf(multiCriteriaSelectCount > 0, t => t.TrialDicList.Count(t => t.KeyName == StaticData.Criterion) == multiCriteriaSelectCount) .WhereIf(multiReviewTypeSelectCount > 0, t => t.TrialDicList.Count(t => t.KeyName == StaticData.ReviewType) == multiReviewTypeSelectCount) - .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin, t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId && t.IsDeleted == false) && t.IsDeleted == false) + .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin, t => t.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId && t.IsDeleted == false) && t.IsDeleted == false) .ProjectTo(_mapper.ConfigurationProvider, new { userTypeEnumInt = _userInfo.UserTypeEnumInt, userId = _userInfo.UserRoleId, isEn_Us = _userInfo.IsEn_Us }); return await query.ToPagedListAsync(inQuery); @@ -102,7 +102,7 @@ namespace IRaCIS.Core.Application.Service public async Task> GetTrialSelect() { return await _trialRepository.AsQueryable() - .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.Admin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.OP, t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId) && t.IsDeleted == false) + .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.Admin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.OP, t => t.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId) && t.IsDeleted == false) .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); } @@ -616,7 +616,7 @@ namespace IRaCIS.Core.Application.Service .WhereIf(inQuery.Expedited != null, o => o.Expedited == inQuery.Expedited) .WhereIf(!string.IsNullOrEmpty(inQuery.Code), o => o.TrialCode.Contains(inQuery.Code)) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.Indication), o => o.Indication.Contains(inQuery.Indication)) - .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin, t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin, t => t.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .ProjectTo(_mapper.ConfigurationProvider, new { userTypeEnumInt = _userInfo.UserTypeEnumInt, userId = _userInfo.UserRoleId, isEn_Us = _userInfo.IsEn_Us }); diff --git a/IRaCIS.Core.Application/Service/Visit/PatientService.cs b/IRaCIS.Core.Application/Service/Visit/PatientService.cs index 423cd4e17..51fe654e3 100644 --- a/IRaCIS.Core.Application/Service/Visit/PatientService.cs +++ b/IRaCIS.Core.Application/Service/Visit/PatientService.cs @@ -202,7 +202,7 @@ namespace IRaCIS.Application.Services .WhereIf(inQuery.TrialType != null, t => t.TrialType == inQuery.TrialType) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.TrialCode), t => t.TrialCode.Contains(inQuery.TrialCode)) .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.Admin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.OA - , t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId && t.IsDeleted == false) && t.IsDeleted == false) + , t => t.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .ProjectTo(_mapper.ConfigurationProvider); @@ -641,7 +641,7 @@ namespace IRaCIS.Application.Services StudyCount = patient.SCPStudyList.Where(t => isAdminOrOA ? true : t.HospitalGroupList.Any(c => currentUserHospitalGroupIdList.Contains(c.HospitalGroupId))).Count(), - TrialList = patient.SubjectPatientList.Where(t => isAdminOrOA ? true : t.Subject.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)).Select(c => new PatientTrialStatInfo() + TrialList = patient.SubjectPatientList.Where(t => isAdminOrOA ? true : t.Subject.Trial.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)).Select(c => new PatientTrialStatInfo() { ExperimentName = c.Subject.Trial.ExperimentName, VisitCount = c.Subject.SubjectVisitList.Count() @@ -713,7 +713,7 @@ namespace IRaCIS.Application.Services var trialQuery = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing && hospitalGroupIdList.Contains(t.HospitalGroupId)) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.Filter), t => t.ResearchProgramNo.Contains(inQuery.Filter) || t.ExperimentName.Contains(inQuery.Filter)) - .Where(t => t.TrialUserList.Any(c => c.UserId == _userInfo.UserRoleId)) + .Where(t => t.TrialUserRoleList.Any(c => c.UserId == _userInfo.UserRoleId)) .Where(t => !exceptQuery.Any(c => c == t.Id)).ProjectTo(_mapper.ConfigurationProvider); var list = trialQuery.ToList(); @@ -734,7 +734,7 @@ namespace IRaCIS.Application.Services var isAdminOrOA = _userInfo.UserTypeEnumInt == (int)UserTypeEnum.Admin || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.OA || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SuperAdmin; var trialQuery = _subjectPatientRepository.Where(t => t.PatientId == inQuery.PatientId) - .Where(t => isAdminOrOA ? true : t.Subject.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + .Where(t => isAdminOrOA ? true : t.Subject.Trial.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .ProjectTo(_mapper.ConfigurationProvider); var pageList = await trialQuery.ToPagedListAsync(inQuery); @@ -908,7 +908,7 @@ namespace IRaCIS.Application.Services [FromServices] IOSSService oSSService) { //清理自己管理的项目的数据 - var subjectPatientList = await _subjectPatientRepository.Where(t => t.PatientId == patientId && t.Subject.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) + var subjectPatientList = await _subjectPatientRepository.Where(t => t.PatientId == patientId && t.Subject.Trial.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId)) .Select(t => new { t.SubjectId, StudyInstanceUidList = t.Patient.SCPStudyList.Select(t => t.StudyInstanceUid).ToList() }).ToListAsync(); if (_studyRepository.Any(t => t.IsUploadFinished == false && t.PatientId == patientId)) @@ -3363,7 +3363,7 @@ namespace IRaCIS.Application.Services { var trialQuery = _trialRepository .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.Admin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.OA - , t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId && t.IsDeleted == false) && t.IsDeleted == false) + , t => t.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId && t.IsDeleted == false) && t.IsDeleted == false) .Select(t => new NewTrialSelectDTO() { TrialId = t.Id, diff --git a/IRaCIS.Core.Application/TestService.cs b/IRaCIS.Core.Application/TestService.cs index fd2b2f72e..36b3ccd24 100644 --- a/IRaCIS.Core.Application/TestService.cs +++ b/IRaCIS.Core.Application/TestService.cs @@ -96,73 +96,8 @@ namespace IRaCIS.Core.Application.Service return ResponseOutput.Ok(); } - /// - /// 项目退出历史数据维护 - /// - /// - /// - /// - [AllowAnonymous] - public async Task OldTrialDeleteUser([FromServices] IRepository _trialIdentityUserRepository, [FromServices] IRepository _trialUserRoleReposiotry) - { - _userInfo.IsNotNeedInspection = true; - if (_trialUserRoleReposiotry.Any(t => t.TrialUserId == Guid.Empty)) - { - var list = _trialUserRoleReposiotry.Where(t => t.IsDeleted == true && t.TrialUserId == Guid.Empty, false, true).Select(t => new { t.TrialId, t.UserRole.IdentityUserId, t.UserId, t.JoinTime, t.RemoveTime, t.DeletedTime, t.DeleteUserId, t.CreateUserId }).ToList(); - - - foreach (var item in list.GroupBy(t => new { t.IdentityUserId, t.TrialId })) - { - - var id = NewId.NextSequentialGuid(); - - var userRoleList = item.ToList(); - - var userIdList = item.Select(t => t.UserId).ToList(); - - var first = userRoleList.OrderByDescending(t => t.RemoveTime).FirstOrDefault(); - - - //判断在项目中是否存在 - - var find = _trialIdentityUserRepository.Where(t => t.IdentityUserId == first.IdentityUserId && t.TrialId == first.TrialId).FirstOrDefault(); - - if (find == null) - { - await _trialIdentityUserRepository.AddAsync(new TrialIdentityUser() - { - Id = id, - IdentityUserId = item.Key.IdentityUserId, - TrialId = item.Key.TrialId, - RemoveTime = first.RemoveTime, - IsDeleted = true, - DeletedTime = first.DeletedTime, - DeleteUserId = first.DeleteUserId, - - }); - - - await _trialUserRoleReposiotry.BatchUpdateNoTrackingAsync(t => t.TrialId == item.Key.TrialId && userIdList.Contains(t.UserId), u => new TrialUserRole() { TrialUserId = id, UpdateTime = (DateTime)first.DeletedTime }); - } - else - { - await _trialUserRoleReposiotry.BatchUpdateNoTrackingAsync(t => t.TrialId == item.Key.TrialId && userIdList.Contains(t.UserId), u => new TrialUserRole() { TrialUserId = find.Id, UpdateTime = (DateTime)first.DeletedTime }); - } - - - - } - - await _trialIdentityUserRepository.SaveChangesAsync(); - } - - - - return ResponseOutput.Ok(); - } - /// /// 用户多账号,初次维护数据 /// @@ -273,6 +208,98 @@ namespace IRaCIS.Core.Application.Service return ResponseOutput.Ok(); } + /// + /// 项目退出历史数据维护 + /// + /// + /// + /// + [AllowAnonymous] + public async Task OldTrialDeleteUser([FromServices] IRepository _trialIdentityUserRepository, [FromServices] IRepository _trialUserRoleReposiotry) + { + _userInfo.IsNotNeedInspection = true; + + + if (_trialUserRoleReposiotry.Any(t => t.TrialUserId == Guid.Empty)) + { + var list = _trialUserRoleReposiotry.Where(t => t.IsDeleted == true && t.TrialUserId == Guid.Empty, false, true).Select(t => new { t.TrialId, t.UserRole.IdentityUserId, t.UserId, t.JoinTime, t.RemoveTime, t.DeletedTime, t.DeleteUserId, t.CreateUserId }).ToList(); + + + foreach (var item in list.GroupBy(t => new { t.IdentityUserId, t.TrialId })) + { + + var id = NewId.NextSequentialGuid(); + + var userRoleList = item.ToList(); + + var userIdList = item.Select(t => t.UserId).ToList(); + + var first = userRoleList.OrderByDescending(t => t.RemoveTime).FirstOrDefault(); + + + //判断在项目中是否存在 + + var find = _trialIdentityUserRepository.Where(t => t.IdentityUserId == first.IdentityUserId && t.TrialId == first.TrialId).FirstOrDefault(); + + if (find == null) + { + await _trialIdentityUserRepository.AddAsync(new TrialIdentityUser() + { + Id = id, + IdentityUserId = item.Key.IdentityUserId, + TrialId = item.Key.TrialId, + RemoveTime = first.RemoveTime, + IsDeleted = true, + DeletedTime = first.DeletedTime, + DeleteUserId = first.DeleteUserId, + + }); + + + await _trialUserRoleReposiotry.BatchUpdateNoTrackingAsync(t => t.TrialId == item.Key.TrialId && userIdList.Contains(t.UserId), u => new TrialUserRole() { TrialUserId = id, UpdateTime = (DateTime)first.DeletedTime }); + } + else + { + await _trialUserRoleReposiotry.BatchUpdateNoTrackingAsync(t => t.TrialId == item.Key.TrialId && userIdList.Contains(t.UserId), u => new TrialUserRole() { TrialUserId = find.Id, UpdateTime = (DateTime)first.DeletedTime }); + } + + + + } + + await _trialIdentityUserRepository.SaveChangesAsync(); + } + + + + return ResponseOutput.Ok(); + } + + /// + /// 给影像库所有检查 打上课题组标签 + /// + /// + /// + /// + /// + [AllowAnonymous] + public async Task OldSCPStudyHospitalGroup( + [FromServices] IRepository _SCPStudyHospitalGroupRepository, + [FromServices] IRepository _SCPStudyRepository, Guid hospitalGroupId) + { + + var scpStudyIdList = _SCPStudyRepository.Where().Select(t => t.Id).ToList(); + + foreach (var item in scpStudyIdList) + { + await _SCPStudyHospitalGroupRepository.AddAsync(new SCPStudyHospitalGroup() { SCPStudyId = item, HospitalGroupId = hospitalGroupId }); + } + + await _SCPStudyRepository.SaveChangesAsync(); + + return ResponseOutput.Ok(); + } + /// /// 外部人员 中心调研人员维护 /// diff --git a/IRaCIS.Core.Domain/Trial/Trial.cs b/IRaCIS.Core.Domain/Trial/Trial.cs index 6f22bdce7..20664a6fb 100644 --- a/IRaCIS.Core.Domain/Trial/Trial.cs +++ b/IRaCIS.Core.Domain/Trial/Trial.cs @@ -37,7 +37,7 @@ public partial class Trial : BaseFullDeleteAuditEntity [JsonIgnore] public List WorkloadList { get; set; } = new List(); [JsonIgnore] - public List TrialUserList { get; set; } = new List(); + public List TrialUserRoleList { get; set; } = new List(); [JsonIgnore] public List TrialReadingCriterionList { get; set; } = new List(); [JsonIgnore] diff --git a/IRaCIS.Core.Infra.EFCore/AuthUser/IUserInfo.cs b/IRaCIS.Core.Infra.EFCore/AuthUser/IUserInfo.cs index 7fca187de..f6d8ed012 100644 --- a/IRaCIS.Core.Infra.EFCore/AuthUser/IUserInfo.cs +++ b/IRaCIS.Core.Infra.EFCore/AuthUser/IUserInfo.cs @@ -7,6 +7,7 @@ namespace IRaCIS.Core.Domain.Share /// public interface IUserInfo { + List HospitalGroupIdList { get; } List HospitalGroupList { get; } Guid UserRoleId { get; } diff --git a/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs b/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs index 9b9f884a1..16a769593 100644 --- a/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs +++ b/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs @@ -60,6 +60,8 @@ namespace IRaCIS.Core.Domain.Share } } + public List HospitalGroupIdList => HospitalGroupList.Select(x => x.Id).ToList(); + public Guid UserTypeId { get