diff --git a/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs b/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs index 465c6776f..b8683146c 100644 --- a/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs +++ b/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs @@ -194,17 +194,17 @@ namespace IRaCIS.Core.Application.Service if (item != null) { x.Code=item.Code; - x.Value = x.Code.IsNullOrEmpty() ? item.Value : x.Value; - x.DictionaryType = x.DictionaryType.IsNullOrEmpty() ? item.DictionaryType : x.DictionaryType; - x.DictionaryCode = x.DictionaryCode.IsNullOrEmpty() ? item.DictionaryCode : x.DictionaryCode; - x.DataType = x.DataType.IsNullOrEmpty() ? item.DataType : x.DataType; - x.DateType = x.DateType.IsNullOrEmpty() ? item.DateType : x.DateType; - x.DictionaryKey = x.DictionaryKey.IsNullOrEmpty() ? item.DictionaryKey : x.DictionaryKey; - x.IsShowParent = x.IsShowParent==null ? item.IsShowParent : x.IsShowParent; - x.ForeignKeyTable = x.ForeignKeyTable.IsNullOrEmpty() ? item.ForeignKeyTable : x.ForeignKeyTable; - x.ForeignKeyText = x.ForeignKeyText.IsNullOrEmpty() ? item.ForeignKeyText : x.ForeignKeyText; - x.ForeignKeyValue = x.ForeignKeyValue.IsNullOrEmpty() ? item.ForeignKeyValue : x.ForeignKeyValue; - x.EnumType = x.EnumType.IsNullOrEmpty() ? item.EnumType : x.EnumType; + x.Value = !item.Code.IsNullOrEmpty() ? item.Value : x.Value; + x.DictionaryType = !item.DictionaryType.IsNullOrEmpty() ? item.DictionaryType : x.DictionaryType; + x.DictionaryCode = !item.DictionaryCode.IsNullOrEmpty() ? item.DictionaryCode : x.DictionaryCode; + x.DataType = !item.DataType.IsNullOrEmpty() ? item.DataType : x.DataType; + x.DateType = !item.DateType.IsNullOrEmpty() ? item.DateType : x.DateType; + x.DictionaryKey = !item.DictionaryKey.IsNullOrEmpty() ? item.DictionaryKey : x.DictionaryKey; + x.IsShowParent = !item.IsShowParent==null ? item.IsShowParent : x.IsShowParent; + x.ForeignKeyTable = !item.ForeignKeyTable.IsNullOrEmpty() ? item.ForeignKeyTable : x.ForeignKeyTable; + x.ForeignKeyText = !item.ForeignKeyText.IsNullOrEmpty() ? item.ForeignKeyText : x.ForeignKeyText; + x.ForeignKeyValue = !item.ForeignKeyValue.IsNullOrEmpty() ? item.ForeignKeyValue : x.ForeignKeyValue; + x.EnumType = !item.EnumType.IsNullOrEmpty() ? item.EnumType : x.EnumType; } }); diff --git a/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs b/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs index 15bc7caf3..dd96cac8d 100644 --- a/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs +++ b/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs @@ -23,10 +23,14 @@ namespace IRaCIS.Core.Application.Services { private readonly IRepository _systemDocumentRepository; + private readonly IRepository _systemDocNeedConfirmedUserTypeRepository; - public SystemDocumentService( IRepository systemDocumentRepository) + public SystemDocumentService( IRepository systemDocumentRepository, + IRepository systemDocNeedConfirmedUserTypeRepository + ) { _systemDocumentRepository = systemDocumentRepository; + this._systemDocNeedConfirmedUserTypeRepository = systemDocNeedConfirmedUserTypeRepository; } @@ -66,18 +70,20 @@ namespace IRaCIS.Core.Application.Services } else { - var document = await _systemDocumentRepository.Where(t => t.Id == addOrEditSystemDocument.Id, true,true).Include(t => t.NeedConfirmedUserTypeList).FirstOrDefaultAsync(); + var document = await _systemDocumentRepository.Where(t => t.Id == addOrEditSystemDocument.Id, true, true).Include(t => t.NeedConfirmedUserTypeList).FirstOrDefaultAsync(); if (document == null) return Null404NotFound(document); - if (await _systemDocumentRepository.AnyAsync(t => t.FileTypeId == addOrEditSystemDocument.FileTypeId && t.Name == addOrEditSystemDocument.Name && t.Id != addOrEditSystemDocument.Id,true)) + if (await _systemDocumentRepository.AnyAsync(t => t.FileTypeId == addOrEditSystemDocument.FileTypeId && t.Name == addOrEditSystemDocument.Name && t.Id != addOrEditSystemDocument.Id, true)) { return ResponseOutput.NotOk("同类型已存在该文件名"); } - + _mapper.Map(addOrEditSystemDocument, document); + document.UpdateTime = DateTime.Now; + if (document.FileTypeId != addOrEditSystemDocument.FileTypeId) { var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).IfNullThrowException().FullName; @@ -94,7 +100,7 @@ namespace IRaCIS.Core.Application.Services } } - var success = _repository.SaveChangesAsync(); + var success = await _repository.SaveChangesAsync(); return ResponseOutput.Ok(document.Id.ToString()); } diff --git a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs index e66d464e8..05298aed7 100644 --- a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs +++ b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs @@ -574,11 +574,11 @@ namespace IRaCIS.Core.Application.Services { if (isSystemDoc) { - await _repository.BatchUpdateAsync(t => t.Id == documentId, u => new SystemDocument() { IsDeleted = true }); + await _systemDocumentRepository.UpdatePartialFromQueryAsync(documentId, u => new SystemDocument() { IsDeleted = true }); } else { - await _trialDocumentRepository.BatchUpdateNoTrackingAsync(t => t.Id == documentId, u => new TrialDocument() { IsDeleted = true }); + await _trialDocumentRepository.UpdatePartialFromQueryAsync(documentId, u => new TrialDocument() { IsDeleted = true }); } return ResponseOutput.Ok(); } diff --git a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs index 2f9c49f10..fd5450d3c 100644 --- a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs +++ b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs @@ -36,29 +36,29 @@ namespace IRaCIS.Core.Application.Service.Inspection { //_repository.GetQueryable.GetQueryable < DataInspection > + var trialfirst= await _repository.GetQueryable< Trial >().Where(x=>x.Id== dto.TrialId).AsNoTracking().FirstOrDefaultAsync(); + + + trialfirst.TrialFinishTime = trialfirst.TrialFinishTime == null ? DateTime.Now : trialfirst.TrialFinishTime; + #region 逻辑代码 - var query = from data in _repository.GetQueryable() - join trial in _repository.GetQueryable() on data.TrialId equals trial.Id into trialtemp + var query = from data in _repository.GetQueryable().Where(x => (x.TrialId == dto.TrialId)||(x.TrialId==null&&x.CreateTime> trialfirst.CreateTime&&x.CreateTime < trialfirst.TrialFinishTime)) + + join trial in _repository.GetQueryable().IgnoreQueryFilters() on data.TrialId equals trial.Id into trialtemp from leftrial in trialtemp.DefaultIfEmpty() - join site in _repository.GetQueryable() on data.SiteId equals site.Id into sitetemp + join site in _repository.GetQueryable().IgnoreQueryFilters() on data.SiteId equals site.Id into sitetemp from leftsite in sitetemp.DefaultIfEmpty() - join subject in _repository.GetQueryable() on data.SubjectId equals subject.Id into subtemp + join subject in _repository.GetQueryable().IgnoreQueryFilters() on data.SubjectId equals subject.Id into subtemp from leftsubject in subtemp.DefaultIfEmpty() - join subjectVisit in _repository.GetQueryable() on data.SubjectVisitId equals subjectVisit.Id into subjectVisittemp + join subjectVisit in _repository.GetQueryable().IgnoreQueryFilters() on data.SubjectVisitId equals subjectVisit.Id into subjectVisittemp from leftsubjectVisit in subjectVisittemp.DefaultIfEmpty() join parent in _repository.GetQueryable() on data.ParentId equals parent.Id into parenttemp from leftparent in parenttemp.DefaultIfEmpty() - join user in _repository.GetQueryable() on data.CreateUserId equals user.Id into usertemp + join user in _repository.GetQueryable().IgnoreQueryFilters() on data.CreateUserId equals user.Id into usertemp from leftuser in usertemp.DefaultIfEmpty() - join usertype in _repository.GetQueryable() on leftuser.UserTypeId equals usertype.Id into usertypetemp + join usertype in _repository.GetQueryable().IgnoreQueryFilters() on leftuser.UserTypeId equals usertype.Id into usertypetemp from leftusertype in usertypetemp.DefaultIfEmpty() - - - - - - //join moduleTyped in _repository.GetQueryable().Where(x => x.Code == "ModuleType") on 1 equals 1 //join moduleTypec in _repository.GetQueryable() on new { ParentId = moduleTyped.Id, ModuleType = data.ModuleType } equals new { ParentId = moduleTypec.ParentId.Value, ModuleType = moduleTypec.Value } into moduleTypectemp @@ -75,24 +75,14 @@ namespace IRaCIS.Core.Application.Service.Inspection //from leftOptType in optTypetemp.DefaultIfEmpty() - join trialSign in _repository.GetQueryable() on data.SignId equals trialSign.Id into trialSigntemp + join trialSign in _repository.GetQueryable().IgnoreQueryFilters() on data.SignId equals trialSign.Id into trialSigntemp from lefttrialSign in trialSigntemp.DefaultIfEmpty() - - join leftfrontAuditConfig in _repository.GetQueryable().Where(x=>x.ConfigType=="M"&&x.Identification!=null&&x.IsEnable==true) on data.Identification.ToLower() equals leftfrontAuditConfig.Identification.ToLower() - - - - - join moduleTypec in _repository.GetQueryable() on new { ModuleType = leftfrontAuditConfig.ModuleTypeId.Value } equals new { ModuleType = moduleTypec.Id } into moduleTypectemp from leftmoduleTypec in moduleTypectemp.DefaultIfEmpty() - - - join OptTypec in _repository.GetQueryable() on new { ModuleType = leftfrontAuditConfig.OptTypeId.Value } equals new { ModuleType = OptTypec.Id } into optTypetemp from leftOptType in optTypetemp.DefaultIfEmpty() @@ -146,8 +136,7 @@ namespace IRaCIS.Core.Application.Service.Inspection }; - query = query.WhereIf(dto.TrialId != null, x => x.TrialId == dto.TrialId) - .WhereIf(dto.SiteId != null, x => x.SiteId == dto.SiteId) + query = query.WhereIf(dto.SiteId != null, x => x.SiteId == dto.SiteId) .WhereIf(!dto.SubjectInfo.IsNullOrEmpty(), x => x.SubjectCode.Contains(dto.SubjectInfo)) .WhereIf(dto.VisitPlanInfo != null, x => x.VisitNum == dto.VisitPlanInfo) .WhereIf(dto.StartTime != null, x => x.CreateTime >= dto.StartTime) diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs index 9c402319f..3c4fbec73 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs @@ -224,7 +224,11 @@ namespace IRaCIS.Core.Application return ResponseOutput.NotOk("项目 基础配置、流程配置、加急配置 、访视计划,有未确认项"); } } - + + if (trialStatusStr != "Ongoing") + { + trial.TrialFinishTime = DateTime.Now; + } trial.TrialStateChangeList.Add(new TrialStateChange() { OriginState = trial.TrialStatusStr, NowState = trialStatusStr, Reason = reason ?? String.Empty, TrialId = trialId }); @@ -276,7 +280,11 @@ namespace IRaCIS.Core.Application [HttpPut("{trialId:guid}/{isAbandon:bool}")] public async Task AbandonTrial(Guid trialId, /*Guid? signId,*/ bool isAbandon) { - await _trialRepository.UpdatePartialNowNoQueryAsync(trialId, u => new Trial() { IsDeleted = isAbandon }); + + await _trialRepository.UpdatePartialFromQueryAsync(trialId, u => new Trial() { + IsDeleted = isAbandon, + TrialFinishTime= isAbandon?DateTime.Now:null + },true); diff --git a/IRaCIS.Core.Domain/Trial/DataInspection.cs b/IRaCIS.Core.Domain/Trial/DataInspection.cs index 823d6842f..27548b937 100644 --- a/IRaCIS.Core.Domain/Trial/DataInspection.cs +++ b/IRaCIS.Core.Domain/Trial/DataInspection.cs @@ -38,8 +38,8 @@ namespace IRaCIS.Core.Domain.Models /// /// 项目iD /// - [Required] - public Guid TrialId { get; set; } + + public Guid? TrialId { get; set; } /// /// 中心 diff --git a/IRaCIS.Core.Domain/Trial/Trial.cs b/IRaCIS.Core.Domain/Trial/Trial.cs index fd5f96512..b4c28e74e 100644 --- a/IRaCIS.Core.Domain/Trial/Trial.cs +++ b/IRaCIS.Core.Domain/Trial/Trial.cs @@ -293,6 +293,11 @@ namespace IRaCIS.Core.Domain.Models public Guid? QCQuestionConfirmedUserId { get; set; } public DateTime? QCQuestionConfirmedTime { get; set; } + /// + /// Ŀʱ + /// + public DateTime? TrialFinishTime { get; set; } + public int? DigitPlaces { get; set; } = 2; diff --git a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs index e55d47370..0e2b99dcf 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs @@ -75,6 +75,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common public async Task InsertAddEntitys(List entitys,string type) { + #region 所有 //foreach (var item in entitys) //{ @@ -84,13 +85,37 @@ namespace IRaCIS.Core.Infra.EFCore.Common #region 区分 + //系统文件 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SystemDocument))) + { + var entity = item.Entity as SystemDocument; + var userTypes = entity.NeedConfirmedUserTypeList; + if (userTypes == null) + { + userTypes = await _dbContext.SystemDocNeedConfirmedUserType.Where(x => x.SystemDocumentId == entity.Id).ToListAsync(); + } + + var userTypeIds = userTypes.Select(x => x.NeedConfirmUserTypeId).ToList(); + var usertypeNames = await _dbContext.UserType.Where(x => userTypeIds.Contains(x.Id)).Select(x => x.UserTypeShortName).ToListAsync(); + var usertypeName = string.Join(",", usertypeNames); + await InsertInspection(item, type, x => new DataInspection() + { + GeneralId = x.Id + },new { + NeedConfirmedUserType= usertypeName, + }); + } + // 项目 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(Trial))) { + var entity = item.Entity as Trial; await InsertInspection(item, type, x => new DataInspection() { TrialId = x.Id, TrialName = x.ExperimentName, + ResearchProgramNo=x.ResearchProgramNo, + GeneralId = x.Id, }); } @@ -202,7 +227,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common filecount = filecount + count; } - await InsertInspection(null, type, x => new DataInspection() + await InsertInspection(null, type, x => new DataInspection() { GeneralId = x.Id, }, new @@ -212,7 +237,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common } } - + #region 注释代码 ////非Dicom文件 //foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(NoneDicomStudyFile))) //{ @@ -250,6 +275,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common // UpNum = 1,// 每次上传或下载一个 // }); //} + #endregion // 访视 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SubjectVisit))) @@ -397,6 +423,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common var subjectvisit = await _dbContext.SubjectVisit.Where(x => x.Id == entity.SubjectVisitId).FirstOrDefaultAsync(); var qCChallenge = await _dbContext.QCChallenge.Where(x => x.Id == entity.QCChallengeId).FirstOrDefaultAsync(); subjectvisit = subjectvisit ?? new SubjectVisit(); + qCChallenge = qCChallenge ?? new QCChallenge(); await InsertInspection(item, type, x => new DataInspection() { GeneralId = qCChallenge.Id,