From cb5f3c00bd91a57e9196e2528e17fe5b712eb94f Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 28 Jul 2022 13:51:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Allocation/DTO/VisitTaskViewModel.cs | 4 + .../Allocation/TaskConsistentRuleService.cs | 90 +++++++++++++------ .../Service/Allocation/VisitTaskService.cs | 4 +- .../Service/Allocation/_MapConfig.cs | 6 ++ 4 files changed, 76 insertions(+), 28 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs index eb492075f..1d3ff86b6 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs @@ -247,6 +247,10 @@ namespace IRaCIS.Core.Application.ViewModel public ReReadingApplyState? ReReadingApplyState { get; set; } + public bool? IsSelfAnalysis { get; set; } + + public Arm? ArmEnum { get; set; } + } diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs index 4cbabed3c..11b13840d 100644 --- a/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs @@ -60,13 +60,16 @@ namespace IRaCIS.Core.Application.Service .WhereIf(queryVisitTask.ReadingCategory != null, t => t.ReadingCategory == queryVisitTask.ReadingCategory) .WhereIf(queryVisitTask.ReadingTaskState != null, t => t.ReadingTaskState == queryVisitTask.ReadingTaskState) .WhereIf(queryVisitTask.TaskAllocationState != null, t => t.TaskAllocationState == queryVisitTask.TaskAllocationState) + .WhereIf(queryVisitTask.IsSelfAnalysis != null, t => t.IsSelfAnalysis == queryVisitTask.IsSelfAnalysis) + .WhereIf(queryVisitTask.ArmEnum != null, t => t.ArmEnum == queryVisitTask.ArmEnum) + .WhereIf(!string.IsNullOrEmpty(queryVisitTask.TrialSiteCode), t => (t.BlindTrialSiteCode.Contains(queryVisitTask.TrialSiteCode) && t.IsAnalysisCreate) || (t.Subject.TrialSite.TrialSiteCode.Contains(queryVisitTask.TrialSiteCode) && t.IsAnalysisCreate == false)) .WhereIf(!string.IsNullOrEmpty(queryVisitTask.TaskName), t => t.TaskName.Contains(queryVisitTask.TaskName) || t.TaskBlindName.Contains(queryVisitTask.TaskName)) .WhereIf(!string.IsNullOrEmpty(queryVisitTask.SubjectCode), t => t.Subject.Code.Contains(queryVisitTask.SubjectCode)) .WhereIf(queryVisitTask.BeginAllocateDate != null, t => t.AllocateTime > queryVisitTask.BeginAllocateDate) .WhereIf(queryVisitTask.EndAllocateDate != null, t => t.AllocateTime < queryVisitTask.EndAllocateDate.Value.AddDays(1)) .ProjectTo(_mapper.ConfigurationProvider); - var defalutSortArray = new string[] { nameof(VisitTask.IsUrgent) + " desc", nameof(VisitTask.SubjectId) , nameof(VisitTask.VisitTaskNum) }; + var defalutSortArray = new string[] { nameof(VisitTask.IsUrgent) + " desc", nameof(VisitTask.SubjectId), nameof(VisitTask.VisitTaskNum) }; var pageList = await visitTaskQueryable.ToPagedListAsync(queryVisitTask.PageIndex, queryVisitTask.PageSize, queryVisitTask.SortField, queryVisitTask.Asc, string.IsNullOrWhiteSpace(queryVisitTask.SortField), defalutSortArray); @@ -147,12 +150,30 @@ namespace IRaCIS.Core.Application.Service //最后一个访视添加全局 if (filterObj.IsGenerateGlobalTask) { - var globalTask = (subject.VisitTaskList.Take(filterObj.PlanVisitCount).Last()).Clone(); - globalTask.TaskName = (int)globalTask.VisitTaskNum + "Global"; - globalTask.TaskBlindName = (int)globalTask.VisitTaskNum + "Global"; - globalTask.ReadingCategory = ReadingCategory.Global; - globalTask.VisitTaskNum += ReadingCommon.TaskNumDic[ReadingCategory.Global]; - subject.VisitTaskList.Add(globalTask); + var lastTask = (subject.VisitTaskList.Take(filterObj.PlanVisitCount).Last()).Clone(); + + var existGlobal = _visitTaskRepository.Where(t => t.SubjectId == lastTask.SubjectId && t.TaskState == TaskState.Effect && t.ReadingCategory == ReadingCategory.Global && t.VisitTaskNum == lastTask.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global]).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefault(); + + + if (existGlobal == null) + { + existGlobal = new VisitTaskSimpleDTO() + { + SubjectId = lastTask.SubjectId, + TrialId = lastTask.TrialId, + BlindSubjectCode = lastTask.BlindSubjectCode, + BlindTrialSiteCode = lastTask.BlindTrialSiteCode, + ArmEnum = lastTask.ArmEnum, + ReadingCategory = ReadingCategory.Global + }; + } + + + + existGlobal.TaskName = (int)existGlobal.VisitTaskNum + "Global"; + existGlobal.TaskBlindName = (int)existGlobal.VisitTaskNum + "Global"; + + subject.VisitTaskList.Add(existGlobal); } @@ -217,10 +238,10 @@ namespace IRaCIS.Core.Application.Service //单重阅片没有组件一致性 subjectQuery = _subjectRepository.Where(t => t.TrialId == trialId && - t.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter).Where(t => t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global).Select(t => t.DoctorUserId).Distinct().Count() == 2 && - t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).GroupBy(t => new { t.SubjectId, t.VisitTaskNum }).Where(g => g.Count() == 2).Count() >= filterObj.PlanVisitCount + t.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter).Where(t => t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global).Select(t => t.DoctorUserId).Distinct().Count() == 2 && + t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).GroupBy(t => new { t.SubjectId, t.VisitTaskNum }).Where(g => g.Count() == 2).Count() >= filterObj.PlanVisitCount ) - .WhereIf(filterObj.IsHaveReadingPeriod == true, u => u.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter).Where(t => t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global).OrderBy(t => t.VisitTaskNum).Take(filterObj.PlanVisitCount*2 + 2).Any(t=>t.ReadingCategory == ReadingCategory.Global)) + .WhereIf(filterObj.IsHaveReadingPeriod == true, u => u.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter).Where(t => t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global).OrderBy(t => t.VisitTaskNum).Take(filterObj.PlanVisitCount * 2 + 2).Any(t => t.ReadingCategory == ReadingCategory.Global)) ; @@ -354,7 +375,9 @@ namespace IRaCIS.Core.Application.Service VisitTaskNum = task.VisitTaskNum, TrialId = task.TrialId, DoctorUserId = needAddDoctorUserId, - ArmEnum = Arm.GroupConsistentArm + ArmEnum = Arm.GroupConsistentArm, + SouceReadModuleId = task.SouceReadModuleId, + SourceSubjectVisitId=task.SourceSubjectVisitId, }); } @@ -363,13 +386,28 @@ namespace IRaCIS.Core.Application.Service if (filterObj.IsGenerateGlobalTask) { - var globalTask = (subjectAddTaskList.Take(filterObj.PlanVisitCount).Last()).Clone(); - globalTask.TaskName = (int)globalTask.VisitTaskNum + "Global"; - globalTask.TaskBlindName = (int)globalTask.VisitTaskNum + "Global"; - globalTask.ReadingCategory = ReadingCategory.Global; - globalTask.VisitTaskNum += ReadingCommon.TaskNumDic[ReadingCategory.Global]; - globalTask.DoctorUserId =needAddDoctorUserId; - subjectAddTaskList.Add(globalTask); + var lastTask = (subjectAddTaskList.Take(filterObj.PlanVisitCount).Last()).Clone(); + + + var existGlobal = _visitTaskRepository.Where(t => t.SubjectId == lastTask.SubjectId && t.TaskState == TaskState.Effect && t.ReadingCategory == ReadingCategory.Global && t.VisitTaskNum == lastTask.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global]).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefault(); + + + if (existGlobal == null) + { + existGlobal = new VisitTaskSimpleDTO() + { + SubjectId = lastTask.SubjectId, + TrialId = lastTask.TrialId, + ArmEnum = lastTask.ArmEnum, + ReadingCategory = ReadingCategory.Global + }; + } + + existGlobal.TaskName = (int)existGlobal.VisitTaskNum + "Global"; + existGlobal.TaskBlindName = (int)existGlobal.VisitTaskNum + "Global"; + existGlobal.DoctorUserId = needAddDoctorUserId; + + subjectAddTaskList.Add(existGlobal); } } @@ -412,7 +450,7 @@ namespace IRaCIS.Core.Application.Service #region Subejct 维度 Expression> comonTaskFilter = u => u.TrialId == trialId && u.IsAnalysisCreate == false && u.TaskState == TaskState.Effect && u.ReadingTaskState == ReadingTaskState.HaveSigned && - u.SignTime!.Value.AddDays(filterObj.IntervalWeeks * 7) < DateTime.Now && (u.ReReadingApplyState == ReReadingApplyState.Default || u.ReReadingApplyState == ReReadingApplyState.Reject) && u.DoctorUserId==doctorUserId; + u.SignTime!.Value.AddDays(filterObj.IntervalWeeks * 7) < DateTime.Now && (u.ReReadingApplyState == ReReadingApplyState.Default || u.ReReadingApplyState == ReReadingApplyState.Reject) && u.DoctorUserId == doctorUserId; @@ -435,9 +473,9 @@ namespace IRaCIS.Core.Application.Service //} - var subjectQuery = _subjectRepository.Where(t => t.TrialId == trialId && - t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).Count() >= filterObj.PlanVisitCount) - .WhereIf(filterObj.IsHaveReadingPeriod == true,u=>u.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter).Where(t=>t.ReadingCategory==ReadingCategory.Visit ||t.ReadingCategory==ReadingCategory.Global).OrderBy(t=>t.VisitTaskNum).Take(filterObj.PlanVisitCount+1).Any(t=>t.ReadingCategory==ReadingCategory.Global)) + var subjectQuery = _subjectRepository.Where(t => t.TrialId == trialId && + t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).Count() >= filterObj.PlanVisitCount) + .WhereIf(filterObj.IsHaveReadingPeriod == true, u => u.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter).Where(t => t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global).OrderBy(t => t.VisitTaskNum).Take(filterObj.PlanVisitCount + 1).Any(t => t.ReadingCategory == ReadingCategory.Global)) ; @@ -456,7 +494,7 @@ namespace IRaCIS.Core.Application.Service ValidVisitCount = t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).Count(), - VisitTaskList = t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).Select(c => new VisitTaskSimpleDTO() + VisitTaskList = t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).OrderBy(t => t.VisitTaskNum).Select(c => new VisitTaskSimpleDTO() { Id = c.Id, ReadingCategory = c.ReadingCategory, @@ -469,8 +507,8 @@ namespace IRaCIS.Core.Application.Service SubjectId = c.SubjectId, VisitTaskNum = c.VisitTaskNum, TrialId = c.TrialId, - SourceSubjectVisitId=c.SourceSubjectVisitId, - SouceReadModuleId=c.SouceReadModuleId, + SourceSubjectVisitId = c.SourceSubjectVisitId, + SouceReadModuleId = c.SouceReadModuleId, //自身一致性才有意义 //IsHaveGeneratedTask = c.Subject.SubjectVisitTaskList.Any(t => t.ConsistentAnalysisOriginalTaskId == c.Id), @@ -492,7 +530,7 @@ namespace IRaCIS.Core.Application.Service SouceReadModuleId = c.SouceReadModuleId, }).ToList(), - }).OrderBy(t => t.VisitTaskNum).ToList() + }).ToList() }); return query.OrderByDescending(t => t.IsHaveGeneratedTask); diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index dc2c855f4..1966e5893 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -95,7 +95,7 @@ namespace IRaCIS.Core.Application.Service.Allocation - await _visitTaskRepository.BatchUpdateNoTrackingAsync(t => t.SubjectId == subjectId && t.ArmEnum == doctorArm.ArmEnum && t.TrialId == command.TrialId && t.TaskAllocationState == TaskAllocationState.NotAllocate && t.TaskState == TaskState.Effect, + await _visitTaskRepository.BatchUpdateNoTrackingAsync(t => t.SubjectId == subjectId && t.ArmEnum == doctorArm.ArmEnum && t.TrialId == command.TrialId && t.TaskAllocationState == TaskAllocationState.NotAllocate && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false, u => new VisitTask() { AllocateTime = DateTime.Now, @@ -169,7 +169,7 @@ namespace IRaCIS.Core.Application.Service.Allocation await _subjectUserRepository.DeleteFromQueryAsync(t => t.Id == command.Id); - await _visitTaskRepository.BatchUpdateNoTrackingAsync(t => t.SubjectId == command.SubjectId && t.DoctorUserId == command.DoctorUserId && t.ArmEnum == command.ArmEnum && t.ReadingTaskState == ReadingTaskState.WaitReading && t.TaskState == TaskState.Effect, u => new VisitTask() + await _visitTaskRepository.BatchUpdateNoTrackingAsync(t => t.SubjectId == command.SubjectId && t.DoctorUserId == command.DoctorUserId && t.ArmEnum == command.ArmEnum && t.ReadingTaskState == ReadingTaskState.WaitReading && t.TaskState == TaskState.Effect && t.IsAnalysisCreate==false, u => new VisitTask() { AllocateTime = null, DoctorUserId = null, diff --git a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs index a536176f6..d5d119bec 100644 --- a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs @@ -192,8 +192,14 @@ namespace IRaCIS.Core.Application.Service .ForMember(o => o.MedicalNo, t => t.MapFrom(u => u.Subject.MedicalNo)) .ForMember(o => o.IsGeneratedJudge, t => t.MapFrom(u => u.JudgeVisitTaskId != null)) .ForMember(o => o.ReadingDurationTimeSpan, t => t.MapFrom(u => u.SignTime - u.FirstReadingTime)) + + ; + CreateMap(); + CreateMap(); + + CreateMap()