diff --git a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs index f87dc1dac..2dca9418f 100644 --- a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs +++ b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs @@ -148,7 +148,7 @@ namespace IRaCIS.Core.Application.Service.Inspection .WhereIf(dto.ObjectRelationParentId != null && dto.BatchId != null && dto.GeneralId != null, x => x.BatchId == dto.BatchId || //同一事务批次 - x.ObjectRelationParentId == dto.ObjectRelationParentId || //不同对象 但是同一层级 适用于子对象 + //x.ObjectRelationParentId == dto.ObjectRelationParentId || //不同对象 但是同一层级 适用于子对象 ( ( x.GeneralId == dto.ObjectRelationParentId || //子稽查 查询父记录 diff --git a/IRaCIS.Core.Domain/Trial/DataInspection.cs b/IRaCIS.Core.Domain/Trial/DataInspection.cs index b0ef52024..202d57f9d 100644 --- a/IRaCIS.Core.Domain/Trial/DataInspection.cs +++ b/IRaCIS.Core.Domain/Trial/DataInspection.cs @@ -127,7 +127,7 @@ namespace IRaCIS.Core.Domain.Models //public Guid? VisitStageId { get; set; } /// - /// 通用Id + /// 稽查的对象Id /// public Guid? GeneralId { get; set; } @@ -139,6 +139,9 @@ namespace IRaCIS.Core.Domain.Models public Guid BatchId { get; set; } + /// + /// 稽查对象,关联的父对象Id + /// public Guid? ObjectRelationParentId { get; set; } } diff --git a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs index 0f3cad0ef..2edb0b07e 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs @@ -580,6 +580,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common TrialId = subjectVisit.TrialId, SubjectVisitId = subjectVisit.Id, GeneralId = subjectVisit.Id, + //byzhouhang + ObjectRelationParentId=subjectVisit.Id, }, new { QcQuestionAnswerCommands = await Getdata(entitylist), @@ -601,6 +603,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common TrialId = subjectVisit.TrialId, SubjectVisitId = subjectVisit.Id, GeneralId = subjectVisit.Id, + //byzhouhang + ObjectRelationParentId = subjectVisit.Id, }, new { QcQuestionAnswerCommands = await Getdata(entitylist), @@ -644,6 +648,8 @@ namespace IRaCIS.Core.Infra.EFCore.Common await InsertInspection(entity, type, x => new InspectionConvertDTO() { GeneralId = entity.SubjectVisitId, + //byzhouhang + ObjectRelationParentId = entity.SubjectVisitId, TrialId = subjectvisit.TrialId, SubjectVisitId = x.SubjectVisitId, SiteId = subjectvisit.SiteId, @@ -679,6 +685,9 @@ namespace IRaCIS.Core.Infra.EFCore.Common await InsertInspection(entity, type, x => new InspectionConvertDTO() { GeneralId = qCChallenge.Id, + //byzhouhang + ObjectRelationParentId = qCChallenge.Id, + TrialId = subjectvisit.TrialId, SubjectVisitId = x.SubjectVisitId, SiteId = subjectvisit.SiteId, @@ -920,7 +929,10 @@ namespace IRaCIS.Core.Infra.EFCore.Common #endregion if (inspection.ParentId == null) { - inspection.ParentId = (await _dbContext.DataInspection.AsQueryable().Where(x => x.TrialId == inspection.TrialId && x.SubjectVisitId == inspection.SubjectVisitId && x.SubjectId == inspection.SubjectId && x.SiteId == inspection.SiteId && x.GeneralId == inspection.GeneralId).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync())?.Id; + //inspection.ParentId = (await _dbContext.DataInspection.AsQueryable().Where(x => x.TrialId == inspection.TrialId && x.SubjectVisitId == inspection.SubjectVisitId && x.SubjectId == inspection.SubjectId && x.SiteId == inspection.SiteId && x.GeneralId == inspection.GeneralId).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync())?.Id; + + + inspection.ParentId = (await _dbContext.DataInspection.AsQueryable().Where(x => x.GeneralId == inspection.GeneralId && x.ObjectRelationParentId==x.ObjectRelationParentId).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync())?.Id; } inspection.CreateUserId = _userInfo.Id; inspection.IP = _userInfo.IP;