在线用户查询完成

This commit is contained in:
thinkgem
2018-01-18 22:58:47 +08:00
parent 10fadeb317
commit 8901309e8f
12 changed files with 458 additions and 407 deletions

View File

@@ -20,7 +20,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.beust.jcommander.internal.Lists; import com.beust.jcommander.internal.Lists;
@@ -80,11 +79,13 @@ public class OnlineController extends BaseController{
@RequiresPermissions("sys:online:view") @RequiresPermissions("sys:online:view")
@RequestMapping(value = "listData") @RequestMapping(value = "listData")
@ResponseBody @ResponseBody
public List<Map<String, Object>> listData(@RequestParam(defaultValue="true") Boolean excludeLeave, public List<Map<String, Object>> listData(String isAllOnline, String isVisitor, String sessionId,
@RequestParam(defaultValue="true") Boolean excludeVisitor, String sessionId, String userCode, String userCode, String userName, String userType, String orderBy) {
String userName, String userType, String orderBy) {
List<Map<String, Object>> list = Lists.newArrayList(); List<Map<String, Object>> list = Lists.newArrayList();
Collection<Session> sessions = sessionDAO.getActiveSessions(excludeLeave, excludeVisitor, null, sessionId, userCode); boolean excludeLeave = isAllOnline==null || !Global.YES.equals(isAllOnline);
boolean excludeVisitor = isVisitor==null || !Global.YES.equals(isVisitor);
Collection<Session> sessions = sessionDAO.getActiveSessions(excludeLeave,
excludeVisitor, null, sessionId, userCode);
long currentTime = System.currentTimeMillis(); long currentTime = System.currentTimeMillis();
for (Session session : sessions){ for (Session session : sessions){
if (StringUtils.isNotBlank(userName) && ((String)session.getAttribute("userName")).contains(userName)){ if (StringUtils.isNotBlank(userName) && ((String)session.getAttribute("userName")).contains(userName)){

View File

@@ -52,7 +52,7 @@ $('#dataGrid').dataGrid({
searchForm: $("#searchForm"), searchForm: $("#searchForm"),
columnModel: [ columnModel: [
{header:'区域名称', name:'areaName', index:'a.area_name', width:230, align:"left", frozen:true, formatter: function(val, obj, row, act){ {header:'区域名称', name:'areaName', index:'a.area_name', width:230, align:"left", frozen:true, formatter: function(val, obj, row, act){
return '( '+row.areaCode+' ) '+'<a href="${ctx}/sys/area/form?areaCode='+row.areaCode+'" class="btnList" data-title="编辑区域">'+(val ? val : row.id)+'</a>'; return '( '+row.areaCode+' ) '+'<a href="${ctx}/sys/area/form?areaCode='+row.areaCode+'" class="btnList" data-title="编辑区域">'+(val||row.id)+'</a>';
}}, }},
{header:'区域类型', name:'areaType', index:'a.area_type', width:150, align:"center", formatter: function(val, obj, row, act){ {header:'区域类型', name:'areaType', index:'a.area_type', width:150, align:"center", formatter: function(val, obj, row, act){
return js.getDictLabel(${@DictUtils.getDictListJson('sys_area_type')}, val, '未知', true); return js.getDictLabel(${@DictUtils.getDictListJson('sys_area_type')}, val, '未知', true);

View File

@@ -58,7 +58,7 @@ $('#dataGrid').dataGrid({
searchForm: $("#searchForm"), searchForm: $("#searchForm"),
columnModel: [ columnModel: [
{header:'公司名称', name:'companyName', index:'a.company_name', width:250, align:"left", frozen:true, formatter: function(val, obj, row, act){ {header:'公司名称', name:'companyName', index:'a.company_name', width:250, align:"left", frozen:true, formatter: function(val, obj, row, act){
return '( '+row.viewCode+' ) '+'<a href="${ctx}/sys/company/form?companyCode='+row.companyCode+'" class="btnList" data-title="编辑公司">'+(val ? val : row.id)+'</a>'; return '( '+row.viewCode+' ) '+'<a href="${ctx}/sys/company/form?companyCode='+row.companyCode+'" class="btnList" data-title="编辑公司">'+(val||row.id)+'</a>';
}}, }},
{header:'公司全称', name:'fullName', index:'a.full_name', width:200, align:"left"}, {header:'公司全称', name:'fullName', index:'a.full_name', width:200, align:"left"},
{header:'排序号', name:'treeSort', index:'a.tree_sort', width:80, align:"center"}, {header:'排序号', name:'treeSort', index:'a.tree_sort', width:80, align:"center"},

View File

@@ -64,7 +64,7 @@ $('#dataGrid').dataGrid({
searchForm: $("#searchForm"), searchForm: $("#searchForm"),
columnModel: [ columnModel: [
{header:'字典标签', name:'dictLabel', index:'a.dict_label', width:200, align:"left", frozen:true, formatter: function(val, obj, row, act){ {header:'字典标签', name:'dictLabel', index:'a.dict_label', width:200, align:"left", frozen:true, formatter: function(val, obj, row, act){
return '<a href="${ctx}/sys/dictData/form?dictCode='+row.dictCode+'" class="btnList" data-title="编辑字典数据">'+(val ? val : row.id)+'</a>'; return '<a href="${ctx}/sys/dictData/form?dictCode='+row.dictCode+'" class="btnList" data-title="编辑字典数据">'+(val||row.id)+'</a>';
}}, }},
{header:'字典键值', name:'dictValue', index:'a.dict_value', width:200, align:"left"}, {header:'字典键值', name:'dictValue', index:'a.dict_value', width:200, align:"left"},
{header:'排序号', name:'treeSort', width:63, align:"center", fixed:true}, {header:'排序号', name:'treeSort', width:63, align:"center", fixed:true},

View File

@@ -56,10 +56,10 @@ $('#dataGrid').dataGrid({
searchForm: $("#searchForm"), searchForm: $("#searchForm"),
columnModel: [ columnModel: [
{header:'字典名称', name:'dictName', index:'a.dict_name', width:200, align:"left", frozen:true, formatter: function(val, obj, row, act){ {header:'字典名称', name:'dictName', index:'a.dict_name', width:200, align:"left", frozen:true, formatter: function(val, obj, row, act){
return '<a href="${ctx}/sys/dictType/form?id='+row.id+'" class="btnList" data-title="编辑字典类型">'+(val ? val : row.id)+'</a>'; return '<a href="${ctx}/sys/dictType/form?id='+row.id+'" class="btnList" data-title="编辑字典类型">'+(val||row.id)+'</a>';
}}, }},
{header:'字典类型', name:'dictType', index:'a.dict_type', width:200, align:"left", frozen:true, formatter: function(val, obj, row, act){ {header:'字典类型', name:'dictType', index:'a.dict_type', width:200, align:"left", frozen:true, formatter: function(val, obj, row, act){
return '<a href="${ctx}/sys/dictData/list?dictType='+row.dictType+'" class="btnList" data-title="编辑字典数据">'+(val ? val : row.id)+'</a>'; return '<a href="${ctx}/sys/dictData/list?dictType='+row.dictType+'" class="btnList" data-title="编辑字典数据">'+(val||row.id)+'</a>';
}}, }},
{header:'系统字典', name:'isSys', index:'a.is_sys', width:80, align:"center", formatter: function(val, obj, row, act){ {header:'系统字典', name:'isSys', index:'a.is_sys', width:80, align:"center", formatter: function(val, obj, row, act){
return js.getDictLabel(${@DictUtils.getDictListJson('sys_yes_no')}, val, '未知', true); return js.getDictLabel(${@DictUtils.getDictListJson('sys_yes_no')}, val, '未知', true);

View File

@@ -7,9 +7,6 @@
</div> </div>
<div class="box-tools pull-right"> <div class="box-tools pull-right">
<a href="#" class="btn btn-default" id="btnSearch" title="查询"><i class="fa fa-filter"></i> 查询</a> <a href="#" class="btn btn-default" id="btnSearch" title="查询"><i class="fa fa-filter"></i> 查询</a>
<% if(hasPermi('sys:log:edit')){ %>
<a href="${ctx}/sys/log/form" class="btn btn-default btnTool" title="新增操作日志表"><i class="fa fa-plus"></i> 新增</a>
<% } %>
</div> </div>
</div> </div>
<div class="box-body"> <div class="box-body">
@@ -33,12 +30,6 @@
<#form:select path="logType" dictType="sys_log_type" blankOption="true" class="form-control required " /> <#form:select path="logType" dictType="sys_log_type" blankOption="true" class="form-control required " />
</div> </div>
</div> </div>
<!-- <div class="form-group"> -->
<!-- <label class="control-label">操作账号:</label> -->
<!-- <div class="control-inline"> -->
<!-- <#form:input path="createBy" maxlength="64" class="form-control width-90"/> -->
<!-- </div> -->
<!-- </div> -->
<div class="form-group"> <div class="form-group">
<label class="control-label">操作用户:</label> <label class="control-label">操作用户:</label>
<div class="control-inline width-120"> <div class="control-inline width-120">
@@ -82,24 +73,6 @@
<#form:input path="remoteAddr" maxlength="255" class="form-control width-90"/> <#form:input path="remoteAddr" maxlength="255" class="form-control width-90"/>
</div> </div>
</div> </div>
<!-- <div class="form-group"> -->
<!-- <label class="control-label">服务器IP</label> -->
<!-- <div class="control-inline"> -->
<!-- <#form:input path="serverAddr" maxlength="255" class="form-control width-90"/> -->
<!-- </div> -->
<!-- </div> -->
<!-- <div class="form-group"> -->
<!-- <label class="control-label">设备名称:</label> -->
<!-- <div class="control-inline"> -->
<!-- <#form:input path="deviceName" maxlength="100" class="form-control width-90"/> -->
<!-- </div> -->
<!-- </div> -->
<!-- <div class="form-group"> -->
<!-- <label class="control-label">浏览器名:</label> -->
<!-- <div class="control-inline"> -->
<!-- <#form:input path="browserName" maxlength="100" class="form-control width-90"/> -->
<!-- </div> -->
<!-- </div> -->
<div class="form-group"> <div class="form-group">
<button type="submit" class="btn btn-primary btn-sm">查询</button> <button type="submit" class="btn btn-primary btn-sm">查询</button>
<button type="reset" class="btn btn-default btn-sm">重置</button> <button type="reset" class="btn btn-default btn-sm">重置</button>
@@ -117,7 +90,7 @@ $('#dataGrid').dataGrid({
searchForm: $("#searchForm"), searchForm: $("#searchForm"),
columnModel: [ columnModel: [
{header:'日志标题', name:'logTitle', index:'a.log_title', width:200, align:"left", frozen:true, formatter: function(val, obj, row, act){ {header:'日志标题', name:'logTitle', index:'a.log_title', width:200, align:"left", frozen:true, formatter: function(val, obj, row, act){
return '<a href="${ctx}/sys/log/form?id='+row.id+'" class="btnList" data-title="日志详情">'+(val ? val : row.id)+'</a>'; return '<a href="${ctx}/sys/log/form?id='+row.id+'" class="btnList" data-title="日志详情">'+(val||row.id)+'</a>';
}}, }},
{header:'请求地址', name:'requestUri', index:'a.request_uri', width:260, align:"left", formatter: function(val, obj, row, act){ {header:'请求地址', name:'requestUri', index:'a.request_uri', width:260, align:"left", formatter: function(val, obj, row, act){
return '<span title="['+row.requestMethod+'] '+row.serverAddr+row.requestUri+'">'+ row.requestUri; return '<span title="['+row.requestMethod+'] '+row.serverAddr+row.requestUri+'">'+ row.requestUri;

View File

@@ -64,7 +64,7 @@ $('#dataGrid').dataGrid({
searchForm: $("#searchForm"), searchForm: $("#searchForm"),
columnModel: [ columnModel: [
{header:'机构名称', name:'officeName', index:'a.office_name', width:250, align:"left", frozen:true, formatter: function(val, obj, row, act){ {header:'机构名称', name:'officeName', index:'a.office_name', width:250, align:"left", frozen:true, formatter: function(val, obj, row, act){
return '( '+row.viewCode+' ) '+'<a href="${ctx}/sys/office/form?officeCode='+row.officeCode+'" class="btnList" data-title="编辑机构">'+(val ? val : row.id)+'</a>'; return '( '+row.viewCode+' ) '+'<a href="${ctx}/sys/office/form?officeCode='+row.officeCode+'" class="btnList" data-title="编辑机构">'+(val||row.id)+'</a>';
}}, }},
{header:'机构全称', name:'fullName', index:'a.full_name', width:200, align:"left"}, {header:'机构全称', name:'fullName', index:'a.full_name', width:200, align:"left"},
{header:'排序号', name:'treeSort', index:'a.tree_sort', width:80, align:"center"}, {header:'排序号', name:'treeSort', index:'a.tree_sort', width:80, align:"center"},

View File

@@ -0,0 +1,77 @@
<% layout('/layouts/default.html', {title: '在线用户', libs: ['dataGrid']}){ %>
<div class="main-content">
<div class="box box-main">
<div class="box-header">
<div class="box-title">
<i class="fa icon-social-twitter"></i> 在线用户
</div>
<div class="box-tools pull-right">
<a href="#" class="btn btn-default" id="btnSearch" title="查询"><i class="fa fa-filter"></i> 查询</a>
</div>
</div>
<div class="box-body">
<#form:form id="searchForm" action="${ctx}/sys/online/listData" method="post" class="form-inline hide"
data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
<div class="form-group">
<label class="control-label">操作用户:</label>
<div class="control-inline width-160">
<#form:listselect id="userSelect" title="用户" path="userCode"
url="${ctx}/sys/user/userSelect?userType=" allowClear="false"
checkbox="false" itemCode="userCode" itemName="userName"/>
</div>
</div>
<div class="form-group">
<div class="control-inline" title="包含3分钟以上未操作的用户">&nbsp;
<#form:checkbox name="isAllOnline" value="false" label="查询所有在线"
class="form-control"/>
</div>
</div>
<div class="form-group">
<div class="control-inline" title="包含未登录的用户">
<#form:checkbox name="isVisitor" value="false" label="查询游客用户"
class="form-control"/>
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary btn-sm">查询</button>
<button type="reset" class="btn btn-default btn-sm">重置</button>
</div>
</#form:form>
<table id="dataGrid"></table>
<div id="dataGridPage"></div>
</div>
</div>
</div>
<% } %>
<script>
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
searchForm: $("#searchForm"),
columnModel: [
{header:'用户名称', name:'userName', index:'a.create_by_name', width:100, align:"center", formatter: function(val, obj, row, act){
return '<span title="账号:'+(row.userCode||'')+'">'+(val||'游客');
}},
{header:'创建时间', name:'startTimestamp', width:100, align:'center'},
{header:'最后访问', name:'lastAccessTime', width:100, align:'center'},
{header:'超时时间', name:'timeout', width:100, align:'center'},
{header:'客户主机', name:'host', width:70, align:'center'},
{header:'用户类型', name:'userType', width:50, align:'center', formatter: function(val, obj, row, act){
return js.getDictLabel(${@DictUtils.getDictListJson('sys_user_type')}, val, '未知', true);
}},
{header:'设备类型', name:'deviceType', width:50, align:'center', formatter: function(val, obj, row, act){
return js.getDictLabel(${@DictUtils.getDictListJson('sys_device_type')}, val, 'PC', true);
}}
<% if(hasPermi('sys:online:edit')){ %>
,{header:'操作', name:'actions', width:50, sortable:false, formatter: function(val, obj, row, act){
var actions = [];
actions.push('<a href="${ctx}/sys/online/tickOut?sessionId='+row.id+'" class="btnList" title="踢出在线用户" data-confirm="确认要踢出该用户在线状态吗?"><i class="fa fa-trash-o"></i></a>&nbsp;');
return actions.join('');
}}
<% } %>
],
// 加载成功后执行事件
ajaxSuccess: function(data){
}
});
</script>

View File

@@ -56,7 +56,7 @@ $('#dataGrid').dataGrid({
searchForm: $("#searchForm"), searchForm: $("#searchForm"),
columnModel: [ columnModel: [
{header:'岗位名称', name:'postName', index:'a.post_name', width:200, align:"center", frozen:true, formatter: function(val, obj, row, act){ {header:'岗位名称', name:'postName', index:'a.post_name', width:200, align:"center", frozen:true, formatter: function(val, obj, row, act){
return '<a href="${ctx}/sys/post/form?postCode='+row.postCode+'" class="btnList" data-title="编辑岗位">'+(val ? val : row.id)+'</a>'; return '<a href="${ctx}/sys/post/form?postCode='+row.postCode+'" class="btnList" data-title="编辑岗位">'+(val||row.id)+'</a>';
}}, }},
{header:'岗位编码', name:'postCode', index:'a.post_code', width:200, align:"center"}, {header:'岗位编码', name:'postCode', index:'a.post_code', width:200, align:"center"},
{header:'排序号', name:'postSort', index:'a.post_sort', width:80, align:"center"}, {header:'排序号', name:'postSort', index:'a.post_sort', width:80, align:"center"},

View File

@@ -66,7 +66,7 @@ $('#dataGrid').dataGrid({
searchForm: $("#searchForm"), searchForm: $("#searchForm"),
columnModel: [ columnModel: [
{header:'登录账号', name:'loginCode', index:'a.login_code', width:200, align:"center", frozen:true, formatter: function(val, obj, row, act){ {header:'登录账号', name:'loginCode', index:'a.login_code', width:200, align:"center", frozen:true, formatter: function(val, obj, row, act){
return '<a href="${ctx}/sys/corpAdmin/form?userCode='+row.userCode+'&op=edit" class="btnList" data-title="编辑用户">'+(val ? val : row.id)+'</a>'; return '<a href="${ctx}/sys/corpAdmin/form?userCode='+row.userCode+'&op=edit" class="btnList" data-title="编辑用户">'+(val||row.id)+'</a>';
}}, }},
{header:'用户昵称', name:'userName', index:'a.user_name', width:200, align:"center"}, {header:'用户昵称', name:'userName', index:'a.user_name', width:200, align:"center"},
<% if(@ObjectUtils.toBoolean(@Global.getConfig('user.useCorpModel'))){ %> <% if(@ObjectUtils.toBoolean(@Global.getConfig('user.useCorpModel'))){ %>

View File

@@ -98,7 +98,7 @@ $('#dataGrid').dataGrid({
searchForm: $("#searchForm"), searchForm: $("#searchForm"),
columnModel: [ columnModel: [
{header:'登录账号', name:'loginCode', index:'a.login_code', width:200, align:"center", frozen:true, formatter: function(val, obj, row, act){ {header:'登录账号', name:'loginCode', index:'a.login_code', width:200, align:"center", frozen:true, formatter: function(val, obj, row, act){
return '<a href="${ctx}/sys/empUser/form?userCode='+row.userCode+'&op=edit" class="btnList" data-title="编辑用户">'+(val ? val : row.id)+'</a>'; return '<a href="${ctx}/sys/empUser/form?userCode='+row.userCode+'&op=edit" class="btnList" data-title="编辑用户">'+(val||row.id)+'</a>';
}}, }},
{header:'用户昵称', name:'userName', index:'a.user_name', width:200, align:"center"}, {header:'用户昵称', name:'userName', index:'a.user_name', width:200, align:"center"},
{header:'用户姓名', name:'refName', index:'a.ref_name', width:200, align:"center"}, {header:'用户姓名', name:'refName', index:'a.ref_name', width:200, align:"center"},

View File

@@ -70,7 +70,7 @@ $('#dataGrid').dataGrid({
searchForm: $("#searchForm"), searchForm: $("#searchForm"),
columnModel: [ columnModel: [
{header:'登录账号', name:'loginCode', index:'a.login_code', width:200, align:"center", frozen:true, formatter: function(val, obj, row, act){ {header:'登录账号', name:'loginCode', index:'a.login_code', width:200, align:"center", frozen:true, formatter: function(val, obj, row, act){
return '<a href="${ctx}/sys/secAdmin/form?userCode='+row.userCode+'" class="btnList" data-title="管理数据权限">'+(val ? val : row.id)+'</a>'; return '<a href="${ctx}/sys/secAdmin/form?userCode='+row.userCode+'" class="btnList" data-title="管理数据权限">'+(val||row.id)+'</a>';
}}, }},
{header:'用户昵称', name:'userName', index:'a.user_name', width:200, align:"center"}, {header:'用户昵称', name:'userName', index:'a.user_name', width:200, align:"center"},
{header:'电子邮箱', name:'email', index:'a.email', width:200, align:"center"}, {header:'电子邮箱', name:'email', index:'a.email', width:200, align:"center"},