diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs index 4bc2e0f74..7b380cde5 100644 --- a/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs @@ -40,7 +40,7 @@ namespace IRaCIS.Core.Application.Service .ProjectTo(_mapper.ConfigurationProvider); - var trialTaskConfig= _trialRepository.Where(t=>t.Id==queryTaskAllocationRule.TrialId).ProjectTo(_mapper.ConfigurationProvider); + var trialTaskConfig= _trialRepository.Where(t=>t.Id==queryTaskAllocationRule.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefault(); return (await taskAllocationRuleQueryable.ToListAsync(), trialTaskConfig); } @@ -51,7 +51,7 @@ namespace IRaCIS.Core.Application.Service { var verifyExp1 = new EntityVerifyExp() { - VerifyExp = t => t.DoctorUserId == addOrEditTaskAllocationRule.DoctorUserId, + VerifyExp = t => t.DoctorUserId == addOrEditTaskAllocationRule.DoctorUserId && t.TrialId== addOrEditTaskAllocationRule.TrialId, VerifyMsg = "已有该医生配置,不允许继续增加" }; diff --git a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs index 088df5811..cef67fa25 100644 --- a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs @@ -16,12 +16,12 @@ namespace IRaCIS.Core.Application.Service .ForMember(o => o.UserName, t => t.MapFrom(u => u.DoctorUser.UserName)) .ForMember(o => o.FullName, t => t.MapFrom(u => u.DoctorUser.FullName)) .ForMember(o => o.UserTypeShortName, t => t.MapFrom(u => u.DoctorUser.UserTypeRole.UserTypeShortName)) - .ForMember(o => o.ArmList, t => t.MapFrom(u => u.VisitTaskList.Select(t=>t.ArmEnum).Distinct())) + .ForMember(o => o.ArmList, t => t.MapFrom(u => u.VisitTaskList.Where(c=>c.TrialId==u.TrialId).Select(t=>t.ArmEnum).Distinct())) .ForMember(o => o.TotalTaskCount, t => t.MapFrom(u => u.Trial.VisitTaskList.Count())) .ForMember(o => o.SelfTaskCount, t => t.MapFrom(u => u.Trial.VisitTaskList.Count(t=>t.DoctorUserId==u.DoctorUserId))); CreateMap() - .ForMember(o => o.ArmList, t => t.MapFrom(u => u.VisitTaskList.Select(t => t.ArmEnum).Distinct())) + .ForMember(o => o.ArmList, t => t.MapFrom(u => u.VisitTaskList.Where(c => c.TrialId == u.TrialId).Select(t => t.ArmEnum).Distinct())) .ForMember(o => o.TotalTaskCount, t => t.MapFrom(u => u.Trial.VisitTaskList.Count())) .ForMember(o => o.SelfTaskCount, t => t.MapFrom(u => u.Trial.VisitTaskList.Count(t => t.DoctorUserId == u.DoctorUserId))); diff --git a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs index 33bd9b5e8..249d1fd10 100644 --- a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs +++ b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs @@ -1159,6 +1159,11 @@ namespace IRaCIS.Core.Application.Image.QA // 不一致性核查 就CVPassed ToForward 否则就是待核查 dbSubjectVisit.CheckState = trialConfig.IsImageConsistencyVerification ? CheckStateEnum.ToCheck : CheckStateEnum.CVPassed; + if(dbSubjectVisit.CheckState== CheckStateEnum.CVPassed) + { + dbSubjectVisit.CheckPassedTime = DateTime.Now; + } + dbSubjectVisit.ForwardState = trialConfig.IsImageConsistencyVerification ? ForwardStateEnum.None : ForwardStateEnum.ToForward; } diff --git a/IRaCIS.Core.Application/Triggers/SubjectVisitCheckPassedTrigger.cs b/IRaCIS.Core.Application/Triggers/SubjectVisitCheckPassedTrigger.cs index d5db333f4..799c71e23 100644 --- a/IRaCIS.Core.Application/Triggers/SubjectVisitCheckPassedTrigger.cs +++ b/IRaCIS.Core.Application/Triggers/SubjectVisitCheckPassedTrigger.cs @@ -100,6 +100,17 @@ namespace IRaCIS.Core.Application.Triggers }); + if (trialConfig.TaskAllocateDefaultState == TaskAllocateDefaultState.Allocated) + { + task1.TaskState =TaskState.Allocated; + task2.TaskState = TaskState.Allocated; + } + else if (trialConfig.TaskAllocateDefaultState == TaskAllocateDefaultState.InitAllocated) + { + task1.TaskState = TaskState.InitAllocated; + task2.TaskState = TaskState.InitAllocated; + } + if (trialConfig.TaskAllocateObjEnum == TaskAllocateObj.Subject) { @@ -115,25 +126,25 @@ namespace IRaCIS.Core.Application.Triggers if (allocateStat.Any(t => t.ArmList.Any(t => t == 1))) { //找到最优的需要分配任务的医生 - task1.DoctorUserId = allocateStat.Where(t => t.ArmList.Any(t => t == 1)).OrderByDescending(t => t.TotalTaskCount * t.PlanReadingRatio * 0.01 - t.TotalTaskCount).FirstOrDefault().DoctorUserId; + task1.DoctorUserId = allocateStat.Where(t => t.ArmList.Any(t => t == 1)).OrderByDescending(t=>t.PlanReadingRatio).ThenBy(t => t.TotalTaskCount * t.PlanReadingRatio * 0.01 - t.TotalTaskCount).FirstOrDefault().DoctorUserId; } else { - task1.DoctorUserId = allocateStat.OrderByDescending(t => t.TotalTaskCount * t.PlanReadingRatio * 0.01 - t.TotalTaskCount).FirstOrDefault().DoctorUserId; + task1.DoctorUserId = allocateStat.OrderByDescending(t => t.PlanReadingRatio).ThenBy(t => t.TotalTaskCount * t.PlanReadingRatio * 0.01 - t.TotalTaskCount).FirstOrDefault().DoctorUserId; } //是否有做过Arm2的医生 if (allocateStat.Any(t => t.ArmList.Any(t => t == 2))) { //找到最优的需要分配任务的医生 - task2.DoctorUserId = allocateStat.Where(t => t.ArmList.Any(t => t == 2)).OrderByDescending(t => t.TotalTaskCount * t.PlanReadingRatio * 0.01 - t.TotalTaskCount).FirstOrDefault().DoctorUserId; + task2.DoctorUserId = allocateStat.Where(t => t.ArmList.Any(t => t == 2)).OrderByDescending(t => t.PlanReadingRatio).ThenBy(t => t.TotalTaskCount * t.PlanReadingRatio * 0.01 - t.TotalTaskCount).FirstOrDefault().DoctorUserId; } else { - task2.DoctorUserId = allocateStat.OrderByDescending(t => t.TotalTaskCount * t.PlanReadingRatio * 0.01 - t.TotalTaskCount).Skip(1).FirstOrDefault().DoctorUserId; + task2.DoctorUserId = allocateStat.OrderByDescending(t => t.PlanReadingRatio).ThenBy(t => t.TotalTaskCount * t.PlanReadingRatio * 0.01 - t.TotalTaskCount).Skip(1).FirstOrDefault().DoctorUserId; } - + } else { @@ -143,7 +154,7 @@ namespace IRaCIS.Core.Application.Triggers } //手动分配的时候 如果只分配了Arm1 没有分配Arm2 就会有问题 - if (allocateSubjectArmList.Any(t => t.ArmEnum == 1) && allocateSubjectArmList.Any(t => t.ArmEnum == 2)) + if (!(allocateSubjectArmList.Any(t => t.ArmEnum == 1) && allocateSubjectArmList.Any(t => t.ArmEnum == 2))) { throw new BusinessValidationFailedException("请确认是否改了配置,或者手动分配时,只分配了一个Arm "); } @@ -153,7 +164,8 @@ namespace IRaCIS.Core.Application.Triggers task2.DoctorUserId = allocateSubjectArmList.FirstOrDefault(t => t.ArmEnum == 2).DoctorUserId; } - + task1.AllocateTime = DateTime.Now; + task2.AllocateTime = DateTime.Now; } } diff --git a/IRaCIS.Core.Domain.Share/Allocation/AllocationRelation.cs b/IRaCIS.Core.Domain.Share/Allocation/AllocationRelation.cs index e9940f651..c95481100 100644 --- a/IRaCIS.Core.Domain.Share/Allocation/AllocationRelation.cs +++ b/IRaCIS.Core.Domain.Share/Allocation/AllocationRelation.cs @@ -20,7 +20,7 @@ namespace IRaCIS.Core.Domain.Share NotAllocate = 0, - + InitAllocated = 1, //已分配 Allocated = 2,