<%--
  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 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 zc_resource_s = pub.trimNull(request.getParameter("zc_resource"));
    String zc_status_s = pub.trimNull(request.getParameter("zc_status"));
    String b_time = pub.trimNull(request.getParameter("b_time"));
    String e_time = pub.trimNull(request.getParameter("e_time"));
    if ("".equals(page_size)) page_size = "10";
    List list_s = new ArrayList();
    try {
        StringBuffer sb = new StringBuffer();
        sb.append("select distinct reg_id,zc_name,zc_gj_type,zc_fl,zc_resource,jz_type,counts,jiazhi,jiage,cw_date,add_time from zc_register where 1=1 ");
        if(!"".equals(zc_name_s)){
            sb.append(" and zc_name like ?");
            list_s.add("%"+zc_name_s+"%");
        }if(!"".equals(zc_gj_type_s)){
            sb.append(" and zc_gj_type = ?");
            list_s.add(zc_gj_type_s);
        }if(!"".equals(zc_fl_s)){
            sb.append(" and zc_fl = ?");
            list_s.add(zc_fl_s);
        }if(!"".equals(zc_resource_s)){
            sb.append(" and zc_resource like ?");
            list_s.add("%"+zc_resource_s+"%");
        }if(!"".equals(zc_status_s)){
            sb.append(" and zc_status = ?");
            list_s.add(zc_status_s);
        }if(!"".equals(b_time)){
            sb.append(" and cw_date >= ?");
            list_s.add(b_time);
        }if(!"".equals(e_time)){
            sb.append(" and cw_date <= ?");
            list_s.add(e_time);
        }
        sb.append(" order by add_time desc");
        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"));
    String pageCnt = pub.trimNull((String) ht_row.get("PAGECOUNT"));
    String telSegmentUrl="./list_add-t.jsp";
%>
<div>
    <a class="btn btn-primary radius" onclick="addRules('资产登记','<%=telSegmentUrl%>');" >
        资产登记
    </a>
    <a class="btn btn-primary radius" onclick="addMostRules('资产登记');" >
        批量登记
    </a>
</div>
<div class="table-list">
    <table class="table  table-hover table-bg">
        <thead>
        <tr class="text-c">
            <th width="120px">资产名称</th>
            <th width="50px">国标大类</th>
            <th width="120px">资产分类</th>
            <th width="50px">资产来源</th>
            <th width="50px">价值</th>
            <th width="50px">数量</th>
            <%--<th width="50px">剩余</th>--%>
            <th width="50px">总价值</th>
            <th width="50px">财务入账日期</th>
            <th width="50px">操作</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 reg_id = pub.trimNull((String) ht.get("reg_id"));
                        String zc_name = pub.trimNull((String) ht.get("zc_name"));
                        String zc_resource = pub.trimNull((String) ht.get("zc_resource"));
                        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 counts = pub.trimNull((String) ht.get("counts"));
                        String jiage = pub.trimNull((String) ht.get("jiazhi"));
                        int total=0;
                        //int shengyu=getCounts(cf,conn,reg_id);
                        if(!"".equals(counts)&&!"".equals(jiage)){
                            total=Integer.parseInt(counts)*Integer.parseInt(jiage);
                        }
                        String cw_date = pub.trimNull((String) ht.get("cw_date"));
                        %>
                        <tr <%if(i%2==0){%>id="tr_doub"<%}else{%>id="tr_single"<%}%> class="text-c">
                            <td><%=zc_name%>
                            </td>
                            <td><%=zc_gj_type%>
                            </td>
                            <td><%=zc_fl%>
                            </td>
                            <td><%=zc_resource%>
                            </td>
                            <td><%=jiage%>
                            </td>
                            <td><%=counts%>
                            </td>
                            <%--<td><%=shengyu%>
                            </td>--%>
                            <td><%=total%>
                            </td>
                            <td><%=cw_date%>
                            </td>
                            <td>
                                <a title="修改" href="javascript:void(0);" onclick="updateById('<%=reg_id%>');" class="ml-5" >
                                    <i class="Hui-iconfont">修改</i>
                                </a>
                                <a title="删除" href="javascript:void(0);" onclick="deleteById('<%=reg_id%>');" class="ml-5" >
                                    <i class="Hui-iconfont">删除</i>
                                </a>
                            </td>
                        </tr>
                        <%
                    }
            }
        %>
        </tbody>
    </table>
</div>
<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>
<%
    } catch (Exception e) {
        out.println("查询异常" + e);
        return;
    } finally {
        if (conn != null) {
            try {
                conn.close();
            } catch (Exception e) {
            }
        }
    }
%>