修改QC问题
							parent
							
								
									55d2ec2dd7
								
							
						
					
					
						commit
						b8e21e5265
					
				| 
						 | 
				
			
			@ -73,7 +73,9 @@ namespace IRaCIS.Core.Application.Contracts
 | 
			
		|||
        public bool? IsEnable { get; set; }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public Guid? TrialId { get; set; }
 | 
			
		||||
        public bool IsDefeaultViewParent { get; set; }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -139,43 +139,107 @@ 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();
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
            #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))
 | 
			
		||||
            //});
 | 
			
		||||
 | 
			
		||||
            //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);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            #endregion
 | 
			
		||||
 | 
			
		||||
            var batchConfigList = _mapper.Map<List<TrialQCQuestion>>(batchList);
 | 
			
		||||
            batchConfigList.ForEach(t => t.TrialId = trialId);
 | 
			
		||||
 | 
			
		||||
            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)
 | 
			
		||||
        {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -225,6 +225,7 @@ namespace IRaCIS.Core.Application.Service
 | 
			
		|||
 | 
			
		||||
            CreateMap<QCQuestionAddOrEdit, QCQuestion>();
 | 
			
		||||
 | 
			
		||||
            CreateMap<QCQuestion, TrialQCQuestion>();
 | 
			
		||||
            CreateMap<TrialQCQuestionAddOrEdit, TrialQCQuestion>();
 | 
			
		||||
 | 
			
		||||
            CreateMap<TrialQCQuestionConfigureBatchAdd, TrialQCQuestion>();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue