feature:#EQD-7093 国联民生-交易确认书校验(2)针对ETF标的获取新增信息并且支持配置分类。 ETF交易确认书中填充参考标的证券全称、参考标的基金管理人,
This commit is contained in:
@@ -423,6 +423,8 @@ namespace YLErp.Modules.AppModule
|
||||
|
||||
var exists = adminDb.Dictionaries.Select(n => n.Name).ToArray()
|
||||
.Select(n => n.Trim()).ToHashSet();
|
||||
// 记录本次新建的字典,确保初始项只写入一次,不覆盖后续人工维护结果。
|
||||
var addedDictionaryNames = new HashSet<string>();
|
||||
|
||||
var root = XElement.Parse(YLErp.Resources.Properties.Resources.db_dictionaries);
|
||||
var itemsAll = root.Elements();
|
||||
@@ -450,10 +452,51 @@ namespace YLErp.Modules.AppModule
|
||||
Name = name,
|
||||
Catalog = catalog
|
||||
});
|
||||
addedDictionaryNames.Add(name);
|
||||
}
|
||||
|
||||
adminDb.SaveChanges();
|
||||
|
||||
// 重点功能:解析 XML 中的初始项,仅为本次首次创建的字典生成 DictionaryItem。
|
||||
foreach (var dictionaryElement in itemsAll.Where(item =>
|
||||
item.Elements().Any() && addedDictionaryNames.Contains(item.Attribute("name")?.Value.TrimToEmpty())))
|
||||
{
|
||||
var dictionaryName = dictionaryElement.Attribute("name")?.Value.TrimToNull();
|
||||
var dictionary = adminDb.Dictionaries.FirstOrDefault(item => item.Name == dictionaryName);
|
||||
if (dictionary == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var existingItemNames = adminDb.DictionaryItems
|
||||
.Where(item => item.DictId == dictionary.Id)
|
||||
.Select(item => item.Name)
|
||||
.ToHashSet();
|
||||
var nextDictionaryItemIndex = adminDb.DictionaryItems
|
||||
.Where(item => item.DictId == dictionary.Id)
|
||||
.Max(item => (int?)item.IndexNum) ?? -1;
|
||||
|
||||
// XML 中的排列顺序写入 IndexNum,页面下拉按该顺序展示。
|
||||
foreach (var itemElement in dictionaryElement.Elements())
|
||||
{
|
||||
var itemName = itemElement.Attribute("name")?.Value.TrimToNull();
|
||||
if (itemName == null || existingItemNames.Contains(itemName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
adminDb.DictionaryItems.Add(new BaseOUDAL.DictionaryItem
|
||||
{
|
||||
DictId = dictionary.Id,
|
||||
Name = itemName,
|
||||
ShortName = itemElement.Attribute("short_name")?.Value.TrimToNull() ?? itemName,
|
||||
IndexNum = ++nextDictionaryItemIndex
|
||||
});
|
||||
existingItemNames.Add(itemName);
|
||||
}
|
||||
}
|
||||
adminDb.SaveChanges();
|
||||
|
||||
var marginTemplateDictionary = adminDb.Dictionaries.FirstOrDefault(item => item.Name == YLErp.Modules.SwapModule.SwapMarginTemplateConfigService.DictionaryName);
|
||||
if (marginTemplateDictionary == null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user