<%--
  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" %>
<%@ page import="org.omg.CosCollection.IteratorInBetween" %>
<%!
    Pub pub = new Pub();
    public int getCounts(ConnectionFactory cf,Connection conn,String id){
        Vector list = cf.doQuery(conn,"select * from zc_register where zc_status='0' and reg_id=?",null,new Object[]{id});
        if(list==null){
            System.out.println("查询出错"+cf.getMsg());
        }
        return list.size();
    }
%>
<%
    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"));
    String xm_id_s = pub.trimNull(request.getParameter("xm_id"));
    String zc_id_s = pub.trimNull(request.getParameter("zc_id"));
    String ly_dept_s = pub.trimNull(request.getParameter("ly_dept"));
    String ly_user_s = pub.trimNull(request.getParameter("ly_user"));
    String zc_name_s = pub.trimNull(request.getParameter("zc_name"));
    String zc_gj_type_s = pub.trimNull(request.getParameter("zc_gj_type"));
    String zc_fl_s = pub.trimNull(request.getParameter("zc_fl"));
    String jz_type_s = pub.trimNull(request.getParameter("jz_type"));
    String zc_status_s = pub.trimNull(request.getParameter("zc_status"));
    String cw_b_time = pub.trimNull(request.getParameter("cw_b_time"));
    String cw_e_time = pub.trimNull(request.getParameter("cw_e_time"));
    String ly_b_time = pub.trimNull(request.getParameter("ly_b_time"));
    String ly_e_time = pub.trimNull(request.getParameter("ly_e_time"));
    if ("".equals(page_size)) page_size = "5";
    List list_s = new ArrayList();
    try {
        StringBuffer sb = new StringBuffer();
        sb.append("select t1.*,t2.ly_id,t2.xm_id,t2.ly_dept,t2.ly_user,t2.bg_time,t2.ly_time from zc_register t1 left join zc_ly t2 on t1.zc_id=t2.zc_id where 1=1 ");
        if(!"".equals(zc_name_s)){
            sb.append(" and t1.zc_name like ?");
            list_s.add("%"+zc_name_s+"%");
        }if(!"".equals(zc_gj_type_s)){
            sb.append(" and t1.zc_gj_type = ?");
            list_s.add(zc_gj_type_s);
        }if(!"".equals(zc_fl_s)){
            sb.append(" and t1.zc_fl = ?");
            list_s.add(zc_fl_s);
        }if(!"".equals(jz_type_s)){
            sb.append(" and t1.jz_type = ?");
            list_s.add(jz_type_s);
        }if(!"".equals(zc_status_s)){
            sb.append(" and t1.zc_status = ?");
            list_s.add(zc_status_s);
        }if(!"".equals(cw_b_time)){
            sb.append(" and t1.cw_date >= ?");
            list_s.add(cw_b_time);
        }if(!"".equals(cw_e_time)){
            sb.append(" and t1.cw_date <= ?");
            list_s.add(cw_e_time);
        }if(!"".equals(xm_id_s)){
            sb.append(" and t2.xm_id = ?");
            list_s.add(xm_id_s);
        }if(!"".equals(zc_id_s)){
            sb.append(" and t1.zc_id like ?");
            list_s.add("%"+zc_id_s+"%");
        }if(!"".equals(ly_dept_s)){
            sb.append(" and t2.ly_dept like ?");
            list_s.add("%"+ly_dept_s+"%");
        }if(!"".equals(ly_user_s)){
            sb.append(" and t2.ly_user like ?");
            list_s.add("%"+ly_user_s+"%");
        }if(!"".equals(ly_b_time)){
            sb.append(" and t2.add_time <= ?");
            list_s.add(ly_b_time);
        }if(!"".equals(ly_e_time)){
            sb.append(" and t2.add_time <= ?");
            list_s.add(ly_e_time);
        }
        sb.append(" order by t2.ly_time desc");
		System.out.println("sb="+sb.toString());
        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;
        }

        Hashtable ht_row = (Hashtable) v_list.get(0);
        String rowCnt = pub.trimNull((String) ht_row.get("ROWCOUNT"));
%>
<style>

    .listext th{background:#eee;color:#3366cc;}
    .listext th,.listext td{border:solid 1px #ddd;text-align:left;padding:10px;}
    .rc-handle-container{position:relative;}
    .rc-handle{width:10px;position:absolute;width:7px;cursor:ew-resize;cursor:pointer;margin-left:-3px;}
    table{table-layout: fixed;overflow:hidden;width:100%;}
    table td{white-space:nowrap;overflow:hidden;text-overflow: ellipsis;nowrap:false}
    *{
        word-break:normal;
        word-wrap:normal;
    }

    .table-hover tbody tr:hover td, .table-hover tbody tr:hover th {
        background-color: #D1D1D1;
    }
</style>
<div class="mt-5">
    <a class="btn btn-primary " onclick="openDiv();">
        导出</a>
</div>
<form  method="post" id="form1" name="form1" action="export_query.jsp" >
    <div class="table-list" style="height:350px;overflow-x:auto;">
        <table id="table1" class="listext table table-border table-bordered table-hover table-bg table-sort">
            <thead>
            <tr class="text-c">
                <th width="30">
                    <input id="checkboxAll" type="checkbox" onclick="checkAll(this);"></input>
                </th>
                <th>所属项目</th>
                <th>资产编号</th>
                <th>资产名称</th>
                <th>资产分类</th>
                <th>国标大类</th>
                <th>价值类型</th>
                <th>价值</th>
                <th>使用部门</th>
                <th>使用人</th>
                <th>资产状态</th>
                <th>领用时间</th>
                <th width="100">入账日期</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 zc_name = pub.trimNull((String) ht.get("zc_name"));
                        String ly_id = pub.trimNull((String) ht.get("ly_id"));
                        String xm_id = pub.trimNull((String) ht.get("xm_id"));
                        String zc_id = pub.trimNull((String) ht.get("zc_id"));
                        String ly_dept = pub.trimNull((String) ht.get("ly_dept"));
                        String ly_user = pub.trimNull((String) ht.get("ly_user"));
                        String ly_time = pub.trimNull((String) ht.get("ly_time"));
                        String zc_gj_type = pub.trimNull((String) ht.get("zc_gj_type"));
                        String zc_fl = pub.trimNull((String) ht.get("zc_fl"));
                        String jz_type = pub.trimNull((String) ht.get("jz_type"));
                        String jiage = pub.trimNull((String) ht.get("jiazhi"));
                        String cw_date = pub.trimNull((String) ht.get("cw_date"));
                        String bg_time = pub.trimNull((String) ht.get("bg_time"));
                        String zc_status = pub.trimNull((String) ht.get("zc_status"));
                        //zc_status:0:未提交、闲置，1：已提交 2：审批中 3：已完结 4：盘点中
                        if("0".equals(zc_status)){
                            zc_status="闲置";
                        }else if("3".equals(zc_status)){
                            zc_status="已领用";
                        }else if("1".equals(zc_status)){
                            zc_status="已提交";
                        }else if("2".equals(zc_status)){
                            zc_status="审核中";
                        }else if("4".equals(zc_status)){
                            zc_status="盘点中";
                        }else if("4_1".equals(zc_status)){
                            zc_status="盘点结束";
                        }else if("5".equals(zc_status)){
                            zc_status="维修中";
                        }else if("6".equals(zc_status)){
                            zc_status="报废";
                        }else if("7".equals(zc_status)){
                            zc_status="审核不通过";
                        }
                        if(!"".equals(bg_time)){
                            zc_status="变更";
                        }
            %>
            <tr <%if(i%2==0){%>id="tr_doub"<%}else{%>id="tr_single"<%}%> class="text-c" >
                <td >
                    <input type="checkbox" class="info" id="zc_ids"
                           name="zc_ids" value="<%=zc_id%>" />
                </td>
                <td title="<%=xm_id%>" onclick="openZcInfo('<%=ly_id%>','<%=zc_id%>');" style="cursor: pointer;">
                    <%=xm_id%>
                </td>
                <td title="<%=zc_id%>" onclick="openZcInfo('<%=ly_id%>','<%=zc_id%>');" style="cursor: pointer;"><%=zc_id%>
                </td>
                <td title="<%=zc_name%>" onclick="openZcInfo('<%=ly_id%>','<%=zc_id%>');" style="cursor: pointer;" ><%=zc_name%>
                </td>
                <td title="<%=zc_fl%>"><%=zc_fl%>
                </td>
                <td title="<%=zc_gj_type%>"><%=zc_gj_type%>
                </td>
                <td title="<%=jz_type%>"><%=jz_type%>
                </td>
                <td title="<%=jiage%>"><%=jiage%>
                </td>
                <td title="<%=ly_dept%>"><%=ly_dept%>
                </td>
                <td title="<%=ly_user%>"><%=ly_user%>
                </td>
                <td title="<%=zc_status%>"><%=zc_status%>
                </td>
                <td title="<%=ly_time%>"><%=ly_time%>
                </td>
                <td title="<%=cw_date%>"><%=cw_date%>
                </td>
            </tr>
            <%
                    }
                }
            %>
            </tbody>
        </table>
    </div>
</form>
<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>
<script type="text/javascript">
    var checkAll = function (checkbox) {
        $(".info").prop("checked", checkbox.checked);
    }
    $(function(){
        $("#table1").resizableColumns({});
    });
</script>
<%
    } catch (Exception e) {
        out.println("查询异常" + e);
        return;
    } finally {
        if (conn != null) {
            try {
                conn.close();
            } catch (Exception e) {
            }
        }
    }
%>