Ver código fonte

整合service

yq 3 anos atrás
pai
commit
5cbfcfd899
25 arquivos alterados com 2228 adições e 514 exclusões
  1. 1 1
      fiveep-common/fiveep-common-mvc/src/main/java/com/bizmatics/common/mvc/utils/IpUtils.java
  2. 6 0
      fiveep-model/pom.xml
  3. 141 0
      fiveep-model/src/main/java/com/bizmatics/model/constants/Constants.java
  4. 105 0
      fiveep-model/src/main/java/com/bizmatics/model/system/SysConfig.java
  5. 102 0
      fiveep-model/src/main/java/com/bizmatics/model/system/SysNotice.java
  6. 238 0
      fiveep-model/src/main/java/com/bizmatics/model/system/SysOperLog.java
  7. 117 0
      fiveep-model/src/main/java/com/bizmatics/model/system/SysPost.java
  8. 46 0
      fiveep-model/src/main/java/com/bizmatics/model/system/SysRoleDept.java
  9. 46 0
      fiveep-model/src/main/java/com/bizmatics/model/system/SysRoleMenu.java
  10. 113 0
      fiveep-model/src/main/java/com/bizmatics/model/system/SysUserOnline.java
  11. 46 0
      fiveep-model/src/main/java/com/bizmatics/model/system/SysUserPost.java
  12. 46 0
      fiveep-model/src/main/java/com/bizmatics/model/system/SysUserRole.java
  13. 4 1
      fiveep-model/src/main/java/com/bizmatics/model/vo/MetaVo.java
  14. 4 4
      fiveep-service/pom.xml
  15. 116 0
      fiveep-service/src/main/java/com/bizmatics/service/config/RuoYiConfig.java
  16. 34 36
      fiveep-service/src/main/java/com/bizmatics/service/impl/AlarmPowerServiceImpl.java
  17. 13 14
      fiveep-service/src/main/java/com/bizmatics/service/impl/DeviceServiceImpl.java
  18. 48 50
      fiveep-service/src/main/java/com/bizmatics/service/impl/HtAnalogDataServiceImpl.java
  19. 380 380
      fiveep-service/src/main/java/com/bizmatics/service/impl/RtAnalogDataServiceImpl.java
  20. 20 21
      fiveep-service/src/main/java/com/bizmatics/service/impl/SiteServiceImpl.java
  21. 0 5
      fiveep-service/src/main/java/com/bizmatics/service/impl/UserServiceImpl.java
  22. 4 2
      fiveep-service/src/main/java/com/bizmatics/service/system/impl/TokenService.java
  23. 63 0
      fiveep-service/src/main/java/com/bizmatics/service/util/AddressUtils.java
  24. 50 0
      fiveep-service/src/main/java/com/bizmatics/service/util/IdUtils.java
  25. 485 0
      fiveep-service/src/main/java/com/bizmatics/service/util/UUID.java

+ 1 - 1
fiveep-common/fiveep-common-mvc/src/main/java/com/bizmatics/common/mvc/utils/IpUtils.java

@@ -10,7 +10,7 @@ import java.util.Objects;
  *
  * @author ruoyi
  */
-public final class IpUtils {
+public final class  IpUtils {
 
     private IpUtils() {
     }

+ 6 - 0
fiveep-model/pom.xml

@@ -42,6 +42,12 @@
 <!--            <groupId>org.springframework.boot</groupId>-->
 <!--            <artifactId>spring-boot-starter-security</artifactId>-->
 <!--        </dependency>-->
+        <!--Token生成与解析-->
+        <dependency>
+            <groupId>io.jsonwebtoken</groupId>
+            <artifactId>jjwt</artifactId>
+            <version>0.9.1</version>
+        </dependency>
     </dependencies>
 
 

+ 141 - 0
fiveep-model/src/main/java/com/bizmatics/model/constants/Constants.java

@@ -0,0 +1,141 @@
+package com.bizmatics.model.constants;
+
+import io.jsonwebtoken.Claims;
+
+/**
+ * 通用常量信息
+ * 
+ * @author ruoyi
+ */
+public class Constants
+{
+    /**
+     * UTF-8 字符集
+     */
+    public static final String UTF8 = "UTF-8";
+
+    /**
+     * GBK 字符集
+     */
+    public static final String GBK = "GBK";
+
+    /**
+     * http请求
+     */
+    public static final String HTTP = "http://";
+
+    /**
+     * https请求
+     */
+    public static final String HTTPS = "https://";
+
+    /**
+     * 通用成功标识
+     */
+    public static final String SUCCESS = "0";
+
+    /**
+     * 通用失败标识
+     */
+    public static final String FAIL = "1";
+
+    /**
+     * 登录成功
+     */
+    public static final String LOGIN_SUCCESS = "Success";
+
+    /**
+     * 注销
+     */
+    public static final String LOGOUT = "Logout";
+
+    /**
+     * 注册
+     */
+    public static final String REGISTER = "Register";
+
+    /**
+     * 登录失败
+     */
+    public static final String LOGIN_FAIL = "Error";
+
+    /**
+     * 验证码 redis key
+     */
+    public static final String CAPTCHA_CODE_KEY = "captcha_codes:";
+
+    /**
+     * 登录用户 redis key
+     */
+    public static final String LOGIN_TOKEN_KEY = "login_tokens:";
+    
+    /**
+     * 防重提交 redis key
+     */
+    public static final String REPEAT_SUBMIT_KEY = "repeat_submit:";
+
+    /**
+     * 验证码有效期(分钟)
+     */
+    public static final Integer CAPTCHA_EXPIRATION = 2;
+
+    /**
+     * 令牌
+     */
+    public static final String TOKEN = "token";
+
+    /**
+     * 令牌前缀
+     */
+    public static final String TOKEN_PREFIX = "Bearer ";
+
+    /**
+     * 令牌前缀
+     */
+    public static final String LOGIN_USER_KEY = "login_user_key";
+
+    /**
+     * 用户ID
+     */
+    public static final String JWT_USERID = "userid";
+
+    /**
+     * 用户名称
+     */
+    public static final String JWT_USERNAME = Claims.SUBJECT;
+
+    /**
+     * 用户头像
+     */
+    public static final String JWT_AVATAR = "avatar";
+
+    /**
+     * 创建时间
+     */
+    public static final String JWT_CREATED = "created";
+
+    /**
+     * 用户权限
+     */
+    public static final String JWT_AUTHORITIES = "authorities";
+
+    /**
+     * 参数管理 cache key
+     */
+    public static final String SYS_CONFIG_KEY = "sys_config:";
+
+    /**
+     * 字典管理 cache key
+     */
+    public static final String SYS_DICT_KEY = "sys_dict:";
+
+    /**
+     * 资源映射路径 前缀
+     */
+    public static final String RESOURCE_PREFIX = "/profile";
+
+    /**
+     * RMI 远程方法调用
+     */
+    public static final String LOOKUP_RMI = "rmi://";
+}

+ 105 - 0
fiveep-model/src/main/java/com/bizmatics/model/system/SysConfig.java

@@ -0,0 +1,105 @@
+package com.bizmatics.model.system;
+
+import com.bizmatics.model.base.BaseEntity;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Size;
+
+/**
+ * 参数配置表 sys_config
+ * 
+ * @author ruoyi
+ */
+public class SysConfig extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 参数主键 */
+    private Long configId;
+
+    /** 参数名称 */
+    private String configName;
+
+    /** 参数键名 */
+    private String configKey;
+
+    /** 参数键值 */
+    private String configValue;
+
+    /** 系统内置(Y是 N否) */
+    private String configType;
+
+    public Long getConfigId()
+    {
+        return configId;
+    }
+
+    public void setConfigId(Long configId)
+    {
+        this.configId = configId;
+    }
+
+    @NotBlank(message = "参数名称不能为空")
+    @Size(min = 0, max = 100, message = "参数名称不能超过100个字符")
+    public String getConfigName()
+    {
+        return configName;
+    }
+
+    public void setConfigName(String configName)
+    {
+        this.configName = configName;
+    }
+
+    @NotBlank(message = "参数键名长度不能为空")
+    @Size(min = 0, max = 100, message = "参数键名长度不能超过100个字符")
+    public String getConfigKey()
+    {
+        return configKey;
+    }
+
+    public void setConfigKey(String configKey)
+    {
+        this.configKey = configKey;
+    }
+
+    @NotBlank(message = "参数键值不能为空")
+    @Size(min = 0, max = 500, message = "参数键值长度不能超过500个字符")
+    public String getConfigValue()
+    {
+        return configValue;
+    }
+
+    public void setConfigValue(String configValue)
+    {
+        this.configValue = configValue;
+    }
+
+    public String getConfigType()
+    {
+        return configType;
+    }
+
+    public void setConfigType(String configType)
+    {
+        this.configType = configType;
+    }
+    
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("configId", getConfigId())
+            .append("configName", getConfigName())
+            .append("configKey", getConfigKey())
+            .append("configValue", getConfigValue())
+            .append("configType", getConfigType())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .append("remark", getRemark())
+            .toString();
+    }
+}

+ 102 - 0
fiveep-model/src/main/java/com/bizmatics/model/system/SysNotice.java

@@ -0,0 +1,102 @@
+package com.bizmatics.model.system;
+
+import com.bizmatics.model.base.BaseEntity;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Size;
+
+
+/**
+ * 通知公告表 sys_notice
+ * 
+ * @author ruoyi
+ */
+public class SysNotice extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 公告ID */
+    private Long noticeId;
+
+    /** 公告标题 */
+    private String noticeTitle;
+
+    /** 公告类型(1通知 2公告) */
+    private String noticeType;
+
+    /** 公告内容 */
+    private String noticeContent;
+
+    /** 公告状态(0正常 1关闭) */
+    private String status;
+
+    public Long getNoticeId()
+    {
+        return noticeId;
+    }
+
+    public void setNoticeId(Long noticeId)
+    {
+        this.noticeId = noticeId;
+    }
+
+    public void setNoticeTitle(String noticeTitle)
+    {
+        this.noticeTitle = noticeTitle;
+    }
+
+    @NotBlank(message = "公告标题不能为空")
+    @Size(min = 0, max = 50, message = "公告标题不能超过50个字符")
+    public String getNoticeTitle()
+    {
+        return noticeTitle;
+    }
+
+    public void setNoticeType(String noticeType)
+    {
+        this.noticeType = noticeType;
+    }
+
+    public String getNoticeType()
+    {
+        return noticeType;
+    }
+
+    public void setNoticeContent(String noticeContent)
+    {
+        this.noticeContent = noticeContent;
+    }
+
+    public String getNoticeContent()
+    {
+        return noticeContent;
+    }
+
+    public void setStatus(String status)
+    {
+        this.status = status;
+    }
+
+    public String getStatus()
+    {
+        return status;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("noticeId", getNoticeId())
+            .append("noticeTitle", getNoticeTitle())
+            .append("noticeType", getNoticeType())
+            .append("noticeContent", getNoticeContent())
+            .append("status", getStatus())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .append("remark", getRemark())
+            .toString();
+    }
+}

+ 238 - 0
fiveep-model/src/main/java/com/bizmatics/model/system/SysOperLog.java

@@ -0,0 +1,238 @@
+package com.bizmatics.model.system;
+
+import com.bizmatics.model.base.BaseEntity;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import java.util.Date;
+
+/**
+ * 操作日志记录表 oper_log
+ * 
+ * @author ruoyi
+ */
+public class SysOperLog extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 日志主键 */
+    private Long operId;
+
+    /** 操作模块 */
+    private String title;
+
+    /** 业务类型(0其它 1新增 2修改 3删除) */
+    private Integer businessType;
+
+    /** 业务类型数组 */
+    private Integer[] businessTypes;
+
+    /** 请求方法 */
+    private String method;
+
+    /** 请求方式 */
+    private String requestMethod;
+
+    /** 操作类别(0其它 1后台用户 2手机端用户) */
+    private Integer operatorType;
+
+    /** 操作人员 */
+    private String operName;
+
+    /** 部门名称 */
+    private String deptName;
+
+    /** 请求url */
+    private String operUrl;
+
+    /** 操作地址 */
+    private String operIp;
+
+    /** 操作地点 */
+    private String operLocation;
+
+    /** 请求参数 */
+    private String operParam;
+
+    /** 返回参数 */
+    private String jsonResult;
+
+    /** 操作状态(0正常 1异常) */
+    private Integer status;
+
+    /** 错误消息 */
+    private String errorMsg;
+
+    /** 操作时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date operTime;
+
+    public Long getOperId()
+    {
+        return operId;
+    }
+
+    public void setOperId(Long operId)
+    {
+        this.operId = operId;
+    }
+
+    public String getTitle()
+    {
+        return title;
+    }
+
+    public void setTitle(String title)
+    {
+        this.title = title;
+    }
+
+    public Integer getBusinessType()
+    {
+        return businessType;
+    }
+
+    public void setBusinessType(Integer businessType)
+    {
+        this.businessType = businessType;
+    }
+
+    public Integer[] getBusinessTypes()
+    {
+        return businessTypes;
+    }
+
+    public void setBusinessTypes(Integer[] businessTypes)
+    {
+        this.businessTypes = businessTypes;
+    }
+
+    public String getMethod()
+    {
+        return method;
+    }
+
+    public void setMethod(String method)
+    {
+        this.method = method;
+    }
+
+    public String getRequestMethod()
+    {
+        return requestMethod;
+    }
+
+    public void setRequestMethod(String requestMethod)
+    {
+        this.requestMethod = requestMethod;
+    }
+
+    public Integer getOperatorType()
+    {
+        return operatorType;
+    }
+
+    public void setOperatorType(Integer operatorType)
+    {
+        this.operatorType = operatorType;
+    }
+
+    public String getOperName()
+    {
+        return operName;
+    }
+
+    public void setOperName(String operName)
+    {
+        this.operName = operName;
+    }
+
+    public String getDeptName()
+    {
+        return deptName;
+    }
+
+    public void setDeptName(String deptName)
+    {
+        this.deptName = deptName;
+    }
+
+    public String getOperUrl()
+    {
+        return operUrl;
+    }
+
+    public void setOperUrl(String operUrl)
+    {
+        this.operUrl = operUrl;
+    }
+
+    public String getOperIp()
+    {
+        return operIp;
+    }
+
+    public void setOperIp(String operIp)
+    {
+        this.operIp = operIp;
+    }
+
+    public String getOperLocation()
+    {
+        return operLocation;
+    }
+
+    public void setOperLocation(String operLocation)
+    {
+        this.operLocation = operLocation;
+    }
+
+    public String getOperParam()
+    {
+        return operParam;
+    }
+
+    public void setOperParam(String operParam)
+    {
+        this.operParam = operParam;
+    }
+
+    public String getJsonResult()
+    {
+        return jsonResult;
+    }
+
+    public void setJsonResult(String jsonResult)
+    {
+        this.jsonResult = jsonResult;
+    }
+
+    public Integer getStatus()
+    {
+        return status;
+    }
+
+    public void setStatus(Integer status)
+    {
+        this.status = status;
+    }
+
+    public String getErrorMsg()
+    {
+        return errorMsg;
+    }
+
+    public void setErrorMsg(String errorMsg)
+    {
+        this.errorMsg = errorMsg;
+    }
+
+    public Date getOperTime()
+    {
+        return operTime;
+    }
+
+    public void setOperTime(Date operTime)
+    {
+        this.operTime = operTime;
+    }
+}

+ 117 - 0
fiveep-model/src/main/java/com/bizmatics/model/system/SysPost.java

@@ -0,0 +1,117 @@
+package com.bizmatics.model.system;
+
+import com.bizmatics.model.base.BaseEntity;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Size;
+
+/**
+ * 岗位表 sys_post
+ * 
+ * @author ruoyi
+ */
+public class SysPost extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 岗位序号 */
+    private Long postId;
+
+    /** 岗位编码 */
+    private String postCode;
+
+    /** 岗位名称 */
+    private String postName;
+
+    /** 岗位排序 */
+    private String postSort;
+
+    /** 状态(0正常 1停用) */
+    private String status;
+
+    /** 用户是否存在此岗位标识 默认不存在 */
+    private boolean flag = false;
+
+    public Long getPostId()
+    {
+        return postId;
+    }
+
+    public void setPostId(Long postId)
+    {
+        this.postId = postId;
+    }
+
+    @NotBlank(message = "岗位编码不能为空")
+    @Size(min = 0, max = 64, message = "岗位编码长度不能超过64个字符")
+    public String getPostCode()
+    {
+        return postCode;
+    }
+
+    public void setPostCode(String postCode)
+    {
+        this.postCode = postCode;
+    }
+
+    @NotBlank(message = "岗位名称不能为空")
+    @Size(min = 0, max = 50, message = "岗位名称长度不能超过50个字符")
+    public String getPostName()
+    {
+        return postName;
+    }
+
+    public void setPostName(String postName)
+    {
+        this.postName = postName;
+    }
+
+    @NotBlank(message = "显示顺序不能为空")
+    public String getPostSort()
+    {
+        return postSort;
+    }
+
+    public void setPostSort(String postSort)
+    {
+        this.postSort = postSort;
+    }
+
+    public String getStatus()
+    {
+        return status;
+    }
+
+    public void setStatus(String status)
+    {
+        this.status = status;
+    }
+
+    public boolean isFlag()
+    {
+        return flag;
+    }
+
+    public void setFlag(boolean flag)
+    {
+        this.flag = flag;
+    }
+    
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("postId", getPostId())
+            .append("postCode", getPostCode())
+            .append("postName", getPostName())
+            .append("postSort", getPostSort())
+            .append("status", getStatus())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .append("remark", getRemark())
+            .toString();
+    }
+}

+ 46 - 0
fiveep-model/src/main/java/com/bizmatics/model/system/SysRoleDept.java

@@ -0,0 +1,46 @@
+package com.bizmatics.model.system;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+/**
+ * 角色和部门关联 sys_role_dept
+ * 
+ * @author ruoyi
+ */
+public class SysRoleDept
+{
+    /** 角色ID */
+    private Long roleId;
+    
+    /** 部门ID */
+    private Long deptId;
+
+    public Long getRoleId()
+    {
+        return roleId;
+    }
+
+    public void setRoleId(Long roleId)
+    {
+        this.roleId = roleId;
+    }
+
+    public Long getDeptId()
+    {
+        return deptId;
+    }
+
+    public void setDeptId(Long deptId)
+    {
+        this.deptId = deptId;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("roleId", getRoleId())
+            .append("deptId", getDeptId())
+            .toString();
+    }
+}

+ 46 - 0
fiveep-model/src/main/java/com/bizmatics/model/system/SysRoleMenu.java

@@ -0,0 +1,46 @@
+package com.bizmatics.model.system;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+/**
+ * 角色和菜单关联 sys_role_menu
+ * 
+ * @author ruoyi
+ */
+public class SysRoleMenu
+{
+    /** 角色ID */
+    private Long roleId;
+    
+    /** 菜单ID */
+    private Long menuId;
+
+    public Long getRoleId()
+    {
+        return roleId;
+    }
+
+    public void setRoleId(Long roleId)
+    {
+        this.roleId = roleId;
+    }
+
+    public Long getMenuId()
+    {
+        return menuId;
+    }
+
+    public void setMenuId(Long menuId)
+    {
+        this.menuId = menuId;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("roleId", getRoleId())
+            .append("menuId", getMenuId())
+            .toString();
+    }
+}

+ 113 - 0
fiveep-model/src/main/java/com/bizmatics/model/system/SysUserOnline.java

@@ -0,0 +1,113 @@
+package com.bizmatics.model.system;
+
+/**
+ * 当前在线会话
+ * 
+ * @author ruoyi
+ */
+public class SysUserOnline
+{
+    /** 会话编号 */
+    private String tokenId;
+
+    /** 部门名称 */
+    private String deptName;
+
+    /** 用户名称 */
+    private String userName;
+
+    /** 登录IP地址 */
+    private String ipaddr;
+
+    /** 登录地址 */
+    private String loginLocation;
+
+    /** 浏览器类型 */
+    private String browser;
+
+    /** 操作系统 */
+    private String os;
+
+    /** 登录时间 */
+    private Long loginTime;
+
+    public String getTokenId()
+    {
+        return tokenId;
+    }
+
+    public void setTokenId(String tokenId)
+    {
+        this.tokenId = tokenId;
+    }
+
+    public String getDeptName()
+    {
+        return deptName;
+    }
+
+    public void setDeptName(String deptName)
+    {
+        this.deptName = deptName;
+    }
+
+    public String getUserName()
+    {
+        return userName;
+    }
+
+    public void setUserName(String userName)
+    {
+        this.userName = userName;
+    }
+
+    public String getIpaddr()
+    {
+        return ipaddr;
+    }
+
+    public void setIpaddr(String ipaddr)
+    {
+        this.ipaddr = ipaddr;
+    }
+
+    public String getLoginLocation()
+    {
+        return loginLocation;
+    }
+
+    public void setLoginLocation(String loginLocation)
+    {
+        this.loginLocation = loginLocation;
+    }
+
+    public String getBrowser()
+    {
+        return browser;
+    }
+
+    public void setBrowser(String browser)
+    {
+        this.browser = browser;
+    }
+
+    public String getOs()
+    {
+        return os;
+    }
+
+    public void setOs(String os)
+    {
+        this.os = os;
+    }
+
+    public Long getLoginTime()
+    {
+        return loginTime;
+    }
+
+    public void setLoginTime(Long loginTime)
+    {
+        this.loginTime = loginTime;
+    }
+}

+ 46 - 0
fiveep-model/src/main/java/com/bizmatics/model/system/SysUserPost.java

@@ -0,0 +1,46 @@
+package com.bizmatics.model.system;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+/**
+ * 用户和岗位关联 sys_user_post
+ * 
+ * @author ruoyi
+ */
+public class SysUserPost
+{
+    /** 用户ID */
+    private Long userId;
+    
+    /** 岗位ID */
+    private Long postId;
+
+    public Long getUserId()
+    {
+        return userId;
+    }
+
+    public void setUserId(Long userId)
+    {
+        this.userId = userId;
+    }
+
+    public Long getPostId()
+    {
+        return postId;
+    }
+
+    public void setPostId(Long postId)
+    {
+        this.postId = postId;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("userId", getUserId())
+            .append("postId", getPostId())
+            .toString();
+    }
+}

+ 46 - 0
fiveep-model/src/main/java/com/bizmatics/model/system/SysUserRole.java

@@ -0,0 +1,46 @@
+package com.bizmatics.model.system;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+/**
+ * 用户和角色关联 sys_user_role
+ * 
+ * @author ruoyi
+ */
+public class SysUserRole
+{
+    /** 用户ID */
+    private Long userId;
+    
+    /** 角色ID */
+    private Long roleId;
+
+    public Long getUserId()
+    {
+        return userId;
+    }
+
+    public void setUserId(Long userId)
+    {
+        this.userId = userId;
+    }
+
+    public Long getRoleId()
+    {
+        return roleId;
+    }
+
+    public void setRoleId(Long roleId)
+    {
+        this.roleId = roleId;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("userId", getUserId())
+            .append("roleId", getRoleId())
+            .toString();
+    }
+}

+ 4 - 1
fiveep-model/src/main/java/com/bizmatics/model/vo/MetaVo.java

@@ -1,6 +1,9 @@
 package com.bizmatics.model.vo;
 
 
+import com.bizmatics.common.core.util.StringUtils;
+import com.bizmatics.model.constants.Constants;
+
 /**
  * 路由显示信息
  * 
@@ -57,7 +60,7 @@ public class MetaVo
         this.title = title;
         this.icon = icon;
         this.noCache = noCache;
-        if (StringUtils.ishttp(link))
+        if (StringUtils.startsWithAny(link, Constants.HTTP, Constants.HTTPS))
         {
             this.link = link;
         }

+ 4 - 4
fiveep-service/pom.xml

@@ -71,11 +71,11 @@
             <artifactId>spring-boot-starter-security</artifactId>
         </dependency>
 
-        <!--Token生成与解析-->
+        <!-- 解析客户端操作系统、浏览器等 -->
         <dependency>
-            <groupId>io.jsonwebtoken</groupId>
-            <artifactId>jjwt</artifactId>
-            <version>0.9.1</version>
+            <groupId>eu.bitwalker</groupId>
+            <artifactId>UserAgentUtils</artifactId>
+            <version>1.21</version>
         </dependency>
 
     </dependencies>

+ 116 - 0
fiveep-service/src/main/java/com/bizmatics/service/config/RuoYiConfig.java

@@ -0,0 +1,116 @@
+package com.bizmatics.service.config;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+/**
+ * 读取项目相关配置
+ * 
+ * @author ruoyi
+ */
+@Component
+@ConfigurationProperties(prefix = "ruoyi")
+public class RuoYiConfig
+{
+    /** 项目名称 */
+    private String name;
+
+    /** 版本 */
+    private String version;
+
+    /** 版权年份 */
+    private String copyrightYear;
+
+    /** 实例演示开关 */
+    private boolean demoEnabled;
+
+    /** 上传路径 */
+    private static String profile;
+
+    /** 获取地址开关 */
+    private static boolean addressEnabled;
+
+    public String getName()
+    {
+        return name;
+    }
+
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+    public String getVersion()
+    {
+        return version;
+    }
+
+    public void setVersion(String version)
+    {
+        this.version = version;
+    }
+
+    public String getCopyrightYear()
+    {
+        return copyrightYear;
+    }
+
+    public void setCopyrightYear(String copyrightYear)
+    {
+        this.copyrightYear = copyrightYear;
+    }
+
+    public boolean isDemoEnabled()
+    {
+        return demoEnabled;
+    }
+
+    public void setDemoEnabled(boolean demoEnabled)
+    {
+        this.demoEnabled = demoEnabled;
+    }
+
+    public static String getProfile()
+    {
+        return profile;
+    }
+
+    public void setProfile(String profile)
+    {
+        RuoYiConfig.profile = profile;
+    }
+
+    public static boolean isAddressEnabled()
+    {
+        return addressEnabled;
+    }
+
+    public void setAddressEnabled(boolean addressEnabled)
+    {
+        RuoYiConfig.addressEnabled = addressEnabled;
+    }
+
+    /**
+     * 获取头像上传路径
+     */
+    public static String getAvatarPath()
+    {
+        return getProfile() + "/avatar";
+    }
+
+    /**
+     * 获取下载路径
+     */
+    public static String getDownloadPath()
+    {
+        return getProfile() + "/download/";
+    }
+
+    /**
+     * 获取上传路径
+     */
+    public static String getUploadPath()
+    {
+        return getProfile() + "/upload";
+    }
+}

+ 34 - 36
fiveep-service/src/main/java/com/bizmatics/service/impl/AlarmPowerServiceImpl.java

@@ -13,7 +13,7 @@ import com.bizmatics.common.spring.util.GlobalUtils;
 import com.bizmatics.model.AlarmPower;
 import com.bizmatics.persistence.mapper.AlarmPowerMapper;
 import com.bizmatics.service.AlarmPowerService;
-import com.bizmatics.service.util.SessionLocal;
+import com.bizmatics.service.util.SecurityUtils;
 import com.bizmatics.service.vo.AlarmPowerExportVO;
 import com.bizmatics.service.vo.ApCountVO;
 import com.bizmatics.service.vo.CommonIcoVO;
@@ -42,9 +42,8 @@ public class AlarmPowerServiceImpl extends AbstractCrudService<AlarmPowerMapper,
 
 
     @Override
-    public ApCountVO selectCount(Integer siteId,Date startTime,Date endTime) {
-//        Integer userId = UserUtil.getUserId();
-        Integer userId = SessionLocal.getUserId();
+    public ApCountVO selectCount(Integer siteId, Date startTime, Date endTime) {
+        Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
         ApCountVO apCountVo = new ApCountVO();
         apCountVo.setCount(baseMapper.selectCount(userId, siteId, null, startTime, endTime, null, null));
         apCountVo.setUnCount(baseMapper.selectCount(userId, siteId, 0, startTime, endTime, null, null));
@@ -52,22 +51,21 @@ public class AlarmPowerServiceImpl extends AbstractCrudService<AlarmPowerMapper,
     }
 
     @Override
-    public List<CommonIcoVO> selectByDate(Date startTime,Date endTime,Integer siteId) {
+    public List<CommonIcoVO> selectByDate(Date startTime, Date endTime, Integer siteId) {
         List<Object> faultList = new ArrayList<>();
         List<Object> rushList = new ArrayList<>();
         List<Object> noDisposeList = new ArrayList<>();
         List<Object> dateList = new ArrayList<>();
-//        Integer userId = UserUtil.getUserId();
-        Integer userId = SessionLocal.getUserId();
+        Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
         List<AlarmPower> alarmPowers = baseMapper.list(userId, siteId, null, startTime, endTime, null, null);
-        for (int i = 0; i < DateUtils.getDistanceDayOfTwoDate(startTime,endTime); i++) {
+        for (int i = 0; i < DateUtils.getDistanceDayOfTwoDate(startTime, endTime); i++) {
             Date setDays = DateUtils.addDays(startTime, i);
             Date dayStartTime = DateUtils.getDayStartTime(setDays);
             Date dayEndTime = DateUtils.getDayEndTime(setDays);
-            faultList.add(getCount(alarmPowers,null,dayStartTime,dayEndTime,null,null));
-            rushList.add(getCount(alarmPowers,1,dayStartTime,dayEndTime,null,null));
-            noDisposeList.add(getCount(alarmPowers,0,dayStartTime,dayEndTime,null,null));
-            dateList.add(DateUtils.getMonth(setDays)+"-"+DateUtils.getDay(setDays));
+            faultList.add(getCount(alarmPowers, null, dayStartTime, dayEndTime, null, null));
+            rushList.add(getCount(alarmPowers, 1, dayStartTime, dayEndTime, null, null));
+            noDisposeList.add(getCount(alarmPowers, 0, dayStartTime, dayEndTime, null, null));
+            dateList.add(DateUtils.getMonth(setDays) + "-" + DateUtils.getDay(setDays));
         }
         List<CommonIcoVO> list = new ArrayList<>();
         list.add(CommonIcoVO.builder().name("故障数量").list(faultList).listDate(dateList).build());
@@ -77,9 +75,10 @@ public class AlarmPowerServiceImpl extends AbstractCrudService<AlarmPowerMapper,
     }
 
     @Override
-    public CommonPage<AlarmPower> page(Date startTime, Date endTime, Integer status, Integer siteId,Integer current,Integer size) {
+    public CommonPage<AlarmPower> page(Date startTime, Date endTime, Integer status, Integer siteId, Integer current, Integer size) {
         Page<AlarmPower> page = new Page<>(current, size);
-        page = baseMapper.page(page,SessionLocal.getUserId(),siteId,status,startTime,endTime);
+        Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
+        page = baseMapper.page(page, userId, siteId, status, startTime, endTime);
         return this.ToCommonPage(page);
     }
 
@@ -89,15 +88,15 @@ public class AlarmPowerServiceImpl extends AbstractCrudService<AlarmPowerMapper,
         List<Map<String, Object>> list = new ArrayList<>();
         List<AlarmPower> loopStatusListMap = baseMapper.getLoopStatusListMap(siteId);
         int int1 = 0;
-        int int12= 0;
-        Map<String,Object> map = new HashMap<>();
+        int int12 = 0;
+        Map<String, Object> map = new HashMap<>();
         loopStatusListMap.forEach(alarmPower -> {
 //            if (alarmPower.getDigitalValue() == 0){
 //                String time1 = formatter.format(alarmPower.getSoeTime());
 //            }else if(alarmPower.getDigitalValue() == 1){
 //                String time2 = formatter.format(alarmPower.getSoeTime());
 //            }
-            if (alarmPower.getDigitalValue() == 0){
+            if (alarmPower.getDigitalValue() == 0) {
 //                Duration differenceValue = Duration.between(time1 ,time2 );
                 // 获取的是两个时间相差的分钟数,如果想要相差小时数就调用toHours()
 //                Long minutesTime = differenceValue .toMinutes();
@@ -127,19 +126,18 @@ public class AlarmPowerServiceImpl extends AbstractCrudService<AlarmPowerMapper,
     }
 
     @Override
-    public String export(Date startTime, Date endTime, Integer status, Integer siteId){
-//        Integer userId = UserUtil.getUserId();
-        Integer userId = SessionLocal.getUserId();
+    public String export(Date startTime, Date endTime, Integer status, Integer siteId) {
+        Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
         Workbook workbook = null;
         File file = null;
         try {
             ExportParams params = new ExportParams(null, "电力告警");
             workbook = ExcelExportUtil.exportBigExcel(params, AlarmPowerExportVO.class,
-                        (o, i) -> {
+                    (o, i) -> {
                         Page<AlarmPower> page = new Page<>(i, 30);
                         page = baseMapper.page(page, userId, siteId, status, startTime, endTime);
-                            return new ArrayList<>(BeanMapperUtils.mapList(page.getRecords(), AlarmPower.class, AlarmPowerExportVO.class));
-                    },null);
+                        return new ArrayList<>(BeanMapperUtils.mapList(page.getRecords(), AlarmPower.class, AlarmPowerExportVO.class));
+                    }, null);
             if (null != workbook) {
                 file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "电力告警", System.currentTimeMillis() + ""));
                 FileUtils.createFile(file.getAbsolutePath());
@@ -165,8 +163,7 @@ public class AlarmPowerServiceImpl extends AbstractCrudService<AlarmPowerMapper,
 
     @Override
     public List<CommonIcoVO> runStatus(Date startTime, Date endTime, Integer siteId) {
-//        Integer userId = UserUtil.getUserId();
-        Integer userId = SessionLocal.getUserId();
+        Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
         List<CommonIcoVO> list = new ArrayList<>();
         List<Object> offCounts = new ArrayList<>();
         List<Object> offDateS = new ArrayList<>();
@@ -174,31 +171,31 @@ public class AlarmPowerServiceImpl extends AbstractCrudService<AlarmPowerMapper,
         List<Object> runDates = new ArrayList<>();
         long offTime = 0;
         List<AlarmPower> alarmPowers = baseMapper.list(userId, siteId, null, startTime, endTime, "LoadLive", null);
-        if (!CollectionUtils.isEmpty(list)){
+        if (!CollectionUtils.isEmpty(list)) {
             Date forEndTime;
             do {
                 Date dayStartTime = DateUtils.getDayStartTime(startTime);
                 Date dayEndTime = DateUtils.getDayEndTime(startTime);
-                offCounts.add(getCount(alarmPowers,null,dayStartTime,dayEndTime,null,null));
+                offCounts.add(getCount(alarmPowers, null, dayStartTime, dayEndTime, null, null));
                 forEndTime = dayEndTime;
-                offDateS.add(DateUtils.format(endTime,DateUtils.PARSE_PATTERNS[8]));
+                offDateS.add(DateUtils.format(endTime, DateUtils.PARSE_PATTERNS[8]));
             } while (forEndTime.before(endTime));
             //上次off时间
             long offStartTime = 0;
             //off状态
             Integer flag = null;
-            for (AlarmPower alarmPower:alarmPowers) {
+            for (AlarmPower alarmPower : alarmPowers) {
                 Integer digitalValue = alarmPower.getDigitalValue();
                 Date sendingTime = alarmPower.getSendingTime();
                 runStatus.add(digitalValue);
-                runDates.add(DateUtils.format(sendingTime,DateUtils.PARSE_PATTERNS[5]));
-                if (1 == digitalValue){
-                    if (null == flag || 0 == flag){
+                runDates.add(DateUtils.format(sendingTime, DateUtils.PARSE_PATTERNS[5]));
+                if (1 == digitalValue) {
+                    if (null == flag || 0 == flag) {
                         offStartTime = sendingTime.getTime();
                     }
-                }else {
-                    if (null != flag && 1 == flag){
-                        offTime+=sendingTime.getTime()-offStartTime;
+                } else {
+                    if (null != flag && 1 == flag) {
+                        offTime += sendingTime.getTime() - offStartTime;
                     }
                 }
                 flag = alarmPower.getDigitalValue();
@@ -213,13 +210,14 @@ public class AlarmPowerServiceImpl extends AbstractCrudService<AlarmPowerMapper,
 
     /**
      * 汇总
+     *
      * @param list
      * @param handlingStatus
      * @param startTime
      * @param endTime
      * @param digitalStatus
      */
-    public Long getCount(List<AlarmPower> list,Integer handlingStatus, Date startTime, Date endTime, Integer digitalStatus,String measName){
+    public Long getCount(List<AlarmPower> list, Integer handlingStatus, Date startTime, Date endTime, Integer digitalStatus, String measName) {
         return list.stream()
                 .filter(alarmPower -> alarmPower.getSendingTime().after(startTime) && alarmPower.getSendingTime().before(endTime))
                 .filter(alarmPower -> Optional.ofNullable(handlingStatus).map(hand -> hand.equals(alarmPower.getHandlingStatus())).orElse(true))

+ 13 - 14
fiveep-service/src/main/java/com/bizmatics/service/impl/DeviceServiceImpl.java

@@ -6,7 +6,7 @@ import com.bizmatics.persistence.mapper.DeviceMapper;
 import com.bizmatics.service.DeviceService;
 import com.bizmatics.service.enums.DeviceStatusCode;
 import com.bizmatics.service.enums.DeviceType;
-import com.bizmatics.service.util.SessionLocal;
+import com.bizmatics.service.util.SecurityUtils;
 import com.bizmatics.service.vo.DeviceCountVO;
 import org.springframework.stereotype.Service;
 
@@ -16,7 +16,7 @@ import java.util.Optional;
 
 /**
  * <p>
- *  服务实现类
+ * 服务实现类
  * </p>
  *
  * @author ya
@@ -28,44 +28,43 @@ public class DeviceServiceImpl extends AbstractCrudService<DeviceMapper, Device>
 
     @Override
     public DeviceCountVO selectDeviceCount(Date startTime, Date endTime) {
-//        Integer userId = UserUtil.getUserId();
-        Integer userId = SessionLocal.getUserId();
+        Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
         DeviceCountVO deviceCountVo = new DeviceCountVO();
         deviceCountVo.setNormalCount(baseMapper
-                .selectCount(userId,null,DeviceStatusCode.NORMAL.getValue(),startTime,endTime,null));
+                .selectCount(userId, null, DeviceStatusCode.NORMAL.getValue(), startTime, endTime, null));
         deviceCountVo.setOffLineCount(baseMapper
-                .selectCount(userId,null,DeviceStatusCode.OFFLINE.getValue(),startTime,endTime,null));
+                .selectCount(userId, null, DeviceStatusCode.OFFLINE.getValue(), startTime, endTime, null));
         deviceCountVo.setDeviceCount(baseMapper
-                .selectCount(userId,null,DeviceStatusCode.DEVICE.getValue(),startTime,endTime,null));
+                .selectCount(userId, null, DeviceStatusCode.DEVICE.getValue(), startTime, endTime, null));
         deviceCountVo.setFaultCount(baseMapper
-                .selectCount(userId,null,DeviceStatusCode.FAULT.getValue(),startTime,endTime,null));
+                .selectCount(userId, null, DeviceStatusCode.FAULT.getValue(), startTime, endTime, null));
         deviceCountVo.setCount(baseMapper
-                .selectCount(userId,null,null,startTime,endTime,null));
+                .selectCount(userId, null, null, startTime, endTime, null));
         return deviceCountVo;
     }
 
     @Override
     public DeviceCountVO selectDeviceCountByType(Integer site) {
         DeviceCountVO deviceCountVo = new DeviceCountVO();
-//        Integer userId = UserUtil.getUserId();
-        Integer userId = SessionLocal.getUserId();
+        Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
         int oneEightThreeEp = baseMapper.selectCount(userId, site, null, null, null, DeviceType.ONE_EIGHT_THREE_EP.getValue());
-        int oneSevenOneEp = baseMapper.selectCount(userId, site,null , null, null, DeviceType.ONE_SEVEN_ONE_EP.getValue());
+        int oneSevenOneEp = baseMapper.selectCount(userId, site, null, null, null, DeviceType.ONE_SEVEN_ONE_EP.getValue());
         int oneSevenThreeEp = baseMapper.selectCount(userId, site, null, null, null, DeviceType.ONE_SEVEN_THREE_EP.getValue());
         int video = baseMapper.selectCount(userId, site, null, null, null, DeviceType.VODEO_MONITROING.getValue());
-        deviceCountVo.setEpCount(oneEightThreeEp+oneSevenOneEp+oneSevenThreeEp);
+        deviceCountVo.setEpCount(oneEightThreeEp + oneSevenOneEp + oneSevenThreeEp);
         deviceCountVo.setVideoCount(video);
         return deviceCountVo;
     }
 
     /**
      * 汇总
+     *
      * @param list
      * @param deviceStatus
      * @param type
      * @return
      */
-    public Long getCount(List<Device> list, Integer deviceStatus, String type){
+    public Long getCount(List<Device> list, Integer deviceStatus, String type) {
         return list.stream()
                 .filter(device -> Optional.ofNullable(deviceStatus).map(ds -> ds.equals(device.getDeviceStatus())).orElse(true))
                 .filter(device -> Optional.ofNullable(type).map(ds -> ds.equals(device.getDeviceType())).orElse(true))

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

@@ -9,7 +9,7 @@ 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.SessionLocal;
+import com.bizmatics.service.util.SecurityUtils;
 import com.bizmatics.service.vo.CommonIcoVO;
 import com.bizmatics.service.vo.HadCountVO;
 import com.bizmatics.service.vo.TimeShareVO;
@@ -33,75 +33,74 @@ public class HtAnalogDataServiceImpl extends AbstractCrudService<HtAnalogDataMap
 
     @Autowired
     private HadSiteStaticService hadSiteStaticService;
+
     @Override
     public HadCountVO selectCount() {
         HadCountVO hadCountVO = new HadCountVO();
-//        Integer userId = UserUtil.getUserId();
-        Integer userId = SessionLocal.getUserId();
+        Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
         Date date = new Date();
-        hadCountVO.setDayCount(hadSiteStaticService.getCount(userId,DateUtils.getDayStartTime(date),date,null));
-        hadCountVO.setMonthCount(hadSiteStaticService.getCount(userId, DateUtils.getFirstDayOfMonth(date), date,null));
-        hadCountVO.setYearCount(hadSiteStaticService.getCount(userId,DateUtils.getBeginDayOfYear(date),date,null));
+        hadCountVO.setDayCount(hadSiteStaticService.getCount(userId, DateUtils.getDayStartTime(date), date, null));
+        hadCountVO.setMonthCount(hadSiteStaticService.getCount(userId, DateUtils.getFirstDayOfMonth(date), date, null));
+        hadCountVO.setYearCount(hadSiteStaticService.getCount(userId, DateUtils.getBeginDayOfYear(date), date, null));
         return hadCountVO;
     }
 
     @Override
     public List<CommonIcoVO> selectTrendByDate(Integer siteId) {
-//        Integer userId = UserUtil.getUserId();
-        Integer userId = SessionLocal.getUserId();
+        Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
         Date date = new Date();
         Date sTime = DateUtils.getDayStartTime(date);
         Date eTime = DateUtils.getDayEndTime(date);
-        Date ysTime = DateUtils.addDays(sTime,-1);
-        Date yeTime = DateUtils.addDays(eTime,-1);
+        Date ysTime = DateUtils.addDays(sTime, -1);
+        Date yeTime = DateUtils.addDays(eTime, -1);
         List<CommonIcoVO> list = new ArrayList<>();
-        if (null != siteId){
+        if (null != siteId) {
             list.add(getTreedBySite("昨日", siteId, ysTime, yeTime));
             list.add(getTreedBySite("今日", siteId, sTime, eTime));
-        }else {
-            list.add(getTrendOne("昨日", userId, ysTime,yeTime));
-            list.add(getTrendOne("今日", userId, sTime,eTime));
+        } else {
+            list.add(getTrendOne("昨日", userId, ysTime, yeTime));
+            list.add(getTrendOne("今日", userId, sTime, eTime));
         }
         return list;
     }
 
 
-    public CommonIcoVO getTrendOne(String name,Integer userId,Date startTime,Date endTime){
+    public CommonIcoVO getTrendOne(String name, Integer userId, Date startTime, Date endTime) {
         List<HadSiteStatic> list = hadSiteStaticService.list(null, startTime, endTime, userId);
         List<Object> objects = new ArrayList<>();
         objects.add(0.0);
         List<Object> dates = new ArrayList<>();
         dates.add("00:00:00");
-        for (int i = 2; i < 24 ; i+=2) {
+        for (int i = 2; i < 24; i += 2) {
             //结束时间
             Date hours = DateUtils.setHours(startTime, i);
             startTime = hours;
             dates.add(DateUtils.getTime(hours));
             Double hourCount = 0.00;
-            for (HadSiteStatic hadSiteStatic:list) {
+            for (HadSiteStatic hadSiteStatic : list) {
                 CommonIcoVO commonIcoVO = JsonUtils.fromJson(hadSiteStatic.getLoadIco(), CommonIcoVO.class);
                 List<Double> dataList = (List<Double>) commonIcoVO.getList();
-                hourCount+=dataList.get(i/2);
+                hourCount += dataList.get(i / 2);
             }
-            objects.add(Arith.div(hourCount,1,2));
+            objects.add(Arith.div(hourCount, 1, 2));
         }
         return CommonIcoVO.builder().name(name).list(objects).listDate(dates).build();
     }
 
-    CommonIcoVO getTreedBySite(String name,Integer siteId,Date startTime,Date endTime){
+    CommonIcoVO getTreedBySite(String name, Integer siteId, Date startTime, Date endTime) {
         Date sTime = DateUtils.getDayStartTime(startTime);
         Date eTime = DateUtils.getDayEndTime(endTime);
         HadSiteStatic hadSiteStatic = hadSiteStaticService.oneBySite(siteId, sTime, eTime);
         CommonIcoVO commonIcoVO = null;
-        if (null != hadSiteStatic){
+        if (null != hadSiteStatic) {
             commonIcoVO = JsonUtils.fromJson(hadSiteStatic.getLoadIco(), CommonIcoVO.class);
             commonIcoVO.setName(name);
-        }else {
+        } else {
             List<Object> objects = new ArrayList<>();
             objects.add(0.0);
             List<Object> dates = new ArrayList<>();
             dates.add("00:00:00");
-            for (int i = 2; i < 24 ; i+=2) {
+            for (int i = 2; i < 24; i += 2) {
                 //结束时间
                 Date hours = DateUtils.setHours(startTime, i);
                 objects.add(0.0);
@@ -116,22 +115,21 @@ public class HtAnalogDataServiceImpl extends AbstractCrudService<HtAnalogDataMap
     @Override
     public List<CommonIcoVO> selectTrendByMonth() {
         Date date = new Date();
-//        Integer userId = UserUtil.getUserId();
-        Integer userId = SessionLocal.getUserId();
+        Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
         List<CommonIcoVO> list = new ArrayList<>();
-        list.add(selectTreedMonthOne(DateUtils.getLastDayOfMonth(DateUtils.addMonths(date,-1)),userId,"上月趋势图"));
-        list.add(selectTreedMonthOne(DateUtils.getLastDayOfMonth(date),userId,"当月趋势图"));
+        list.add(selectTreedMonthOne(DateUtils.getLastDayOfMonth(DateUtils.addMonths(date, -1)), userId, "上月趋势图"));
+        list.add(selectTreedMonthOne(DateUtils.getLastDayOfMonth(date), userId, "当月趋势图"));
         return list;
     }
 
-    public CommonIcoVO selectTreedMonthOne(Date date,Integer userId,String name){
+    public CommonIcoVO selectTreedMonthOne(Date date, Integer userId, String name) {
         List<Object> objects = new ArrayList<>();
         List<Object> dateList = new ArrayList<>();
         for (int i = 1; i <= Integer.parseInt(DateUtils.getDay(date)); i++) {
             Date setDays = DateUtils.setDays(date, i);
             Date dayStartTime = DateUtils.getDayStartTime(setDays);
             Date dayEndTime = DateUtils.getDayEndTime(setDays);
-            objects.add(hadSiteStaticService.getCount(userId,dayStartTime,dayEndTime,null));
+            objects.add(hadSiteStaticService.getCount(userId, dayStartTime, dayEndTime, null));
             dateList.add(DateUtils.getDay(setDays));
         }
         return CommonIcoVO.builder().name(name).list(objects).listDate(dateList).build();
@@ -139,8 +137,7 @@ public class HtAnalogDataServiceImpl extends AbstractCrudService<HtAnalogDataMap
 
     @Override
     public HadCountVO getCountBySite(Integer siteId) {
-//        Integer userId = UserUtil.getUserId();
-        Integer userId = SessionLocal.getUserId();
+        Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
         Date date = new Date();
         //当日开始时间
         Date firstDayOfDate = DateUtils.getDayStartTime(date);
@@ -149,12 +146,12 @@ public class HtAnalogDataServiceImpl extends AbstractCrudService<HtAnalogDataMap
         //当年开始时间
         Date firstDayOfYear = DateUtils.getBeginDayOfYear(date);
         HadCountVO hadCountVO = new HadCountVO();
-        hadCountVO.setDayCount(hadSiteStaticService.getCount(userId,DateUtils.getDayStartTime(date),date,siteId));
-        hadCountVO.setMonthCount(hadSiteStaticService.getCount(userId, DateUtils.getFirstDayOfMonth(date), date,siteId));
-        hadCountVO.setYearCount(hadSiteStaticService.getCount(userId,DateUtils.getBeginDayOfYear(date),date,siteId));
-        hadCountVO.setLastDayCount(hadSiteStaticService.getCount(userId, DateUtils.addDays(firstDayOfDate, -1), DateUtils.addDays(date, -1),siteId));
-        hadCountVO.setLastMonthCount(hadSiteStaticService.getCount(userId, DateUtils.addMonths(firstDayOfMonth, -1), DateUtils.addMonths(date, -1),siteId));
-        hadCountVO.setLastYearCount(hadSiteStaticService.getCount(userId, DateUtils.addYears(firstDayOfYear, -1), DateUtils.addYears(date, -1),siteId));
+        hadCountVO.setDayCount(hadSiteStaticService.getCount(userId, DateUtils.getDayStartTime(date), date, siteId));
+        hadCountVO.setMonthCount(hadSiteStaticService.getCount(userId, DateUtils.getFirstDayOfMonth(date), date, siteId));
+        hadCountVO.setYearCount(hadSiteStaticService.getCount(userId, DateUtils.getBeginDayOfYear(date), date, siteId));
+        hadCountVO.setLastDayCount(hadSiteStaticService.getCount(userId, DateUtils.addDays(firstDayOfDate, -1), DateUtils.addDays(date, -1), siteId));
+        hadCountVO.setLastMonthCount(hadSiteStaticService.getCount(userId, DateUtils.addMonths(firstDayOfMonth, -1), DateUtils.addMonths(date, -1), siteId));
+        hadCountVO.setLastYearCount(hadSiteStaticService.getCount(userId, DateUtils.addYears(firstDayOfYear, -1), DateUtils.addYears(date, -1), siteId));
         hadCountVO.setDayRadio(Optional.ofNullable(hadCountVO.getDayCount())
                 .filter(dayCount -> 0.00 != dayCount)
                 .map(dayCount -> Arith.div(hadCountVO.getLastDayCount(), dayCount))
@@ -176,19 +173,19 @@ public class HtAnalogDataServiceImpl extends AbstractCrudService<HtAnalogDataMap
     public TimeShareVO getTimeShare(Integer siteId, Integer type) {
         TimeShareVO timeShareVO = new TimeShareVO();
         Date date = new Date();
-        if (0 == type){
+        if (0 == type) {
             HadSiteStatic hadSiteStatic = hadSiteStaticService.oneBySite(siteId, date, date);
-            Optional.ofNullable(hadSiteStatic).ifPresent(hads -> JsonUtils.fromJson(hads.getTimeShare(),timeShareVO.getClass()));
-        }else {
+            Optional.ofNullable(hadSiteStatic).ifPresent(hads -> JsonUtils.fromJson(hads.getTimeShare(), timeShareVO.getClass()));
+        } else {
             List<HadSiteStatic> list = hadSiteStaticService.list(siteId, DateUtils.getFirstDayOfMonth(date), date);
-            for (HadSiteStatic hadSiteStatic:list) {
+            for (HadSiteStatic hadSiteStatic : list) {
                 Optional.ofNullable(hadSiteStatic.getTimeShare())
                         .ifPresent(has -> {
                             TimeShareVO ts = JsonUtils.fromJson(has, TimeShareVO.class);
-                            timeShareVO.setFlat(Arith.add(timeShareVO.getFlat(),ts.getFlat()));
-                            timeShareVO.setPeak(Arith.add(timeShareVO.getPeak(),ts.getPeak()));
-                            timeShareVO.setNeed(Arith.add(timeShareVO.getNeed(),ts.getNeed()));
-                            timeShareVO.setGrain(Arith.add(timeShareVO.getGrain(),ts.getGrain()));
+                            timeShareVO.setFlat(Arith.add(timeShareVO.getFlat(), ts.getFlat()));
+                            timeShareVO.setPeak(Arith.add(timeShareVO.getPeak(), ts.getPeak()));
+                            timeShareVO.setNeed(Arith.add(timeShareVO.getNeed(), ts.getNeed()));
+                            timeShareVO.setGrain(Arith.add(timeShareVO.getGrain(), ts.getGrain()));
                         });
             }
         }
@@ -208,14 +205,14 @@ public class HtAnalogDataServiceImpl extends AbstractCrudService<HtAnalogDataMap
             Date dayStartTime = DateUtils.getDayStartTime(setDays);
             Date dayEndTime = DateUtils.getDayEndTime(setDays);
             maxList.add(hadSiteStatics.stream()
-                    .filter(hadSiteStatic -> DateUtils.isEffectiveDate(hadSiteStatic.getHadTime(),dayStartTime,dayEndTime)
+                    .filter(hadSiteStatic -> DateUtils.isEffectiveDate(hadSiteStatic.getHadTime(), dayStartTime, dayEndTime)
                     ).findFirst().map(HadSiteStatic::getMaxDemand).orElse(0.00));
 
             minList.add(hadSiteStatics.stream()
-                    .filter(hadSiteStatic -> DateUtils.isEffectiveDate(hadSiteStatic.getHadTime(),dayStartTime,dayEndTime)
+                    .filter(hadSiteStatic -> DateUtils.isEffectiveDate(hadSiteStatic.getHadTime(), dayStartTime, dayEndTime)
                     ).findFirst().map(HadSiteStatic::getMinDemand).orElse(0.00));
             avgList.add(hadSiteStatics.stream()
-                    .filter(hadSiteStatic -> DateUtils.isEffectiveDate(hadSiteStatic.getHadTime(),dayStartTime,dayEndTime)
+                    .filter(hadSiteStatic -> DateUtils.isEffectiveDate(hadSiteStatic.getHadTime(), dayStartTime, dayEndTime)
                     ).findFirst().map(HadSiteStatic::getAvgDemand).orElse(0.00));
             dateList.add(DateUtils.getDay(setDays));
         }
@@ -245,9 +242,10 @@ public class HtAnalogDataServiceImpl extends AbstractCrudService<HtAnalogDataMap
         HadSiteStatic hadSiteStatic = hadSiteStaticService.oneBySite(siteId, date, date);
         List<HtAnalogData> htList = Optional.ofNullable(hadSiteStatic)
                 .map(HadSiteStatic::getHisIco)
-                .map(his -> JsonUtils.fromJson(hadSiteStatic.getHisIco(), new TypeReference<List<HtAnalogData>>(){}))
+                .map(his -> JsonUtils.fromJson(hadSiteStatic.getHisIco(), new TypeReference<List<HtAnalogData>>() {
+                }))
                 .orElse(null);
-        for (int i = 2; i < 24 ; i+=2) {
+        for (int i = 2; i < 24; i += 2) {
             Date hours = DateUtils.setHours(date, i);
             date = hours;
             Date finalDate = date;

Diferenças do arquivo suprimidas por serem muito extensas
+ 380 - 380
fiveep-service/src/main/java/com/bizmatics/service/impl/RtAnalogDataServiceImpl.java


+ 20 - 21
fiveep-service/src/main/java/com/bizmatics/service/impl/SiteServiceImpl.java

@@ -16,7 +16,7 @@ import com.bizmatics.service.DeviceService;
 import com.bizmatics.service.SiteService;
 import com.bizmatics.service.UserSiteService;
 import com.bizmatics.service.enums.DeviceStatusCode;
-import com.bizmatics.service.util.SessionLocal;
+import com.bizmatics.service.util.SecurityUtils;
 import com.bizmatics.service.vo.DeviceCountVO;
 import com.bizmatics.service.vo.SiteVO;
 import lombok.extern.slf4j.Slf4j;
@@ -30,7 +30,7 @@ import java.util.stream.Collectors;
 
 /**
  * <p>
- *  服务实现类
+ * 服务实现类
  * </p>
  *
  * @author ya
@@ -52,32 +52,31 @@ public class SiteServiceImpl extends AbstractCrudService<SiteMapper, Site> imple
 
     @Override
     public DeviceCountVO selectCount() {
-//        Integer userId = UserUtil.getUserId();
-        Integer userId = SessionLocal.getUserId();
+        Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
         DeviceCountVO deviceCountVO = new DeviceCountVO();
-        deviceCountVO.setNormalCount(baseMapper.selectCount(userId,null,DeviceStatusCode.NORMAL.getValue()));
-        deviceCountVO.setOffLineCount(baseMapper.selectCount(userId,null,DeviceStatusCode.OFFLINE.getValue()));
-        deviceCountVO.setDeviceCount(baseMapper.selectCount(userId,null,DeviceStatusCode.DEVICE.getValue()));
-        deviceCountVO.setFaultCount(baseMapper.selectCount(userId,null,DeviceStatusCode.FAULT.getValue()));
+        deviceCountVO.setNormalCount(baseMapper.selectCount(userId, null, DeviceStatusCode.NORMAL.getValue()));
+        deviceCountVO.setOffLineCount(baseMapper.selectCount(userId, null, DeviceStatusCode.OFFLINE.getValue()));
+        deviceCountVO.setDeviceCount(baseMapper.selectCount(userId, null, DeviceStatusCode.DEVICE.getValue()));
+        deviceCountVO.setFaultCount(baseMapper.selectCount(userId, null, DeviceStatusCode.FAULT.getValue()));
         deviceCountVO.setCount(userSiteService.count(userId));
         return deviceCountVO;
     }
 
     @Override
     public List<Site> list(String name) {
-        return baseMapper.list(SessionLocal.getUserId(),name);
+        Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
+        return baseMapper.list(userId, name);
 
     }
 
     @Override
     public List<SiteVO> siteAndStatusList(String name) {
         List<SiteVO> list = new ArrayList<>();
-//        Integer userId = UserUtil.getUserId();
-        Integer userId = SessionLocal.getUserId();
-        List<Site> sites = baseMapper.list(SessionLocal.getUserId(), name);
+        Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
+        List<Site> sites = baseMapper.list(userId, name);
         List<Device> deviceList = deviceMapper.list(userId, null, null, null, null, null);
         List<AlarmPower> alarmPowers = alarmPowerMapper.list(userId, null, null, null, null, null, 1);
-        sites.forEach(site -> list.add(enhanceSite(deviceList,site,alarmPowers)));
+        sites.forEach(site -> list.add(enhanceSite(deviceList, site, alarmPowers)));
         return list;
     }
 
@@ -87,7 +86,7 @@ public class SiteServiceImpl extends AbstractCrudService<SiteMapper, Site> imple
         return Optional.ofNullable(site)
                 .map(st -> {
                     LambdaQueryWrapper<Device> deviceLambdaQueryWrapper = Wrappers.lambdaQuery();
-                    deviceLambdaQueryWrapper.eq(Device::getSiteId,site.getId());
+                    deviceLambdaQueryWrapper.eq(Device::getSiteId, site.getId());
                     List<Device> list = deviceService.list(deviceLambdaQueryWrapper);
                     Integer count = alarmPowerMapper.selectCount(null, site.getId(), null, null, null, null, 1);
                     SiteVO siteVO = enhanceSite(list, site, null);
@@ -99,7 +98,7 @@ public class SiteServiceImpl extends AbstractCrudService<SiteMapper, Site> imple
     }
 
 
-    public SiteVO enhanceSite(List<Device> list,Site site,List<AlarmPower> alarmPowers){
+    public SiteVO enhanceSite(List<Device> list, Site site, List<AlarmPower> alarmPowers) {
         SiteVO siteVo = BeanMapperUtils.map(site, SiteVO.class);
         siteVo.setDeviceCount(list.size());
         long deviceCount = list.stream()
@@ -114,18 +113,18 @@ public class SiteServiceImpl extends AbstractCrudService<SiteMapper, Site> imple
                 .filter(device -> device.getSiteId().equals(site.getId()))
                 .filter(device -> DeviceStatusCode.OFFLINE.getValue().equals(device.getDeviceStatus()))
                 .count();
-        if (CollectionUtils.isNotEmpty(alarmPowers)){
+        if (CollectionUtils.isNotEmpty(alarmPowers)) {
             siteVo.setAlarmPowerCount((int) alarmPowers.stream().filter(alarmPower -> alarmPower.getSiteId().equals(site.getId())).count());
-        }else {
+        } else {
             siteVo.setAlarmPowerCount(0);
         }
-        if (deviceCount > 0){
+        if (deviceCount > 0) {
             siteVo.setStatus(DeviceStatusCode.FAULT.getDescribe());
-        }else if (offCount > 0){
+        } else if (offCount > 0) {
             siteVo.setStatus(DeviceStatusCode.OFFLINE.getDescribe());
-        }else if (faultCount > 0){
+        } else if (faultCount > 0) {
             siteVo.setStatus(DeviceStatusCode.FAULT.getDescribe());
-        }else {
+        } else {
             siteVo.setStatus(DeviceStatusCode.NORMAL.getDescribe());
         }
         List<String> deviceTypes = list.stream()

+ 0 - 5
fiveep-service/src/main/java/com/bizmatics/service/impl/UserServiceImpl.java

@@ -6,7 +6,6 @@ import com.bizmatics.common.mvc.base.AbstractCrudService;
 import com.bizmatics.model.User;
 import com.bizmatics.persistence.mapper.UserMapper;
 import com.bizmatics.service.UserService;
-import com.bizmatics.service.util.SessionLocal;
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import org.springframework.stereotype.Service;
 
@@ -29,10 +28,6 @@ public class UserServiceImpl extends AbstractCrudService<UserMapper, User> imple
         User user = baseMapper.selectOne(Wrappers.lambdaQuery(User.class)
                 .eq(User::getUserName, name)
                 .eq(User::getUserPassword, password));
-        //存储session
-        request.getSession().setAttribute( "sessionuser", user );
-        //存储ThreadLocal
-        SessionLocal.setUser( user );
         return Optional.ofNullable(user).orElseThrow(() -> new BusinessException("用户信息为空"));
 
     }

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

@@ -5,13 +5,15 @@ 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.service.constants.Constants;
+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;
 import io.jsonwebtoken.SignatureAlgorithm;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.cloud.commons.util.IdUtils;
 import org.springframework.stereotype.Component;
 
 import javax.servlet.http.HttpServletRequest;
@@ -66,7 +68,7 @@ public class TokenService
                 // 解析对应的权限以及用户信息
                 String uuid = (String) claims.get(Constants.LOGIN_USER_KEY);
                 String userKey = getTokenKey(uuid);
-                LoginUser user = redisHelper.getCacheObject(userKey);
+                LoginUser user = (LoginUser)redisHelper.get(userKey);
                 return user;
             }
             catch (Exception e)

+ 63 - 0
fiveep-service/src/main/java/com/bizmatics/service/util/AddressUtils.java

@@ -0,0 +1,63 @@
+package com.bizmatics.service.util;
+
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.bizmatics.common.core.util.HttpUtils;
+import com.bizmatics.common.mvc.utils.IpUtils;
+import com.bizmatics.common.spring.util.JsonUtils;
+import com.bizmatics.service.config.RuoYiConfig;
+import com.fasterxml.jackson.core.type.TypeReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 获取地址类
+ * 
+ * @author ruoyi
+ */
+public class AddressUtils
+{
+    private static final Logger log = LoggerFactory.getLogger(AddressUtils.class);
+
+    // IP地址查询
+    public static final String IP_URL = "http://whois.pconline.com.cn/ipJson.jsp";
+
+    // 未知地址
+    public static final String UNKNOWN = "XX XX";
+
+    public static String getRealAddressByIP(String ip)
+    {
+        String address = UNKNOWN;
+        // 内网不查询
+        if (IpUtils.internalIp(ip))
+        {
+            return "内网IP";
+        }
+        if (RuoYiConfig.isAddressEnabled())
+        {
+            try
+            {
+                Map<String,String> param = new HashMap<>();
+                param.put("ip",ip);
+                String rspStr = HttpUtils.get(IP_URL, param);
+                if (StringUtils.isBlank(rspStr))
+                {
+                    log.error("获取地理位置异常 {}", ip);
+                    return UNKNOWN;
+                }
+                Map<String, String> objectMap = JsonUtils.fromJson(rspStr, new TypeReference<Map<String, String>>() {
+                });
+                String region = objectMap.get("pro");
+                String city = objectMap.get("city");
+                return String.format("%s %s", region, city);
+            }
+            catch (Exception e)
+            {
+                log.error("获取地理位置异常 {}", ip);
+            }
+        }
+        return address;
+    }
+}

+ 50 - 0
fiveep-service/src/main/java/com/bizmatics/service/util/IdUtils.java

@@ -0,0 +1,50 @@
+package com.bizmatics.service.util;
+
+
+/**
+ * ID生成器工具类
+ * 
+ * @author ruoyi
+ */
+public class IdUtils
+{
+    /**
+     * 获取随机UUID
+     * 
+     * @return 随机UUID
+     */
+    public static String randomUUID()
+    {
+        return UUID.randomUUID().toString();
+    }
+
+    /**
+     * 简化的UUID,去掉了横线
+     * 
+     * @return 简化的UUID,去掉了横线
+     */
+    public static String simpleUUID()
+    {
+        return UUID.randomUUID().toString();
+    }
+
+    /**
+     * 获取随机UUID,使用性能更好的ThreadLocalRandom生成UUID
+     * 
+     * @return 随机UUID
+     */
+    public static String fastUUID()
+    {
+        return UUID.fastUUID().toString();
+    }
+
+    /**
+     * 简化的UUID,去掉了横线,使用性能更好的ThreadLocalRandom生成UUID
+     * 
+     * @return 简化的UUID,去掉了横线
+     */
+    public static String fastSimpleUUID()
+    {
+        return UUID.fastUUID().toString(true);
+    }
+}

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

@@ -0,0 +1,485 @@
+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();
+    }
+}

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff