修改QC问题

Test.EIImageViewer
{872297557@qq.com} 2023-01-03 13:32:22 +08:00
parent 55d2ec2dd7
commit b8e21e5265
6 changed files with 102 additions and 25 deletions

View File

@ -73,7 +73,9 @@ namespace IRaCIS.Core.Application.Contracts
public bool? IsEnable { get; set; }
public Guid? TrialId { get; set; }
public bool IsDefeaultViewParent { get; set; }
}

View File

@ -95,6 +95,7 @@ namespace IRaCIS.Core.Application.Contracts
.WhereIf(queryQCQuestionConfigure.IsEnable != null,x=>x.IsEnable== queryQCQuestionConfigure.IsEnable)
.WhereIf(!string.IsNullOrWhiteSpace(queryQCQuestionConfigure.QuestionName), t => t.QuestionName.Contains(queryQCQuestionConfigure.QuestionName))
.WhereIf(!string.IsNullOrWhiteSpace(queryQCQuestionConfigure.Type), t => t.Type.Contains(queryQCQuestionConfigure.Type))
.WhereIf(queryQCQuestionConfigure.IsDefeaultViewParent==true,t=>t.ParentId==null)
.OrderBy(t=>t.ShowOrder)
.ProjectTo<QCQuestionConfigureView>(_mapper.ConfigurationProvider);

View File

@ -40,7 +40,7 @@ namespace IRaCIS.Core.Application.Contracts
var trialQCQuestionQueryable = _trialQcQuestionRepository.Where(t => t.TrialId == queryTrialQCQuestionConfigure.TrialId)
.WhereIf(!string.IsNullOrWhiteSpace(queryTrialQCQuestionConfigure.QuestionName), t => t.QuestionName.Contains(queryTrialQCQuestionConfigure.QuestionName))
.WhereIf(!string.IsNullOrWhiteSpace(queryTrialQCQuestionConfigure.Type), t => t.Type.Contains(queryTrialQCQuestionConfigure.Type))
.WhereIf(queryTrialQCQuestionConfigure.IsEnable!=null, t => t.IsEnable== queryTrialQCQuestionConfigure.IsEnable)
.WhereIf(queryTrialQCQuestionConfigure.IsEnable != null, t => t.IsEnable == queryTrialQCQuestionConfigure.IsEnable)
.WhereIf(queryTrialQCQuestionConfigure.IsRequired != null, t => t.IsRequired == queryTrialQCQuestionConfigure.IsRequired)
@ -139,49 +139,113 @@ namespace IRaCIS.Core.Application.Contracts
{
await VerifyIsQCConfirmedAsync(trialId);
var maxShowOrder = await _trialQcQuestionRepository.Where(x => x.TrialId == trialId).OrderByDescending(x=>x.ShowOrder).Select(x => x.ShowOrder).FirstOrDefaultAsync();
batchList.ForEach(x =>
{
maxShowOrder++;
x.ShowOrder= maxShowOrder;
x.SystemQuestionId = x.Id.Value;
x.Id = NewId.NextGuid();
});
var maxShowOrder = await _trialQcQuestionRepository.Where(x => x.TrialId == trialId).OrderByDescending(x => x.ShowOrder).Select(x => x.ShowOrder).FirstOrDefaultAsync();
maxShowOrder++;
foreach (var item in batchList.Where(x=>x.ParentId!=null))
#region OLd
//batchList.ForEach(x =>
//{
// maxShowOrder++;
// x.ShowOrder = maxShowOrder;
// x.SystemQuestionId = x.Id.Value;
// x.Id = NewId.NextGuid();
//});
//foreach (var item in batchList.Where(x => x.ParentId != null))
//{
// var parent = batchList.Where(x => x.SystemQuestionId == item.ParentId).FirstOrDefault();
// if (parent == null)
// {
// item.ParentId = null;
// item.ParentTriggerValue = String.Empty;
// }
// else
// {
// item.ParentId = parent.Id;
// }
//}
#endregion
#region New
//查询所有的子问题
var list = await _qCQuestionRepository.Where(t => t.ParentId != null).ToListAsync();
var mappedList = _mapper.Map<List<TrialQCQuestion>>(list);
var childList = new List<TrialQCQuestion>();
//遍历父层级的问题
var batchConfigList = _mapper.Map<List<TrialQCQuestion>>(batchList.Where(t => t.ParentId == null));
foreach (var item in batchConfigList.Where(t=>t.ParentId==null).OrderBy(t => t.ShowOrder))
{
var parent = batchList.Where(x => x.SystemQuestionId == item.ParentId).FirstOrDefault();
if (parent == null)
var oldParentId = item.Id;
item.Id = NewId.NextGuid();
item.TrialId = trialId;
item.ShowOrder = maxShowOrder++;
var findChildList = GetChildList(oldParentId, item.Id, mappedList);
foreach (var findChild in findChildList)
{
item.ParentId = null;
item.ParentTriggerValue = String.Empty;
}
else
{
item.ParentId = parent.Id;
findChild.TrialId = trialId;
findChild.ShowOrder = maxShowOrder++;
}
childList.AddRange(findChildList);
}
var batchConfigList = _mapper.Map<List<TrialQCQuestion>>(batchList);
batchConfigList.ForEach(t => t.TrialId = trialId);
#endregion
await _trialQcQuestionRepository.AddRangeAsync(batchConfigList);
await _trialQcQuestionRepository.AddRangeAsync(childList);
var success = await _repository.SaveChangesAsync();
return ResponseOutput.Result(success);
}
private List<TrialQCQuestion> GetChildList(Guid parentId, Guid newParentId, List<TrialQCQuestion> list)
{
var childList = new List<TrialQCQuestion>();
var findlist = list.Where(t => t.ParentId == parentId).ToList();
foreach (var child in findlist)
{
var oldParentId = child.Id;
child.Id = NewId.NextGuid();
child.ParentId = newParentId;
childList.Add(child);
var findList = GetChildList(oldParentId, child.Id, list);
childList.AddRange(findList);
}
return childList;
}
[Authorize(Policy = IRaCISPolicy.IQC)]
public async Task<IResponseOutput> AddOrUpdateTrialQCQuestionConfigure(TrialQCQuestionAddOrEdit addOrEditTrialQCQuestionConfigure)
{
if (await _trialQcQuestionRepository.AnyAsync(x =>x.TrialId== addOrEditTrialQCQuestionConfigure.TrialId&& x.Id != addOrEditTrialQCQuestionConfigure.Id && x.ShowOrder == addOrEditTrialQCQuestionConfigure.ShowOrder))
if (await _trialQcQuestionRepository.AnyAsync(x => x.TrialId == addOrEditTrialQCQuestionConfigure.TrialId && x.Id != addOrEditTrialQCQuestionConfigure.Id && x.ShowOrder == addOrEditTrialQCQuestionConfigure.ShowOrder))
{
throw new BusinessValidationFailedException("序号重复,操作失败");

View File

@ -225,6 +225,7 @@ namespace IRaCIS.Core.Application.Service
CreateMap<QCQuestionAddOrEdit, QCQuestion>();
CreateMap<QCQuestion, TrialQCQuestion>();
CreateMap<TrialQCQuestionAddOrEdit, TrialQCQuestion>();
CreateMap<TrialQCQuestionConfigureBatchAdd, TrialQCQuestion>();

View File

@ -101,9 +101,13 @@ namespace IRaCIS.Application.Services
//await _repository.BatchUpdateAsync<DataInspection>(t => t.TrialId == Guid.Parse("40400000-3e2c-0016-239b-08da581f0e74") && t.EntityName== "ClinicalDataTrialSet", t => new DataInspection() { CreateTime= DateTime.Now.AddMonths(-2) } );
await _visitTaskRepositoryy.UpdatePartialFromQueryAsync( Guid.Parse("78360000-3E2C-0016-9B53-08DA6A002040"), c => new VisitTask() { UpdateTime = DateTime.Now });
//await _visitTaskRepositoryy.UpdatePartialFromQueryAsync( Guid.Parse("78360000-3E2C-0016-9B53-08DA6A002040"), c => new VisitTask() { UpdateTime = DateTime.Now });
await _visitTaskRepositoryy.UpdatePartialFromQueryAsync( Guid.Parse("78360000-3E2C-0016-9B53-08DA6A002040"), c => new VisitTask() { UpdateTime = DateTime.Now.AddMinutes(1) });
//await _visitTaskRepositoryy.UpdatePartialFromQueryAsync( Guid.Parse("78360000-3E2C-0016-9B53-08DA6A002040"), c => new VisitTask() { UpdateTime = DateTime.Now.AddMinutes(1) });
var list1 = await _repository.Where<Dictionary>().Select(t => t.TranslateValue(t.Value, t.ValueCN,true)).ToListAsync();
var list2 = await _repository.Where<Dictionary>().Select(t => t.TranslateValue(t.Value, t.ValueCN, false)).ToListAsync();
await _repository.SaveChangesAsync();
return _userInfo.LocalIp;

View File

@ -1,3 +1,4 @@
using EntityFrameworkCore.Projectables;
using IRaCIS.Core.Domain.Share;
using System;
using System.Collections.Generic;
@ -62,5 +63,9 @@ namespace IRaCIS.Core.Domain.Models
public string MappedValue { get; set; }
[Projectable]
public string TranslateValue( string value, string valueCN,bool isCN) => isCN?valueCN:value;
}
}