<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="weaver.general.*" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="java.util.*" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="com.api.doc.detail.util.DocDownloadCheckUtil" %>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="bb" class="weaver.general.BaseBean" />
<%
    List<Map<String,String>> dataList = new ArrayList<Map<String,String>>();

    String sql =" select top 20 * from uf_jfwp where sl > 0 order by jfs asc,sl asc " ;
    bb.writeLog("sql:"+sql);
    rs.executeQuery(sql);
    while (rs.next()){
        Map<String,String> dataMap = new HashMap<>();

        String id = Util.null2String(rs.getString("id"));
        String wpmc = Util.null2String(rs.getString("wpmc"));
        String jfs = Util.null2String(rs.getString("jfs"));
        String sl = Util.null2o(rs.getString("sl"));
        String wptpid = Util.null2o(rs.getString("wptp"));
        int imagefileid = 0;
        if(wptpid != null && !"".equals(wptpid)){
            imagefileid = getImagefielid(wptpid);
            String fileid = DocDownloadCheckUtil.checkPermission(String.valueOf(imagefileid),null);
            String imageurl = "/weaver/weaver.file.FileDownload?fileid="+ fileid ;
            dataMap.put("imageurl",imageurl);
        }
        dataMap.put("wpid",wptpid);
        dataMap.put("wpmc",wpmc);
        dataMap.put("jfs",jfs);
        dataMap.put("sl",sl);

        dataList.add(dataMap);
    }
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("data",dataList);

    out.print(jsonObject.toString());
%>

<%!
    public static int getImagefielid(String docid){
        int imagefileid = -1;
        RecordSet rs = new RecordSet();
        rs.executeQuery("select imagefileid from docimagefile where docid=?",docid);
        if(rs.next()){
            imagefileid = Util.getIntValue(rs.getString("imagefileid"));
        }
        return imagefileid;
    }
%>

