稽查翻译提交

Uat_Study
{872297557@qq.com} 2023-01-06 13:10:37 +08:00
parent 1225d18e75
commit 5602f45ebd
1 changed files with 76 additions and 27 deletions

View File

@ -253,7 +253,7 @@ namespace IRaCIS.Core.Application.Service
var objectLsit = new List<object>();
var relationParentDataObjList = await GetRelationParentData(item.Id, item.ObjectRelationParentId, item.ObjectRelationParentId2, item.ObjectRelationParentId3 ,item.CreateTime, item.BatchId, objectLsit);
var relationParentDataObjList = await GetRelationParentData(item.Id, item.ObjectRelationParentId, item.ObjectRelationParentId2, item.ObjectRelationParentId3, item.CreateTime, item.BatchId, objectLsit);
@ -708,19 +708,19 @@ namespace IRaCIS.Core.Application.Service
//DictionaryCode='' and EnumType='Dictionary' 是审核状态
var list = await (from u in _frontAuditConfigRepository.Where(x => identificationList.Contains(x.Identification))
join p in _frontAuditConfigRepository.Where(x => (x.DictionaryCode!=string.Empty && x.EnumType == "Dictionary" )||(x.DataType=="Table") && 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
{
//前端展示类型
DataType=p.DataType,
TableConfigJsonStr= p.TableConfigJsonStr,
DataType = p.DataType,
TableConfigJsonStr = p.TableConfigJsonStr,
Key = p.Code,
Code = p.DictionaryCode,
Type = p.DictionaryType
}).ToListAsync();
//两条不同的标识 但是里面配置有相同的翻译字典
list=list.Distinct().ToList();
list = list.Distinct().ToList();
// 添加单双审
var trialtype = await _trialRepository.AsQueryable().Where(x => x.Id == trialId).Select(x => x.QCProcessEnum).FirstOrDefaultAsync();
@ -734,7 +734,7 @@ namespace IRaCIS.Core.Application.Service
Key = "AuditState",
Code = trialtype == TrialQCProcess.SingleAudit ? "AuditStatePE" : "AuditStateRC",
Type = "Code",
});
});
}
var jsonDataDic = JsonConvert.DeserializeObject<IDictionary<string, object>>(jsonStr);
@ -757,31 +757,80 @@ namespace IRaCIS.Core.Application.Service
if (item.DataType == "Table")
{
var tableConfigList= JsonConvert.DeserializeObject<List<TableConfig>>(item.TableConfigJsonStr) ?? new List<TableConfig>();
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();
//处理动态翻译 会在数组中提供 一个属性 “DictionaryCode” 这个是默认约束,做稽查的时候记得注意,免得配置麻烦
var dynamicTranslateInfoList = tableConfigList.Where(t => t.IsDynamicTranslate && t.IsList).Select(t => new { t.ListName, t.ColumnValue }).Distinct().ToList();
var dynamicDictionaryNameList = new List<string>();
foreach (var dynamicTranslateInfo in dynamicTranslateInfoList)
{
var tempNameList = arrays[0][dynamicTranslateInfo.ListName].Select(t => t["DictionaryCode"].ToString()).Where(t => !string.IsNullOrEmpty(t)).ToList();
dynamicDictionaryNameList.AddRange(tempNameList);
dynamicDictionaryNameList = dynamicDictionaryNameList.Distinct().ToList();
}
var allDictionaryNameList = dictionaryNameList.Union(dynamicDictionaryNameList).Distinct();
var searchList = await _dictionaryRepository.Where(t => allDictionaryNameList.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());
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();
}
//处理动态翻译
foreach (var dynamicTranslateInfo in dynamicTranslateInfoList)
{
var innerArrays = (JArray)jsonObject[dynamicTranslateInfo.ListName];
List<JObject> innberJsonList = new List<JObject>();
foreach (var innerItem in innerArrays)
{
var innerObject = JObject.Parse(innerItem.ToString());
var dicName = innerObject["DictionaryCode"]?.ToString();
if(dicName!=null && !string.IsNullOrEmpty(dicName))
{
innerObject[dynamicTranslateInfo.ColumnValue] = translateDataList[dicName].Where(t => t.Code.ToLower() == innerObject[dynamicTranslateInfo.ColumnValue].ToString().ToLower()).Select(t => t.ValueCN).FirstOrDefault();
}
innberJsonList.Add(innerObject);
}
jsonObject[dynamicTranslateInfo.ListName] = JToken.FromObject(innberJsonList) ;
}
jsonList.Add(jsonObject);
}
@ -832,18 +881,18 @@ namespace IRaCIS.Core.Application.Service
var jsonObject = JObject.Parse(arraysItem.ToString());
try
{
if (jsonObject["DictionaryCode"]!=null && jsonObject["DictionaryCode"].ToString() != string.Empty)
{
jsonObject[item.Code]= await _dictionaryRepository.Where(x => x.Code == jsonObject["DictionaryCode"].ToString()).Join(_dictionaryRepository.Where(x => x.Code == jsonObject[item.Code].ToString()), a => a.Id, b => b.ParentId, (a, b) => new
if (jsonObject["DictionaryCode"] != null && jsonObject["DictionaryCode"].ToString() != string.Empty)
{
value = b.ValueCN
}).Select(x => x.value).FirstOrDefaultAsync();
jsonObject[item.Code] = await _dictionaryRepository.Where(x => x.Code == jsonObject["DictionaryCode"].ToString()).Join(_dictionaryRepository.Where(x => x.Code == jsonObject[item.Code].ToString()), a => a.Id, b => b.ParentId, (a, b) => new
{
value = b.ValueCN
}).Select(x => x.value).FirstOrDefaultAsync();
}
jsonList.Add(jsonObject);
}
catch (Exception)
{
@ -874,7 +923,7 @@ namespace IRaCIS.Core.Application.Service
);
}
}
//翻译的是单个字段
else
{
@ -882,7 +931,7 @@ namespace IRaCIS.Core.Application.Service
if (item.Type.ToLower() == FrontAudit.Id.GetDescription().ToLower())
{
Guid guid = Guid.Parse(value.ToString());
jsonDataDic[item.Key] = await _dictionaryRepository.Where(x => x.Id== guid ).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())
{
@ -1037,10 +1086,10 @@ namespace IRaCIS.Core.Application.Service
var alllist = _frontAuditConfigRepository.Where(x => item.DataSourceGuids.Contains(x.ParentId)).ToList().GroupBy(x => new { x.ValueCN }, (key, lst) => new FrontAuditConfig
{
Sort = lst.Select(x => x.Sort).FirstOrDefault(),
TableConfigJsonStr= lst.Select(x => x.TableConfigJsonStr).FirstOrDefault(),
UrlConfigJsonStr=lst.Select(x => x.UrlConfigJsonStr).FirstOrDefault(),
TableConfigJsonStr = lst.Select(x => x.TableConfigJsonStr).FirstOrDefault(),
UrlConfigJsonStr = lst.Select(x => x.UrlConfigJsonStr).FirstOrDefault(),
IsShowByTrialConfig = lst.Select(x => x.IsShowByTrialConfig).FirstOrDefault(),
IsTableFiled= lst.Select(x => x.IsTableFiled).FirstOrDefault(),
IsTableFiled = lst.Select(x => x.IsTableFiled).FirstOrDefault(),
TableFiledName = lst.Select(x => x.TableFiledName).FirstOrDefault(),
TrialConfigRelyFieldName = lst.Select(x => x.TrialConfigRelyFieldName).FirstOrDefault(),
Code = lst.Max(x => x.Code),
@ -1193,10 +1242,10 @@ namespace IRaCIS.Core.Application.Service
DictionaryType = data.DictionaryType,
InterfaceName = data.InterfaceName,
IsTableFiled=data.IsTableFiled,
TableFiledName=data.TableFiledName,
UrlConfigJsonStr=data.UrlConfigJsonStr,
TableConfigJsonStr=data.TableConfigJsonStr,
IsTableFiled = data.IsTableFiled,
TableFiledName = data.TableFiledName,
UrlConfigJsonStr = data.UrlConfigJsonStr,
TableConfigJsonStr = data.TableConfigJsonStr,
};
query = query