Uat_Study
he 2022-08-09 11:22:22 +08:00
parent c39f6225e9
commit 4662157bf2
2 changed files with 28 additions and 0 deletions

View File

@ -14,6 +14,7 @@ using IRaCIS.Core.Infra.EFCore.Common;
using System.Linq.Dynamic.Core; using System.Linq.Dynamic.Core;
using IRaCIS.Core.Application.Service; using IRaCIS.Core.Application.Service;
using IRaCIS.Core.Application.ViewModel; using IRaCIS.Core.Application.ViewModel;
using IRaCIS.Core.Infrastructure;
namespace IRaCIS.Application.Services namespace IRaCIS.Application.Services
{ {
@ -463,7 +464,21 @@ namespace IRaCIS.Application.Services
[HttpDelete("{readModuleId:guid}")] [HttpDelete("{readModuleId:guid}")]
public async Task<IResponseOutput> DeleteReadModule(Guid readModuleId) public async Task<IResponseOutput> 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.DeleteFromQueryAsync(t => t.Id == readModuleId, true);
await _readModuleRepository.SaveChangesAsync();
return ResponseOutput.Result(true); return ResponseOutput.Result(true);
} }

View File

@ -13,6 +13,7 @@ using IRaCIS.Core.Infra.EFCore.Common;
using IRaCIS.Core.Infrastructure.Extention; using IRaCIS.Core.Infrastructure.Extention;
using IRaCIS.Core.Application.Service; using IRaCIS.Core.Application.Service;
using IRaCIS.Core.Application.ViewModel; using IRaCIS.Core.Application.ViewModel;
using IRaCIS.Core.Infrastructure;
namespace IRaCIS.Application.Services namespace IRaCIS.Application.Services
{ {
@ -434,6 +435,18 @@ namespace IRaCIS.Application.Services
} }
else else
{ {
List<Guid> 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); await _readModuleRepository.DeleteFromQueryAsync(x => x.ReadingPeriodSetId == indto.Id);
} }