diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj index ccc3201d1..dfd16993a 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj @@ -86,7 +86,7 @@ - + true diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index dcf371494..0a2eef9d2 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -323,7 +323,7 @@ - 重阅原任务跟踪处理 + 重阅原任务跟踪处理 只会在同意的时候调用这个 diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs index 5dc760277..113dcffb1 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs @@ -199,6 +199,9 @@ namespace IRaCIS.Core.Application.Service task1.AllocateTime = DateTime.Now; task2.AllocateTime = DateTime.Now; + task1.SuggesteFinishedTime = DateTime.Now.AddDays(7); + task2.SuggesteFinishedTime = DateTime.Now.AddDays(7); + #endregion @@ -224,6 +227,7 @@ namespace IRaCIS.Core.Application.Service arm1.TaskAllocationState = TaskAllocationState.Allocated; arm1.AllocateTime = DateTime.Now; arm1.DoctorUserId = task1.DoctorUserId; + arm1.SuggesteFinishedTime = DateTime.Now.AddDays(7); } else { @@ -264,6 +268,7 @@ namespace IRaCIS.Core.Application.Service arm2.TaskAllocationState = TaskAllocationState.Allocated; arm2.AllocateTime = DateTime.Now; arm2.DoctorUserId = task2.DoctorUserId; + arm2.SuggesteFinishedTime = DateTime.Now.AddDays(7); } else { @@ -325,6 +330,9 @@ namespace IRaCIS.Core.Application.Service task1.AllocateTime = DateTime.Now; task2.AllocateTime = DateTime.Now; + + task1.SuggesteFinishedTime = DateTime.Now.AddDays(7); + task2.SuggesteFinishedTime = DateTime.Now.AddDays(7); } @@ -429,6 +437,8 @@ namespace IRaCIS.Core.Application.Service singleTask.AllocateTime = DateTime.Now; + singleTask.SuggesteFinishedTime = DateTime.Now.AddDays(7); + #endregion @@ -454,6 +464,7 @@ namespace IRaCIS.Core.Application.Service arm.TaskAllocationState = TaskAllocationState.Allocated; arm.AllocateTime = DateTime.Now; arm.DoctorUserId = singleTask.DoctorUserId; + arm.SuggesteFinishedTime = DateTime.Now.AddDays(7); } else { @@ -511,6 +522,8 @@ namespace IRaCIS.Core.Application.Service singleTask.AllocateTime = DateTime.Now; + singleTask.SuggesteFinishedTime = DateTime.Now.AddDays(7); + } #endregion @@ -627,6 +640,7 @@ namespace IRaCIS.Core.Application.Service DoctorUserId = task.DoctorUserId, TaskAllocationState = TaskAllocationState.Allocated, AllocateTime = DateTime.Now, + SuggesteFinishedTime = DateTime.Now.AddDays(7), SouceReadModuleId = task.SouceReadModuleId, SourceSubjectVisitId = task.SourceSubjectVisitId, @@ -668,10 +682,11 @@ namespace IRaCIS.Core.Application.Service SouceReadModuleId = task.SouceReadModuleId, SourceSubjectVisitId = task.SourceSubjectVisitId, + DoctorUserId = task.DoctorUserId, TaskAllocationState = TaskAllocationState.Allocated, AllocateTime = DateTime.Now, - + SuggesteFinishedTime= DateTime.Now.AddDays(7), IsAnalysisCreate = true, IsSelfAnalysis = false, diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index d7600bab6..7bbac7c6e 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -89,16 +89,25 @@ namespace IRaCIS.Core.Application.Service.Allocation { foreach (var doctorArm in command.DoctorArmList) { - if(!await _subjectUserRepository.AnyAsync(t=>t.SubjectId == subjectId && t.DoctorUserId == doctorArm.DoctorUserId && t.ArmEnum == doctorArm.ArmEnum && t.IsConfirmed && t.OrignalSubjectUserId == null)) + if (!await _subjectUserRepository.AnyAsync(t => t.SubjectId == subjectId && t.DoctorUserId == doctorArm.DoctorUserId && t.ArmEnum == doctorArm.ArmEnum && t.IsConfirmed && t.OrignalSubjectUserId == null)) { - await _subjectUserRepository.AddAsync(new SubjectUser() {TrialId=command.TrialId, ArmEnum = doctorArm.ArmEnum, DoctorUserId = doctorArm.DoctorUserId, SubjectId = subjectId, AssignTime = DateTime.Now }); + await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = command.TrialId, ArmEnum = doctorArm.ArmEnum, DoctorUserId = doctorArm.DoctorUserId, SubjectId = subjectId, AssignTime = DateTime.Now }); + + + + await _visitTaskRepository.BatchUpdateNoTrackingAsync(t => t.SubjectId == subjectId && t.ArmEnum == doctorArm.ArmEnum && t.TrialId == command.TrialId && t.TaskAllocationState == TaskAllocationState.NotAllocate && t.TaskState == TaskState.Effect, + u => new VisitTask() + { + AllocateTime = DateTime.Now, + DoctorUserId = doctorArm.DoctorUserId, + TaskAllocationState = TaskAllocationState.Allocated, + + SuggesteFinishedTime = /*t.IsUrgent ? DateTime.Now.AddDays(2) :*/ DateTime.Now.AddDays(7), + }); + + //task.SuggesteFinishedTime = task.IsUrgent ? DateTime.Now.AddDays(2) : DateTime.Now.AddDays(7); + - await _visitTaskRepository.BatchUpdateNoTrackingAsync(t => t.SubjectId == subjectId && t.ArmEnum == doctorArm.ArmEnum && t.TrialId==command.TrialId && t.TaskAllocationState==TaskAllocationState.NotAllocate && t.TaskState==TaskState.Effect, u => new VisitTask() - { - AllocateTime = DateTime.Now, - DoctorUserId = doctorArm.DoctorUserId, - TaskAllocationState = TaskAllocationState.Allocated - }); } } @@ -107,6 +116,9 @@ namespace IRaCIS.Core.Application.Service.Allocation await _subjectUserRepository.SaveChangesAsync(); + + + return ResponseOutput.Ok(); } @@ -150,18 +162,19 @@ namespace IRaCIS.Core.Application.Service.Allocation { foreach (var command in commandList.Where(t => t.IsCancelAssign)) { - if(await _visitTaskRepository.AnyAsync(t=>t.SubjectId==command.SubjectId && t.DoctorUserId==command.DoctorUserId && t.ArmEnum==command.ArmEnum && t.ReadingTaskState != ReadingTaskState.WaitReading)) + if (await _visitTaskRepository.AnyAsync(t => t.SubjectId == command.SubjectId && t.DoctorUserId == command.DoctorUserId && t.ArmEnum == command.ArmEnum && t.ReadingTaskState != ReadingTaskState.WaitReading)) { throw new BusinessValidationFailedException("当前医生已开始做该Subject的任务,不允许取消分配"); } 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, u => new VisitTask() { - AllocateTime=null, - DoctorUserId=null, - TaskAllocationState=TaskAllocationState.NotAllocate + AllocateTime = null, + DoctorUserId = null, + TaskAllocationState = TaskAllocationState.NotAllocate, + SuggesteFinishedTime = null }); } @@ -219,9 +232,13 @@ namespace IRaCIS.Core.Application.Service.Allocation visitTask.DoctorUserId = assignSubjectTaskToDoctorCommand.DoctorUserId; visitTask.TaskAllocationState = TaskAllocationState.Allocated; - await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == visitTask.SourceSubjectVisitId, u => new SubjectVisit() { ReadingStatus = ReadingStatusEnum.ImageReading }); + visitTask.SuggesteFinishedTime = DateTime.Now.AddDays(7); - await _readModuleRepository.BatchUpdateNoTrackingAsync(t => t.Id == visitTask.SouceReadModuleId, u => new ReadModule() { ReadingStatus = ReadingStatusEnum.ImageReading }); + + + //await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == visitTask.SourceSubjectVisitId, u => new SubjectVisit() { ReadingStatus = ReadingStatusEnum.ImageReading }); + + //await _readModuleRepository.BatchUpdateNoTrackingAsync(t => t.Id == visitTask.SouceReadModuleId, u => new ReadModule() { ReadingStatus = ReadingStatusEnum.ImageReading }); } else if (assignSubjectTaskToDoctorCommand.TaskOptType == TaskOptType.ReAssign) @@ -247,9 +264,9 @@ namespace IRaCIS.Core.Application.Service.Allocation visitTask.DoctorUserId = null; visitTask.TaskAllocationState = TaskAllocationState.NotAllocate; - await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == visitTask.SourceSubjectVisitId, u => new SubjectVisit() { ReadingStatus = ReadingStatusEnum.TaskAllocate }); + //await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == visitTask.SourceSubjectVisitId, u => new SubjectVisit() { ReadingStatus = ReadingStatusEnum.TaskAllocate }); - await _readModuleRepository.BatchUpdateNoTrackingAsync(t => t.Id == visitTask.SouceReadModuleId, u => new ReadModule() { ReadingStatus = ReadingStatusEnum.TaskAllocate }); + //await _readModuleRepository.BatchUpdateNoTrackingAsync(t => t.Id == visitTask.SouceReadModuleId, u => new ReadModule() { ReadingStatus = ReadingStatusEnum.TaskAllocate }); } await _visitTaskRepository.SaveChangesAsync(); return ResponseOutput.Ok(); @@ -1262,7 +1279,7 @@ namespace IRaCIS.Core.Application.Service.Allocation /// - /// 重阅原任务跟踪处理 + /// 重阅原任务跟踪处理 只会在同意的时候调用这个 /// /// private void ReReadingTaskTrackingDeal(VisitTask origenalTask, ConfirmReReadingCommand agreeReReadingCommand) @@ -1655,20 +1672,36 @@ namespace IRaCIS.Core.Application.Service.Allocation newTask.DoctorUserId = origenalTask.DoctorUserId; newTask.TaskAllocationState = TaskAllocationState.Allocated; newTask.AllocateTime = DateTime.Now; + newTask.SuggesteFinishedTime = DateTime.Now.AddDays(7); //拷贝表单 - if (visitTaskReReadingAppply.IsCopyFollowForms) + if (visitTaskReReadingAppply.IsCopyOrigenalForms) { - - var list = _readingTaskQuestionAnswerRepository.Where(t => t.VisitTaskId == influenceTask.Id).ToList(); - - foreach (var item in list) + if (origenalTask.ReadingCategory == ReadingCategory.Visit) { - item.Id = Guid.Empty; - item.VisitTaskId = newTask.Id; + var list = _readingTaskQuestionAnswerRepository.Where(t => t.VisitTaskId == origenalTask.Id).ToList(); + + foreach (var item in list) + { + item.Id = Guid.Empty; + item.VisitTaskId = newTask.Id; + } + + _ = _readingTaskQuestionAnswerRepository.AddRangeAsync(list).Result; + } + else if (origenalTask.ReadingCategory == ReadingCategory.Global) + { + var list = _repository.Where(t => t.GlobalTaskId == origenalTask.Id).ToList(); + + foreach (var item in list) + { + item.Id = Guid.Empty; + item.GlobalTaskId = newTask.Id; + } + + _ = _repository.AddRangeAsync(list).Result; } - _ = _readingTaskQuestionAnswerRepository.AddRangeAsync(list).Result; } @@ -1781,6 +1814,7 @@ namespace IRaCIS.Core.Application.Service.Allocation newTask.DoctorUserId = origenalTask.DoctorUserId; newTask.TaskAllocationState = TaskAllocationState.Allocated; newTask.AllocateTime = DateTime.Now; + newTask.SuggesteFinishedTime = DateTime.Now.AddDays(7); //拷贝表单 if (visitTaskReReadingAppply.IsCopyOrigenalForms) @@ -1799,7 +1833,15 @@ namespace IRaCIS.Core.Application.Service.Allocation } else if (origenalTask.ReadingCategory == ReadingCategory.Global) { + var list = _repository.Where(t => t.GlobalTaskId == origenalTask.Id).ToList(); + foreach (var item in list) + { + item.Id = Guid.Empty; + item.GlobalTaskId = newTask.Id; + } + + _ = _repository.AddRangeAsync(list).Result; } @@ -1818,11 +1860,19 @@ namespace IRaCIS.Core.Application.Service.Allocation } } - - + else if (agreeReReadingCommand.RequestReReadingResultEnum == RequestReReadingResult.Reject) + { + await _visitTaskRepository.BatchUpdateNoTrackingAsync(t => t.Id == origenalTask.Id, u => new VisitTask() + { + ReReadingApplyState = ReReadingApplyState.Reject + }); + } } + + + await _visitTaskRepository.SaveChangesAsync(); return ResponseOutput.Ok(); diff --git a/IRaCIS.Core.Application/TestService.cs b/IRaCIS.Core.Application/TestService.cs index f53467bed..cf9bef5e9 100644 --- a/IRaCIS.Core.Application/TestService.cs +++ b/IRaCIS.Core.Application/TestService.cs @@ -47,9 +47,12 @@ namespace IRaCIS.Application.Services //var needAddVisitList = await _repository.Where(t => t.TrialId == Guid.Empty).DistinctBy(t => t.VisitTaskNum).ToListAsync(); - await _repository.BatchUpdateAsync(t => t.InfluenceTask.TaskState == Core.Domain.Share.TaskState.HaveReturned, u => new TaskInfluence() { OptType = ReReadingOrBackOptType.Return }); - await _repository.BatchUpdateAsync(t => t.InfluenceTask.TaskState == Core.Domain.Share.TaskState.Adbandon, u => new TaskInfluence() { OptType = ReReadingOrBackOptType.Abandon }); + await _repository.BatchUpdateAsync(t => t.Id==Guid.Empty, u => new VisitTask() { + SuggesteFinishedTime = u.IsUrgent ? DateTime.Now.AddDays(2) : DateTime.Now.AddDays(7), + + Code = u.Code+1 + }); return _userInfo.LocalIp; } diff --git a/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj b/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj index 4447e8c90..88dbf8471 100644 --- a/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj +++ b/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj @@ -17,9 +17,9 @@ - + - + diff --git a/IRaCIS.Core.Infra.EFCore/Repository/IRepository.cs b/IRaCIS.Core.Infra.EFCore/Repository/IRepository.cs index bfedf9a50..55d16e3c3 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/IRepository.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/IRepository.cs @@ -12,6 +12,7 @@ using System.Linq; using System.Linq.Expressions; using System.Threading.Tasks; using IRaCIS.Core.Domain.Share; +using EFCore.BulkExtensions; namespace IRaCIS.Core.Infra.EFCore { @@ -412,7 +413,9 @@ namespace IRaCIS.Core.Infra.EFCore { return await _dbContext.BatchUpdateNoTrackingAsync(whereFilter, updateFactory, _userInfo.Id); - + + //return await _dbContext.Set().IgnoreQueryFilters().Where(whereFilter).BatchUpdateAsync(updateFactory).ConfigureAwait(false) > 0; + }