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,7 +156,6 @@ 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());
|
||||
|
@ -161,13 +166,17 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
|||
|
||||
|
||||
//特殊处理逻辑
|
||||
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);
|
||||
|
@ -199,8 +208,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
|||
|
||||
|
||||
|
||||
studyMonitor.StudyId = study.Id;
|
||||
studyMonitor.StudyCode = study.StudyCode;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -212,6 +220,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
|||
//_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);
|
||||
|
||||
|
||||
|
@ -228,8 +237,6 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
|||
//判断重复
|
||||
if (dicomSeries == null)
|
||||
{
|
||||
|
||||
|
||||
var series = _mapper.Map<DicomSeries>(seriesItem);
|
||||
|
||||
series.Id = seriesId;
|
||||
|
@ -278,7 +285,8 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
|||
}
|
||||
|
||||
|
||||
await _dicomstudyRepository.SaveChangesAsync();
|
||||
await _repository.SaveChangesAsync();
|
||||
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue