diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs index f73df68cd..d378680ac 100644 --- a/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs @@ -52,7 +52,7 @@ namespace IRaCIS.Core.Application.Service { - await _visitTaskRepository.BatchUpdateNoTrackingAsync(t => taskIdList.Contains(t.Id), u => new VisitTask() { TaskState = TaskState.NotEffect }); + await _visitTaskRepository.UpdatePartialFromQueryAsync(t => taskIdList.Contains(t.Id), u => new VisitTask() { TaskState = TaskState.NotEffect },true); await _visitTaskRepository.SaveChangesAsync(); diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs index 4475536be..ba000f08b 100644 --- a/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs @@ -163,7 +163,7 @@ namespace IRaCIS.Core.Application.Service return ResponseOutput.NotOk("已签名的不允许设置为失效"); } - await _taskMedicalReviewRepository.BatchUpdateNoTrackingAsync(t => command.MedicalReviewIdList.Contains(t.Id), c => new TaskMedicalReview() { IsInvalid = true }); + await _taskMedicalReviewRepository.UpdatePartialFromQueryAsync(t => command.MedicalReviewIdList.Contains(t.Id), c => new TaskMedicalReview() { IsInvalid = true },true); return ResponseOutput.Ok(); diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index b228593d5..05ce2403a 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -114,7 +114,7 @@ namespace IRaCIS.Core.Application.Service.Allocation await _visitTaskRepository - .BatchUpdateNoTrackingAsync(updateWhere, + .UpdatePartialFromQueryAsync(updateWhere, u => new VisitTask() { AllocateTime = DateTime.Now, @@ -189,7 +189,7 @@ namespace IRaCIS.Core.Application.Service.Allocation await _subjectUserRepository.DeleteFromQueryAsync(t => t.Id == command.Id); - await _visitTaskRepository.BatchUpdateNoTrackingAsync(t => t.SubjectId == command.SubjectId && t.DoctorUserId == command.DoctorUserId && t.ArmEnum == command.ArmEnum && t.ReadingTaskState == ReadingTaskState.WaitReading && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false, u => new VisitTask() + await _visitTaskRepository.UpdatePartialFromQueryAsync(t => t.SubjectId == command.SubjectId && t.DoctorUserId == command.DoctorUserId && t.ArmEnum == command.ArmEnum && t.ReadingTaskState == ReadingTaskState.WaitReading && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false, u => new VisitTask() { AllocateTime = null, DoctorUserId = null, @@ -2309,7 +2309,7 @@ namespace IRaCIS.Core.Application.Service.Allocation //回退后,回退状态恢复 sv.RequestBackState = RequestBackStateEnum.NotRequest; - sv.IsCheckBack = true; + sv.IsCheckBack = false; sv.CheckState = CheckStateEnum.None; sv.CheckChallengeState = CheckChanllengeTypeEnum.None; diff --git a/IRaCIS.Core.Application/Service/Inspection/FrontAuditConfigService.cs b/IRaCIS.Core.Application/Service/Inspection/FrontAuditConfigService.cs index 2c41d4257..0f99f9b17 100644 --- a/IRaCIS.Core.Application/Service/Inspection/FrontAuditConfigService.cs +++ b/IRaCIS.Core.Application/Service/Inspection/FrontAuditConfigService.cs @@ -224,7 +224,10 @@ namespace IRaCIS.Core.Application.Service JsonStr = x.JsonDetail, Identification = x.Identification, ObjectRelationParentId = x.ObjectRelationParentId, - CreateTime=x.CreateTime + ObjectRelationParentId2 = x.ObjectRelationParentId2, + CreateTime = x.CreateTime, + BatchId = x.BatchId, + }).ToListAsync(); @@ -238,9 +241,9 @@ namespace IRaCIS.Core.Application.Service //查询关联父层级数据 if (item.Id == currentInspectionId) { - //把父层级的数据的 CommonData 数据合并 + //把父层级的数据的 CommonData 数据合并(每一个层级把下面层级需要的数据放在CommonData 里面) 麻烦点是每个层级都需要记录一些信息,而且名称不能重复 - var commonDataObjList = await GetRelationParentData(item.ObjectRelationParentId, item.CreateTime); + var commonDataObjList = await GetRelationParentData(item.ObjectRelationParentId, item.ObjectRelationParentId2, item.CreateTime, item.BatchId); var currentDic = JsonConvert.DeserializeObject>(jsonDict[nameof(InspectionJsonDetail.CommonData)].ToJsonStr()); @@ -250,15 +253,31 @@ namespace IRaCIS.Core.Application.Service foreach (var valuePair in otherDic) { - if (currentDic.ContainsKey(valuePair.Key)) + //关联层级的数据 + if (valuePair.Key.Contains("_")) { - currentDic[valuePair.Key] = valuePair.Value; + var entityProperName = valuePair.Key.Split("_").ToList().Last(); + + if (!currentDic.ContainsKey(entityProperName)) + { + currentDic.Add(entityProperName, valuePair.Value); + } + else + { + if (!currentDic.ContainsKey(valuePair.Key)) + { + currentDic.Add(valuePair.Key, valuePair.Value); + + } + } } else { - currentDic.Add(valuePair.Key, valuePair.Value); + if (!currentDic.ContainsKey(valuePair.Key)) + { + currentDic.Add(valuePair.Key, valuePair.Value); + } } - } } @@ -301,7 +320,7 @@ namespace IRaCIS.Core.Application.Service - private async Task> GetRelationParentData(Guid? objectRelationParentId, DateTime createTime) + private async Task> GetRelationParentData(Guid? objectRelationParentId, Guid? objectRelationParentId2, DateTime createTime, Guid batchId) { var objectLsit = new List(); @@ -309,7 +328,50 @@ namespace IRaCIS.Core.Application.Service if (objectRelationParentId != null) { - var relationParentInspection = await _dataInspectionRepository.Where(t => t.GeneralId == objectRelationParentId && t.CreateTime <= createTime).OrderByDescending(x => x.CreateTime).Select(t => new { t.ObjectRelationParentId, t.CreateTime, t.JsonDetail }).FirstOrDefaultAsync(); + //父子层级的数据可能在同一个批次 进行更新 但是后插入的是父层级的数据 找父层级的稽查应该优先同一批次的 + var relationParentInspection = await _dataInspectionRepository.Where(t => t.GeneralId == objectRelationParentId && (t.CreateTime <= createTime || t.BatchId == batchId)).OrderByDescending(x => x.CreateTime).Select(t => new { t.ObjectRelationParentId, t.CreateTime, t.JsonDetail, t.BatchId, t.ObjectRelationParentId2, t.EntityName }).FirstOrDefaultAsync(); + + + if (relationParentInspection != null) + { + Dictionary jsonDic = JsonConvert.DeserializeObject>(relationParentInspection.JsonDetail); + + + var commonDataDicObj = jsonDic[nameof(InspectionJsonDetail.CommonData)]; + + objectLsit.Add(commonDataDicObj); + + //避免对象信息记录 把 Data里面的信息也取过去 但是加上稽查对象的前缀 + var dataDicObj = jsonDic[nameof(InspectionJsonDetail.Data)]; + + if (dataDicObj != null) + { + var entityName = relationParentInspection.EntityName; + + IDictionary newNamepDic = new Dictionary(); + + var tempDic = JsonConvert.DeserializeObject>(dataDicObj.ToJsonStr()); + + foreach (var valuePair in tempDic) + { + newNamepDic.Add(entityName + "_" + valuePair.Key, valuePair.Value); + } + + + objectLsit.Add(newNamepDic); + } + + + + await GetRelationParentData(relationParentInspection.ObjectRelationParentId, relationParentInspection.ObjectRelationParentId2, relationParentInspection.CreateTime, relationParentInspection.BatchId); + } + + } + + if (objectRelationParentId2 != null) + { + //父子层级的数据可能在同一个批次 进行更新 但是后插入的是父层级的数据 找父层级的稽查应该优先同一批次的 + var relationParentInspection = await _dataInspectionRepository.Where(t => t.GeneralId == objectRelationParentId2 && (t.CreateTime <= createTime || t.BatchId == batchId)).OrderByDescending(x => x.CreateTime).Select(t => new { t.ObjectRelationParentId, t.CreateTime, t.JsonDetail, t.BatchId, t.ObjectRelationParentId2, t.EntityName }).FirstOrDefaultAsync(); if (relationParentInspection != null) @@ -322,8 +384,42 @@ namespace IRaCIS.Core.Application.Service objectLsit.Add(commonDataDicObj); - await GetRelationParentData(relationParentInspection.ObjectRelationParentId, relationParentInspection.CreateTime); + //避免对象信息记录 把 Data里面的信息也取过去 但是加上稽查对象的前缀 + var dataDicObj = jsonDic[nameof(InspectionJsonDetail.Data)]; + + if (dataDicObj != null) + { + var entityName = relationParentInspection.EntityName; + + IDictionary newNamepDic = new Dictionary(); + + var tempDic = JsonConvert.DeserializeObject>(dataDicObj.ToJsonStr()); + + foreach (var valuePair in tempDic) + { + newNamepDic.Add(entityName + "_" + valuePair.Key, valuePair.Value); + } + + + objectLsit.Add(newNamepDic); + } + + + + + + await GetRelationParentData(relationParentInspection.ObjectRelationParentId, relationParentInspection.ObjectRelationParentId2, relationParentInspection.CreateTime, relationParentInspection.BatchId); } + else + { + //用户的数据稽查没有 临时处理 + + var userObj = await _repository.Where(t => t.Id == objectRelationParentId2).Select(t => new { UserFullName = t.FullName, t.UserName }).FirstOrDefaultAsync(); + + objectLsit.Add(userObj); + } + + } diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingClinicalDataService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingClinicalDataService.cs index 7cefc7cf3..a2a87fada 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingClinicalDataService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingClinicalDataService.cs @@ -98,6 +98,8 @@ namespace IRaCIS.Application.Services }).ToList(); entity.ReadingClinicalDataState = ReadingClinicalDataStatus.HaveUploaded; + entity.IsBlind = null; + entity.IsComplete = null; await _readingClinicalDataRepository.AddAsync(entity, true); var success = await _readingClinicalDataRepository.SaveChangesAsync(); return ResponseOutput.Ok(entity.Id); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs index e618f9e7b..8c534d7d0 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs @@ -307,7 +307,7 @@ namespace IRaCIS.Core.Application.Services var isSuccess = await _trialSiteUserRepository.UpdatePartialFromQueryAsync(id, u => new TrialSiteUser() - { IsDeleted = isDelete, DeletedTime = isDelete ? DateTime.Now : null },true); + { IsDeleted = isDelete, DeletedTime = isDelete ? DateTime.Now : null },true,true); return ResponseOutput.Ok(isSuccess); } diff --git a/IRaCIS.Core.Domain.Share/Trial/TrialExpedited.cs b/IRaCIS.Core.Domain.Share/Trial/TrialExpedited.cs index e45c35ef0..6820a0d9d 100644 --- a/IRaCIS.Core.Domain.Share/Trial/TrialExpedited.cs +++ b/IRaCIS.Core.Domain.Share/Trial/TrialExpedited.cs @@ -15,7 +15,7 @@ public enum TrialType { - //非正式项目 + //正式项目 OfficialTrial = 1, NoneOfficial = 0, diff --git a/IRaCIS.Core.Domain/Trial/DataInspection.cs b/IRaCIS.Core.Domain/Trial/DataInspection.cs index 202d57f9d..7f2735975 100644 --- a/IRaCIS.Core.Domain/Trial/DataInspection.cs +++ b/IRaCIS.Core.Domain/Trial/DataInspection.cs @@ -143,6 +143,13 @@ namespace IRaCIS.Core.Domain.Models /// 稽查对象,关联的父对象Id /// public Guid? ObjectRelationParentId { get; set; } + + public Guid? ObjectRelationParentId2 { get; set; } + + + public string EntityName { get; set; } + + } diff --git a/IRaCIS.Core.Domain/Visit/Subject.cs b/IRaCIS.Core.Domain/Visit/Subject.cs index ec5fca48c..371138c40 100644 --- a/IRaCIS.Core.Domain/Visit/Subject.cs +++ b/IRaCIS.Core.Domain/Visit/Subject.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; using IRaCIS.Core.Domain.Share; +using Newtonsoft.Json; namespace IRaCIS.Core.Domain.Models { @@ -11,11 +12,17 @@ namespace IRaCIS.Core.Domain.Models [Table("Subject")] public class Subject : Entity, IAuditAdd, IAuditUpdate, ISoftDelete { + [JsonIgnore] public List SubjectVisitList { get; set; } = new List(); - + [JsonIgnore] public List SubjectDoctorList { get; set; } = new List(); - + [JsonIgnore] public List SubjectVisitTaskList { get; set; } = new List(); + [JsonIgnore] + public List ReadModuleList { get; set; } + + public List SubjectCanceDoctorList { get; set; } + [ForeignKey("FinalSubjectVisitId")] @@ -85,7 +92,6 @@ namespace IRaCIS.Core.Domain.Models public bool IsUrgent { get; set; } - public List ReadModuleList { get; set; } public bool IsDeleted { get; set; } public DateTime? DeletedTime { get; set; } @@ -93,7 +99,6 @@ namespace IRaCIS.Core.Domain.Models public bool IsReReadingOrBackInfluenceAnalysis { get; set; } - public List SubjectCanceDoctorList { get; set; } //是否分配了读片医生 //public bool IsAssignDoctorUser{get;set;} diff --git a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs index c314cdfcd..426bbffe3 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs @@ -153,8 +153,11 @@ namespace IRaCIS.Core.Infra.EFCore.Common ResearchProgramNo = x.ResearchProgramNo, }, new { + ExperimentName = entity.ExperimentName, + ResearchProgramNo = entity.ResearchProgramNo, + TrialDicList = string.Join(",", trialDics) - }, item.OriginalValues); + }); } // 访视计划 @@ -242,7 +245,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common { entity.Site = await _dbContext.Site.Where(x => x.Id == entity.SiteId).FirstOrDefaultAsync(); } - await InsertInspection(entity, type,null, new + await InsertInspection(entity, type, null, new { TrialSiteCode = entity.TrialSiteCode, SiteName = entity.Site.SiteName, @@ -359,7 +362,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common { var entity = item.Entity as TrialQCQuestion; var paretName = await _dbContext.TrialQCQuestionConfigure.Where(x => x.Id == entity.ParentId).Select(x => x.QuestionName).FirstOrDefaultAsync(); - await InsertInspection(entity, type,null, new + await InsertInspection(entity, type, null, new { QuestionName = entity.QuestionName, Type = entity.Type, @@ -389,7 +392,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common { dicomStudy = await _dbContext.DicomStudys.AsNoTracking().FirstOrDefaultAsync(x => x.Id == entity.StudyId); } - await InsertInspection(item.Entity as DicomSeries, type,null, new + await InsertInspection(item.Entity as DicomSeries, type, null, new { StudyCode = dicomStudy?.StudyCode, Modalities = dicomStudy?.Modalities, @@ -428,7 +431,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common filecount = filecount + count; } - await InsertInspection(noneDicomStudy, type,null, new + await InsertInspection(noneDicomStudy, type, null, new { FileCount = filecount, }); @@ -437,29 +440,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common } - // 访视 - foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SubjectVisit))) - { - var entity = item.Entity as SubjectVisit; - string reason = string.Empty; - if (_userInfo.RequestUrl.ToLower() == "qcoperation/setcheckpass") - { - reason = entity.ManualPassReason; - } - - - var subjectCode = entity.Subject?.Code; - await InsertInspection(item.Entity as SubjectVisit, type, x => new InspectionConvertDTO() - { - SubjectCode = subjectCode, - SubjectId = x.SubjectId, - SubjectVisitId = x.Id, - SubjectVisitName = x.VisitName, - BlindName = x.BlindName, - Reason = reason, - }); - } // 既往手术史 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(PreviousSurgery))) @@ -570,7 +551,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common subjectVisit = subjectVisit ?? new SubjectVisit(); if (type == "Add") { - + await InsertInspection(firstEntity, type, answer => new InspectionConvertDTO() { @@ -581,7 +562,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common SubjectVisitId = subjectVisit.Id, GeneralId = subjectVisit.Id, //byzhouhang - ObjectRelationParentId=subjectVisit.Id, + ObjectRelationParentId = subjectVisit.Id, }, new { QcQuestionAnswerCommands = await Getdata(entitylist), @@ -610,7 +591,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common QcQuestionAnswerCommands = await Getdata(entitylist), }); - + } async Task> Getdata(List questionAnswers) @@ -721,9 +702,12 @@ namespace IRaCIS.Core.Infra.EFCore.Common GeneralId = x.Id, }, new { + //父层级的数据 暂时没有记录稽查 所以这里必须查 Name = doctor.FullName, ChineseName = doctor.ChineseName, Email = doctor.EMail, + + IsUploadedACKSOW = entity.AttachmentId != Guid.Empty }); } @@ -741,9 +725,12 @@ namespace IRaCIS.Core.Infra.EFCore.Common GeneralId = enroll.Id, }, new { + //父层级的数据 暂时没有记录稽查 所以这里必须查 Name = enroll.Doctor.FullName, ChineseName = enroll.Doctor.ChineseName, Email = enroll.Doctor.EMail, + + IsUploadedACKSOW = enroll.AttachmentId != Guid.Empty, ReadingCategoryList = list.Select(t => t.ReadingCategory).ToList() }); } @@ -761,10 +748,41 @@ namespace IRaCIS.Core.Infra.EFCore.Common await InsertInspection(entity, type, x => new InspectionConvertDTO() { SubjectId = x.Id, - SubjectCode = x.Code, + //SubjectCode = x.Code, }, new { FinalSubjectVisitName = finalSubjectVisitName, + SujectCode = entity.Code + + }); + } + + // 访视 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SubjectVisit))) + { + var entity = item.Entity as SubjectVisit; + string reason = string.Empty; + + if (_userInfo.RequestUrl.ToLower() == "qcoperation/setcheckpass") + { + reason = entity.ManualPassReason; + } + + var subjectCode = entity.Subject?.Code; + + await InsertInspection(item.Entity as SubjectVisit, type, x => new InspectionConvertDTO() + { + ObjectRelationParentId = x.SubjectId, + SubjectCode = subjectCode, + SubjectId = x.SubjectId, + SubjectVisitId = x.Id, + //SubjectVisitName = x.VisitName, + //BlindName = x.BlindName, + Reason = reason, + }, new + { + SubjectVisitName = entity.VisitName, + BlindName = entity.BlindName, }); } @@ -874,7 +892,122 @@ namespace IRaCIS.Core.Infra.EFCore.Common #endregion + #region 阅片 + //用户添加 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(User))) + { + var entity = item.Entity as User; + + await InsertInspection(entity, type, x => new InspectionConvertDTO() + { + IsDistinctionInterface = false + }, new + { + UserFullName = entity.FullName, + entity.UserCode, + entity.UserName + } + ); + } + + + + //分配规则 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TaskAllocationRule))) + { + var entity = item.Entity as TaskAllocationRule; + + await InsertInspection(entity, type, x => new InspectionConvertDTO() + { + IsDistinctionInterface = false, + + ObjectRelationParentId = entity.EnrollId, + + ObjectRelationParentId2 = entity.DoctorUserId + + }); + } + + // suject 医生绑定关系 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SubjectUser))) + { + var entity = item.Entity as SubjectUser; + + await InsertInspection(entity, type, x => new InspectionConvertDTO() + { + IsDistinctionInterface = false, + + ObjectRelationParentId = entity.SubjectId, + + ObjectRelationParentId2 = entity.DoctorUserId + + }); + } + + //任务 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(VisitTask))) + { + var entity = item.Entity as VisitTask; + + await InsertInspection(entity, type, x => new InspectionConvertDTO() + { + IsDistinctionInterface = type == AuditOpt.Update ? true : false, + ObjectRelationParentId = entity.SourceSubjectVisitId != null ? entity.SourceSubjectVisitId : entity.SouceReadModuleId, + + ObjectRelationParentId2 = entity.DoctorUserId + + }); ; + } + + //申请重阅记录表 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(VisitTaskReReading))) + { + var entity = item.Entity as VisitTaskReReading; + + await InsertInspection(entity, type, x => new InspectionConvertDTO() + { + + ObjectRelationParentId = entity.OriginalReReadingTaskId, + + }); + } + + + + //医学审核 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TaskMedicalReview))) + { + var entity = item.Entity as TaskMedicalReview; + + await InsertInspection(entity, type, x => new InspectionConvertDTO() + { + + ObjectRelationParentId = entity.VisitTaskId, + + ObjectRelationParentId2 = entity.MedicalManagerUserId + + + }); + } + + //一致性分析规则 + + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TaskConsistentRule))) + { + var entity = item.Entity as TaskConsistentRule; + + await InsertInspection(entity, type, x => new InspectionConvertDTO() + { + + ObjectRelationParentId = entity.TrialId + + }); + } + + + + #endregion #endregion @@ -890,12 +1023,12 @@ namespace IRaCIS.Core.Infra.EFCore.Common /// 表达式 /// 其他对象 /// - public async Task InsertInspection(T entityObj, string type, Expression> expression = null, object otherItem = null, object originaldata = null) where T : Entity + public async Task InsertInspection(T entityObj, string type, Expression> expression = null, object otherItem = null) where T : Entity { InspectionConvertDTO inspection = new InspectionConvertDTO(); - + if (expression != null) { @@ -905,7 +1038,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common } //避免重复赋值 有些特殊的GeneralId - var generalId = (inspection.GeneralId != null && inspection.GeneralId != Guid.Empty) ? inspection.GeneralId : entityObj.Id ; + var generalId = (inspection.GeneralId != null && inspection.GeneralId != Guid.Empty) ? inspection.GeneralId : entityObj.Id; inspection.GeneralId = generalId; inspection.Identification = await GetInspectionRecordIdentificationAsync(entityObj, type, inspection.IsDistinctionInterface); @@ -932,7 +1065,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common //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== inspection.ObjectRelationParentId).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync())?.Id; + inspection.ParentId = (await _dbContext.DataInspection.AsQueryable().Where(x => x.GeneralId == inspection.GeneralId && x.ObjectRelationParentId == inspection.ObjectRelationParentId).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync())?.Id; } inspection.CreateUserId = _userInfo.Id; inspection.IP = _userInfo.IP; @@ -944,20 +1077,29 @@ namespace IRaCIS.Core.Infra.EFCore.Common inspection.IsSign = true; } + var entityName= entityObj.GetType().Name; inspection.JsonDetail = new InspectionJsonDetail { //稽查实体,加上扩充的信息 - Data = AddJsonItem(entityObj, otherItem), + //Data = AddJsonItem(entityObj, otherItem), //通用信息 每条稽查必须记录的 - CommonData = generalData + //CommonData = generalData + + EntityName = entityName, + + Data = entityObj, + + CommonData = AddJsonItem(generalData, otherItem) }.ToJsonStr(); inspection.BatchId = _userInfo.BatchId.Value; - await _dbContext.DataInspection.AddAsync(inspection ); + inspection.EntityName = entityName; + + await _dbContext.DataInspection.AddAsync(inspection); //await AddInspectionRecordAsync( entityObj, inspection, otherItem); @@ -1018,25 +1160,25 @@ namespace IRaCIS.Core.Infra.EFCore.Common #region 访视 阅片期那里关联了访视 - if (generalData.SubjectVisitId != null) - { - //添加访视的时候,会带信息过来 - if (string.IsNullOrEmpty(generalData.SubjectVisitName)) - { - var info = (await _dbContext.SubjectVisit.Where(x => x.Id == generalData.SubjectVisitId).Select(x => - new { x.VisitName, x.SubjectId, x.SiteId, SubjectCode = x.Subject.Code, TrialSiteCode = x.TrialSite.TrialSiteCode, x.TrialId, x.Trial.ExperimentName, x.Trial.ResearchProgramNo }).FirstOrDefaultAsync()).IfNullThrowException(); + //if (generalData.SubjectVisitId != null) + //{ + // //添加访视的时候,会带信息过来 + // if (string.IsNullOrEmpty(generalData.SubjectVisitName)) + // { + // var info = (await _dbContext.SubjectVisit.Where(x => x.Id == generalData.SubjectVisitId).Select(x => + // new { x.VisitName, x.SubjectId, x.SiteId, SubjectCode = x.Subject.Code, TrialSiteCode = x.TrialSite.TrialSiteCode, x.TrialId, x.Trial.ExperimentName, x.Trial.ResearchProgramNo }).FirstOrDefaultAsync()).IfNullThrowException(); - generalData.SubjectVisitName = info.VisitName; + // generalData.SubjectVisitName = info.VisitName; - generalData.TrialId = info.TrialId; - generalData.TrialName = info.ExperimentName; - generalData.ResearchProgramNo = info.ResearchProgramNo; - generalData.SiteId = info.SiteId; - generalData.SubjectCode = info.SubjectCode; - generalData.SubjectId = info.SubjectId; - generalData.SiteCode = info.TrialSiteCode; - } - } + // generalData.TrialId = info.TrialId; + // generalData.TrialName = info.ExperimentName; + // generalData.ResearchProgramNo = info.ResearchProgramNo; + // generalData.SiteId = info.SiteId; + // generalData.SubjectCode = info.SubjectCode; + // generalData.SubjectId = info.SubjectId; + // generalData.SiteCode = info.TrialSiteCode; + // } + //} #endregion @@ -1112,7 +1254,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common /// 获取稽查记录的标识符 部分业务会进行特殊处理 /// /// - public async Task GetInspectionRecordIdentificationAsync(T entityObj, string type, bool IsDistinctionInterface = true) + public async Task GetInspectionRecordIdentificationAsync(T entityObj, string type, bool IsDistinctionInterface = true) { var entityTypeName = entityObj.GetType().Name; @@ -1178,8 +1320,127 @@ namespace IRaCIS.Core.Infra.EFCore.Common { } break; + + //确认重阅 区分用户类型 + case "visittask/confirmrereading": + + if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.APM) + { + type = type + "/" + 1; + + } + else + { + type = type + "/" + 2; + } + break; } break; + + case nameof(VisitTask): + + var visitTask = entityObj as VisitTask; + + switch (_userInfo.RequestUrl) + { + //申请重阅 + case "VisitTask/applyReReading": + type = type + "/" + (int)visitTask.ReReadingApplyState; + break; + //同意重阅 + case "VisitTask/ConfirmReReading": + + if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.APM) + { + type = type + "/" + 1; + + } + else + { + type = type + "/" + 2; + } + + + if (visitTask.ReReadingApplyState == ReReadingApplyState.Agree) + { + type = type + "/" + 1; + + } + else if (visitTask.ReReadingApplyState == ReReadingApplyState.Reject) + { + type = type + "/" + 2; + } + break; + + + + } + + if (type == AuditOpt.Add) + { + //生成一致性分析任务 + if (visitTask.IsSelfAnalysis == true) + { + type = type + "/" + "SelfAnalysis"; + } + else if (visitTask.IsSelfAnalysis == false) + { + type = type + "/" + "GroupAnalysis"; + } + else + { + type = type + "/" + "NotAnalysis"; + } + break; + } + + break; + + + case nameof(VisitTaskReReading): + + var visitTaskReReading = entityObj as VisitTaskReReading; + + switch (_userInfo.RequestUrl) + { + case "VisitTask/applyReReading": + type = type + "/" + (int)visitTaskReReading.RequestReReadingType; + break; + + case "VisitTask/ConfirmReReading": + + if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.APM) + { + type = type + "/" + 1; + + } + else + { + type = type + "/" + 2; + } + break; + } + + break; + + case nameof(TaskConsistentRule): + + var taskConsistentRule = entityObj as TaskConsistentRule; + + //自身一致性分析 + if (taskConsistentRule.IsSelfAnalysis == true) + { + type = type + "/" + 1; + + } + //组件一致性分析 + else + { + type = type + "/" + 2; + } + + break; + } #endregion diff --git a/IRaCIS.Core.Infra.EFCore/Common/Dto/SetDictionaryValueDto.cs b/IRaCIS.Core.Infra.EFCore/Common/Dto/SetDictionaryValueDto.cs index 042e5eda7..48196bd86 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/Dto/SetDictionaryValueDto.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/Dto/SetDictionaryValueDto.cs @@ -30,6 +30,14 @@ namespace IRaCIS.Core.Infra.EFCore.Common.Dto public Guid? ObjectRelationParentId { get; set; } + public Guid? ObjectRelationParentId2 { get; set; } + + + /// + /// 批次Id + /// + public Guid BatchId { get; set; } + public DateTime CreateTime { get; set; } } @@ -92,9 +100,10 @@ namespace IRaCIS.Core.Infra.EFCore.Common.Dto /// public class InspectionJsonDetail { + public string EntityName { get; set; } public object Data { get; set; } - public InspectionGeneralData CommonData { get; set; } + public object CommonData { get; set; } } diff --git a/IRaCIS.Core.Infrastructure/_IRaCIS/ObjectExtension.cs b/IRaCIS.Core.Infrastructure/_IRaCIS/ObjectExtension.cs index 184da9cc6..23525f517 100644 --- a/IRaCIS.Core.Infrastructure/_IRaCIS/ObjectExtension.cs +++ b/IRaCIS.Core.Infrastructure/_IRaCIS/ObjectExtension.cs @@ -27,7 +27,7 @@ namespace IRaCIS.Core.Infrastructure.Extention public static string ToJsonStr(this object obj) { - return JsonConvert.SerializeObject(obj, new JsonSerializerSettings { DateFormatString = "yyyy-MM-dd HH:mm:ss", ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); + return JsonConvert.SerializeObject(obj, new JsonSerializerSettings { DateFormatString = "yyyy-MM-dd HH:mm:ss", ReferenceLoopHandling = ReferenceLoopHandling.Ignore, NullValueHandling = NullValueHandling.Ignore }); } } }