diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs index e3ef59ace..01a485cd1 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs @@ -7,6 +7,7 @@ using System; using IRaCIS.Core.Domain.Share; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using Newtonsoft.Json; namespace IRaCIS.Core.Application.ViewModel { @@ -235,7 +236,10 @@ namespace IRaCIS.Core.Application.ViewModel public bool IsAssignedDoctorUser { get; set; } - public bool IsAssignDoctorApplyedTask => DoctorUserList.All(t => t.IsAssignDoctorApplyedTask) && DoctorUserList.Count > 0; + [JsonIgnore] + public bool IsJudge { get; set; } + + public bool IsAssignDoctorApplyedTask => DoctorUserList.Where(t=> IsJudge? t.ArmEnum==Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).All(t => t.IsAssignDoctorApplyedTask) && DoctorUserList.Where(t => IsJudge ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Count() > 0; public List DoctorUserIdList => DoctorUserList.Select(t => t.DoctorUserId).ToList(); diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs index 2ddc40bf9..f4984860b 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).FirstOrDefault(); + var trialTaskConfig= _trialRepository.Where(t=>t.Id==queryTaskAllocationRule.TrialId).ProjectTo(_mapper.ConfigurationProvider, new { isJudgeDoctor = queryTaskAllocationRule.IsJudgeDoctor }).FirstOrDefault(); return (await taskAllocationRuleQueryable.ToListAsync(), trialTaskConfig); } @@ -65,7 +65,7 @@ namespace IRaCIS.Core.Application.Service { var verifyExp1 = new EntityVerifyExp() { - VerifyExp = t => t.DoctorUserId == addOrEditTaskAllocationRule.DoctorUserId && t.TrialId== addOrEditTaskAllocationRule.TrialId, + VerifyExp = t => t.DoctorUserId == addOrEditTaskAllocationRule.DoctorUserId && t.TrialId== addOrEditTaskAllocationRule.TrialId && t.IsJudgeDoctor, VerifyMsg = "已有该医生配置,不允许继续增加" }; @@ -79,7 +79,7 @@ namespace IRaCIS.Core.Application.Service [HttpDelete("{taskAllocationRuleId:guid}/{isJudgeDoctor:bool}")] public async Task DeleteTaskAllocationRule(Guid taskAllocationRuleId, bool isJudgeDoctor ) { - if(await _taskAllocationRuleRepository.Where(t => t.Id == taskAllocationRuleId && t.IsJudgeDoctor== isJudgeDoctor).AnyAsync(t => t.DoctorVisitTaskList.Count() > 0)) + if(await _taskAllocationRuleRepository.Where(t => t.Id == taskAllocationRuleId ).AnyAsync(t => t.DoctorVisitTaskList.Where(t=>isJudgeDoctor?t.ArmEnum==Domain.Share.Arm.JudgeArm: t.ArmEnum != Domain.Share.Arm.JudgeArm).Count() > 0)) { return ResponseOutput.NotOk("已分配任务给该医生,不允许删除"); } diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index 711c4aa59..75e84fc23 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -333,7 +333,7 @@ namespace IRaCIS.Core.Application.Service .WhereIf(querySubjectAssign.DoctorUserId != null && querySubjectAssign.IsJudgeDoctor == false, t => t.SubjectDoctorList.Where(t=>t.ArmEnum != Arm.JudgeArm).Any(t => t.DoctorUserId == querySubjectAssign.DoctorUserId)) .WhereIf(querySubjectAssign.DoctorUserId != null && querySubjectAssign.IsJudgeDoctor, t => t.SubjectDoctorList.Where(t => t.ArmEnum == Arm.JudgeArm).Any(t => t.DoctorUserId == querySubjectAssign.DoctorUserId)) - .ProjectTo(_mapper.ConfigurationProvider); + .ProjectTo(_mapper.ConfigurationProvider, new { isJudgeDoctor = querySubjectAssign.IsJudgeDoctor }); var pageList = await subjectQuery.ToPagedListAsync(querySubjectAssign.PageIndex, querySubjectAssign.PageSize, string.IsNullOrWhiteSpace(querySubjectAssign.SortField) ? nameof(querySubjectAssign.SubjectId) : querySubjectAssign.SortField, querySubjectAssign.Asc); @@ -560,7 +560,7 @@ namespace IRaCIS.Core.Application.Service .Select(t => new { SubjectId = t.Id, DoctorUserList = t.SubjectDoctorList.Where(t => isJudge? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Select(t => new { t.DoctorUserId, t.ArmEnum }), - IsApplyed = t.SubjectVisitTaskList.Where(t => isJudge? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Any(c => c.DoctorUserId != null) + IsApplyed = t.SubjectDoctorList.Where(t => isJudge? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).SelectMany(t=>t.SubjectArmVisitTaskList).Any(c => c.DoctorUserId != null) }).ToList(); //已产生任务的Subject数量(裁判情况下,就是产生裁判任务Subject 的数量) diff --git a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs index 161a658d1..b4161f7cc 100644 --- a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs @@ -139,10 +139,11 @@ namespace IRaCIS.Core.Application.Service .ForMember(o => o.SubjectId, t => t.MapFrom(u => u.Id)) .ForMember(o => o.TrialSiteCode, t => t.MapFrom(u => u.TrialSite.TrialSiteCode)) .ForMember(o => o.SubjectCode, t => t.MapFrom(u => u.Code)) - .ForMember(o => o.IsAssignedDoctorUser, t => t.MapFrom(u => u.SubjectDoctorList.Any())) + .ForMember(o => o.IsJudge, t => t.MapFrom(u => isJudgeDoctor)) + .ForMember(o => o.IsAssignedDoctorUser, t => t.MapFrom(u => u.SubjectDoctorList.Where(t=>isJudgeDoctor? t.ArmEnum == Arm.JudgeArm: t.ArmEnum != Arm.JudgeArm).Any())) - .ForMember(o => o.DoctorUserList, t => t.MapFrom(u => u.SubjectDoctorList.OrderBy(t => t.ArmEnum))); + .ForMember(o => o.DoctorUserList, t => t.MapFrom(u => u.SubjectDoctorList.Where(t => isJudgeDoctor ? true : t.ArmEnum != Arm.JudgeArm).OrderBy(t => t.ArmEnum))); CreateMap() //.ForMember(o => o.AssignTime, t => t.MapFrom(u => u.AssignTime))