<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/9/11
  Time: 12:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.util.*" %>
<%@ page import="com.censoft.common.db.ConnectionFactory" %>
<%@ page import="com.censoft.common.base.Pub" %>
<%
    ConnectionFactory cf = new ConnectionFactory();
    Pub pub = new Pub();
    Connection conn = null;
    Vector v_list = null;
    String page_number = pub.trimNull(request.getParameter("page_number"));
    if ("".equals(page_number)) page_number = "1";
    String page_size = pub.trimNull(request.getParameter("page_size"));
    if ("".equals(page_size)) page_size = "10";
    List list_s = new ArrayList();
    StringBuffer sb = new StringBuffer();
    sb.append("select t1.*,t2.login_name,t3.user_name as name1,t4.user_name as name2 from t_book_log t1 left join t_book_admin t2  on t2.login_id=t1.add_user " +
            " left join zb_user t3  on t3.id=t1.add_user left join zb_bgs_user t4  on t4.id=t1.add_user where 1=1 ");
    String s_login_name = pub.trimNull(request.getParameter("s_login_name"));
    if (!"".equals(s_login_name)) {
        sb.append(" and （t2.login_name like ? or t3.user_name like ? or t4.user_name like ?)");
        list_s.add("%" + s_login_name + "%");
        list_s.add("%" + s_login_name + "%");
        list_s.add("%" + s_login_name + "%");
    }
    String s_action = pub.trimNull(request.getParameter("s_action"));
    if (!"".equals(s_action)) {
        sb.append(" and t1.action like ? ");
        list_s.add("%" + s_action + "%");
    }
    String s_model = pub.trimNull(request.getParameter("s_model"));
    if (!"".equals(s_model)) {
        sb.append(" and t1.model like ? ");
        list_s.add("%" + s_model + "%");
    }
    String b_time = pub.trimNull(request.getParameter("b_time"));
    if (!"".equals(b_time)) {
        sb.append(" and t1.add_time >= ? ");
        list_s.add(b_time + " 00:00:01");
    }
    String e_time = pub.trimNull(request.getParameter("e_time"));
    if (!"".equals(e_time)) {
        sb.append(" and t1.add_time <= ? ");
        list_s.add(e_time + " 23:59:59");
    }
    sb.append("  order by t1.add_time desc");
    try {
        conn = com.censoft.db.DBUtil.getConnection();
        v_list = cf.doPageQueryWithCount(conn, sb.toString(), page_number, page_size, null, list_s.toArray());
        if (v_list == null) {
            out.println("查询日志出错" + cf.getMsg());
            return;
        }
    } catch (Exception e) {
        out.println("查询日志出错异常" + e);
        return;
    } finally {
        if (conn != null) {
            try {
                conn.close();
            } catch (Exception e) {
            }
        }
    }
    Hashtable ht_row = (Hashtable) v_list.get(0);
    String rowCnt = pub.trimNull((String) ht_row.get("ROWCOUNT"));
    String pageCnt = pub.trimNull((String) ht_row.get("PAGECOUNT"));
%>
<table class="table table-border table-bordered table-hover table-bg table-sort">
    <thead>
    <tr class="text-c">
        <th width="30px">序号</th>
        <th width="100px">操作人</th>
        <th width="100px">动作</th>
        <th width="150px">模块</th>
        <th width="130px">操作时间</th>
        <th width="120px">IP</th>
        <th >内容</th>
    </tr>
    </thead>
    <tbody>
    <%
        if (v_list != null && v_list.size() > 0) {
            for (int i = 1; i < v_list.size(); i++) {
                Hashtable ht = (Hashtable) v_list.get(i);
                String login_name = pub.trimNull((String) ht.get("login_name"));
                String name1 = pub.trimNull((String) ht.get("name1"));
                String name2 = pub.trimNull((String) ht.get("name2"));
                if(!"".equals(name1)){
                    login_name=name1;
                }
                if(!"".equals(name2)){
                    login_name=name2;
                }
                String action = pub.trimNull((String) ht.get("action"));
                String model = pub.trimNull((String) ht.get("model"));
                String add_time = pub.trimNull((String) ht.get("add_time"));
                String content = pub.trimNull((String) ht.get("content"));
                String ip = pub.trimNull((String) ht.get("ip"));
                String yw_id = pub.trimNull((String) ht.get("yw_id"));
    %>
    <tr class="text-c">
        <td><%=i%>
        </td>
        <td><%=login_name%>
        </td>
        <td><%=action%>
        </td>
        <td><%=model%>
        </td>
        <td><%=add_time%>
        </td>
        <td class="td-status">
            <%=ip%>
        </td>
        <td class="td-manage" title="<%=content%>" style="overflow: hidden;text-overflow:ellipsis;white-space: nowrap;">
            业务ID：<%=yw_id%>,<%=content%>
        </td>
    </tr>
    <%
            }
        }
    %>
    </tbody>
</table>
<jsp:include page="../common/page_ajax.jsp" >
    <jsp:param name="page_number" value="<%=page_number%>" />
    <jsp:param name="rowCnt" value="<%=rowCnt%>" />
    <jsp:param name="page_size" value="<%=page_size%>" />
</jsp:include>