diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index 92b79eda0..8a7853fcc 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -1080,7 +1080,7 @@ namespace IRaCIS.Core.Application.Service.Allocation public async Task AIRReReading(AIRReReadingCommand command, [FromServices] IVisitTaskHelpeService _visitTaskCommonService) { var baseLineTaskList = await _visitTaskRepository.Where(t => t.TrialId == command.TrialId && t.TrialReadingCriterionId == command.TrialReadingCriterionId && t.DoctorUserId == _userInfo.Id - && t.TaskState == TaskState.Effect && t.ReadingCategory == ReadingCategory.Visit && t.ReadingTaskState == ReadingTaskState.HaveSigned && t.SourceSubjectVisit.IsBaseLine == true && t.DoctorUserId == _userInfo.Id).ToListAsync(); + && t.TaskState == TaskState.Effect && t.ReadingCategory == ReadingCategory.Visit && t.ReadingTaskState == ReadingTaskState.HaveSigned && t.SourceSubjectVisit.IsBaseLine == true).ToListAsync(); var baseLineTaskIdList = baseLineTaskList.Select(t => t.Id).ToList(); @@ -2235,7 +2235,8 @@ namespace IRaCIS.Core.Application.Service.Allocation } else { - await _readingClinicalDataReposiotry.UpdatePartialFromQueryAsync(t => t.ReadingId == sv.Id && t.ClinicalDataTrialSet.ClinicalDataLevel == ClinicalLevel.SubjectVisit, c => new ReadingClinicalData() { IsSign = false, ReadingClinicalDataState =ReadingClinicalDataStatus.HaveUploaded }); + await _readingClinicalDataReposiotry.UpdatePartialFromQueryAsync(t => t.ReadingId == sv.Id && t.ClinicalDataTrialSet.ClinicalDataLevel == ClinicalLevel.SubjectVisit, c => new ReadingClinicalData() { + IsSign = false, ReadingClinicalDataState =ReadingClinicalDataStatus.HaveUploaded,IsBlind=null,IsComplete=null }); } diff --git a/IRaCIS.Core.Application/Service/Management/DTO/UserModel.cs b/IRaCIS.Core.Application/Service/Management/DTO/UserModel.cs index 57a089d1b..96c9037d2 100644 --- a/IRaCIS.Core.Application/Service/Management/DTO/UserModel.cs +++ b/IRaCIS.Core.Application/Service/Management/DTO/UserModel.cs @@ -194,9 +194,14 @@ namespace IRaCIS.Application.Contracts public class UserListQueryDTO : PageInput { public string UserName { get; set; } = string.Empty; + public string RealName { get; set; } public string Phone { get; set; } = string.Empty; public string OrganizationName { get; set; } = string.Empty; public Guid? UserType { get; set; } + + public bool? IsTestUser { get; set; } + + public bool ? IsZhiZhun { get; set; } public UserStateEnum? UserState { get; set; } } diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index 4db65f04c..2ae546c0c 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -448,11 +448,14 @@ namespace IRaCIS.Application.Services public async Task> GetUserList(UserListQueryDTO param) { var userQueryable = _userRepository.Where(x => x.UserTypeEnum != UserTypeEnum.SuperAdmin) - .WhereIf(!string.IsNullOrWhiteSpace(param.UserName), t => t.UserName.Contains(param.UserName) || (t.FullName).Contains(param.UserName)) + .WhereIf(!string.IsNullOrWhiteSpace(param.UserName), t => t.UserName.Contains(param.UserName) ) + .WhereIf(!string.IsNullOrWhiteSpace(param.RealName), t => t.FullName.Contains(param.RealName)) .WhereIf(!string.IsNullOrWhiteSpace(param.Phone), t => t.Phone.Contains(param.Phone)) .WhereIf(!string.IsNullOrWhiteSpace(param.OrganizationName), t => t.OrganizationName.Contains(param.OrganizationName)) .WhereIf(param.UserType != null, t => t.UserTypeId == param.UserType) .WhereIf(param.UserState != null, t => t.Status == param.UserState) + .WhereIf(param.IsTestUser != null, t => t.IsTestUser == param.IsTestUser) + .WhereIf(param.IsZhiZhun != null, t => t.IsZhiZhun == param.IsZhiZhun) .ProjectTo(_mapper.ConfigurationProvider); return await userQueryable.ToPagedListAsync(param.PageIndex, param.PageSize, param.SortField == string.Empty ? "UserName" : param.SortField, param.Asc); @@ -540,7 +543,7 @@ namespace IRaCIS.Application.Services if (user.IsZhiZhun) { - user.OrganizationName = "Zhizhun"; + user.OrganizationName = AppSettings.DefaultInternalOrganizationName; } var success = await _userRepository.SaveChangesAsync(); diff --git a/IRaCIS.Core.Application/Service/Management/UserTypeService.cs b/IRaCIS.Core.Application/Service/Management/UserTypeService.cs index d5583dd7c..2b99cd9be 100644 --- a/IRaCIS.Core.Application/Service/Management/UserTypeService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserTypeService.cs @@ -108,7 +108,7 @@ namespace IRaCIS.Core.Application.Contracts if (userTypeSelectEnum == UserTypeSelectEnum.InnerUser) { - userTypeEnums = new List() { UserTypeEnum.IQC, UserTypeEnum.APM, UserTypeEnum.MIM, UserTypeEnum.MW }; + userTypeEnums = new List() { UserTypeEnum.IQC, UserTypeEnum.APM, UserTypeEnum.MIM, UserTypeEnum.QA ,UserTypeEnum.MW}; if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SuperAdmin) { diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs index 4817a91fb..013c157b3 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs @@ -54,7 +54,7 @@ namespace IRaCIS.Core.Application.Contracts if (existSysUser.LastName != addOrEditTrialSiteUserSurvey.LastName || existSysUser.FirstName != addOrEditTrialSiteUserSurvey.FirstName) { return ResponseOutput.NotOk($"该用户在系统中账户名为:{existSysUser.LastName + " / " + existSysUser.FirstName} ,与填写信息存在不一致项, 现将界面信息修改为与系统一致,可进行保存", - new { existSysUser.LastName, existSysUser.FirstName, existSysUser.Phone }, ApiResponseCodeEnum.NeedTips); + new { existSysUser.LastName, existSysUser.FirstName, existSysUser.Phone,existSysUser.IsTestUser,existSysUser.IsZhiZhun }, ApiResponseCodeEnum.NeedTips); } } diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs index d029a6b8e..f5f70b230 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs @@ -68,7 +68,8 @@ namespace IRaCIS.Core.Application.Service /// /// [Authorize(Policy = IRaCISPolicy.PM_APM)] - [TypeFilter(typeof(TrialResourceFilter),Arguments = new object[] { "AfterStopCannNotOpt" })] + [UnitOfWork] + [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] public async Task AddOrUpdateTrialExternalUser(TrialExternalUserAddAndSendEmail addOrEditTrialExternalUser) { @@ -80,7 +81,7 @@ namespace IRaCIS.Core.Application.Service { if (existSysUser.LastName != addOrEditTrialExternalUser.LastName || existSysUser.FirstName != addOrEditTrialExternalUser.FirstName) { - return ResponseOutput.NotOk($"该用户在系统中的用户名为:{existSysUser.LastName + " / " + existSysUser.FirstName} 电话:{existSysUser.Phone},与填写信息存在不一致项, 请将界面信息修改为与系统一致,再进行保存", new { existSysUser.LastName, existSysUser.FirstName, existSysUser.Phone }, ApiResponseCodeEnum.NeedTips); + return ResponseOutput.NotOk($"该用户在系统中的用户名为:{existSysUser.LastName + " / " + existSysUser.FirstName} 电话:{existSysUser.Phone},与填写信息存在不一致项, 请将界面信息修改为与系统一致,再进行保存", new { existSysUser.LastName, existSysUser.FirstName, existSysUser.Phone, existSysUser.IsZhiZhun, existSysUser.IsTestUser }, ApiResponseCodeEnum.NeedTips); } } @@ -95,6 +96,7 @@ namespace IRaCIS.Core.Application.Service } + var addEntity = _mapper.Map(addOrEditTrialExternalUser); await _trialExternalUseRepository.AddAsync(addEntity); @@ -206,7 +208,7 @@ namespace IRaCIS.Core.Application.Service //New 省掉邀请流程 [HttpPost] [Authorize(Policy = IRaCISPolicy.PM_APM)] - [TypeFilter(typeof(TrialResourceFilter),Arguments = new object[] { "AfterStopCannNotOpt" })] + [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] [UnitOfWork] public async Task SendExternalUserJoinEmail(TrialExternalUserSendEmail sendEmail) { @@ -224,7 +226,7 @@ namespace IRaCIS.Core.Application.Service if (!await _trialUserRepository.AnyAsync(t => t.TrialId == trialId && t.UserId == userId, true)) { - await _repository.AddAsync(new TrialUser() { TrialId = trialId, UserId = userId ,JoinTime = DateTime.Now }); + await _repository.AddAsync(new TrialUser() { TrialId = trialId, UserId = userId, JoinTime = DateTime.Now }); await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == userId, u => new User() { Status = UserStateEnum.Enable }); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs index 80c6fe9f6..0e4df4a07 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs @@ -107,11 +107,25 @@ namespace IRaCIS.Application.Services { var trialType = _trialRepository.Where(t => t.Id == trialUserQuery.TrialId).Select(t => t.TrialType).FirstOrDefault(); + var userTypeEnums = new List() { UserTypeEnum.IQC, UserTypeEnum.APM, UserTypeEnum.MIM, UserTypeEnum.QA, UserTypeEnum.MW }; + if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SuperAdmin) + { + userTypeEnums.Add(UserTypeEnum.ProjectManager); + } + + //之前已经选择的用户 不放在列表中,现在又要改回去 废弃 var query = _repository.Where(t => t.UserTypeEnum != UserTypeEnum.SuperAdmin) - //正式或者培训的项目不能允许测试用户 - .WhereIf(trialType == TrialType.OfficialTrial || trialType == TrialType.Training, t => t.IsTestUser == false) + //正式或者培训的项目不能允许测试用户 同时必须是内部的用户 + .WhereIf(trialType == TrialType.OfficialTrial || trialType == TrialType.Training, t => t.IsTestUser == false && t.IsZhiZhun) + + //测试用户 或者内部正式用户 + .WhereIf(trialType == TrialType.NoneOfficial, t => t.IsTestUser == true || (t.IsTestUser == false && t.IsZhiZhun)) + + + + .WhereIf(!string.IsNullOrWhiteSpace(trialUserQuery.UserRealName), t => (t.FullName).Contains(trialUserQuery.UserRealName)) .WhereIf(!string.IsNullOrWhiteSpace(trialUserQuery.UserName), t => t.UserName.Contains(trialUserQuery.UserName)) diff --git a/IRaCIS.Core.Application/Triggers/AddlTrialUserTrigger.cs b/IRaCIS.Core.Application/Triggers/AddlTrialUserTrigger.cs index 528f3bd09..2ca86d9ab 100644 --- a/IRaCIS.Core.Application/Triggers/AddlTrialUserTrigger.cs +++ b/IRaCIS.Core.Application/Triggers/AddlTrialUserTrigger.cs @@ -33,10 +33,11 @@ namespace IRaCIS.Core.Application.Triggers //批量添加的时候,使用Find 不会多次查询,优先从跟踪的内存中查找 var trialInfo = await _trialRepository.FindAsync(trialUser.TrialId); - if(trialInfo.TrialType==Domain.Share.TrialType.OfficialTrial || trialInfo.TrialType == Domain.Share.TrialType.Training ) + // 必须包在同一个事务,有的时候是数据库还没用户,不能直接查询数据库 + var user = await _userRepository.FindAsync(trialUser.UserId); + + if (trialInfo.TrialType == Domain.Share.TrialType.OfficialTrial || trialInfo.TrialType == Domain.Share.TrialType.Training) { - // 必须包在同一个事务,有的时候是数据库还没用户,不能直接查询数据库 - var user = await _userRepository.FindAsync(trialUser.UserId); if (user.IsTestUser) { @@ -44,6 +45,16 @@ namespace IRaCIS.Core.Application.Triggers } } + + if (trialInfo.TrialType == TrialType.NoneOfficial) + { + + if (user.IsTestUser == false && user.IsZhiZhun == false) + { + throw new BusinessValidationFailedException("测试项目 不允许加入外部正式用户 "); + + } + } } } } diff --git a/IRaCIS.Core.Domain/Management/User.cs b/IRaCIS.Core.Domain/Management/User.cs index 2e410c5a0..ede2ff587 100644 --- a/IRaCIS.Core.Domain/Management/User.cs +++ b/IRaCIS.Core.Domain/Management/User.cs @@ -42,6 +42,9 @@ namespace IRaCIS.Core.Domain.Models public DateTime? LastLoginTime { get; set; } public Guid UserTypeId { get; set; } = Guid.Empty; + + + // ڲû ⲿû public bool IsZhiZhun { get; set; } public UserTypeEnum UserTypeEnum { get; set; } diff --git a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs index 5c08d07d7..a29dd95ad 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs @@ -392,35 +392,83 @@ namespace IRaCIS.Core.Infra.EFCore.Common }); } + //项目器官 - foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(OrganTrialInfo))) + + if (entitys.Any(x => x.Entity.GetType() == typeof(OrganTrialInfo))) { - var type = GetEntityAuditOpt(item); - - var entity = item.Entity as OrganTrialInfo; + var organTrialEntityEnrtyList = entitys.Where(x => x.Entity.GetType() == typeof(OrganTrialInfo)); var extraIdentification = string.Empty; - if (_userInfo.RequestUrl != "OrganInfo/batchAddTrialOrgan" && type == AuditOpt.Add) + + //同步添加 + if (_userInfo.RequestUrl != "OrganInfo/batchAddTrialOrgan" && organTrialEntityEnrtyList.Any( t=>GetEntityAuditOpt(t) == AuditOpt.Add) ) { extraIdentification = "/Auto"; + + + + var list = organTrialEntityEnrtyList.Select(t => t.Entity as OrganTrialInfo); + + var organIdList = list.Select(t => t.OrganInfoId).ToList(); + + var organList = await _dbContext.OrganInfo.Where(x => organIdList.Contains(x.Id)).ToListAsync(); + + + var firstEntity = list.FirstOrDefault(); + + var cloneEntity = firstEntity.Clone(); + + //保证Id 唯一 + cloneEntity.Id = IdentifierHelper.CreateGuid(firstEntity.TrialId.ToString(), firstEntity.TrialCriterionId.ToString()); + + await InsertInspection(cloneEntity, AuditOpt.Add, x => new InspectionConvertDTO() + { + IsDistinctionInterface = false, + + TrialReadingCriterionId = cloneEntity.TrialCriterionId, + + ObjectRelationParentId = cloneEntity.TrialCriterionId, + + ObjectRelationParentId2 = cloneEntity.OrganInfoId, + + ExtraIndentification = extraIdentification + + }, new + { + QuestionAnswerList = list.Join(organList, t => t.OrganInfoId, u => u.Id, (t, u) => u).OrderBy(t => t.ShowOrder).ToList(), + }); + } - - await InsertInspection(entity, type, x => new InspectionConvertDTO() + else { - IsDistinctionInterface = false, + //手动操作 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(OrganTrialInfo))) + { + var type = GetEntityAuditOpt(item); - TrialReadingCriterionId = entity.TrialCriterionId, + var entity = item.Entity as OrganTrialInfo; - ObjectRelationParentId = entity.TrialCriterionId, + await InsertInspection(entity, type, x => new InspectionConvertDTO() + { + IsDistinctionInterface = false, - ObjectRelationParentId2 = entity.OrganInfoId, + TrialReadingCriterionId = entity.TrialCriterionId, - ExtraIndentification =extraIdentification + ObjectRelationParentId = entity.TrialCriterionId, - }); + ObjectRelationParentId2 = entity.OrganInfoId, + + ExtraIndentification = extraIdentification + + }); + } + } } + + // 项目 系统公用表 //病灶管理 区分项目 还是系统的 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(CriterionNidus))) @@ -1987,7 +2035,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common await InsertInspection(cloneEntity, type, x => new InspectionConvertDTO() { - VisitTaskId = x.TaskId, + VisitTaskId = x.GlobalTaskId, TrialReadingCriterionId = trialReadingCriterionId, ObjectRelationParentId = x.TaskId, }, new { GlobalAnswerList = objList } );