From 1a3ad4f602a5a9f86ef882e4e57d989049e9fa40 Mon Sep 17 00:00:00 2001 From: he <109787524@qq.com> Date: Fri, 28 Jun 2024 09:35:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/QC/DTO/QCListViewModel.cs | 13 +++- .../Service/QC/QCListService.cs | 64 +++++++++++++++++-- 2 files changed, 71 insertions(+), 6 deletions(-) diff --git a/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs b/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs index dd47abc68..82c491a75 100644 --- a/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs +++ b/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs @@ -1107,8 +1107,19 @@ namespace IRaCIS.Core.Application.Contracts } + public class GetNextCRCChallengeInDto + { + [NotDefault] + public Guid TrialId { get; set; } - public class ChallengeQuery : PageInput + /// + /// QCChallengeId + /// + public Guid QCChallengeId { get; set; } + } + + + public class ChallengeQuery : PageInput { [NotDefault] public Guid TrialId { get; set; } diff --git a/IRaCIS.Core.Application/Service/QC/QCListService.cs b/IRaCIS.Core.Application/Service/QC/QCListService.cs index 11c4b7e90..4bcae96ac 100644 --- a/IRaCIS.Core.Application/Service/QC/QCListService.cs +++ b/IRaCIS.Core.Application/Service/QC/QCListService.cs @@ -9,6 +9,7 @@ using IRaCIS.Application.Contracts; using IRaCIS.Core.Application.ViewModel; using IRaCIS.Core.Application.Service.Reading.Dto; using static Org.BouncyCastle.Math.EC.ECCurve; +using IRaCIS.Core.Infrastructure; namespace IRaCIS.Core.Application.Image.QA { @@ -87,14 +88,67 @@ namespace IRaCIS.Core.Application.Image.QA } - - /// - /// CRC 质疑列表 + /// 获取下一个crc的未关闭的质疑 /// - /// + /// /// + /// [HttpPost] + public async Task GetNextCRCChallenge(GetNextCRCChallengeInDto inDto) + { + var list =await GetCRCChallengeList(new ChallengeQuery() + { + TrialId = inDto.TrialId, + PageIndex = 1, + PageSize = 9999 + }); + + + var data = list.Item1.CurrentPageData.Where(x=>x.Id==inDto.QCChallengeId||x.IsClosed==false).ToList(); + + if (data.Count > 0) + { + + var index = data.ToList().FindIndex(x => x.Id == inDto.QCChallengeId); + + var result = new QCCRCChallengeViewModel() { }; + + if (index + 1 == data.Count()) // 最后一个 + { + throw new BusinessValidationFailedException(_localizer["QCList_CRCFinishChallenge"]); + } + else if (index == -1 || data.Count == 1) // 第一个或者只有一个 + { + if (data[0].Id == inDto.QCChallengeId) + { + throw new BusinessValidationFailedException(_localizer["QCList_CRCFinishChallenge"]); + } + result = data[0]; + } + else + { + result = data.Skip(index + 1).Take(1).First(); + + } + return result; + + } + else + { + throw new BusinessValidationFailedException(_localizer["QCList_CRCFinishChallenge"]); + } + + } + + + + /// + /// CRC 质疑列表 + /// + /// + /// + [HttpPost] public async Task<(PageOutput, TrialSubjectAndSVConfig)> GetCRCChallengeList(ChallengeQuery challengeQuery) { @@ -117,7 +171,7 @@ namespace IRaCIS.Core.Application.Image.QA .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CRA, t => t.SubjectVisit.TrialSite.CRCUserList.Any(t => t.UserId == _userInfo.Id)) .ProjectTo(_mapper.ConfigurationProvider); - var pageList = await query2.ToPagedListAsync(challengeQuery.PageIndex, challengeQuery.PageSize, challengeQuery.SortField, challengeQuery.Asc, string.IsNullOrWhiteSpace(challengeQuery.SortField), new string[] { "IsUrgent desc", "IsClosed asc" }); + var pageList = await query2.ToPagedListAsync(challengeQuery.PageIndex, challengeQuery.PageSize, challengeQuery.SortField, challengeQuery.Asc, string.IsNullOrWhiteSpace(challengeQuery.SortField), new string[] { "IsUrgent desc", "CreateTime asc" }); var config = await _repository.Where(t => t.Id == challengeQuery.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync().IfNullThrowException(); return (pageList, config);