From 46b5846d0ccb792470b73012ccb7b2638045eab8 Mon Sep 17 00:00:00 2001 From: he <10978375@qq.com> Date: Mon, 6 Jun 2022 17:32:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/InspectionController.cs | 4 +- IRaCIS.Core.API/IRaCIS.Core.API.xml | 2 +- .../Service/Inspection/InspectionService.cs | 13 +- .../Interface/IInspectionService.cs | 2 +- .../Common/AuditingData.cs | 143 +++++++----------- 5 files changed, 67 insertions(+), 97 deletions(-) diff --git a/IRaCIS.Core.API/Controllers/InspectionController.cs b/IRaCIS.Core.API/Controllers/InspectionController.cs index ea0bab87c..5052df95d 100644 --- a/IRaCIS.Core.API/Controllers/InspectionController.cs +++ b/IRaCIS.Core.API/Controllers/InspectionController.cs @@ -86,9 +86,9 @@ namespace IRaCIS.Core.API.Controllers /// /// [HttpPost, Route("Inspection/GetInspectionData")] - public async Task> GetInspectionData(GetDataInspectionDto dto) + public async Task> GetInspectionList(GetDataInspectionDto dto) { - return await _inspectionService.GetInspectionData(dto); + return await _inspectionService.GetInspectionList(dto); } #endregion diff --git a/IRaCIS.Core.API/IRaCIS.Core.API.xml b/IRaCIS.Core.API/IRaCIS.Core.API.xml index 87aed4ebc..77526e2d4 100644 --- a/IRaCIS.Core.API/IRaCIS.Core.API.xml +++ b/IRaCIS.Core.API/IRaCIS.Core.API.xml @@ -84,7 +84,7 @@ Financials /Monthly Payment 列表查询接口 - + 获取稽查数据 diff --git a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs index a897daf77..e59a90143 100644 --- a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs +++ b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs @@ -25,17 +25,17 @@ namespace IRaCIS.Core.Application.Service.Inspection - public async Task> GetInspectionData(GetDataInspectionDto dto) + public async Task> GetInspectionList(GetDataInspectionDto dto) { //_repository.GetQueryable.GetQueryable < DataInspection > - var trialfirst= await _repository.GetQueryable< Trial >().Where(x=>x.Id== dto.TrialId).AsNoTracking().FirstOrDefaultAsync(); + var trialData= await _repository.GetQueryable().Where(x=>x.Id== dto.TrialId).AsNoTracking().FirstOrDefaultAsync(); - trialfirst.TrialFinishTime = trialfirst.TrialFinishTime == null ? DateTime.Now : trialfirst.TrialFinishTime; + trialData.TrialFinishTime = trialData.TrialFinishTime == null ? DateTime.Now : trialData.TrialFinishTime; #region 逻辑代码 - var query = from data in _repository.GetQueryable().Where(x => (x.TrialId == dto.TrialId)||(x.TrialId==null&&x.CreateTime> trialfirst.CreateTime&&x.CreateTime < trialfirst.TrialFinishTime)) + var query = from data in _repository.GetQueryable().Where(x => (x.TrialId == dto.TrialId)||(x.TrialId==null&&x.CreateTime> trialData.CreateTime&&x.CreateTime < trialData.TrialFinishTime)) join trial in _repository.GetQueryable().IgnoreQueryFilters() on data.TrialId equals trial.Id into trialtemp from leftrial in trialtemp.DefaultIfEmpty() @@ -127,7 +127,6 @@ namespace IRaCIS.Core.Application.Service.Inspection IsFrontAdd=data.IsFrontAdd, BatchId=data.BatchId, OptTypeName = leftOptType.Value, - }; query = query.WhereIf(dto.SiteId != null, x => x.SiteId == dto.SiteId) @@ -141,14 +140,12 @@ namespace IRaCIS.Core.Application.Service.Inspection .WhereIf(!dto.OpByUserName.IsNullOrEmpty(), x => x.CreateUserName.Contains(dto.OpByUserName)) //.WhereIf(!dto.SubjectInfo.IsNullOrEmpty(), x => x.SubjectCode.Contains(dto.SubjectInfo)) .WhereIf(dto.IsSign != null, x => x.IsSign == dto.IsSign); - - #endregion dto.Asc = false; - return await query.ToPagedListAsync(dto.PageIndex, dto.PageSize, "CreateTime", dto.Asc); + return await query.ToPagedListAsync(dto.PageIndex, dto.PageSize,"CreateTime", dto.Asc); } diff --git a/IRaCIS.Core.Application/Service/Inspection/Interface/IInspectionService.cs b/IRaCIS.Core.Application/Service/Inspection/Interface/IInspectionService.cs index 141506bc5..74c0d7c9b 100644 --- a/IRaCIS.Core.Application/Service/Inspection/Interface/IInspectionService.cs +++ b/IRaCIS.Core.Application/Service/Inspection/Interface/IInspectionService.cs @@ -11,7 +11,7 @@ namespace IRaCIS.Core.Application.Service.Inspection.Interface public interface IInspectionService { - Task> GetInspectionData(GetDataInspectionDto dto); + Task> GetInspectionList(GetDataInspectionDto dto); diff --git a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs index 88644bf6c..133ad3ae2 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs @@ -85,45 +85,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common } } - /// - /// 需要赋值的GeneralId - /// - private List NeedSetGeneralIdList - { - get - { - return new List() - { - typeof(SystemDocument), - typeof(SystemBasicData), - typeof(Trial), - typeof(VisitStage), - typeof(TrialDocument), - typeof(SystemDocConfirmedUser), - typeof(TrialDocUserTypeConfirmedUser), - typeof(Enroll), - typeof(EnrollDetail), - typeof(TrialSite), - typeof(TrialUser), - typeof(TrialSiteUser), - typeof(TrialSiteSurvey), - typeof(TrialQCQuestion), - typeof(DicomStudy), - typeof(DicomSeries), - typeof(NoneDicomStudy), - typeof(CheckChallengeDialog), - typeof(PreviousSurgery), - typeof(PreviousHistory), - typeof(PreviousOther), - typeof(QCChallenge), - typeof(QCChallengeDialog), - typeof(QCQuestion), - typeof(ConsistencyCheckFile), - typeof(DataInspection), - - }; - } - } + /// /// 插入Add的实体 @@ -170,7 +132,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common { var entity = item.Entity as Trial; - List trials = new List(); + List trialDics = new List(); var dictionaryIds = new List(); if (entity.TrialDicList == null || entity.TrialDicList.Count == 0) { @@ -183,7 +145,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common } - trials = await this._dbContext.Dictionary.Where(x => dictionaryIds.Contains(x.Id)).Select(x => x.ValueCN).ToListAsync(); + trialDics = await this._dbContext.Dictionary.Where(x => dictionaryIds.Contains(x.Id)).Select(x => x.ValueCN).ToListAsync(); await InsertInspection(item.Entity as Trial, type, x => new DataInspection() @@ -194,7 +156,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common GeneralId = x.Id, }, new { - TrialDicList = string.Join(",", trials) + TrialDicList = string.Join(",", trialDics) }, item.OriginalValues); } @@ -204,10 +166,10 @@ namespace IRaCIS.Core.Infra.EFCore.Common var entity = item.Entity as VisitStage; - var VisitPlanStatus = await this._dbContext.Trial.Where(x => x.Id == entity.TrialId).Select(x => x.VisitPlanConfirmed).FirstOrDefaultAsync(); + var visitPlanStatus = await this._dbContext.Trial.Where(x => x.Id == entity.TrialId).Select(x => x.VisitPlanConfirmed).FirstOrDefaultAsync(); if (type == "Add") { - VisitPlanStatus = false; + visitPlanStatus = false; } await InsertInspection(item.Entity as VisitStage, type, x => new DataInspection() { @@ -215,7 +177,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common GeneralId = x.Id, }, new { - VisitPlanStatus = VisitPlanStatus, + VisitPlanStatus = visitPlanStatus, }); } @@ -319,7 +281,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common SiteAliasName = entity.TrialSiteAliasName, City = entity.Site.City, Country = entity.Site.Country, - Status = entity.IsDeleted ? "禁用" : "启用", }); } @@ -340,7 +301,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common EMail = user.EMail, Phone = user.Phone, OrganizationName = user.OrganizationName, - State = entity.IsDeleted ? "退出" : "加入", + }); } @@ -386,7 +347,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common SiteAliasName = entity.TrialSite.TrialSiteAliasName, City = entity.Site.City, Country = entity.Site.Country, - Status = entity.IsDeleted ? "禁用" : "启用", + UserName = user.UserName, UserRealName = user.FullName, UserType = userType.UserTypeShortName, @@ -429,7 +390,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common Email = entity.Email, PreliminaryUser = entity.PreliminaryUser == null ? "" : entity.PreliminaryUser.LastName + " / " + entity.PreliminaryUser.FirstName, ReviewerUser = entity.ReviewerUser == null ? "" : entity.ReviewerUser.LastName + " / " + entity.ReviewerUser.FirstName, - IsDeleted = entity.IsDeleted ? "是" : "否", + }); } @@ -459,7 +420,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(Subject))) { var entity = item.Entity as Subject; - var FinalSubjectVisitName = await _dbContext.SubjectVisit.AsNoTracking().Where(x => x.Id == entity.FinalSubjectVisitId && entity.FinalSubjectVisitId != null).Select(x => x.VisitName).FirstOrDefaultAsync(); + var finalSubjectVisitName = await _dbContext.SubjectVisit.AsNoTracking().Where(x => x.Id == entity.FinalSubjectVisitId && entity.FinalSubjectVisitId != null).Select(x => x.VisitName).FirstOrDefaultAsync(); await InsertInspection(entity, type, x => new DataInspection() { @@ -467,7 +428,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common SubjectCode = x.Code, }, new { - FinalSubjectVisitName = FinalSubjectVisitName, + FinalSubjectVisitName = finalSubjectVisitName, }); } @@ -504,7 +465,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(NoneDicomStudy))) { var entity = item.Entity as NoneDicomStudy; - var filecount = await _dbContext.NoneDicomStudyFile.Where(x => x.NoneDicomStudyId == entity.Id).CountAsync(); + var fileCount = await _dbContext.NoneDicomStudyFile.Where(x => x.NoneDicomStudyId == entity.Id).CountAsync(); await InsertInspection(item.Entity as NoneDicomStudy, type, x => new DataInspection() @@ -512,7 +473,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common GeneralId = x.Id, }, new { - FileCount = filecount, + FileCount = fileCount, }); } @@ -546,7 +507,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common } - //一致性核查 + //一致性核查 // 特殊GeneralId foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(CheckChallengeDialog))) { @@ -692,7 +653,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common }); } - // 质疑信息 + // 质疑信息 // 特殊GeneralId foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(QCChallengeDialog))) { var reason = string.Empty; @@ -742,7 +703,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common - // 一致性核查文件 + // 一致性核查文件 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ConsistencyCheckFile))) { await InsertInspection(item.Entity as ConsistencyCheckFile, type, x => new DataInspection() @@ -752,24 +713,24 @@ namespace IRaCIS.Core.Infra.EFCore.Common }); } - // Qc 问题答案 + // Qc 问题答案 // 特殊GeneralId if (entitys.Any(x => x.Entity.GetType() == typeof(TrialQCQuestionAnswer))) { var entitylist = entitys.Where(x => x.Entity.GetType() == typeof(TrialQCQuestionAnswer)).Select(x => x.Entity as TrialQCQuestionAnswer).ToList(); - var firstentity = entitylist.FirstOrDefault(); - var subjectvisit = await _dbContext.SubjectVisit.Where(x => x.Id == firstentity.SubjectVisitId).FirstOrDefaultAsync(); - subjectvisit = subjectvisit ?? new SubjectVisit(); + var firstEntity = entitylist.FirstOrDefault(); + var subjectVisit = await _dbContext.SubjectVisit.Where(x => x.Id == firstEntity.SubjectVisitId).FirstOrDefaultAsync(); + subjectVisit = subjectVisit ?? new SubjectVisit(); if (type == "Add") { await AddInspectionRecordAsync(new DataInspection() { - SiteId = subjectvisit.SiteId, - Identification = $"{_userInfo.RequestUrl}/{ firstentity.GetType().Name}/{type}", - SubjectId = subjectvisit.SubjectId, - SubjectVisitName = subjectvisit.VisitName, - TrialId = subjectvisit.TrialId, - SubjectVisitId = subjectvisit.Id, - GeneralId = subjectvisit.Id, + SiteId = subjectVisit.SiteId, + Identification = $"{_userInfo.RequestUrl}/{ firstEntity.GetType().Name}/{type}", + SubjectId = subjectVisit.SubjectId, + SubjectVisitName = subjectVisit.VisitName, + TrialId = subjectVisit.TrialId, + SubjectVisitId = subjectVisit.Id, + GeneralId = subjectVisit.Id, }, new { QcQuestionAnswerCommands = await Getdata(entitylist), @@ -778,19 +739,19 @@ namespace IRaCIS.Core.Infra.EFCore.Common else if (type == "Update") { - var questionids = entitylist.Where(x => x.SubjectVisitId == subjectvisit.Id).Select(x => x.Id).ToList(); + var questionIds = entitylist.Where(x => x.SubjectVisitId == subjectVisit.Id).Select(x => x.Id).ToList(); var createUserId = entitylist.Select(x => x.CreateUserId).FirstOrDefault(); - var noupdatedata = _dbContext.TrialQCQuestionAnswer.Where(x => x.CreateUserId== createUserId&& x.SubjectVisitId == subjectvisit.Id && !questionids.Contains(x.Id)).ToList(); - entitylist.AddRange(noupdatedata); + var noUpdateData = _dbContext.TrialQCQuestionAnswer.Where(x => x.CreateUserId== createUserId&& x.SubjectVisitId == subjectVisit.Id && !questionIds.Contains(x.Id)).ToList(); + entitylist.AddRange(noUpdateData); await AddInspectionRecordAsync(new DataInspection() { - Identification = $"{_userInfo.RequestUrl}/{ firstentity.GetType().Name}/{type}", - SiteId = subjectvisit.SiteId, - SubjectId = subjectvisit.SubjectId, - TrialId = subjectvisit.TrialId, - SubjectVisitId = subjectvisit.Id, - SubjectVisitName = subjectvisit.VisitName, - GeneralId = subjectvisit.Id, + Identification = $"{_userInfo.RequestUrl}/{ firstEntity.GetType().Name}/{type}", + SiteId = subjectVisit.SiteId, + SubjectId = subjectVisit.SubjectId, + TrialId = subjectVisit.TrialId, + SubjectVisitId = subjectVisit.Id, + SubjectVisitName = subjectVisit.VisitName, + GeneralId = subjectVisit.Id, }, new { QcQuestionAnswerCommands = await Getdata(entitylist), @@ -924,8 +885,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common break; } - - inspection.Identification = $"{_userInfo.RequestUrl}/{ entityTypeName}/{type}"; #region 注释 @@ -980,11 +939,25 @@ namespace IRaCIS.Core.Infra.EFCore.Common /// 数据 /// /// - public async Task AddInspectionRecordAsync(DataInspection add, dynamic data, object otherItem = null) + public async Task AddInspectionRecordAsync(DataInspection add, object data, object otherItem = null) { MapData(data, add); - InspectionGeneralData generalData = new InspectionGeneralData(); - MapData(add, generalData); + InspectionGeneralData generalData = new InspectionGeneralData() + { + CreateUserName = add.CreateUserName, + SiteCode = add.SiteCode, + SiteId = add.SiteId, + SiteName = add.SiteName, + SubjectCode = add.SubjectCode, + SubjectId = add.SubjectId, + SubjectVisitId = add.SubjectVisitId, + SubjectVisitName = add.SubjectVisitName, + ResearchProgramNo = add.ResearchProgramNo, + RoleName = add.RoleName, + TrialId = add.TrialId, + TrialName = add.TrialName + }; + await SetInspectionNameValue(generalData); #region 处理标识 @@ -1027,14 +1000,14 @@ namespace IRaCIS.Core.Infra.EFCore.Common /// /// 往json里面添加属性 /// - /// json + /// json /// 添加对象 /// - public IDictionary AddJsonItem(dynamic json, object otherItem = null) + public IDictionary AddJsonItem(object jsonObj, object otherItem = null) { - var JsonData = JsonConvert.DeserializeObject>((json as object).ToJsonStr()); + var JsonData = JsonConvert.DeserializeObject>((jsonObj).ToJsonStr()); if (otherItem == null) {