diff --git a/IRC.Core.SCP/HostConfig/SyncFileRecoveryService.cs b/IRC.Core.SCP/HostConfig/SyncFileRecoveryService.cs index 894d36696..5114d819d 100644 --- a/IRC.Core.SCP/HostConfig/SyncFileRecoveryService.cs +++ b/IRC.Core.SCP/HostConfig/SyncFileRecoveryService.cs @@ -107,7 +107,7 @@ public class FileSyncWorker(IServiceScopeFactory _scopeFactory, ILogger + + + 按照 subject visit studyCode 三个维度进行分组的查询列表 (subject相关) + + + + - 上传记录表--里面包含待同步任务 + 上传记录表--里面包含待同步任务 DataFileType= 0 :代表系统文件 1:Subject相关 2:项目相关,但是和subject 没关系 - 任务具体执行记录表 (需要同步的才可以点击) + 任务具体执行记录表 @@ -1582,6 +1589,12 @@ + + + 获取队列任务Id + + + 入队任务 @@ -17086,17 +17099,17 @@ - ���� + 质疑 - һ���Ժ˲� + 一致性核查 - ���� + 复制 diff --git a/IRaCIS.Core.Application/Service/Common/DTO/FileUploadRecordViewModel.cs b/IRaCIS.Core.Application/Service/Common/DTO/FileUploadRecordViewModel.cs index ed3f0ffbe..95c632ece 100644 --- a/IRaCIS.Core.Application/Service/Common/DTO/FileUploadRecordViewModel.cs +++ b/IRaCIS.Core.Application/Service/Common/DTO/FileUploadRecordViewModel.cs @@ -9,6 +9,31 @@ using IRaCIS.Core.Domain.Share; using System.Collections.Generic; namespace IRaCIS.Core.Application.ViewModel; +public class SubjectFileUploadRecordView +{ + public string? SubjectCode { get; set; } + + public string? VisitName { get; set; } + + public string StudyCode { get; set; } + + public Guid? SubjectId { get; set; } + + public Guid? SubjectVisitId { get; set; } + + public int FileCount { get; set; } + + + public string? UploadRegion { get; set; } + public string? TargetRegion { get; set; } + + + public DateTime CreateTime { get; set; } + public DateTime? SyncFinishedTime { get; set; } + + public bool IsSync { get; set; } +} + public class FileUploadRecordView : FileUploadRecordAddOrEdit { @@ -22,6 +47,11 @@ public class FileUploadRecordView : FileUploadRecordAddOrEdit [Comment("同步结束时间-最后一个任务的时间")] public DateTime? SyncFinishedTime { get; set; } + + public string? SubjectCode { get; set; } + + public string? VisitName { get; set; } + } @@ -65,16 +95,40 @@ public class FileUploadRecordAddOrEdit public string TargetRegion { get; set; } } + +public class SubjectFileUploadRecordQuery : PageInput +{ + public Guid TrialId { get; set; } + + public string? SubjectCode { get; set; } + + public string? VisitName { get; set; } + + public string? StudyCode { get; set; } + + public string? UploadRegion { get; set; } + public string? TargetRegion { get; set; } + + public bool? IsSync { get; set; } + + +} + public class FileUploadRecordQuery : PageInput { public BatchDataType? BatchDataType { get; set; } public Guid? TrialId { get; set; } - public bool? IsSystermFile { get; set; } + public int? DataFileType { get; set; } public string StudyCode { get; set; } + public Guid? SubjectId { get; set; } + + public Guid? SubjectVisitId { get; set; } + + public string? FileMarkId { get; set; } @@ -115,6 +169,7 @@ public class FileUploadRecordQuery : PageInput public class UploadFileSyncRecordView { + public Guid Id { get; set; } public DateTime? StartTime { get; set; } @@ -125,13 +180,40 @@ public class UploadFileSyncRecordView public string Msg { get; set; } + + public DateTime CreateTime { get; set; } + + public DateTime UpdateTime { get; set; } + + + public Guid? FileUploadRecordId { get; set; } + public string? FileName { get; set; } + + public string? FileType { get; set; } + + public string? Path { get; set; } + + + public string StudyCode { get; set; } + + public string? SubjectCode { get; set; } + + public string? VisitName { get; set; } + + + } -public class UploadFileSyncRecordQuery:PageInput +public class UploadFileSyncRecordQuery : PageInput { public Guid? FileUploadRecordId { get; set; } public jobState? JobState { get; set; } -} \ No newline at end of file +} + +public class BatchAddSyncFileCommand +{ + public List FileUploadRecordIdList { get; set; } +} diff --git a/IRaCIS.Core.Application/Service/Common/FileUploadRecordService.cs b/IRaCIS.Core.Application/Service/Common/FileUploadRecordService.cs index 444f14e09..2d7f4dcdb 100644 --- a/IRaCIS.Core.Application/Service/Common/FileUploadRecordService.cs +++ b/IRaCIS.Core.Application/Service/Common/FileUploadRecordService.cs @@ -31,10 +31,55 @@ public class FileUploadRecordService(IRepository _fileUploadRe + /// + /// 按照 subject visit studyCode 三个维度进行分组的查询列表 (subject相关) + /// + /// + /// + [HttpPost] + public async Task> GetSubjectUploadRecordList(SubjectFileUploadRecordQuery inQuery) + { + + var query = _fileUploadRecordRepository.Where(t => t.TrialId == inQuery.TrialId && t.SubjectId != null) + .WhereIf(!string.IsNullOrEmpty(inQuery.VisitName), t => t.SubjectVisit.VisitName.Contains(inQuery.VisitName)) + .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => t.Subject.Code.Contains(inQuery.SubjectCode)) + .WhereIf(!string.IsNullOrEmpty(inQuery.StudyCode), t => t.StudyCode.Contains(inQuery.StudyCode)) + .WhereIf(!string.IsNullOrEmpty(inQuery.UploadRegion), t => t.UploadRegion == inQuery.UploadRegion) + .WhereIf(!string.IsNullOrEmpty(inQuery.TargetRegion), t => t.TargetRegion == inQuery.TargetRegion) + .WhereIf(inQuery.IsSync != null, t => t.IsSync == inQuery.IsSync) + .GroupBy(t => new { t.StudyCode, SubjectCode = t.Subject.Code, t.SubjectVisit.VisitName, t.SubjectId, t.SubjectVisitId }) + .Select(g => new SubjectFileUploadRecordView() + { + SubjectCode = g.Key.SubjectCode, + VisitName = g.Key.VisitName, + StudyCode = g.Key.StudyCode, + SubjectId = g.Key.SubjectId, + SubjectVisitId = g.Key.SubjectVisitId, + + FileCount = g.Count(), + + CreateTime = g.Max(t => t.CreateTime), + + SyncFinishedTime = g.Max(t => t.SyncFinishedTime), + + UploadRegion = g.First().UploadRegion, + + TargetRegion = g.First().TargetRegion, + + IsSync = !g.Any(t => t.IsSync == false) + + }); + + + var pageList = await query.ToPagedListAsync(inQuery); + + return pageList; + } + /// - /// 上传记录表--里面包含待同步任务 + /// 上传记录表--里面包含待同步任务 DataFileType= 0 :代表系统文件 1:Subject相关 2:项目相关,但是和subject 没关系 /// /// /// @@ -46,14 +91,26 @@ public class FileUploadRecordService(IRepository _fileUploadRe .WhereIf(inQuery.BatchDataType != null, t => t.BatchDataType == inQuery.BatchDataType) .WhereIf(!string.IsNullOrEmpty(inQuery.FileName), t => t.FileName.Contains(inQuery.FileName)) .WhereIf(!string.IsNullOrEmpty(inQuery.FileType), t => t.FileType.Contains(inQuery.FileType)) - .WhereIf(!string.IsNullOrEmpty(inQuery.StudyCode), t => t.StudyCode.Contains(inQuery.StudyCode)) .WhereIf(inQuery.TrialId != null, t => t.TrialId == inQuery.TrialId) - .WhereIf(inQuery.IsSystermFile == true, t => t.TrialId == null) + + .WhereIf(inQuery.SubjectId != null, t => t.SubjectId == inQuery.SubjectId) + .WhereIf(inQuery.SubjectVisitId != null, t => t.SubjectVisitId == inQuery.SubjectVisitId) + .WhereIf(!string.IsNullOrEmpty(inQuery.StudyCode), t => t.StudyCode.Contains(inQuery.StudyCode)) + + .WhereIf(inQuery.DataFileType == 1 && inQuery.SubjectId != null && inQuery.SubjectVisitId == null, t => t.SubjectVisitId == null) + .WhereIf(inQuery.DataFileType == 1 && inQuery.SubjectVisitId != null && inQuery.StudyCode.IsNullOrEmpty(), t => t.StudyCode == "") + + .WhereIf(inQuery.DataFileType == 0, t => t.TrialId == null) + .WhereIf(inQuery.DataFileType == 1, t => t.SubjectId != null) + .WhereIf(inQuery.DataFileType == 2, t => t.SubjectId == null) + + .WhereIf(inQuery.IsNeedSync != null, t => t.IsNeedSync == inQuery.IsNeedSync) + .WhereIf(inQuery.IsSync != null, t => t.IsSync == inQuery.IsSync) .WhereIf(inQuery.Priority != null, t => t.Priority == inQuery.Priority) .WhereIf(inQuery.BatchDataType != null, t => t.BatchDataType == inQuery.BatchDataType) - .WhereIf(!string.IsNullOrEmpty(inQuery.UploadRegion), t => t.UploadRegion.Contains(inQuery.UploadRegion)) - .WhereIf(!string.IsNullOrEmpty(inQuery.TargetRegion), t => t.TargetRegion.Contains(inQuery.TargetRegion)) + .WhereIf(!string.IsNullOrEmpty(inQuery.UploadRegion), t => t.UploadRegion == inQuery.UploadRegion) + .WhereIf(!string.IsNullOrEmpty(inQuery.TargetRegion), t => t.TargetRegion == inQuery.TargetRegion) .WhereIf(!string.IsNullOrEmpty(inQuery.UploadBatchId), t => t.UploadBatchId.Contains(inQuery.UploadBatchId)) .WhereIf(!string.IsNullOrEmpty(inQuery.Path), t => t.Path.Contains(inQuery.Path)) .WhereIf(inQuery.UploadStartTime != null, t => t.CreateTime >= inQuery.UploadStartTime) @@ -69,7 +126,7 @@ public class FileUploadRecordService(IRepository _fileUploadRe } /// - /// 任务具体执行记录表 (需要同步的才可以点击) + /// 任务具体执行记录表 /// /// /// @@ -79,7 +136,7 @@ public class FileUploadRecordService(IRepository _fileUploadRe var fileUploadRecordQueryable = _uploadFileSyncRecordRepository - .WhereIf(inQuery.FileUploadRecordId != null, t => t.FileUploadRecordId >= inQuery.FileUploadRecordId) + .WhereIf(inQuery.FileUploadRecordId != null, t => t.FileUploadRecordId == inQuery.FileUploadRecordId) .ProjectTo(_mapper.ConfigurationProvider); @@ -90,6 +147,16 @@ public class FileUploadRecordService(IRepository _fileUploadRe } + public async Task BatchAddSyncFileTask(BatchAddSyncFileCommand inComand) + { + + + + + + return ResponseOutput.Ok(); + } + @@ -143,7 +210,9 @@ public class FileUploadRecordService(IRepository _fileUploadRe } else { - addOrEditFileUploadRecord.TargetRegion = ""; + addOrEditFileUploadRecord.IsNeedSync = false; + + //addOrEditFileUploadRecord.TargetRegion = ""; } @@ -218,6 +287,20 @@ public class FileSyncQueue return _queue.Dequeue(); } } + + /// + /// 获取队列任务Id + /// + /// + public Guid[] Snapshot() + { + lock (_lock) + { + return _queue.UnorderedItems + .Select(x => x.Element) + .ToArray(); + } + } } #region 这里不用 SyncQueueUseChannel 和调度器 SyncScheduler diff --git a/IRaCIS.Core.Application/Service/Common/_MapConfig.cs b/IRaCIS.Core.Application/Service/Common/_MapConfig.cs index e27ac47e0..20114af4a 100644 --- a/IRaCIS.Core.Application/Service/Common/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Common/_MapConfig.cs @@ -20,7 +20,7 @@ namespace IRaCIS.Core.Application.Service CreateMap() .ForMember(t => t.RecipientList, u => u.MapFrom(c => c.EmailRecipientLogList)) - .ForMember(t => t.AttachmentList, u => u.MapFrom(c => c.AttachmentList)); + .ForMember(t => t.AttachmentList, u => u.MapFrom(c => c.AttachmentList)); CreateMap().ReverseMap(); @@ -41,7 +41,7 @@ namespace IRaCIS.Core.Application.Service .ForMember(t => t.EmailNoticeUserList, u => u.MapFrom(c => c.EmailNoticeUserTypeList)); CreateMap(); - + CreateMap() .ForMember(t => t.ParentCode, u => u.MapFrom(c => c.Parent.Code)); @@ -89,14 +89,14 @@ namespace IRaCIS.Core.Application.Service CreateMap().ReverseMap(); CreateMap(); - + CreateMap().ReverseMap(); CreateMap(); CreateMap(); - + CreateMap(); @@ -116,7 +116,7 @@ namespace IRaCIS.Core.Application.Service .ForMember(d => d.TrialSiteCode, u => u.MapFrom(s => s.Subject.TrialSite.TrialSiteCode)); - CreateMap(); + CreateMap(); CreateMap(); CreateMap(); CreateMap(); @@ -125,12 +125,20 @@ namespace IRaCIS.Core.Application.Service CreateMap(); - CreateMap(); + CreateMap() + .ForMember(d => d.SubjectCode, u => u.MapFrom(s => s.Subject.Code)) + .ForMember(d => d.VisitName, u => u.MapFrom(s => s.SubjectVisit.VisitName)); CreateMap().ReverseMap(); - CreateMap(); - + CreateMap() + .ForMember(d => d.FileName, u => u.MapFrom(s => s.FileUploadRecord.FileName)) + .ForMember(d => d.FileType, u => u.MapFrom(s => s.FileUploadRecord.FileType)) + .ForMember(d => d.Path, u => u.MapFrom(s => s.FileUploadRecord.Path)) + .ForMember(d => d.StudyCode, u => u.MapFrom(s => s.FileUploadRecord.StudyCode)) + .ForMember(d => d.SubjectCode, u => u.MapFrom(s => s.FileUploadRecord.Subject.Code)) + .ForMember(d => d.VisitName, u => u.MapFrom(s => s.FileUploadRecord.SubjectVisit.VisitName)); + } }