<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="org.apache.commons.lang3.StringUtils" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="weaver.hrm.User" %>
<%@ page import="weaver.hrm.HrmUserVarify" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%

    User user = HrmUserVarify.getUser(request, response);
    if(user==null) {
        response.sendRedirect("/login/Login.jsp");
        return;
    }

    List<Map<String,Object>> mainList = new ArrayList<Map<String,Object>>();
    RecordSet rs = new RecordSet();
    String pbry = request.getParameter("pbry");
    if(StringUtils.isNotBlank(pbry)) {
        String sql = "select id,lastname from hrmresource where id in("+pbry+")";
        rs.executeQuery(sql);
        while (rs.next()){
            String userid = Util.null2String(rs.getString("id"));
            String lastname = Util.null2String(rs.getString("lastname"));

            Map<String,Object>  mainMap = new HashMap<String,Object>();
            mainMap.put("id",userid);
            mainMap.put("name",lastname);

            List<Map<String,String>> specialobjList = new ArrayList<Map<String,String>>();
            Map<String,String> specialobjMap = new HashMap<String,String>();
            specialobjMap.put("id",userid);
            specialobjMap.put("name",lastname);
            specialobjList.add(specialobjMap);

            Map<String,Object> valueMap = new HashMap<String,Object>();
            valueMap.put("value",userid);
            valueMap.put("specialobj",specialobjList);
            mainMap.put("value",valueMap);
            mainList.add(mainMap);
        }
    }

    JSONObject jsonObject = new JSONObject();
    jsonObject.put("main",mainList);
%>

<%=jsonObject.toJSONString() %>


