From 58656ac27ef7858233e483ae55a43ecef85e6fca Mon Sep 17 00:00:00 2001
From: hang <872297557@qq.com>
Date: Mon, 17 Oct 2022 16:45:37 +0800
Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Service/Reading/ReadingQuestionService.cs | 1561 +++++++++--------
1 file changed, 787 insertions(+), 774 deletions(-)
diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs
index 7178c21b5..109b0b0a6 100644
--- a/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs
+++ b/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs
@@ -1,14 +1,7 @@
-using IRaCIS.Application.Interfaces;
-using IRaCIS.Core.Infra.EFCore;
-using IRaCIS.Core.Domain.Share;
-using IRaCIS.Core.Application.Filter;
+using IRaCIS.Core.Domain.Share;
using Microsoft.AspNetCore.Mvc;
-using IRaCIS.Core.Application.Service.WorkLoad.DTO;
-using Microsoft.AspNetCore.Authorization;
-using IRaCIS.Core.Application.Auth;
using IRaCIS.Core.Application.Service.Reading.Dto;
using MassTransit;
-using IRaCIS.Core.Application.Service.Reading;
using IRaCIS.Core.Infra.EFCore.Common;
using Panda.DynamicWebApi.Attributes;
using IRaCIS.Core.Application.Contracts;
@@ -78,21 +71,686 @@ namespace IRaCIS.Application.Services
}
+ #region 系统标准
+ ///
+ /// 获取获取系统阅片标准下拉
+ ///
+ ///
+ [HttpPost]
+ public async Task> GetSystemCriterionList()
+ {
+ List result = await _readingQuestionCriterionSystemRepository.Select(x => new GetSystemCriterionListOutDto()
+ {
+
+ CriterionId = x.Id,
+ CriterionName = x.CriterionName,
+
+ }).ToListAsync();
+
+ return result;
+ }
+
+ ///
+ /// 获取系统问题标准
+ ///
+ ///
+ [HttpPost]
+ public async Task> GetReadingQuestionCriterionSystemList(ReadingQuestionCriterionSystemViewInDto inDto)
+ {
+ //await AddSystemQuestionCriterion();
+ var query = _readingQuestionCriterionSystemRepository.AsQueryable()
+ .WhereIf(!inDto.CriterionName.IsNullOrEmpty(), x => x.CriterionName.Contains(inDto.CriterionName))
+ .ProjectTo(_mapper.ConfigurationProvider);
+
+ return await query.ToPagedListAsync(inDto.PageIndex, inDto.PageSize, inDto.SortField.IsNullOrEmpty() ? nameof(ReadingQuestionCriterionSystemView.ShowOrder) : inDto.SortField,
+ inDto.Asc);
+ }
+
+ ///
+ /// 获取系统问题标准下拉
+ ///
+ ///
+ [HttpPost]
+ public async Task> GetSystemCriterionSelectList()
+ {
+ var criterionList = await _readingQuestionCriterionSystemRepository.AsQueryable()
+ .OrderBy(x => x.ShowOrder)
+ .Select(x => new GetSystemCriterionSelectDto()
+ {
+ Id = x.Id,
+ CriterionName = x.CriterionName,
+
+ }).ToListAsync();
+ return criterionList;
+ }
+
+ ///
+ /// 新增修改系统问题标准
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task AddOrUpdateReadingQuestionCriterionSystem(AddOrUpdateReadingQuestionCriterionSystemInDto indto)
+ {
+ var entity = await _readingQuestionCriterionSystemRepository.InsertOrUpdateAsync(indto, true);
+
+ if (indto.Id != null)
+ {
+ await _readingQuestionCriterionTrialRepository.BatchUpdateNoTrackingAsync(x => x.ReadingQuestionCriterionSystemId == indto.Id, x => new ReadingQuestionCriterionTrial()
+ {
+ CriterionName = indto.CriterionName,
+ CriterionType = indto.CriterionType,
+
+ });
+ }
+ return ResponseOutput.Ok(entity.Id.ToString());
+ }
+
+ ///
+ /// 删除系统问题标准
+ ///
+ ///
+ ///
+ [HttpDelete("{id:guid}")]
+ public async Task DeleteReadingQuestionCriterionSystem(Guid id)
+ {
+
+
+ if (await _readingQuestionCriterionTrialRepository.AnyAsync(x => x.IsConfirm && x.ReadingQuestionCriterionSystemId == id))
+ {
+ throw new BusinessValidationFailedException("当前标准被引用过了,不可以删除");
+ }
+
+ await _readingQuestionCriterionSystemRepository.DeleteFromQueryAsync(t => t.Id == id);
+ var success = await _readingQuestionCriterionSystemRepository.SaveChangesAsync();
+ return ResponseOutput.Result(success);
+ }
+
+
+
+ ///
+ /// 设置系统问题标准是否完成配置
+ ///
+ ///
+ ///
+ public async Task SetSystemReadingQuestionCriterionIsCompleteConfig(SetSystemReadingQuestionCriterionIsIsCompleteConfig inDto)
+ {
+
+ if (!inDto.IsCompleteConfig)
+ {
+ var trialCriterionIds = await _readingQuestionCriterionTrialRepository.Where(x => x.ReadingQuestionCriterionSystemId == inDto.Id).Select(x => x.Id).ToListAsync();
+ if (await _readingTaskQuestionAnswer.AnyAsync(x => trialCriterionIds.Contains(x.ReadingQuestionCriterionTrialId)))
+ {
+ return ResponseOutput.NotOk("此标准在项目里面已被使用,操作失败");
+ }
+ }
+
+ var systemCriterion = await _readingQuestionCriterionSystemRepository.Where(x => x.Id == inDto.Id).AsNoTracking().FirstOrDefaultAsync();
+
+ var confirmTime = systemCriterion.ConfirmTime;
+
+ if (inDto.IsCompleteConfig)
+ {
+ confirmTime = DateTime.Now;
+ }
+
+ await _readingQuestionCriterionSystemRepository.UpdatePartialFromQueryAsync(inDto.Id, x => new ReadingQuestionCriterionSystem()
+ {
+ IsCompleteConfig = inDto.IsCompleteConfig,
+ ConfirmTime = confirmTime,
+ });
+
+ if (inDto.IsCompleteConfig)
+ {
+ //await SynchronizeSystemCriterion(inDto.Id);
+ }
+ else
+ {
+ await _readingQuestionCriterionTrialRepository.BatchUpdateNoTrackingAsync(x => x.ReadingQuestionCriterionSystemId == inDto.Id, x => new ReadingQuestionCriterionTrial()
+ {
+ IsCompleteConfig = inDto.IsCompleteConfig
+ });
+ }
+ var result = await _readingQuestionCriterionSystemRepository.SaveChangesAsync();
+
+ return ResponseOutput.Ok(result);
+ }
+
+
+ #endregion
+
+ #region 项目标准
+
+ ///
+ /// 获取项目裁判信息
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task GetTrialJudgyInfo(GetTrialJudgyInfoInDto inDto)
+ {
+ GetTrialJudgyInfoOutDto result = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == inDto.TrialReadingCriterionId).Select(x => new GetTrialJudgyInfoOutDto
+ {
+ TrialId = x.TrialId,
+ IsReadingTaskViewInOrder = x.IsReadingTaskViewInOrder,
+ ArbitrationRule = x.ArbitrationRule,
+ IsArbitrationReading = x.IsArbitrationReading
+
+ }).FirstNotNullAsync();
+
+ return result;
+ }
+
+ ///
+ /// 新增修改项目问题标准(项目)
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task AddOrUpdateReadingQuestionCriterionTrial(AddOrUpdateReadingQuestionCriterionTrialInDto indto)
+ {
+
+ var entity = await _readingQuestionCriterionTrialRepository.InsertOrUpdateAsync(indto, true);
+ return ResponseOutput.Ok(entity.Id.ToString());
+ }
+
+
+
+ ///
+ /// 设置项目标准是否完成配置
+ ///
+ ///
+ ///
+ public async Task SetTrialReadingQuestionCriterionIsIsCompleteConfig(SetSystemReadingQuestionCriterionIsIsCompleteConfig inDto)
+ {
+ await _readingQuestionCriterionTrialRepository.UpdatePartialFromQueryAsync(inDto.Id, x => new ReadingQuestionCriterionTrial()
+ {
+ IsCompleteConfig = inDto.IsCompleteConfig
+ });
+
+ var result = await _readingQuestionCriterionTrialRepository.SaveChangesAsync();
+
+ return ResponseOutput.Ok(result);
+ }
+
+ ///
+ /// 获取项目问题标准(项目)
+ ///
+ ///
+ [HttpPost]
+ public async Task> GetReadingQuestionCriterionTrialList(ReadingQuestionCriterionTrialViewInDto inDto)
+ {
+ await AddSystemDataToTrila(inDto.TrialId);
+ var query = _readingQuestionCriterionTrialRepository.AsQueryable()
+ .Where(x => x.TrialId == inDto.TrialId)
+ .Where(x => (x.ReadingQuestionCriterionSystemId != null && x.IsEnable) || x.ReadingQuestionCriterionSystemId == null)
+ .WhereIf(!inDto.CriterionName.IsNullOrEmpty(), x => x.CriterionName.Contains(inDto.CriterionName))
+
+ .ProjectTo(_mapper.ConfigurationProvider);
+ return await query.ToPagedListAsync(inDto.PageIndex, inDto.PageSize, inDto.SortField.IsNullOrEmpty() ? nameof(ReadingQuestionCriterionTrialView.ShowOrder) : inDto.SortField,
+ inDto.Asc);
+ }
+
+ ///
+ /// 删除项目问题标准(项目)
+ ///
+ ///
+ ///
+ [HttpDelete("{id:guid}")]
+ public async Task DeleteReadingQuestionCriterionTrial(Guid id)
+ {
+ await _readingQuestionCriterionTrialRepository.DeleteFromQueryAsync(t => t.Id == id);
+ var success = await _readingQuestionCriterionTrialRepository.SaveChangesAsync();
+ return ResponseOutput.Result(success);
+ }
+
+ ///
+ /// 设置项目裁判信息
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task SetTrialJudgyInfo(SetTrialJudgyInfoInDto inDto)
+ {
+
+ var trialCriterion = await _readingQuestionCriterionTrialRepository.Where(x => x.TrialId == inDto.TrialId && x.Id == inDto.TrialReadingCriterionId).FirstOrDefaultAsync();
+
+ var judgeCount = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == trialCriterion.Id && x.IsJudgeQuestion)
+ .WhereIf(trialCriterion.FormType == FormType.SinglePage, x => x.ReadingCriterionPageId == null)
+ .WhereIf(trialCriterion.FormType == FormType.MultiplePage, x => x.ReadingCriterionPageId != null).CountAsync();
+
+ if (judgeCount == 0 && (inDto.ArbitrationRule == ArbitrationRule.Visit || inDto.ArbitrationRule == ArbitrationRule.Reading))
+ {
+ throw new BusinessValidationFailedException("无裁判问题却有仲裁对象,操作失败");
+ }
+ await _readingQuestionCriterionTrialRepository.UpdatePartialFromQueryAsync(inDto.TrialReadingCriterionId, x => new ReadingQuestionCriterionTrial()
+ {
+ ArbitrationRule = inDto.ArbitrationRule,
+ //IsArbitrationReading = inDto.IsArbitrationReading,
+ });
+
+ var result = await _trialRepository.SaveChangesAsync();
+ return ResponseOutput.Ok(result);
+ }
+
+
+ #endregion
+
#region 系统标准问题
+ ///
+ /// 获取系统问题分组
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task> GetSystemGroupNameList(GetTrialGroupNameListInDto inDto)
+ {
+ var result = await _readingQuestionSystemRepository.Where(x => x.ReadingQuestionCriterionSystemId == inDto.CriterionId && x.Type == ReadingQestionType.Group)
+ .Select(x => x.GroupName).ToListAsync();
+ return result;
+
+ }
+
+ ///
+ /// 获取系统问题
+ ///
+ ///
+ [HttpPost]
+ public async Task> GetReadingQuestionSystemList(ReadingQuestionSystemViewInDto inDto)
+ {
+ var query = _readingQuestionSystemRepository.AsQueryable()
+ .Where(x => x.ReadingQuestionCriterionSystemId == inDto.ReadingQuestionCriterionSystemId)
+ .WhereIf(!inDto.QuestionName.IsNullOrEmpty(), x => x.QuestionName.Contains(inDto.QuestionName))
+ .WhereIf(!inDto.Type.IsNullOrEmpty(), x => x.Type.Contains(inDto.Type))
+ .ProjectTo(_mapper.ConfigurationProvider);
+ return await query.ToPagedListAsync(inDto.PageIndex, inDto.PageSize, nameof(ReadingQuestionSystemView.ShowOrder),
+ inDto.Asc);
+ }
+
+ ///
+ /// 获取系统标准的其他问题
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task> GetSystemCriterionOtherQuestion(GetSystemCriterionOtherQuestionInDto inDto)
+ {
+ var types = new List()
+ {
+ "select","radio"
+ };
+ var questionList = await _readingQuestionSystemRepository.Where(x => x.ReadingQuestionCriterionSystemId == inDto.ReadingQuestionCriterionSystemId)
+ .Where(x => types.Contains(x.Type))
+ .WhereIf(inDto.Id != null, x => x.Id != inDto.Id && x.ParentId != inDto.Id)
+ .Select(x => new CriterionOtherQuestionOutDto()
+ {
+ QuestionId = x.Id,
+ QuestionName = x.QuestionName,
+ TypeValue = x.TypeValue,
+ GroupName = x.GroupName,
+ }).ToListAsync();
+
+ return questionList;
+ }
+
+ ///
+ /// 新增修改系统问题
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task AddOrUpdateReadingQuestionSystem(AddOrUpdateReadingQuestionSystemInDto indto)
+ {
+ if (indto.Id != null)
+ {
+ var trialIdList = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionSystemId == indto.Id && x.IsJudgeQuestion && x.JudgeType != JudgeTypeEnum.None)
+ .Select(x => x.TrialId).ToListAsync();
+
+ //if (trialIdList.Count>0)
+ //{
+ // var trialNames = await _trialRepository.Where(x => trialIdList.Contains(x.Id)).Select(x => x.ExperimentName).ToListAsync();
+ // throw new BusinessValidationFailedException("当前问题在项目"+ string.Join(',', trialNames) + "设置了裁判标准了,修改失败");
+ //}
+ }
+
+ if (await _readingQuestionSystemRepository.AnyAsync(x => x.Id != indto.Id && x.ShowOrder == indto.ShowOrder && x.ReadingQuestionCriterionSystemId == indto.ReadingQuestionCriterionSystemId))
+ {
+ throw new BusinessValidationFailedException("问题编号重复");
+ }
+ var entity = await _readingQuestionSystemRepository.InsertOrUpdateAsync(indto, true);
+ return ResponseOutput.Ok(entity.Id.ToString());
+ }
+
+
+ ///
+ /// 删除系统问题
+ ///
+ ///
+ ///
+ [HttpDelete("{id:guid}")]
+ public async Task DeleteReadingQuestionSystem(Guid id)
+ {
+ if (await _readingQuestionSystemRepository.AnyAsync(x => x.ParentId == id))
+ {
+ return ResponseOutput.NotOk("此问题存在子问题,请先删除子问题");
+ }
+ await _readingQuestionSystemRepository.DeleteFromQueryAsync(t => t.Id == id);
+ var success = await _readingQuestionSystemRepository.SaveChangesAsync();
+ return ResponseOutput.Result(success);
+ }
+
+
#endregion
#region 系统标准表格问题
+ ///
+ /// 获取系统的表格问题
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task> GetReadingTableQuestionSystemList(ReadingTableQuestionSystemQuery inDto)
+ {
+ var readingTableQuestionSystemQueryable = _readingTableQuestionSystemRepository
+ .WhereIf(inDto.TableQuestionType != null, x => x.TableQuestionType == inDto.TableQuestionType!)
+ .Where(x => x.ReadingQuestionId == inDto.ReadingQuestionId).ProjectTo(_mapper.ConfigurationProvider);
+
+ var result = await readingTableQuestionSystemQueryable.OrderBy(x => x.ShowOrder).ToListAsync();
+ return result;
+ }
+
+ ///
+ /// 获取系统表格其他问题
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task> GetReadingTableOtherQuestionSystem(GetReadingTableOtherQuestionSystemInDto inDto)
+ {
+ var types = new List()
+ {
+ "select","radio"
+ };
+ var questionList = await _readingTableQuestionSystemRepository.Where(x => x.ReadingQuestionId == inDto.ReadingQuestionId)
+ .Where(x => types.Contains(x.Type))
+ .WhereIf(inDto.Id != null, x => x.Id != inDto.Id && x.ParentId != inDto.Id)
+
+ .Select(x => new CriterionOtherQuestionOutDto()
+ {
+ QuestionId = x.Id,
+ QuestionName = x.QuestionName,
+ TypeValue = x.TypeValue,
+ }).ToListAsync();
+
+ return questionList;
+ }
+
+
+ ///
+ /// 新增修改系统表格问题
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task AddOrUpdateReadingTableQuestionSystem(ReadingTableQuestionSystemAddOrEdit addOrEditReadingTableQuestionSystem)
+ {
+
+ var entity = await _readingTableQuestionSystemRepository.InsertOrUpdateAsync(addOrEditReadingTableQuestionSystem, true);
+
+ return ResponseOutput.Ok(entity.Id.ToString());
+
+ }
+
+ ///
+ /// 删除系统表格问题
+ ///
+ ///
+ ///
+ [HttpDelete("{Id:guid}")]
+ public async Task DeleteReadingTableQuestionSystem(Guid Id)
+ {
+ if (await _readingTableQuestionSystemRepository.AnyAsync(x => x.ParentId == Id || x.RelevanceId == Id))
+ {
+ return ResponseOutput.NotOk("当前问题存在子问题 删除失败");
+ }
+
+ await _readingTableQuestionSystemRepository.DeleteFromQueryAsync(t => t.Id == Id);
+ var success = await _readingTableQuestionSystemRepository.SaveChangesAsync();
+ return ResponseOutput.Result(success);
+ }
+
#endregion
-
#region 项目标准问题
+ ///
+ /// 新增修改项目问题(项目)
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task AddOrUpdateReadingQuestionTrial(AddOrUpdateReadingQuestionTrialInDto indto)
+ {
+ if (indto.Id != null)
+ {
+ if (await _readingQuestionTrialRepository.AnyAsync(x => x.Id == indto.Id && x.IsJudgeQuestion && x.JudgeType != JudgeTypeEnum.None))
+ {
+ throw new BusinessValidationFailedException("当前问题已经设置了裁判标准了,修改失败");
+ }
+ }
+
+ if (indto.ParentId == indto.RelevanceId && indto.ParentId != null && indto.ParentTriggerValue != indto.RelevanceValue)
+ {
+ throw new BusinessValidationFailedException("显示依赖父问题和必填依赖的问题为同一个,但答案互斥,操作失败");
+ }
+
+
+ if (await _readingQuestionTrialRepository.AnyAsync(x => x.Id != indto.Id && x.ShowOrder == indto.ShowOrder && x.TrialId == indto.TrialId && x.ReadingQuestionCriterionTrialId == indto.ReadingQuestionCriterionTrialId && x.ReadingCriterionPageId == indto.ReadingCriterionPageId))
+ {
+ throw new BusinessValidationFailedException("问题编号重复");
+ }
+ var entity = await _readingQuestionTrialRepository.InsertOrUpdateAsync(indto, true);
+ return ResponseOutput.Ok(entity.Id.ToString());
+ }
+
+ ///
+ /// 获取项目问题(项目)
+ ///
+ ///
+ [HttpPost]
+ public async Task> GetReadingQuestionTrialList(ReadingQuestionTrialViewInDto inDto)
+ {
+ var query = _readingQuestionTrialRepository.AsQueryable()
+ .Where(x => x.ReadingQuestionCriterionTrialId == inDto.ReadingQuestionCriterionTrialId)
+ .WhereIf(!inDto.QuestionName.IsNullOrEmpty(), x => x.QuestionName.Contains(inDto.QuestionName))
+ .WhereIf(!inDto.Type.IsNullOrEmpty(), x => x.Type.Contains(inDto.Type))
+ .Where(x => x.ReadingCriterionPageId == inDto.ReadingCriterionPageId)
+ .ProjectTo(_mapper.ConfigurationProvider).OrderBy(x => x.ShowOrder);
+ return await query.ToListAsync();
+ }
+
+ ///
+ /// 获取项目标准的其他问题(项目)
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task> GetTrialCriterionOtherQuestion(GetTrialCriterionOtherQuestionInDto inDto)
+ {
+ var types = new List()
+ {
+ "select","radio"
+ };
+ var questionList = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == inDto.ReadingQuestionCriterionTrialId)
+ .Where(x => types.Contains(x.Type))
+ .WhereIf(inDto.Id != null, x => x.Id != inDto.Id && x.ParentId != inDto.Id)
+ .Where(x => x.ReadingCriterionPageId == inDto.ReadingCriterionPageId)
+
+ .Select(x => new CriterionOtherQuestionOutDto()
+ {
+ QuestionId = x.Id,
+ QuestionName = x.QuestionName,
+ TypeValue = x.TypeValue,
+ GroupName = x.GroupName,
+ }).ToListAsync();
+
+ return questionList;
+ }
+
+ ///
+ /// 删除项目问题(项目)
+ ///
+ ///
+ ///
+ [HttpDelete("{id:guid}")]
+ public async Task DeleteReadingQuestionTrial(Guid id)
+ {
+ if (await _readingQuestionTrialRepository.AnyAsync(x => x.ParentId == id))
+ {
+ return ResponseOutput.NotOk("此问题存在子问题,请先删除子问题");
+ }
+ await _readingQuestionTrialRepository.DeleteFromQueryAsync(t => t.Id == id);
+ var success = await _readingQuestionTrialRepository.SaveChangesAsync();
+ return ResponseOutput.Result(success);
+ }
+
+ ///
+ /// 获取项目问题分组
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task> GetTrialGroupNameList(GetTrialGroupNameListInDto inDto)
+ {
+ var result = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == inDto.CriterionId && x.Type == ReadingQestionType.Group)
+ .Where(x => x.ReadingCriterionPageId == inDto.ReadingCriterionPageId)
+ .Select(x => x.GroupName).ToListAsync();
+
+ return result;
+
+ }
+
#endregion
#region 项目标准表格问题
+
+ ///
+ /// 获取项目的表格问题
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task> GetReadingTableQuestionTrialList(ReadingTableQuestionSystemQuery inDto)
+ {
+
+ var readingTableQuestionSystemQueryable = _readingTableQuestionTrialRepository
+ .WhereIf(inDto.TableQuestionType != null, x => x.TableQuestionType == inDto.TableQuestionType!)
+ .Where(x => x.ReadingQuestionId == inDto.ReadingQuestionId).ProjectTo(_mapper.ConfigurationProvider);
+
+ var result = await readingTableQuestionSystemQueryable.OrderBy(x => x.ShowOrder).ToListAsync();
+ return result;
+ }
+
+ ///
+ /// 获取项目表格其他问题
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task> GetReadingTableOtherQuestionTrial(GetReadingTableOtherQuestionSystemInDto inDto)
+ {
+
+ var types = new List()
+ {
+ "select","radio"
+ };
+ var questionList = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == inDto.ReadingQuestionId)
+ .Where(x => types.Contains(x.Type))
+ .WhereIf(inDto.Id != null, x => x.Id != inDto.Id && x.ParentId != inDto.Id)
+
+ .Select(x => new CriterionOtherQuestionOutDto()
+ {
+ QuestionId = x.Id,
+ QuestionName = x.QuestionName,
+ TypeValue = x.TypeValue,
+ }).ToListAsync();
+
+ return questionList;
+ }
+
+
+
+
+ ///
+ /// 新增修改想想项目表格问题
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task AddOrUpdateReadingTableQuestionTrial(ReadingTableQuestionTrialAddOrEdit addOrEditReadingTableQuestionTrial)
+ {
+
+ var entity = await _readingTableQuestionTrialRepository.InsertOrUpdateAsync(addOrEditReadingTableQuestionTrial, true);
+
+ return ResponseOutput.Ok(entity.Id.ToString());
+
+ }
+
+
+
+ ///
+ /// 删除项目表格问题
+ ///
+ ///
+ ///
+ [HttpDelete("{Id:guid}")]
+ public async Task DeleteReadingTableQuestionTrial(Guid Id)
+ {
+ if (await _readingTableQuestionTrialRepository.AnyAsync(x => x.ParentId == Id || x.RelevanceId == Id))
+ {
+ return ResponseOutput.NotOk("当前问题存在子问题 删除失败");
+ }
+
+ await _readingTableQuestionTrialRepository.DeleteFromQueryAsync(t => t.Id == Id);
+ var success = await _readingTableQuestionTrialRepository.SaveChangesAsync();
+ return ResponseOutput.Result(success);
+ }
+
+
+ #endregion
+
+ #region 项目阅片标准问题分页
+
+ ///
+ /// 新增修改项目标准分页
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task AddOrUpdateReadingCriterionPage(ReadingCriterionPageAddOrEdit addOrEditReadingCriterionPage)
+ {
+
+ var entity = await _readingCriterionPageRepository.InsertOrUpdateAsync(addOrEditReadingCriterionPage, true);
+ return ResponseOutput.Ok(entity.Id.ToString());
+
+ }
+
+ ///
+ /// 删除标准分页
+ ///
+ ///
+ ///
+ [HttpDelete("{Id:guid}")]
+ public async Task DeleteReadingCriterionPage(Guid Id)
+ {
+ var success = await _readingCriterionPageRepository.DeleteFromQueryAsync(t => t.Id == Id, true);
+ return ResponseOutput.Ok();
+ }
+
+
#endregion
#region 疗效对照表
@@ -250,269 +908,6 @@ namespace IRaCIS.Application.Services
return ResponseOutput.Ok();
}
- ///
- /// 获取获取系统阅片标准下拉
- ///
- ///
- [HttpPost]
- public async Task> GetSystemCriterionList()
- {
- List result = await _readingQuestionCriterionSystemRepository.Select(x => new GetSystemCriterionListOutDto()
- {
-
- CriterionId = x.Id,
- CriterionName = x.CriterionName,
-
- }).ToListAsync();
-
- return result;
- }
-
- ///
- /// 获取系统的表格问题
- ///
- ///
- ///
- [HttpPost]
- public async Task> GetReadingTableQuestionSystemList(ReadingTableQuestionSystemQuery inDto)
- {
- var readingTableQuestionSystemQueryable = _readingTableQuestionSystemRepository
- .WhereIf(inDto.TableQuestionType != null, x => x.TableQuestionType == inDto.TableQuestionType!)
- .Where(x => x.ReadingQuestionId == inDto.ReadingQuestionId).ProjectTo(_mapper.ConfigurationProvider);
-
- var result = await readingTableQuestionSystemQueryable.OrderBy(x => x.ShowOrder).ToListAsync();
- return result;
- }
-
-
-
- ///
- /// 获取项目的表格问题
- ///
- ///
- ///
- [HttpPost]
- public async Task> GetReadingTableQuestionTrialList(ReadingTableQuestionSystemQuery inDto)
- {
-
- var readingTableQuestionSystemQueryable = _readingTableQuestionTrialRepository
- .WhereIf(inDto.TableQuestionType != null, x => x.TableQuestionType == inDto.TableQuestionType!)
- .Where(x => x.ReadingQuestionId == inDto.ReadingQuestionId).ProjectTo(_mapper.ConfigurationProvider);
-
- var result = await readingTableQuestionSystemQueryable.OrderBy(x => x.ShowOrder).ToListAsync();
- return result;
- }
-
-
- ///
- /// 新增修改系统表格问题
- ///
- ///
- ///
- [HttpPost]
- public async Task AddOrUpdateReadingTableQuestionSystem(ReadingTableQuestionSystemAddOrEdit addOrEditReadingTableQuestionSystem)
- {
-
- var entity = await _readingTableQuestionSystemRepository.InsertOrUpdateAsync(addOrEditReadingTableQuestionSystem, true);
-
- return ResponseOutput.Ok(entity.Id.ToString());
-
- }
-
- ///
- /// 新增修改想想项目表格问题
- ///
- ///
- ///
- [HttpPost]
- public async Task AddOrUpdateReadingTableQuestionTrial(ReadingTableQuestionTrialAddOrEdit addOrEditReadingTableQuestionTrial)
- {
-
- var entity = await _readingTableQuestionTrialRepository.InsertOrUpdateAsync(addOrEditReadingTableQuestionTrial, true);
-
- return ResponseOutput.Ok(entity.Id.ToString());
-
- }
-
-
-
- ///
- /// 删除项目表格问题
- ///
- ///
- ///
- [HttpDelete("{Id:guid}")]
- public async Task DeleteReadingTableQuestionTrial(Guid Id)
- {
- if (await _readingTableQuestionTrialRepository.AnyAsync(x => x.ParentId == Id || x.RelevanceId == Id))
- {
- return ResponseOutput.NotOk("当前问题存在子问题 删除失败");
- }
-
- await _readingTableQuestionTrialRepository.DeleteFromQueryAsync(t => t.Id == Id);
- var success = await _readingTableQuestionTrialRepository.SaveChangesAsync();
- return ResponseOutput.Result(success);
- }
-
- ///
- /// 删除系统表格问题
- ///
- ///
- ///
- [HttpDelete("{Id:guid}")]
- public async Task DeleteReadingTableQuestionSystem(Guid Id)
- {
- if (await _readingTableQuestionSystemRepository.AnyAsync(x => x.ParentId == Id || x.RelevanceId == Id))
- {
- return ResponseOutput.NotOk("当前问题存在子问题 删除失败");
- }
-
- await _readingTableQuestionSystemRepository.DeleteFromQueryAsync(t => t.Id == Id);
- var success = await _readingTableQuestionSystemRepository.SaveChangesAsync();
- return ResponseOutput.Result(success);
- }
-
- ///
- /// 获取项目表格其他问题
- ///
- ///
- ///
- [HttpPost]
- public async Task> GetReadingTableOtherQuestionTrial(GetReadingTableOtherQuestionSystemInDto inDto)
- {
-
- var types = new List()
- {
- "select","radio"
- };
- var questionList = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == inDto.ReadingQuestionId)
- .Where(x => types.Contains(x.Type))
- .WhereIf(inDto.Id != null, x => x.Id != inDto.Id && x.ParentId != inDto.Id)
-
- .Select(x => new CriterionOtherQuestionOutDto()
- {
- QuestionId = x.Id,
- QuestionName = x.QuestionName,
- TypeValue = x.TypeValue,
- }).ToListAsync();
-
- return questionList;
- }
-
- ///
- /// 获取系统表格其他问题
- ///
- ///
- ///
- [HttpPost]
- public async Task> GetReadingTableOtherQuestionSystem(GetReadingTableOtherQuestionSystemInDto inDto)
- {
- var types = new List()
- {
- "select","radio"
- };
- var questionList = await _readingTableQuestionSystemRepository.Where(x => x.ReadingQuestionId == inDto.ReadingQuestionId)
- .Where(x => types.Contains(x.Type))
- .WhereIf(inDto.Id != null, x => x.Id != inDto.Id && x.ParentId != inDto.Id)
-
- .Select(x => new CriterionOtherQuestionOutDto()
- {
- QuestionId = x.Id,
- QuestionName = x.QuestionName,
- TypeValue = x.TypeValue,
- }).ToListAsync();
-
- return questionList;
- }
-
- ///
- /// 设置项目裁判信息
- ///
- ///
- ///
- [HttpPost]
- public async Task SetTrialJudgyInfo(SetTrialJudgyInfoInDto inDto)
- {
-
- var trialCriterion = await _readingQuestionCriterionTrialRepository.Where(x => x.TrialId == inDto.TrialId&&x.Id== inDto.TrialReadingCriterionId).FirstOrDefaultAsync();
-
- var judgeCount = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == trialCriterion.Id && x.IsJudgeQuestion)
- .WhereIf(trialCriterion.FormType == FormType.SinglePage, x => x.ReadingCriterionPageId == null)
- .WhereIf(trialCriterion.FormType == FormType.MultiplePage, x => x.ReadingCriterionPageId != null).CountAsync();
-
- if (judgeCount == 0 && (inDto.ArbitrationRule == ArbitrationRule.Visit || inDto.ArbitrationRule == ArbitrationRule.Reading))
- {
- throw new BusinessValidationFailedException("无裁判问题却有仲裁对象,操作失败");
- }
- await _readingQuestionCriterionTrialRepository.UpdatePartialFromQueryAsync(inDto.TrialReadingCriterionId, x => new ReadingQuestionCriterionTrial()
- {
- ArbitrationRule = inDto.ArbitrationRule,
- //IsArbitrationReading = inDto.IsArbitrationReading,
- });
-
- var result = await _trialRepository.SaveChangesAsync();
- return ResponseOutput.Ok(result);
- }
-
-
- ///
- /// 验证是否要同步标准
- ///
- ///
- ///
- [HttpPost]
- public async Task VerifyeCriterionNeedSynchronize(VerifyeCriterionNeedSynchronizeInDto inDto)
- {
- var trialCriterion = await _readingQuestionCriterionTrialRepository.Where(x => x.Id==inDto.TrialReadingCriterionId).FirstOrDefaultAsync();
- if (trialCriterion == null)
- {
- return NeedSynchronize.NotNeed;
- }
- if (trialCriterion.ReadingQuestionCriterionSystemId != null)
- {
- var systemCriterion = await _readingQuestionCriterionSystemRepository.Where(x => x.Id == trialCriterion.ReadingQuestionCriterionSystemId).FirstNotNullAsync();
- if (systemCriterion.ConfirmTime > trialCriterion.SynchronizeTime)
- {
-
- var systemQuestionList = await _readingQuestionSystemRepository.Where(x => x.IsJudgeQuestion && x.ReadingQuestionCriterionSystemId == trialCriterion.ReadingQuestionCriterionSystemId).ToListAsync();
- var trialQuestionList = await _readingQuestionTrialRepository.Where(x => x.IsJudgeQuestion && x.ReadingQuestionCriterionTrialId == trialCriterion.Id).ToListAsync();
- if (systemQuestionList.Count() != trialQuestionList.Count())
- {
- return NeedSynchronize.JudgeNotEqual;
- }
-
-
- foreach (var item in trialQuestionList)
- {
- var systemQuestion = systemQuestionList.Where(x => x.Id == (item.ReadingQuestionSystemId ?? default(Guid))).FirstOrDefault();
- if (systemQuestion == null)
- {
- return NeedSynchronize.JudgeNotEqual;
- }
-
-
- if (systemQuestion.TypeValue != item.TypeValue)
- {
- return NeedSynchronize.JudgeNotEqual;
- }
- }
-
-
- return NeedSynchronize.Need;
-
- }
- else
- {
- return NeedSynchronize.NotNeed;
- }
-
- }
- else
- {
- return NeedSynchronize.NotNeed;
- }
- }
-
///
/// 同步标准到项目新(2022-08-10)
///
@@ -644,175 +1039,6 @@ namespace IRaCIS.Application.Services
}
- ///
- /// 获取项目裁判信息
- ///
- ///
- ///
- [HttpPost]
- public async Task GetTrialJudgyInfo(GetTrialJudgyInfoInDto inDto)
- {
- GetTrialJudgyInfoOutDto result = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == inDto.TrialReadingCriterionId).Select(x => new GetTrialJudgyInfoOutDto
- {
- TrialId = x.TrialId,
- IsReadingTaskViewInOrder = x.IsReadingTaskViewInOrder,
- ArbitrationRule = x.ArbitrationRule,
- IsArbitrationReading = x.IsArbitrationReading
-
- }).FirstNotNullAsync();
-
- return result;
- }
-
-
- ///
- /// 新增修改项目标准分页
- ///
- ///
- ///
- [HttpPost]
- public async Task AddOrUpdateReadingCriterionPage(ReadingCriterionPageAddOrEdit addOrEditReadingCriterionPage)
- {
-
- var entity = await _readingCriterionPageRepository.InsertOrUpdateAsync(addOrEditReadingCriterionPage, true);
- return ResponseOutput.Ok(entity.Id.ToString());
-
- }
-
- ///
- /// 删除标准分页
- ///
- ///
- ///
- [HttpDelete("{Id:guid}")]
- public async Task DeleteReadingCriterionPage(Guid Id)
- {
- var success = await _readingCriterionPageRepository.DeleteFromQueryAsync(t => t.Id == Id, true);
- return ResponseOutput.Ok();
- }
-
- /////
- ///// 新增修改系统问题标准
- /////
- /////
- /////
- //[HttpPost]
- //public async Task AddOrUpdateReadingQuestionCriterionSystem(AddOrUpdateReadingQuestionCriterionSystemInDto indto)
- //{
- // var entity = await _readingQuestionCriterionSystemRepository.InsertOrUpdateAsync(indto, true);
- // return ResponseOutput.Ok(entity.Id.ToString());
- //}
-
- ///
- /// 获取系统问题标准
- ///
- ///
- [HttpPost]
- public async Task> GetReadingQuestionCriterionSystemList(ReadingQuestionCriterionSystemViewInDto inDto)
- {
- //await AddSystemQuestionCriterion();
- var query = _readingQuestionCriterionSystemRepository.AsQueryable()
- .WhereIf(!inDto.CriterionName.IsNullOrEmpty(), x => x.CriterionName.Contains(inDto.CriterionName))
- .ProjectTo(_mapper.ConfigurationProvider);
-
- return await query.ToPagedListAsync(inDto.PageIndex, inDto.PageSize, inDto.SortField.IsNullOrEmpty() ? nameof(ReadingQuestionCriterionSystemView.ShowOrder) : inDto.SortField,
- inDto.Asc);
- }
-
-
- ///
- /// 获取系统问题标准下拉
- ///
- ///
- [HttpPost]
- public async Task> GetSystemCriterionSelectList()
- {
- var criterionList = await _readingQuestionCriterionSystemRepository.AsQueryable()
- .OrderBy(x => x.ShowOrder)
- .Select(x => new GetSystemCriterionSelectDto()
- {
- Id = x.Id,
- CriterionName = x.CriterionName,
-
- }).ToListAsync();
- return criterionList;
- }
-
-
-
- /////
- ///// 设置系统标准被禁用
- /////
- /////
- //[NonDynamicMethod]
- //public async Task SetSystemCriterionDisable(Guid dictionaryId, Guid? parentId)
- //{
- // // 判断是否是阅片
- // if (await _dictionaryRepository.AnyAsync(x => x.Id == parentId && x.Code == "ReadingStandard"))
- // {
- // // 判断当前阅片是否在项目里面存在
- // var systemCriterion = await _readingQuestionCriterionSystemRepository.FirstOrDefaultAsync(x => x.CriterionId == dictionaryId);
- // if (systemCriterion != null)
- // {
- // var trialCriterionIds = await _readingQuestionCriterionTrialRepository.Where(x => x.ReadingQuestionCriterionSystemId == systemCriterion.Id).Select(x=>x.ReadingQuestionCriterionSystemId).ToListAsync();
- // await _readingQuestionCriterionTrialRepository.BatchDeleteNoTrackingAsync(x => x.ReadingQuestionCriterionSystemId == systemCriterion.Id);
- // await _readingQuestionTrialRepository.BatchDeleteNoTrackingAsync(x => trialCriterionIds.Contains(x.ReadingQuestionCriterionTrialId));
- // return ResponseOutput.Ok();
- // }
- // }
-
- // return ResponseOutput.Ok();
- //}
-
-
- ///
- /// 设置系统问题标准是否完成配置
- ///
- ///
- ///
- public async Task SetSystemReadingQuestionCriterionIsCompleteConfig(SetSystemReadingQuestionCriterionIsIsCompleteConfig inDto)
- {
-
- if (!inDto.IsCompleteConfig)
- {
- var trialCriterionIds = await _readingQuestionCriterionTrialRepository.Where(x => x.ReadingQuestionCriterionSystemId == inDto.Id).Select(x => x.Id).ToListAsync();
- if (await _readingTaskQuestionAnswer.AnyAsync(x => trialCriterionIds.Contains(x.ReadingQuestionCriterionTrialId)))
- {
- return ResponseOutput.NotOk("此标准在项目里面已被使用,操作失败");
- }
- }
-
- var systemCriterion = await _readingQuestionCriterionSystemRepository.Where(x => x.Id == inDto.Id).AsNoTracking().FirstOrDefaultAsync();
-
- var confirmTime = systemCriterion.ConfirmTime;
-
- if (inDto.IsCompleteConfig)
- {
- confirmTime = DateTime.Now;
- }
-
- await _readingQuestionCriterionSystemRepository.UpdatePartialFromQueryAsync(inDto.Id, x => new ReadingQuestionCriterionSystem()
- {
- IsCompleteConfig = inDto.IsCompleteConfig,
- ConfirmTime = confirmTime,
- });
-
- if (inDto.IsCompleteConfig)
- {
- //await SynchronizeSystemCriterion(inDto.Id);
- }
- else
- {
- await _readingQuestionCriterionTrialRepository.BatchUpdateNoTrackingAsync(x => x.ReadingQuestionCriterionSystemId == inDto.Id, x => new ReadingQuestionCriterionTrial()
- {
- IsCompleteConfig = inDto.IsCompleteConfig
- });
- }
- var result = await _readingQuestionCriterionSystemRepository.SaveChangesAsync();
-
- return ResponseOutput.Ok(result);
- }
-
///
/// 更改项目标准(老)
///
@@ -954,170 +1180,64 @@ namespace IRaCIS.Application.Services
///
- /// 新增修改系统问题标准
- ///
- ///
- ///
- [HttpPost]
- public async Task AddOrUpdateReadingQuestionCriterionSystem(AddOrUpdateReadingQuestionCriterionSystemInDto indto)
- {
- var entity = await _readingQuestionCriterionSystemRepository.InsertOrUpdateAsync(indto, true);
-
- if (indto.Id != null)
- {
- await _readingQuestionCriterionTrialRepository.BatchUpdateNoTrackingAsync(x => x.ReadingQuestionCriterionSystemId == indto.Id, x => new ReadingQuestionCriterionTrial()
- {
- CriterionName = indto.CriterionName,
- CriterionType=indto.CriterionType,
-
- });
- }
- return ResponseOutput.Ok(entity.Id.ToString());
- }
-
-
- /////
- ///// 添加系统问题标准
- /////
- /////
- //[NonDynamicMethod]
- //private async Task AddSystemQuestionCriterion()
- //{
- // var useSystemQuestionCriterionIds = _readingQuestionCriterionSystemRepository.Select(x => x.CriterionId);
- // var dictionaryParentId =await _dictionaryRepository.Where(x => x.Code == "ReadingStandard").Select(x => x.Id).FirstOrDefaultAsync();
- // var criterionList = await _dictionaryRepository.Where(x => x.ParentId == dictionaryParentId && !useSystemQuestionCriterionIds.Contains(x.Id))
- // .Select(x => new CriterionList()
- // {
- // Id = x.Id,
- // Value = x.Value,
- // ShowOrder=x.ShowOrder,
- // }).ToListAsync();
- // List needAddCriterionList = new List();
- // criterionList.ForEach(x =>
- // {
- // needAddCriterionList.Add(new ReadingQuestionCriterionSystem()
- // {
- // CriterionId = x.Id,
- // ShowOrder=x.ShowOrder,
- // CriterionName = x.Value,
- // IsEnable = false,
- // });
- // });
- // await _readingQuestionCriterionSystemRepository.AddRangeAsync(needAddCriterionList);
- // await _readingQuestionCriterionSystemRepository.SaveChangesAsync();
- //}
-
-
-
- ///
- /// 删除系统问题标准
- ///
- ///
- ///
- [HttpDelete("{id:guid}")]
- public async Task DeleteReadingQuestionCriterionSystem(Guid id)
- {
-
-
- if (await _readingQuestionCriterionTrialRepository.AnyAsync(x => x.IsConfirm && x.ReadingQuestionCriterionSystemId == id))
- {
- throw new BusinessValidationFailedException("当前标准被引用过了,不可以删除");
- }
-
- await _readingQuestionCriterionSystemRepository.DeleteFromQueryAsync(t => t.Id == id);
- var success = await _readingQuestionCriterionSystemRepository.SaveChangesAsync();
- return ResponseOutput.Result(success);
- }
-
-
-
- ///
- /// 新增修改系统问题
- ///
- ///
- ///
- [HttpPost]
- public async Task AddOrUpdateReadingQuestionSystem(AddOrUpdateReadingQuestionSystemInDto indto)
- {
- if (indto.Id != null)
- {
- var trialIdList = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionSystemId == indto.Id && x.IsJudgeQuestion && x.JudgeType != JudgeTypeEnum.None)
- .Select(x => x.TrialId).ToListAsync();
-
- //if (trialIdList.Count>0)
- //{
- // var trialNames = await _trialRepository.Where(x => trialIdList.Contains(x.Id)).Select(x => x.ExperimentName).ToListAsync();
- // throw new BusinessValidationFailedException("当前问题在项目"+ string.Join(',', trialNames) + "设置了裁判标准了,修改失败");
- //}
- }
-
- if (await _readingQuestionSystemRepository.AnyAsync(x => x.Id != indto.Id && x.ShowOrder == indto.ShowOrder && x.ReadingQuestionCriterionSystemId == indto.ReadingQuestionCriterionSystemId))
- {
- throw new BusinessValidationFailedException("问题编号重复");
- }
- var entity = await _readingQuestionSystemRepository.InsertOrUpdateAsync(indto, true);
- return ResponseOutput.Ok(entity.Id.ToString());
- }
-
- ///
- /// 获取系统问题
- ///
- ///
- [HttpPost]
- public async Task> GetReadingQuestionSystemList(ReadingQuestionSystemViewInDto inDto)
- {
- var query = _readingQuestionSystemRepository.AsQueryable()
- .Where(x => x.ReadingQuestionCriterionSystemId == inDto.ReadingQuestionCriterionSystemId)
- .WhereIf(!inDto.QuestionName.IsNullOrEmpty(), x => x.QuestionName.Contains(inDto.QuestionName))
- .WhereIf(!inDto.Type.IsNullOrEmpty(), x => x.Type.Contains(inDto.Type))
- .ProjectTo(_mapper.ConfigurationProvider);
- return await query.ToPagedListAsync(inDto.PageIndex, inDto.PageSize, nameof(ReadingQuestionSystemView.ShowOrder),
- inDto.Asc);
- }
-
- ///
- /// 获取系统标准的其他问题
+ /// 验证是否要同步标准
///
///
///
[HttpPost]
- public async Task> GetSystemCriterionOtherQuestion(GetSystemCriterionOtherQuestionInDto inDto)
+ public async Task VerifyeCriterionNeedSynchronize(VerifyeCriterionNeedSynchronizeInDto inDto)
{
- var types = new List()
+ var trialCriterion = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == inDto.TrialReadingCriterionId).FirstOrDefaultAsync();
+ if (trialCriterion == null)
{
- "select","radio"
- };
- var questionList = await _readingQuestionSystemRepository.Where(x => x.ReadingQuestionCriterionSystemId == inDto.ReadingQuestionCriterionSystemId)
- .Where(x => types.Contains(x.Type))
- .WhereIf(inDto.Id != null, x => x.Id != inDto.Id && x.ParentId != inDto.Id)
- .Select(x => new CriterionOtherQuestionOutDto()
- {
- QuestionId = x.Id,
- QuestionName = x.QuestionName,
- TypeValue = x.TypeValue,
- GroupName = x.GroupName,
- }).ToListAsync();
-
- return questionList;
- }
-
- ///
- /// 删除系统问题
- ///
- ///
- ///
- [HttpDelete("{id:guid}")]
- public async Task DeleteReadingQuestionSystem(Guid id)
- {
- if (await _readingQuestionSystemRepository.AnyAsync(x => x.ParentId == id))
- {
- return ResponseOutput.NotOk("此问题存在子问题,请先删除子问题");
+ return NeedSynchronize.NotNeed;
+ }
+ if (trialCriterion.ReadingQuestionCriterionSystemId != null)
+ {
+ var systemCriterion = await _readingQuestionCriterionSystemRepository.Where(x => x.Id == trialCriterion.ReadingQuestionCriterionSystemId).FirstNotNullAsync();
+ if (systemCriterion.ConfirmTime > trialCriterion.SynchronizeTime)
+ {
+
+ var systemQuestionList = await _readingQuestionSystemRepository.Where(x => x.IsJudgeQuestion && x.ReadingQuestionCriterionSystemId == trialCriterion.ReadingQuestionCriterionSystemId).ToListAsync();
+ var trialQuestionList = await _readingQuestionTrialRepository.Where(x => x.IsJudgeQuestion && x.ReadingQuestionCriterionTrialId == trialCriterion.Id).ToListAsync();
+ if (systemQuestionList.Count() != trialQuestionList.Count())
+ {
+ return NeedSynchronize.JudgeNotEqual;
+ }
+
+
+ foreach (var item in trialQuestionList)
+ {
+ var systemQuestion = systemQuestionList.Where(x => x.Id == (item.ReadingQuestionSystemId ?? default(Guid))).FirstOrDefault();
+ if (systemQuestion == null)
+ {
+ return NeedSynchronize.JudgeNotEqual;
+ }
+
+
+ if (systemQuestion.TypeValue != item.TypeValue)
+ {
+ return NeedSynchronize.JudgeNotEqual;
+ }
+ }
+
+
+ return NeedSynchronize.Need;
+
+ }
+ else
+ {
+ return NeedSynchronize.NotNeed;
+ }
+
+ }
+ else
+ {
+ return NeedSynchronize.NotNeed;
}
- await _readingQuestionSystemRepository.DeleteFromQueryAsync(t => t.Id == id);
- var success = await _readingQuestionSystemRepository.SaveChangesAsync();
- return ResponseOutput.Result(success);
}
+
///
/// 添加系统数据到项目里面
///
@@ -1230,18 +1350,77 @@ namespace IRaCIS.Application.Services
}
- ///
- /// 新增修改项目问题标准(项目)
- ///
- ///
- ///
- [HttpPost]
- public async Task AddOrUpdateReadingQuestionCriterionTrial(AddOrUpdateReadingQuestionCriterionTrialInDto indto)
- {
- var entity = await _readingQuestionCriterionTrialRepository.InsertOrUpdateAsync(indto, true);
- return ResponseOutput.Ok(entity.Id.ToString());
- }
+ #region 废弃
+
+ /////
+ ///// 新增修改系统问题标准
+ /////
+ /////
+ /////
+ //[HttpPost]
+ //public async Task AddOrUpdateReadingQuestionCriterionSystem(AddOrUpdateReadingQuestionCriterionSystemInDto indto)
+ //{
+ // var entity = await _readingQuestionCriterionSystemRepository.InsertOrUpdateAsync(indto, true);
+ // return ResponseOutput.Ok(entity.Id.ToString());
+ //}
+
+
+ /////
+ ///// 设置系统标准被禁用
+ /////
+ /////
+ //[NonDynamicMethod]
+ //public async Task SetSystemCriterionDisable(Guid dictionaryId, Guid? parentId)
+ //{
+ // // 判断是否是阅片
+ // if (await _dictionaryRepository.AnyAsync(x => x.Id == parentId && x.Code == "ReadingStandard"))
+ // {
+ // // 判断当前阅片是否在项目里面存在
+ // var systemCriterion = await _readingQuestionCriterionSystemRepository.FirstOrDefaultAsync(x => x.CriterionId == dictionaryId);
+ // if (systemCriterion != null)
+ // {
+ // var trialCriterionIds = await _readingQuestionCriterionTrialRepository.Where(x => x.ReadingQuestionCriterionSystemId == systemCriterion.Id).Select(x=>x.ReadingQuestionCriterionSystemId).ToListAsync();
+ // await _readingQuestionCriterionTrialRepository.BatchDeleteNoTrackingAsync(x => x.ReadingQuestionCriterionSystemId == systemCriterion.Id);
+ // await _readingQuestionTrialRepository.BatchDeleteNoTrackingAsync(x => trialCriterionIds.Contains(x.ReadingQuestionCriterionTrialId));
+ // return ResponseOutput.Ok();
+ // }
+ // }
+
+ // return ResponseOutput.Ok();
+ //}
+
+ /////
+ ///// 添加系统问题标准
+ /////
+ /////
+ //[NonDynamicMethod]
+ //private async Task AddSystemQuestionCriterion()
+ //{
+ // var useSystemQuestionCriterionIds = _readingQuestionCriterionSystemRepository.Select(x => x.CriterionId);
+ // var dictionaryParentId =await _dictionaryRepository.Where(x => x.Code == "ReadingStandard").Select(x => x.Id).FirstOrDefaultAsync();
+ // var criterionList = await _dictionaryRepository.Where(x => x.ParentId == dictionaryParentId && !useSystemQuestionCriterionIds.Contains(x.Id))
+ // .Select(x => new CriterionList()
+ // {
+ // Id = x.Id,
+ // Value = x.Value,
+ // ShowOrder=x.ShowOrder,
+ // }).ToListAsync();
+ // List needAddCriterionList = new List();
+ // criterionList.ForEach(x =>
+ // {
+ // needAddCriterionList.Add(new ReadingQuestionCriterionSystem()
+ // {
+ // CriterionId = x.Id,
+ // ShowOrder=x.ShowOrder,
+ // CriterionName = x.Value,
+ // IsEnable = false,
+ // });
+ // });
+ // await _readingQuestionCriterionSystemRepository.AddRangeAsync(needAddCriterionList);
+ // await _readingQuestionCriterionSystemRepository.SaveChangesAsync();
+ //}
+
/////
///// 获取预览问题信息
@@ -1294,174 +1473,8 @@ namespace IRaCIS.Application.Services
// return ResponseOutput.Ok(result);
//}
- ///
- /// 设置项目标准是否完成配置
- ///
- ///
- ///
- public async Task SetTrialReadingQuestionCriterionIsIsCompleteConfig(SetSystemReadingQuestionCriterionIsIsCompleteConfig inDto)
- {
- await _readingQuestionCriterionTrialRepository.UpdatePartialFromQueryAsync(inDto.Id, x => new ReadingQuestionCriterionTrial()
- {
- IsCompleteConfig = inDto.IsCompleteConfig
- });
-
- var result = await _readingQuestionCriterionTrialRepository.SaveChangesAsync();
-
- return ResponseOutput.Ok(result);
- }
-
- ///
- /// 获取项目问题标准(项目)
- ///
- ///
- [HttpPost]
- public async Task> GetReadingQuestionCriterionTrialList(ReadingQuestionCriterionTrialViewInDto inDto)
- {
- await AddSystemDataToTrila(inDto.TrialId);
- var query = _readingQuestionCriterionTrialRepository.AsQueryable()
- .Where(x => x.TrialId == inDto.TrialId)
- .Where(x=>(x.ReadingQuestionCriterionSystemId!=null&&x.IsEnable)||x.ReadingQuestionCriterionSystemId==null)
- .WhereIf(!inDto.CriterionName.IsNullOrEmpty(), x => x.CriterionName.Contains(inDto.CriterionName))
-
- .ProjectTo(_mapper.ConfigurationProvider);
- return await query.ToPagedListAsync(inDto.PageIndex, inDto.PageSize, inDto.SortField.IsNullOrEmpty() ? nameof(ReadingQuestionCriterionTrialView.ShowOrder) : inDto.SortField,
- inDto.Asc);
- }
-
- ///
- /// 删除项目问题标准(项目)
- ///
- ///
- ///
- [HttpDelete("{id:guid}")]
- public async Task DeleteReadingQuestionCriterionTrial(Guid id)
- {
- await _readingQuestionCriterionTrialRepository.DeleteFromQueryAsync(t => t.Id == id);
- var success = await _readingQuestionCriterionTrialRepository.SaveChangesAsync();
- return ResponseOutput.Result(success);
- }
-
- ///
- /// 新增修改项目问题(项目)
- ///
- ///
- ///
- [HttpPost]
- public async Task AddOrUpdateReadingQuestionTrial(AddOrUpdateReadingQuestionTrialInDto indto)
- {
- if (indto.Id != null)
- {
- if (await _readingQuestionTrialRepository.AnyAsync(x => x.Id == indto.Id && x.IsJudgeQuestion && x.JudgeType != JudgeTypeEnum.None))
- {
- throw new BusinessValidationFailedException("当前问题已经设置了裁判标准了,修改失败");
- }
- }
-
- if (indto.ParentId == indto.RelevanceId && indto.ParentId != null && indto.ParentTriggerValue != indto.RelevanceValue)
- {
- throw new BusinessValidationFailedException("显示依赖父问题和必填依赖的问题为同一个,但答案互斥,操作失败");
- }
+ #endregion
- if (await _readingQuestionTrialRepository.AnyAsync(x => x.Id != indto.Id && x.ShowOrder == indto.ShowOrder && x.TrialId == indto.TrialId && x.ReadingQuestionCriterionTrialId == indto.ReadingQuestionCriterionTrialId && x.ReadingCriterionPageId == indto.ReadingCriterionPageId))
- {
- throw new BusinessValidationFailedException("问题编号重复");
- }
- var entity = await _readingQuestionTrialRepository.InsertOrUpdateAsync(indto, true);
- return ResponseOutput.Ok(entity.Id.ToString());
- }
-
- ///
- /// 获取项目问题(项目)
- ///
- ///
- [HttpPost]
- public async Task> GetReadingQuestionTrialList(ReadingQuestionTrialViewInDto inDto)
- {
- var query = _readingQuestionTrialRepository.AsQueryable()
- .Where(x => x.ReadingQuestionCriterionTrialId == inDto.ReadingQuestionCriterionTrialId)
- .WhereIf(!inDto.QuestionName.IsNullOrEmpty(), x => x.QuestionName.Contains(inDto.QuestionName))
- .WhereIf(!inDto.Type.IsNullOrEmpty(), x => x.Type.Contains(inDto.Type))
- .Where(x => x.ReadingCriterionPageId == inDto.ReadingCriterionPageId)
- .ProjectTo(_mapper.ConfigurationProvider).OrderBy(x => x.ShowOrder);
- return await query.ToListAsync();
- }
-
- ///
- /// 获取项目标准的其他问题(项目)
- ///
- ///
- ///
- [HttpPost]
- public async Task> GetTrialCriterionOtherQuestion(GetTrialCriterionOtherQuestionInDto inDto)
- {
- var types = new List()
- {
- "select","radio"
- };
- var questionList = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == inDto.ReadingQuestionCriterionTrialId)
- .Where(x => types.Contains(x.Type))
- .WhereIf(inDto.Id != null, x => x.Id != inDto.Id && x.ParentId != inDto.Id)
- .Where(x => x.ReadingCriterionPageId == inDto.ReadingCriterionPageId)
-
- .Select(x => new CriterionOtherQuestionOutDto()
- {
- QuestionId = x.Id,
- QuestionName = x.QuestionName,
- TypeValue = x.TypeValue,
- GroupName = x.GroupName,
- }).ToListAsync();
-
- return questionList;
- }
-
- ///
- /// 删除项目问题(项目)
- ///
- ///
- ///
- [HttpDelete("{id:guid}")]
- public async Task DeleteReadingQuestionTrial(Guid id)
- {
- if (await _readingQuestionTrialRepository.AnyAsync(x => x.ParentId == id))
- {
- return ResponseOutput.NotOk("此问题存在子问题,请先删除子问题");
- }
- await _readingQuestionTrialRepository.DeleteFromQueryAsync(t => t.Id == id);
- var success = await _readingQuestionTrialRepository.SaveChangesAsync();
- return ResponseOutput.Result(success);
- }
-
- ///
- /// 获取项目问题分组
- ///
- ///
- ///
- [HttpPost]
- public async Task> GetTrialGroupNameList(GetTrialGroupNameListInDto inDto)
- {
- var result = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == inDto.CriterionId && x.Type == ReadingQestionType.Group)
- .Where(x => x.ReadingCriterionPageId == inDto.ReadingCriterionPageId)
- .Select(x => x.GroupName).ToListAsync();
-
- return result;
-
- }
-
-
- ///
- /// 获取系统问题分组
- ///
- ///
- ///
- [HttpPost]
- public async Task> GetSystemGroupNameList(GetTrialGroupNameListInDto inDto)
- {
- var result = await _readingQuestionSystemRepository.Where(x => x.ReadingQuestionCriterionSystemId == inDto.CriterionId && x.Type == ReadingQestionType.Group)
- .Select(x => x.GroupName).ToListAsync();
- return result;
-
- }
}
}
\ No newline at end of file