From aad4a4dac227ef51fa332ea092a2904f749f2ffd Mon Sep 17 00:00:00 2001 From: wangshaoping Date: Thu, 6 Jun 2024 11:59:18 +0800 Subject: [PATCH] update --- gradle.properties | 2 +- io.sc.platform.core.frontend/package.json | 24 +- .../src/platform/components/grid/WGrid.vue | 12 +- .../src/platform/plugin/quasar.ts | 4 + .../template-project/package.json | 15 +- .../io/sc/platform/core/util/DateUtil.java | 44 + io.sc.platform.monitor/build.gradle | 1 + .../doc/database/structure.erm | 960 ------------------ .../doc/database/structure.sql | 34 - .../monitor/service/SystemMonitor.java | 4 +- .../service/impl/SystemMonitorImpl.java | 21 +- .../platform/monitor/service/support/Cpu.java | 28 + .../monitor/service/support/Disk.java | 45 + .../monitor/service/support/Hardware.java | 85 ++ .../platform/monitor/service/support/Jvm.java | 35 +- .../service/support/{Mem.java => Memory.java} | 23 +- .../platform/monitor/service/support/Os.java | 95 ++ .../monitor/service/support/Server.java | 174 ---- .../monitor/service/support/ServerInfo.java | 82 ++ .../platform/monitor/service/support/Sys.java | 68 -- .../monitor/service/support/SysFile.java | 94 -- .../src/main/resources/META-INF/MANIFEST.MF | 2 +- .../main/resources/META-INF/spring.factories | 15 - .../MvcWebMvcAutoConfiguration.java | 3 + .../support/OnlineUserCounterInterceptor.java | 44 + io.sc.platform.system.frontend/package.json | 2 +- .../src/components/index.ts | 4 +- .../src/i18n/messages.json | 9 +- .../src/i18n/messages_tw_CN.json | 9 +- .../src/i18n/messages_zh_CN.json | 39 +- .../src/menus/menus.json | 4 +- .../src/routes/routes.json | 10 +- .../src/views/application/Application.vue | 11 +- .../src/views/corporation/Corporation.vue | 11 +- .../src/views/department/Department.vue | 11 +- .../src/views/menu/Menu.vue | 68 +- .../src/views/monitor/Resources.vue | 4 - .../src/views/monitor/ServerInfo.vue | 215 ++++ .../src/views/org/Org.vue | 14 +- .../src/views/role/Role.vue | 18 +- .../views/shared/SelectApplicationGrid.vue | 18 +- .../src/views/shared/SelectMenuTreeGrid.vue | 15 +- .../src/views/shared/SelectOrgTreeGrid.vue | 15 +- .../src/views/shared/SelectRoleGrid.vue | 18 +- .../src/views/shared/SelectUserGrid.vue | 10 +- .../src/views/user/User.vue | 14 +- io.sc.platform.system/build.gradle | 1 + .../menu/service/impl/MenuServiceImpl.java | 48 +- .../controller/MetricsWebController.java | 21 + .../META-INF/platform/plugins/components.json | 1 + 50 files changed, 992 insertions(+), 1512 deletions(-) delete mode 100644 io.sc.platform.monitor/doc/database/structure.erm delete mode 100644 io.sc.platform.monitor/doc/database/structure.sql create mode 100644 io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Disk.java create mode 100644 io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Hardware.java rename io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/{Mem.java => Memory.java} (63%) create mode 100644 io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Os.java delete mode 100644 io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Server.java create mode 100644 io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/ServerInfo.java delete mode 100644 io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Sys.java delete mode 100644 io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/SysFile.java delete mode 100644 io.sc.platform.monitor/src/main/resources/META-INF/spring.factories create mode 100644 io.sc.platform.mvc/src/main/java/io/sc/platform/mvc/autoconfigure/support/OnlineUserCounterInterceptor.java delete mode 100644 io.sc.platform.system.frontend/src/views/monitor/Resources.vue create mode 100644 io.sc.platform.system.frontend/src/views/monitor/ServerInfo.vue create mode 100644 io.sc.platform.system/src/main/java/io/sc/platform/system/monitor/controller/MetricsWebController.java diff --git a/gradle.properties b/gradle.properties index d66935df..068ef42f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -65,7 +65,7 @@ jxls_poi_version=1.0.15 jxls_version=2.4.6 mybatis_version=3.5.10 opencsv_version=5.7.1 -oshi_version=6.4.2 +oshi_version=6.6.1 p6spy_version=3.9.1 pinyin4j_version=2.5.1 poi_version=5.2.5 diff --git a/io.sc.platform.core.frontend/package.json b/io.sc.platform.core.frontend/package.json index 1e44e525..cf4c3ab0 100644 --- a/io.sc.platform.core.frontend/package.json +++ b/io.sc.platform.core.frontend/package.json @@ -1,6 +1,6 @@ { "name": "platform-core", - "version": "8.1.223", + "version": "8.1.225", "description": "前端核心包,用于快速构建前端的脚手架", "//main": "库的主文件", "main": "dist/platform-core.js", @@ -111,17 +111,17 @@ "@codemirror/view": "6.26.3", "@maxgraph/core": "0.10.0", "@quasar/extras": "1.16.11", - "@univerjs/core":"0.1.13", - "@univerjs/design":"0.1.13", - "@univerjs/docs":"0.1.13", - "@univerjs/docs-ui":"0.1.13", - "@univerjs/engine-formula":"0.1.13", - "@univerjs/engine-render":"0.1.13", - "@univerjs/facade":"0.1.13", - "@univerjs/sheets":"0.1.13", - "@univerjs/sheets-formula":"0.1.13", - "@univerjs/sheets-ui":"0.1.13", - "@univerjs/ui":"0.1.13", + "@univerjs/core": "0.1.13", + "@univerjs/design": "0.1.13", + "@univerjs/docs": "0.1.13", + "@univerjs/docs-ui": "0.1.13", + "@univerjs/engine-formula": "0.1.13", + "@univerjs/engine-render": "0.1.13", + "@univerjs/facade": "0.1.13", + "@univerjs/sheets": "0.1.13", + "@univerjs/sheets-formula": "0.1.13", + "@univerjs/sheets-ui": "0.1.13", + "@univerjs/ui": "0.1.13", "@vueuse/core": "10.9.0", "axios": "1.6.8", "codemirror": "6.0.1", diff --git a/io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue b/io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue index c5a481bd..1bea67bb 100644 --- a/io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue +++ b/io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue @@ -2558,24 +2558,24 @@ const getTreeRow = (arr, key, parentFlag: boolean) => { } return result; }; -const getCascadeParentData = (row, propertyName) => { +const getCascadeParentsData = (row, propertyName) => { const data = []; if (row && row[props.foreignKey]) { const parent = getTreeRow(table.rows, row[props.foreignKey], true); if (parent) { data.push(propertyName ? parent[propertyName] : parent); if (parent[props.foreignKey]) { - const parentData = getCascadeParentData(parent, propertyName); + const parentData = getCascadeParentsData(parent, propertyName); data.push(...parentData); } } } return data; }; -// 获取选中的行记录及父记录 -const getCascadeParent = (propertyName: string) => { +// 获取选中的行记录及所有父记录 +const getCascadeParents = (propertyName: string) => { const row = getSelectedRow(); - const parent = getCascadeParentData(row, propertyName); + const parent = getCascadeParentsData(row, propertyName); const result = [propertyName ? row[propertyName] : row]; if (parent && parent.length > 0) { result.push(...parent); @@ -2589,7 +2589,7 @@ const getElement = () => { defineExpose({ getCascadeChildren, - getCascadeParent, + getCascadeParents, getSelectedRow, getSelectedRows, getTickedRow, diff --git a/io.sc.platform.core.frontend/src/platform/plugin/quasar.ts b/io.sc.platform.core.frontend/src/platform/plugin/quasar.ts index 92f73b88..6e44ff44 100644 --- a/io.sc.platform.core.frontend/src/platform/plugin/quasar.ts +++ b/io.sc.platform.core.frontend/src/platform/plugin/quasar.ts @@ -35,6 +35,10 @@ export default { size: gc.theme.loadingBar.size + 'px', position: gc.theme.loadingBar.position, reverse: gc.theme.loadingBar.reverse, + // 设置顶部加载进度栏过滤器(请求地址包含 /api/ 的不显示进度栏,即请求后端服务时不显示进度栏) + hijackFilter: (url) => { + return !/\/api\//.test(url); + }, }, }, plugins: { diff --git a/io.sc.platform.core.frontend/template-project/package.json b/io.sc.platform.core.frontend/template-project/package.json index 15029754..c72e5bc3 100644 --- a/io.sc.platform.core.frontend/template-project/package.json +++ b/io.sc.platform.core.frontend/template-project/package.json @@ -1,6 +1,6 @@ { "name": "platform-core", - "version": "8.1.223", + "version": "8.1.225", "description": "前端核心包,用于快速构建前端的脚手架", "private": false, "keywords": [], @@ -83,6 +83,17 @@ "@codemirror/view": "6.26.3", "@maxgraph/core": "0.10.0", "@quasar/extras": "1.16.11", + "@univerjs/core": "0.1.13", + "@univerjs/design": "0.1.13", + "@univerjs/docs": "0.1.13", + "@univerjs/docs-ui": "0.1.13", + "@univerjs/engine-formula": "0.1.13", + "@univerjs/engine-render": "0.1.13", + "@univerjs/facade": "0.1.13", + "@univerjs/sheets": "0.1.13", + "@univerjs/sheets-formula": "0.1.13", + "@univerjs/sheets-ui": "0.1.13", + "@univerjs/ui": "0.1.13", "@vueuse/core": "10.9.0", "axios": "1.6.8", "codemirror": "6.0.1", @@ -93,7 +104,7 @@ "luckyexcel": "1.0.1", "mockjs": "1.1.0", "pinia": "2.1.7", - "platform-core": "8.1.223", + "platform-core": "8.1.225", "quasar": "2.15.3", "tailwindcss": "3.4.3", "vue": "3.4.24", diff --git a/io.sc.platform.core/src/main/java/io/sc/platform/core/util/DateUtil.java b/io.sc.platform.core/src/main/java/io/sc/platform/core/util/DateUtil.java index c476c9c9..c9dd7c5e 100644 --- a/io.sc.platform.core/src/main/java/io/sc/platform/core/util/DateUtil.java +++ b/io.sc.platform.core/src/main/java/io/sc/platform/core/util/DateUtil.java @@ -69,6 +69,17 @@ public class DateUtil { + yyyy_MM_dd_HH_mm + "\n" + yyyy_MM_dd_HH + "\n" + yyyy_MM_dd + "\n"; + + /** + * 获取日期 + * @param time 日期对象毫秒数 + * @return 日期 + */ + public static Date from(long time){ + Date date =new Date(); + date.setTime(time); + return date; + } /** * 获取日期格式化对象 @@ -170,6 +181,22 @@ public class DateUtil { return result; } + /** + * 格式化日期对象 + * @param time 日期对象的毫秒数 + * @return 日期字符串 + */ + public static String formatDate(long time){ + Date date =from(time); + if(date!=null){ + DateFormat df =getDateFormat(DateUtil.yyyy_MM_dd_HH_mm_ss); + if(df!=null){ + return df.format(date); + } + } + return null; + } + /** * 格式化日期对象 * @param date 日期对象 @@ -185,6 +212,23 @@ public class DateUtil { return null; } + /** + * 格式化日期对象 + * @param time 日期对象毫秒数 + * @param format 日期格式 + * @return 日期字符串 + */ + public static String formatDate(long time, String format){ + Date date =from(time); + if(date!=null){ + DateFormat df =getDateFormat(format); + if(df!=null){ + return df.format(date); + } + } + return null; + } + /** * 格式化日期对象 * @param date 日期对象 diff --git a/io.sc.platform.monitor/build.gradle b/io.sc.platform.monitor/build.gradle index 9b669f7a..195993cb 100644 --- a/io.sc.platform.monitor/build.gradle +++ b/io.sc.platform.monitor/build.gradle @@ -1,5 +1,6 @@ dependencies { api( "com.github.oshi:oshi-core:${oshi_version}", + project(":io.sc.platform.core"), ) } diff --git a/io.sc.platform.monitor/doc/database/structure.erm b/io.sc.platform.monitor/doc/database/structure.erm deleted file mode 100644 index 3d597eb2..00000000 --- a/io.sc.platform.monitor/doc/database/structure.erm +++ /dev/null @@ -1,960 +0,0 @@ - - - - true - 100 - A4 210 x 297 mm - 30 - 30 - 30 - 30 - - 0 - 1.0 - 0 - 0 - - 128 - 128 - 192 - - - 255 - 255 - 255 - - .SF NS Text - 9 - - MySQL - false - - - 0 - true - 2 - 1 - 1 - false - true - false - false - - - doc/database/structure.sql - UTF-8 - LF - true - 0 - null - - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - false - false - false - - - - - null - - - - - - true - true - true - - - - true - true - true - - - - - true - true - - - - - - - false - - - - - 0 - - - - false - false - - - - - false - - - - - - -1 - -1 - .SF NS Text - 9 - 50 - 50 - - 255 - 255 - 255 - - - - false - 2016-03-10 20:37:38 - 2016-03-16 02:25:45 - - Project Name - - - - Model Name - - - - Version - - - - Company - - - - Author - - - - - - - - - null - - - - 0 - Default - - - - - - 0 - 255 - null - false - null - false - false - false - - false - - Bean autowire - FD_AUTOWIRE - varchar(n) - - - 1 - 255 - null - false - null - false - false - false - - false - - Bean customizer-ref - FD_CUSTOMIZER_REF - varchar(n) - - - 2 - 255 - null - false - null - false - false - false - - false - - Bean depends-on - FD_DEPENDS_ON - varchar(n) - - - 3 - 255 - null - false - null - false - false - false - - false - - Bean描述 - FD_DESCRIPTION - varchar(n) - - - 4 - 255 - null - false - null - false - false - false - - false - - Bean destroy-method - FD_DESTROY_METHOD - varchar(n) - - - 5 - 255 - null - false - null - false - false - false - - false - - Bean id - FD_ID - varchar(n) - - - 6 - 255 - null - false - null - false - false - false - - false - - Bean init-method - FD_INIT_METHOD - varchar(n) - - - 7 - 255 - null - false - null - false - false - false - - false - - Bean名称 - FD_NAME - varchar(n) - - - 8 - 255 - null - false - null - false - false - false - - false - - Bean proxy-target-class - FD_PROXY_TARGET_CLASS - varchar(n) - - - 9 - 4 - null - false - null - false - false - false - - false - - Bean refresh-check-delay - FD_REFRESH_CHECK_DELAY - int(n) - - - 10 - 255 - null - false - null - false - false - false - - false - - Bean scope - FD_SCOPE - varchar(n) - - - 11 - 3000 - null - false - null - false - false - false - - false - - Bean脚本内容 - FD_SCRIPT - varchar(n) - - - 12 - 255 - null - false - null - false - false - false - - false - - Bean实现接口 - FD_SCRIPT_INTERFACE - varchar(n) - - - 13 - 255 - null - false - null - false - false - false - - false - GROOVY:groovy Bean,BSH:bsh Bean - Bean类型 - FD_TYPE - varchar(n) - - - 14 - 36 - null - false - null - false - false - false - - false - - Bean定义ID - FD_UUID - varchar(n) - - - - - - - 0 - 75 - 120 - .SF NS Text - 9 - 137 - 74 - - 128 - 128 - 192 - - - - WSP_DYNAMIC_BEAN - 动态SpringBean定义表 - - - - - - - 14 - 0 - - - - - varchar(n) - - - false - false - true - true - false - - - - - - - - - - - false - false - false - - - 0 - - - - 13 - 1 - - - - - varchar(n) - - - false - false - false - false - false - - - - - - - - - - - false - false - false - - - 0 - - - - 5 - 2 - - - - - varchar(n) - - - false - false - false - false - false - - - - - - - - - - - false - false - false - - - 0 - - - - 7 - 3 - - - - - varchar(n) - - - false - false - false - false - false - - - - - - - - - - - false - false - false - - - 0 - - - - 3 - 4 - - - - - varchar(n) - - - false - false - false - false - false - - - - - - - - - - - false - false - false - - - 0 - - - - 12 - 5 - - - - - varchar(n) - - - false - false - false - false - false - - - - - - - - - - - false - false - false - - - 0 - - - - 11 - 6 - - - - - varchar(n) - - - false - false - false - false - false - - - - - - - - - - - false - false - false - - - 0 - - - - 0 - 7 - - - - - varchar(n) - - - false - false - false - false - false - - - - - - - - - - - false - false - false - - - 0 - - - - 1 - 8 - - - - - varchar(n) - - - false - false - false - false - false - - - - - - - - - - - false - false - false - - - 0 - - - - 2 - 9 - - - - - varchar(n) - - - false - false - false - false - false - - - - - - - - - - - false - false - false - - - 0 - - - - 4 - 10 - - - - - varchar(n) - - - false - false - false - false - false - - - - - - - - - - - false - false - false - - - 0 - - - - 6 - 11 - - - - - varchar(n) - - - false - false - false - false - false - - - - - - - - - - - false - false - false - - - 0 - - - - 8 - 12 - - - - - varchar(n) - - - false - false - false - false - false - - - - - - - - - - - false - false - false - - - 0 - - - - 9 - 13 - - - - - int(n) - - - false - false - false - false - false - - - - - - - - - - - false - false - false - - - 0 - - - - 10 - 14 - - - - - varchar(n) - - - false - false - false - false - false - - - - - - - - - - - false - false - false - - - 0 - - - - - - - - - - - - - null - -
-
- - - - - - - - - - -
diff --git a/io.sc.platform.monitor/doc/database/structure.sql b/io.sc.platform.monitor/doc/database/structure.sql deleted file mode 100644 index 0ca618c7..00000000 --- a/io.sc.platform.monitor/doc/database/structure.sql +++ /dev/null @@ -1,34 +0,0 @@ -SET SESSION FOREIGN_KEY_CHECKS=0; - -/* Drop Tables */ - -DROP TABLE IF EXISTS WSP_DYNAMIC_BEAN; - - - - -/* Create Tables */ - -CREATE TABLE WSP_DYNAMIC_BEAN -( - FD_UUID varchar(36) NOT NULL, - -- GROOVY:groovy Bean,BSH:bsh Bean - FD_TYPE varchar(255) COMMENT 'GROOVY:groovy Bean,BSH:bsh Bean', - FD_ID varchar(255), - FD_NAME varchar(255), - FD_DESCRIPTION varchar(255), - FD_SCRIPT_INTERFACE varchar(255), - FD_SCRIPT varchar(3000), - FD_AUTOWIRE varchar(255), - FD_CUSTOMIZER_REF varchar(255), - FD_DEPENDS_ON varchar(255), - FD_DESTROY_METHOD varchar(255), - FD_INIT_METHOD varchar(255), - FD_PROXY_TARGET_CLASS varchar(255), - FD_REFRESH_CHECK_DELAY int(4), - FD_SCOPE varchar(255), - PRIMARY KEY (FD_UUID) -); - - - diff --git a/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/SystemMonitor.java b/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/SystemMonitor.java index 80b9a31c..3e7beb3f 100644 --- a/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/SystemMonitor.java +++ b/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/SystemMonitor.java @@ -1,5 +1,7 @@ package io.sc.platform.monitor.service; +import io.sc.platform.monitor.service.support.ServerInfo; + public interface SystemMonitor { - public void getCpuInfo(); + public ServerInfo getServerInfo() throws Exception; } diff --git a/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/impl/SystemMonitorImpl.java b/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/impl/SystemMonitorImpl.java index 0d6bf20a..afc58074 100644 --- a/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/impl/SystemMonitorImpl.java +++ b/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/impl/SystemMonitorImpl.java @@ -1,26 +1,11 @@ package io.sc.platform.monitor.service.impl; import io.sc.platform.monitor.service.SystemMonitor; -import oshi.SystemInfo; -import oshi.hardware.CentralProcessor; -import oshi.hardware.ComputerSystem; -import oshi.hardware.HardwareAbstractionLayer; +import io.sc.platform.monitor.service.support.ServerInfo; public class SystemMonitorImpl implements SystemMonitor { @Override - public void getCpuInfo() { - SystemInfo si =new SystemInfo(); - HardwareAbstractionLayer hal = si.getHardware(); - CentralProcessor processor = hal.getProcessor(); - double[] loadAverage = processor.getSystemLoadAverage(3); - System.out.println("CPU load averages:" + (loadAverage[0] < 0 ? " N/A" : String.format(" %.2f", loadAverage[0])) - + (loadAverage[1] < 0 ? " N/A" : String.format(" %.2f", loadAverage[1])) - + (loadAverage[2] < 0 ? " N/A" : String.format(" %.2f", loadAverage[2]))); - - } - - public static void main(String[] args) { - SystemMonitor monitor =new SystemMonitorImpl(); - monitor.getCpuInfo(); + public ServerInfo getServerInfo() throws Exception { + return ServerInfo.info(); } } diff --git a/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Cpu.java b/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Cpu.java index 7e50a523..604a71fc 100644 --- a/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Cpu.java +++ b/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Cpu.java @@ -1,6 +1,11 @@ package io.sc.platform.monitor.service.support; +import oshi.hardware.CentralProcessor; +import oshi.util.Util; + public class Cpu { + private static final int OSHI_WAIT_SECOND = 1000; + /** * 核心数 */ @@ -31,6 +36,29 @@ public class Cpu { */ private double free; + public static Cpu from(CentralProcessor processor) { + Cpu cpu =new Cpu(); + long[] prevTicks = processor.getSystemCpuLoadTicks(); + Util.sleep(OSHI_WAIT_SECOND); + long[] ticks = processor.getSystemCpuLoadTicks(); + long nice = ticks[CentralProcessor.TickType.NICE.getIndex()] - prevTicks[CentralProcessor.TickType.NICE.getIndex()]; + long irq = ticks[CentralProcessor.TickType.IRQ.getIndex()] - prevTicks[CentralProcessor.TickType.IRQ.getIndex()]; + long softirq = ticks[CentralProcessor.TickType.SOFTIRQ.getIndex()] - prevTicks[CentralProcessor.TickType.SOFTIRQ.getIndex()]; + long steal = ticks[CentralProcessor.TickType.STEAL.getIndex()] - prevTicks[CentralProcessor.TickType.STEAL.getIndex()]; + long cSys = ticks[CentralProcessor.TickType.SYSTEM.getIndex()] - prevTicks[CentralProcessor.TickType.SYSTEM.getIndex()]; + long user = ticks[CentralProcessor.TickType.USER.getIndex()] - prevTicks[CentralProcessor.TickType.USER.getIndex()]; + long iowait = ticks[CentralProcessor.TickType.IOWAIT.getIndex()] - prevTicks[CentralProcessor.TickType.IOWAIT.getIndex()]; + long idle = ticks[CentralProcessor.TickType.IDLE.getIndex()] - prevTicks[CentralProcessor.TickType.IDLE.getIndex()]; + long totalCpu = user + nice + cSys + idle + iowait + irq + softirq + steal; + cpu.setNumber(processor.getLogicalProcessorCount()); + cpu.setTotalUsed(totalCpu); + cpu.setSysUsed(cSys); + cpu.setUserUsed(user); + cpu.setWait(iowait); + cpu.setFree(idle); + return cpu; + } + public int getNumber() { return number; } diff --git a/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Disk.java b/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Disk.java new file mode 100644 index 00000000..193890a2 --- /dev/null +++ b/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Disk.java @@ -0,0 +1,45 @@ +package io.sc.platform.monitor.service.support; + +import io.sc.platform.core.util.StringUtil; + +import java.io.File; + +public class Disk { + private long total; + private long free; + private long used; + + public static Disk from() { + File file =new File("/"); + + Disk disk =new Disk(); + disk.setTotal(file.getTotalSpace()); + disk.setUsed(file.getTotalSpace()-file.getFreeSpace()); + disk.setFree(file.getFreeSpace()); + return disk; + } + + public long getTotal() { + return total; + } + + public void setTotal(long total) { + this.total = total; + } + + public long getFree() { + return free; + } + + public void setFree(long free) { + this.free = free; + } + + public long getUsed() { + return used; + } + + public void setUsed(long used) { + this.used = used; + } +} diff --git a/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Hardware.java b/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Hardware.java new file mode 100644 index 00000000..de9e4f1f --- /dev/null +++ b/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Hardware.java @@ -0,0 +1,85 @@ +package io.sc.platform.monitor.service.support; + +import oshi.hardware.ComputerSystem; +import oshi.hardware.HardwareAbstractionLayer; + +import java.util.List; + +public class Hardware { + private String uuid; + private String manufacturer; + private String model; + private String serialNumber; + private int logicalProcessorCount; + private int physicalProcessorCount; + private long physicalMemory; + + public static Hardware from(HardwareAbstractionLayer hd) { + ComputerSystem cs =hd.getComputerSystem(); + Hardware hardware =new Hardware(); + hardware.setLogicalProcessorCount(hd.getProcessor().getLogicalProcessors().size()); + hardware.setPhysicalProcessorCount(hd.getProcessor().getPhysicalProcessors().size()); + hardware.setUuid(cs.getHardwareUUID()); + hardware.setManufacturer(cs.getManufacturer()); + hardware.setModel(cs.getModel()); + hardware.setSerialNumber(cs.getSerialNumber()); + hardware.setPhysicalMemory(hd.getMemory().getTotal()); + return hardware; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getManufacturer() { + return manufacturer; + } + + public void setManufacturer(String manufacturer) { + this.manufacturer = manufacturer; + } + + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model = model; + } + + public String getSerialNumber() { + return serialNumber; + } + + public void setSerialNumber(String serialNumber) { + this.serialNumber = serialNumber; + } + + public int getLogicalProcessorCount() { + return logicalProcessorCount; + } + + public void setLogicalProcessorCount(int logicalProcessorCount) { + this.logicalProcessorCount = logicalProcessorCount; + } + + public int getPhysicalProcessorCount() { + return physicalProcessorCount; + } + + public void setPhysicalProcessorCount(int physicalProcessorCount) { + this.physicalProcessorCount = physicalProcessorCount; + } + + public long getPhysicalMemory() { + return physicalMemory; + } + + public void setPhysicalMemory(long physicalMemory) { + this.physicalMemory = physicalMemory; + } +} diff --git a/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Jvm.java b/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Jvm.java index 4e671a65..35705e54 100644 --- a/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Jvm.java +++ b/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Jvm.java @@ -1,20 +1,24 @@ package io.sc.platform.monitor.service.support; +import io.sc.platform.core.util.StringUtil; + +import java.util.Properties; + public class Jvm { /** * 当前JVM占用的内存总数(M) */ - private double total; + private String total; /** * JVM最大可用内存总数(M) */ - private double max; + private String max; /** * JVM空闲内存(M) */ - private double free; + private String free; /** * JDK版本 @@ -26,27 +30,40 @@ public class Jvm { */ private String home; - public double getTotal() { + public static Jvm from(){ + Runtime r =Runtime.getRuntime(); + Properties props = System.getProperties(); + + Jvm jvm =new Jvm(); + jvm.setTotal(StringUtil.commaStyle(r.totalMemory())); + jvm.setMax(StringUtil.commaStyle(r.maxMemory())); + jvm.setFree(StringUtil.commaStyle(r.freeMemory())); + jvm.setVersion(props.getProperty("java.version")); + jvm.setHome(props.getProperty("java.home")); + return jvm; + } + + public String getTotal() { return total; } - public void setTotal(double total) { + public void setTotal(String total) { this.total = total; } - public double getMax() { + public String getMax() { return max; } - public void setMax(double max) { + public void setMax(String max) { this.max = max; } - public double getFree() { + public String getFree() { return free; } - public void setFree(double free) { + public void setFree(String free) { this.free = free; } diff --git a/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Mem.java b/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Memory.java similarity index 63% rename from io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Mem.java rename to io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Memory.java index e1401df9..26d71a6e 100644 --- a/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Mem.java +++ b/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Memory.java @@ -1,21 +1,20 @@ package io.sc.platform.monitor.service.support; -public class Mem { - /** - * 内存总量 - */ - private double total; +import oshi.hardware.GlobalMemory; - /** - * 已用内存 - */ +public class Memory { + private double total; private double used; - - /** - * 剩余内存 - */ private double free; + public static Memory from(GlobalMemory m){ + Memory memory =new Memory(); + memory.setTotal(m.getTotal()); + memory.setUsed(m.getTotal() - m.getAvailable()); + memory.setFree(m.getAvailable()); + return memory; + } + public double getTotal() { return total; } diff --git a/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Os.java b/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Os.java new file mode 100644 index 00000000..4f60b72b --- /dev/null +++ b/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Os.java @@ -0,0 +1,95 @@ +package io.sc.platform.monitor.service.support; + +import io.sc.platform.core.util.DateUtil; +import oshi.software.os.OperatingSystem; + +import java.util.Date; +import java.util.Properties; + +public class Os { + private String computerName; + private String ip; + private String name; + private String version; + private String arch; + private String manufacturer; + private String bootTime; + private int upTime; + + public static Os from(OperatingSystem operatingSystem){ + Properties props = System.getProperties(); + + Os os =new Os(); + os.setName(props.getProperty("os.name")); + os.setVersion(operatingSystem.getVersionInfo().getVersion() + " - " + operatingSystem.getVersionInfo().getCodeName()); + os.setArch(props.getProperty("os.arch")); + os.setManufacturer(operatingSystem.getManufacturer()); + os.setBootTime(DateUtil.formatDate(operatingSystem.getSystemBootTime()*1000)); + os.setUpTime((int)operatingSystem.getSystemUptime()/(60*60*24)); + return os; + } + + public String getComputerName() { + return computerName; + } + + public void setComputerName(String computerName) { + this.computerName = computerName; + } + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + 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 getArch() { + return arch; + } + + public void setArch(String arch) { + this.arch = arch; + } + + public String getManufacturer() { + return manufacturer; + } + + public void setManufacturer(String manufacturer) { + this.manufacturer = manufacturer; + } + + public String getBootTime() { + return bootTime; + } + + public void setBootTime(String bootTime) { + this.bootTime = bootTime; + } + + public int getUpTime() { + return upTime; + } + + public void setUpTime(int upTime) { + this.upTime = upTime; + } +} diff --git a/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Server.java b/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Server.java deleted file mode 100644 index 844e7298..00000000 --- a/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Server.java +++ /dev/null @@ -1,174 +0,0 @@ -package io.sc.platform.monitor.service.support; - -import oshi.SystemInfo; -import oshi.hardware.CentralProcessor; -import oshi.hardware.GlobalMemory; -import oshi.hardware.HardwareAbstractionLayer; -import oshi.software.os.FileSystem; -import oshi.software.os.OSFileStore; -import oshi.software.os.OperatingSystem; -import oshi.util.Util; -import oshi.hardware.CentralProcessor.TickType; - -import java.net.UnknownHostException; -import java.util.LinkedList; -import java.util.List; -import java.util.Properties; - -public class Server { - private static final int OSHI_WAIT_SECOND = 1000; - - /** - * CPU相关信息 - */ - private Cpu cpu = new Cpu(); - - /** - * 內存相关信息 - */ - private Mem mem = new Mem(); - - /** - * JVM相关信息 - */ - private Jvm jvm = new Jvm(); - - /** - * 服务器相关信息 - */ - private Sys sys = new Sys(); - - /** - * 磁盘相关信息 - */ - private List sysFiles = new LinkedList(); - - - public void copyTo() throws Exception { - SystemInfo si = new SystemInfo(); - HardwareAbstractionLayer hal = si.getHardware(); - setCpuInfo(hal.getProcessor()); - setMemInfo(hal.getMemory()); - setSysInfo(); - setJvmInfo(); - setSysFiles(si.getOperatingSystem()); - } - - /** - * 设置CPU信息 - */ - private void setCpuInfo(CentralProcessor processor) { - // CPU信息 - long[] prevTicks = processor.getSystemCpuLoadTicks(); - Util.sleep(OSHI_WAIT_SECOND); - long[] ticks = processor.getSystemCpuLoadTicks(); - long nice = ticks[TickType.NICE.getIndex()] - prevTicks[TickType.NICE.getIndex()]; - long irq = ticks[TickType.IRQ.getIndex()] - prevTicks[TickType.IRQ.getIndex()]; - long softirq = ticks[TickType.SOFTIRQ.getIndex()] - prevTicks[TickType.SOFTIRQ.getIndex()]; - long steal = ticks[TickType.STEAL.getIndex()] - prevTicks[TickType.STEAL.getIndex()]; - long cSys = ticks[TickType.SYSTEM.getIndex()] - prevTicks[TickType.SYSTEM.getIndex()]; - long user = ticks[TickType.USER.getIndex()] - prevTicks[TickType.USER.getIndex()]; - long iowait = ticks[TickType.IOWAIT.getIndex()] - prevTicks[TickType.IOWAIT.getIndex()]; - long idle = ticks[TickType.IDLE.getIndex()] - prevTicks[TickType.IDLE.getIndex()]; - long totalCpu = user + nice + cSys + idle + iowait + irq + softirq + steal; - cpu.setNumber(processor.getLogicalProcessorCount()); - cpu.setTotalUsed(totalCpu); - cpu.setSysUsed(cSys); - cpu.setUserUsed(user); - cpu.setWait(iowait); - cpu.setFree(idle); - } - - /** - * 设置内存信息 - */ - private void setMemInfo(GlobalMemory memory) { - mem.setTotal(memory.getTotal()); - mem.setUsed(memory.getTotal() - memory.getAvailable()); - mem.setFree(memory.getAvailable()); - } - - /** - * 设置服务器信息 - */ - private void setSysInfo() { - Properties props = System.getProperties(); - sys.setOsName(props.getProperty("os.name")); - sys.setOsArch(props.getProperty("os.arch")); - sys.setUserDir(props.getProperty("user.dir")); - } - - /** - * 设置Java虚拟机 - */ - private void setJvmInfo() throws UnknownHostException { - Properties props = System.getProperties(); - jvm.setTotal(Runtime.getRuntime().totalMemory()); - jvm.setMax(Runtime.getRuntime().maxMemory()); - jvm.setFree(Runtime.getRuntime().freeMemory()); - jvm.setVersion(props.getProperty("java.version")); - jvm.setHome(props.getProperty("java.home")); - } - - /** - * 设置磁盘信息 - */ - private void setSysFiles(OperatingSystem os) { - FileSystem fileSystem = os.getFileSystem(); - List fsArray = fileSystem.getFileStores(); - for (OSFileStore fs : fsArray) { - long free = fs.getUsableSpace(); - long total = fs.getTotalSpace(); - long used = total - free; - SysFile sysFile = new SysFile(); - sysFile.setDirName(fs.getMount()); - sysFile.setSysTypeName(fs.getType()); - sysFile.setTypeName(fs.getName()); - sysFile.setTotal(total); - sysFile.setFree(free); - sysFile.setUsed(used); - sysFile.setUsage(used/total); - sysFiles.add(sysFile); - } - } - - public Cpu getCpu() { - return cpu; - } - - public void setCpu(Cpu cpu) { - this.cpu = cpu; - } - - public Mem getMem() { - return mem; - } - - public void setMem(Mem mem) { - this.mem = mem; - } - - public Jvm getJvm() { - return jvm; - } - - public void setJvm(Jvm jvm) { - this.jvm = jvm; - } - - public Sys getSys() { - return sys; - } - - public void setSys(Sys sys) { - this.sys = sys; - } - - public List getSysFiles() { - return sysFiles; - } - - public void setSysFiles(List sysFiles) { - this.sysFiles = sysFiles; - } -} diff --git a/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/ServerInfo.java b/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/ServerInfo.java new file mode 100644 index 00000000..e8eb8e3b --- /dev/null +++ b/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/ServerInfo.java @@ -0,0 +1,82 @@ +package io.sc.platform.monitor.service.support; + +import oshi.SystemInfo; + +public class ServerInfo { + private Hardware hardware; + private Os os; + private Cpu cpu; + private Memory memory; + private Disk disk; + private Jvm jvm; + private int onlineUserCount; + + public static ServerInfo info(){ + SystemInfo si = new SystemInfo(); + + ServerInfo server =new ServerInfo(); + server.setHardware(Hardware.from(si.getHardware())); + server.setOs(Os.from(si.getOperatingSystem())); + server.setCpu(Cpu.from(si.getHardware().getProcessor())); + server.setMemory(Memory.from(si.getHardware().getMemory())); + server.setDisk(Disk.from()); + server.setJvm(Jvm.from()); + return server; + } + + public Hardware getHardware() { + return hardware; + } + + public void setHardware(Hardware hardware) { + this.hardware = hardware; + } + + public Os getOs() { + return os; + } + + public void setOs(Os os) { + this.os = os; + } + + public Cpu getCpu() { + return cpu; + } + + public void setCpu(Cpu cpu) { + this.cpu = cpu; + } + + public Memory getMemory() { + return memory; + } + + public void setMemory(Memory memory) { + this.memory = memory; + } + + public Disk getDisk() { + return disk; + } + + public void setDisk(Disk disk) { + this.disk = disk; + } + + public Jvm getJvm() { + return jvm; + } + + public void setJvm(Jvm jvm) { + this.jvm = jvm; + } + + public int getOnlineUserCount() { + return onlineUserCount; + } + + public void setOnlineUserCount(int onlineUserCount) { + this.onlineUserCount = onlineUserCount; + } +} diff --git a/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Sys.java b/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Sys.java deleted file mode 100644 index 0577b47c..00000000 --- a/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/Sys.java +++ /dev/null @@ -1,68 +0,0 @@ -package io.sc.platform.monitor.service.support; - -public class Sys { - /** - * 服务器名称 - */ - private String computerName; - - /** - * 服务器Ip - */ - private String computerIp; - - /** - * 项目路径 - */ - private String userDir; - - /** - * 操作系统 - */ - private String osName; - - /** - * 系统架构 - */ - private String osArch; - - public String getComputerName() { - return computerName; - } - - public void setComputerName(String computerName) { - this.computerName = computerName; - } - - public String getComputerIp() { - return computerIp; - } - - public void setComputerIp(String computerIp) { - this.computerIp = computerIp; - } - - public String getUserDir() { - return userDir; - } - - public void setUserDir(String userDir) { - this.userDir = userDir; - } - - public String getOsName() { - return osName; - } - - public void setOsName(String osName) { - this.osName = osName; - } - - public String getOsArch() { - return osArch; - } - - public void setOsArch(String osArch) { - this.osArch = osArch; - } -} diff --git a/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/SysFile.java b/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/SysFile.java deleted file mode 100644 index bc60ec89..00000000 --- a/io.sc.platform.monitor/src/main/java/io/sc/platform/monitor/service/support/SysFile.java +++ /dev/null @@ -1,94 +0,0 @@ -package io.sc.platform.monitor.service.support; - -public class SysFile { - /** - * 盘符路径 - */ - private String dirName; - - /** - * 盘符类型 - */ - private String sysTypeName; - - /** - * 文件类型 - */ - private String typeName; - - /** - * 总大小 - */ - private long total; - - /** - * 剩余大小 - */ - private long free; - - /** - * 已经使用量 - */ - private long used; - - /** - * 资源的使用率 - */ - private double usage; - - public String getDirName() { - return dirName; - } - - public void setDirName(String dirName) { - this.dirName = dirName; - } - - public String getSysTypeName() { - return sysTypeName; - } - - public void setSysTypeName(String sysTypeName) { - this.sysTypeName = sysTypeName; - } - - public String getTypeName() { - return typeName; - } - - public void setTypeName(String typeName) { - this.typeName = typeName; - } - - public long getTotal() { - return total; - } - - public void setTotal(long total) { - this.total = total; - } - - public long getFree() { - return free; - } - - public void setFree(long free) { - this.free = free; - } - - public long getUsed() { - return used; - } - - public void setUsed(long used) { - this.used = used; - } - - public double getUsage() { - return usage; - } - - public void setUsage(double usage) { - this.usage = usage; - } -} diff --git a/io.sc.platform.monitor/src/main/resources/META-INF/MANIFEST.MF b/io.sc.platform.monitor/src/main/resources/META-INF/MANIFEST.MF index edc178ef..6fd3d247 100644 --- a/io.sc.platform.monitor/src/main/resources/META-INF/MANIFEST.MF +++ b/io.sc.platform.monitor/src/main/resources/META-INF/MANIFEST.MF @@ -1,4 +1,4 @@ Manifest-Version: 1.0 Implementation-Vendor: io.sc -Implementation-Title: io.sc.platform.mvc +Implementation-Title: io.sc.platform.monitor Implementation-Version: 1.0.0 diff --git a/io.sc.platform.monitor/src/main/resources/META-INF/spring.factories b/io.sc.platform.monitor/src/main/resources/META-INF/spring.factories deleted file mode 100644 index bc84b459..00000000 --- a/io.sc.platform.monitor/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,15 +0,0 @@ -# Auto Configuration -#org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -#io.sc.platform.mvc.autoconfigure.MvcWebMvcAutoConfiguration,\ -#io.sc.platform.mvc.autoconfigure.MvcServiceProviderAutoConfiguration,\ -#io.sc.platform.mvc.autoconfigure.ReturnValueAutoConfiguration,\ -#io.sc.platform.mvc.autoconfigure.MvcErrorAutoConfiguration - -# Auto Configuration -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -io.sc.platform.mvc.autoconfigure.MvcServiceProviderAutoConfiguration - - -# platform plugin spi service -io.sc.platform.core.spi.PluginSpiService=\ -io.sc.platform.mvc.plugins.PluginSpiServiceImpl \ No newline at end of file diff --git a/io.sc.platform.mvc/src/main/java/io/sc/platform/mvc/autoconfigure/MvcWebMvcAutoConfiguration.java b/io.sc.platform.mvc/src/main/java/io/sc/platform/mvc/autoconfigure/MvcWebMvcAutoConfiguration.java index c0ce72c4..5698efef 100644 --- a/io.sc.platform.mvc/src/main/java/io/sc/platform/mvc/autoconfigure/MvcWebMvcAutoConfiguration.java +++ b/io.sc.platform.mvc/src/main/java/io/sc/platform/mvc/autoconfigure/MvcWebMvcAutoConfiguration.java @@ -1,5 +1,6 @@ package io.sc.platform.mvc.autoconfigure; +import io.sc.platform.mvc.autoconfigure.support.OnlineUserCounterInterceptor; import io.sc.platform.mvc.autoconfigure.support.RequestHeaderLocaleChangeInterceptor; import io.sc.platform.mvc.plugins.PluginManager; import io.sc.platform.mvc.plugins.item.Resource; @@ -63,6 +64,8 @@ public class MvcWebMvcAutoConfiguration implements WebMvcConfigurer{ registry.addInterceptor(new RequestHeaderLocaleChangeInterceptor()); //主题拦截器 registry.addInterceptor(new ThemeChangeInterceptor()); + //在线用户计数器 + registry.addInterceptor(new OnlineUserCounterInterceptor()); } @Override diff --git a/io.sc.platform.mvc/src/main/java/io/sc/platform/mvc/autoconfigure/support/OnlineUserCounterInterceptor.java b/io.sc.platform.mvc/src/main/java/io/sc/platform/mvc/autoconfigure/support/OnlineUserCounterInterceptor.java new file mode 100644 index 00000000..192dbb63 --- /dev/null +++ b/io.sc.platform.mvc/src/main/java/io/sc/platform/mvc/autoconfigure/support/OnlineUserCounterInterceptor.java @@ -0,0 +1,44 @@ +package io.sc.platform.mvc.autoconfigure.support; + +import io.sc.platform.security.util.SecurityUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.lang.Nullable; +import org.springframework.util.ObjectUtils; +import org.springframework.util.StringUtils; +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.LocaleResolver; +import org.springframework.web.servlet.support.RequestContextUtils; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.HashSet; +import java.util.Locale; +import java.util.Set; + +public class OnlineUserCounterInterceptor implements HandlerInterceptor { + private static final Set sessionIds =new HashSet<>(); + + public static void addSession(String sessionId) { + if(StringUtils.hasText(sessionId)) { + sessionIds.add(sessionId); + } + } + + public static void removeSession(String sessionId) { + if(StringUtils.hasText(sessionId)) { + sessionIds.remove(sessionId); + } + } + + public static int count(){ + return sessionIds.size(); + } + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws ServletException { + OnlineUserCounterInterceptor.addSession(SecurityUtil.getUserId()); + return true; + } +} diff --git a/io.sc.platform.system.frontend/package.json b/io.sc.platform.system.frontend/package.json index 2de945b9..554ce9b1 100644 --- a/io.sc.platform.system.frontend/package.json +++ b/io.sc.platform.system.frontend/package.json @@ -92,7 +92,7 @@ "luckyexcel": "1.0.1", "mockjs": "1.1.0", "pinia": "2.1.7", - "platform-core": "8.1.223", + "platform-core": "8.1.225", "quasar": "2.15.3", "tailwindcss": "3.4.3", "vue": "3.4.24", diff --git a/io.sc.platform.system.frontend/src/components/index.ts b/io.sc.platform.system.frontend/src/components/index.ts index 7767c78b..a002e264 100644 --- a/io.sc.platform.system.frontend/src/components/index.ts +++ b/io.sc.platform.system.frontend/src/components/index.ts @@ -18,7 +18,7 @@ import component_system_I18n from '@/views/i18n/I18n.vue'; import component_system_datasource from '@/views/datasource/Datasource.vue'; import component_system_monitor_AuditLog from '@/views/monitor/AuditLog.vue'; import component_system_monitor_Log from '@/views/monitor/Log.vue'; -import component_system_monitor_Resources from '@/views/monitor/Resources.vue'; +import component_system_monitor_ServerInfo from '@/views/monitor/ServerInfo.vue'; const localComponents = { 'component.system.License': component_system_License, @@ -37,7 +37,7 @@ const localComponents = { 'component.system.datasource': component_system_datasource, 'component.system.monitor.AuditLog': component_system_monitor_AuditLog, 'component.system.monitor.Log': component_system_monitor_Log, - 'component.system.monitor.Resources': component_system_monitor_Resources, + 'component.system.monitor.ServerInfo': component_system_monitor_ServerInfo, }; export default localComponents; diff --git a/io.sc.platform.system.frontend/src/i18n/messages.json b/io.sc.platform.system.frontend/src/i18n/messages.json index 142a8585..9ce2d222 100644 --- a/io.sc.platform.system.frontend/src/i18n/messages.json +++ b/io.sc.platform.system.frontend/src/i18n/messages.json @@ -17,7 +17,7 @@ "menu.system.monitor" : "Monitor", "menu.system.monitor.auditlog" : "Audit Log", "menu.system.monitor.log" : "Log", - "menu.system.monitor.resources" : "Resources", + "menu.system.monitor.serverInfo" : "Server Information", "system.shared.selectUser.grid.title": "Included User List", "system.shared.selectUser.grid.toolbar.selectIn":"Select In", @@ -152,5 +152,10 @@ "system.monitor.log.download.grid.title":"Log File List", "system.monitor.log.level.grid.title":"Log Level List", "system.monitor.log.level.entity.configuredLevel":"Configured", - "system.monitor.log.level.entity.effectiveLevel":"Effective" + "system.monitor.log.level.entity.effectiveLevel":"Effective", + + "system.monitor.serverInfo.os":"Operating System", + "system.monitor.serverInfo.os.name":"Name", + "system.monitor.serverInfo.os.version":"Version", + "system.monitor.serverInfo.os.arch":"Architecture", } diff --git a/io.sc.platform.system.frontend/src/i18n/messages_tw_CN.json b/io.sc.platform.system.frontend/src/i18n/messages_tw_CN.json index 66aad1d8..67b41aa6 100644 --- a/io.sc.platform.system.frontend/src/i18n/messages_tw_CN.json +++ b/io.sc.platform.system.frontend/src/i18n/messages_tw_CN.json @@ -17,7 +17,7 @@ "menu.system.monitor" : "系統監控", "menu.system.monitor.auditlog" : "審計日誌", "menu.system.monitor.log" : "系統日誌", - "menu.system.monitor.resources" : "系統資源", + "menu.system.monitor.serverInfo" : "服務器信息", "system.shared.selectUser.grid.title": "已包含用戶列表", "system.shared.selectUser.grid.toolbar.selectIn":"選入", @@ -129,5 +129,10 @@ "system.monitor.log.download.grid.title":"日誌文件列表", "system.monitor.log.level.grid.title":"日誌級別列表", "system.monitor.log.level.entity.configuredLevel":"配置級別", - "system.monitor.log.level.entity.effectiveLevel":"生效級別" + "system.monitor.log.level.entity.effectiveLevel":"生效級別", + + "system.monitor.serverInfo.os":"操作系統", + "system.monitor.serverInfo.os.name":"名稱", + "system.monitor.serverInfo.os.version":"版本", + "system.monitor.serverInfo.os.arch":"架構", } diff --git a/io.sc.platform.system.frontend/src/i18n/messages_zh_CN.json b/io.sc.platform.system.frontend/src/i18n/messages_zh_CN.json index 5a4acab6..57fc1a90 100644 --- a/io.sc.platform.system.frontend/src/i18n/messages_zh_CN.json +++ b/io.sc.platform.system.frontend/src/i18n/messages_zh_CN.json @@ -17,7 +17,7 @@ "menu.system.monitor" : "系统监控", "menu.system.monitor.auditlog" : "审计日志", "menu.system.monitor.log" : "系统日志", - "menu.system.monitor.resources" : "系统资源", + "menu.system.monitor.serverInfo" : "服务器信息", "system.shared.selectUser.grid.title": "已包含用户列表", "system.shared.selectUser.grid.toolbar.selectIn":"选入", @@ -151,5 +151,40 @@ "system.monitor.log.download.grid.title":"日志文件列表", "system.monitor.log.level.grid.title":"日志级别列表", "system.monitor.log.level.entity.configuredLevel":"配置级别", - "system.monitor.log.level.entity.effectiveLevel":"生效级别" + "system.monitor.log.level.entity.effectiveLevel":"生效级别", + + "system.monitor.serverInfo.hardware":"硬件", + "system.monitor.serverInfo.hardware.manufacturer":"生产商", + "system.monitor.serverInfo.hardware.model":"型号", + "system.monitor.serverInfo.hardware.serialNumber":"序列号", + "system.monitor.serverInfo.hardware.physicalProcessorCount":"物理处理器个数", + "system.monitor.serverInfo.hardware.logicalProcessorCount":"逻辑处理器个数", + "system.monitor.serverInfo.hardware.physicalMemory":"物理内存", + + "system.monitor.serverInfo.os":"操作系统", + "system.monitor.serverInfo.os.name":"名称", + "system.monitor.serverInfo.os.version":"版本", + "system.monitor.serverInfo.os.arch":"架构", + "system.monitor.serverInfo.os.manufacturer":"生产商", + "system.monitor.serverInfo.os.bootTime":"上次启动日期", + "system.monitor.serverInfo.os.upTime":"持续运行天数", + + "system.monitor.serverInfo.jvm":"Java 虚拟机", + "system.monitor.serverInfo.jvm.total":"当前占用的内存总数", + "system.monitor.serverInfo.jvm.max":"最大可用内存总数", + "system.monitor.serverInfo.jvm.free":"空闲内存", + "system.monitor.serverInfo.jvm.version":"JDK 版本", + "system.monitor.serverInfo.jvm.home":"JDK 路径", + + "system.monitor.serverInfo.cpu":"CPU", + "system.monitor.serverInfo.cpu.system":"系统", + "system.monitor.serverInfo.cpu.user":"用户", + + "system.monitor.serverInfo.memory":"内存", + + "system.monitor.serverInfo.disk":"存储", + "system.monitor.serverInfo.disk.used":"已用", + "system.monitor.serverInfo.disk.free":"空闲", + + "system.monitor.serverInfo.online":"在线用户", } diff --git a/io.sc.platform.system.frontend/src/menus/menus.json b/io.sc.platform.system.frontend/src/menus/menus.json index 8dee233e..d792d26b 100644 --- a/io.sc.platform.system.frontend/src/menus/menus.json +++ b/io.sc.platform.system.frontend/src/menus/menus.json @@ -64,7 +64,7 @@ {"type":"ROUTE", "order":100, "parentId":"menu.system.monitor", "id":"menu.system.monitor.auditlog", "titleI18nKey":"menu.system.monitor.auditlog", "icon":"bi-card-list", "routeName":"route.system.monitor.auditlog","authorizeExpression":"'database'.equals(T(org.wsp.framework.core.Environment).getAuditLogType())"}, /*系统管理/系统监控/系统日志*/ {"type":"ROUTE", "order":200, "parentId":"menu.system.monitor", "id":"menu.system.monitor.log", "titleI18nKey":"menu.system.monitor.log", "icon":"bi-terminal", "routeName":"route.system.monitor.log"}, - /*系统管理/系统监控/系统资源*/ - {"type":"ROUTE", "order":300, "parentId":"menu.system.monitor", "id":"menu.system.monitor.resources", "titleI18nKey":"menu.system.monitor.resources", "icon":"ssid_chart", "routeName":"route.system.monitor.resources"} + /*系统管理/系统监控/服务器信息*/ + {"type":"ROUTE", "order":300, "parentId":"menu.system.monitor", "id":"menu.system.monitor.serverInfo", "titleI18nKey":"menu.system.monitor.serverInfo", "icon":"ssid_chart", "routeName":"route.system.monitor.serverInfo"} ] diff --git a/io.sc.platform.system.frontend/src/routes/routes.json b/io.sc.platform.system.frontend/src/routes/routes.json index 77058f9d..7a0f0812 100644 --- a/io.sc.platform.system.frontend/src/routes/routes.json +++ b/io.sc.platform.system.frontend/src/routes/routes.json @@ -247,16 +247,16 @@ }, { "parent": "/", - "name": "route.system.monitor.resources", - "path": "system/monitor/resources", + "name": "route.system.monitor.serverInfo", + "path": "system/monitor/serverInfo", "priority": 0, "module": "io.sc.platform.system.frontend", - "component": "component.system.monitor.Resources", - "componentPath":"@/views/monitor/Resources.vue", + "component": "component.system.monitor.ServerInfo", + "componentPath":"@/views/monitor/ServerInfo.vue", "redirect": null, "meta": { "permissions": [ - "/system/monitor/resources/**/*" + "/system/monitor/serverInfo/**/*" ] } } diff --git a/io.sc.platform.system.frontend/src/views/application/Application.vue b/io.sc.platform.system.frontend/src/views/application/Application.vue index 7a3f3bb8..f9b26256 100644 --- a/io.sc.platform.system.frontend/src/views/application/Application.vue +++ b/io.sc.platform.system.frontend/src/views/application/Application.vue @@ -63,14 +63,12 @@ }" @row-click=" (evt, row, index) => { - currentSelectedApplicationId = row.id; - menuTreeGridRef?.refresh(); + refreshRelationshipComponents(row.id); } " @before-request-data=" () => { - currentSelectedApplicationId = ''; - menuTreeGridRef?.refresh(); + refreshRelationshipComponents(''); } " > @@ -109,6 +107,11 @@ const menuTreeGridRef = ref(); const selectedTabRef = ref('menu'); const currentSelectedApplicationId = ref(''); +const refreshRelationshipComponents = (id) => { + currentSelectedApplicationId.value = id; + menuTreeGridRef.value?.refresh(); +}; + const update = (ids, gridComponent) => { axios .post(Environment.apiContextPath('/api/system/application/updateMenus'), { diff --git a/io.sc.platform.system.frontend/src/views/corporation/Corporation.vue b/io.sc.platform.system.frontend/src/views/corporation/Corporation.vue index ca3426c0..7cb087f4 100644 --- a/io.sc.platform.system.frontend/src/views/corporation/Corporation.vue +++ b/io.sc.platform.system.frontend/src/views/corporation/Corporation.vue @@ -74,14 +74,12 @@ }" @row-click=" (evt, row, index) => { - currentSelectedCorporationCode = row.code; - userGridRef?.refresh(); + refreshRelationshipComponents(row.code); } " @before-request-data=" () => { - currentSelectedCorporationCode = ''; - userGridRef?.refresh(); + refreshRelationshipComponents(''); } " > @@ -114,6 +112,11 @@ const corporationTreeGridRef = ref(); const userGridRef = ref(); const currentSelectedCorporationCode = ref(''); +const refreshRelationshipComponents = (id) => { + currentSelectedCorporationCode.value = id; + userGridRef.value?.refresh(); +}; + const selectIn = (ids: string[], gridComponent, dialogComponent) => { axios .post(Environment.apiContextPath('/api/system/corporation/addUsers'), { diff --git a/io.sc.platform.system.frontend/src/views/department/Department.vue b/io.sc.platform.system.frontend/src/views/department/Department.vue index 874f8ef2..8b06cf5b 100644 --- a/io.sc.platform.system.frontend/src/views/department/Department.vue +++ b/io.sc.platform.system.frontend/src/views/department/Department.vue @@ -75,14 +75,12 @@ }" @row-click=" (evt, row, index) => { - currentSelectedDepartmentId = row.id; - userGridRef?.refresh(); + refreshRelationshipComponents(row.id); } " @before-request-data=" () => { - currentSelectedDepartmentId = ''; - userGridRef?.refresh(); + refreshRelationshipComponents(''); } " > @@ -125,6 +123,11 @@ const userGridRef = ref(); const selectedTabRef = ref('user'); const currentSelectedDepartmentId = ref(''); +const refreshRelationshipComponents = (id) => { + currentSelectedDepartmentId.value = id; + userGridRef.value?.refresh(); +}; + const selectIn = (ids: string[], gridComponent, dialogComponent) => { axios .post(Environment.apiContextPath('/api/system/department/addUsers'), { diff --git a/io.sc.platform.system.frontend/src/views/menu/Menu.vue b/io.sc.platform.system.frontend/src/views/menu/Menu.vue index e9c5521d..f432d3db 100644 --- a/io.sc.platform.system.frontend/src/views/menu/Menu.vue +++ b/io.sc.platform.system.frontend/src/views/menu/Menu.vue @@ -183,16 +183,12 @@ " @row-click=" (evt, row, index) => { - currentSelectedMenuId = row.id; - roleGridRef?.refresh(); - orgTreeGridRef?.refresh(); + refreshRelationshipComponents(row.id); } " @before-request-data=" () => { - currentSelectedMenuId = ''; - roleGridRef?.refresh(); - orgTreeGridRef?.refresh(); + refreshRelationshipComponents(''); } " > @@ -270,11 +266,19 @@ const importMenuPluginDialogRef = ref(); const selectedTabRef = ref('role'); const currentSelectedMenuId = ref(''); +const refreshRelationshipComponents = (id) => { + currentSelectedMenuId.value = id; + roleGridRef.value?.refresh(); + orgTreeGridRef.value?.refresh(); +}; + const selectRoleIn = (ids: string[], gridComponent, dialogComponent) => { axios .post(Environment.apiContextPath('/api/system/menu/addRoles'), { - one: menuTreeGridRef.value.getSelectedRows()[0].id, - many: ids, + source: menuTreeGridRef.value.getSelectedRow().id, + sourceParents: menuTreeGridRef.value.getCascadeParents('id'), + sourceChildren: menuTreeGridRef.value.getCascadeChildren('id'), + targets: ids, }) .then(() => { gridComponent?.refresh(); @@ -285,8 +289,10 @@ const selectRoleIn = (ids: string[], gridComponent, dialogComponent) => { const selectRoleOut = (ids, gridComponent) => { axios .post(Environment.apiContextPath('/api/system/menu/removeRoles'), { - one: menuTreeGridRef.value.getSelectedRows()[0].id, - many: ids, + source: menuTreeGridRef.value.getSelectedRow().id, + sourceParents: menuTreeGridRef.value.getCascadeParents('id'), + sourceChildren: menuTreeGridRef.value.getCascadeChildren('id'), + targets: ids, }) .then(() => { gridComponent?.refresh(); @@ -296,8 +302,10 @@ const selectRoleOut = (ids, gridComponent) => { const selectRoleAllIn = (gridComponent) => { axios .post(Environment.apiContextPath('/api/system/menu/addAllRoles'), { - one: menuTreeGridRef.value.getSelectedRows()[0].id, - many: [], + source: menuTreeGridRef.value.getSelectedRow().id, + sourceParents: menuTreeGridRef.value.getCascadeParents('id'), + sourceChildren: menuTreeGridRef.value.getCascadeChildren('id'), + targets: [], }) .then(() => { gridComponent?.refresh(); @@ -307,8 +315,10 @@ const selectRoleAllIn = (gridComponent) => { const selectRoleAllOut = (gridComponent) => { axios .post(Environment.apiContextPath('/api/system/menu/removeAllRoles'), { - one: menuTreeGridRef.value.getSelectedRows()[0].id, - many: [], + source: menuTreeGridRef.value.getSelectedRow().id, + sourceParents: menuTreeGridRef.value.getCascadeParents('id'), + sourceChildren: menuTreeGridRef.value.getCascadeChildren('id'), + targets: [], }) .then(() => { gridComponent?.refresh(); @@ -318,8 +328,10 @@ const selectRoleAllOut = (gridComponent) => { const selectApplicationIn = (ids: string[], gridComponent, dialogComponent) => { axios .post(Environment.apiContextPath('/api/system/menu/addApplications'), { - one: menuTreeGridRef.value.getSelectedRows()[0].id, - many: ids, + source: menuTreeGridRef.value.getSelectedRow().id, + sourceParents: menuTreeGridRef.value.getCascadeParents('id'), + sourceChildren: menuTreeGridRef.value.getCascadeChildren('id'), + targets: ids, }) .then(() => { gridComponent?.refresh(); @@ -330,8 +342,10 @@ const selectApplicationIn = (ids: string[], gridComponent, dialogComponent) => { const selectApplicationOut = (ids, gridComponent) => { axios .post(Environment.apiContextPath('/api/system/menu/removeApplications'), { - one: menuTreeGridRef.value.getSelectedRows()[0].id, - many: ids, + source: menuTreeGridRef.value.getSelectedRow().id, + sourceParents: menuTreeGridRef.value.getCascadeParents('id'), + sourceChildren: menuTreeGridRef.value.getCascadeChildren('id'), + targets: ids, }) .then(() => { gridComponent?.refresh(); @@ -341,8 +355,10 @@ const selectApplicationOut = (ids, gridComponent) => { const selectApplicationAllIn = (gridComponent) => { axios .post(Environment.apiContextPath('/api/system/menu/addAllApplications'), { - one: menuTreeGridRef.value.getSelectedRows()[0].id, - many: [], + source: menuTreeGridRef.value.getSelectedRow().id, + sourceParents: menuTreeGridRef.value.getCascadeParents('id'), + sourceChildren: menuTreeGridRef.value.getCascadeChildren('id'), + targets: [], }) .then(() => { gridComponent?.refresh(); @@ -352,8 +368,10 @@ const selectApplicationAllIn = (gridComponent) => { const selectApplicationAllOut = (gridComponent) => { axios .post(Environment.apiContextPath('/api/system/menu/removeAllApplications'), { - one: menuTreeGridRef.value.getSelectedRows()[0].id, - many: [], + source: menuTreeGridRef.value.getSelectedRow().id, + sourceParents: menuTreeGridRef.value.getCascadeParents('id'), + sourceChildren: menuTreeGridRef.value.getCascadeChildren('id'), + targets: [], }) .then(() => { gridComponent?.refresh(); @@ -363,8 +381,10 @@ const selectApplicationAllOut = (gridComponent) => { const update = (ids, gridComponent) => { axios .post(Environment.apiContextPath('/api/system/menu/updateOrgs'), { - one: menuTreeGridRef.value.getSelectedRows()[0].id, - many: ids, + source: menuTreeGridRef.value.getSelectedRow().id, + sourceParents: menuTreeGridRef.value.getCascadeParents('id'), + sourceChildren: menuTreeGridRef.value.getCascadeChildren('id'), + targets: ids, }) .then(() => { gridComponent.refresh(); diff --git a/io.sc.platform.system.frontend/src/views/monitor/Resources.vue b/io.sc.platform.system.frontend/src/views/monitor/Resources.vue deleted file mode 100644 index 1a4913ff..00000000 --- a/io.sc.platform.system.frontend/src/views/monitor/Resources.vue +++ /dev/null @@ -1,4 +0,0 @@ - - diff --git a/io.sc.platform.system.frontend/src/views/monitor/ServerInfo.vue b/io.sc.platform.system.frontend/src/views/monitor/ServerInfo.vue new file mode 100644 index 00000000..c99536eb --- /dev/null +++ b/io.sc.platform.system.frontend/src/views/monitor/ServerInfo.vue @@ -0,0 +1,215 @@ + + diff --git a/io.sc.platform.system.frontend/src/views/org/Org.vue b/io.sc.platform.system.frontend/src/views/org/Org.vue index acb1d6a4..3788eaf6 100644 --- a/io.sc.platform.system.frontend/src/views/org/Org.vue +++ b/io.sc.platform.system.frontend/src/views/org/Org.vue @@ -74,16 +74,12 @@ }" @row-click=" (evt, row, index) => { - currentSelectedOrgId = row.id; - userGridRef?.refresh(); - menuTreeGridRef?.refresh(); + refreshRelationshipComponents(row.id); } " @before-request-data=" () => { - currentSelectedOrgId = ''; - userGridRef?.refresh(); - menuTreeGridRef?.refresh(); + refreshRelationshipComponents(''); } " > @@ -138,6 +134,12 @@ const menuTreeGridRef = ref(); const selectedTabRef = ref('user'); const currentSelectedOrgId = ref(''); +const refreshRelationshipComponents = (id) => { + currentSelectedOrgId.value = id; + userGridRef.value?.refresh(); + menuTreeGridRef.value?.refresh(); +}; + const selectIn = (ids: string[], gridComponent, dialogComponent) => { axios .post(Environment.apiContextPath('/api/system/org/addUsers'), { diff --git a/io.sc.platform.system.frontend/src/views/role/Role.vue b/io.sc.platform.system.frontend/src/views/role/Role.vue index 15788601..555e1464 100644 --- a/io.sc.platform.system.frontend/src/views/role/Role.vue +++ b/io.sc.platform.system.frontend/src/views/role/Role.vue @@ -63,16 +63,12 @@ }" @row-click=" (evt, row, index) => { - currentSelectedRoleId = row.id; - menuTreeGridRef?.refresh(); - userGridRef?.refresh(); + refreshRelationshipComponents(row.id); } " @before-request-data=" () => { - currentSelectedRoleId = ''; - menuTreeGridRef?.refresh(); - userGridRef?.refresh(); + refreshRelationshipComponents(''); } " > @@ -118,12 +114,10 @@