<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="java.util.*" %>
<%@ page import="weaver.hrm.resource.ResourceComInfo" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%
    RecordSet rs = new RecordSet();
    out.print("系统当前时间等于预计落地时，若尚未进行落地结果录入，\n" +
             " 提醒：支公司分管总 </br>");
    ResourceComInfo resourceComInfo = null;
    try{
        resourceComInfo = new ResourceComInfo();
        List<Map<String,String>> list = new ArrayList<Map<String,String>>();
        String sql =" select id,modedatacreater,proname,profall,sfcj \n" +
                    " from uf_threebatches\n" +
                    " where profall = to_char(sysdate,'YYYY-MM-DD') " +
                    " and sfcj is null " ;
        rs.executeQuery(sql);
        out.print("当前时间 = 预计落地时间，是否承接 为空值:"+sql+"</br>");

        while (rs.next()){
            String id = Util.null2String(rs.getString("id"));
            String lrry = Util.null2String(rs.getString("modedatacreater"));
            String xmmc = Util.null2String(rs.getString("proname"));
            String profall = Util.null2String(rs.getString("profall"));
            String sfcj = Util.null2String(rs.getString("sfcj"));

            Map<String,String> map = new HashMap<String,String>();
            map.put("id",id);
            map.put("lrry",lrry);
            map.put("xmmc",xmmc);
            map.put("profall",profall);
            map.put("sfcj",sfcj);

            list.add(map);
        }
        out.print("总计:"+list.size()+"</br>");

        for(int i=0;i<list.size();i++){
            Map<String,String> map = list.get(i);
            String xmmc = map.get("xmmc");
            String lrry = map.get("lrry");
            String billid = map.get("id");
            String profall = map.get("profall");

            String lastname = "";
            Set<String> userSet = new HashSet<String>();
            sql =   " select id\n" +
                    " from hrmresource\n" +
                    " where subcompanyid1 in (\n" +
                    "    select subcompanyid1 from hrmresource where id = "+lrry+"\n" +
                    " )\n" +
                    " and seclevel >=40 and seclevel <=50";

            out.print("获取录入人员随着支公司的分管总:"+sql+"</br>");
            rs.executeQuery(sql);
            while (rs.next()){
                String id = Util.null2String(rs.getString("id"));
                userSet.add(id);

                lastname += resourceComInfo.getLastname(id)+",";
            }
            String context = "请及时维护"+xmmc+"的落地情况";
            String title = "三个一批项目提醒";

            out.print("序号:"+(i+1)+" ,建模ID:"+billid+" ,预计落地时间:"+profall+" ,提醒标题:"+title+" ,提醒内容:"+context+" ,提醒人:"+lastname+"("+userSet.toString()+")</br>");
        }
    }catch (Exception e){
        out.print("e:"+e);
    }
%>
