Merge branch 'master' of http://192.168.1.2:8033/IRaCIS_Core_Api
commit
8b481aaae2
|
@ -187,9 +187,13 @@ namespace IRaCIS.Core.Application.Contracts
|
|||
[NotDefault]
|
||||
public Guid SubjectVisitId { get; set; }
|
||||
|
||||
public int FailedFileCount { get; set; }
|
||||
|
||||
public decimal FileSize { get; set; }
|
||||
|
||||
public bool IsDicomReUpload { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public int FileCount { get; set; }
|
||||
}
|
||||
|
@ -207,7 +211,7 @@ namespace IRaCIS.Core.Application.Contracts
|
|||
[NotDefault]
|
||||
public Guid StudyMonitorId { get; set; }
|
||||
|
||||
public bool IsAdd { get; set; }
|
||||
public int FailedFileCount { get; set; }
|
||||
|
||||
public AddOrUpdateStudyDto Study { get; set; }
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@ using IRaCIS.Core.Application.Filter;
|
|||
using IRaCIS.Core.Application.MediatR.Handlers;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Newtonsoft.Json;
|
||||
using System.Threading;
|
||||
using Nito.AsyncEx;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
{
|
||||
|
@ -20,6 +22,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
|||
public class StudyService : BaseService, IStudyService
|
||||
{
|
||||
private static object lockCodeGenerate = new object();
|
||||
private readonly AsyncLock _mutex = new AsyncLock();
|
||||
|
||||
private readonly IEasyCachingProvider _provider;
|
||||
|
||||
|
@ -104,9 +107,10 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
|||
IsDicom = true,
|
||||
IP = _userInfo.IP,
|
||||
|
||||
IsDicomReUpload = preArchiveStudyCommand.IsDicomReUpload,
|
||||
FileSize = preArchiveStudyCommand.FileSize,
|
||||
FileCount = preArchiveStudyCommand.FileCount,
|
||||
FailedFileCount = preArchiveStudyCommand.FailedFileCount,
|
||||
//FailedFileCount = preArchiveStudyCommand.FailedFileCount,
|
||||
|
||||
};
|
||||
|
||||
|
@ -127,13 +131,15 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
|||
var studyMonitor = await _studyMonitorRepository.FirstOrDefaultAsync(t => t.Id == incommand.StudyMonitorId);
|
||||
studyMonitor.UploadFinishedTime = DateTime.Now;
|
||||
studyMonitor.ArchiveFinishedTime = DateTime.Now;
|
||||
studyMonitor.IsDicomReUpload = !incommand.IsAdd;
|
||||
studyMonitor.FailedFileCount = incommand.FailedFileCount;
|
||||
studyMonitor.IsSuccess = true;
|
||||
|
||||
if (incommand.IsAdd)
|
||||
//上传
|
||||
if (studyMonitor.IsDicomReUpload == false)
|
||||
{
|
||||
var study = _mapper.Map<DicomStudy>(incommand.Study);
|
||||
|
||||
lock (lockCodeGenerate)
|
||||
using (await _mutex.LockAsync())
|
||||
{
|
||||
|
||||
//查询数据库获取最大的Code 没有记录则为0
|
||||
|
@ -150,24 +156,27 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
|||
|
||||
_provider.Set<int>($"{trialId}_{StaticData.CacheKey.StudyMaxCode}", study.Code, TimeSpan.FromMinutes(30));
|
||||
|
||||
|
||||
|
||||
study.Id = IdentifierHelper.CreateGuid(incommand.Study.StudyInstanceUid, incommand.TrialId.ToString());
|
||||
study.TrialId = incommand.TrialId;
|
||||
study.SiteId = incommand.SiteId;
|
||||
study.SubjectId = incommand.SubjectId;
|
||||
study.SubjectVisitId = incommand.SubjectVisitId;
|
||||
|
||||
|
||||
//特殊处理逻辑
|
||||
study.Modalities = string.Join("、", incommand.Study.SeriesList.Select(t => t.Modality).Distinct());
|
||||
SpecialArchiveStudyDeal(study);
|
||||
|
||||
await _dicomstudyRepository.AddAsync(study);
|
||||
|
||||
|
||||
studyMonitor.StudyId = study.Id;
|
||||
studyMonitor.StudyCode = study.StudyCode;
|
||||
}
|
||||
|
||||
|
||||
study.Id = IdentifierHelper.CreateGuid(incommand.Study.StudyInstanceUid, incommand.TrialId.ToString());
|
||||
study.TrialId = incommand.TrialId;
|
||||
study.SiteId = incommand.SiteId;
|
||||
study.SubjectId = incommand.SubjectId;
|
||||
study.SubjectVisitId = incommand.SubjectVisitId;
|
||||
|
||||
|
||||
//特殊处理逻辑
|
||||
SpecialArchiveStudyDeal(study);
|
||||
|
||||
|
||||
|
||||
await _dicomstudyRepository.AddAsync(study);
|
||||
|
||||
|
||||
foreach (var seriesItem in incommand.Study.SeriesList)
|
||||
{
|
||||
var series = _mapper.Map<DicomSeries>(seriesItem);
|
||||
|
@ -199,19 +208,19 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
|||
|
||||
|
||||
|
||||
studyMonitor.StudyId = study.Id;
|
||||
studyMonitor.StudyCode = study.StudyCode;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var studyId = IdentifierHelper.CreateGuid(incommand.Study.StudyInstanceUid, incommand.TrialId.ToString());;
|
||||
var studyId = IdentifierHelper.CreateGuid(incommand.Study.StudyInstanceUid, incommand.TrialId.ToString()); ;
|
||||
|
||||
var study = await _dicomstudyRepository.FirstOrDefaultAsync(t => t.Id == studyId);
|
||||
|
||||
//_mapper.Map(incommand.Study, study);
|
||||
|
||||
//特殊处理逻辑
|
||||
study.Modalities = string.Join("、", incommand.Study.SeriesList.Select(t => t.Modality).Union(study.Modalities.Split("、", StringSplitOptions.RemoveEmptyEntries)).Distinct());
|
||||
SpecialArchiveStudyDeal(study);
|
||||
|
||||
|
||||
|
@ -223,13 +232,11 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
|||
{
|
||||
var seriesId = IdentifierHelper.CreateGuid(seriesItem.StudyInstanceUid, seriesItem.SeriesInstanceUid, trialId.ToString());
|
||||
|
||||
DicomSeries dicomSeries = await _dicomSeriesRepository.FirstOrDefaultAsync(t=>t.Id==seriesId);
|
||||
DicomSeries dicomSeries = await _dicomSeriesRepository.FirstOrDefaultAsync(t => t.Id == seriesId);
|
||||
|
||||
//判断重复
|
||||
if (dicomSeries == null)
|
||||
{
|
||||
|
||||
|
||||
var series = _mapper.Map<DicomSeries>(seriesItem);
|
||||
|
||||
series.Id = seriesId;
|
||||
|
@ -241,18 +248,18 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
|||
series.SubjectVisitId = incommand.SubjectVisitId;
|
||||
|
||||
|
||||
dicomSeries= await _dicomSeriesRepository.AddAsync(series);
|
||||
dicomSeries = await _dicomSeriesRepository.AddAsync(series);
|
||||
|
||||
//新的序列 那么 检查的序列数量+1
|
||||
study.SeriesCount += 1;
|
||||
study.SeriesCount += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
//该序列掉了instance
|
||||
dicomSeries.InstanceCount += seriesItem.InstanceCount;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
foreach (var instanceItem in seriesItem.InstanceList)
|
||||
{
|
||||
var insntance = _mapper.Map<DicomInstance>(instanceItem);
|
||||
|
@ -277,8 +284,9 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
|||
|
||||
}
|
||||
|
||||
|
||||
await _dicomstudyRepository.SaveChangesAsync();
|
||||
|
||||
await _repository.SaveChangesAsync();
|
||||
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
@ -700,7 +708,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
|||
|
||||
var systemAnonymizationList = _repository.Where<SystemAnonymization>(t => t.IsEnable).ToList();
|
||||
|
||||
return ResponseOutput.Ok<List<VerifyStudyUploadResult>>(result, new
|
||||
return ResponseOutput.Ok<List<VerifyStudyUploadResult>>(result, new
|
||||
{
|
||||
DicomStoreInfo = otherData,
|
||||
AnonymizeFixedList = systemAnonymizationList.Where(t => t.IsFixed).ToList(),
|
||||
|
@ -760,7 +768,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
|||
result.AllowReUpload = true;
|
||||
|
||||
result.UploadedSeriesList = _repository.Where<DicomSeries>(t => t.StudyId == verifyStudyInfo.Id).Select(t => new UploadedSeries()
|
||||
{ SeriesId=t.Id, SeriesInstanceUid = t.SeriesInstanceUid, SOPInstanceUIDList = t.DicomInstanceList.Select(c => c.SopInstanceUid).ToList() }).ToList();
|
||||
{ SeriesId = t.Id, SeriesInstanceUid = t.SeriesInstanceUid, SOPInstanceUIDList = t.DicomInstanceList.Select(c => c.SopInstanceUid).ToList() }).ToList();
|
||||
}
|
||||
//不是同一个受试者
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue