From a340b0f21771586a7897d9d92361fbdf6462bfcd Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 16 Jun 2022 17:38:15 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=96=B0=E5=8F=91=E5=B8=83=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=88=86=E9=85=8D=E7=AE=97=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Allocation/VisitTaskService.cs | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index 2b7fa419..d3bdf2d1 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -751,8 +751,8 @@ namespace IRaCIS.Core.Application.Service } - //仅仅分配未应用的 - foreach (var subject in subjectList.Where(t => t.IsApplyed == false)) + //仅仅分配未应用的 而且 没有没有分配医生的 + foreach (var subject in subjectList.Where(t => t.IsApplyed == false && !t.DoctorUserList.Any())) { //该Subject 已经分配的医生数量 var hasAssignDoctorCount = subject.DoctorUserList.Count(); @@ -818,23 +818,29 @@ namespace IRaCIS.Core.Application.Service } - await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = trialId, SubjectId = subject.SubjectId, DoctorUserId = allocateDoctorList[0].DoctorUserId, ArmEnum = doctor1Arm, AssignTime = DateTime.Now }); + //if(!waitAllocationDoctorList.Where(t=>t.DoctorUserId== allocateDoctorList[0].DoctorUserId).SelectMany(u => u.SubjectArmList).Any(t => t.SubjectId == subject.SubjectId)) + //{ + await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = trialId, SubjectId = subject.SubjectId, DoctorUserId = allocateDoctorList[0].DoctorUserId, ArmEnum = doctor1Arm, AssignTime = DateTime.Now }); + + waitAllocationDoctorList.FirstOrDefault(t => t.DoctorUserId == allocateDoctorList[0].DoctorUserId).SubjectArmList.Add(new SubjectArm() + { + SubjectId = subject.SubjectId, + ArmEnum = doctor1Arm + }); + //} - await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = trialId, SubjectId = subject.SubjectId, DoctorUserId = allocateDoctorList[1].DoctorUserId, ArmEnum = doctor2Arm, AssignTime = DateTime.Now }); + //if (!waitAllocationDoctorList.Where(t => t.DoctorUserId == allocateDoctorList[1].DoctorUserId).SelectMany(u => u.SubjectArmList).Any(t => t.SubjectId == subject.SubjectId)) + //{ + await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = trialId, SubjectId = subject.SubjectId, DoctorUserId = allocateDoctorList[1].DoctorUserId, ArmEnum = doctor2Arm, AssignTime = DateTime.Now }); + waitAllocationDoctorList.FirstOrDefault(t => t.DoctorUserId == allocateDoctorList[1].DoctorUserId).SubjectArmList.Add(new SubjectArm() + { + SubjectId = subject.SubjectId, + ArmEnum = doctor2Arm + }); + //} - - waitAllocationDoctorList.FirstOrDefault(t => t.DoctorUserId == allocateDoctorList[0].DoctorUserId).SubjectArmList.Add(new SubjectArm() - { - SubjectId = subject.SubjectId, - ArmEnum = doctor1Arm - }); - - waitAllocationDoctorList.FirstOrDefault(t => t.DoctorUserId == allocateDoctorList[1].DoctorUserId).SubjectArmList.Add(new SubjectArm() - { - SubjectId = subject.SubjectId, - ArmEnum = doctor2Arm - }); + }