修改一版

Uat_Study
he 2022-05-13 18:12:50 +08:00
parent 894424a00e
commit 6741f11b27
8 changed files with 85 additions and 50 deletions

View File

@ -194,17 +194,17 @@ namespace IRaCIS.Core.Application.Service
if (item != null) if (item != null)
{ {
x.Code=item.Code; x.Code=item.Code;
x.Value = x.Code.IsNullOrEmpty() ? item.Value : x.Value; x.Value = !item.Code.IsNullOrEmpty() ? item.Value : x.Value;
x.DictionaryType = x.DictionaryType.IsNullOrEmpty() ? item.DictionaryType : x.DictionaryType; x.DictionaryType = !item.DictionaryType.IsNullOrEmpty() ? item.DictionaryType : x.DictionaryType;
x.DictionaryCode = x.DictionaryCode.IsNullOrEmpty() ? item.DictionaryCode : x.DictionaryCode; x.DictionaryCode = !item.DictionaryCode.IsNullOrEmpty() ? item.DictionaryCode : x.DictionaryCode;
x.DataType = x.DataType.IsNullOrEmpty() ? item.DataType : x.DataType; x.DataType = !item.DataType.IsNullOrEmpty() ? item.DataType : x.DataType;
x.DateType = x.DateType.IsNullOrEmpty() ? item.DateType : x.DateType; x.DateType = !item.DateType.IsNullOrEmpty() ? item.DateType : x.DateType;
x.DictionaryKey = x.DictionaryKey.IsNullOrEmpty() ? item.DictionaryKey : x.DictionaryKey; x.DictionaryKey = !item.DictionaryKey.IsNullOrEmpty() ? item.DictionaryKey : x.DictionaryKey;
x.IsShowParent = x.IsShowParent==null ? item.IsShowParent : x.IsShowParent; x.IsShowParent = !item.IsShowParent==null ? item.IsShowParent : x.IsShowParent;
x.ForeignKeyTable = x.ForeignKeyTable.IsNullOrEmpty() ? item.ForeignKeyTable : x.ForeignKeyTable; x.ForeignKeyTable = !item.ForeignKeyTable.IsNullOrEmpty() ? item.ForeignKeyTable : x.ForeignKeyTable;
x.ForeignKeyText = x.ForeignKeyText.IsNullOrEmpty() ? item.ForeignKeyText : x.ForeignKeyText; x.ForeignKeyText = !item.ForeignKeyText.IsNullOrEmpty() ? item.ForeignKeyText : x.ForeignKeyText;
x.ForeignKeyValue = x.ForeignKeyValue.IsNullOrEmpty() ? item.ForeignKeyValue : x.ForeignKeyValue; x.ForeignKeyValue = !item.ForeignKeyValue.IsNullOrEmpty() ? item.ForeignKeyValue : x.ForeignKeyValue;
x.EnumType = x.EnumType.IsNullOrEmpty() ? item.EnumType : x.EnumType; x.EnumType = !item.EnumType.IsNullOrEmpty() ? item.EnumType : x.EnumType;
} }
}); });

View File

@ -23,10 +23,14 @@ namespace IRaCIS.Core.Application.Services
{ {
private readonly IRepository<SystemDocument> _systemDocumentRepository; private readonly IRepository<SystemDocument> _systemDocumentRepository;
private readonly IRepository<SystemDocNeedConfirmedUserType> _systemDocNeedConfirmedUserTypeRepository;
public SystemDocumentService( IRepository<SystemDocument> systemDocumentRepository) public SystemDocumentService( IRepository<SystemDocument> systemDocumentRepository,
IRepository<SystemDocNeedConfirmedUserType> systemDocNeedConfirmedUserTypeRepository
)
{ {
_systemDocumentRepository = systemDocumentRepository; _systemDocumentRepository = systemDocumentRepository;
this._systemDocNeedConfirmedUserTypeRepository = systemDocNeedConfirmedUserTypeRepository;
} }
@ -66,18 +70,20 @@ namespace IRaCIS.Core.Application.Services
} }
else 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 (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("同类型已存在该文件名"); return ResponseOutput.NotOk("同类型已存在该文件名");
} }
_mapper.Map(addOrEditSystemDocument, document); _mapper.Map(addOrEditSystemDocument, document);
document.UpdateTime = DateTime.Now;
if (document.FileTypeId != addOrEditSystemDocument.FileTypeId) if (document.FileTypeId != addOrEditSystemDocument.FileTypeId)
{ {
var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).IfNullThrowException().FullName; 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()); return ResponseOutput.Ok(document.Id.ToString());
} }

View File

@ -574,11 +574,11 @@ namespace IRaCIS.Core.Application.Services
{ {
if (isSystemDoc) if (isSystemDoc)
{ {
await _repository.BatchUpdateAsync<SystemDocument>(t => t.Id == documentId, u => new SystemDocument() { IsDeleted = true }); await _systemDocumentRepository.UpdatePartialFromQueryAsync(documentId, u => new SystemDocument() { IsDeleted = true });
} }
else 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(); return ResponseOutput.Ok();
} }

View File

@ -36,29 +36,29 @@ namespace IRaCIS.Core.Application.Service.Inspection
{ {
//_repository.GetQueryable.GetQueryable < DataInspection > //_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 逻辑代码 #region 逻辑代码
var query = from data in _repository.GetQueryable<DataInspection>() var query = from data in _repository.GetQueryable<DataInspection>().Where(x => (x.TrialId == dto.TrialId)||(x.TrialId==null&&x.CreateTime> trialfirst.CreateTime&&x.CreateTime < trialfirst.TrialFinishTime))
join trial in _repository.GetQueryable<Trial>() on data.TrialId equals trial.Id into trialtemp
join trial in _repository.GetQueryable<Trial>().IgnoreQueryFilters() on data.TrialId equals trial.Id into trialtemp
from leftrial in trialtemp.DefaultIfEmpty() from leftrial in trialtemp.DefaultIfEmpty()
join site in _repository.GetQueryable<Site>() on data.SiteId equals site.Id into sitetemp join site in _repository.GetQueryable<Site>().IgnoreQueryFilters() on data.SiteId equals site.Id into sitetemp
from leftsite in sitetemp.DefaultIfEmpty() from leftsite in sitetemp.DefaultIfEmpty()
join subject in _repository.GetQueryable<Subject>() on data.SubjectId equals subject.Id into subtemp join subject in _repository.GetQueryable<Subject>().IgnoreQueryFilters() on data.SubjectId equals subject.Id into subtemp
from leftsubject in subtemp.DefaultIfEmpty() from leftsubject in subtemp.DefaultIfEmpty()
join subjectVisit in _repository.GetQueryable<SubjectVisit>() on data.SubjectVisitId equals subjectVisit.Id into subjectVisittemp join subjectVisit in _repository.GetQueryable<SubjectVisit>().IgnoreQueryFilters() on data.SubjectVisitId equals subjectVisit.Id into subjectVisittemp
from leftsubjectVisit in subjectVisittemp.DefaultIfEmpty() from leftsubjectVisit in subjectVisittemp.DefaultIfEmpty()
join parent in _repository.GetQueryable<DataInspection>() on data.ParentId equals parent.Id into parenttemp join parent in _repository.GetQueryable<DataInspection>() on data.ParentId equals parent.Id into parenttemp
from leftparent in parenttemp.DefaultIfEmpty() from leftparent in parenttemp.DefaultIfEmpty()
join user in _repository.GetQueryable<User>() on data.CreateUserId equals user.Id into usertemp join user in _repository.GetQueryable<User>().IgnoreQueryFilters() on data.CreateUserId equals user.Id into usertemp
from leftuser in usertemp.DefaultIfEmpty() from leftuser in usertemp.DefaultIfEmpty()
join usertype in _repository.GetQueryable<UserType>() on leftuser.UserTypeId equals usertype.Id into usertypetemp join usertype in _repository.GetQueryable<UserType>().IgnoreQueryFilters() on leftuser.UserTypeId equals usertype.Id into usertypetemp
from leftusertype in usertypetemp.DefaultIfEmpty() from leftusertype in usertypetemp.DefaultIfEmpty()
//join moduleTyped in _repository.GetQueryable<Dictionary>().Where(x => x.Code == "ModuleType") on 1 equals 1 //join moduleTyped in _repository.GetQueryable<Dictionary>().Where(x => x.Code == "ModuleType") on 1 equals 1
//join moduleTypec in _repository.GetQueryable<Dictionary>() on new { ParentId = moduleTyped.Id, ModuleType = data.ModuleType } equals new { ParentId = moduleTypec.ParentId.Value, ModuleType = moduleTypec.Value } into moduleTypectemp //join moduleTypec in _repository.GetQueryable<Dictionary>() 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() //from leftOptType in optTypetemp.DefaultIfEmpty()
join trialSign in _repository.GetQueryable<TrialSign>() on data.SignId equals trialSign.Id into trialSigntemp join trialSign in _repository.GetQueryable<TrialSign>().IgnoreQueryFilters() on data.SignId equals trialSign.Id into trialSigntemp
from lefttrialSign in trialSigntemp.DefaultIfEmpty() from lefttrialSign in trialSigntemp.DefaultIfEmpty()
join leftfrontAuditConfig in _repository.GetQueryable<FrontAuditConfig>().Where(x=>x.ConfigType=="M"&&x.Identification!=null&&x.IsEnable==true) on join leftfrontAuditConfig in _repository.GetQueryable<FrontAuditConfig>().Where(x=>x.ConfigType=="M"&&x.Identification!=null&&x.IsEnable==true) on
data.Identification.ToLower() data.Identification.ToLower()
equals equals
leftfrontAuditConfig.Identification.ToLower() leftfrontAuditConfig.Identification.ToLower()
join moduleTypec in _repository.GetQueryable<Dictionary>() on new { ModuleType = leftfrontAuditConfig.ModuleTypeId.Value } equals new { ModuleType = moduleTypec.Id } into moduleTypectemp join moduleTypec in _repository.GetQueryable<Dictionary>() on new { ModuleType = leftfrontAuditConfig.ModuleTypeId.Value } equals new { ModuleType = moduleTypec.Id } into moduleTypectemp
from leftmoduleTypec in moduleTypectemp.DefaultIfEmpty() from leftmoduleTypec in moduleTypectemp.DefaultIfEmpty()
join OptTypec in _repository.GetQueryable<Dictionary>() on new { ModuleType = leftfrontAuditConfig.OptTypeId.Value } equals new { ModuleType = OptTypec.Id } into optTypetemp join OptTypec in _repository.GetQueryable<Dictionary>() on new { ModuleType = leftfrontAuditConfig.OptTypeId.Value } equals new { ModuleType = OptTypec.Id } into optTypetemp
from leftOptType in optTypetemp.DefaultIfEmpty() 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) query = query.WhereIf(dto.SiteId != null, x => x.SiteId == dto.SiteId)
.WhereIf(dto.SiteId != null, x => x.SiteId == dto.SiteId)
.WhereIf(!dto.SubjectInfo.IsNullOrEmpty(), x => x.SubjectCode.Contains(dto.SubjectInfo)) .WhereIf(!dto.SubjectInfo.IsNullOrEmpty(), x => x.SubjectCode.Contains(dto.SubjectInfo))
.WhereIf(dto.VisitPlanInfo != null, x => x.VisitNum == dto.VisitPlanInfo) .WhereIf(dto.VisitPlanInfo != null, x => x.VisitNum == dto.VisitPlanInfo)
.WhereIf(dto.StartTime != null, x => x.CreateTime >= dto.StartTime) .WhereIf(dto.StartTime != null, x => x.CreateTime >= dto.StartTime)

View File

@ -224,7 +224,11 @@ namespace IRaCIS.Core.Application
return ResponseOutput.NotOk("项目 基础配置、流程配置、加急配置 、访视计划,有未确认项"); 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 }); 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}")] [HttpPut("{trialId:guid}/{isAbandon:bool}")]
public async Task<IResponseOutput> AbandonTrial(Guid trialId, /*Guid? signId,*/ bool isAbandon) public async Task<IResponseOutput> 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);

View File

@ -38,8 +38,8 @@ namespace IRaCIS.Core.Domain.Models
/// <summary> /// <summary>
/// 项目iD /// 项目iD
/// </summary> /// </summary>
[Required]
public Guid TrialId { get; set; } public Guid? TrialId { get; set; }
/// <summary> /// <summary>
/// 中心 /// 中心

View File

@ -293,6 +293,11 @@ namespace IRaCIS.Core.Domain.Models
public Guid? QCQuestionConfirmedUserId { get; set; } public Guid? QCQuestionConfirmedUserId { get; set; }
public DateTime? QCQuestionConfirmedTime { get; set; } public DateTime? QCQuestionConfirmedTime { get; set; }
/// <summary>
/// 项目完成时间
/// </summary>
public DateTime? TrialFinishTime { get; set; }
public int? DigitPlaces { get; set; } = 2; public int? DigitPlaces { get; set; } = 2;

View File

@ -75,6 +75,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
public async Task InsertAddEntitys(List<EntityEntry> entitys,string type) public async Task InsertAddEntitys(List<EntityEntry> entitys,string type)
{ {
#region 所有 #region 所有
//foreach (var item in entitys) //foreach (var item in entitys)
//{ //{
@ -84,13 +85,37 @@ namespace IRaCIS.Core.Infra.EFCore.Common
#region 区分 #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<SystemDocument>(item, type, x => new DataInspection()
{
GeneralId = x.Id
},new {
NeedConfirmedUserType= usertypeName,
});
}
// 项目 // 项目
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(Trial))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(Trial)))
{ {
var entity = item.Entity as Trial;
await InsertInspection<Trial>(item, type, x => new DataInspection() await InsertInspection<Trial>(item, type, x => new DataInspection()
{ {
TrialId = x.Id, TrialId = x.Id,
TrialName = x.ExperimentName, TrialName = x.ExperimentName,
ResearchProgramNo=x.ResearchProgramNo,
GeneralId = x.Id,
}); });
} }
@ -202,7 +227,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
filecount = filecount + count; filecount = filecount + count;
} }
await InsertInspection<NoneDicomStudy>(null, type, x => new DataInspection() await InsertInspection(null, type, x => new DataInspection()
{ {
GeneralId = x.Id, GeneralId = x.Id,
}, new }, new
@ -212,7 +237,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
} }
} }
#region 注释代码
////非Dicom文件 ////非Dicom文件
//foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(NoneDicomStudyFile))) //foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(NoneDicomStudyFile)))
//{ //{
@ -250,6 +275,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
// UpNum = 1,// 每次上传或下载一个 // UpNum = 1,// 每次上传或下载一个
// }); // });
//} //}
#endregion
// 访视 // 访视
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SubjectVisit))) 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 subjectvisit = await _dbContext.SubjectVisit.Where(x => x.Id == entity.SubjectVisitId).FirstOrDefaultAsync();
var qCChallenge = await _dbContext.QCChallenge.Where(x => x.Id == entity.QCChallengeId).FirstOrDefaultAsync(); var qCChallenge = await _dbContext.QCChallenge.Where(x => x.Id == entity.QCChallengeId).FirstOrDefaultAsync();
subjectvisit = subjectvisit ?? new SubjectVisit(); subjectvisit = subjectvisit ?? new SubjectVisit();
qCChallenge = qCChallenge ?? new QCChallenge();
await InsertInspection<QCChallengeDialog>(item, type, x => new DataInspection() await InsertInspection<QCChallengeDialog>(item, type, x => new DataInspection()
{ {
GeneralId = qCChallenge.Id, GeneralId = qCChallenge.Id,