字典处理
parent
8f6830ea8d
commit
0c0a82d8e1
|
@ -82,6 +82,13 @@ namespace IRaCIS.Core.API.Controllers
|
|||
this._dataInspectionRepository = dataInspectionRepository;
|
||||
}
|
||||
|
||||
|
||||
//[HttpPost, Route("Inspection/Test")]
|
||||
//public async Task Test(string Table, string ForeignKeyValue, string ForeignKeyText, string value)
|
||||
//{
|
||||
// string a= await _dataInspectionRepository.GetDictionaryValue(Table, ForeignKeyValue, ForeignKeyText, value);
|
||||
//}
|
||||
|
||||
#region 文件管理
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -44,6 +44,13 @@
|
|||
FrontAuditConfigService
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.FrontAuditConfigService.SetDictionaryValue(IRaCIS.Core.Infra.EFCore.Dto.SetDictionaryValueDto)">
|
||||
<summary>
|
||||
翻译稽查数据
|
||||
</summary>
|
||||
<param name="dto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.FrontAuditConfigService.GetChildrenItem(IRaCIS.Core.Application.ViewModel.GetChildrenItem)">
|
||||
<summary>
|
||||
获取子数据
|
||||
|
@ -203,6 +210,11 @@
|
|||
用户 签名某个文档 Dto
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:IRaCIS.Core.Application.Service.Inspection.DTO.GetDataInspectionOutDto.ParentIdentification">
|
||||
<summary>
|
||||
父标识
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:IRaCIS.Core.Application.Service.Inspection.DTO.GetDataInspectionDto.TrialId">
|
||||
<summary>
|
||||
项目iD
|
||||
|
@ -305,12 +317,6 @@
|
|||
<param name="keyValues">字典</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.Inspection.InspectionService.SetEnum(IRaCIS.Core.Application.Service.Inspection.DTO.DataInspectionAddDTO)">
|
||||
<summary>
|
||||
处理枚举
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.Inspection.InspectionService.SetInspectionNameValue(IRaCIS.Core.Domain.Models.DataInspection)">
|
||||
<summary>
|
||||
设置项目以及名称
|
||||
|
|
|
@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||
using IRaCIS.Core.Application.Interfaces;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
using Castle.Core.Internal;
|
||||
using IRaCIS.Core.Infra.EFCore.Dto;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service
|
||||
{
|
||||
|
@ -26,6 +27,17 @@ namespace IRaCIS.Core.Application.Service
|
|||
_frontAuditConfigRepository = frontAuditConfigRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 翻译稽查数据
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<List<string>> SetDictionaryValue(SetDictionaryValueDto dto)
|
||||
{
|
||||
return await _frontAuditConfigRepository.SetDictionaryValue(dto);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取子数据
|
||||
/// </summary>
|
||||
|
|
|
@ -430,8 +430,8 @@ namespace IRaCIS.Core.Application.Services
|
|||
SiteId = dicomStudy.SiteId,
|
||||
TrialId = dicomStudy.TrialId,
|
||||
SubjectId = dicomStudy.SubjectId,
|
||||
IsDeleted=false,
|
||||
IsReading=false,
|
||||
IsDeleted=true,
|
||||
IsReading= true,
|
||||
SubjectVisitId = dicomStudy.SubjectVisitId,
|
||||
|
||||
InstanceCount = 0
|
||||
|
|
|
@ -363,6 +363,11 @@ namespace IRaCIS.Core.Application.Service.Inspection.DTO
|
|||
|
||||
public decimal? VisitNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 父标识
|
||||
/// </summary>
|
||||
public string ParentIdentification { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ 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.Infra.EFCore.Dto;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
@ -29,6 +30,9 @@ namespace IRaCIS.Core.Application.Service.Inspection
|
|||
this._dataInspectionRepository = dataInspectionRepository;
|
||||
this._frontAuditConfigRepository = frontAuditConfigRepository;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<PageOutput<GetDataInspectionOutDto>> GetInspectionData(GetDataInspectionDto dto)
|
||||
{
|
||||
//_repository.GetQueryable.GetQueryable < DataInspection >
|
||||
|
@ -84,7 +88,8 @@ namespace IRaCIS.Core.Application.Service.Inspection
|
|||
} into frontAuditConfigtemp
|
||||
from leftfrontAuditConfig in frontAuditConfigtemp.DefaultIfEmpty()
|
||||
|
||||
|
||||
|
||||
|
||||
join moduleTypec in _repository.GetQueryable<Dictionary>() on new { ModuleType = leftfrontAuditConfig.ModuleTypeId } equals new { ModuleType = moduleTypec.Id.ToString() } into moduleTypectemp
|
||||
from leftmoduleTypec in moduleTypectemp.DefaultIfEmpty()
|
||||
|
||||
|
@ -134,7 +139,8 @@ namespace IRaCIS.Core.Application.Service.Inspection
|
|||
ModuleTypeName= leftmoduleTypec.ValueCN,
|
||||
SignText= lefttrialSign.SignText,
|
||||
Identification= leftfrontAuditConfig.Identification,
|
||||
OptType= leftOptType.Value,
|
||||
ParentIdentification = leftparent.Identification,
|
||||
OptType = leftOptType.Value,
|
||||
VisitNum=leftsubjectVisit.VisitNum,
|
||||
IsFrontAdd=data.IsFrontAdd
|
||||
|
||||
|
@ -292,7 +298,7 @@ namespace IRaCIS.Core.Application.Service.Inspection
|
|||
{
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
await SetEnum(addDto);
|
||||
//await SetEnum(addDto);
|
||||
var add = _mapper.Map<DataInspection>(addDto);
|
||||
await SetInspectionNameValue(add);
|
||||
Guid? parentId = null;
|
||||
|
@ -395,114 +401,113 @@ namespace IRaCIS.Core.Application.Service.Inspection
|
|||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理枚举
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
///// <summary>
|
||||
///// 处理枚举
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//public async Task SetEnum(DataInspectionAddDTO Data)
|
||||
//{
|
||||
// //Data.JsonDetail= await _dataInspectionRepository.SetEnum(Data.TrialId.Value, Data.Identification, Data.JsonDetail);
|
||||
// #region 枚举
|
||||
// //try
|
||||
// //{
|
||||
// // var JsonData = JsonConvert.DeserializeObject<IDictionary<string, object>>(Data.JsonDetail);
|
||||
// // foreach (var item in Data.EnumList)
|
||||
// // {
|
||||
// // if (!JsonData.ContainsKey(item.Key))
|
||||
// // {
|
||||
// // continue;
|
||||
// // }
|
||||
// // var value = JsonData[item.Key];
|
||||
// // if (value.GetType() == typeof(JArray))
|
||||
// // {
|
||||
// // JArray arrays = (JArray)value;
|
||||
// // if (item.Type.ToLower() == "id".ToLower())
|
||||
// // {
|
||||
// // List<Guid> guids = new List<Guid>();
|
||||
// // arrays.ForEach(x =>
|
||||
// // {
|
||||
// // guids.Add(Guid.Parse(x.ToString()));
|
||||
// // });
|
||||
// // JsonData[item.Key] = string.Join(',', await _repository.GetQueryable<Dictionary>().Where(x => guids.Contains(x.Id)).Select(x => x.ValueCN).ToListAsync());
|
||||
// // }
|
||||
// // else if (item.Type.ToLower() == "ChildGroup".ToLower())
|
||||
// // {
|
||||
// // List<string> guids = new List<string>();
|
||||
// // arrays.ForEach(x =>
|
||||
// // {
|
||||
// // guids.Add(x.ToString());
|
||||
// // });
|
||||
// // JsonData[item.Key] = string.Join(',', await
|
||||
// // _repository.GetQueryable<Dictionary>().Where(x => x.Code == item.Code).GroupJoin(
|
||||
// // _repository.GetQueryable<Dictionary>().Where(x => guids.Contains(x.ChildGroup)), a => a.Id, b => b.ParentId, (a, b) => new
|
||||
// // {
|
||||
// // parent = b
|
||||
// // }).SelectMany(a => a.parent, (m, n) => new
|
||||
// // {
|
||||
// // value = n.ValueCN
|
||||
// // }).Select(x => x.value).ToListAsync()
|
||||
// // );
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // List<string> guids =new List<string>();
|
||||
// // arrays.ForEach(x =>
|
||||
// // {
|
||||
// // guids.Add(x.ToString());
|
||||
// // });
|
||||
// // JsonData[item.Key] = string.Join(',', await
|
||||
// // _repository.GetQueryable<Dictionary>().Where(x => x.Code == item.Code).GroupJoin(
|
||||
// // _repository.GetQueryable<Dictionary>().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.ValueCN
|
||||
// // }).Select(x => x.value).ToListAsync()
|
||||
// // );
|
||||
// // }
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // if (item.Type.ToLower() == "id".ToLower())
|
||||
// // {
|
||||
// // Guid guid = Guid.Parse(value.ToString());
|
||||
// // JsonData[item.Key] = await _repository.GetQueryable<Dictionary>().Where(x => guid == x.Id).Select(x => x.ValueCN).FirstOrDefaultAsync();
|
||||
// // }
|
||||
// // else if (item.Type.ToLower() == "ChildGroup".ToLower())
|
||||
// // {
|
||||
// // JsonData[item.Key] = await _repository.GetQueryable<Dictionary>().Where(x => x.Code == item.Code).Join(_repository.GetQueryable<Dictionary>().Where(x => x.ChildGroup == value.ToString()), a => a.Id, b => b.ParentId, (a, b) => new
|
||||
// // {
|
||||
// // value = b.ValueCN
|
||||
// // }).Select(x => x.value).FirstOrDefaultAsync();
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // JsonData[item.Key] = await _repository.GetQueryable<Dictionary>().Where(x=>x.Code==item.Code).Join(_repository.GetQueryable<Dictionary>().Where(x=>x.Code== value.ToString()), a => a.Id, b => b.ParentId, (a, b) => new
|
||||
// // {
|
||||
// // value=b.ValueCN
|
||||
// // }).Select(x=>x.value).FirstOrDefaultAsync();
|
||||
|
||||
public async Task SetEnum(DataInspectionAddDTO Data)
|
||||
{
|
||||
Data.JsonDetail= await _dataInspectionRepository.SetEnum(Data.TrialId.Value, Data.Identification, Data.JsonDetail);
|
||||
#region 枚举
|
||||
//try
|
||||
//{
|
||||
// var JsonData = JsonConvert.DeserializeObject<IDictionary<string, object>>(Data.JsonDetail);
|
||||
// foreach (var item in Data.EnumList)
|
||||
// {
|
||||
// if (!JsonData.ContainsKey(item.Key))
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
// var value = JsonData[item.Key];
|
||||
// if (value.GetType() == typeof(JArray))
|
||||
// {
|
||||
// JArray arrays = (JArray)value;
|
||||
// if (item.Type.ToLower() == "id".ToLower())
|
||||
// {
|
||||
// List<Guid> guids = new List<Guid>();
|
||||
// arrays.ForEach(x =>
|
||||
// {
|
||||
// guids.Add(Guid.Parse(x.ToString()));
|
||||
// });
|
||||
// JsonData[item.Key] = string.Join(',', await _repository.GetQueryable<Dictionary>().Where(x => guids.Contains(x.Id)).Select(x => x.ValueCN).ToListAsync());
|
||||
// }
|
||||
// else if (item.Type.ToLower() == "ChildGroup".ToLower())
|
||||
// {
|
||||
// List<string> guids = new List<string>();
|
||||
// arrays.ForEach(x =>
|
||||
// {
|
||||
// guids.Add(x.ToString());
|
||||
// });
|
||||
// JsonData[item.Key] = string.Join(',', await
|
||||
// _repository.GetQueryable<Dictionary>().Where(x => x.Code == item.Code).GroupJoin(
|
||||
// _repository.GetQueryable<Dictionary>().Where(x => guids.Contains(x.ChildGroup)), a => a.Id, b => b.ParentId, (a, b) => new
|
||||
// {
|
||||
// parent = b
|
||||
// }).SelectMany(a => a.parent, (m, n) => new
|
||||
// {
|
||||
// value = n.ValueCN
|
||||
// }).Select(x => x.value).ToListAsync()
|
||||
// );
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// List<string> guids =new List<string>();
|
||||
// arrays.ForEach(x =>
|
||||
// {
|
||||
// guids.Add(x.ToString());
|
||||
// });
|
||||
// JsonData[item.Key] = string.Join(',', await
|
||||
// _repository.GetQueryable<Dictionary>().Where(x => x.Code == item.Code).GroupJoin(
|
||||
// _repository.GetQueryable<Dictionary>().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.ValueCN
|
||||
// }).Select(x => x.value).ToListAsync()
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (item.Type.ToLower() == "id".ToLower())
|
||||
// {
|
||||
// Guid guid = Guid.Parse(value.ToString());
|
||||
// JsonData[item.Key] = await _repository.GetQueryable<Dictionary>().Where(x => guid == x.Id).Select(x => x.ValueCN).FirstOrDefaultAsync();
|
||||
// }
|
||||
// else if (item.Type.ToLower() == "ChildGroup".ToLower())
|
||||
// {
|
||||
// JsonData[item.Key] = await _repository.GetQueryable<Dictionary>().Where(x => x.Code == item.Code).Join(_repository.GetQueryable<Dictionary>().Where(x => x.ChildGroup == value.ToString()), a => a.Id, b => b.ParentId, (a, b) => new
|
||||
// {
|
||||
// value = b.ValueCN
|
||||
// }).Select(x => x.value).FirstOrDefaultAsync();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// JsonData[item.Key] = await _repository.GetQueryable<Dictionary>().Where(x=>x.Code==item.Code).Join(_repository.GetQueryable<Dictionary>().Where(x=>x.Code== value.ToString()), a => a.Id, b => b.ParentId, (a, b) => new
|
||||
// {
|
||||
// value=b.ValueCN
|
||||
// }).Select(x=>x.value).FirstOrDefaultAsync();
|
||||
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// // }
|
||||
// // }
|
||||
// // }
|
||||
|
||||
|
||||
|
||||
// Data.JsonDetail = JsonConvert.SerializeObject(JsonData);
|
||||
// // Data.JsonDetail = JsonConvert.SerializeObject(JsonData);
|
||||
|
||||
//}
|
||||
//catch (Exception)
|
||||
//{
|
||||
// //}
|
||||
// //catch (Exception)
|
||||
// //{
|
||||
|
||||
// throw new BusinessValidationFailedException("Json 对象枚举异常");
|
||||
//}
|
||||
// // throw new BusinessValidationFailedException("Json 对象枚举异常");
|
||||
// //}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
// #endregion
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -4,7 +4,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Data.SqlClient;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
@ -74,6 +74,8 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
parameter.ParameterName = $"@{parameter.ParameterName}";
|
||||
command.Parameters.Add(parameter);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IRaCIS.Core.Infra.EFCore.Dto
|
||||
{
|
||||
public class ForeignKey
|
||||
{
|
||||
public string Text { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IRaCIS.Core.Infra.EFCore.Dto
|
||||
{
|
||||
public class SetDictionaryValueDto
|
||||
{
|
||||
public Guid Trial { get; set; }
|
||||
|
||||
public List<SetDictionaryDto> Items { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class SetDictionaryDto
|
||||
{
|
||||
public string Identification { get; set; }
|
||||
|
||||
public string Json { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -13,6 +13,7 @@ using System.Linq.Expressions;
|
|||
using System.Threading.Tasks;
|
||||
using EFCore.BulkExtensions;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infra.EFCore.Dto;
|
||||
|
||||
namespace IRaCIS.Core.Infra.EFCore
|
||||
{
|
||||
|
@ -48,6 +49,25 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
/// <returns></returns>
|
||||
|
||||
Task<string> SetEnum(Guid trial, string Identification, string json);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取外键表数据
|
||||
/// </summary>
|
||||
/// <param name="Table">表名称</param>
|
||||
/// <param name="ForeignKeyValue">外键value</param>
|
||||
/// <param name="ForeignKeyText">要查询的外键值</param>
|
||||
/// <param name="value">传入的纸</param>
|
||||
/// <returns></returns>
|
||||
Task<string> GetDictionaryValue(string Identification, string json);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 翻译稽查数据
|
||||
/// </summary>
|
||||
/// <param name="dto">传入Dto</param>
|
||||
/// <returns></returns>
|
||||
Task<List<string>> SetDictionaryValue(SetDictionaryValueDto dto);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -564,69 +564,78 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
#region 稽查
|
||||
|
||||
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
///// <param name="Identification"></param>
|
||||
///// <param name="json"></param>
|
||||
///// <returns></returns>
|
||||
//public async Task<string> SetDictionaryValue(string Identification, string json)
|
||||
//{
|
||||
|
||||
/// <summary>
|
||||
/// 翻译稽查数据
|
||||
/// </summary>
|
||||
/// <param name="dto">传入Dto</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<string>> SetDictionaryValue(SetDictionaryValueDto dto)
|
||||
{
|
||||
|
||||
foreach (var item in dto.Items)
|
||||
{
|
||||
item.Json = await GetDictionaryValue(item.Identification,item.Json);
|
||||
item.Json = await SetEnum(dto.Trial, item.Identification, item.Json);
|
||||
}
|
||||
|
||||
//}
|
||||
return dto.Items.Select(x=>x.Json).ToList();
|
||||
}
|
||||
|
||||
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
///// <param name="Table"></param>
|
||||
///// <param name="ForeignKeyValue"></param>
|
||||
///// <param name="ForeignKeyText"></param>
|
||||
///// <param name="value"></param>
|
||||
///// <returns></returns>
|
||||
//public async Task<string> GetDictionaryValue(string Table,string ForeignKeyValue,string ForeignKeyText,string value)
|
||||
//{
|
||||
// string para = string.Empty;
|
||||
// string sql = string.Empty;
|
||||
// string item = JsonConvert.SerializeObject(new {
|
||||
// item = value
|
||||
// });
|
||||
// var JsonData = JsonConvert.DeserializeObject<IDictionary<string, object>>(item);
|
||||
// if (JsonData["item"].GetType() == typeof(JArray))
|
||||
// {
|
||||
// foreach (var v in JsonData["item"] as JArray)
|
||||
// {
|
||||
// para += para == string.Empty ? $"'{v}'" : $",'{v}'";
|
||||
// }
|
||||
/// <summary>
|
||||
/// 获取外键表数据
|
||||
/// </summary>
|
||||
/// <param name="Table">表名称</param>
|
||||
/// <param name="ForeignKeyValue">外键value</param>
|
||||
/// <param name="ForeignKeyText">要查询的外键值</param>
|
||||
/// <param name="value">传入的纸</param>
|
||||
/// <returns></returns>
|
||||
public async Task<string> GetDictionaryValue(string Identification, string json)
|
||||
{
|
||||
var list = await (from u in _dbContext.FrontAuditConfig.Where(x => x.Identification == Identification)
|
||||
join p in _dbContext.FrontAuditConfig.Where(x => x.EnumType == "Foreign") on u.Id equals p.ParentId
|
||||
select new
|
||||
{
|
||||
Key = p.Code,
|
||||
ForeignKeyValue = p.ForeignKeyValue,
|
||||
ForeignKeyText = p.ForeignKeyText,
|
||||
ForeignKeyTable = p.ForeignKeyTable
|
||||
}).ToListAsync();
|
||||
|
||||
var JsonDataValue = JsonConvert.DeserializeObject<IDictionary<string, object>>(json);
|
||||
foreach (var item in list)
|
||||
{
|
||||
if (!JsonDataValue.ContainsKey(item.Key))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string Table = item.ForeignKeyTable;
|
||||
string ForeignKeyValue = item.ForeignKeyValue; string ForeignKeyText = item.ForeignKeyText;
|
||||
string value = JsonDataValue[item.Key].ToString();
|
||||
string para = string.Empty;
|
||||
string sql = string.Empty;
|
||||
var JsonData = JsonConvert.DeserializeObject<IDictionary<string, object>>(JsonConvert.SerializeObject(new { item = value }));
|
||||
if (JsonData["item"].GetType() == typeof(JArray))
|
||||
{
|
||||
foreach (var v in JsonData["item"] as JArray)
|
||||
{
|
||||
para += para == string.Empty ? $"'{v.ToString()}'" : $",'{v.ToString()}'";
|
||||
}
|
||||
sql = $"select {ForeignKeyText} Text from {Table} where {ForeignKeyValue} in (@para)";
|
||||
}
|
||||
else
|
||||
{
|
||||
para = $"{JsonData["item"].ToString()}";
|
||||
sql = $"select {ForeignKeyText} Text from {Table} where {ForeignKeyValue} = @para";
|
||||
}
|
||||
SqlParameter[] paravalue = new SqlParameter[] {
|
||||
new SqlParameter("@para",para)
|
||||
};
|
||||
JsonDataValue[item.Key] = string.Join(",", _dbContext.Database.SqlQuery<ForeignKey>(sql, paravalue).Select(x => x.Text).ToList());
|
||||
}
|
||||
return JsonConvert.SerializeObject(JsonDataValue);
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// //Type type = typeof(TFrom);
|
||||
|
||||
// ////以下是不要ID这个字段的 比如自增列ID 就不能像上名那样写
|
||||
// //var properties = type.GetProperties().Where(t => t.Name != "Id");
|
||||
|
||||
|
||||
// //string strSqlName = string.Join(",", properties.Select(p => $"[{p.Name}]").ToArray());
|
||||
|
||||
// //string strSqlValue = string.Join(",", properties.Select(P => $"@{P.Name}").ToArray());
|
||||
|
||||
// //string strSql = $"insert into {nameof(Dictionary)} ( " + strSqlName + " ) values (" + strSqlValue + ")";
|
||||
|
||||
// ////para Sql是参数
|
||||
// //SqlParameter[] para = properties.Select(p => new SqlParameter($"@{p.Name}", p.GetValue(from, null))).ToArray();
|
||||
|
||||
// _dbContext.Database.SqlQuery<>
|
||||
// //_dbContext.Database.ExecuteSqlRaw(strSql, para);
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
@ -658,11 +667,12 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
Type = "Code",
|
||||
});
|
||||
|
||||
try
|
||||
var JsonData = JsonConvert.DeserializeObject<IDictionary<string, object>>(json);
|
||||
foreach (var item in list)
|
||||
{
|
||||
var JsonData = JsonConvert.DeserializeObject<IDictionary<string, object>>(json);
|
||||
foreach (var item in list)
|
||||
try
|
||||
{
|
||||
|
||||
if (!JsonData.ContainsKey(item.Key))
|
||||
{
|
||||
continue;
|
||||
|
@ -741,17 +751,18 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
|
||||
|
||||
return JsonConvert.SerializeObject(JsonData);
|
||||
|
||||
//throw new BusinessValidationFailedException("Json 对象枚举异常");
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
throw new BusinessValidationFailedException("Json 对象枚举异常");
|
||||
}
|
||||
|
||||
|
||||
return JsonConvert.SerializeObject(JsonData);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -895,7 +906,7 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
{
|
||||
add.CreateTime = DateTime.Now;
|
||||
}
|
||||
add.JsonDetail = await SetEnum(add.TrialId, add.Identification, add.JsonDetail);
|
||||
//add.JsonDetail = await SetEnum(add.TrialId, add.Identification, add.JsonDetail);
|
||||
await SetDataInspectionDateType(add);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue