@@ -131,7 +131,8 @@ namespace Learun.Application.Base.SystemModule
/// <param name="keyValue">主键</param>
/// <param name="itemCode">编码</param>
/// <returns></returns>
public bool ExistItemCode(string keyValue, string itemCode) {
public bool ExistItemCode(string keyValue, string itemCode)
{
try
{
bool res = false;
@@ -199,7 +200,8 @@ namespace Learun.Application.Base.SystemModule
/// </summary>
/// <param name="keyValue">主键</param>
/// <param name="entity">实体</param>
public void SaveClassifyEntity(string keyValue, DataItemEntity entity) {
public void SaveClassifyEntity(string keyValue, DataItemEntity entity)
{
try
{
dataItemService.SaveClassifyEntity(keyValue, entity);
@@ -279,7 +281,7 @@ namespace Learun.Application.Base.SystemModule
try
{
List<DataItemDetailEntity> list = cache.Read<List<DataItemDetailEntity>>(cacheKeyDetail + itemCode, CacheId.dataItem);
if (list?.Count==0 || list==null)
if (list?.Count == 0 || list == null)
{
list = (List<DataItemDetailEntity>)dataItemService.GetDetailList(itemCode);
cache.Write<List<DataItemDetailEntity>>(cacheKeyDetail + itemCode, list, CacheId.dataItem);
@@ -298,12 +300,35 @@ namespace Learun.Application.Base.SystemModule
}
}
}
/// <summary>
/// 获取数据字典明显
/// </summary>
/// <param name="itemCode">分类编码</param>
/// <returns></returns>
public List<DataItemDetailEntity> GetDetailList2(string itemCode)
{
try
{
List<DataItemDetailEntity> list = (List<DataItemDetailEntity>)dataItemService.GetDetailList2(itemCode);
return list;
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
public IEnumerable<DataItemDetailEntity> GetAllDetailList()
{
try
{
return dataItemService.GetAllDetailList();
return dataItemService.GetAllDetailList();
}
catch (Exception ex)
{
@@ -322,20 +347,24 @@ namespace Learun.Application.Base.SystemModule
/// 获取数据字典详细映射数据
/// </summary>
/// <returns></returns>
public Dictionary<string, Dictionary<string,DataItemModel>> GetModelMap()
public Dictionary<string, Dictionary<string, DataItemModel>> GetModelMap()
{
try
{
Dictionary<string, Dictionary<string,DataItemModel>> dic = cache.Read<Dictionary<string, Dictionary<string,DataItemModel>>>(cacheKeyDetail + "dic", CacheId.dataItem);
if (dic == null) {
dic = new Dictionary<string, Dictionary<string,DataItemModel>>();
Dictionary<string, Dictionary<string, DataItemModel>> dic = cache.Read<Dictionary<string, Dictionary<string, DataItemModel>>>(cacheKeyDetail + "dic", CacheId.dataItem);
if (dic == null)
{
dic = new Dictionary<string, Dictionary<string, DataItemModel>>();
var list = GetClassifyList();
foreach (var item in list) {
foreach (var item in list)
{
var detailList = GetDetailList(item.F_ItemCode);
if (!dic.ContainsKey(item.F_ItemCode)) {
dic.Add(item.F_ItemCode,new Dictionary<string,DataItemModel>());
if (!dic.ContainsKey(item.F_ItemCode))
{
dic.Add(item.F_ItemCode, new Dictionary<string, DataItemModel>());
}
foreach (var detailItem in detailList) {
foreach (var detailItem in detailList)
{
dic[item.F_ItemCode].Add(detailItem.F_ItemDetailId, new DataItemModel()
{
parentId = detailItem.F_ParentId,
@@ -373,7 +402,37 @@ namespace Learun.Application.Base.SystemModule
try
{
List<DataItemDetailEntity> list = GetDetailList(itemCode);
if (!string.IsNullOrEmpty(keyword)) {
if (!string.IsNullOrEmpty(keyword))
{
list = list.FindAll(t => t.F_ItemName.Contains(keyword) || t.F_ItemValue.Contains(keyword));
}
return list;
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
/// <summary>
/// 获取数据字典明显
/// </summary>
/// <param name="itemCode">分类编码</param>
/// <param name="keyword">关键词(名称/值)</param>
/// <returns></returns>
public List<DataItemDetailEntity> GetDetailList2(string itemCode, string keyword)
{
try
{
List<DataItemDetailEntity> list = GetDetailList2(itemCode);
if (!string.IsNullOrEmpty(keyword))
{
list = list.FindAll(t => t.F_ItemName.Contains(keyword) || t.F_ItemValue.Contains(keyword));
}
return list;
@@ -435,7 +494,8 @@ namespace Learun.Application.Base.SystemModule
{
List<DataItemDetailEntity> list = GetDetailList(itemCode);
List<TreeModel> treeList = new List<TreeModel>();
foreach (var item in list) {
foreach (var item in list)
{
TreeModel node = new TreeModel();
node.id = item.F_ItemDetailId;
node.text = item.F_ItemName;