diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index b2ae9cd4d..0ccf275c9 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -4336,6 +4336,13 @@ + + + 更改项目标准 + + + + 添加系统qc问题标准 diff --git a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs index c453aa619..799339711 100644 --- a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs +++ b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs @@ -155,10 +155,7 @@ namespace IRaCIS.Core.Application.Service.Inspection { query = query.Where(x => x.InPlan == false); } - - - dto.Asc = false; - return await query.ToPagedListAsync(dto.PageIndex, dto.PageSize,"CreateTime", dto.Asc); + return await query.ToPagedListAsync(dto.PageIndex, dto.PageSize, dto.SortField.IsNullOrEmpty()?nameof(GetDataInspectionOutDto.CreateTime): dto.SortField, dto.Asc); } diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs index 2469c4f28..9ed927979 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs @@ -108,21 +108,52 @@ namespace IRaCIS.Application.Services public async Task SetSystemReadingQuestionCriterionIsCompleteConfig(SetSystemReadingQuestionCriterionIsIsCompleteConfig inDto) { - if (!inDto.IsCompleteConfig && await _readingQuestionCriterionTrialRepository.AnyAsync(x => x.ReadingQuestionCriterionSystemId == inDto.Id)) - { - ResponseOutput.NotOk("当前标准已经运用到项目,操作失败"); - } + //if (!inDto.IsCompleteConfig && await _readingQuestionCriterionTrialRepository.AnyAsync(x => x.ReadingQuestionCriterionSystemId == inDto.Id)) + //{ + // ResponseOutput.NotOk("当前标准已经运用到项目,操作失败"); + //} await _readingQuestionCriterionSystemRepository.UpdatePartialFromQueryAsync(inDto.Id, x => new ReadingQuestionCriterionSystem() { IsCompleteConfig = inDto.IsCompleteConfig }); + if (inDto.IsCompleteConfig) + { + await UpdateTrialCriterion(inDto.Id); + } var result = await _readingQuestionCriterionSystemRepository.SaveChangesAsync(); return ResponseOutput.Ok(result); } + /// + /// 更改项目标准 + /// + /// + /// + private async Task UpdateTrialCriterion(Guid systemCriterionId) + { + await _readingQuestionCriterionTrialRepository.BatchUpdateNoTrackingAsync(x => x.ReadingQuestionCriterionSystemId == systemCriterionId, x => new ReadingQuestionCriterionTrial() + { + IsCompleteConfig = true, + }); + var systemCriterionQuestionList = await _readingQuestionSystemRepository.Where(x => x.ReadingQuestionCriterionSystemId == systemCriterionId).ToListAsync(); + var trialCriterionList = await _readingQuestionCriterionTrialRepository.Where(x => x.ReadingQuestionCriterionSystemId == systemCriterionId).Select(x => new { + x.Id, + x.TrialId, + }).ToListAsync(); + var trialCriterionIdList = trialCriterionList.Select(x => x.Id).ToList(); + List needAddQuestionList = new List(); + foreach (var item in trialCriterionList) + { + await _readingQuestionTrialRepository.BatchDeleteNoTrackingAsync(x => trialCriterionIdList.Contains(x.ReadingQuestionCriterionTrialId)); + List trialQuestionList = new List(); + SetChildParentQuestion(item.Id, item.TrialId, systemCriterionQuestionList, trialQuestionList); + needAddQuestionList.AddRange(trialQuestionList); + } + await _readingQuestionTrialRepository.AddRangeAsync(needAddQuestionList); + } /// /// 添加系统qc问题标准