Uat_Study
he 2022-12-01 14:45:09 +08:00
parent a92def6f70
commit 77f9bd84d7
1 changed files with 76 additions and 0 deletions

View File

@ -6,6 +6,7 @@ using IRaCIS.Core.Infra.EFCore.Common;
using Panda.DynamicWebApi.Attributes;
using IRaCIS.Core.Application.Contracts;
using IRaCIS.Core.Infrastructure;
using Newtonsoft.Json;
namespace IRaCIS.Application.Services
{
@ -391,6 +392,32 @@ namespace IRaCIS.Application.Services
}
indto.ParentTriggerValue = string.Join(',', indto.ParentTriggerValueList);
indto.RelevanceValue = string.Join(',', indto.RelevanceValueList);
if (indto.Id != null)
{
var relationList = await GetQuestionCalculateRelation(new GetQuestionCalculateRelationInDto()
{
TrialReadingCriterionId = indto.ReadingQuestionCriterionTrialId,
});
var relation = relationList.Where(x => x.QuestionId == indto.Id).FirstOrDefault();
List<CalculateInfo> calculateInfoList = new List<CalculateInfo>();
try
{
var result = JsonConvert.DeserializeObject<List<CalculateInfo>>(indto.CalculateQuestions);
calculateInfoList = result == null ? new List<CalculateInfo>() : result;
}
catch (Exception)
{
}
this.VerifyCalculateRelation(relationList, indto.Id.Value);
}
var entity = await _readingQuestionTrialRepository.InsertOrUpdateAsync(indto, true);
return ResponseOutput.Ok(entity.Id.ToString());
}
@ -411,6 +438,27 @@ namespace IRaCIS.Application.Services
return await query.ToListAsync();
}
private void VerifyCalculateRelation(List<CalculateRelationDto> relationList,Guid QuestionId)
{
var relation = relationList.Where(x=>x.CalculateQuestionList.Any(y=>y.QuestionId== QuestionId||y.TableQuestionId==QuestionId)).ToList();
if (relation.Select(x => x.QuestionId).ToList().Contains(QuestionId))
{
throw new BusinessValidationFailedException("计算依赖循环了!");
}
else
{
var newrelation = relation.Clone();
relation.ForEach(x =>
{
VerifyCalculateRelation(newrelation, QuestionId);
});
}
}
/// <summary>
/// 获取问题计算关系
/// </summary>
@ -565,6 +613,32 @@ namespace IRaCIS.Application.Services
{
indto.ParentTriggerValue = string.Join(',', indto.ParentTriggerValueList);
indto.RelevanceValue = string.Join(',', indto.RelevanceValueList);
if (indto.Id != null)
{
var relationList = await GetQuestionCalculateRelation(new GetQuestionCalculateRelationInDto()
{
ReadingQuestionId = indto.ReadingQuestionId,
});
var relation = relationList.Where(x => x.QuestionId == indto.Id).FirstOrDefault();
List<CalculateInfo> calculateInfoList = new List<CalculateInfo>();
try
{
var result = JsonConvert.DeserializeObject<List<CalculateInfo>>(indto.CalculateQuestions);
calculateInfoList = result == null ? new List<CalculateInfo>() : result;
}
catch (Exception)
{
}
this.VerifyCalculateRelation(relationList, indto.Id.Value);
}
var entity = await _readingTableQuestionTrialRepository.InsertOrUpdateAsync(indto, true);
return ResponseOutput.Ok(entity.Id.ToString());
@ -572,6 +646,8 @@ namespace IRaCIS.Application.Services
}
/// <summary>
/// 删除项目表格问题