<%@ 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.time.LocalDate" %> <%@ 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 import="weaver.general.BaseBean" %> <%@ page language="java" contentType="text/html; charset=UTF-8" %> <% User user = HrmUserVarify.getUser(request, response); if(user==null) { response.sendRedirect("/login/Login.jsp"); return; } BaseBean bb = new BaseBean(); RecordSet rs = new RecordSet(); String cjrbm = request.getParameter("cjrbm"); Map valueMap = new HashMap<>(); List> dt1List = new ArrayList>(); if(StringUtils.isNotBlank(cjrbm)) { String sql = "select id,lastname from hrmresource where departmentid = "+cjrbm ; List> hrmList = queryListBySql(sql); valueMap = getMainUserDate(hrmList); dt1List = getDt1UserDate(hrmList); } JSONObject jsonObject = new JSONObject(); jsonObject.put("data",valueMap); jsonObject.put("dt1",dt1List); %> <%=jsonObject.toJSONString() %> <%! public List> getDt1UserDate(List> hrmList){ List> dt1List = new ArrayList>(); for(int i=0;i hrmMap = hrmList.get(i); String userid = Util.null2String(hrmMap.get("id")); String lastname = Util.null2String(hrmMap.get("lastname")); Map dt1Map = new HashMap(); dt1Map.put("id",userid); dt1Map.put("name",lastname); List> specialobjList2 = new ArrayList>(); Map specialobjMap2 = new HashMap(); specialobjMap2.put("id",userid); specialobjMap2.put("name",lastname); specialobjList2.add(specialobjMap2); Map valueMap2 = new HashMap(); valueMap2.put("value",userid); valueMap2.put("specialobj",specialobjList2); dt1Map.put("value",valueMap2); dt1List.add(dt1Map); } return dt1List; } /*** * * @param hrmList * @return */ public Map getMainUserDate(List> hrmList){ String userids = ""; List> specialobjList = new ArrayList>(); for(int i=0;i hrmMap = hrmList.get(i); String userid = Util.null2String(hrmMap.get("id")); String lastname = Util.null2String(hrmMap.get("lastname")); userids += StringUtils.isBlank(userids) ? userid : ","+userid ; Map specialobjMap = new HashMap(); specialobjMap.put("id",userid); specialobjMap.put("name",lastname); specialobjList.add(specialobjMap); } Map valueMap = new HashMap(); valueMap.put("value",userids); valueMap.put("specialobj",specialobjList); return valueMap; } public List> queryListBySql(String sql){ RecordSet rs = new RecordSet(); BaseBean bb = new BaseBean(); List> list = new ArrayList>(); try{ if(StringUtils.isNotBlank(sql)){ Map map = new HashMap(); rs.executeQuery(sql); String[] column = rs.getColumnName(); while (rs.next()){ map = new HashMap(); for(int i=0;i0){ list.add(map); } } } }catch (Exception e){ e.printStackTrace(); bb.writeLog("queryListBySql-e:"+e); } return list; } %>