字典处理
parent
8f6830ea8d
commit
0c0a82d8e1
|
@ -82,6 +82,13 @@ namespace IRaCIS.Core.API.Controllers
|
||||||
this._dataInspectionRepository = dataInspectionRepository;
|
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 文件管理
|
#region 文件管理
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -44,6 +44,13 @@
|
||||||
FrontAuditConfigService
|
FrontAuditConfigService
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</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)">
|
<member name="M:IRaCIS.Core.Application.Service.FrontAuditConfigService.GetChildrenItem(IRaCIS.Core.Application.ViewModel.GetChildrenItem)">
|
||||||
<summary>
|
<summary>
|
||||||
获取子数据
|
获取子数据
|
||||||
|
@ -203,6 +210,11 @@
|
||||||
用户 签名某个文档 Dto
|
用户 签名某个文档 Dto
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</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">
|
<member name="P:IRaCIS.Core.Application.Service.Inspection.DTO.GetDataInspectionDto.TrialId">
|
||||||
<summary>
|
<summary>
|
||||||
项目iD
|
项目iD
|
||||||
|
@ -305,12 +317,6 @@
|
||||||
<param name="keyValues">字典</param>
|
<param name="keyValues">字典</param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</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)">
|
<member name="M:IRaCIS.Core.Application.Service.Inspection.InspectionService.SetInspectionNameValue(IRaCIS.Core.Domain.Models.DataInspection)">
|
||||||
<summary>
|
<summary>
|
||||||
设置项目以及名称
|
设置项目以及名称
|
||||||
|
|
|
@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||||
using IRaCIS.Core.Application.Interfaces;
|
using IRaCIS.Core.Application.Interfaces;
|
||||||
using IRaCIS.Core.Application.ViewModel;
|
using IRaCIS.Core.Application.ViewModel;
|
||||||
using Castle.Core.Internal;
|
using Castle.Core.Internal;
|
||||||
|
using IRaCIS.Core.Infra.EFCore.Dto;
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Service
|
namespace IRaCIS.Core.Application.Service
|
||||||
{
|
{
|
||||||
|
@ -26,6 +27,17 @@ namespace IRaCIS.Core.Application.Service
|
||||||
_frontAuditConfigRepository = frontAuditConfigRepository;
|
_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>
|
||||||
/// 获取子数据
|
/// 获取子数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -430,8 +430,8 @@ namespace IRaCIS.Core.Application.Services
|
||||||
SiteId = dicomStudy.SiteId,
|
SiteId = dicomStudy.SiteId,
|
||||||
TrialId = dicomStudy.TrialId,
|
TrialId = dicomStudy.TrialId,
|
||||||
SubjectId = dicomStudy.SubjectId,
|
SubjectId = dicomStudy.SubjectId,
|
||||||
IsDeleted=false,
|
IsDeleted=true,
|
||||||
IsReading=false,
|
IsReading= true,
|
||||||
SubjectVisitId = dicomStudy.SubjectVisitId,
|
SubjectVisitId = dicomStudy.SubjectVisitId,
|
||||||
|
|
||||||
InstanceCount = 0
|
InstanceCount = 0
|
||||||
|
|
|
@ -363,6 +363,11 @@ namespace IRaCIS.Core.Application.Service.Inspection.DTO
|
||||||
|
|
||||||
public decimal? VisitNum { get; set; }
|
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.DTO;
|
||||||
using IRaCIS.Core.Application.Service.Inspection.Interface;
|
using IRaCIS.Core.Application.Service.Inspection.Interface;
|
||||||
using IRaCIS.Core.Domain.Share;
|
using IRaCIS.Core.Domain.Share;
|
||||||
|
using IRaCIS.Core.Infra.EFCore.Dto;
|
||||||
using IRaCIS.Core.Infrastructure;
|
using IRaCIS.Core.Infrastructure;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Converters;
|
||||||
|
@ -29,6 +30,9 @@ namespace IRaCIS.Core.Application.Service.Inspection
|
||||||
this._dataInspectionRepository = dataInspectionRepository;
|
this._dataInspectionRepository = dataInspectionRepository;
|
||||||
this._frontAuditConfigRepository = frontAuditConfigRepository;
|
this._frontAuditConfigRepository = frontAuditConfigRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public async Task<PageOutput<GetDataInspectionOutDto>> GetInspectionData(GetDataInspectionDto dto)
|
public async Task<PageOutput<GetDataInspectionOutDto>> GetInspectionData(GetDataInspectionDto dto)
|
||||||
{
|
{
|
||||||
//_repository.GetQueryable.GetQueryable < DataInspection >
|
//_repository.GetQueryable.GetQueryable < DataInspection >
|
||||||
|
@ -84,7 +88,8 @@ namespace IRaCIS.Core.Application.Service.Inspection
|
||||||
} into frontAuditConfigtemp
|
} into frontAuditConfigtemp
|
||||||
from leftfrontAuditConfig in frontAuditConfigtemp.DefaultIfEmpty()
|
from leftfrontAuditConfig in frontAuditConfigtemp.DefaultIfEmpty()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
join moduleTypec in _repository.GetQueryable<Dictionary>() on new { ModuleType = leftfrontAuditConfig.ModuleTypeId } equals new { ModuleType = moduleTypec.Id.ToString() } into moduleTypectemp
|
join moduleTypec in _repository.GetQueryable<Dictionary>() on new { ModuleType = leftfrontAuditConfig.ModuleTypeId } equals new { ModuleType = moduleTypec.Id.ToString() } into moduleTypectemp
|
||||||
from leftmoduleTypec in moduleTypectemp.DefaultIfEmpty()
|
from leftmoduleTypec in moduleTypectemp.DefaultIfEmpty()
|
||||||
|
|
||||||
|
@ -134,7 +139,8 @@ namespace IRaCIS.Core.Application.Service.Inspection
|
||||||
ModuleTypeName= leftmoduleTypec.ValueCN,
|
ModuleTypeName= leftmoduleTypec.ValueCN,
|
||||||
SignText= lefttrialSign.SignText,
|
SignText= lefttrialSign.SignText,
|
||||||
Identification= leftfrontAuditConfig.Identification,
|
Identification= leftfrontAuditConfig.Identification,
|
||||||
OptType= leftOptType.Value,
|
ParentIdentification = leftparent.Identification,
|
||||||
|
OptType = leftOptType.Value,
|
||||||
VisitNum=leftsubjectVisit.VisitNum,
|
VisitNum=leftsubjectVisit.VisitNum,
|
||||||
IsFrontAdd=data.IsFrontAdd
|
IsFrontAdd=data.IsFrontAdd
|
||||||
|
|
||||||
|
@ -292,7 +298,7 @@ namespace IRaCIS.Core.Application.Service.Inspection
|
||||||
{
|
{
|
||||||
return ResponseOutput.Ok();
|
return ResponseOutput.Ok();
|
||||||
}
|
}
|
||||||
await SetEnum(addDto);
|
//await SetEnum(addDto);
|
||||||
var add = _mapper.Map<DataInspection>(addDto);
|
var add = _mapper.Map<DataInspection>(addDto);
|
||||||
await SetInspectionNameValue(add);
|
await SetInspectionNameValue(add);
|
||||||
Guid? parentId = null;
|
Guid? parentId = null;
|
||||||
|
@ -395,114 +401,113 @@ namespace IRaCIS.Core.Application.Service.Inspection
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 处理枚举
|
///// 处理枚举
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <returns></returns>
|
///// <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>
|
/// <summary>
|
||||||
|
|
|
@ -4,7 +4,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
using System.Data.SqlClient;
|
using Microsoft.Data.SqlClient;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -74,6 +74,8 @@ namespace IRaCIS.Core.Infra.EFCore
|
||||||
parameter.ParameterName = $"@{parameter.ParameterName}";
|
parameter.ParameterName = $"@{parameter.ParameterName}";
|
||||||
command.Parameters.Add(parameter);
|
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 System.Threading.Tasks;
|
||||||
using EFCore.BulkExtensions;
|
using EFCore.BulkExtensions;
|
||||||
using IRaCIS.Core.Domain.Share;
|
using IRaCIS.Core.Domain.Share;
|
||||||
|
using IRaCIS.Core.Infra.EFCore.Dto;
|
||||||
|
|
||||||
namespace IRaCIS.Core.Infra.EFCore
|
namespace IRaCIS.Core.Infra.EFCore
|
||||||
{
|
{
|
||||||
|
@ -48,6 +49,25 @@ namespace IRaCIS.Core.Infra.EFCore
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
|
||||||
Task<string> SetEnum(Guid trial, string Identification, string json);
|
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 稽查
|
#region 稽查
|
||||||
|
|
||||||
|
|
||||||
///// <summary>
|
/// <summary>
|
||||||
/////
|
/// 翻译稽查数据
|
||||||
///// </summary>
|
/// </summary>
|
||||||
///// <param name="Identification"></param>
|
/// <param name="dto">传入Dto</param>
|
||||||
///// <param name="json"></param>
|
/// <returns></returns>
|
||||||
///// <returns></returns>
|
public async Task<List<string>> SetDictionaryValue(SetDictionaryValueDto dto)
|
||||||
//public async Task<string> SetDictionaryValue(string Identification, string json)
|
{
|
||||||
//{
|
|
||||||
|
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>
|
||||||
/////
|
/// 获取外键表数据
|
||||||
///// </summary>
|
/// </summary>
|
||||||
///// <param name="Table"></param>
|
/// <param name="Table">表名称</param>
|
||||||
///// <param name="ForeignKeyValue"></param>
|
/// <param name="ForeignKeyValue">外键value</param>
|
||||||
///// <param name="ForeignKeyText"></param>
|
/// <param name="ForeignKeyText">要查询的外键值</param>
|
||||||
///// <param name="value"></param>
|
/// <param name="value">传入的纸</param>
|
||||||
///// <returns></returns>
|
/// <returns></returns>
|
||||||
//public async Task<string> GetDictionaryValue(string Table,string ForeignKeyValue,string ForeignKeyText,string value)
|
public async Task<string> GetDictionaryValue(string Identification, string json)
|
||||||
//{
|
{
|
||||||
// string para = string.Empty;
|
var list = await (from u in _dbContext.FrontAuditConfig.Where(x => x.Identification == Identification)
|
||||||
// string sql = string.Empty;
|
join p in _dbContext.FrontAuditConfig.Where(x => x.EnumType == "Foreign") on u.Id equals p.ParentId
|
||||||
// string item = JsonConvert.SerializeObject(new {
|
select new
|
||||||
// item = value
|
{
|
||||||
// });
|
Key = p.Code,
|
||||||
// var JsonData = JsonConvert.DeserializeObject<IDictionary<string, object>>(item);
|
ForeignKeyValue = p.ForeignKeyValue,
|
||||||
// if (JsonData["item"].GetType() == typeof(JArray))
|
ForeignKeyText = p.ForeignKeyText,
|
||||||
// {
|
ForeignKeyTable = p.ForeignKeyTable
|
||||||
// foreach (var v in JsonData["item"] as JArray)
|
}).ToListAsync();
|
||||||
// {
|
|
||||||
// para += para == string.Empty ? $"'{v}'" : $",'{v}'";
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
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>
|
/// <summary>
|
||||||
|
@ -658,11 +667,12 @@ namespace IRaCIS.Core.Infra.EFCore
|
||||||
Type = "Code",
|
Type = "Code",
|
||||||
});
|
});
|
||||||
|
|
||||||
try
|
var JsonData = JsonConvert.DeserializeObject<IDictionary<string, object>>(json);
|
||||||
|
foreach (var item in list)
|
||||||
{
|
{
|
||||||
var JsonData = JsonConvert.DeserializeObject<IDictionary<string, object>>(json);
|
try
|
||||||
foreach (var item in list)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!JsonData.ContainsKey(item.Key))
|
if (!JsonData.ContainsKey(item.Key))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
@ -741,17 +751,18 @@ namespace IRaCIS.Core.Infra.EFCore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
|
||||||
|
//throw new BusinessValidationFailedException("Json 对象枚举异常");
|
||||||
|
}
|
||||||
return JsonConvert.SerializeObject(JsonData);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
|
|
||||||
throw new BusinessValidationFailedException("Json 对象枚举异常");
|
|
||||||
}
|
|
||||||
|
return JsonConvert.SerializeObject(JsonData);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -895,7 +906,7 @@ namespace IRaCIS.Core.Infra.EFCore
|
||||||
{
|
{
|
||||||
add.CreateTime = DateTime.Now;
|
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);
|
await SetDataInspectionDateType(add);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue