Browse Source

日志管理

git-svn-id: https://192.168.57.71/svn/jsgkj@1753 931142cf-59ea-a443-aa0e-51397b428577
ld_zhouk 8 years ago
parent
commit
cea42e019a

+ 65 - 0
gkaqv2/trunk/modules/web/src/main/java/com/xt/js/gkaq/web/ctl/frame/SysLogCtl.java

@@ -0,0 +1,65 @@
+package com.xt.js.gkaq.web.ctl.frame;
+
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.xt.js.gkaq.common.BaseCtl;
+import com.xt.js.gkaq.common.log.annotation.SysLog;
+import com.xt.js.gkaq.frame.model.SysLogModel;
+import com.xt.js.gkaq.frame.service.SysLogService;
+import com.xt.js.gkaq.web.vo.SysLogVo;
+import com.yuanxd.tools.pagehelper.PageHelper;
+import com.yuanxd.tools.pagehelper.PageInfo;
+
+/**
+ * 系统日志管理控制
+ */
+@Controller
+@RequestMapping(value = "/syslog", produces = "application/json; charset=utf-8")
+public class SysLogCtl extends BaseCtl {
+    @Autowired
+    private SysLogService syslogService;
+
+    /**
+     * 进入首页
+     * 
+     * @param model
+     * @return
+     */
+    @RequestMapping("")
+    public String index(Model model) {
+        return "frame/syslog";
+    }
+
+    /**
+     * 初始化页面加载数据
+     * 
+     * @param vo
+     * @return
+     * @throws UnsupportedEncodingException
+     */
+    @RequestMapping("list")
+    @ResponseBody
+    @SysLog(description="日志列表查询")
+    public PageInfo<SysLogModel> getPageInfo(SysLogVo vo) {
+        // 初始化参数
+        PageHelper.startPage(vo.getcPage(), vo.getpSize());
+
+        SysLogModel model = new SysLogModel();
+        model.setLogType(vo.getLogType());
+        // 开始时间
+        model.setCreateTime(vo.getBeginTime());
+        // 结束时间
+        model.setUpdateTime(vo.getEndTime());
+        List<SysLogModel> list = syslogService.findAllByCond(model);
+        PageInfo<SysLogModel> pageResult = new PageInfo<>(list);
+        return pageResult;
+    }
+
+}

+ 82 - 0
gkaqv2/trunk/modules/web/src/main/java/com/xt/js/gkaq/web/vo/SysLogVo.java

@@ -0,0 +1,82 @@
+package com.xt.js.gkaq.web.vo;
+
+import java.util.Date;
+
+import org.springframework.format.annotation.DateTimeFormat;
+
+import com.xt.js.gkaq.common.BaseVo;
+
+public class SysLogVo extends BaseVo {
+
+    private String logType;
+
+    private String logPath;
+
+    private String logParam;
+
+    private String logMsg;
+
+    private String clientIp;
+
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date beginTime;
+
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date endTime;
+
+    public String getLogType() {
+        return logType;
+    }
+
+    public void setLogType(String logType) {
+        this.logType = logType;
+    }
+
+    public String getLogPath() {
+        return logPath;
+    }
+
+    public void setLogPath(String logPath) {
+        this.logPath = logPath;
+    }
+
+    public String getLogParam() {
+        return logParam;
+    }
+
+    public void setLogParam(String logParam) {
+        this.logParam = logParam;
+    }
+
+    public String getLogMsg() {
+        return logMsg;
+    }
+
+    public void setLogMsg(String logMsg) {
+        this.logMsg = logMsg;
+    }
+
+    public String getClientIp() {
+        return clientIp;
+    }
+
+    public void setClientIp(String clientIp) {
+        this.clientIp = clientIp;
+    }
+
+    public Date getBeginTime() {
+        return beginTime;
+    }
+
+    public void setBeginTime(Date beginTime) {
+        this.beginTime = beginTime;
+    }
+
+    public Date getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(Date endTime) {
+        this.endTime = endTime;
+    }
+}

+ 59 - 0
gkaqv2/trunk/modules/web/src/main/webapp/WEB-INF/view/frame/syslog.jsp

@@ -0,0 +1,59 @@
+<%@ page language="java" contentType="text/html;charset=GBK" pageEncoding="GBK"%>
+<!DOCTYPE html>
+<html>
+<head>
+<title>日志管理</title>
+
+<%@ include file="../layouts/header.jsp"%>
+<script src="<%=base%>/static/js/frame/syslog.js"></script>
+</head>
+<body class="p_body">
+    <div class="p_all">
+        <div class="p_headdiv">
+            <div class="p_headnav">
+                <img class="p_headnavimg" onclick="gotoHome()" src="<%=base%>/static/images/list/home.png" />
+            </div>
+            <div class="p_headblock">
+                <div class="p_headleft">系统设置 > 日志管理</div>
+            </div>
+        </div>
+        <div class="p_block">
+            <div class="p_fucdiv">
+                <div class="p_titlediv">
+                    <div class="p_titlename">日志管理</div>
+                    <div id="totalRecord" class="p_titlerecord">共0条记录</div>
+                </div>
+                <div class="p_buttondiv">
+                    <div class="p_buttonbg">
+                        <img class="p_buttonimg" src="<%=base%>/static/images/list/search.png" onclick="showSearch()"
+                            title="查询" />
+                    </div>
+                </div>
+            </div>
+            <div class="p_searchdiv">
+                <table class="tabsearch">
+                    <tr class="trsearch">
+                        <td class="tdname">日志类型</td>
+                        <td class="tdcontent"><select class="selectpicker form-control" data-width="200px"
+                            id="srh_logType" name="srh_logType">
+                                <option value="" selected="selected">请选择...</option>
+                        </select></td>
+                        <td class="tdname">日志时间</td>
+                        <td class="tdcontent" style="width:400px"><input type="text" id="srh_begin" name="srh_begin" class="p_txt"> ~
+                            <input type="text" id="srh_end" name="srh_end" class="p_txt"></td>
+                        <td class="tdname"><img class="p_searchbtn"
+                            src="<%=base%>/static/images/list/btn_query.png" title="查询" onclick="searchRecord()" />
+                        </td>
+                    </tr>
+                </table>
+            </div>
+            <div class="container page-content">
+                <!--  列表部分 -->
+                <table grid-manager="grid-table" id="grid-table"></table>
+            </div>
+        </div>
+        <%@ include file="../layouts/footer.jsp"%>
+    </div>
+
+</body>
+</html>

+ 31 - 0
gkaqv2/trunk/modules/web/src/main/webapp/static/js/common/common.js

@@ -246,6 +246,31 @@ function multFmtData(data) {
     return fmtData;
 }
 
+// 对Date的扩展,将 Date 转化为指定格式的String
+// 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符,
+// 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
+// 例子:
+// (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
+// (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18
+Date.prototype.Format = function(fmt) { // author: meizz
+    var o = {
+        "M+" : this.getMonth() + 1, // 月份
+        "d+" : this.getDate(), // 日
+        "h+" : this.getHours(), // 小时
+        "m+" : this.getMinutes(), // 分
+        "s+" : this.getSeconds(), // 秒
+        "q+" : Math.floor((this.getMonth() + 3) / 3), // 季度
+        "S" : this.getMilliseconds()
+    // 毫秒
+    };
+    if (/(y+)/.test(fmt))
+        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
+    for ( var k in o)
+        if (new RegExp("(" + k + ")").test(fmt))
+            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
+    return fmt;
+}
+
 if (typeof constData == "undefined") {
     var constData = {};
     // 人员类型
@@ -261,6 +286,12 @@ if (typeof constData == "undefined") {
     constData.orgType_4 = "站所";
     constData.orgType_8 = "企业";
     constData.orgType_9 = "科室";
+    // 日志类型
+    constData.logType_0 = "普通";
+    constData.logType_1 = "异常";
+    constData.logType_2 = "业务";
+    constData.logType_3 = "登入";
+    constData.logType_4 = "登出";
 }
 
 (function($) {

+ 101 - 0
gkaqv2/trunk/modules/web/src/main/webapp/static/js/frame/syslog.js

@@ -0,0 +1,101 @@
+var grid_selector = "#grid-table";
+
+$(document).ready(function() {
+    logTypeSelect();
+    $("#srh_begin").datetimepicker({
+        format:"Y-m-d H:i:s"
+    });
+    $("#srh_end").datetimepicker({
+        format:"Y-m-d H:i:s"
+    });
+    initGrid();
+});
+
+/**
+ * 初始化Grid
+ */
+function initGrid() {
+    //单列表简易渲染
+    var table = $(grid_selector);
+    table.GM({
+        ajax_url: basePath + '/syslog/list'
+        ,ajax_type: 'POST'
+        ,columnData: [
+            {
+                key: 'logType',
+                text: '日志类型',
+                template: function(operation, rowObject) {
+                    var val = eval('constData.logType_' + operation);
+                    if (isNull(val)) {
+                        val = operation;
+                    }
+                    return val;
+                }
+            },{
+                key: 'logPath',
+                text: '日志路径'
+            },{
+                key: 'logParam',
+                text: '日志参数'
+            },{
+                key: 'logMsg',
+                text: '日志消息'
+            },{
+                key: 'clientIp',
+                text: '客户端IP'
+            },{
+                key: 'createTime',
+                text: '日志时间',
+                template: function(operation, rowObject) {
+                    var val = new Date(operation);
+                    return val.Format("yyyy-MM-dd hh:mm:ss");
+                }
+            },{
+                key: 'createUser',
+                text: '操作人'
+            }
+        ]
+        ,pagingBefore:function(query){}
+        ,pagingAfter: function(query){}
+        ,sortingBefore:function(query){}
+        ,sortingAfter: function(query){}
+        ,ajax_beforeSend: function(query){}
+        ,ajax_complete: function(data){
+            showTotalRecord(data);
+        }
+    },function(query){
+//        console.log('init方法回调query参数', query);
+    });
+};
+
+/**
+ * 查询
+ */
+function searchRecord() {
+    var srh_logType = $("#srh_logType").val();
+    var srh_begin = $("#srh_begin").val();
+    var srh_end = $("#srh_end").val();
+
+    // 定义查询参数
+    var obj = {
+        'logType': srh_logType,
+        'beginTime': srh_begin,
+        'endTime': srh_end,
+    };
+    // 设置gird参数
+    $(grid_selector).GM('setQuery', obj);
+    // 查询grid
+    $(grid_selector).GM('refreshGrid', true, null);
+};
+
+//加载日志类型下拉框选项
+function logTypeSelect() {
+    $.ajax({
+        type : "post",
+        url : basePath + '/dict/findDicts?pcode=LOG_TYPE',
+        success : function(data) {
+            loadComboBox(data, "#srh_logType");
+            $('#srh_logType').selectpicker('refresh');
+        }
+    });
+}