Uat_Study
he 2023-05-06 16:11:47 +08:00
commit 0aa981eea5
1 changed files with 25 additions and 22 deletions

View File

@ -22,7 +22,8 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
public class StudyService : BaseService, IStudyService
{
private static object lockCodeGenerate = new object();
private readonly AsyncLock _mutex = new AsyncLock();
private static readonly AsyncLock _mutex = new AsyncLock();
private static readonly AsyncLock _mutex2 = new AsyncLock();
private readonly IEasyCachingProvider _provider;
@ -141,7 +142,6 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
using (await _mutex.LockAsync())
{
//查询数据库获取最大的Code 没有记录则为0
var dbStudyCodeIntMax = _dicomstudyRepository.Where(s => s.TrialId == trialId).Select(t => t.Code).DefaultIfEmpty().Max();
@ -156,27 +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;
//特殊处理逻辑
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;
foreach (var seriesItem in incommand.Study.SeriesList)
{
var series = _mapper.Map<DicomSeries>(seriesItem);
@ -284,13 +284,16 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
}
using (await _mutex.LockAsync())
using (await _mutex2.LockAsync())
{
await _repository.SaveChangesAsync();
await _dicomInstanceRepository.SaveChangesAsync();
}
return ResponseOutput.Ok();
}