From 47793b7c905f2bcdf8c2034d82a5415722c89a8f Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期二, 22 九月 2020 18:21:23 +0800
Subject: [PATCH] 升级oshi到最新版本v5.2.5

---
 src/main/java/com/ruoyi/common/utils/DictUtils.java |  105 ++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 81 insertions(+), 24 deletions(-)

diff --git a/src/main/java/com/ruoyi/common/utils/DictUtils.java b/src/main/java/com/ruoyi/common/utils/DictUtils.java
index 5e97f53..e3d3612 100644
--- a/src/main/java/com/ruoyi/common/utils/DictUtils.java
+++ b/src/main/java/com/ruoyi/common/utils/DictUtils.java
@@ -15,6 +15,11 @@
 public class DictUtils
 {
     /**
+     * 鍒嗛殧绗�
+     */
+    public static final String SEPARATOR = ",";
+
+    /**
      * 璁剧疆瀛楀吀缂撳瓨
      * 
      * @param key 鍙傛暟閿�
@@ -36,8 +41,8 @@
         Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key));
         if (StringUtils.isNotNull(cacheObj))
         {
-            List<SysDictData> DictDatas = StringUtils.cast(cacheObj);
-            return DictDatas;
+            List<SysDictData> dictDatas = StringUtils.cast(cacheObj);
+            return dictDatas;
         }
         return null;
     }
@@ -51,21 +56,7 @@
      */
     public static String getDictLabel(String dictType, String dictValue)
     {
-        if (StringUtils.isNotEmpty(dictType) && StringUtils.isNotEmpty(dictValue))
-        {
-            List<SysDictData> datas = getDictCache(dictType);
-            if (StringUtils.isNotEmpty(datas))
-            {
-                for (SysDictData dict : datas)
-                {
-                    if (dictValue.equals(dict.getDictValue()))
-                    {
-                        return dict.getDictLabel();
-                    }
-                }
-            }
-        }
-        return dictValue;
+        return getDictLabel(dictType, dictValue, SEPARATOR);
     }
 
     /**
@@ -77,21 +68,87 @@
      */
     public static String getDictValue(String dictType, String dictLabel)
     {
-        if (StringUtils.isNotEmpty(dictType) && StringUtils.isNotEmpty(dictLabel))
+        return getDictValue(dictType, dictLabel, SEPARATOR);
+    }
+
+    /**
+     * 鏍规嵁瀛楀吀绫诲瀷鍜屽瓧鍏稿�艰幏鍙栧瓧鍏告爣绛�
+     * 
+     * @param dictType 瀛楀吀绫诲瀷
+     * @param dictValue 瀛楀吀鍊�
+     * @param separator 鍒嗛殧绗�
+     * @return 瀛楀吀鏍囩
+     */
+    public static String getDictLabel(String dictType, String dictValue, String separator)
+    {
+        StringBuilder propertyString = new StringBuilder();
+        List<SysDictData> datas = getDictCache(dictType);
+
+        if (StringUtils.containsAny(separator, dictValue) && StringUtils.isNotEmpty(datas))
         {
-            List<SysDictData> datas = getDictCache(dictType);
-            if (StringUtils.isNotEmpty(datas))
+            for (SysDictData dict : datas)
             {
-                for (SysDictData dict : datas)
+                for (String value : dictValue.split(separator))
                 {
-                    if (dictLabel.equals(dict.getDictLabel()))
+                    if (value.equals(dict.getDictValue()))
                     {
-                        return dict.getDictValue();
+                        propertyString.append(dict.getDictLabel() + separator);
+                        break;
                     }
                 }
             }
         }
-        return dictLabel;
+        else
+        {
+            for (SysDictData dict : datas)
+            {
+                if (dictValue.equals(dict.getDictValue()))
+                {
+                    return dict.getDictLabel();
+                }
+            }
+        }
+        return StringUtils.stripEnd(propertyString.toString(), separator);
+    }
+
+    /**
+     * 鏍规嵁瀛楀吀绫诲瀷鍜屽瓧鍏告爣绛捐幏鍙栧瓧鍏稿��
+     * 
+     * @param dictType 瀛楀吀绫诲瀷
+     * @param dictLabel 瀛楀吀鏍囩
+     * @param separator 鍒嗛殧绗�
+     * @return 瀛楀吀鍊�
+     */
+    public static String getDictValue(String dictType, String dictLabel, String separator)
+    {
+        StringBuilder propertyString = new StringBuilder();
+        List<SysDictData> datas = getDictCache(dictType);
+
+        if (StringUtils.containsAny(separator, dictLabel) && StringUtils.isNotEmpty(datas))
+        {
+            for (SysDictData dict : datas)
+            {
+                for (String label : dictLabel.split(separator))
+                {
+                    if (label.equals(dict.getDictLabel()))
+                    {
+                        propertyString.append(dict.getDictValue() + separator);
+                        break;
+                    }
+                }
+            }
+        }
+        else
+        {
+            for (SysDictData dict : datas)
+            {
+                if (dictLabel.equals(dict.getDictLabel()))
+                {
+                    return dict.getDictValue();
+                }
+            }
+        }
+        return StringUtils.stripEnd(propertyString.toString(), separator);
     }
 
     /**

--
Gitblit v1.9.3