修改scp 服务监控
parent
2d06b12368
commit
af95166782
|
|
@ -45,9 +45,11 @@ namespace IRaCIS.Core.SCP.Service
|
|||
//private IServiceProvider _injectServiceProvider { get; set; }
|
||||
private IServiceProvider _serviceProvider { get; set; }
|
||||
|
||||
private List<Guid> _SCPStudyIdList { get; set; } = new List<Guid>();
|
||||
private List<Guid> _SCPStudyIdList => _ImageUploadList.Where(t => t.SCPStudyId != Guid.Empty).Select(t => t.SCPStudyId).ToList();
|
||||
|
||||
private List<string> _StudyInstanceUIdList { get; set; } = new List<string>();
|
||||
|
||||
|
||||
private List<ImageUploadInfo> _ImageUploadList { get; set; } = new List<ImageUploadInfo>();
|
||||
|
||||
private SCPImageUpload _upload { get; set; }
|
||||
|
||||
|
|
@ -169,7 +171,9 @@ namespace IRaCIS.Core.SCP.Service
|
|||
var _SCPImageUploadRepository = _serviceProvider.GetService<IRepository<SCPImageUpload>>();
|
||||
|
||||
_upload.EndTime = DateTime.Now;
|
||||
_upload.StudyCount = _StudyInstanceUIdList.Count;
|
||||
_upload.StudyCount = _ImageUploadList.Count;
|
||||
|
||||
_upload.UploadJsonStr = (new SCPImageLog() { UploadList = _ImageUploadList }).ToJsonStr();
|
||||
|
||||
//可能是测试echo 导致记录了
|
||||
await _SCPImageUploadRepository.AddAsync(_upload, _upload.FileCount > 0 ? true : false);
|
||||
|
|
@ -260,6 +264,7 @@ namespace IRaCIS.Core.SCP.Service
|
|||
string studyInstanceUid = request.Dataset.GetSingleValueOrDefault(DicomTag.StudyInstanceUID, string.Empty);
|
||||
string seriesInstanceUid = request.Dataset.GetSingleValueOrDefault(DicomTag.SeriesInstanceUID, string.Empty);
|
||||
string sopInstanceUid = request.Dataset.GetSingleValueOrDefault(DicomTag.SOPInstanceUID, string.Empty);
|
||||
string patientIdStr = request.Dataset.GetSingleValueOrDefault(DicomTag.PatientID, string.Empty);
|
||||
|
||||
if (studyInstanceUid.IsNullOrEmpty() || seriesInstanceUid.IsNullOrEmpty() || sopInstanceUid.IsNullOrEmpty())
|
||||
{
|
||||
|
|
@ -268,9 +273,10 @@ namespace IRaCIS.Core.SCP.Service
|
|||
return new DicomCStoreResponse(request, DicomStatus.Success);
|
||||
}
|
||||
|
||||
if (!_StudyInstanceUIdList.Contains(studyInstanceUid))
|
||||
//确保来了影像集合存在
|
||||
if (!_ImageUploadList.Any(t => t.StudyInstanceUid == studyInstanceUid))
|
||||
{
|
||||
_StudyInstanceUIdList.Add(studyInstanceUid);
|
||||
_ImageUploadList.Add(new ImageUploadInfo() { StudyInstanceUid = studyInstanceUid });
|
||||
}
|
||||
|
||||
Guid seriesId = IdentifierHelper.CreateGuid(studyInstanceUid, seriesInstanceUid);
|
||||
|
|
@ -383,44 +389,6 @@ namespace IRaCIS.Core.SCP.Service
|
|||
{
|
||||
var scpStudyId = await dicomArchiveService.ArchiveDicomFileAsync(request.Dataset, storeRelativePath, Association.CallingAE, Association.CalledAE, fileSize);
|
||||
|
||||
if (!_SCPStudyIdList.Contains(scpStudyId))
|
||||
{
|
||||
_SCPStudyIdList.Add(scpStudyId);
|
||||
|
||||
#region 给检查打课题组标签
|
||||
|
||||
//添加课题组标签
|
||||
if (CurrentHospitalGroup != null)
|
||||
{
|
||||
if (!_studyGroupRepository.Any(t => t.SCPStudyId == scpStudyId && t.HospitalGroupId == CurrentHospitalGroup.Id))
|
||||
{
|
||||
await _studyGroupRepository.AddAsync(new SCPStudyHospitalGroup() { SCPStudyId = scpStudyId, HospitalGroupId = CurrentHospitalGroup.Id });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var findCmoveInfo = _cmoveStudyRepository.Where(t => t.StudyInstanceUIDList.Any(c => c == studyInstanceUid)).OrderByDescending(t => t.CreateTime).FirstOrDefault();
|
||||
|
||||
if (findCmoveInfo != null)
|
||||
{
|
||||
foreach (var item in findCmoveInfo.HopitalGroupIdList)
|
||||
{
|
||||
if (!_studyGroupRepository.Any(t => t.SCPStudyId == scpStudyId && t.HospitalGroupId == item))
|
||||
{
|
||||
await _studyGroupRepository.AddAsync(new SCPStudyHospitalGroup() { SCPStudyId = scpStudyId, HospitalGroupId = item });
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Logger.Warning($"未找到{studyInstanceUid}的Cmove记录");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
var series = await _seriesRepository.FirstOrDefaultAsync(t => t.Id == seriesId);
|
||||
|
||||
//没有缩略图
|
||||
|
|
@ -452,22 +420,81 @@ namespace IRaCIS.Core.SCP.Service
|
|||
}
|
||||
|
||||
await _seriesRepository.SaveChangesAsync();
|
||||
|
||||
if (_ImageUploadList.Any(t => t.StudyInstanceUid == studyInstanceUid))
|
||||
{
|
||||
var find = _ImageUploadList.FirstOrDefault(t => t.StudyInstanceUid.Equals(studyInstanceUid));
|
||||
|
||||
|
||||
find.SuccessImageCount++;
|
||||
|
||||
if (!find.PatientNameList.Any(t => t == patientIdStr) && patientIdStr.IsNotNullOrEmpty())
|
||||
{
|
||||
find.PatientNameList.Add(patientIdStr);
|
||||
}
|
||||
|
||||
//首次 (默认是Guid 空,数据库归档出了Id)
|
||||
if (find.SCPStudyId != scpStudyId)
|
||||
{
|
||||
find.SCPStudyId = scpStudyId;
|
||||
|
||||
#region 给检查打课题组标签
|
||||
|
||||
//添加课题组标签
|
||||
if (CurrentHospitalGroup != null)
|
||||
{
|
||||
if (!_studyGroupRepository.Any(t => t.SCPStudyId == scpStudyId && t.HospitalGroupId == CurrentHospitalGroup.Id))
|
||||
{
|
||||
await _studyGroupRepository.AddAsync(new SCPStudyHospitalGroup() { SCPStudyId = scpStudyId, HospitalGroupId = CurrentHospitalGroup.Id });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var findCmoveInfo = _cmoveStudyRepository.Where(t => t.StudyInstanceUIDList.Any(c => c == studyInstanceUid)).OrderByDescending(t => t.CreateTime).FirstOrDefault();
|
||||
|
||||
if (findCmoveInfo != null)
|
||||
{
|
||||
foreach (var item in findCmoveInfo.HopitalGroupIdList)
|
||||
{
|
||||
if (!_studyGroupRepository.Any(t => t.SCPStudyId == scpStudyId && t.HospitalGroupId == item))
|
||||
{
|
||||
await _studyGroupRepository.AddAsync(new SCPStudyHospitalGroup() { SCPStudyId = scpStudyId, HospitalGroupId = item });
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Logger.Warning($"未找到{studyInstanceUid}的Cmove记录");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Log.Logger.Warning($"CallingAE:{Association.CallingAE} CalledAE:{Association.CalledAE} 传输处理异常:{ex.ToString()}");
|
||||
|
||||
if (_ImageUploadList.Any(t => t.StudyInstanceUid == studyInstanceUid))
|
||||
{
|
||||
var find = _ImageUploadList.FirstOrDefault(t => t.StudyInstanceUid.Equals(studyInstanceUid));
|
||||
|
||||
find.FailedImageCount++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//监控信息设置
|
||||
_upload.FileCount++;
|
||||
_upload.FileSize = _upload.FileSize + fileSize;
|
||||
return new DicomCStoreResponse(request, DicomStatus.Success);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//监控信息设置
|
||||
_upload.FileCount++;
|
||||
_upload.FileSize = _upload.FileSize + fileSize;
|
||||
return new DicomCStoreResponse(request, DicomStatus.Success);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -223,6 +223,7 @@ namespace IRaCIS.Core.SCP.Service
|
|||
findStudy.PatientName = dataset.GetSingleValueOrDefault(DicomTag.PatientName, string.Empty);
|
||||
findStudy.PatientSex = dataset.GetSingleValueOrDefault(DicomTag.PatientSex, string.Empty);
|
||||
findStudy.PatientAge = dataset.GetSingleValueOrDefault(DicomTag.PatientAge, string.Empty);
|
||||
findStudy.UpdateTime = DateTime.Now;
|
||||
|
||||
await _patientRepository.BatchUpdateNoTrackingAsync(t => t.Id == findStudy.PatientId, u => new SCPPatient() { LatestPushTime = DateTime.Now });
|
||||
}
|
||||
|
|
@ -271,6 +272,7 @@ namespace IRaCIS.Core.SCP.Service
|
|||
{
|
||||
findSerice.DicomSeriesDate = dataset.GetSingleValueOrDefault(DicomTag.SeriesDate, string.Empty);
|
||||
findSerice.DicomSeriesTime = dataset.GetSingleValueOrDefault(DicomTag.SeriesTime, string.Empty);
|
||||
findSerice.UpdateTime=DateTime.Now;
|
||||
}
|
||||
|
||||
var transferSyntaxUID = dataset.GetSingleValueOrDefault(DicomTag.TransferSyntaxUID, string.Empty);
|
||||
|
|
@ -332,6 +334,7 @@ namespace IRaCIS.Core.SCP.Service
|
|||
findInstance.TransferSyntaxUID = transferSyntaxUID;
|
||||
findInstance.MediaStorageSOPInstanceUID = dataset.GetSingleValueOrDefault(DicomTag.MediaStorageSOPInstanceUID, string.Empty);
|
||||
findInstance.IsEncapsulated = isEncapsulated;
|
||||
findInstance.UpdateTime = DateTime.Now;
|
||||
}
|
||||
|
||||
if (isPatientNeedAdd)
|
||||
|
|
|
|||
|
|
@ -1042,6 +1042,8 @@ namespace IRaCIS.Application.Contracts
|
|||
|
||||
public int StudyCount { get; set; }
|
||||
|
||||
public string UploadJsonStr { get; set; }
|
||||
|
||||
}
|
||||
public class VisitPatientStudyView : PatientStudySelectDto
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
using System.Linq;
|
||||
|
||||
namespace IRaCIS.Core.Domain.Models;
|
||||
|
||||
[Comment("项目中心 - 影像推送记录")]
|
||||
|
|
@ -14,4 +16,36 @@ public class SCPImageUpload : BaseAddAuditEntity
|
|||
public long FileSize { get; set; }
|
||||
public int StudyCount { get; set; }
|
||||
|
||||
[MaxLength]
|
||||
public string UploadJsonStr { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class SCPImageLog
|
||||
{
|
||||
////当前传输 检查患者名字,一个检查可能患者名字不同 记录去重的,然后,拼接
|
||||
//public string PatientNames => string.Join(",", UploadList.SelectMany(t => t.PatientNameList).ToList());
|
||||
|
||||
/// <summary>
|
||||
/// 归档到数据库的检查Id
|
||||
/// </summary>
|
||||
public List<Guid> SCPStudyIdList => UploadList.Select(t => t.SCPStudyId).ToList();
|
||||
|
||||
|
||||
public List<ImageUploadInfo> UploadList { get; set; } = new List<ImageUploadInfo>();
|
||||
|
||||
}
|
||||
|
||||
public class ImageUploadInfo
|
||||
{
|
||||
public List<string> PatientNameList { get; set; } = new List<string>();
|
||||
|
||||
public Guid SCPStudyId { get; set; }
|
||||
|
||||
public string StudyInstanceUid { get; set; }
|
||||
|
||||
|
||||
public int FailedImageCount { get; set; }
|
||||
|
||||
public int SuccessImageCount { get; set; }
|
||||
}
|
||||
19205
IRaCIS.Core.Infra.EFCore/Migrations/20250917023357_scpImageUploadModify.Designer.cs
generated
Normal file
19205
IRaCIS.Core.Infra.EFCore/Migrations/20250917023357_scpImageUploadModify.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,29 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace IRaCIS.Core.Infra.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class scpImageUploadModify : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "UploadJsonStr",
|
||||
table: "SCPImageUpload",
|
||||
type: "nvarchar(max)",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "UploadJsonStr",
|
||||
table: "SCPImageUpload");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7748,6 +7748,10 @@ namespace IRaCIS.Core.Infra.EFCore.Migrations
|
|||
b.Property<int>("StudyCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("UploadJsonStr")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CreateUserId");
|
||||
|
|
|
|||
Loading…
Reference in New Issue