From 4662157bf2024824310f2da3f56a0771808039d1 Mon Sep 17 00:00:00 2001 From: he <10978375@qq.com> Date: Tue, 9 Aug 2022 11:22:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Reading/ReadModuleService.cs | 15 +++++++++++++++ .../Service/Reading/ReadingPeriodSetService.cs | 13 +++++++++++++ 2 files changed, 28 insertions(+) diff --git a/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs b/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs index bdee9d976..dfb016150 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs @@ -14,6 +14,7 @@ using IRaCIS.Core.Infra.EFCore.Common; using System.Linq.Dynamic.Core; using IRaCIS.Core.Application.Service; using IRaCIS.Core.Application.ViewModel; +using IRaCIS.Core.Infrastructure; namespace IRaCIS.Application.Services { @@ -463,7 +464,21 @@ namespace IRaCIS.Application.Services [HttpDelete("{readModuleId:guid}")] public async Task DeleteReadModule(Guid readModuleId) { + + if (await _visitTaskRepository.AnyAsync(x => readModuleId==x.SouceReadModuleId && x.ReadingTaskState == ReadingTaskState.HaveSigned && x.TaskState == TaskState.Effect)) + { + throw new BusinessValidationFailedException("当前阅片已生成任务并且阅片完成,操作失败。"); + } + + + await _visitTaskRepository.BatchUpdateNoTrackingAsync(x => readModuleId==x.SouceReadModuleId, x => new VisitTask() + { + TaskState = TaskState.Adbandon + }); + + await _readModuleRepository.DeleteFromQueryAsync(t => t.Id == readModuleId, true); + await _readModuleRepository.SaveChangesAsync(); return ResponseOutput.Result(true); } diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingPeriodSetService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingPeriodSetService.cs index 0f1dc8cae..a2ff80f35 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingPeriodSetService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingPeriodSetService.cs @@ -13,6 +13,7 @@ using IRaCIS.Core.Infra.EFCore.Common; using IRaCIS.Core.Infrastructure.Extention; using IRaCIS.Core.Application.Service; using IRaCIS.Core.Application.ViewModel; +using IRaCIS.Core.Infrastructure; namespace IRaCIS.Application.Services { @@ -434,6 +435,18 @@ namespace IRaCIS.Application.Services } else { + + List readModuleIds = await _readModuleRepository.Where(x => x.ReadingPeriodSetId == indto.Id).Select(x => x.Id).ToListAsync(); + if (await _visitTaskRepository.AnyAsync(x => readModuleIds.Contains(x.SouceReadModuleId ?? default(Guid)) && x.ReadingTaskState == ReadingTaskState.HaveSigned && x.TaskState == TaskState.Effect)) + { + throw new BusinessValidationFailedException("当前阅片已生成任务并且阅片完成,撤销失败。"); + } + + + await _visitTaskRepository.BatchUpdateNoTrackingAsync(x => readModuleIds.Contains(x.SouceReadModuleId ?? default(Guid)), x => new VisitTask() + { + TaskState = TaskState.Adbandon + }); await _readModuleRepository.DeleteFromQueryAsync(x => x.ReadingPeriodSetId == indto.Id); }