<%@ page import="weaver.general.*" %>
<%@page import="weaver.conn.RecordSet"%>
<%@ page import="org.apache.commons.lang.StringUtils" %>
<%@ page import="com.engine.portrait.util.PortraitUtil" %>
<%@ page import="com.engine.portrait.util.CommonUtil" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.*" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>

<%
    List<Map<String,String>> dataList = new ArrayList<Map<String,String>>();
    Map<String,String> dataMap = null;
    RecordSet rs = new RecordSet();
    BaseBean bb = new BaseBean();
    String timestrformart = "MM-dd" ;
    SimpleDateFormat sdf = new SimpleDateFormat(timestrformart) ;
    Calendar calendar = Calendar.getInstance() ;
    String currentDay = sdf.format(calendar.getTime()) ;
    bb.writeLog("currentDay:"+currentDay);

    String sql =" select h.id,h.lastname,h.sex,d.departmentname,s.subcompanyname from hrmresource h\n" +
                " inner join HrmDepartment d on d.id = h.departmentid\n" +
                " inner join HrmSubCompany s on s.id = h.subcompanyid1\n" +
                " where birthday like '%"+currentDay+"'\n" +
                " and h.status in(1,2,3,4)" ;
    bb.writeLog("sql:"+sql);
    rs.executeQuery(sql);
    while (rs.next()){
        String id = Util.null2String(rs.getString("id"));
        String lastname = Util.null2String(rs.getString("lastname"));
        String sex = Util.null2String(rs.getString("sex"));
        String departmentname = Util.null2String(rs.getString("departmentname"));
        String subcompanyname = Util.null2String(rs.getString("subcompanyname"));

        dataMap = new HashMap<String, String>();
        dataMap.put("userid",id);
        dataMap.put("sex",sex);
        dataMap.put("lastname",lastname);
        dataMap.put("departmentname",departmentname);
        dataMap.put("subcompanyname",subcompanyname);
        dataList.add(dataMap);
    }

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

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


<%!

    /***
     *
     * @param userid
     * @param itemid
     * @return
     */
    private String getQuerySql(String userid,String itemid) {

        BaseBean bb = new BaseBean();
        StringBuilder sqlSB = new StringBuilder();

        if(StringUtils.isNotEmpty(itemid))
        {
            sqlSB.append(" select e.id as itemdataid,e.userid,e.itemvalue,e.otherinfo as itemdata,d.* from (SELECT a.moduleid,a.name ,b.subname,b.subid ,b.iconname,b.iconcolor,b.iconbgcolor,c.id as itemid,c.iszeroshow,c.name as itemname,c.tipsinfo,c.isability,c.isnegative,c.overcolor,c.showorder")
                    .append(" FROM wr_individualitem_module a join wr_individualitem_submodule b on a.moduleid = b.moduleid ")
                    .append(" join wr_individualitem_info c on b.subid = c.subid ")
                    .append(" where a.status = 1 and b.status = 1 and  c.status = 1 ");
            if (!CommonUtil.hasSubordinate(userid)) {
                sqlSB.append(" and a.moduleid != 3 ");
            }
            String shareSql = "";
            try {
                shareSql = PortraitUtil.getShareBizidSql("10",userid);
            } catch (Exception e) {
                bb.writeLog("获取shareSql失败,userid="+userid+",type=10,"+e);
            }
            if (StringUtils.isNotEmpty(shareSql)) {
                sqlSB.append(" and b.subid in (").append(shareSql).append(")");
            }
            sqlSB.append(" ) d join wr_individualitem_detail e on e.itemid = d.itemid ").append(" WHERE e.userid = ? and e.type = ? ");
            sqlSB.append(" and d.itemid = "+itemid);
            sqlSB.append(" order by d.moduleid asc,d.showorder asc");
        }
        return sqlSB.toString();
    }

%>



