diff --git a/IRaCIS.Core.API/Controllers/InspectionController.cs b/IRaCIS.Core.API/Controllers/InspectionController.cs index 71b149ed0..96f9da616 100644 --- a/IRaCIS.Core.API/Controllers/InspectionController.cs +++ b/IRaCIS.Core.API/Controllers/InspectionController.cs @@ -80,6 +80,10 @@ namespace IRaCIS.Core.API.Controllers { //opt.AuditInfo.SubjectCode = opt.OptCommand.Code; var fun = await _subjectVisitService.AddOrUpdateSV(opt.OptCommand); + if (!fun.IsSuccess) + { + return ResponseOutput.NotOk(fun.ErrorMessage); + } opt.AuditInfo.SubjectId = Guid.Parse(fun.Data); var statusdata = new { @@ -150,11 +154,13 @@ namespace IRaCIS.Core.API.Controllers public async Task AddOrUpdateSubject(InsSubjectCommand opt) { + opt.AuditInfo.SubjectCode = opt.OptCommand.Code; var fun = await _subjectService.AddOrUpdateSubject(opt.OptCommand); opt.AuditInfo.SubjectId = Guid.Parse(fun.Data); - var statusdata = new { - Status = 1, + var statusdata = new + { + Status = "OnVisit", //OutEnrollmentTime = DateTime.Now.ToString("yyyy-MM-dd"), //VisitOverTime = DateTime.Now.ToString("yyyy-MM-dd"), Reason = string.Empty, diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index bb7990b91..c4d65f6dd 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -239,6 +239,12 @@ 初始化状态对象 + + + 处理枚举 + + + 设置项目以及名称 @@ -246,6 +252,59 @@ + + + 提取json字符串对象 + 例如输入:{"1":1,"a":"aa","aa":"{\"2\":2,\"bb\":\"{\\\"3\\\":3,\\\"cc\\\":\\\"ccc\\\"}\"}"} + 例如输出:{"1":1,"a":"aa","aa":{"2":2,"bb":{"3":3,"cc":"ccc"}}} + + + + + 提取json对象 + 例如输入:{"1":1,"a":"aa","aa":"{\"2\":2,\"bb\":\"{\\\"3\\\":3,\\\"cc\\\":\\\"ccc\\\"}\"}"} + 例如输出:{"1":1,"a":"aa","aa":{"2":2,"bb":{"3":3,"cc":"ccc"}}} + + + + + 提取json字符串数组 + 例如输入:["5","6","[\"3\",\"4\",\"[\\\"1\\\",\\\"2\\\"]\"]"] + 例如输出:["5","6",["3","4",["1","2"]]] + + + + + 提取json数组 + 例如输入:["5","6","[\"3\",\"4\",\"[\\\"1\\\",\\\"2\\\"]\"]"] + 例如输出:["5","6",["3","4",["1","2"]]] + + + + + + + 提取json字符串(支持json字符串的对象、数组、字符串) + 例如输入:["5","6","[\"3\",\"4\",\"[\\\"1\\\",\\\"2\\\"]\"]","{\"1\":2,\"a\":\"ab\"}"] + 例如输出:["5","6",["3","4",["1","2"]],{"1":2,"a":"ab"}] + + + + + + + 提取json(支持json对象、数组、字符串) + 例如输入:["5","6","[\"3\",\"4\",\"[\\\"1\\\",\\\"2\\\"]\"]","{\"1\":2,\"a\":\"ab\"}"] + 例如输出:["5","6",["3","4",["1","2"]],{"1":2,"a":"ab"}] + + + + + + + 是否为json(开头是'{','['的) + + 项目外部人员 录入流程相关 diff --git a/IRaCIS.Core.Application/Service/Common/DTO/FrontAuditConfigViewModel.cs b/IRaCIS.Core.Application/Service/Common/DTO/FrontAuditConfigViewModel.cs index 8cd1a5f81..c8ac2b641 100644 --- a/IRaCIS.Core.Application/Service/Common/DTO/FrontAuditConfigViewModel.cs +++ b/IRaCIS.Core.Application/Service/Common/DTO/FrontAuditConfigViewModel.cs @@ -7,107 +7,122 @@ using System; using IRaCIS.Core.Domain.Share; using System.Collections.Generic; namespace IRaCIS.Core.Application.ViewModel -{ - /// FrontAuditConfigView 列表视图模型 - public class FrontAuditConfigView - { - public Guid Id { get; set; } - public string Value { get; set; } = string.Empty; - public string ValueCN { get; set; } = string.Empty; - public string Description { get; set; } = string.Empty; - public DateTime CreateTime { get; set; } - public Guid CreateUserId { get; set; } - public DateTime UpdateTime { get; set; } - public Guid UpdateUserId { get; set; } - public string Code { get; set; } = string.Empty; - public Guid? ParentId { get; set; } - public bool? IsEnable { get; set; } - public bool? IsConfig { get; set; } - public string ModuleTypeId { get; set; } = string.Empty; - public string OptTypeId { get; set; } = string.Empty; - public string ChildrenTypeId { get; set; } = string.Empty; +{ + /// FrontAuditConfigView 列表视图模型 + public class FrontAuditConfigView + { + public Guid Id { get; set; } + public string Value { get; set; } = string.Empty; + public string ValueCN { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public DateTime CreateTime { get; set; } + public Guid CreateUserId { get; set; } + public DateTime UpdateTime { get; set; } + public Guid UpdateUserId { get; set; } + public string Code { get; set; } = string.Empty; + public Guid? ParentId { get; set; } + public bool? IsEnable { get; set; } + public bool? IsConfig { get; set; } + public string ModuleTypeId { get; set; } = string.Empty; + public string OptTypeId { get; set; } = string.Empty; + public string ChildrenTypeId { get; set; } = string.Empty; - public string ConfigType { get; set; } = string.Empty; + public string ConfigType { get; set; } = string.Empty; - public bool? IsShowParent { get; set; } - - public string ChildrenTypeValue { get; set; } = string.Empty; - public string ChildrenTypeValueCN { get; set; } = string.Empty; + public bool? IsShowParent { get; set; } - public string ModuleTypeValue { get; set; } = string.Empty; - public string ModuleTypeValueCN { get; set; } = string.Empty; + public string ChildrenTypeValue { get; set; } = string.Empty; + public string ChildrenTypeValueCN { get; set; } = string.Empty; - public string OptTypeValue { get; set; } = string.Empty; - public string OptTypeValueCN { get; set; } = string.Empty; + public string ModuleTypeValue { get; set; } = string.Empty; + public string ModuleTypeValueCN { get; set; } = string.Empty; - public int? Sort { get; set; } + public string OptTypeValue { get; set; } = string.Empty; + public string OptTypeValueCN { get; set; } = string.Empty; - public string? EnumList { get; set; } + public int? Sort { get; set; } - public string? DictionaryKey { get; set; } + public string? EnumList { get; set; } - public string? EnumType { get; set; } + public string? DictionaryKey { get; set; } + + public string? EnumType { get; set; } + + public string ObjectTypeId { get; set; } = string.Empty; + + public bool? IsShowByTrialConfig { get; set; } + + public string ByTrialConfig { get; set; } = string.Empty; - } - ///FrontAuditConfigQuery 列表查询参数模型 - public class FrontAuditConfigQuery - { - /// Value - public string Value { get; set; }=string.Empty; + } - /// ValueCN - public string ValueCN { get; set; } = string.Empty; + ///FrontAuditConfigQuery 列表查询参数模型 + public class FrontAuditConfigQuery + { + /// Value + public string Value { get; set; } = string.Empty; - /// Description - public string Description { get; set; } = string.Empty; + /// ValueCN + public string ValueCN { get; set; } = string.Empty; - /// Code - public string Code { get; set; } = string.Empty; + /// Description + public string Description { get; set; } = string.Empty; - /// OptTypeId - public string OptTypeId { get; set; } = string.Empty; + /// Code + public string Code { get; set; } = string.Empty; - /// ChildrenTypeId - public string ChildrenTypeId { get; set; } = string.Empty; + /// OptTypeId + public string OptTypeId { get; set; } = string.Empty; - } + /// ChildrenTypeId + public string ChildrenTypeId { get; set; } = string.Empty; - /// FrontAuditConfigAddOrEdit 列表查询参数模型 - public class FrontAuditConfigAddOrEdit - { - public Guid? Id { get; set; } - public string Value { get; set; } = string.Empty; - public string ValueCN { get; set; } = string.Empty; - public string Description { get; set; } = string.Empty; - public DateTime CreateTime { get; set; } - public Guid CreateUserId { get; set; } - public DateTime UpdateTime { get; set; } - public Guid UpdateUserId { get; set; } - public string Code { get; set; } = string.Empty; - public Guid? ParentId { get; set; } - public bool IsEnable { get; set; } - public bool IsConfig { get; set; } - public string ModuleTypeId { get; set; } = string.Empty; - public string OptTypeId { get; set; } = string.Empty; - public string ChildrenTypeId { get; set; } = string.Empty; + } - public string ConfigType { get; set; } = string.Empty; + /// FrontAuditConfigAddOrEdit 列表查询参数模型 + public class FrontAuditConfigAddOrEdit + { + public Guid? Id { get; set; } + public string Value { get; set; } = string.Empty; + public string ValueCN { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public DateTime CreateTime { get; set; } + public Guid CreateUserId { get; set; } + public DateTime UpdateTime { get; set; } + public Guid UpdateUserId { get; set; } + public string Code { get; set; } = string.Empty; + public Guid? ParentId { get; set; } + public bool IsEnable { get; set; } + public bool IsConfig { get; set; } + public string ModuleTypeId { get; set; } = string.Empty; + public string OptTypeId { get; set; } = string.Empty; + public string ChildrenTypeId { get; set; } = string.Empty; - public bool? IsShowParent { get; set; } + public string ConfigType { get; set; } = string.Empty; - public int? Sort { get; set; } + public bool? IsShowParent { get; set; } - public string EnumList { get; set; } = string.Empty; + public int? Sort { get; set; } - public string DictionaryKey { get; set; } = string.Empty; + public string EnumList { get; set; } = string.Empty; - public string EnumType { get; set; } = string.Empty; + public string DictionaryKey { get; set; } = string.Empty; + + public string EnumType { get; set; } = string.Empty; + + public string ObjectTypeId { get; set; } = string.Empty; + + public bool? IsShowByTrialConfig { get; set; } + + public string ByTrialConfig { get; set; } = string.Empty; + + + + } - } - } diff --git a/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs b/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs index a582de3eb..f93714b4a 100644 --- a/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs +++ b/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs @@ -73,6 +73,9 @@ namespace IRaCIS.Core.Application.Service EnumList=data.EnumList, DictionaryKey=data.DictionaryKey, EnumType=data.EnumType, + ObjectTypeId=data.ObjectTypeId, + IsShowByTrialConfig=data.IsShowByTrialConfig, + ByTrialConfig=data.ByTrialConfig, }; query = query diff --git a/IRaCIS.Core.Application/Service/Inspection/DTO/InspectionModel.cs b/IRaCIS.Core.Application/Service/Inspection/DTO/InspectionModel.cs index 400cdf4f6..d6e4b301f 100644 --- a/IRaCIS.Core.Application/Service/Inspection/DTO/InspectionModel.cs +++ b/IRaCIS.Core.Application/Service/Inspection/DTO/InspectionModel.cs @@ -76,6 +76,14 @@ namespace IRaCIS.Core.Application.Service.Inspection.DTO /// public string ResearchProgramNo { get; set; } = string.Empty; + public List EnumList { get; set; }=new List { }; + + + /// + /// 对象名称 + /// + public string ObjectType { get; set; } = string.Empty; + ////需要单独处理 //public string IP { get; set; } @@ -85,6 +93,15 @@ namespace IRaCIS.Core.Application.Service.Inspection.DTO } + public class EnumList + { + public string Key { get; set; } = string.Empty; + + public string Code { get; set; } = string.Empty; + + public string Type { get; set; } = string.Empty; + } + public interface IInspectionDTO { public DataInspectionAddDTO AuditInfo { get; set; } @@ -245,6 +262,12 @@ namespace IRaCIS.Core.Application.Service.Inspection.DTO /// 是否有签名 /// public bool? IsSign { get; set; } + + /// + /// 对象名称 + /// + + public string ObjectType { get; set; } = string.Empty; } public class InspectionBase diff --git a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs index 6440c73b5..0979f0a8a 100644 --- a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs +++ b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs @@ -3,7 +3,9 @@ using IRaCIS.Core.Application.Contracts; using IRaCIS.Core.Application.Service.Inspection.DTO; using IRaCIS.Core.Application.Service.Inspection.Interface; using IRaCIS.Core.Domain.Share; +using IRaCIS.Core.Infrastructure; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using Panda.DynamicWebApi.Attributes; using System; using System.Collections.Generic; @@ -39,6 +41,14 @@ namespace IRaCIS.Core.Application.Service.Inspection join user in _repository.GetQueryable() on data.CreateUserId equals user.Id into usertemp from leftuser in usertemp.DefaultIfEmpty() + + join moduleTyped in _repository.GetQueryable().Where(x => x.Code == "ModuleType") on 1 equals 1 + join moduleTypec in _repository.GetQueryable() on new { ParentId = moduleTyped.Id, ModuleType=data.ModuleType } equals new { ParentId=moduleTypec.ParentId.Value, ModuleType= moduleTypec.Value } into moduleTypectemp + from leftmoduleTypec in moduleTypectemp.DefaultIfEmpty() + + + + select new GetDataInspectionOutDto() { CreateTime = data.CreateTime, @@ -75,10 +85,12 @@ namespace IRaCIS.Core.Application.Service.Inspection TrialName=data.TrialName, SiteCode=data.SiteCode, ResearchProgramNo=data.ResearchProgramNo, + ObjectType=data.ObjectType, }; query = query.WhereIf(!dto.BlindName.IsNullOrEmpty(), x => x.BlindName == dto.BlindName) .WhereIf(dto.IsSign != null, x => x.IsSign == dto.IsSign) + .WhereIf(!dto.ObjectType.IsNullOrEmpty(), x => x.ObjectType == dto.ObjectType) .WhereIf(!dto.ChildrenType.IsNullOrEmpty(), x => x.ChildrenType == dto.ChildrenType) .WhereIf(!dto.ModuleType.IsNullOrEmpty(), x => x.ModuleType == dto.ModuleType) .WhereIf(!dto.OptType.IsNullOrEmpty(), x => x.OptType == dto.OptType) @@ -244,9 +256,10 @@ namespace IRaCIS.Core.Application.Service.Inspection /// public async Task AddInspectionRecordAsync(DataInspectionAddDTO addDto, Guid? signId, object? Statusdata = null) { + await SetEnum(addDto); var add = _mapper.Map(addDto); Guid? parentId = null; - parentId = (await _repository.GetQueryable().Where(x => x.TrialId == add.TrialId && x.SubjectVisitId == add.SubjectVisitId && x.SubjectId == add.SubjectId && x.SiteId == add.SiteId&&x.ModuleType==add.ModuleType&&x.ChildrenType==add.ChildrenType).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync())?.Id; + parentId = (await _repository.GetQueryable().Where(x => x.TrialId == add.TrialId && x.SubjectVisitId == add.SubjectVisitId && x.SubjectId == add.SubjectId && x.SiteId == add.SiteId&&x.ModuleType==add.ModuleType&&x.ChildrenType==add.ChildrenType && x.ObjectType==add.ObjectType).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync())?.Id; add.ParentId = parentId; add.CreateTime = DateTime.Now; add.CreateUserId = _userInfo.Id; @@ -272,6 +285,83 @@ namespace IRaCIS.Core.Application.Service.Inspection } + /// + /// 处理枚举 + /// + /// + + public async Task SetEnum(DataInspectionAddDTO Data) + { + #region 枚举 + try + { + var JsonData = JsonConvert.DeserializeObject>(Data.JsonDetail); + foreach (var item in Data.EnumList) + { + var value = JsonData[item.Key]; + if (value.GetType() == typeof(JArray)) + { + JArray arrays = (JArray)value; + if (item.Type.ToLower() == "id".ToLower()) + { + List guids = new List(); + arrays.ForEach(x => + { + guids.Add(Guid.Parse(x.ToString())); + }); + JsonData[item.Key] = string.Join(',', await _repository.GetQueryable().Where(x => guids.Contains(x.Id)).Select(x => x.Value).ToListAsync()); + } + else + { + List guids =new List(); + arrays.ForEach(x => + { + guids.Add(x.ToString()); + }); + JsonData[item.Key] = string.Join(',', await + _repository.GetQueryable().Where(x => x.Code == item.Code).GroupJoin( + _repository.GetQueryable().Where(x=>guids.Contains(x.Code)), a => a.Id, b => b.ParentId, (a, b) => new + { + parent = b + }).SelectMany(a => a.parent, (m, n) => new + { + value = n.Value + }).Select(x => x.value).ToListAsync() + ); + } + } + else + { + if (item.Type.ToLower() == "id".ToLower()) + { + Guid guid = Guid.Parse(value.ToString()); + JsonData[item.Key] = await _repository.GetQueryable().Where(x => guid == x.Id).Select(x => x.Value).FirstOrDefaultAsync(); + } + else + { + JsonData[item.Key] = await _repository.GetQueryable().Where(x=>x.Code==item.Code).Join(_repository.GetQueryable().Where(x=>x.Code== value.ToString()), a => a.Id, b => b.ParentId, (a, b) => new + { + value=b.Value + }).Select(x=>x.value).FirstOrDefaultAsync(); + + } + } + } + + Data.JsonDetail = JsonConvert.SerializeObject(JsonData); + } + catch (Exception) + { + + throw new BusinessValidationFailedException("Json 对象枚举异常"); + } + + + + #endregion + } + + /// /// 设置项目以及名称 /// @@ -349,6 +439,10 @@ namespace IRaCIS.Core.Application.Service.Inspection } #endregion + + } + + } } diff --git a/IRaCIS.Core.Application/Service/Inspection/Interface/IInspectionService.cs b/IRaCIS.Core.Application/Service/Inspection/Interface/IInspectionService.cs index f939563b6..fd2acd785 100644 --- a/IRaCIS.Core.Application/Service/Inspection/Interface/IInspectionService.cs +++ b/IRaCIS.Core.Application/Service/Inspection/Interface/IInspectionService.cs @@ -22,5 +22,7 @@ namespace IRaCIS.Core.Application.Service.Inspection.Interface Task Enforcement(dynamic OptCommand, DataInspectionAddDTO AuditInfo, SignDTO SignInfo, dynamic fun, IResponseOutput? response = null, object? Statusdata = null); Task AddInspectionRecordAsync(DataInspectionAddDTO addDto, Guid? signId, object? Statusdata = null); + + Task SetEnum(DataInspectionAddDTO Data); } } diff --git a/IRaCIS.Core.Domain.Share/IRaCIS.Core.Domain.Share.csproj b/IRaCIS.Core.Domain.Share/IRaCIS.Core.Domain.Share.csproj index d9335b8b4..78fa3b6cf 100644 --- a/IRaCIS.Core.Domain.Share/IRaCIS.Core.Domain.Share.csproj +++ b/IRaCIS.Core.Domain.Share/IRaCIS.Core.Domain.Share.csproj @@ -12,6 +12,7 @@ + diff --git a/IRaCIS.Core.Domain/Common/FrontAuditConfig.cs b/IRaCIS.Core.Domain/Common/FrontAuditConfig.cs index dfcc6c5d6..865932753 100644 --- a/IRaCIS.Core.Domain/Common/FrontAuditConfig.cs +++ b/IRaCIS.Core.Domain/Common/FrontAuditConfig.cs @@ -109,6 +109,14 @@ namespace IRaCIS.Core.Domain.Models public string EnumType { get; set; } + public string ObjectTypeId { get; set; } + + + public bool? IsShowByTrialConfig { get; set; } + + public string ByTrialConfig { get; set; } + + } diff --git a/IRaCIS.Core.Domain/Common/SystemBasicData.cs b/IRaCIS.Core.Domain/Common/SystemBasicData.cs index 95e3a6e01..c44b14681 100644 --- a/IRaCIS.Core.Domain/Common/SystemBasicData.cs +++ b/IRaCIS.Core.Domain/Common/SystemBasicData.cs @@ -85,6 +85,8 @@ namespace IRaCIS.Core.Domain.Models public BasicDataTypeEnum BasicDataTypeEnum { get; set; } + + diff --git a/IRaCIS.Core.Domain/Trial/DataInspection.cs b/IRaCIS.Core.Domain/Trial/DataInspection.cs index 5e06dba41..567e835ce 100644 --- a/IRaCIS.Core.Domain/Trial/DataInspection.cs +++ b/IRaCIS.Core.Domain/Trial/DataInspection.cs @@ -139,6 +139,11 @@ namespace IRaCIS.Core.Domain.Models /// public string ResearchProgramNo { get; set; } + /// + /// 对象名称 + /// + public string ObjectType { get; set; } + }