处理检查删除、添加、维护绑定关系

This commit is contained in:
2024-07-22 15:41:16 +08:00
parent 9898673dbf
commit 5246c10e32
3 changed files with 42 additions and 19 deletions
@@ -17,6 +17,7 @@ using IRaCIS.Core.Application.ViewModel;
using IRaCIS.Core.Domain.Models;
using IRaCIS.Core.Application.Service;
using Medallion.Threading;
using DocumentFormat.OpenXml.Office2010.Excel;
namespace IRaCIS.Core.Application.Image.QA
{
@@ -802,28 +803,46 @@ namespace IRaCIS.Core.Application.Image.QA
var succeess2 = await _repository.BatchDeleteAsync<DicomInstance>(t => t.StudyId == id);
var success3 = await _dicomSeriesrepository.BatchDeleteNoTrackingAsync(t => t.StudyId == id);
await _repository.BatchUpdateAsync<SCPStudy>(t => t.Id == id,u=>new SCPStudy() { SubjectVisitId=null});
//var success3 = await _dicomSeriesrepository.DeleteFromQueryAsync(t => t.StudyId == id, true);
//var success4 = await _repository.BatchDeleteAsync<StudyMonitor>(t => t.StudyId == id);
//删除 物理文件
var instancePathList = await _repository.Where<DicomInstance>(t => t.StudyId == id)
.Select(t => t.Path).ToListAsync();
//var instancePathList = await _repository.Where<DicomInstance>(t => t.StudyId == id)
// .Select(t => t.Path).ToListAsync();
instancePathList.ForEach(path =>
{
//instancePathList.ForEach(path =>
//{
var physicalPath = FileStoreHelper.GetPhysicalFilePath(_hostEnvironment, path);
// var physicalPath = FileStoreHelper.GetPhysicalFilePath(_hostEnvironment, path);
if (System.IO.File.Exists(physicalPath))
{
File.Delete(physicalPath);
}
});
// if (System.IO.File.Exists(physicalPath))
// {
// File.Delete(physicalPath);
// }
//});
}
var subjectId=waitDeleteStudyList.Select(t=>t.SubjectId).FirstOrDefault();
var patientList = _repository.Where<SCPPatient>(t => t.SubjectId == subjectId).Select(t => t.Id).ToList();
foreach (var patientId in patientList)
{
if (_repository.Where<SCPPatient>(t=>t.Id== patientId).Any(t => t.SCPStudyList.Count() == t.SCPStudyList.Where(t => t.SubjectVisitId == null).Count()))
{
await _repository.BatchUpdateAsync<SCPPatient>(t => t.Id == patientId, u => new SCPPatient() { SubjectId = null });
}
}
await _subjectVisitRepository.SaveChangesAsync();