Ver Fonte

完善工具类和基础设置

yq há 3 anos atrás
pai
commit
c4b0bcecf8
31 ficheiros alterados com 530 adições e 701 exclusões
  1. 1 1
      fiveep-common/fiveep-common-core/src/main/java/com/bizmatics/common/core/util/Arith.java
  2. 1 1
      fiveep-common/fiveep-common-core/src/main/java/com/bizmatics/common/core/util/FileUtils.java
  3. 5 5
      fiveep-common/fiveep-common-core/src/main/java/com/bizmatics/common/core/util/IdUtils.java
  4. 448 46
      fiveep-common/fiveep-common-core/src/main/java/com/bizmatics/common/core/util/UUIDUtils.java
  5. 38 2
      fiveep-common/fiveep-common-spring/src/main/java/com/bizmatics/common/spring/util/ThreadUtils.java
  6. 1 1
      fiveep-controller/src/main/java/com/bizmatics/controller/web/system/CaptchaController.java
  7. 1 1
      fiveep-controller/src/main/java/com/bizmatics/controller/web/system/SysLoginController.java
  8. 1 1
      fiveep-controller/src/main/java/com/bizmatics/controller/web/system/SysMenuController.java
  9. 1 1
      fiveep-controller/src/main/java/com/bizmatics/controller/web/system/SysProfileController.java
  10. 1 1
      fiveep-controller/src/main/java/com/bizmatics/controller/web/system/SysRoleController.java
  11. 1 1
      fiveep-service/src/main/java/com/bizmatics/service/aop/DataScopeAspect.java
  12. 1 1
      fiveep-service/src/main/java/com/bizmatics/service/config/PermissionService.java
  13. 3 2
      fiveep-service/src/main/java/com/bizmatics/service/config/ThreadPoolConfig.java
  14. 1 1
      fiveep-service/src/main/java/com/bizmatics/service/config/security/LoginUser.java
  15. 0 1
      fiveep-service/src/main/java/com/bizmatics/service/config/security/UserDetailsServiceImpl.java
  16. 1 1
      fiveep-service/src/main/java/com/bizmatics/service/config/security/filter/JwtAuthenticationTokenFilter.java
  17. 1 1
      fiveep-service/src/main/java/com/bizmatics/service/config/security/handle/LogoutSuccessHandlerImpl.java
  18. 0 19
      fiveep-service/src/main/java/com/bizmatics/service/enums/DataSourceType.java
  19. 2 2
      fiveep-service/src/main/java/com/bizmatics/service/impl/HadSiteStaticServiceImpl.java
  20. 1 1
      fiveep-service/src/main/java/com/bizmatics/service/impl/HtAnalogDataServiceImpl.java
  21. 1 1
      fiveep-service/src/main/java/com/bizmatics/service/impl/RtAnalogDataServiceImpl.java
  22. 1 1
      fiveep-service/src/main/java/com/bizmatics/service/job/RatAnalogTask.java
  23. 1 1
      fiveep-service/src/main/java/com/bizmatics/service/system/ISysUserOnlineService.java
  24. 1 1
      fiveep-service/src/main/java/com/bizmatics/service/system/impl/SysLoginService.java
  25. 1 1
      fiveep-service/src/main/java/com/bizmatics/service/system/impl/SysUserOnlineServiceImpl.java
  26. 2 2
      fiveep-service/src/main/java/com/bizmatics/service/system/impl/TokenService.java
  27. 0 18
      fiveep-service/src/main/java/com/bizmatics/service/util/LogUtils.java
  28. 1 0
      fiveep-service/src/main/java/com/bizmatics/service/util/SecurityUtils.java
  29. 0 96
      fiveep-service/src/main/java/com/bizmatics/service/util/Threads.java
  30. 0 485
      fiveep-service/src/main/java/com/bizmatics/service/util/UUID.java
  31. 13 5
      fiveep-service/src/main/java/com/bizmatics/service/util/manager/factory/AsyncFactory.java

+ 1 - 1
fiveep-service/src/main/java/com/bizmatics/service/util/Arith.java → fiveep-common/fiveep-common-core/src/main/java/com/bizmatics/common/core/util/Arith.java

@@ -1,4 +1,4 @@
-package com.bizmatics.service.util;
+package com.bizmatics.common.core.util;
 
 import java.math.BigDecimal;
 

+ 1 - 1
fiveep-common/fiveep-common-core/src/main/java/com/bizmatics/common/core/util/FileUtils.java

@@ -277,7 +277,7 @@ public final class FileUtils extends org.apache.commons.io.FileUtils {
                 }
 
                 if (!StringUtils.isBlank(fileType)) {
-                    remoteFileName = String.format("%s%s%s.%s", localDirPath, File.separator, UUIDUtils.shortUUID(), fileType);
+                    remoteFileName = String.format("%s%s%s.%s", localDirPath, File.separator, UUIDUtils.fastUUID().toString(), fileType);
                 }
             }
 

+ 5 - 5
fiveep-service/src/main/java/com/bizmatics/service/util/IdUtils.java → fiveep-common/fiveep-common-core/src/main/java/com/bizmatics/common/core/util/IdUtils.java

@@ -1,4 +1,4 @@
-package com.bizmatics.service.util;
+package com.bizmatics.common.core.util;
 
 
 /**
@@ -15,7 +15,7 @@ public class IdUtils
      */
     public static String randomUUID()
     {
-        return UUID.randomUUID().toString();
+        return UUIDUtils.randomUUID().toString();
     }
 
     /**
@@ -25,7 +25,7 @@ public class IdUtils
      */
     public static String simpleUUID()
     {
-        return UUID.randomUUID().toString();
+        return UUIDUtils.randomUUID().toString();
     }
 
     /**
@@ -35,7 +35,7 @@ public class IdUtils
      */
     public static String fastUUID()
     {
-        return UUID.fastUUID().toString();
+        return UUIDUtils.fastUUID().toString();
     }
 
     /**
@@ -45,6 +45,6 @@ public class IdUtils
      */
     public static String fastSimpleUUID()
     {
-        return UUID.fastUUID().toString(true);
+        return UUIDUtils.fastUUID().toString(true);
     }
 }

+ 448 - 46
fiveep-common/fiveep-common-core/src/main/java/com/bizmatics/common/core/util/UUIDUtils.java

@@ -1,86 +1,488 @@
 package com.bizmatics.common.core.util;
 
-import org.apache.commons.lang3.StringUtils;
+import com.bizmatics.common.core.exception.BusinessException;
 
-import java.util.UUID;
-import java.util.stream.IntStream;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.util.Random;
+import java.util.concurrent.ThreadLocalRandom;
 
 /**
- * <p>UUID 工具类</p>
+ * 提供通用唯一识别码(universally unique identifier)(UUID)实现
  *
- * @author chenpeng
- * Create at February 11, 2019 at 17:49:24 GMT+8
+ * @author ruoyi
  */
-public final class UUIDUtils {
+public final class UUIDUtils implements java.io.Serializable, Comparable<UUIDUtils>
+{
+    private static final long serialVersionUID = -1185015143654744140L;
 
     /**
-     * 16 进制
+     * SecureRandom 的单例
+     *
      */
-    private static final int HEXADECIMAL = 16;
+    private static class Holder
+    {
+        static final SecureRandom numberGenerator = getSecureRandom();
+    }
+
+    /** 此UUID的最高64有效位 */
+    private final long mostSigBits;
+
+    /** 此UUID的最低64有效位 */
+    private final long leastSigBits;
+
     /**
-     * 短 uuid 默认长度
+     * 私有构造
+     * 
+     * @param data 数据
      */
-    private static final int SHORT_UUID_LENGTH = 8;
+    private UUIDUtils(byte[] data)
+    {
+        long msb = 0;
+        long lsb = 0;
+        assert data.length == 16 : "data must be 16 bytes in length";
+        for (int i = 0; i < 8; i++)
+        {
+            msb = (msb << 8) | (data[i] & 0xff);
+        }
+        for (int i = 8; i < 16; i++)
+        {
+            lsb = (lsb << 8) | (data[i] & 0xff);
+        }
+        this.mostSigBits = msb;
+        this.leastSigBits = lsb;
+    }
+
     /**
-     * 字符表
+     * 使用指定的数据构造新的 UUID。
+     *
+     * @param mostSigBits 用于 {@code UUID} 的最高有效 64 位
+     * @param leastSigBits 用于 {@code UUID} 的最低有效 64 位
      */
-    private static final String[] CODES = new String[]{"a", "b", "c", "d", "e", "f",
-            "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
-            "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5",
-            "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I",
-            "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
-            "W", "X", "Y", "Z"};
+    public UUIDUtils(long mostSigBits, long leastSigBits)
+    {
+        this.mostSigBits = mostSigBits;
+        this.leastSigBits = leastSigBits;
+    }
+
+    /**
+     * 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的本地线程伪随机数生成器生成该 UUID。
+     * 
+     * @return 随机生成的 {@code UUID}
+     */
+    public static UUIDUtils fastUUID()
+    {
+        return randomUUID(false);
+    }
+
     /**
-     * 字符表长度
+     * 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的强伪随机数生成器生成该 UUID。
+     * 
+     * @return 随机生成的 {@code UUID}
      */
-    private static final int CODES_LENTH = CODES.length;
+    public static UUIDUtils randomUUID()
+    {
+        return randomUUID(true);
+    }
+
     /**
-     * UUID 分隔符
+     * 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的强伪随机数生成器生成该 UUID。
+     * 
+     * @param isSecure 是否使用{@link SecureRandom}如果是可以获得更安全的随机码,否则可以得到更好的性能
+     * @return 随机生成的 {@code UUID}
      */
-    private static final String UUID_SEPARATOR = "-";
+    public static UUIDUtils randomUUID(boolean isSecure)
+    {
+        final Random ng = isSecure ? Holder.numberGenerator : getRandom();
 
-    private UUIDUtils() {
+        byte[] randomBytes = new byte[16];
+        ng.nextBytes(randomBytes);
+        randomBytes[6] &= 0x0f; /* clear version */
+        randomBytes[6] |= 0x40; /* set to version 4 */
+        randomBytes[8] &= 0x3f; /* clear variant */
+        randomBytes[8] |= 0x80; /* set to IETF variant */
+        return new UUIDUtils(randomBytes);
     }
 
     /**
-     * 获得 uuid,默认不带分隔符 “-”
+     * 根据指定的字节数组获取类型 3(基于名称的)UUID 的静态工厂。
+     *
+     * @param name 用于构造 UUID 的字节数组。
+     *
+     * @return 根据指定数组生成的 {@code UUID}
      */
-    public static String uuid() {
-        return uuid(true);
+    public static UUIDUtils nameUUIDFromBytes(byte[] name)
+    {
+        MessageDigest md;
+        try
+        {
+            md = MessageDigest.getInstance("MD5");
+        }
+        catch (NoSuchAlgorithmException nsae)
+        {
+            throw new InternalError("MD5 not supported");
+        }
+        byte[] md5Bytes = md.digest(name);
+        md5Bytes[6] &= 0x0f; /* clear version */
+        md5Bytes[6] |= 0x30; /* set to version 3 */
+        md5Bytes[8] &= 0x3f; /* clear variant */
+        md5Bytes[8] |= 0x80; /* set to IETF variant */
+        return new UUIDUtils(md5Bytes);
     }
 
     /**
-     * 通过给定参数指定返回 uuid 是否带有分隔符
+     * 根据 {@link #toString()} 方法中描述的字符串标准表示形式创建{@code UUID}。
+     *
+     * @param name 指定 {@code UUID} 字符串
+     * @return 具有指定值的 {@code UUID}
+     * @throws IllegalArgumentException 如果 name 与 {@link #toString} 中描述的字符串表示形式不符抛出此异常
      *
-     * @param withoutSeparator 是否带分隔符
-     * @return String
      */
-    public static String uuid(boolean withoutSeparator) {
-        String uuid = UUID.randomUUID().toString();
-        if (withoutSeparator) {
-            uuid = uuid.replaceAll(UUID_SEPARATOR, StringUtils.EMPTY);
+    public static UUIDUtils fromString(String name)
+    {
+        String[] components = name.split("-");
+        if (components.length != 5)
+        {
+            throw new IllegalArgumentException("Invalid UUID string: " + name);
         }
-        return uuid;
+        for (int i = 0; i < 5; i++)
+        {
+            components[i] = "0x" + components[i];
+        }
+
+        long mostSigBits = Long.decode(components[0]).longValue();
+        mostSigBits <<= 16;
+        mostSigBits |= Long.decode(components[1]).longValue();
+        mostSigBits <<= 16;
+        mostSigBits |= Long.decode(components[2]).longValue();
+
+        long leastSigBits = Long.decode(components[3]).longValue();
+        leastSigBits <<= 48;
+        leastSigBits |= Long.decode(components[4]).longValue();
+
+        return new UUIDUtils(mostSigBits, leastSigBits);
+    }
+
+    /**
+     * 返回此 UUID 的 128 位值中的最低有效 64 位。
+     *
+     * @return 此 UUID 的 128 位值中的最低有效 64 位。
+     */
+    public long getLeastSignificantBits()
+    {
+        return leastSigBits;
     }
 
     /**
-     * 获取短 uuid
+     * 返回此 UUID 的 128 位值中的最高有效 64 位。
      *
-     * @return String
+     * @return 此 UUID 的 128 位值中最高有效 64 位。
      */
-    public static String shortUUID() {
+    public long getMostSignificantBits()
+    {
+        return mostSigBits;
+    }
 
-        StringBuilder shortUUID = new StringBuilder();
+    /**
+     * 与此 {@code UUID} 相关联的版本号. 版本号描述此 {@code UUID} 是如何生成的。
+     * <p>
+     * 版本号具有以下含意:
+     * <ul>
+     * <li>1 基于时间的 UUID
+     * <li>2 DCE 安全 UUID
+     * <li>3 基于名称的 UUID
+     * <li>4 随机生成的 UUID
+     * </ul>
+     *
+     * @return 此 {@code UUID} 的版本号
+     */
+    public int version()
+    {
+        // Version is bits masked by 0x000000000000F000 in MS long
+        return (int) ((mostSigBits >> 12) & 0x0f);
+    }
 
-        String uuid = uuid();
-        int step = uuid.length() / SHORT_UUID_LENGTH;
+    /**
+     * 与此 {@code UUID} 相关联的变体号。变体号描述 {@code UUID} 的布局。
+     * <p>
+     * 变体号具有以下含意:
+     * <ul>
+     * <li>0 为 NCS 向后兼容保留
+     * <li>2 <a href="http://www.ietf.org/rfc/rfc4122.txt">IETF&nbsp;RFC&nbsp;4122</a>(Leach-Salz), 用于此类
+     * <li>6 保留,微软向后兼容
+     * <li>7 保留供以后定义使用
+     * </ul>
+     *
+     * @return 此 {@code UUID} 相关联的变体号
+     */
+    public int variant()
+    {
+        // This field is composed of a varying number of bits.
+        // 0 - - Reserved for NCS backward compatibility
+        // 1 0 - The IETF aka Leach-Salz variant (used by this class)
+        // 1 1 0 Reserved, Microsoft backward compatibility
+        // 1 1 1 Reserved for future definition.
+        return (int) ((leastSigBits >>> (64 - (leastSigBits >>> 62))) & (leastSigBits >> 63));
+    }
+
+    /**
+     * 与此 UUID 相关联的时间戳值。
+     *
+     * <p>
+     * 60 位的时间戳值根据此 {@code UUID} 的 time_low、time_mid 和 time_hi 字段构造。<br>
+     * 所得到的时间戳以 100 毫微秒为单位,从 UTC(通用协调时间) 1582 年 10 月 15 日零时开始。
+     *
+     * <p>
+     * 时间戳值仅在在基于时间的 UUID(其 version 类型为 1)中才有意义。<br>
+     * 如果此 {@code UUID} 不是基于时间的 UUID,则此方法抛出 UnsupportedOperationException。
+     *
+     * @throws UnsupportedOperationException 如果此 {@code UUID} 不是 version 为 1 的 UUID。
+     */
+    public long timestamp() throws UnsupportedOperationException
+    {
+        checkTimeBase();
+        return (mostSigBits & 0x0FFFL) << 48//
+                | ((mostSigBits >> 16) & 0x0FFFFL) << 32//
+                | mostSigBits >>> 32;
+    }
 
-        IntStream.range(0, SHORT_UUID_LENGTH).forEach(i -> {
-            String temp = uuid.substring(i * step, i * step + step);
-            int value = Integer.parseInt(temp, HEXADECIMAL);
-            shortUUID.append(CODES[value % CODES_LENTH]);
-        });
+    /**
+     * 与此 UUID 相关联的时钟序列值。
+     *
+     * <p>
+     * 14 位的时钟序列值根据此 UUID 的 clock_seq 字段构造。clock_seq 字段用于保证在基于时间的 UUID 中的时间唯一性。
+     * <p>
+     * {@code clockSequence} 值仅在基于时间的 UUID(其 version 类型为 1)中才有意义。 如果此 UUID 不是基于时间的 UUID,则此方法抛出
+     * UnsupportedOperationException。
+     *
+     * @return 此 {@code UUID} 的时钟序列
+     *
+     * @throws UnsupportedOperationException 如果此 UUID 的 version 不为 1
+     */
+    public int clockSequence() throws UnsupportedOperationException
+    {
+        checkTimeBase();
+        return (int) ((leastSigBits & 0x3FFF000000000000L) >>> 48);
+    }
 
-        return shortUUID.toString();
+    /**
+     * 与此 UUID 相关的节点值。
+     *
+     * <p>
+     * 48 位的节点值根据此 UUID 的 node 字段构造。此字段旨在用于保存机器的 IEEE 802 地址,该地址用于生成此 UUID 以保证空间唯一性。
+     * <p>
+     * 节点值仅在基于时间的 UUID(其 version 类型为 1)中才有意义。<br>
+     * 如果此 UUID 不是基于时间的 UUID,则此方法抛出 UnsupportedOperationException。
+     *
+     * @return 此 {@code UUID} 的节点值
+     *
+     * @throws UnsupportedOperationException 如果此 UUID 的 version 不为 1
+     */
+    public long node() throws UnsupportedOperationException
+    {
+        checkTimeBase();
+        return leastSigBits & 0x0000FFFFFFFFFFFFL;
     }
+
+    /**
+     * 返回此{@code UUID} 的字符串表现形式。
+     *
+     * <p>
+     * UUID 的字符串表示形式由此 BNF 描述:
+     * 
+     * <pre>
+     * {@code
+     * UUID                   = <time_low>-<time_mid>-<time_high_and_version>-<variant_and_sequence>-<node>
+     * time_low               = 4*<hexOctet>
+     * time_mid               = 2*<hexOctet>
+     * time_high_and_version  = 2*<hexOctet>
+     * variant_and_sequence   = 2*<hexOctet>
+     * node                   = 6*<hexOctet>
+     * hexOctet               = <hexDigit><hexDigit>
+     * hexDigit               = [0-9a-fA-F]
+     * }
+     * </pre>
+     * 
+     * </blockquote>
+     *
+     * @return 此{@code UUID} 的字符串表现形式
+     * @see #toString(boolean)
+     */
+    @Override
+    public String toString()
+    {
+        return toString(false);
+    }
+
+    /**
+     * 返回此{@code UUID} 的字符串表现形式。
+     *
+     * <p>
+     * UUID 的字符串表示形式由此 BNF 描述:
+     * 
+     * <pre>
+     * {@code
+     * UUID                   = <time_low>-<time_mid>-<time_high_and_version>-<variant_and_sequence>-<node>
+     * time_low               = 4*<hexOctet>
+     * time_mid               = 2*<hexOctet>
+     * time_high_and_version  = 2*<hexOctet>
+     * variant_and_sequence   = 2*<hexOctet>
+     * node                   = 6*<hexOctet>
+     * hexOctet               = <hexDigit><hexDigit>
+     * hexDigit               = [0-9a-fA-F]
+     * }
+     * </pre>
+     * 
+     * </blockquote>
+     *
+     * @param isSimple 是否简单模式,简单模式为不带'-'的UUID字符串
+     * @return 此{@code UUID} 的字符串表现形式
+     */
+    public String toString(boolean isSimple)
+    {
+        final StringBuilder builder = new StringBuilder(isSimple ? 32 : 36);
+        // time_low
+        builder.append(digits(mostSigBits >> 32, 8));
+        if (false == isSimple)
+        {
+            builder.append('-');
+        }
+        // time_mid
+        builder.append(digits(mostSigBits >> 16, 4));
+        if (false == isSimple)
+        {
+            builder.append('-');
+        }
+        // time_high_and_version
+        builder.append(digits(mostSigBits, 4));
+        if (false == isSimple)
+        {
+            builder.append('-');
+        }
+        // variant_and_sequence
+        builder.append(digits(leastSigBits >> 48, 4));
+        if (false == isSimple)
+        {
+            builder.append('-');
+        }
+        // node
+        builder.append(digits(leastSigBits, 12));
+
+        return builder.toString();
+    }
+
+    /**
+     * 返回此 UUID 的哈希码。
+     *
+     * @return UUID 的哈希码值。
+     */
+    @Override
+    public int hashCode()
+    {
+        long hilo = mostSigBits ^ leastSigBits;
+        return ((int) (hilo >> 32)) ^ (int) hilo;
+    }
+
+    /**
+     * 将此对象与指定对象比较。
+     * <p>
+     * 当且仅当参数不为 {@code null}、而是一个 UUID 对象、具有与此 UUID 相同的 varriant、包含相同的值(每一位均相同)时,结果才为 {@code true}。
+     *
+     * @param obj 要与之比较的对象
+     *
+     * @return 如果对象相同,则返回 {@code true};否则返回 {@code false}
+     */
+    @Override
+    public boolean equals(Object obj)
+    {
+        if ((null == obj) || (obj.getClass() != UUIDUtils.class))
+        {
+            return false;
+        }
+        UUIDUtils id = (UUIDUtils) obj;
+        return (mostSigBits == id.mostSigBits && leastSigBits == id.leastSigBits);
+    }
+
+    // Comparison Operations
+
+    /**
+     * 将此 UUID 与指定的 UUID 比较。
+     *
+     * <p>
+     * 如果两个 UUID 不同,且第一个 UUID 的最高有效字段大于第二个 UUID 的对应字段,则第一个 UUID 大于第二个 UUID。
+     *
+     * @param val 与此 UUID 比较的 UUID
+     *
+     * @return 在此 UUID 小于、等于或大于 val 时,分别返回 -1、0 或 1。
+     *
+     */
+    @Override
+    public int compareTo(UUIDUtils val)
+    {
+        // The ordering is intentionally set up so that the UUIDs
+        // can simply be numerically compared as two numbers
+        return (this.mostSigBits < val.mostSigBits ? -1 : //
+                (this.mostSigBits > val.mostSigBits ? 1 : //
+                        (this.leastSigBits < val.leastSigBits ? -1 : //
+                                (this.leastSigBits > val.leastSigBits ? 1 : //
+                                        0))));
+    }
+
+    // -------------------------------------------------------------------------------------------------------------------
+    // Private method start
+    /**
+     * 返回指定数字对应的hex值
+     * 
+     * @param val 值
+     * @param digits 位
+     * @return 值
+     */
+    private static String digits(long val, int digits)
+    {
+        long hi = 1L << (digits * 4);
+        return Long.toHexString(hi | (val & (hi - 1))).substring(1);
+    }
+
+    /**
+     * 检查是否为time-based版本UUID
+     */
+    private void checkTimeBase()
+    {
+        if (version() != 1)
+        {
+            throw new UnsupportedOperationException("Not a time-based UUID");
+        }
+    }
+
+    /**
+     * 获取{@link SecureRandom},类提供加密的强随机数生成器 (RNG)
+     * 
+     * @return {@link SecureRandom}
+     */
+    public static SecureRandom getSecureRandom()
+    {
+        try
+        {
+            return SecureRandom.getInstance("SHA1PRNG");
+        }
+        catch (NoSuchAlgorithmException e)
+        {
+            throw new BusinessException(e.getMessage());
+        }
+    }
+
+    /**
+     * 获取随机数生成器对象<br>
+     * ThreadLocalRandom是JDK 7之后提供并发产生随机数,能够解决多个线程发生的竞争争夺。
+     * 
+     * @return {@link ThreadLocalRandom}
+     */
+    public static ThreadLocalRandom getRandom()
+    {
+        return ThreadLocalRandom.current();
+    }
+
+
+
 }

+ 38 - 2
fiveep-common/fiveep-common-spring/src/main/java/com/bizmatics/common/spring/util/ThreadUtils.java

@@ -1,16 +1,17 @@
 package com.bizmatics.common.spring.util;
 
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.*;
 
 /**
  * @author barry chen
  * @date 2020/11/27 4:20 下午
  */
+@Slf4j
 public final class ThreadUtils extends org.apache.commons.lang3.ThreadUtils {
     private static final Logger LOG = LoggerFactory.getLogger(ThreadUtils.class);
 
@@ -55,4 +56,39 @@ public final class ThreadUtils extends org.apache.commons.lang3.ThreadUtils {
             }
         }
     }
+
+
+    /**
+     * 打印线程异常信息
+     */
+    public static void printException(Runnable r, Throwable t)
+    {
+        if (t == null && r instanceof Future<?>)
+        {
+            try
+            {
+                Future<?> future = (Future<?>) r;
+                if (future.isDone())
+                {
+                    future.get();
+                }
+            }
+            catch (CancellationException ce)
+            {
+                t = ce;
+            }
+            catch (ExecutionException ee)
+            {
+                t = ee.getCause();
+            }
+            catch (InterruptedException ie)
+            {
+                Thread.currentThread().interrupt();
+            }
+        }
+        if (t != null)
+        {
+            log.error(t.getMessage(), t);
+        }
+    }
 }

+ 1 - 1
fiveep-controller/src/main/java/com/bizmatics/controller/web/system/CaptchaController.java

@@ -2,11 +2,11 @@ package com.bizmatics.controller.web.system;
 
 import com.bizmatics.common.core.bean.ApiResult;
 import com.bizmatics.common.core.exception.BusinessException;
+import com.bizmatics.common.core.util.IdUtils;
 import com.bizmatics.common.core.util.sign.Base64;
 import com.bizmatics.common.spring.config.redis.RedisHelper;
 import com.bizmatics.model.constants.Constants;
 import com.bizmatics.service.system.ISysConfigService;
-import com.bizmatics.service.util.IdUtils;
 import com.google.code.kaptcha.Producer;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;

+ 1 - 1
fiveep-controller/src/main/java/com/bizmatics/controller/web/system/SysLoginController.java

@@ -8,7 +8,7 @@ import com.bizmatics.service.system.ISysMenuService;
 import com.bizmatics.service.system.impl.SysLoginService;
 import com.bizmatics.service.system.impl.SysPermissionService;
 import com.bizmatics.service.system.impl.TokenService;
-import com.bizmatics.service.util.LoginUser;
+import com.bizmatics.service.config.security.LoginUser;
 import com.bizmatics.service.vo.LoginBody;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;

+ 1 - 1
fiveep-controller/src/main/java/com/bizmatics/controller/web/system/SysMenuController.java

@@ -9,7 +9,7 @@ import com.bizmatics.model.constants.UserConstants;
 import com.bizmatics.model.system.SysMenu;
 import com.bizmatics.service.system.ISysMenuService;
 import com.bizmatics.service.system.impl.TokenService;
-import com.bizmatics.service.util.LoginUser;
+import com.bizmatics.service.config.security.LoginUser;
 import com.bizmatics.service.util.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;

+ 1 - 1
fiveep-controller/src/main/java/com/bizmatics/controller/web/system/SysProfileController.java

@@ -8,7 +8,7 @@ import com.bizmatics.model.constants.UserConstants;
 import com.bizmatics.model.system.SysUser;
 import com.bizmatics.service.system.ISysUserService;
 import com.bizmatics.service.system.impl.TokenService;
-import com.bizmatics.service.util.LoginUser;
+import com.bizmatics.service.config.security.LoginUser;
 import com.bizmatics.service.util.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;

+ 1 - 1
fiveep-controller/src/main/java/com/bizmatics/controller/web/system/SysRoleController.java

@@ -12,7 +12,7 @@ import com.bizmatics.service.system.ISysRoleService;
 import com.bizmatics.service.system.ISysUserService;
 import com.bizmatics.service.system.impl.SysPermissionService;
 import com.bizmatics.service.system.impl.TokenService;
-import com.bizmatics.service.util.LoginUser;
+import com.bizmatics.service.config.security.LoginUser;
 import com.bizmatics.service.util.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;

+ 1 - 1
fiveep-service/src/main/java/com/bizmatics/service/aop/DataScopeAspect.java

@@ -7,7 +7,7 @@ import com.bizmatics.model.base.BaseEntity;
 import com.bizmatics.model.system.SysRole;
 import com.bizmatics.model.system.SysUser;
 import com.bizmatics.service.system.impl.TokenService;
-import com.bizmatics.service.util.LoginUser;
+import com.bizmatics.service.config.security.LoginUser;
 import org.aspectj.lang.JoinPoint;
 import org.aspectj.lang.Signature;
 import org.aspectj.lang.annotation.Aspect;

+ 1 - 1
fiveep-service/src/main/java/com/bizmatics/service/config/PermissionService.java

@@ -5,7 +5,7 @@ import com.bizmatics.common.core.util.StringUtils;
 import com.bizmatics.common.mvc.utils.ServletUtils;
 import com.bizmatics.model.system.SysRole;
 import com.bizmatics.service.system.impl.TokenService;
-import com.bizmatics.service.util.LoginUser;
+import com.bizmatics.service.config.security.LoginUser;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;

+ 3 - 2
fiveep-service/src/main/java/com/bizmatics/service/config/ThreadPoolConfig.java

@@ -1,7 +1,8 @@
 package com.bizmatics.service.config;
 
 
-import com.bizmatics.service.util.Threads;
+
+import com.bizmatics.common.spring.util.ThreadUtils;
 import org.apache.commons.lang3.concurrent.BasicThreadFactory;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -58,7 +59,7 @@ public class ThreadPoolConfig
             protected void afterExecute(Runnable r, Throwable t)
             {
                 super.afterExecute(r, t);
-                Threads.printException(r, t);
+                ThreadUtils.printException(r, t);
             }
         };
     }

+ 1 - 1
fiveep-service/src/main/java/com/bizmatics/service/util/LoginUser.java → fiveep-service/src/main/java/com/bizmatics/service/config/security/LoginUser.java

@@ -1,4 +1,4 @@
-package com.bizmatics.service.util;
+package com.bizmatics.service.config.security;
 
 import com.bizmatics.model.system.SysUser;
 import com.fasterxml.jackson.annotation.JsonIgnore;

+ 0 - 1
fiveep-service/src/main/java/com/bizmatics/service/config/security/UserDetailsServiceImpl.java

@@ -5,7 +5,6 @@ import com.bizmatics.model.system.SysUser;
 import com.bizmatics.service.enums.UserStatus;
 import com.bizmatics.service.system.ISysUserService;
 import com.bizmatics.service.system.impl.SysPermissionService;
-import com.bizmatics.service.util.LoginUser;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;

+ 1 - 1
fiveep-service/src/main/java/com/bizmatics/service/config/security/filter/JwtAuthenticationTokenFilter.java

@@ -1,7 +1,7 @@
 package com.bizmatics.service.config.security.filter;
 
 import com.bizmatics.service.system.impl.TokenService;
-import com.bizmatics.service.util.LoginUser;
+import com.bizmatics.service.config.security.LoginUser;
 import com.bizmatics.service.util.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;

+ 1 - 1
fiveep-service/src/main/java/com/bizmatics/service/config/security/handle/LogoutSuccessHandlerImpl.java

@@ -5,7 +5,7 @@ import com.bizmatics.common.mvc.utils.ServletUtils;
 import com.bizmatics.common.spring.util.JsonUtils;
 import com.bizmatics.model.constants.Constants;
 import com.bizmatics.service.system.impl.TokenService;
-import com.bizmatics.service.util.LoginUser;
+import com.bizmatics.service.config.security.LoginUser;
 import com.bizmatics.service.util.manager.AsyncManager;
 import com.bizmatics.service.util.manager.factory.AsyncFactory;
 import org.springframework.beans.factory.annotation.Autowired;

+ 0 - 19
fiveep-service/src/main/java/com/bizmatics/service/enums/DataSourceType.java

@@ -1,19 +0,0 @@
-package com.bizmatics.service.enums;
-
-/**
- * 数据源
- * 
- * @author ruoyi
- */
-public enum DataSourceType
-{
-    /**
-     * 主库
-     */
-    MASTER,
-
-    /**
-     * 从库
-     */
-    SLAVE
-}

+ 2 - 2
fiveep-service/src/main/java/com/bizmatics/service/impl/HadSiteStaticServiceImpl.java

@@ -2,11 +2,11 @@ package com.bizmatics.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.bizmatics.common.core.util.Arith;
+import com.bizmatics.common.mvc.base.AbstractCrudService;
 import com.bizmatics.model.HadSiteStatic;
 import com.bizmatics.persistence.mapper.HadSiteStaticMapper;
 import com.bizmatics.service.HadSiteStaticService;
-import com.bizmatics.common.mvc.base.AbstractCrudService;
-import com.bizmatics.service.util.Arith;
 import org.springframework.stereotype.Service;
 
 import java.util.Date;

+ 1 - 1
fiveep-service/src/main/java/com/bizmatics/service/impl/HtAnalogDataServiceImpl.java

@@ -1,5 +1,6 @@
 package com.bizmatics.service.impl;
 
+import com.bizmatics.common.core.util.Arith;
 import com.bizmatics.common.core.util.DateUtils;
 import com.bizmatics.common.mvc.base.AbstractCrudService;
 import com.bizmatics.common.spring.util.JsonUtils;
@@ -8,7 +9,6 @@ import com.bizmatics.model.HtAnalogData;
 import com.bizmatics.persistence.mapper.HtAnalogDataMapper;
 import com.bizmatics.service.HadSiteStaticService;
 import com.bizmatics.service.HtAnalogDataService;
-import com.bizmatics.service.util.Arith;
 import com.bizmatics.service.util.SecurityUtils;
 import com.bizmatics.service.vo.CommonIcoVO;
 import com.bizmatics.service.vo.HadCountVO;

+ 1 - 1
fiveep-service/src/main/java/com/bizmatics/service/impl/RtAnalogDataServiceImpl.java

@@ -4,6 +4,7 @@ import cn.afterturn.easypoi.excel.ExcelExportUtil;
 import cn.afterturn.easypoi.excel.entity.ExportParams;
 import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
 import com.bizmatics.common.core.exception.BusinessException;
+import com.bizmatics.common.core.util.Arith;
 import com.bizmatics.common.core.util.DateUtils;
 import com.bizmatics.common.core.util.FileUtils;
 import com.bizmatics.common.core.util.StringUtils;
@@ -15,7 +16,6 @@ import com.bizmatics.model.RtAnalogData;
 import com.bizmatics.persistence.mapper.DeviceMapper;
 import com.bizmatics.persistence.mapper.RtAnalogDataMapper;
 import com.bizmatics.service.RtAnalogDataService;
-import com.bizmatics.service.util.Arith;
 import com.bizmatics.service.util.SecurityUtils;
 import com.bizmatics.service.vo.RadCountVO;
 import org.apache.commons.lang3.ArrayUtils;

+ 1 - 1
fiveep-service/src/main/java/com/bizmatics/service/job/RatAnalogTask.java

@@ -1,12 +1,12 @@
 package com.bizmatics.service.job;
 
+import com.bizmatics.common.core.util.Arith;
 import com.bizmatics.common.core.util.DateUtils;
 import com.bizmatics.common.spring.util.JsonUtils;
 import com.bizmatics.model.HadSiteStatic;
 import com.bizmatics.model.HtAnalogData;
 import com.bizmatics.persistence.mapper.HadSiteStaticMapper;
 import com.bizmatics.persistence.mapper.HtAnalogDataMapper;
-import com.bizmatics.service.util.Arith;
 import com.bizmatics.service.vo.CommonIcoVO;
 import com.bizmatics.service.vo.TimeShareVO;
 import lombok.extern.slf4j.Slf4j;

+ 1 - 1
fiveep-service/src/main/java/com/bizmatics/service/system/ISysUserOnlineService.java

@@ -2,7 +2,7 @@ package com.bizmatics.service.system;
 
 
 import com.bizmatics.model.system.SysUserOnline;
-import com.bizmatics.service.util.LoginUser;
+import com.bizmatics.service.config.security.LoginUser;
 
 /**
  * 在线用户 服务层

+ 1 - 1
fiveep-service/src/main/java/com/bizmatics/service/system/impl/SysLoginService.java

@@ -8,7 +8,7 @@ import com.bizmatics.model.constants.Constants;
 import com.bizmatics.model.system.SysUser;
 import com.bizmatics.service.system.ISysConfigService;
 import com.bizmatics.service.system.ISysUserService;
-import com.bizmatics.service.util.LoginUser;
+import com.bizmatics.service.config.security.LoginUser;
 import com.bizmatics.service.util.manager.AsyncManager;
 import com.bizmatics.service.util.manager.MessageUtils;
 import com.bizmatics.service.util.manager.factory.AsyncFactory;

+ 1 - 1
fiveep-service/src/main/java/com/bizmatics/service/system/impl/SysUserOnlineServiceImpl.java

@@ -3,7 +3,7 @@ package com.bizmatics.service.system.impl;
 import com.bizmatics.common.core.util.StringUtils;
 import com.bizmatics.model.system.SysUserOnline;
 import com.bizmatics.service.system.ISysUserOnlineService;
-import com.bizmatics.service.util.LoginUser;
+import com.bizmatics.service.config.security.LoginUser;
 import org.springframework.stereotype.Service;
 
 import java.util.Objects;

+ 2 - 2
fiveep-service/src/main/java/com/bizmatics/service/system/impl/TokenService.java

@@ -1,13 +1,13 @@
 package com.bizmatics.service.system.impl;
 
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.bizmatics.common.core.util.IdUtils;
 import com.bizmatics.common.mvc.utils.IpUtils;
 import com.bizmatics.common.mvc.utils.ServletUtils;
 import com.bizmatics.common.spring.config.redis.RedisHelper;
 import com.bizmatics.model.constants.Constants;
+import com.bizmatics.service.config.security.LoginUser;
 import com.bizmatics.service.util.AddressUtils;
-import com.bizmatics.service.util.IdUtils;
-import com.bizmatics.service.util.LoginUser;
 import eu.bitwalker.useragentutils.UserAgent;
 import io.jsonwebtoken.Claims;
 import io.jsonwebtoken.Jwts;

+ 0 - 18
fiveep-service/src/main/java/com/bizmatics/service/util/LogUtils.java

@@ -1,18 +0,0 @@
-package com.bizmatics.service.util;
-
-/**
- * 处理并记录日志文件
- * 
- * @author ruoyi
- */
-public class LogUtils
-{
-    public static String getBlock(Object msg)
-    {
-        if (msg == null)
-        {
-            msg = "";
-        }
-        return "[" + msg.toString() + "]";
-    }
-}

+ 1 - 0
fiveep-service/src/main/java/com/bizmatics/service/util/SecurityUtils.java

@@ -2,6 +2,7 @@ package com.bizmatics.service.util;
 
 import com.bizmatics.common.core.exception.BusinessException;
 import com.bizmatics.model.system.SysUser;
+import com.bizmatics.service.config.security.LoginUser;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

+ 0 - 96
fiveep-service/src/main/java/com/bizmatics/service/util/Threads.java

@@ -1,96 +0,0 @@
-package com.bizmatics.service.util;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.concurrent.*;
-
-/**
- * 线程相关工具类.
- * 
- * @author yq
- */
-public class Threads
-{
-    private static final Logger logger = LoggerFactory.getLogger(Threads.class);
-
-    /**
-     * sleep等待,单位为毫秒
-     */
-    public static void sleep(long milliseconds)
-    {
-        try
-        {
-            Thread.sleep(milliseconds);
-        }
-        catch (InterruptedException e)
-        {
-            return;
-        }
-    }
-
-    /**
-     * 停止线程池
-     * 先使用shutdown, 停止接收新任务并尝试完成所有已存在任务.
-     * 如果超时, 则调用shutdownNow, 取消在workQueue中Pending的任务,并中断所有阻塞函数.
-     * 如果仍人超時,則強制退出.
-     * 另对在shutdown时线程本身被调用中断做了处理.
-     */
-    public static void shutdownAndAwaitTermination(ExecutorService pool)
-    {
-        if (pool != null && !pool.isShutdown())
-        {
-            pool.shutdown();
-            try
-            {
-                if (!pool.awaitTermination(120, TimeUnit.SECONDS))
-                {
-                    pool.shutdownNow();
-                    if (!pool.awaitTermination(120, TimeUnit.SECONDS))
-                    {
-                        logger.info("Pool did not terminate");
-                    }
-                }
-            }
-            catch (InterruptedException ie)
-            {
-                pool.shutdownNow();
-                Thread.currentThread().interrupt();
-            }
-        }
-    }
-
-    /**
-     * 打印线程异常信息
-     */
-    public static void printException(Runnable r, Throwable t)
-    {
-        if (t == null && r instanceof Future<?>)
-        {
-            try
-            {
-                Future<?> future = (Future<?>) r;
-                if (future.isDone())
-                {
-                    future.get();
-                }
-            }
-            catch (CancellationException ce)
-            {
-                t = ce;
-            }
-            catch (ExecutionException ee)
-            {
-                t = ee.getCause();
-            }
-            catch (InterruptedException ie)
-            {
-                Thread.currentThread().interrupt();
-            }
-        }
-        if (t != null)
-        {
-            logger.error(t.getMessage(), t);
-        }
-    }
-}

+ 0 - 485
fiveep-service/src/main/java/com/bizmatics/service/util/UUID.java

@@ -1,485 +0,0 @@
-package com.bizmatics.service.util;
-
-import com.bizmatics.common.core.exception.BusinessException;
-
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.security.SecureRandom;
-import java.util.Random;
-import java.util.concurrent.ThreadLocalRandom;
-
-/**
- * 提供通用唯一识别码(universally unique identifier)(UUID)实现
- *
- * @author ruoyi
- */
-public final class UUID implements java.io.Serializable, Comparable<UUID>
-{
-    private static final long serialVersionUID = -1185015143654744140L;
-
-    /**
-     * SecureRandom 的单例
-     *
-     */
-    private static class Holder
-    {
-        static final SecureRandom numberGenerator = getSecureRandom();
-    }
-
-    /** 此UUID的最高64有效位 */
-    private final long mostSigBits;
-
-    /** 此UUID的最低64有效位 */
-    private final long leastSigBits;
-
-    /**
-     * 私有构造
-     * 
-     * @param data 数据
-     */
-    private UUID(byte[] data)
-    {
-        long msb = 0;
-        long lsb = 0;
-        assert data.length == 16 : "data must be 16 bytes in length";
-        for (int i = 0; i < 8; i++)
-        {
-            msb = (msb << 8) | (data[i] & 0xff);
-        }
-        for (int i = 8; i < 16; i++)
-        {
-            lsb = (lsb << 8) | (data[i] & 0xff);
-        }
-        this.mostSigBits = msb;
-        this.leastSigBits = lsb;
-    }
-
-    /**
-     * 使用指定的数据构造新的 UUID。
-     *
-     * @param mostSigBits 用于 {@code UUID} 的最高有效 64 位
-     * @param leastSigBits 用于 {@code UUID} 的最低有效 64 位
-     */
-    public UUID(long mostSigBits, long leastSigBits)
-    {
-        this.mostSigBits = mostSigBits;
-        this.leastSigBits = leastSigBits;
-    }
-
-    /**
-     * 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的本地线程伪随机数生成器生成该 UUID。
-     * 
-     * @return 随机生成的 {@code UUID}
-     */
-    public static UUID fastUUID()
-    {
-        return randomUUID(false);
-    }
-
-    /**
-     * 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的强伪随机数生成器生成该 UUID。
-     * 
-     * @return 随机生成的 {@code UUID}
-     */
-    public static UUID randomUUID()
-    {
-        return randomUUID(true);
-    }
-
-    /**
-     * 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的强伪随机数生成器生成该 UUID。
-     * 
-     * @param isSecure 是否使用{@link SecureRandom}如果是可以获得更安全的随机码,否则可以得到更好的性能
-     * @return 随机生成的 {@code UUID}
-     */
-    public static UUID randomUUID(boolean isSecure)
-    {
-        final Random ng = isSecure ? Holder.numberGenerator : getRandom();
-
-        byte[] randomBytes = new byte[16];
-        ng.nextBytes(randomBytes);
-        randomBytes[6] &= 0x0f; /* clear version */
-        randomBytes[6] |= 0x40; /* set to version 4 */
-        randomBytes[8] &= 0x3f; /* clear variant */
-        randomBytes[8] |= 0x80; /* set to IETF variant */
-        return new UUID(randomBytes);
-    }
-
-    /**
-     * 根据指定的字节数组获取类型 3(基于名称的)UUID 的静态工厂。
-     *
-     * @param name 用于构造 UUID 的字节数组。
-     *
-     * @return 根据指定数组生成的 {@code UUID}
-     */
-    public static UUID nameUUIDFromBytes(byte[] name)
-    {
-        MessageDigest md;
-        try
-        {
-            md = MessageDigest.getInstance("MD5");
-        }
-        catch (NoSuchAlgorithmException nsae)
-        {
-            throw new InternalError("MD5 not supported");
-        }
-        byte[] md5Bytes = md.digest(name);
-        md5Bytes[6] &= 0x0f; /* clear version */
-        md5Bytes[6] |= 0x30; /* set to version 3 */
-        md5Bytes[8] &= 0x3f; /* clear variant */
-        md5Bytes[8] |= 0x80; /* set to IETF variant */
-        return new UUID(md5Bytes);
-    }
-
-    /**
-     * 根据 {@link #toString()} 方法中描述的字符串标准表示形式创建{@code UUID}。
-     *
-     * @param name 指定 {@code UUID} 字符串
-     * @return 具有指定值的 {@code UUID}
-     * @throws IllegalArgumentException 如果 name 与 {@link #toString} 中描述的字符串表示形式不符抛出此异常
-     *
-     */
-    public static UUID fromString(String name)
-    {
-        String[] components = name.split("-");
-        if (components.length != 5)
-        {
-            throw new IllegalArgumentException("Invalid UUID string: " + name);
-        }
-        for (int i = 0; i < 5; i++)
-        {
-            components[i] = "0x" + components[i];
-        }
-
-        long mostSigBits = Long.decode(components[0]).longValue();
-        mostSigBits <<= 16;
-        mostSigBits |= Long.decode(components[1]).longValue();
-        mostSigBits <<= 16;
-        mostSigBits |= Long.decode(components[2]).longValue();
-
-        long leastSigBits = Long.decode(components[3]).longValue();
-        leastSigBits <<= 48;
-        leastSigBits |= Long.decode(components[4]).longValue();
-
-        return new UUID(mostSigBits, leastSigBits);
-    }
-
-    /**
-     * 返回此 UUID 的 128 位值中的最低有效 64 位。
-     *
-     * @return 此 UUID 的 128 位值中的最低有效 64 位。
-     */
-    public long getLeastSignificantBits()
-    {
-        return leastSigBits;
-    }
-
-    /**
-     * 返回此 UUID 的 128 位值中的最高有效 64 位。
-     *
-     * @return 此 UUID 的 128 位值中最高有效 64 位。
-     */
-    public long getMostSignificantBits()
-    {
-        return mostSigBits;
-    }
-
-    /**
-     * 与此 {@code UUID} 相关联的版本号. 版本号描述此 {@code UUID} 是如何生成的。
-     * <p>
-     * 版本号具有以下含意:
-     * <ul>
-     * <li>1 基于时间的 UUID
-     * <li>2 DCE 安全 UUID
-     * <li>3 基于名称的 UUID
-     * <li>4 随机生成的 UUID
-     * </ul>
-     *
-     * @return 此 {@code UUID} 的版本号
-     */
-    public int version()
-    {
-        // Version is bits masked by 0x000000000000F000 in MS long
-        return (int) ((mostSigBits >> 12) & 0x0f);
-    }
-
-    /**
-     * 与此 {@code UUID} 相关联的变体号。变体号描述 {@code UUID} 的布局。
-     * <p>
-     * 变体号具有以下含意:
-     * <ul>
-     * <li>0 为 NCS 向后兼容保留
-     * <li>2 <a href="http://www.ietf.org/rfc/rfc4122.txt">IETF&nbsp;RFC&nbsp;4122</a>(Leach-Salz), 用于此类
-     * <li>6 保留,微软向后兼容
-     * <li>7 保留供以后定义使用
-     * </ul>
-     *
-     * @return 此 {@code UUID} 相关联的变体号
-     */
-    public int variant()
-    {
-        // This field is composed of a varying number of bits.
-        // 0 - - Reserved for NCS backward compatibility
-        // 1 0 - The IETF aka Leach-Salz variant (used by this class)
-        // 1 1 0 Reserved, Microsoft backward compatibility
-        // 1 1 1 Reserved for future definition.
-        return (int) ((leastSigBits >>> (64 - (leastSigBits >>> 62))) & (leastSigBits >> 63));
-    }
-
-    /**
-     * 与此 UUID 相关联的时间戳值。
-     *
-     * <p>
-     * 60 位的时间戳值根据此 {@code UUID} 的 time_low、time_mid 和 time_hi 字段构造。<br>
-     * 所得到的时间戳以 100 毫微秒为单位,从 UTC(通用协调时间) 1582 年 10 月 15 日零时开始。
-     *
-     * <p>
-     * 时间戳值仅在在基于时间的 UUID(其 version 类型为 1)中才有意义。<br>
-     * 如果此 {@code UUID} 不是基于时间的 UUID,则此方法抛出 UnsupportedOperationException。
-     *
-     * @throws UnsupportedOperationException 如果此 {@code UUID} 不是 version 为 1 的 UUID。
-     */
-    public long timestamp() throws UnsupportedOperationException
-    {
-        checkTimeBase();
-        return (mostSigBits & 0x0FFFL) << 48//
-                | ((mostSigBits >> 16) & 0x0FFFFL) << 32//
-                | mostSigBits >>> 32;
-    }
-
-    /**
-     * 与此 UUID 相关联的时钟序列值。
-     *
-     * <p>
-     * 14 位的时钟序列值根据此 UUID 的 clock_seq 字段构造。clock_seq 字段用于保证在基于时间的 UUID 中的时间唯一性。
-     * <p>
-     * {@code clockSequence} 值仅在基于时间的 UUID(其 version 类型为 1)中才有意义。 如果此 UUID 不是基于时间的 UUID,则此方法抛出
-     * UnsupportedOperationException。
-     *
-     * @return 此 {@code UUID} 的时钟序列
-     *
-     * @throws UnsupportedOperationException 如果此 UUID 的 version 不为 1
-     */
-    public int clockSequence() throws UnsupportedOperationException
-    {
-        checkTimeBase();
-        return (int) ((leastSigBits & 0x3FFF000000000000L) >>> 48);
-    }
-
-    /**
-     * 与此 UUID 相关的节点值。
-     *
-     * <p>
-     * 48 位的节点值根据此 UUID 的 node 字段构造。此字段旨在用于保存机器的 IEEE 802 地址,该地址用于生成此 UUID 以保证空间唯一性。
-     * <p>
-     * 节点值仅在基于时间的 UUID(其 version 类型为 1)中才有意义。<br>
-     * 如果此 UUID 不是基于时间的 UUID,则此方法抛出 UnsupportedOperationException。
-     *
-     * @return 此 {@code UUID} 的节点值
-     *
-     * @throws UnsupportedOperationException 如果此 UUID 的 version 不为 1
-     */
-    public long node() throws UnsupportedOperationException
-    {
-        checkTimeBase();
-        return leastSigBits & 0x0000FFFFFFFFFFFFL;
-    }
-
-    /**
-     * 返回此{@code UUID} 的字符串表现形式。
-     *
-     * <p>
-     * UUID 的字符串表示形式由此 BNF 描述:
-     * 
-     * <pre>
-     * {@code
-     * UUID                   = <time_low>-<time_mid>-<time_high_and_version>-<variant_and_sequence>-<node>
-     * time_low               = 4*<hexOctet>
-     * time_mid               = 2*<hexOctet>
-     * time_high_and_version  = 2*<hexOctet>
-     * variant_and_sequence   = 2*<hexOctet>
-     * node                   = 6*<hexOctet>
-     * hexOctet               = <hexDigit><hexDigit>
-     * hexDigit               = [0-9a-fA-F]
-     * }
-     * </pre>
-     * 
-     * </blockquote>
-     *
-     * @return 此{@code UUID} 的字符串表现形式
-     * @see #toString(boolean)
-     */
-    @Override
-    public String toString()
-    {
-        return toString(false);
-    }
-
-    /**
-     * 返回此{@code UUID} 的字符串表现形式。
-     *
-     * <p>
-     * UUID 的字符串表示形式由此 BNF 描述:
-     * 
-     * <pre>
-     * {@code
-     * UUID                   = <time_low>-<time_mid>-<time_high_and_version>-<variant_and_sequence>-<node>
-     * time_low               = 4*<hexOctet>
-     * time_mid               = 2*<hexOctet>
-     * time_high_and_version  = 2*<hexOctet>
-     * variant_and_sequence   = 2*<hexOctet>
-     * node                   = 6*<hexOctet>
-     * hexOctet               = <hexDigit><hexDigit>
-     * hexDigit               = [0-9a-fA-F]
-     * }
-     * </pre>
-     * 
-     * </blockquote>
-     *
-     * @param isSimple 是否简单模式,简单模式为不带'-'的UUID字符串
-     * @return 此{@code UUID} 的字符串表现形式
-     */
-    public String toString(boolean isSimple)
-    {
-        final StringBuilder builder = new StringBuilder(isSimple ? 32 : 36);
-        // time_low
-        builder.append(digits(mostSigBits >> 32, 8));
-        if (false == isSimple)
-        {
-            builder.append('-');
-        }
-        // time_mid
-        builder.append(digits(mostSigBits >> 16, 4));
-        if (false == isSimple)
-        {
-            builder.append('-');
-        }
-        // time_high_and_version
-        builder.append(digits(mostSigBits, 4));
-        if (false == isSimple)
-        {
-            builder.append('-');
-        }
-        // variant_and_sequence
-        builder.append(digits(leastSigBits >> 48, 4));
-        if (false == isSimple)
-        {
-            builder.append('-');
-        }
-        // node
-        builder.append(digits(leastSigBits, 12));
-
-        return builder.toString();
-    }
-
-    /**
-     * 返回此 UUID 的哈希码。
-     *
-     * @return UUID 的哈希码值。
-     */
-    @Override
-    public int hashCode()
-    {
-        long hilo = mostSigBits ^ leastSigBits;
-        return ((int) (hilo >> 32)) ^ (int) hilo;
-    }
-
-    /**
-     * 将此对象与指定对象比较。
-     * <p>
-     * 当且仅当参数不为 {@code null}、而是一个 UUID 对象、具有与此 UUID 相同的 varriant、包含相同的值(每一位均相同)时,结果才为 {@code true}。
-     *
-     * @param obj 要与之比较的对象
-     *
-     * @return 如果对象相同,则返回 {@code true};否则返回 {@code false}
-     */
-    @Override
-    public boolean equals(Object obj)
-    {
-        if ((null == obj) || (obj.getClass() != UUID.class))
-        {
-            return false;
-        }
-        UUID id = (UUID) obj;
-        return (mostSigBits == id.mostSigBits && leastSigBits == id.leastSigBits);
-    }
-
-    // Comparison Operations
-
-    /**
-     * 将此 UUID 与指定的 UUID 比较。
-     *
-     * <p>
-     * 如果两个 UUID 不同,且第一个 UUID 的最高有效字段大于第二个 UUID 的对应字段,则第一个 UUID 大于第二个 UUID。
-     *
-     * @param val 与此 UUID 比较的 UUID
-     *
-     * @return 在此 UUID 小于、等于或大于 val 时,分别返回 -1、0 或 1。
-     *
-     */
-    @Override
-    public int compareTo(UUID val)
-    {
-        // The ordering is intentionally set up so that the UUIDs
-        // can simply be numerically compared as two numbers
-        return (this.mostSigBits < val.mostSigBits ? -1 : //
-                (this.mostSigBits > val.mostSigBits ? 1 : //
-                        (this.leastSigBits < val.leastSigBits ? -1 : //
-                                (this.leastSigBits > val.leastSigBits ? 1 : //
-                                        0))));
-    }
-
-    // -------------------------------------------------------------------------------------------------------------------
-    // Private method start
-    /**
-     * 返回指定数字对应的hex值
-     * 
-     * @param val 值
-     * @param digits 位
-     * @return 值
-     */
-    private static String digits(long val, int digits)
-    {
-        long hi = 1L << (digits * 4);
-        return Long.toHexString(hi | (val & (hi - 1))).substring(1);
-    }
-
-    /**
-     * 检查是否为time-based版本UUID
-     */
-    private void checkTimeBase()
-    {
-        if (version() != 1)
-        {
-            throw new UnsupportedOperationException("Not a time-based UUID");
-        }
-    }
-
-    /**
-     * 获取{@link SecureRandom},类提供加密的强随机数生成器 (RNG)
-     * 
-     * @return {@link SecureRandom}
-     */
-    public static SecureRandom getSecureRandom()
-    {
-        try
-        {
-            return SecureRandom.getInstance("SHA1PRNG");
-        }
-        catch (NoSuchAlgorithmException e)
-        {
-            throw new BusinessException(e.getMessage());
-        }
-    }
-
-    /**
-     * 获取随机数生成器对象<br>
-     * ThreadLocalRandom是JDK 7之后提供并发产生随机数,能够解决多个线程发生的竞争争夺。
-     * 
-     * @return {@link ThreadLocalRandom}
-     */
-    public static ThreadLocalRandom getRandom()
-    {
-        return ThreadLocalRandom.current();
-    }
-}

+ 13 - 5
fiveep-service/src/main/java/com/bizmatics/service/util/manager/factory/AsyncFactory.java

@@ -10,7 +10,6 @@ import com.bizmatics.model.system.SysOperLog;
 import com.bizmatics.service.system.ISysLogininforService;
 import com.bizmatics.service.system.ISysOperLogService;
 import com.bizmatics.service.util.AddressUtils;
-import com.bizmatics.service.util.LogUtils;
 import eu.bitwalker.useragentutils.UserAgent;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -47,11 +46,11 @@ public class AsyncFactory
             {
                 String address = AddressUtils.getRealAddressByIP(ip);
                 StringBuilder s = new StringBuilder();
-                s.append(LogUtils.getBlock(ip));
+                s.append(getBlock(ip));
                 s.append(address);
-                s.append(LogUtils.getBlock(username));
-                s.append(LogUtils.getBlock(status));
-                s.append(LogUtils.getBlock(message));
+                s.append(getBlock(username));
+                s.append(getBlock(status));
+                s.append(getBlock(message));
                 // 打印信息到日志
                 sys_user_logger.info(s.toString(), args);
                 // 获取客户端操作系统
@@ -81,6 +80,15 @@ public class AsyncFactory
         };
     }
 
+    public static String getBlock(Object msg)
+    {
+        if (msg == null)
+        {
+            msg = "";
+        }
+        return "[" + msg.toString() + "]";
+    }
+
     /**
      * 操作日志记录
      *