<%--
  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="java.text.*" %>
<%@ page import="com.censoft.common.db.ConnectionFactory" %>
<%@ page import="com.censoft.common.base.Pub" %>
<%
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
	DateFormat df = new SimpleDateFormat("yyyyMMdd");
    Date sys_date = new Date();
    String code = String.valueOf(sys_date.getTime());//条形码内容
	//code=code+"_1";
    ConnectionFactory cf = new ConnectionFactory();
    Pub pub = new Pub();
    Connection conn = null;
    Vector v_list = null;
    Hashtable ht =null;
    String zc_status ="";
    List list = new ArrayList();
    String[] field = request.getParameterValues("zc_ids");
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
    String fileName = sdf.format(new Date()) + ".doc";
    // 文件路径
    String filePath = fileName;
    String zc_name ="";
    String gg_type ="";
    String ly_dept ="";
    String ly_user ="";
	String regex="[\u4e00-\u9fa5]";
    try {
        conn = com.censoft.db.DBUtil.getConnection();
        StringBuffer sb = new StringBuffer();
        sb.append("select t1.zc_name,t1.gg_type,t2.xm_id,t2.ly_dept,t2.ly_user,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(" )");
		code=field[0].replace("_","").replaceAll(regex,"");
        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);
            zc_name=pub.trimNull((String) ht.get("zc_name"));
            gg_type=pub.trimNull((String) ht.get("gg_type"));
            ly_dept=pub.trimNull((String) ht.get("ly_dept"));
            ly_user=pub.trimNull((String) ht.get("ly_user"));
        }
%>
<!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>
    <script type="text/javascript" src="./js/jquery-1.11.0.min.js"></script>
    <script type="text/javascript" src="./js/FileSaver.js"></script>
    <script type="text/javascript" src="./js/jquery.wordexport.js"></script>
</head>
<body >
    <div id="wordExportDiv">
        <div style="width:400px;height:30px;line-height: 30px;font-size: 20px;margin: 0 auto;text-align: center;">
            北&nbsp;&nbsp;京&nbsp;&nbsp;市&nbsp;&nbsp;专&nbsp;&nbsp;用&nbsp;&nbsp;通&nbsp;&nbsp;信&nbsp;&nbsp;局
        </div>
        <div style="width:300px;height:30px;line-height: 30px;font-size: 18px;margin: 0 auto;text-align: left;padding-left:50px;margin-top: 20px;">
            资产名称：<%=zc_name%>
        </div>
        <div style="width:300px;height:30px;line-height: 30px;font-size: 18px;margin: 0 auto;text-align: left;padding-left:50px;">
            规格型号：<%=gg_type%>
        </div>
        <div style="width:300px;height:30px;line-height: 30px;font-size: 18px;margin: 0 auto;text-align: left;padding-left:50px;">
            使用部门：<%=ly_dept%>
        </div>
        <div style="width:300px;height:30px;line-height: 30px;font-size: 18px;margin: 0 auto;text-align: left;padding-left:50px;">
            使用人：<%=ly_user%>
        </div>
        <div style="width:300px;margin: 0 auto;text-align: center;">
           <img src="/zcgl/barcode?msg=<%=code%>&type=code128"/>
        </div>
    </div>
	
    <!--<button class="btn btn-primary" id="word_export" onclick="wordExport()">word导出</button>-->
</body>
</html>
<script>
    function wordExport() {
        $("#wordExportDiv").wordExport('生成word文档');
    }
	function dayin(){
		window.print();
	}
	function quxiao(){
	
	}
</script>
<%
    } catch (Exception e) {
        out.println("查询角色信息异常" + e);
        return;
    } finally {
        if (conn != null) {
            try {
                conn.close();
            } catch (Exception e) {
            }
        }
    }
%>