diff --git a/IRaCIS.Core.Application/Service/Inspection/DTO/InspectionModel.cs b/IRaCIS.Core.Application/Service/Inspection/DTO/InspectionModel.cs index 16c2630fa..01c14b8df 100644 --- a/IRaCIS.Core.Application/Service/Inspection/DTO/InspectionModel.cs +++ b/IRaCIS.Core.Application/Service/Inspection/DTO/InspectionModel.cs @@ -349,6 +349,7 @@ namespace IRaCIS.Core.Application.Service.Inspection.DTO public class GetDataInspectionOutDto : DataInspection { + public bool IsShow { get; set; } public string TrialReadingCriterionName { get; set; } public string BlindName { get; set; } @@ -420,7 +421,42 @@ namespace IRaCIS.Core.Application.Service.Inspection.DTO public bool isAbandon { get; set; } } + public class GetTrialShowInspectionOutDto + { + public Guid FrontAuditConfigId { get; set; } + public Guid? ParentId { get; set; } + + public int Sort { get; set; } + + public string Description { get; set; } + + public string DescriptionCN { get; set; } + + public bool IsShow { get; set; } + + public List Children { get; set; } + } + + + public class SetTrialShowInspection + { + public Guid TrialId { get; set; } + + public List TrialShowInspectionList { get; set; } + } + + public class TrialShowInspection + { + public Guid FrontAuditConfigId { get; set; } + + public bool IsShow { get; set; } + } + + public class GetTrialShowInspectionInDto + { + public Guid TrialId { get; set; } + } public class GetDataInspectionDto : PageInput { diff --git a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs index 2b9c79c7a..88d0028b6 100644 --- a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs +++ b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs @@ -1,8 +1,10 @@ using IRaCIS.Core.Application.Contracts; using IRaCIS.Core.Application.Service.Inspection.DTO; using IRaCIS.Core.Application.Service.Inspection.Interface; +using IRaCIS.Core.Application.ViewModel; using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Infrastructure; +using Microsoft.AspNetCore.Mvc; using Panda.DynamicWebApi.Attributes; @@ -13,6 +15,7 @@ namespace IRaCIS.Core.Application.Service.Inspection IRepository _dictionaryRepository, IRepository _trialSignRepository, IRepository _identityUserRepository, + IRepository _trialAuditShowRepository, IRepository _userRoleRepository, IRepository _trialSiteRepository, IRepository _trialRepository, @@ -23,7 +26,63 @@ namespace IRaCIS.Core.Application.Service.Inspection IRepository _frontAuditConfigRepository, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, IInspectionService { + /// + /// 设置项目稽查配置 + /// + /// + /// + [HttpPost] + public async Task SetTrialShowInspection(SetTrialShowInspection inDto) + { + await _trialAuditShowRepository.BatchDeleteNoTrackingAsync(x => x.TrialId == inDto.TrialId); + List trialAuditShows = inDto.TrialShowInspectionList.Select(x => new TrialAuditShow() + { + FrontAuditConfigId = x.FrontAuditConfigId, + TrialId = inDto.TrialId, + IsShow = x.IsShow, + + }).ToList(); + + await _trialAuditShowRepository.AddRangeAsync(trialAuditShows); + + await _trialAuditShowRepository.SaveChangesAsync(); + + return ResponseOutput.Ok(); + } + + /// + /// 获取项目稽查显示信息 + /// + /// + /// + [HttpPost] + public async Task> GetTrialShowInspection(GetTrialShowInspectionInDto inDto) + { + var query = from data in _frontAuditConfigRepository.Where(x => x.IsEnable && x.ConfigType == "M") + join trialdata in _trialAuditShowRepository.Where(x => x.TrialId == inDto.TrialId) on data.Id equals trialdata.FrontAuditConfigId into trialdatatemp + from lefttrialdata in trialdatatemp.DefaultIfEmpty() + select new GetTrialShowInspectionOutDto() + { + Description = data.Description, + DescriptionCN = data.DescriptionCN, + FrontAuditConfigId = data.Id, + ParentId= data.ParentId, + Sort=data.Sort, + IsShow = lefttrialdata != null ? lefttrialdata.IsShow : data.IsDefaultChoice + }; + var frontAuditList =await query.ToListAsync(); + + var result= frontAuditList.Where(x=>x.ParentId==null).OrderBy(x=>x.Sort).ToList(); + result.ForEach(x => + { + + x.Children = frontAuditList.Where(y => y.ParentId == x.FrontAuditConfigId).OrderBy(x => x.Sort).ToList(); + }); + + return result; + + } public async Task> GetInspectionList(GetDataInspectionDto inQuery) @@ -61,26 +120,6 @@ namespace IRaCIS.Core.Application.Service.Inspection join visttask in _visitTaskRepository.Where().IgnoreQueryFilters() on data.VisitTaskId equals visttask.Id into visttasktemp from leftvisttask in visttasktemp.DefaultIfEmpty() - - //join trialCriterion in _repository.GetQueryable().IgnoreQueryFilters() on data.TrialReadingCriterionId equals trialCriterion.Id into criterion - //from leftCriterion in criterion.DefaultIfEmpty() - - //join moduleTyped in _dictionaryRepository.Where().Where(x => x.Code == "ModuleType") on 1 equals 1 - //join moduleTypec in _dictionaryRepository.Where() on new { ParentId = moduleTyped.Id, ModuleType = data.ModuleType } equals new { ParentId = moduleTypec.ParentId.Value, ModuleType = moduleTypec.Value } into moduleTypectemp - - //join childrenTyped in _dictionaryRepository.Where().Where(x => x.Code == "ChildrenType") on 1 equals 1 - //join childrenTypec in _dictionaryRepository.Where() on new { ParentId = childrenTyped.Id, ModuleType = data.ChildrenType } equals new { ParentId = childrenTypec.ParentId.Value, ModuleType = childrenTypec.Value } into childrenTypectemp - //from leftchildrenTypec in childrenTypectemp.DefaultIfEmpty() - - //join ObjectTyped in _dictionaryRepository.Where().Where(x => x.Code == "ObjectType") on 1 equals 1 - //join ObjectTypec in _dictionaryRepository.Where() on new { ParentId = ObjectTyped.Id, ModuleType = data.ObjectType } equals new { ParentId = ObjectTypec.ParentId.Value, ModuleType = ObjectTypec.Value } into objectTypetemp - //from leftObjectType in objectTypetemp.DefaultIfEmpty() - - //join OptTyped in _dictionaryRepository.Where().Where(x => x.Code == "OptType") on 1 equals 1 - //join OptTypec in _dictionaryRepository.Where() on new { ParentId = OptTyped.Id, ModuleType = data.OptType } equals new { ParentId = OptTypec.ParentId.Value, ModuleType = OptTypec.Value } into optTypetemp - //from leftOptType in optTypetemp.DefaultIfEmpty() - - join trialSign in _trialSignRepository.Where().IgnoreQueryFilters() on data.SignId equals trialSign.Id into trialSigntemp from lefttrialSign in trialSigntemp.DefaultIfEmpty() join leftfrontAuditConfig in _frontAuditConfigRepository.Where().Where(x => x.ConfigType == "M" && x.Identification != null && x.IsEnable == true) on @@ -91,9 +130,11 @@ namespace IRaCIS.Core.Application.Service.Inspection from leftmoduleTypec in moduleTypectemp.DefaultIfEmpty() join OptTypec in _dictionaryRepository.Where() on new { ModuleType = leftfrontAuditConfig.OptTypeId!.Value } equals new { ModuleType = OptTypec.Id } into optTypetemp from leftOptType in optTypetemp.DefaultIfEmpty() - + join trialShow in _trialAuditShowRepository.Where(x => x.TrialId == inQuery.TrialId) on leftfrontAuditConfig.Id equals trialShow.FrontAuditConfigId into trialShowtemp + from lefttrialShow in trialShowtemp.DefaultIfEmpty() select new GetDataInspectionOutDto() { + IsShow = lefttrialShow != null ? lefttrialShow.IsShow : leftfrontAuditConfig.IsDefaultChoice, CreateTime = data.CreateTime, CreateUserId = data.CreateUserId, ModuleTypeId = leftmoduleTypec.Id, @@ -167,6 +208,7 @@ namespace IRaCIS.Core.Application.Service.Inspection query = query.WhereIf(inQuery.TrialSiteId != null, x => x.TrialSiteId == inQuery.TrialSiteId) //.Where(x => (x.TrialId == dto.TrialId) || (x.TrialId == null && x.CreateTime >= trialData.CreateTime && x.CreateTime <= trialData.TrialFinishTime)) .Where(x => x.TrialId == inQuery.TrialId) + .Where(x => x.IsShow) #region 废弃 // .WhereIf(dto.BatchId != null && dto.ObjectRelationParentId == null && dto.GeneralId == null, x => x.BatchId == dto.BatchId)