表格翻译
parent
d03aa27f9e
commit
52515f3dfe
|
@ -16,6 +16,7 @@ using Newtonsoft.Json.Linq;
|
||||||
using IRaCIS.Core.Domain.Share;
|
using IRaCIS.Core.Domain.Share;
|
||||||
using IRaCIS.Core.Domain.Share.Management;
|
using IRaCIS.Core.Domain.Share.Management;
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
|
using IRaCIS.Application.Contracts;
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Service
|
namespace IRaCIS.Core.Application.Service
|
||||||
{
|
{
|
||||||
|
@ -235,7 +236,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var listIdentification = auditDatas.Select(x => x.Identification).ToList();
|
var listIdentification = auditDatas.Select(x => x.Identification).Distinct().ToList();
|
||||||
foreach (var item in auditDatas)
|
foreach (var item in auditDatas)
|
||||||
{
|
{
|
||||||
Dictionary<string, object> jsonDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(item.JsonStr);
|
Dictionary<string, object> jsonDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(item.JsonStr);
|
||||||
|
@ -703,12 +704,16 @@ namespace IRaCIS.Core.Application.Service
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//DictionaryCode='' and EnumType='Dictionary' 是审核状态
|
||||||
var list = await (from u in _frontAuditConfigRepository.Where(x => identificationList.Contains(x.Identification))
|
var list = await (from u in _frontAuditConfigRepository.Where(x => identificationList.Contains(x.Identification))
|
||||||
join p in _frontAuditConfigRepository.Where(x => x.DictionaryCode!=null &&x.DictionaryCode!=string.Empty && x.EnumType == "Dictionary" && x.IsEnable) on u.Id equals p.ParentId
|
join p in _frontAuditConfigRepository.Where(x => (x.DictionaryCode!=string.Empty && x.EnumType == "Dictionary" )||(x.DataType=="Table") && x.IsEnable) on u.Id equals p.ParentId
|
||||||
select new
|
select new
|
||||||
{
|
{
|
||||||
//前端展示类型
|
//前端展示类型
|
||||||
//DataType=p.DataType,
|
DataType=p.DataType,
|
||||||
|
TableConfigJsonStr= p.TableConfigJsonStr,
|
||||||
Key = p.Code,
|
Key = p.Code,
|
||||||
Code = p.DictionaryCode,
|
Code = p.DictionaryCode,
|
||||||
Type = p.DictionaryType
|
Type = p.DictionaryType
|
||||||
|
@ -721,22 +726,14 @@ namespace IRaCIS.Core.Application.Service
|
||||||
{
|
{
|
||||||
list.Add(new
|
list.Add(new
|
||||||
{
|
{
|
||||||
//DataType="",
|
DataType = string.Empty,
|
||||||
|
TableConfigJsonStr = string.Empty,
|
||||||
Key = "AuditState",
|
Key = "AuditState",
|
||||||
Code = trialtype == TrialQCProcess.SingleAudit ? "AuditStatePE" : "AuditStateRC",
|
Code = trialtype == TrialQCProcess.SingleAudit ? "AuditStatePE" : "AuditStateRC",
|
||||||
Type = "Code",
|
Type = "Code",
|
||||||
});
|
}); ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
list = list.GroupBy(x => new { x.Key }, (key, lst) => new
|
|
||||||
{
|
|
||||||
Key = key.Key,
|
|
||||||
Code = lst.Max(x => x.Code),
|
|
||||||
Type = lst.Max(x => x.Type),
|
|
||||||
}).ToList();
|
|
||||||
|
|
||||||
var jsonDataDic = JsonConvert.DeserializeObject<IDictionary<string, object>>(jsonStr);
|
var jsonDataDic = JsonConvert.DeserializeObject<IDictionary<string, object>>(jsonStr);
|
||||||
foreach (var item in list)
|
foreach (var item in list)
|
||||||
|
@ -749,11 +746,51 @@ namespace IRaCIS.Core.Application.Service
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var value = jsonDataDic[item.Key];
|
var value = jsonDataDic[item.Key];
|
||||||
|
|
||||||
|
//翻译的是数组
|
||||||
if (value.GetType() == typeof(JArray))
|
if (value.GetType() == typeof(JArray))
|
||||||
{
|
{
|
||||||
JArray arrays = (JArray)value;
|
JArray arrays = (JArray)value;
|
||||||
|
|
||||||
|
|
||||||
|
if (item.DataType == "Table")
|
||||||
|
{
|
||||||
|
var tableConfigList= JsonConvert.DeserializeObject<List<TableConfig>>(item.TableConfigJsonStr) ?? new List<TableConfig>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var translateInfoList = tableConfigList.Where(t => t.IsNeedTransalate).Select(t => new { t.ColumnValue, t.TranslateDictionaryName }).Distinct().ToList();
|
||||||
|
|
||||||
|
var dictionaryNameList = translateInfoList.Select(t => t.TranslateDictionaryName).Distinct().ToList();
|
||||||
|
|
||||||
|
|
||||||
|
var searchList = await _dictionaryRepository.Where(t => dictionaryNameList.Contains(t.Parent.Code) && t.ParentId != null && t.IsEnable).ProjectTo<BasicDicSelect>(_mapper.ConfigurationProvider).ToListAsync();
|
||||||
|
|
||||||
|
//翻译的字典数据
|
||||||
|
var translateDataList= searchList.GroupBy(t => t.ParentCode).ToDictionary(g => g.Key, g => g.OrderBy(t => t.ShowOrder).ToList());
|
||||||
|
|
||||||
|
List<JObject> jsonList = new List<JObject>();
|
||||||
|
foreach (JToken arraysItem in arrays)
|
||||||
|
{
|
||||||
|
var jsonObject = JObject.Parse(arraysItem.ToString());
|
||||||
|
|
||||||
|
foreach (var translateInfo in translateInfoList)
|
||||||
|
{
|
||||||
|
//Json 解析后 true 变为了True
|
||||||
|
jsonObject[translateInfo.ColumnValue] = translateDataList[translateInfo.TranslateDictionaryName].Where(t => t.Code.ToLower() == jsonObject[translateInfo.ColumnValue].ToString().ToLower()).Select(t => t.ValueCN).FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonList.Add(jsonObject);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonDataDic[item.Key] = JToken.FromObject(jsonList);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (item.Type.ToLower() == FrontAudit.Id.GetDescription().ToLower())
|
if (item.Type.ToLower() == FrontAudit.Id.GetDescription().ToLower())
|
||||||
{
|
{
|
||||||
List<Guid> guids = new List<Guid>();
|
List<Guid> guids = new List<Guid>();
|
||||||
|
@ -835,12 +872,15 @@ namespace IRaCIS.Core.Application.Service
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//翻译的是单个字段
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
//通过字典项的Guid 翻译
|
||||||
if (item.Type.ToLower() == FrontAudit.Id.GetDescription().ToLower())
|
if (item.Type.ToLower() == FrontAudit.Id.GetDescription().ToLower())
|
||||||
{
|
{
|
||||||
Guid guid = Guid.Parse(value.ToString());
|
Guid guid = Guid.Parse(value.ToString());
|
||||||
jsonDataDic[item.Key] = await _dictionaryRepository.Where(x => guid == x.Id).Select(x => x.ValueCN).FirstOrDefaultAsync();
|
jsonDataDic[item.Key] = await _dictionaryRepository.Where(x => x.Id== guid ).Select(x => x.ValueCN).FirstOrDefaultAsync();
|
||||||
}
|
}
|
||||||
else if (item.Type.ToLower() == FrontAudit.ChildGroup.GetDescription().ToLower())
|
else if (item.Type.ToLower() == FrontAudit.ChildGroup.GetDescription().ToLower())
|
||||||
{
|
{
|
||||||
|
@ -849,6 +889,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
value = b.ValueCN
|
value = b.ValueCN
|
||||||
}).Select(x => x.value).FirstOrDefaultAsync();
|
}).Select(x => x.value).FirstOrDefaultAsync();
|
||||||
}
|
}
|
||||||
|
//通过字典项的code 翻译 枚举或者 bool
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
jsonDataDic[item.Key] = await _dictionaryRepository.Where(x => x.Code == item.Code).Join(_dictionaryRepository.Where(x => x.Code == value.ToString()), a => a.Id, b => b.ParentId, (a, b) => new
|
jsonDataDic[item.Key] = await _dictionaryRepository.Where(x => x.Code == item.Code).Join(_dictionaryRepository.Where(x => x.Code == value.ToString()), a => a.Id, b => b.ParentId, (a, b) => new
|
||||||
|
|
Loading…
Reference in New Issue