登录和未登录的session超时时间分开;deviceType 设备类型,默认 pc

;新增孤立会话集群模式Quartz清理;微服务情况下可关闭孤立会话清理任务,只需开启core服务即可;在线用户游客列表,删除还未来得及清理的已超时会话;在线人数统计,增加缓存3分钟的数据,节省服务器资源
This commit is contained in:
thinkgem
2022-03-12 09:23:07 +08:00
parent ab1481f6c7
commit 18cca069c1
4 changed files with 30 additions and 25 deletions

View File

@@ -39,7 +39,7 @@ import com.jeesite.modules.sys.utils.UserUtils;
/**
* 在线用户Controller
* @author ThinkGem
* @version 2016-8-31
* @version 2022-3-10
*/
@Controller
@RequestMapping(value = "${adminPath}/sys/online")
@@ -58,7 +58,8 @@ public class OnlineController extends BaseController{
@RequestMapping(value = "count")
@ResponseBody
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 instanceof LoginInfo){
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);
}
}

View File

@@ -443,15 +443,17 @@ shiro:
# 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 超时时间,大于这个值。
sessionTimeout: 1800000
# PC设备会话超时参数设置登录请求参数加 param_deviceType=pc 时有效
#pcSessionTimeout: 1800000
# 游客会话超时时间只访问了系统但未登录系统的用户为游客游客默认超时时间为10分钟未登录系统时的图片验证码有效时间。
sessionTimeout: 180000
# 手机APP设备会话超时参数设置登录请求参数加 param_deviceType=mobileApp 时有效
#mobileAppSessionTimeout: 43200000
# 登录系统后的用户超时时间(不明确 param_deviceType 参数的,默认设备为 pc 登录)
pcSessionTimeout: 1800000
# 手机APP设备会话超时参数设置登录请求参数加 param_deviceType=mobileApp 时有效,一般无需单独设置
#mobileAppSessionTimeout: 1800000
# 定时清理失效会话,清理用户直接关闭浏览器造成的孤立会话
sessionTimeoutClean: 1200000

View File

@@ -11,8 +11,8 @@
</div>
</div>
<div class="box-body">
<#form:form id="searchForm" action="${ctx}/sys/online/listData" method="post" class="form-inline hide2"
data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
<#form:form id="searchForm" action="${ctx}/sys/online/listData" method="post" class="form-inline hide2"
data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
<div class="form-group">
<label class="control-label">${text('操作用户')}</label>
<div class="control-inline width-160">
@@ -21,11 +21,11 @@
checkbox="false" itemCode="userCode" itemName="userName"/>
</div>
</div>
<div class="form-group">
<div class="form-group">
<div class="control-inline" title="${text('包含3分钟以上未操作的用户')}">&nbsp;
<#form:checkbox name="isAllOnline" value="false" label="${text('查询所有在线')}"
class="form-control"/>
</div>
</div>
</div>
<div class="form-group">
<div class="control-inline" title="${text('包含未登录的用户')}">
@@ -33,10 +33,10 @@
class="form-control"/>
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
</div>
</#form:form>
<table id="dataGrid"></table>
</div>
@@ -59,7 +59,7 @@ $('#dataGrid').dataGrid({
return js.getDictLabel(${@DictUtils.getDictListJson('sys_user_type')}, val, '未知', true);
}},
{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')){ %>
,{header:'${text("操作")}', name:'actions', width:100, sortable:false, formatter: function(val, obj, row, act){