From 41a5531dc31a642623f0a7a766fbe9c256ba9247 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期二, 11 二月 2025 13:53:29 +0800
Subject: [PATCH] 优化WMS前端
---
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_SystemRepository/Sys_DictionaryRepository.cs | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 103 insertions(+), 0 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_SystemRepository/Sys_DictionaryRepository.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_SystemRepository/Sys_DictionaryRepository.cs"
index a235134..80ce9c2 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_SystemRepository/Sys_DictionaryRepository.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_SystemRepository/Sys_DictionaryRepository.cs"
@@ -5,9 +5,12 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
+using WIDESEA_DTO.System;
using WIDESEA_ISystemRepository;
using WIDESEA_Model.Models;
+using WIDESEA_Model.Models.System;
namespace WIDESEA_SystemRepository
{
@@ -19,6 +22,106 @@
{
}
+ public class SourceKeyVaule
+ {
+ public int id { get; set; }
+ public int parentId { get; set; }
+ public string DicName { get; set; }
+ public int DicValue { get; set; }
+ }
+ public IEnumerable<VueDictionaryDTO> GetDictionaries(IEnumerable<string> dicNos, List<RoleNodes> roleNodes, bool executeSql = true)
+ {
+ List<Sys_Dictionary> Dictionaries = GetAllDictionary();
+ List<VueDictionaryDTO> DictionaryDTO = new List<VueDictionaryDTO>();
+
+
+ foreach (var item in Dictionaries.Where(x => dicNos.Contains(x.DicNo)))
+ {
+ VueDictionaryDTO dictionaryDTO = new VueDictionaryDTO();
+ dictionaryDTO.DicNo = item.DicNo;
+ dictionaryDTO.Config = item.Config;
+ dictionaryDTO.Data = item.DicList.OrderByDescending(o => o.OrderNo).Select(list => new { key = list.DicValue, value = list.DicName });
+ if (executeSql)
+ {
+ // 2020.05.01澧炲姞鏍规嵁鐢ㄦ埛淇℃伅鍔犺浇瀛楀吀鏁版嵁婧恠ql
+ string sql = item.Sql;
+ if (!string.IsNullOrEmpty(sql))
+ {
+ dictionaryDTO.Data = item.DicNo == "tree_roles" ?
+ QueryRole(GetCustomDBSql(item.DicNo, sql, roleNodes)).OrderBy(x => x.id).Select(list => new { id = list.id, parentId = list.parentId, key = list.DicValue, value = list.DicName }) : Query(GetCustomDBSql(item.DicNo, sql, roleNodes)).OrderByDescending(o => o.OrderNo).Select(list => new { key = list.DicValue, value = list.DicName });
+ }
+ }
+ DictionaryDTO.Add(dictionaryDTO);
+ }
+ return DictionaryDTO;
+ }
+ List<SourceKeyVaule> QueryRole(string sql)
+ {
+ try
+ {
+ return base.QueryDynamicDataBySql(sql, null).Select(s => new SourceKeyVaule()
+ {
+ id = s.id,
+ parentId = s.parentId,
+ DicName = s.value,
+ DicValue = s.key
+ }).ToList();
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ }
+ /// <summary>
+ /// 鑾峰彇鑷畾涔夋暟鎹簮sql
+ /// </summary>
+ /// <param name="dicNo"></param>
+ /// <param name="originalSql"></param>
+ /// <returns></returns>
+ public static string GetCustomDBSql(string dicNo, string originalSql, List<RoleNodes> roleNodes)
+ {
+ switch (dicNo)
+ {
+ case "roles":
+ //2020.05.24澧炲姞缁戝畾table琛ㄦ椂锛岃幏鍙栨墍鏈夌殑瑙掕壊鍒楄〃
+ //娉ㄦ剰锛屽鏋滄槸2020.05.24涔嬪墠鑾峰彇鐨勬暟鎹簱鑴氭湰
+ //璇峰湪鑿滃崟銆愪笅鎷夋缁戝畾璁剧疆銆戞坊鍔犱竴涓瓧鍏哥紪鍙枫�恡_roles銆�,闄や簡瀛楀吀缂栧彿锛屽叾浠栧唴瀹归殢渚垮~鍐�
+ case "t_roles":
+ case "tree_roles":
+ originalSql = GetRolesSql(originalSql, roleNodes);
+ break;
+ default:
+ break;
+ }
+ return originalSql;
+ }
+
+ /// <summary>
+ /// 鑾峰彇瑙e喅鐨勬暟鎹簮锛屽彧鑳界湅鍒拌嚜宸变笌涓嬬骇鎵�鏈夎鑹�
+ /// </summary>
+ /// <param name="context"></param>
+ /// <param name="originalSql"></param>
+ /// <returns></returns>
+ public static string GetRolesSql(string originalSql, List<RoleNodes> roleNodes)
+ {
+ if (App.User.IsSuperAdmin)
+ {
+ return originalSql;
+ }
+
+ var RoleNodes = roleNodes.Where(x => x.Id == App.User.RoleId)
+ .Select(s => new RoleNodes()
+ {
+ Id = s.Id,
+ ParentId = 0,//灏嗚嚜宸辩殑瑙掕壊浣滀负root鑺傜偣
+ RoleName = s.RoleName
+ }).ToList();
+ List<int> roleIds = roleNodes.Select(x => x.Id).ToList();
+ //roleIds.Add(App.User.RoleId);
+
+ return originalSql = $@"SELECT RoleId as 'key',RoleId AS id,ParentId AS parentId,RoleName as 'value' FROM Sys_Role
+ WHERE Enable=1 and RoleId in ({string.Join(',', roleIds)})";
+ }
/// <summary>
///
--
Gitblit v1.9.3