<%--
  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.apache.commons.lang.StringUtils" %>
<%!
    Pub pub = new Pub();
    public String getDeptName(ConnectionFactory cf,Connection conn,String dept_id){
        StringBuffer sql = new StringBuffer();
        String deptName="";
        sql.append("select t1.dept_name as dept_name_4,t2.dept_name as dept_name_3,t3.dept_name as dept_name_2,t4.dept_name as dept_name_1 from ");
        sql.append("tp_dept t1 left join tp_dept t2 on t1.p_id=t2.id");
        sql.append(" left join tp_dept t3 on t2.p_id=t3.id");
        sql.append(" left join tp_dept t4 on t3.p_id=t4.id");
        sql.append(" where t1.id=?");
        Vector v_list = cf.doQuery(conn, sql.toString(), null, new Object[]{dept_id});
        if(v_list!=null && v_list.size()>0){
            Hashtable ht = (Hashtable) v_list.get(0);
            String dept_name_4 = pub.trimNull((String) ht.get("dept_name_4"));
            String dept_name_3 = pub.trimNull((String) ht.get("dept_name_3"));
            String dept_name_2 = pub.trimNull((String) ht.get("dept_name_2"));
            String dept_name_1 = pub.trimNull((String) ht.get("dept_name_1"));
            if(!"".equals(dept_name_3)){
                deptName=dept_name_3+">"+dept_name_4;
            }else{
                deptName=dept_name_4;
            }
            if(!"".equals(dept_name_2)){
                deptName=dept_name_2+">"+dept_name_3+">"+dept_name_4;
            }
            if(!"".equals(dept_name_1)){
                deptName=dept_name_1+">"+dept_name_2+">"+dept_name_3+">"+dept_name_4;
            }
        }
        return deptName;
    }
%>
<%
    response.setCharacterEncoding("UTF-8");
    request.setCharacterEncoding("UTF-8");
    ConnectionFactory cf = new ConnectionFactory();
    Pub pub = new Pub();
    Connection conn = null;
    Vector v_list = null;
    Hashtable ht =null;
    String zc_status ="";
    String[] field = request.getParameterValues("zc_ids");
    response.setContentType("application/vnd.ms-excel");
    response.setHeader("Content-Disposition", "attachment; filename=" + "excel.xls");
    try {
        conn = com.censoft.db.DBUtil.getConnection();
        String sql="";
        StringBuffer sb = new StringBuffer();
        sb.append("select t1.*,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 ");
        sb.append(" and t1.zc_id in (");
        if(field!=null&&field.length>0){
            for(int i=0;i<field.length;i++){
                if(i==field.length-1){
                    sb.append("'" + field[i] + "'");
                }else{
                    sb.append("'" + field[i] + "',");
                }
            }
        }
        sb.append(" )");
        v_list = cf.doQuery(conn, sb.toString(), null, new Object[]{});
        if (v_list == null) {
            System.out.println("查询出错"+cf.getMsg());
            return;
        }
        if (v_list != null && v_list.size() > 0) {
            ht = (Hashtable) v_list.get(0);
            String bg_time = pub.trimNull((String) ht.get("bg_time"));
            zc_status = pub.trimNull((String) ht.get("zc_status"));
            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="报废";
            }
            if(!"".equals(bg_time)){
                zc_status="变更";
            }
        }
%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache, must-revalidate">
    <meta http-equiv="expires" content="0">
    <title></title>
    <style>
        table th{border:1px solid  black}
        table td{border:1px solid  black;width: 300px;}
    </style>
</head>
<body>
<table style="border-collapse:collapse;border:1px solid  black;">
    <tbody>
        <tr class="text-c">
            <td colspan="6" style="text-align:center;font-weight: bold;width:160px;">资产卡片信息</td>
        </tr>
        <tr class="text-c">
            <td  style="font-weight: bold;width:160px;">资产编号</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("zc_id"))%></td>
            <td  style="font-weight: bold;width:160px;">资产名称</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("zc_name"))%></td>
            <td style="font-weight: bold;width:160px;">所属项目</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("xm_id"))%></td>
        </tr>
        <tr class="text-c">
            <td style="font-weight: bold;width:160px;">资产国标大类</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("zc_gj_type"))%></td>
            <td style="font-weight: bold;width:160px;">资产分类</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("zc_fl"))%></td>
            <td style="font-weight: bold;width:160px;">资产分类代码</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("zc_fl_code"))%></td>
        </tr>
        <tr class="text-c">
            <td style="font-weight: bold;width:160px;">设备类型</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("sb_type"))%></td>
            <td style="font-weight: bold;width:160px;">品牌</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("pinpai"))%></td>
            <td style="font-weight: bold;width:160px;">规格型号</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("gg_type"))%></td>
        </tr>
        <tr class="text-c">
            <td style="font-weight: bold;width:160px;">价值类型</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("jz_type"))%></td>
            <td style="font-weight: bold;width:160px;">价值</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("jiazhi"))%></td>
            <td style="font-weight: bold;width:160px;">价格</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("jiage"))%></td>
        </tr>
        <tr class="text-c">
            <td style="font-weight: bold;width:160px;">管理部门</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("dept"))%></td>
            <td style="font-weight: bold;width:160px;">使用部门</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("ly_dept"))%></td>
            <td style="font-weight: bold;width:160px;">使用人</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("ly_user"))%></td>
        </tr>
        <tr class="text-c">
            <td style="font-weight: bold;width:160px;">资产状态</td>
            <td style="text-align:right;"><%=zc_status%></td>
            <td style="font-weight: bold;width:160px;">领用时间</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("ly_time"))%></td>
            <td style="font-weight: bold;width:160px;">制单时间</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("dept"))%></td>
        </tr>
        <tr class="text-c">
            <td style="font-weight: bold;width:160px;">出厂日期</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("chuchang_date"))%></td>
            <td style="font-weight: bold;width:160px;">财务入账日期</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("cw_date"))%></td>
            <td style="font-weight: bold;width:160px;">会计凭证号</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("kj_id"))%></td>
        </tr>
        <tr class="text-c">
            <td style="font-weight: bold;width:160px;">财政性资金</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("czx_money"))%></td>
            <td style="font-weight: bold;width:160px;">非财政性资金</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("fczx_money"))%></td>
            <td style="font-weight: bold;width:160px;">累计折旧</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("ljzj"))%></td>
        </tr>
        <tr class="text-c">
            <td style="font-weight: bold;width:160px;">净值</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("jingzhi"))%></td>
            <td style="font-weight: bold;width:160px;">已提月折旧</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("ytyzj"))%></td>
            <td style="font-weight: bold;width:160px;">是否利旧</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("is_lj"))%></td>
        </tr>
        <tr class="text-c">
            <td style="font-weight: bold;width:160px;">车辆识别号</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("car_id"))%></td>
            <td style="font-weight: bold;width:160px;">车辆用途分类</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("car_type"))%></td>
            <td style="font-weight: bold;width:160px;">发动机号</td>
            <td style="text-align:right;"><%=pub.trimNull((String) ht.get("car_fdj_id"))%></td>
        </tr>
        <tr class="text-c">
            <td style="font-weight: bold;width:160px;">存放地</td>
            <td colspan="5" style="text-align:right;"><%=pub.trimNull((String) ht.get("car_address"))%></td>
        </tr>
        <tr class="text-c">
            <td style="font-weight: bold;width:160px;">备注</td>
            <td colspan="5" style="text-align:right;"><%=pub.trimNull((String) ht.get("beizhu"))%></td>
        </tr>
    </tbody>
</table>
</body>
</html>

<%
    } catch (Exception e) {
        out.println("查询信息异常" + e);
        return;
    } finally {
        if (conn != null) {
            try {
                conn.close();
            } catch (Exception e) {
            }
        }
    }
    out.close();
%>