diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs index 806207274..9bacbbbab 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs @@ -44,7 +44,7 @@ namespace IRaCIS.Core.Application.ViewModel public Guid DoctorUserId { get; set; } - public List ArmList { get; set; } + public List ArmList { get; set; } = new List(); //public double? TargetCount => TotalTaskCount * PlanReadingRatio * 0.01; diff --git a/IRaCIS.Core.Application/Triggers/SubjectVisitCheckPassedTrigger.cs b/IRaCIS.Core.Application/Triggers/SubjectVisitCheckPassedTrigger.cs index 799c71e23..9a66856e7 100644 --- a/IRaCIS.Core.Application/Triggers/SubjectVisitCheckPassedTrigger.cs +++ b/IRaCIS.Core.Application/Triggers/SubjectVisitCheckPassedTrigger.cs @@ -122,27 +122,31 @@ namespace IRaCIS.Core.Application.Triggers { //排除已经入选其他Arm的阅片人 - //是否有做过Arm1的医生 - if (allocateStat.Any(t => t.ArmList.Any(t => t == 1))) + //是否有做过Arm1的医生 有新的医生未分配 按照最优法找 + if (allocateStat.Any(t => t.ArmList.Any(t => t == 1)) && !allocateStat.Any(t=>t.ArmList.Count==0)) { - //找到最优的需要分配任务的医生 - 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; + + task1.DoctorUserId = allocateStat.Where(t => t.ArmList.Any(t => t == 1)).OrderByDescending(t => t.TotalTaskCount * t.PlanReadingRatio * 0.01 - t.SelfTaskCount).ThenByDescending(t => t.PlanReadingRatio).FirstOrDefault().DoctorUserId; } else { - task1.DoctorUserId = allocateStat.OrderByDescending(t => t.PlanReadingRatio).ThenBy(t => t.TotalTaskCount * t.PlanReadingRatio * 0.01 - t.TotalTaskCount).FirstOrDefault().DoctorUserId; + //找到最优的需要分配任务的医生 + task1.DoctorUserId = allocateStat.OrderByDescending(t => t.TotalTaskCount * t.PlanReadingRatio * 0.01 - t.SelfTaskCount).ThenByDescending(t => t.PlanReadingRatio).FirstOrDefault().DoctorUserId; + + allocateStat.FirstOrDefault(t => t.DoctorUserId == task1.DoctorUserId).ArmList.Add(1); } - //是否有做过Arm2的医生 - if (allocateStat.Any(t => t.ArmList.Any(t => t == 2))) + //是否有做过Arm2的医生 有新的医生未分配 按照最优法找 + if (allocateStat.Any(t => t.ArmList.Any(t => t == 2)) && !allocateStat.Any(t => t.ArmList.Count == 0)) { - //找到最优的需要分配任务的医生 - 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; + + task2.DoctorUserId = allocateStat.Where(t => t.ArmList.Any(t => t == 2)).OrderByDescending(t => t.TotalTaskCount * t.PlanReadingRatio * 0.01 - t.SelfTaskCount).ThenByDescending(t => t.PlanReadingRatio).FirstOrDefault().DoctorUserId; } else { - task2.DoctorUserId = allocateStat.OrderByDescending(t => t.PlanReadingRatio).ThenBy(t => t.TotalTaskCount * t.PlanReadingRatio * 0.01 - t.TotalTaskCount).Skip(1).FirstOrDefault().DoctorUserId; + //找到最优的需要分配任务的医生 + task2.DoctorUserId = allocateStat.OrderByDescending(t => t.TotalTaskCount * t.PlanReadingRatio * 0.01 - t.SelfTaskCount).ThenByDescending(t => t.PlanReadingRatio).Skip(1).FirstOrDefault().DoctorUserId; } }