登录和未登录的session超时时间分开;deviceType 设备类型,默认 pc
;新增孤立会话集群模式Quartz清理;微服务情况下可关闭孤立会话清理任务,只需开启core服务即可;在线用户游客列表,删除还未来得及清理的已超时会话;在线人数统计,增加缓存3分钟的数据,节省服务器资源
This commit is contained in:
@@ -42,6 +42,9 @@ public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
String str = val.toString();
|
String str = val.toString();
|
||||||
|
if (StringUtils.isBlank(str)) {
|
||||||
|
return 0D;
|
||||||
|
}
|
||||||
if (StringUtils.contains(str, "*")) {
|
if (StringUtils.contains(str, "*")) {
|
||||||
Double number = null, d = null;
|
Double number = null, d = null;
|
||||||
for (String s : StringUtils.split(str, "*")) {
|
for (String s : StringUtils.split(str, "*")) {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ import com.jeesite.modules.sys.utils.UserUtils;
|
|||||||
/**
|
/**
|
||||||
* 在线用户Controller
|
* 在线用户Controller
|
||||||
* @author ThinkGem
|
* @author ThinkGem
|
||||||
* @version 2016-8-31
|
* @version 2022-3-10
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping(value = "${adminPath}/sys/online")
|
@RequestMapping(value = "${adminPath}/sys/online")
|
||||||
@@ -58,7 +58,8 @@ public class OnlineController extends BaseController{
|
|||||||
@RequestMapping(value = "count")
|
@RequestMapping(value = "count")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Integer count(HttpServletRequest request, HttpServletResponse response) {
|
public Integer count(HttpServletRequest request, HttpServletResponse response) {
|
||||||
return sessionDAO.getActiveSessions(true, true).size();
|
// 在线人数统计,缓存3分钟的数据,要求高的业务可缩小间隔时间
|
||||||
|
return sessionDAO.getActiveSessionsCount(false, false, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -156,7 +157,7 @@ public class OnlineController extends BaseController{
|
|||||||
if (pp != null) {
|
if (pp != null) {
|
||||||
if (pp instanceof LoginInfo){
|
if (pp instanceof LoginInfo){
|
||||||
LoginInfo loginInfo = ((LoginInfo)pp);
|
LoginInfo loginInfo = ((LoginInfo)pp);
|
||||||
String key = loginInfo.getId()+"_"+loginInfo.getParam("deviceType", "PC");
|
String key = loginInfo.getId()+"_"+loginInfo.getParam("deviceType", "pc");
|
||||||
onlineTickOutMap.put(key, StringUtils.EMPTY);
|
onlineTickOutMap.put(key, StringUtils.EMPTY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ job:
|
|||||||
isClustered: true
|
isClustered: true
|
||||||
dataSourceName: job
|
dataSourceName: job
|
||||||
clusterCheckinInterval: 1000
|
clusterCheckinInterval: 1000
|
||||||
# className: org.springframework.scheduling.quartz.LocalDataSourceJobStore
|
#className: org.springframework.scheduling.quartz.LocalDataSourceJobStore
|
||||||
|
|
||||||
# 调度日志配置
|
# 调度日志配置
|
||||||
log:
|
log:
|
||||||
@@ -443,17 +443,19 @@ shiro:
|
|||||||
# Session 相关
|
# Session 相关
|
||||||
session:
|
session:
|
||||||
|
|
||||||
# 全局会话超时,单位:毫秒, 20m=1200000ms, 30m=1800000ms, 60m=3600000ms, 12h=43200000ms, 1day=86400000ms
|
# 会话超时时间,单位:毫秒,10m=600000, 20m=1200000ms, 30m=1800000ms, 60m=3600000ms, 12h=43200000ms, 1day=86400000ms
|
||||||
# 注意:如果超时超过30m,你还需要同步修改当前配置文件的属性:j2cache.caffeine.region.sessionCache 超时时间,大于这个值。
|
# 注意:如果超时超过30m,你还需要同步修改当前配置文件的属性:j2cache.caffeine.region.sessionCache 超时时间,大于这个值。
|
||||||
sessionTimeout: 1800000
|
|
||||||
|
|
||||||
# PC设备会话超时参数设置,登录请求参数加 param_deviceType=pc 时有效
|
# 游客会话超时时间:只访问了系统,但未登录系统的用户为游客,游客默认超时时间为10分钟,如:未登录系统时的图片验证码有效时间。
|
||||||
#pcSessionTimeout: 1800000
|
sessionTimeout: 180000
|
||||||
|
|
||||||
# 手机APP设备会话超时参数设置,登录请求参数加 param_deviceType=mobileApp 时有效
|
# 登录系统后的用户超时时间(不明确 param_deviceType 参数的,默认设备为 pc 登录)
|
||||||
#mobileAppSessionTimeout: 43200000
|
pcSessionTimeout: 1800000
|
||||||
|
|
||||||
# 定时清理失效会话,清理用户直接关闭浏览器造成的孤立会话
|
# 手机APP设备会话超时参数设置,登录请求参数加 param_deviceType=mobileApp 时有效,一般无需单独设置
|
||||||
|
#mobileAppSessionTimeout: 1800000
|
||||||
|
|
||||||
|
# 定时清理失效会话,清理用户直接关闭浏览器造成的孤立会话(设置为 0 关闭,微服务下只开启 core 即可)
|
||||||
sessionTimeoutClean: 1200000
|
sessionTimeoutClean: 1200000
|
||||||
|
|
||||||
# 会话唯一标识SessionId在Cookie中的名称。
|
# 会话唯一标识SessionId在Cookie中的名称。
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ $('#dataGrid').dataGrid({
|
|||||||
return js.getDictLabel(${@DictUtils.getDictListJson('sys_user_type')}, val, '未知', true);
|
return js.getDictLabel(${@DictUtils.getDictListJson('sys_user_type')}, val, '未知', true);
|
||||||
}},
|
}},
|
||||||
{header:'${text("设备类型")}', name:'deviceType', width:50, align:'center', formatter: function(val, obj, row, act){
|
{header:'${text("设备类型")}', name:'deviceType', width:50, align:'center', formatter: function(val, obj, row, act){
|
||||||
return js.getDictLabel(${@DictUtils.getDictListJson('sys_device_type')}, val, 'PC', true);
|
return js.getDictLabel(${@DictUtils.getDictListJson('sys_device_type')}, val, '未知', true);
|
||||||
}}
|
}}
|
||||||
<% if(hasPermi('sys:online:edit')){ %>
|
<% if(hasPermi('sys:online:edit')){ %>
|
||||||
,{header:'${text("操作")}', name:'actions', width:100, sortable:false, formatter: function(val, obj, row, act){
|
,{header:'${text("操作")}', name:'actions', width:100, sortable:false, formatter: function(val, obj, row, act){
|
||||||
|
|||||||
@@ -580,17 +580,19 @@ shiro:
|
|||||||
# Session 相关
|
# Session 相关
|
||||||
#session:
|
#session:
|
||||||
#
|
#
|
||||||
# # 全局会话超时,单位:毫秒, 20m=1200000ms, 30m=1800000ms, 60m=3600000ms, 12h=43200000ms, 1day=86400000ms
|
# # 会话超时时间,单位:毫秒,10m=600000, 20m=1200000ms, 30m=1800000ms, 60m=3600000ms, 12h=43200000ms, 1day=86400000ms
|
||||||
# # 注意:如果超时超过30m,你还需要同步修改当前配置文件的属性:j2cache.caffeine.region.sessionCache 超时时间,大于这个值。
|
# # 注意:如果超时超过30m,你还需要同步修改当前配置文件的属性:j2cache.caffeine.region.sessionCache 超时时间,大于这个值。
|
||||||
# sessionTimeout: 1800000
|
|
||||||
#
|
#
|
||||||
# # PC设备会话超时参数设置,登录请求参数加 param_deviceType=pc 时有效
|
# # 游客会话超时时间:只访问了系统,但未登录系统的用户为游客,游客默认超时时间为10分钟,如:未登录系统时的图片验证码有效时间。
|
||||||
# #pcSessionTimeout: 1800000
|
# sessionTimeout: 180000
|
||||||
#
|
#
|
||||||
# # 手机APP设备会话超时参数设置,登录请求参数加 param_deviceType=mobileApp 时有效
|
# # 登录系统后的用户超时时间(不明确 param_deviceType 参数的,默认设备为 pc 登录)
|
||||||
# #mobileAppSessionTimeout: 43200000
|
# pcSessionTimeout: 1800000
|
||||||
#
|
#
|
||||||
# # 定时清理失效会话,清理用户直接关闭浏览器造成的孤立会话
|
# # 手机APP设备会话超时参数设置,登录请求参数加 param_deviceType=mobileApp 时有效,一般无需单独设置
|
||||||
|
# #mobileAppSessionTimeout: 1800000
|
||||||
|
#
|
||||||
|
# # 定时清理失效会话,清理用户直接关闭浏览器造成的孤立会话(设置为 0 关闭,微服务下只开启 core 即可)
|
||||||
# sessionTimeoutClean: 1200000
|
# sessionTimeoutClean: 1200000
|
||||||
#
|
#
|
||||||
# # 会话唯一标识SessionId在Cookie中的名称。
|
# # 会话唯一标识SessionId在Cookie中的名称。
|
||||||
|
|||||||
@@ -580,17 +580,19 @@ shiro:
|
|||||||
# Session 相关
|
# Session 相关
|
||||||
#session:
|
#session:
|
||||||
#
|
#
|
||||||
# # 全局会话超时,单位:毫秒, 20m=1200000ms, 30m=1800000ms, 60m=3600000ms, 12h=43200000ms, 1day=86400000ms
|
# # 会话超时时间,单位:毫秒,10m=600000, 20m=1200000ms, 30m=1800000ms, 60m=3600000ms, 12h=43200000ms, 1day=86400000ms
|
||||||
# # 注意:如果超时超过30m,你还需要同步修改当前配置文件的属性:j2cache.caffeine.region.sessionCache 超时时间,大于这个值。
|
# # 注意:如果超时超过30m,你还需要同步修改当前配置文件的属性:j2cache.caffeine.region.sessionCache 超时时间,大于这个值。
|
||||||
# sessionTimeout: 1800000
|
|
||||||
#
|
#
|
||||||
# # PC设备会话超时参数设置,登录请求参数加 param_deviceType=pc 时有效
|
# # 游客会话超时时间:只访问了系统,但未登录系统的用户为游客,游客默认超时时间为10分钟,如:未登录系统时的图片验证码有效时间。
|
||||||
# #pcSessionTimeout: 1800000
|
# sessionTimeout: 180000
|
||||||
#
|
#
|
||||||
# # 手机APP设备会话超时参数设置,登录请求参数加 param_deviceType=mobileApp 时有效
|
# # 登录系统后的用户超时时间(不明确 param_deviceType 参数的,默认设备为 pc 登录)
|
||||||
# #mobileAppSessionTimeout: 43200000
|
# pcSessionTimeout: 1800000
|
||||||
#
|
#
|
||||||
# # 定时清理失效会话,清理用户直接关闭浏览器造成的孤立会话
|
# # 手机APP设备会话超时参数设置,登录请求参数加 param_deviceType=mobileApp 时有效,一般无需单独设置
|
||||||
|
# #mobileAppSessionTimeout: 1800000
|
||||||
|
#
|
||||||
|
# # 定时清理失效会话,清理用户直接关闭浏览器造成的孤立会话(设置为 0 关闭,微服务下只开启 core 即可)
|
||||||
# sessionTimeoutClean: 1200000
|
# sessionTimeoutClean: 1200000
|
||||||
#
|
#
|
||||||
# # 会话唯一标识SessionId在Cookie中的名称。
|
# # 会话唯一标识SessionId在Cookie中的名称。
|
||||||
|
|||||||
Reference in New Issue
Block a user