From 15b24f27b57d8f1319ed9c92fc43479a6b076b99 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 6 Jul 2022 11:17:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9B=9E=E9=80=80=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Allocation/VisitTaskService.cs | 188 +++++++----------- 1 file changed, 70 insertions(+), 118 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index 27d6e93db..57a3f0771 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -12,6 +12,7 @@ using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Infrastructure; using IRaCIS.Core.Application.Contracts; using IRaCIS.Core.Infra.EFCore.Common; +using System.Linq.Expressions; namespace IRaCIS.Core.Application.Service { @@ -1221,78 +1222,12 @@ namespace IRaCIS.Core.Application.Service } } - - - - ////产生的新任务 - - //await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand() - //{ - // TrialId = trialId, - - // ReadingCategory = ReadingCategory.ReReading, - - // ReReadingTask = origenalTask, - - // //同步才可以 - // Action = (newTask) => - // { - - // visitTaskReReadingAppply.NewReReadingTaskId = newTask.Id; - - - // if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer) - // { - - // if (visitTaskReReadingAppply.IsCopyOrigenalForms) - // { - // var origenalAnswerList = _readingTaskQuestionAnswerRepository.Where(t => t.VisitTaskId == origenalTask.Id).ToList(); - - // origenalAnswerList.ForEach(t => { t.VisitTaskId = newTask.Id; t.Id = Guid.Empty; }); - - // _readingTaskQuestionAnswerRepository.AddRangeAsync(origenalAnswerList).Wait(); - // } - // } - - // //IR申请 PM同意 立即分配 - // if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) - // { - // //有序阅片 - // if (trialConfig.IsReadingTaskViewInOrder) - // { - - // } - // else - // { - // //无序阅片 - - // newTask.DoctorUserId = origenalTask.DoctorUserId; - // newTask.TaskAllocationState = TaskAllocationState.Allocated; - // newTask.AllocateTime = DateTime.Now; - // } - - - // } - - // } - - - - //}); - //} - - + } - - - - await _visitTaskRepository.SaveChangesAsync(); - - return ResponseOutput.Ok(); } @@ -1309,39 +1244,77 @@ namespace IRaCIS.Core.Application.Service if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) { - //有序 - if (trialConfig.IsReadingTaskViewInOrder) + var task = (await _visitTaskRepository.FirstOrDefaultAsync(t => t.Id == taskId)).IfNullThrowException(); + + //申请的任务 肯定是未完成阅片的 并且是访视类型的 + if (task.ReadingTaskState != ReadingTaskState.HaveSigned && task.ReadingCategory == ReadingCategory.Visit) { - } - //无序 无序阅片没有 全局 肿瘤学 - else - { - // 当前任务标为失效,后续任务不处理 - var task = (await _visitTaskRepository.FirstOrDefaultAsync(t => t.Id == taskId)).IfNullThrowException(); + #region 有序 无序公用流程 + + // 当前任务标为失效 task.TaskState = TaskState.Adbandon; + //执行类似一致性核查回退流程 回退访视到影像上传流程 + await VisitBackAsync(task.SourceSubjectVisitId); - //考虑该访视 另外一个阅片人的任务也同时退回 - var otherTask = await _visitTaskRepository.FirstOrDefaultAsync(t => t.SourceSubjectVisitId == task.SourceSubjectVisitId && t.Id != task.Id && t.TaskState == TaskState.Effect); - if (otherTask.ReadingTaskState == ReadingTaskState.HaveSigned) + //考虑该访视 另外一个阅片人的任务 + var otherReviewerTask = await _visitTaskRepository.FirstOrDefaultAsync(t => t.SourceSubjectVisitId == task.SourceSubjectVisitId && t.Id != task.Id && t.TaskState == TaskState.Effect); + + + #endregion + + + //有序 + if (trialConfig.IsReadingTaskViewInOrder) { - otherTask.TaskState = TaskState.HaveReturned; + //本身自己 有序 PM 申请回退流程 + + + + + if (otherReviewerTask.ReadingTaskState == ReadingTaskState.HaveSigned) + { + //另外阅片人完成阅片了 就设置为重阅重置 + otherReviewerTask.TaskState = TaskState.HaveReturned; + + + //另外一个阅片人 有序PM 申请重阅流程 + } + else + { + + otherReviewerTask.TaskState = TaskState.Adbandon; + + + //另外一个阅片人 有序 PM 申请回退流程 + + + + } + + + } + //无序 无序阅片没有 全局 肿瘤学 else { - otherTask.TaskState = TaskState.Adbandon; - } + if (otherReviewerTask.ReadingTaskState == ReadingTaskState.HaveSigned) + { + //另外阅片人完成阅片了 就设置为重阅重置 + otherReviewerTask.TaskState = TaskState.HaveReturned; + } + else + { - //回退访视 - if (task.ReadingCategory == ReadingCategory.Visit) - { - //执行类似一致性核查回退流程 - await VisitBackAsync(task.SourceSubjectVisitId); + otherReviewerTask.TaskState = TaskState.Adbandon; + } } } + + } await _visitTaskRepository.SaveChangesAsync(); @@ -1395,7 +1368,7 @@ namespace IRaCIS.Core.Application.Service /// - /// 重阅影响提示列表 + /// 重阅影响提示列表 仅仅针对已完成的任务申请 /// /// /// @@ -1407,8 +1380,8 @@ namespace IRaCIS.Core.Application.Service var trialConfig = (await _trialRepository.Where(t => t.Id == trialId).Select(t => new { TrialId = t.Id, t.IsReadingTaskViewInOrder, t.ReadingType }).FirstOrDefaultAsync()).IfNullThrowException(); + Expression> filterExpression = t => t.TrialId == trialId && t.SubjectId == filterObj.SubjectId && t.TaskState == TaskState.Effect; - List list = null; //有序 if (trialConfig.IsReadingTaskViewInOrder) @@ -1416,58 +1389,37 @@ namespace IRaCIS.Core.Application.Service //当前任务及其之后的所有访视任务、全局任务、裁判任务、肿瘤学阅片任务 if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer) { - list = await _visitTaskRepository.Where(t => t.TrialId == trialId && t.SubjectId == filterObj.SubjectId) - .Where(t => t.TaskState == TaskState.Effect && !t.IsAnalysisCreate) - //过滤区别 - .Where(t => t.VisitTaskNum >= filterObj.VisitTaskNum && t.DoctorUserId==filterObj.DoctorUserId) - - .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + filterExpression = filterExpression.And(t => t.VisitTaskNum >= filterObj.VisitTaskNum && t.DoctorUserId == filterObj.DoctorUserId); } //影响所有阅片人 if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) { - list = await _visitTaskRepository.Where(t => t.TrialId == trialId && t.SubjectId == filterObj.SubjectId) - .Where(t => t.TaskState == TaskState.Effect && !t.IsAnalysisCreate) - //过滤区别 - .Where(t => t.VisitTaskNum >= filterObj.VisitTaskNum ) - - .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + filterExpression = filterExpression.And(t => t.VisitTaskNum >= filterObj.VisitTaskNum); } } //无序 else { - //1.当前任务及裁判任务 - //2.影响当前阅片人的任务 + //1.当前任务及裁判任务 + //2.影响当前阅片人的任务 if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer) { - - list = await _visitTaskRepository.Where(t => t.TrialId == trialId && t.SubjectId == filterObj.SubjectId ) - .Where(t => t.TaskState == TaskState.Effect && !t.IsAnalysisCreate) - //过滤区别 - .Where (t=> t.Id==filterObj.Id || t.Id ==filterObj.JudgeVisitTaskId) - - .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - - + filterExpression = filterExpression.And(t => t.Id == filterObj.Id || t.Id == filterObj.JudgeVisitTaskId); } - //1.当前任务及裁判任务 + // 1.当前任务及裁判任务 // 2.影响所有阅片人的任务 if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) { var judegTaskNum = filterObj.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Judge]; - list = await _visitTaskRepository.Where(t => t.TrialId == trialId && t.SubjectId == filterObj.SubjectId) - .Where(t => t.TaskState == TaskState.Effect && !t.IsAnalysisCreate) - //过滤区别 - .Where(t => t.VisitTaskNum==filterObj.VisitTaskNum || t.VisitTaskNum== judegTaskNum) - - .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + filterExpression = filterExpression.And(t => t.VisitTaskNum == filterObj.VisitTaskNum || t.VisitTaskNum == judegTaskNum); } } + var list = await _visitTaskRepository.Where(filterExpression).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + return list; }