From ce988d44d754e8681aaba472827116fb9a9147d3 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 21 Jun 2022 09:02:42 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A3=81=E5=88=A4=E4=BB=BB=E5=8A=A1=E5=88=86?= =?UTF-8?q?=E9=85=8D=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DTO/TaskAllocationRuleViewModel.cs | 32 ++------- .../Allocation/DTO/VisitTaskViewModel.cs | 3 +- .../Allocation/TaskAllocationRuleService.cs | 16 ++--- .../Service/Allocation/_MapConfig.cs | 72 +++++++++++-------- 4 files changed, 54 insertions(+), 69 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs index 3becd0c7c..9cfb652d8 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs @@ -24,11 +24,12 @@ namespace IRaCIS.Core.Application.ViewModel public DateTime UpdateTime { get; set; } public Guid UpdateUserId { get; set; } + } - - + public class DoctorVisitTaskStatView: TaskAllocationRuleView + { //该医生已经应用的 Subject数量 public int? SelfApplyedSubjectCount { get; set; } @@ -74,11 +75,6 @@ namespace IRaCIS.Core.Application.ViewModel //总任务数 public int? TotalTaskCount { get; set; } - - - - - } @@ -86,33 +82,13 @@ namespace IRaCIS.Core.Application.ViewModel - public class AllocateInfo - { - public int? TotalTaskCount { get; set; } - - public int? SelfTaskCount { get; set; } - - public int PlanReadingRatio { get; set; } - - public Guid DoctorUserId { get; set; } - - //public List ArmList { get; set; } = new List(); - - //public double? TargetCount => TotalTaskCount * PlanReadingRatio * 0.01; - - //public double? Diff => TargetCount - SelfTaskCount; - - - } - - ///TaskAllocationRuleQuery 列表查询参数模型 public class TaskAllocationRuleQuery { [NotDefault] public Guid TrialId { get; set; } - public bool? IsJudgeDoctor { get; set; } + public bool IsJudgeDoctor { get; set; } } /// TaskAllocationRuleAddOrEdit 列表查询参数模型 diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs index 36e400676..70bff0ba6 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs @@ -312,7 +312,7 @@ namespace IRaCIS.Core.Application.ViewModel { public Guid TrialId { get; set; } - public bool? IsJudgeDoctor { get; set; } + public bool IsJudgeDoctor { get; set; } public List SubjectIdList { get; set; } = new List(); } @@ -322,6 +322,7 @@ namespace IRaCIS.Core.Application.ViewModel { public Guid TrialId { get; set; } + public List SubjectDoctorUserList { get; set; } = new List(); } diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs index 0225efa46..2ddc40bf9 100644 --- a/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs @@ -34,11 +34,10 @@ namespace IRaCIS.Core.Application.Service } [HttpPost] - public async Task<(List,object)> GetTaskAllocationRuleList(TaskAllocationRuleQuery queryTaskAllocationRule) + public async Task<(List,object)> GetTaskAllocationRuleList(TaskAllocationRuleQuery queryTaskAllocationRule) { - var taskAllocationRuleQueryable = _taskAllocationRuleRepository.Where(t=>t.TrialId== queryTaskAllocationRule.TrialId) - .WhereIf(queryTaskAllocationRule.IsJudgeDoctor!=null ,t=>t.IsJudgeDoctor== queryTaskAllocationRule.IsJudgeDoctor) - .ProjectTo(_mapper.ConfigurationProvider); + var taskAllocationRuleQueryable = _taskAllocationRuleRepository.Where(t=>t.TrialId== queryTaskAllocationRule.TrialId && t.IsJudgeDoctor == queryTaskAllocationRule.IsJudgeDoctor) + .ProjectTo(_mapper.ConfigurationProvider); var trialTaskConfig= _trialRepository.Where(t=>t.Id==queryTaskAllocationRule.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefault(); @@ -48,15 +47,14 @@ namespace IRaCIS.Core.Application.Service /// - /// 获取应用Subject后 医生比率情况 + /// 获取访视任务 应用Subject后 医生比率情况 /// /// [HttpPost] - public async Task> GetSubjectApplyDoctorTaskStatList(ApplySubjectCommand assignConfirmCommand) + public async Task> GetSubjectApplyDoctorTaskStatList(ApplySubjectCommand assignConfirmCommand) { - var taskAllocationRuleQueryable = _taskAllocationRuleRepository.Where(t => t.TrialId == assignConfirmCommand.TrialId) - .WhereIf(assignConfirmCommand.IsJudgeDoctor != null, t => t.IsJudgeDoctor == assignConfirmCommand.IsJudgeDoctor) - .ProjectTo(_mapper.ConfigurationProvider, new { subjectIdList = assignConfirmCommand.SubjectIdList }); + var taskAllocationRuleQueryable = _taskAllocationRuleRepository.Where(t => t.TrialId == assignConfirmCommand.TrialId && t.IsJudgeDoctor == assignConfirmCommand.IsJudgeDoctor) + .ProjectTo(_mapper.ConfigurationProvider, new { subjectIdList = assignConfirmCommand.SubjectIdList , isJudgeDoctor = assignConfirmCommand.IsJudgeDoctor }); return await taskAllocationRuleQueryable.ToListAsync(); } diff --git a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs index 61f35bdc7..161a658d1 100644 --- a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs @@ -12,43 +12,60 @@ namespace IRaCIS.Core.Application.Service public AllocationConfig() { - List subjectIdList=new List (); - CreateMap() + .ForMember(o => o.UserCode, t => t.MapFrom(u => u.DoctorUser.UserCode)) + .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)); + + List subjectIdList=new List (); + bool isJudgeDoctor = false; + + + CreateMap() .ForMember(o => o.UserCode, t => t.MapFrom(u => u.DoctorUser.UserCode)) .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.DoctorVisitTaskList.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.ApplyedTotalTaskCount, t => t.MapFrom(u => u.Trial.VisitTaskList.Count(t => t.DoctorUserId != null))) + .ForMember(o => o.SelfUndoTaskCount, t => t.MapFrom(u => u.Trial.VisitTaskList.Count(t => t.DoctorUserId == u.DoctorUserId && t.ReadingTaskState != ReadingTaskState.HaveSigned))) + .ForMember(o => o.TotalSubjectCount, t => t.MapFrom(u => u.Trial.SubjectList.Count())) + .ForMember(o => o.SelfApplyedTaskCount, t => t.MapFrom(u => u.Trial.VisitTaskList.Count(t => t.DoctorUserId == u.DoctorUserId))) + .ForMember(o => o.ApplyedTotalTaskCount, t => t.MapFrom(u => u.Trial.VisitTaskList.Count(t => t.DoctorUserId != null))) + + .ForMember(o => o.SelfApplyedSubjectCount, t => t.MapFrom(u => u.Trial.SubjectDoctorUserList.Where(t => t.DoctorUserId == u.DoctorUserId && t.SubjectArmVisitTaskList.Any(c => c.DoctorUserId != null)).Count())) + .ForMember(o => o.SelfSubjectCount, t => t.MapFrom(u => u.Trial.SubjectDoctorUserList.Where(t => t.DoctorUserId == u.DoctorUserId).Count())) + + .ForMember(o => o.ApplyedTotalSubjectCount, t => t.MapFrom(u => u.Trial.SubjectList.Count(c => c.SubjectVisitTaskList.Any(d => d.DoctorUserId != null)))) + + + + //该医生未应用Subject 数量 + .ForMember(o => o.WaitApplySelfSubjectCount, t => t.MapFrom(u => + subjectIdList.Count == 0 ? u.Trial.SubjectDoctorUserList.Where(t => t.DoctorUserId == u.DoctorUserId && t.SubjectArmVisitTaskList.Where(t=> isJudgeDoctor? t.ArmEnum==Arm.JudgeArm:t.ArmEnum!= Arm.JudgeArm).Any(c => c.DoctorUserId == null)).Count() + : u.Trial.SubjectDoctorUserList.Where(t => t.DoctorUserId == u.DoctorUserId && subjectIdList.Contains(t.SubjectId) && t.SubjectArmVisitTaskList.Where(t => isJudgeDoctor ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Any(c => c.DoctorUserId == null)).Count() + )) + + + .ForMember(o => o.WaitApplyTotalSubjectCount, t => t.MapFrom(u => + subjectIdList.Count == 0 ? u.Trial.SubjectList.Where(t => t.SubjectVisitTaskList.Where(t => isJudgeDoctor ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Any(c => c.DoctorUserId == null)).Count() + : u.Trial.SubjectList.Where(t => subjectIdList.Contains(t.Id) && t.SubjectVisitTaskList.Where(t => isJudgeDoctor ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Any(c => c.DoctorUserId == null)).Count() + )) + .ForMember(o => o.WaitApplySelfTaskCount, t => t.MapFrom(u => - subjectIdList.Count==0? u.Trial.SubjectDoctorUserList.Where(d => d.DoctorUserId == u.DoctorUserId).SelectMany(t => t.SubjectArmVisitTaskList.Where(t => t.DoctorUserId == null)).Count() - : u.Trial.SubjectDoctorUserList.Where(d => d.DoctorUserId == u.DoctorUserId && subjectIdList.Contains(d.SubjectId)).SelectMany(t => t.SubjectArmVisitTaskList.Where(t => t.DoctorUserId == null)).Count() + subjectIdList.Count==0? u.Trial.SubjectDoctorUserList.Where(d => d.DoctorUserId == u.DoctorUserId).SelectMany(t => t.SubjectArmVisitTaskList.Where(t => isJudgeDoctor ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Where(t => t.DoctorUserId == null)).Count() + : u.Trial.SubjectDoctorUserList.Where(d => d.DoctorUserId == u.DoctorUserId && subjectIdList.Contains(d.SubjectId)).SelectMany(t => t.SubjectArmVisitTaskList.Where(t => isJudgeDoctor ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Where(t => t.DoctorUserId == null)).Count() )) .ForMember(o => o.WaitApplyTotalTaskCount, t => t.MapFrom(u => - subjectIdList.Count == 0 ? u.Trial.VisitTaskList.Where(t => t.DoctorUserId == null).Count() - : u.Trial.VisitTaskList.Where(t => t.DoctorUserId == null && subjectIdList.Contains(t.SubjectId)).Count() )) + subjectIdList.Count == 0 ? u.Trial.VisitTaskList.Where(t => isJudgeDoctor ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Where(t => t.DoctorUserId == null).Count() + : u.Trial.VisitTaskList.Where(t => isJudgeDoctor ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Where(t => t.DoctorUserId == null && subjectIdList.Contains(t.SubjectId)).Count() )) - + - .ForMember(o => o.SelfUndoTaskCount, t => t.MapFrom(u => u.Trial.VisitTaskList.Count(t => t.DoctorUserId == u.DoctorUserId && t.ReadingTaskState != ReadingTaskState.HaveSigned))) - .ForMember(o => o.SelfApplyedTaskCount, t => t.MapFrom(u => u.Trial.VisitTaskList.Count(t => t.DoctorUserId == u.DoctorUserId))) - .ForMember(o => o.TotalSubjectCount, t => t.MapFrom(u => u.Trial.SubjectList.Count())) - .ForMember(o => o.ApplyedTotalSubjectCount, t => t.MapFrom(u => u.Trial.SubjectList.Count(c => c.SubjectVisitTaskList.Any(d => d.DoctorUserId !=null)))) - .ForMember(o => o.WaitApplyTotalSubjectCount, t => t.MapFrom(u => - subjectIdList.Count == 0 ? u.Trial.SubjectList.Where(t => t.SubjectVisitTaskList.Any(c => c.DoctorUserId == null)).Count() - : u.Trial.SubjectList.Where(t => subjectIdList.Contains(t.Id) && t.SubjectVisitTaskList.Any(c => c.DoctorUserId == null)).Count() - )) - - .ForMember(o => o.SelfSubjectCount, t => t.MapFrom(u => u.Trial.SubjectDoctorUserList.Where(t => t.DoctorUserId == u.DoctorUserId).Count())) - .ForMember(o => o.SelfApplyedSubjectCount, t => t.MapFrom(u => u.Trial.SubjectDoctorUserList.Where(t => t.DoctorUserId == u.DoctorUserId && t.SubjectArmVisitTaskList.Any(c => c.DoctorUserId != null)).Count())) - - .ForMember(o => o.WaitApplySelfSubjectCount, t => t.MapFrom(u => - subjectIdList.Count == 0 ? u.Trial.SubjectDoctorUserList.Where(t => t.DoctorUserId == u.DoctorUserId && t.SubjectArmVisitTaskList.Any(c=>c.DoctorUserId ==null)).Count() - : u.Trial.SubjectDoctorUserList.Where(t => t.DoctorUserId == u.DoctorUserId && subjectIdList.Contains(t.SubjectId) && t.SubjectArmVisitTaskList.Any(c => c.DoctorUserId == null)).Count() - )) + + ; @@ -56,13 +73,6 @@ namespace IRaCIS.Core.Application.Service - CreateMap() - //.ForMember(o => o.ArmList, t => t.MapFrom(u => u.DoctorVisitTaskList.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()