From 7cbd37cb2b6508694855a30872136d55c370a546 Mon Sep 17 00:00:00 2001 From: zhujj Date: Thu, 6 Dec 2018 15:08:39 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 5 +-- ruoyi-admin/pom.xml | 2 +- ruoyi-common/pom.xml | 2 +- .../com/ruoyi/common/base/BaseEntity.java | 1 + .../com/ruoyi/common/utils/DateUtils.java | 32 +++++++++++++++++++ .../java/com/ruoyi/common/utils/IpUtils.java | 26 +++++++++++++++ ruoyi-exam/pom.xml | 4 +-- ruoyi-framework/pom.xml | 19 ++++++++++- ruoyi-generator/pom.xml | 4 +-- ruoyi-quartz/pom.xml | 2 +- .../com/ruoyi/quartz/util/ScheduleJob.java | 2 ++ 11 files changed, 89 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index a2786cb4a..1bfdec756 100644 --- a/pom.xml +++ b/pom.xml @@ -6,14 +6,14 @@ com.ruoyi ruoyi - 3.0 + 3.1 ruoyi http://www.ruoyi.vip 若依管理系统 - 3.0 + 3.1 UTF-8 UTF-8 1.8 @@ -25,6 +25,7 @@ 2.3.2 2.7.0 1.2.5 + 3.9.1 diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index 7fb9d467c..e29662ee7 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -5,7 +5,7 @@ ruoyi com.ruoyi - 3.0 + 3.1 4.0.0 jar diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml index b4f93f892..8f6a21449 100644 --- a/ruoyi-common/pom.xml +++ b/ruoyi-common/pom.xml @@ -5,7 +5,7 @@ ruoyi com.ruoyi - 3.0 + 3.1 4.0.0 diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/base/BaseEntity.java b/ruoyi-common/src/main/java/com/ruoyi/common/base/BaseEntity.java index e881c4865..a3a9c4bb4 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/base/BaseEntity.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/base/BaseEntity.java @@ -67,6 +67,7 @@ public class BaseEntity implements Serializable { this.createTime = createTime; } + public String getUpdateBy() { return updateBy; diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java index 996bdd34a..8ff95f1b7 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java @@ -1,5 +1,6 @@ package com.ruoyi.common.utils; +import java.lang.management.ManagementFactory; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; @@ -120,4 +121,35 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils return null; } } + + /** + * 获取服务器启动时间 + */ + public static Date getServerStartDate() + { + long time = ManagementFactory.getRuntimeMXBean().getStartTime(); + return new Date(time); + } + + /** + * 计算两个时间差 + */ + public static String getDatePoor(Date endDate, Date nowDate) + { + long nd = 1000 * 24 * 60 * 60; + long nh = 1000 * 60 * 60; + long nm = 1000 * 60; + // long ns = 1000; + // 获得两个时间的毫秒时间差异 + long diff = endDate.getTime() - nowDate.getTime(); + // 计算差多少天 + long day = diff / nd; + // 计算差多少小时 + long hour = diff % nd / nh; + // 计算差多少分钟 + long min = diff % nd % nh / nm; + // 计算差多少秒//输出结果 + // long sec = diff % nd % nh % nm / ns; + return day + "天" + hour + "小时" + min + "分钟"; + } } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/IpUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/IpUtils.java index 0e15e46e7..bbbb4a4eb 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/IpUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/IpUtils.java @@ -1,5 +1,7 @@ package com.ruoyi.common.utils; +import java.net.InetAddress; +import java.net.UnknownHostException; import javax.servlet.http.HttpServletRequest; /** @@ -155,4 +157,28 @@ public class IpUtils } return bytes; } + + public static String getHostIp() + { + try + { + return InetAddress.getLocalHost().getHostAddress(); + } + catch (UnknownHostException e) + { + } + return "127.0.0.1"; + } + + public static String getHostName() + { + try + { + return InetAddress.getLocalHost().getHostName(); + } + catch (UnknownHostException e) + { + } + return "未知"; + } } \ No newline at end of file diff --git a/ruoyi-exam/pom.xml b/ruoyi-exam/pom.xml index 3b7ffe873..276efe81c 100644 --- a/ruoyi-exam/pom.xml +++ b/ruoyi-exam/pom.xml @@ -5,7 +5,7 @@ ruoyi com.ruoyi - 3.0 + 3.1 4.0.0 @@ -14,7 +14,7 @@ com.ruoyi ruoyi-framework - 3.0 + 3.1 diff --git a/ruoyi-framework/pom.xml b/ruoyi-framework/pom.xml index b94d18a75..c3a2799f7 100644 --- a/ruoyi-framework/pom.xml +++ b/ruoyi-framework/pom.xml @@ -5,7 +5,7 @@ ruoyi com.ruoyi - 3.0 + 3.1 4.0.0 @@ -110,6 +110,23 @@ pagehelper-spring-boot-starter ${pagehelper.boot.version} + + + + com.github.oshi + oshi-core + ${oshi.version} + + + + net.java.dev.jna + jna + + + + net.java.dev.jna + jna-platform + diff --git a/ruoyi-generator/pom.xml b/ruoyi-generator/pom.xml index a0d952410..131e7bcf9 100644 --- a/ruoyi-generator/pom.xml +++ b/ruoyi-generator/pom.xml @@ -5,7 +5,7 @@ ruoyi com.ruoyi - 3.0 + 3.1 4.0.0 @@ -31,7 +31,7 @@ com.ruoyi ruoyi-framework - 3.0 + ${ruoyi.version} diff --git a/ruoyi-quartz/pom.xml b/ruoyi-quartz/pom.xml index d342e672c..7a1cbdba2 100644 --- a/ruoyi-quartz/pom.xml +++ b/ruoyi-quartz/pom.xml @@ -5,7 +5,7 @@ ruoyi com.ruoyi - 3.0 + 3.1 4.0.0 diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleJob.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleJob.java index 1770a839f..4ce41f6f5 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleJob.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleJob.java @@ -4,6 +4,7 @@ import java.util.Date; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; +import org.quartz.DisallowConcurrentExecution; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; import org.slf4j.Logger; @@ -23,6 +24,7 @@ import com.ruoyi.quartz.service.ISysJobLogService; * @author ruoyi * */ +@DisallowConcurrentExecution public class ScheduleJob extends QuartzJobBean { private static final Logger log = LoggerFactory.getLogger(ScheduleJob.class);