<%@ 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(":预计落地时间前5天，若尚未进行过程性管理录入，\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\n" +
                    " from uf_threebatches\n" +
                    " where id in(\n" +
                    "   select l.id \n" +
                    "   from uf_threebatches l " +
                    "   left join uf_threebatches_dt4 t on l.id = t.mainid \n" +
                    "   where l.id in(\n" +
                    "       select p.id\n" +
                    "       from uf_threebatches p\n" +
                    "       where (trunc(sysdate - to_date(p.profall,'YYYY-MM-DD' ))+1) <= 5 " +
                    "       and (trunc(sysdate - to_date(p.profall,'YYYY-MM-DD' ))+1) >= 0 \n" +
                    "  )\n" +
                    "  group by l.id having count(t.id) = 0\n" +
                    ")" ;
        out.print("当前时间在预计落地时间(profall)的前5天，并且明细表4没有数据的:"+sql+"</br>");
        rs.executeQuery(sql);
        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"));
            Map<String,String> map = new HashMap<String,String>();

            map.put("id",id);
            map.put("lrry",lrry);
            map.put("xmmc",xmmc);
            map.put("profall",profall);

            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");

            Set<String> userSet = new HashSet<String>();

            String lastname = "";
            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"));

                lastname += resourceComInfo.getLastname(id)+",";
                userSet.add(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);
    }
%>
