<%@ page import="weaver.general.*" %>
<%@page import="weaver.conn.RecordSet"%>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.commons.lang3.StringUtils" %>
<%@ page import="com.api.doc.detail.util.DocDownloadCheckUtil" %>
<%@ page import="weaver.hrm.User" %>
<%@ page import="weaver.hrm.HrmUserVarify" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>

<%
    RecordSet rs = new RecordSet();
    BaseBean bb = new BaseBean();

    User user = HrmUserVarify.getUser (request , response) ;
    Map<String,String> map = null;
    List<Map<String,String>> list = new ArrayList<Map<String,String>>();

    String sql = " select id,tp,zfy,zfby from uf_rzzntp where sfqy = 0 ";
    rs.executeQuery(sql);
    while (rs.next()){
        String billid = Util.null2String(rs.getString("id"));
        String tp = Util.null2String(rs.getString("tp"));
        String zfy = Util.null2String(rs.getString("zfy"));
        String zfby = Util.null2String(rs.getString("zfby"));
        map = new HashMap<String, String>();
        map.put("billid",billid);
        map.put("tp",tp);
        map.put("zfy",zfy);
        map.put("zfby",zfby);
        list.add(map);
    }

    for(int i=0;i<list.size();i++){
        Map<String,String> dataMap = list.get(i);
        String tp = dataMap.get("tp");
        if(StringUtils.isNotBlank(tp)){
            String imagefileid = "" ;
            sql = " select k.imagefileid \n" +
                  " from DocImageFile t\n" +
                  " inner join imagefile k on k.imagefileid = t.imagefileid\n" +
                  " where docid="+tp ;
            rs.executeQuery(sql);
            if(rs.next()){
                imagefileid = Util.null2String(rs.getString("imagefileid"));
            }

            if(StringUtils.isNotBlank(imagefileid)){
                String imageurl ="";
                String imagefileid_ = DocDownloadCheckUtil.checkPermission(imagefileid,user);
                if(StringUtils.isNotBlank(imagefileid_)){
                   imageurl =  "/weaver/weaver.file.FileDownload?fileid="+imagefileid_;
                }
                dataMap.put("imagefileid",imagefileid);
                dataMap.put("imageurl",imageurl);
            }
        }
    }

    JSONObject jsonObject = new JSONObject();
    jsonObject.put("data",list);

%>
<%=jsonObject.toString()  %>




