三级菜单树的组装与遍历显示

阅读更多
Action:
UserManagerAction.java
树工具类.
TreeUtil.java
三级菜单形如:
三级菜单树的组装与遍历显示_第1张图片
具体加载数据:
PS:TreeUtil可以对菜单无限级装填.
详见->menus的List-Map数据格式.zip

页面:
left.jsp
显示效果:
直接加载,展开
三级菜单树的组装与遍历显示_第2张图片

再点击,关闭.
三级菜单树的组装与遍历显示_第3张图片


1.
UserManagerAction.java 参见menusInfo()方法.
package com.lecheng.pcaction;

import io.rong.api.ApiHttpClient;
import io.rong.models.FormatType;
import io.rong.models.SdkHttpResult;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.struts2.ServletActionContext;

import com.lecheng.entity.manager_entity;
import com.lecheng.entity.user_entity;
import com.lecheng.entity.menu.MenuInfo;
import com.lecheng.framework.filter.init.BaseConf;
import com.lecheng.serviceimpl.SchoolManagerServiceImpl;
import com.lecheng.serviceimpl.SystemLogServiceImpl;
import com.lecheng.serviceimpl.UserManagerServiceImpl;
import com.lecheng.serviceimpl.menu.MenuInfoServiceImpl;
import com.lecheng.services.PaymentService;
import com.lecheng.services.SchoolManagerService;
import com.lecheng.services.SystemLogService;
import com.lecheng.services.UserManagerService;
import com.lecheng.services.menu.MenuInfoService;
import com.lecheng.utils.BaseAction;
import com.lecheng.utils.CommonUtils;
import com.lecheng.utils.DesEncrypt;
import com.lecheng.utils.TreeUtil;
import com.lecheng.utils.link_db;

/**
 * 用户管理action
 * @author lengzl
 * @email [email protected]
 * @create 2017年1月12日 上午10:23:14
 */
public class UserManagerAction extends BaseAction {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1426884653078966867L;
	private Map dataMap;
	private HttpServletRequest request = ServletActionContext.getRequest();
	private HttpServletResponse response = ServletActionContext.getResponse();
	private HttpSession session = request.getSession();
	SystemLogServiceImpl systemLog = new SystemLogService();
	SdkHttpResult result = null;
	private MenuInfoService menuInfoService = new MenuInfoServiceImpl();
	
	//======lengzl新加===============================================================================
	
	
	public Map getDataMap() {
		return this.dataMap;
	}

	public void setDataMap(Map dataMap) {
		this.dataMap = dataMap;
	}
	
	
	
	/**
	 * 管理员登录
	 * 
	 *  * 版本修改历史记录:
     * 1)  初始创建 未知
     * 
* 2) 2017年1月5日 下午1:29:31 获取当前用户所有的功能权限. * * @throws Exception */ @SuppressWarnings("unchecked") public String MangerLogin() throws Exception { dataMap = new HashMap(); String username = this.request.getParameter("username"); String password = this.request.getParameter("password"); String type = this.request.getParameter("type"); String m = "1"; String content = ""; UserManagerServiceImpl umanager = new UserManagerService(); password = DesEncrypt.encryptDES(password, CommonUtils.encryptKey); ArrayList res = umanager.adminLogin(username, password, type); if (res != null && res.size() > 0) { dataMap.put("result", "success"); dataMap.put("message", "登录成功"); dataMap.put("msg", res); session.setAttribute("username", username); session.setAttribute("usertype", type); session.setAttribute("schoolid", res.get(0).getSchoolid()); session.setAttribute("schoolname", res.get(0).getSchoolname()); session.setAttribute("areaid", res.get(0).getAreaid()); session.setAttribute("userid", res.get(0).getUserid()); session.setAttribute("classid", res.get(0).getClassid()); session.setAttribute("schoolareaid", res.get(0).getSchoolareaid()); session.setAttribute("rootPath", request.getSession().getServletContext().getRealPath("")); session.setAttribute("m", m); manager_entity currUser= res.get(0); session.setAttribute("curuser", currUser); String functions = umanager.getFuncIDs(currUser.getRoleIds()); if(StringUtils.isNotEmpty(functions)){ session.setAttribute("funcIds", functions); String[] functionsArray = functions.split(","); //未使用. /*[, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 607, 608, 801, 802, 804, 3301, 3302, 3303, 805, 1701, 1702, 1703, 1704,1705, 2301, 2302, 2303, 2304, 2305, 2306, 2307, 2308, 2501, 2502, 201, 202, 203, 402, 1258, 1, 405, 1003, 1008, 1009, 1010, 1011, 2105, 4901, 1004, 1201, 1202, 1203, 1204, 1801, 1802, 1005, 2103, 2104, 1006, 1205, 1206, 1207, 1208, 1007, 1209, 1210, 1211, 1212, 1213, 1214, 1215, 1901, 1904, 2106, 1216, 1220, 1221, 1222, 1218, 2101, 2102, 2901, 3901, 406, 1001, 1002]*/ //供应商跳转的页面. etc } /** * 添加系统日志 */ if(type.equals(CommonUtils.userTypeForAdmin)){ content = "系统管理员"; }if(type.equals(CommonUtils.userTypeForParkAdmin)){ content = "学校管理员"; }if(type.equals(CommonUtils.userTypeForCityAdmin)){ content = "市教育局管理员"; }if(type.equals(CommonUtils.userTypeForAreaAdmin)){ content = "区县教育局管理员"; } systemLog.addSystemLog(CommonUtils.operation_class_login, request.getRemoteAddr(), content+"登录", username); } else { dataMap.put("result", "faild"); dataMap.put("message", "用户名或密码错误"); } return SUCCESS; } public String parentLogin() { dataMap = new HashMap(); String username = this.request.getParameter("username"); String password = this.request.getParameter("password"); String type = this.request.getParameter("type"); String m = "0"; UserManagerServiceImpl umanager = new UserManagerService(); ArrayList res = umanager.adminLogin(username, password, type); if (res != null && res.size() > 0) { session.setAttribute("username", username); session.setAttribute("usertype", type); session.setAttribute("schoolid", res.get(0).getSchoolid()); session.setAttribute("schoolname", res.get(0).getSchoolname()); session.setAttribute("areaid", res.get(0).getAreaid()); session.setAttribute("userid", res.get(0).getUserid()); session.setAttribute("classid", res.get(0).getClassid()); session.setAttribute("m", m); dataMap.put("result", "success"); dataMap.put("message", "登录成功"); try { response.sendRedirect("adminpages/main_parent.jsp"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { try { response.sendRedirect("http://youyitong365.com/login.html"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } dataMap.put("result", "faild"); dataMap.put("message", "用户名或密码错误"); } return SUCCESS; } /* * 用户统计 */ public String getUserState() { dataMap = new HashMap(); UserManagerServiceImpl umanager = new UserManagerService(); dataMap.put("result", "success"); dataMap.put("message", umanager.getUserState()); return SUCCESS; } /* * 获取园区管理员 列表 */ public String getYuanquanManagerList() { dataMap = new HashMap(); String schoolid = this.request.getParameter("schoolid"); UserManagerServiceImpl umanager = new UserManagerService(); dataMap.put("result", "success"); dataMap.put("message", umanager.getSubManagerList(schoolid, "4")); return SUCCESS; } /** * 添加园区管理员 */ public String addYuanquManager() { dataMap = new HashMap(); String username = this.request.getParameter("username"); String password = this.request.getParameter("password"); String schoolid = this.request.getParameter("schoolid"); UserManagerServiceImpl umanager = new UserManagerService(); umanager.addSchoolManager(username, password, schoolid, "", ""); dataMap.put("result", "success"); dataMap.put("message", "添加成功"); return SUCCESS; } /** * 添加业务人员 */ public String addBusiness() { dataMap = new HashMap(); String username = request.getParameter("username"); String password = request.getParameter("password"); String nickname = request.getParameter("nickname"); String sex = request.getParameter("sex"); String tel = request.getParameter("tel"); String area = request.getParameter("area"); UserManagerServiceImpl umanager = new UserManagerService(); if (umanager.addBusiness(username, password, nickname, sex, area, tel)) { dataMap.put("result", "success"); dataMap.put("msg", "添加成功"); } else { dataMap.put("msg", "添加失败"); } return SUCCESS; } /** * 获取业务人员列表 */ public String getBusinessList() { dataMap = new HashMap(); String usertype = this.request.getParameter("usertype"); String account = this.request.getParameter("account"); String pageindex = request.getParameter("pageindex"); String pagesize = request.getParameter("pagesize"); if (account == null) { account = ""; } UserManagerServiceImpl umanager = new UserManagerService(); int pagequeryIndex = Integer.parseInt(pageindex) * Integer.parseInt(pagesize); int queryPageSize = Integer.parseInt(pagesize); int counts = umanager.getBusinessCount(usertype, account); int allpagesize = (int) Math.ceil((double) counts / (double) queryPageSize); dataMap.put("counts", counts); dataMap.put("allpagesize", allpagesize); dataMap.put("msg", umanager.getBusinessList(usertype, account, pagequeryIndex, queryPageSize)); dataMap.put("result", "success"); return SUCCESS; } /* * 获取代理列表 */ public String getDailiList() { String usertype = this.request.getParameter("usertype"); String areaid = this.request.getParameter("areaid"); String pageNum = request.getParameter("pageNum"); String pageSize = request.getParameter("pageSize"); dataMap = new HashMap(); UserManagerServiceImpl umanager = new UserManagerService(); List l = umanager.getDailiList(usertype, areaid); List rl = new ArrayList<>(); int pn = Integer.parseInt(pageNum); int ps = Integer.parseInt(pageSize); if (pn > 0) { dataMap.put("haspre", true); } else { dataMap.put("haspre", false); } if ((pn + 1) > (l.size() % ps == 0 ? l.size() / ps : (l.size() / ps + 1))) { dataMap.put("hasnext", true); } else { dataMap.put("hasnext", false); } if (l.size() >= (pn + 1) * ps) { rl = l.subList(pn * ps, (pn + 1) * ps); } else { rl = l.subList(pn * ps, l.size()); } dataMap.put("total", l.size()); dataMap.put("result", "success"); dataMap.put("message", rl); return SUCCESS; } /** * 添加管理员 * @throws Exception */ public String addDaili() throws Exception { dataMap = new HashMap(); String areaid = this.request.getParameter("areaid"); String username = this.request.getParameter("username"); String password = this.request.getParameter("password"); password = DesEncrypt.encryptDES(password, CommonUtils.encryptKey); String usertype = this.request.getParameter("usertype"); UserManagerServiceImpl umanager = new UserManagerService(); umanager.addDaili(username, password, areaid, usertype); dataMap.put("result", "success"); dataMap.put("message", "添加成功"); return SUCCESS; } /** * 删除管理员 */ public String deleteManager() { dataMap = new HashMap(); String userid = this.request.getParameter("userid"); UserManagerServiceImpl umanager = new UserManagerService(); umanager.delelteManager(userid); dataMap.put("result", "success"); dataMap.put("message", "删除成功"); return SUCCESS; } /** * 幼儿园添加家长 */ public String addparents() { this.dataMap = new HashMap(); UserManagerServiceImpl usermanagerService = new UserManagerService(); SchoolManagerServiceImpl schoolManager = new SchoolManagerService(); String schoolid = request.getParameter("schoolid"); String phonenunm = request.getParameter("phonenunm"); String parentname = request.getParameter("parentname"); String relationselect = request.getParameter("relationselect"); String idCard = request.getParameter("idCard"); int babyid = usermanagerService.getMaxBabyId(); String watchendttime = schoolManager.getSchoolName(schoolid).getAddtime(); // -------宝宝冲会员状态在相关联的家长数据中,所以再次新增家长取其他家长的会员日期----- PaymentService paymentService = new PaymentService(); Map params = new HashMap<>(); params.put("babyid", request.getParameter("babyid")); Map parentResult = paymentService.gotParentsByBabyId(params); if ("success".equals(parentResult.get("result"))) { List> parents = (List>) parentResult.get("parents"); if (CollectionUtils.isNotEmpty(parents)) { watchendttime = MapUtils.getString(parents.get(0), "watchendttime"); } } // -------取其他家长的会员日期-------------- int count = usermanagerService.getPaeretCountByUserName(phonenunm); String userpassword = ""; if(count!=0){ userpassword = usermanagerService.getUserInfo(phonenunm).getUserpassword(); String groupId = usermanagerService.getBabyInfo(String.valueOf(babyid)).getClasschatroomid(); String groupName = usermanagerService.getBabyInfo(String.valueOf(babyid)).getClassname(); // 加入群组 try { result = ApiHttpClient.joinGroup( CommonUtils.rongAppKey, CommonUtils.rongAppSecret, phonenunm, groupId, groupName, FormatType.json); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } if (usermanagerService.addParents(phonenunm,parentname,CommonUtils.parent,relationselect,idCard,babyid,watchendttime,userpassword)) { dataMap.put("msg", "添加成功"); dataMap.put("result", "success"); /** * 系统日志 */ systemLog.addSystemLog(CommonUtils.operation_class_add, request.getRemoteAddr(), "新增家长【"+parentname+"】", request.getSession().getAttribute("username").toString()); } else { dataMap.put("msg", "添加失败"); dataMap.put("result", "faild"); } return SUCCESS; } public String addUser() { this.dataMap = new HashMap(); UserManagerServiceImpl usermanagerService = new UserManagerService(); SchoolManagerServiceImpl schoolManager = new SchoolManagerService(); String schoolid = this.request.getParameter("schoolid"); String phonenunm = this.request.getParameter("phonenunm"); String parentname = this.request.getParameter("parentname"); String relationselect = this.request.getParameter("relationselect"); String idCard = this.request.getParameter("idCard"); int babyid = Integer.parseInt(this.request.getParameter("babyid")); String watchendttime = schoolManager.getSchoolName(schoolid).getAddtime(); // -------宝宝冲会员状态在相关联的家长数据中,所以再次新增家长取其他家长的会员日期----- PaymentService paymentService = new PaymentService(); Map params = new HashMap<>(); params.put("babyid", request.getParameter("babyid")); Map parentResult = paymentService.gotParentsByBabyId(params); if ("success".equals(parentResult.get("result"))) { List> parents = (List>) parentResult.get("parents"); if (CollectionUtils.isNotEmpty(parents)) { watchendttime = MapUtils.getString(parents.get(0), "watchendttime"); } } // -------取其他家长的会员日期-------------- int count = usermanagerService.getPaeretCountByUserName(phonenunm); String userpassword = ""; if(phonenunm==null){ phonenunm = ""; }if(parentname==null){ parentname = ""; } if(count!=0){ userpassword = usermanagerService.getUserInfo(phonenunm).getUserpassword(); }if (usermanagerService.addParents(phonenunm,parentname,CommonUtils.parent,relationselect,idCard,babyid,watchendttime,userpassword)) { dataMap.put("msg", "添加成功"); dataMap.put("result", "success"); String username = request.getSession().getAttribute("username").toString(); if(StringUtils.isNotBlank(username)) systemLog.addSystemLog(CommonUtils.operation_class_add, request.getRemoteAddr(), "新增家长【" + parentname + "】", username); } else { dataMap.put("msg", "添加失败"); dataMap.put("result", "faild"); } return SUCCESS; } /** * 添加教师 */ public String addTeacher() { dataMap = new HashMap(); final String username = this.request.getParameter("username"); //String password = this.request.getParameter("password"); String schoolid = this.request.getParameter("schoolid"); String schoolname = this.request.getParameter("schoolname"); String idCard = this.request.getParameter("idCard"); final String classid = this.request.getParameter("classid"); String nickname = this.request.getParameter("nickname"); String sex = this.request.getParameter("sex"); UserManagerServiceImpl usermanager = new UserManagerService(); int count = usermanager.getPaeretCountByUserName(username); String password = ""; if(count!=0){ password = usermanager.getUserInfo(username).getUserpassword(); } if (usermanager.adduser(username, password, "1", schoolid, schoolname, "", nickname, classid, "", sex,idCard) == 1) { dataMap.put("result", "success"); dataMap.put("message", "添加成功"); /** * 异步处理 */ /*Thread thread = new Thread(new Runnable() { public void run() { // TODO Auto-generated method stub try { TimeUnit.SECONDS.sleep(1); IMmanagerUtil.addUser(username, "123456"); IMmanagerUtil.updateMemberOfOldClass(username, classid); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); thread.start();*/ } else { dataMap.put("result", "faild"); dataMap.put("message", "该教师已经存在"); } return SUCCESS; } /** * 编辑教师 */ public String updateTeacher() { dataMap = new HashMap(); String userid = this.request.getParameter("userid"); final String username = this.request.getParameter("username"); //IMmanagerUtil.deleteMemberOfOldClass(userid,CommonUtils.teacher); String password = this.request.getParameter("password"); String nickname = this.request.getParameter("nickname"); String oldUserName = this.request.getParameter("oldUserName"); String sex = this.request.getParameter("sex"); String idCard = this.request.getParameter("idCard"); final String classid = this.request.getParameter("classid"); UserManagerServiceImpl usermanager = new UserManagerService(); if (usermanager.updateTeacher(userid, username, password, nickname,sex, classid,idCard)) { dataMap.put("result", "success"); dataMap.put("message", "修改成功"); if (password != null && password.length() != 0) { // 退出群组 String schoolroom = usermanager.getTeacherInfo(userid, CommonUtils.teacher) .getSchoolroom(); String[] schoolGroupId = schoolroom.split(","); String classGroupId = usermanager.getTeacherInfo(userid, CommonUtils.teacher) .getClasschatroomid(); String classname = usermanager.getTeacherInfo(userid, CommonUtils.teacher) .getClassname(); String schoolname = usermanager.getTeacherInfo(userid, CommonUtils.teacher) .getSchoolname(); try { result = ApiHttpClient.quitGroup(CommonUtils.rongAppKey, CommonUtils.rongAppSecret, oldUserName, classGroupId, FormatType.json); result = ApiHttpClient.joinGroup(CommonUtils.rongAppKey, CommonUtils.rongAppSecret, username, classGroupId, classname, FormatType.json); for (int i = 0; i < schoolGroupId.length; i++) { result = ApiHttpClient.quitGroup( CommonUtils.rongAppKey, CommonUtils.rongAppSecret, oldUserName, schoolGroupId[i], FormatType.json); result = ApiHttpClient.joinGroup( CommonUtils.rongAppKey, CommonUtils.rongAppSecret, username, schoolGroupId[i], schoolname, FormatType.json); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } /** * 异步处理 */ /*Thread thread = new Thread(new Runnable() { public void run() { // TODO Auto-generated method stub try { TimeUnit.SECONDS.sleep(1); IMmanagerUtil.updateMemberOfOldClass(username, classid); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); thread.start();*/ } else { dataMap.put("result", "faild"); dataMap.put("message", "修改失败"); } return SUCCESS; } /** * 根据学校ID获取教师列表 */ public String getTeachersList() { dataMap = new HashMap(); String schoolid = this.request.getParameter("schoolid"); String account = this.request.getParameter("account"); String other = this.request.getParameter("other"); String pageindex = request.getParameter("pageindex"); String pagesize = request.getParameter("pagesize"); String time = ""; if (pageindex == null || pageindex.length() == 0) { dataMap.put("result", "faild"); dataMap.put("message", "请输入页码"); } if (pagesize == null || pagesize.length() == 0) { dataMap.put("result", "faild"); dataMap.put("message", "请输入每页显示数量"); } if (account == null || account.length() == 0) { account = ""; } UserManagerServiceImpl usermanager = new UserManagerService(); dataMap.put("result", "success"); int pagequeryIndex = Integer.parseInt(pageindex) * Integer.parseInt(pagesize); int queryPageSize = Integer.parseInt(pagesize); ArrayList teacherlist = usermanager.getUserListBySchoolid( pagequeryIndex, queryPageSize, schoolid, "1", account, other, time); int counts = usermanager.getTeacherCount(schoolid, "1", account, other, time); ArrayList copylist = new ArrayList(); int allpagesize = (int) Math.ceil((double) counts/ (double) queryPageSize); dataMap.put("result", "success"); dataMap.put("counts", counts); dataMap.put("allpagesize", allpagesize); for (user_entity ue : teacherlist) { String userid = ue.getUserid(); String sql1 = "select * from table_babycomment where teacherid='" + userid + "'"; String sql2 = "select * from table_trends where userid='" + userid + "'"; int commentnum; try { commentnum = link_db.getInstance().executeQuery_noobj(sql1); int notinum = link_db.getInstance().executeQuery_noobj(sql2); ue.setDianpingshu(commentnum + ""); ue.setBangjitongzhi(notinum + ""); copylist.add(ue); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } dataMap.put("message", copylist); return SUCCESS; } /** * 根据班级获取家长列表 */ public String getParentListByClassid() { dataMap = new HashMap(); String classid = this.request.getParameter("classid"); String account = this.request.getParameter("account"); String other = this.request.getParameter("other"); String schoolid = (String) request.getSession() .getAttribute("schoolid"); String adminSchoolid = this.request.getParameter("adminSchoolid"); String pageindex = request.getParameter("pageindex"); String pagesize = request.getParameter("pagesize"); String userType = (String) request.getSession() .getAttribute("usertype"); // if (pageindex == null || pageindex.length() == 0) { dataMap.put("result", "faild"); dataMap.put("message", "请输入页码"); } if (pagesize == null || pagesize.length() == 0) { dataMap.put("result", "faild"); dataMap.put("message", "请输入每页显示数量"); } if (account == null || account.length() == 0) { account = ""; } UserManagerServiceImpl usermanager = new UserManagerService(); dataMap.put("result", "success"); int pagequeryIndex = Integer.parseInt(pageindex) * Integer.parseInt(pagesize); int queryPageSize = Integer.parseInt(pagesize); int counts = 0; int allpagesize; //userType=3系统管理员 if (userType.equals(CommonUtils.userTypeForAdmin) //权限管理判断用户是否是管理员.学校管理员or业务员的权限. LLD.走这 || userType.equals(CommonUtils.business)) { dataMap.put("message", usermanager .getUserListByClassid(pagequeryIndex, queryPageSize, classid, CommonUtils.parent, account, adminSchoolid, CommonUtils.userTypeForAdmin, other)); counts = usermanager .getPaeretCount(classid, CommonUtils.parent, account, adminSchoolid, CommonUtils.userTypeForAdmin, other); } else { dataMap.put("message", usermanager.getUserListByClassid( pagequeryIndex, queryPageSize, classid, CommonUtils.parent, //0家长 account, schoolid, CommonUtils.userTypeForParkAdmin, CommonUtils.all)); counts = usermanager.getPaeretCount(classid, CommonUtils.parent, account, schoolid, CommonUtils.userTypeForParkAdmin, CommonUtils.all); } allpagesize = (int) Math.ceil((double) counts / (double) queryPageSize); dataMap.put("result", "success"); dataMap.put("counts", counts); dataMap.put("allpagesize", allpagesize); return SUCCESS; } /* * 获取幼儿园列表 */ public String getYuanquanList() { // String schoolid= return SUCCESS; } /** * 设置家长视频观看时间 */ public String setParentWatchTime() { dataMap = new HashMap(); String starttime = this.request.getParameter("starttime"); String endtime = this.request.getParameter("endtime"); String userid = this.request.getParameter("userid"); //IMmanagerUtil.deleteMemberOfOldClass(userid,CommonUtils.parent); String childname = this.request.getParameter("childname"); String selectsex = this.request.getParameter("selectsex"); String demo = this.request.getParameter("demo"); String selectclass = this.request.getParameter("selectclass"); String relationselect = this.request.getParameter("relationselect"); String parentname = this.request.getParameter("parentname"); String phonenunm = this.request.getParameter("phonenunm"); String idCard = this.request.getParameter("idCard"); String userpassword = this.request.getParameter("userpassword"); String oldUserName = this.request.getParameter("oldUserName"); UserManagerServiceImpl usermanager = new UserManagerService(); //根据用户ID获取宝宝ID String babyid = usermanager.getMark(userid).getBabyid(); if (usermanager.setParentsWatchTime(relationselect, parentname, phonenunm, starttime,endtime,idCard, userid)) { usermanager.updateBabyInfo(childname, selectsex, demo, selectclass, babyid); dataMap.put("result", "success"); dataMap.put("message", "修改成功"); /** * 异步处理 */ /*Thread thread = new Thread(new Runnable() { public void run() { // TODO Auto-generated method stub try { TimeUnit.SECONDS.sleep(1); IMmanagerUtil.updateMemberOfOldClass(phonenunm, selectclass); } catch (InterruptedException e) { e.printStackTrace(); } } }); thread.start();*/ if (userpassword != null && userpassword.length() != 0) { // 退出群组 String schoolroom = usermanager.getBabyInfo(babyid) .getSchoolroom(); String[] schoolGroupId = schoolroom.split(","); String classGroupId = usermanager.getBabyInfo(babyid) .getClasschatroomid(); String classname = usermanager.getBabyInfo(babyid) .getClassname(); String schoolname = usermanager.getBabyInfo(babyid) .getSchoolname(); try { result = ApiHttpClient.quitGroup(CommonUtils.rongAppKey, CommonUtils.rongAppSecret, oldUserName, classGroupId, FormatType.json); result = ApiHttpClient.joinGroup(CommonUtils.rongAppKey, CommonUtils.rongAppSecret, phonenunm, classGroupId, classname, FormatType.json); for (int m = 0; m < schoolGroupId.length; m++) { result = ApiHttpClient.quitGroup( CommonUtils.rongAppKey, CommonUtils.rongAppSecret, oldUserName, schoolGroupId[m], FormatType.json); result = ApiHttpClient.joinGroup( CommonUtils.rongAppKey, CommonUtils.rongAppSecret, phonenunm, schoolGroupId[m], schoolname, FormatType.json); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } else { dataMap.put("result", "faild"); dataMap.put("message", "修改失败"); } return SUCCESS; } /** * 根据下拉列表获取教师信息 * * @return */ public String getTeacherBySelect() { dataMap = new HashMap(); String account = this.request.getParameter("account"); String typeid = this.request.getParameter("typeid"); String type = this.request.getParameter("type"); String pageindex = request.getParameter("pageindex"); String pagesize = request.getParameter("pagesize"); String time = ""; // String other = "0"; String other = this.request.getParameter("other"); if (pageindex == null || pageindex.length() == 0) { dataMap.put("result", "faild"); dataMap.put("message", "请输入页码"); } if (pagesize == null || pagesize.length() == 0) { dataMap.put("result", "faild"); dataMap.put("message", "请输入每页显示数量"); } if (account == null || account.length() == 0) { account = ""; } UserManagerServiceImpl usermanager = new UserManagerService(); dataMap.put("result", "success"); ArrayList teacherlist = null; ArrayList copylist = new ArrayList(); int counts = 0; int pagequeryIndex = Integer.parseInt(pageindex) * Integer.parseInt(pagesize); int queryPageSize = Integer.parseInt(pagesize); if (type.equals("1")) { teacherlist = usermanager.getUserListByProvinceid(pagequeryIndex, queryPageSize, typeid, CommonUtils.teacher, account, other, time); counts = usermanager.getTeacherCountByProvince(typeid, CommonUtils.teacher, account, other, time); } else if (type.equals("2")) { teacherlist = usermanager.getUserListByCityid(pagequeryIndex, queryPageSize, typeid, CommonUtils.teacher, account, other, time); counts = usermanager.getTeacherCountByCity(typeid, CommonUtils.teacher, account, other, time); } else if (type.equals("3")) { teacherlist = usermanager.getUserListByAreaid(pagequeryIndex, queryPageSize, typeid, CommonUtils.teacher, account, other, time); counts = usermanager.getTeacherCountByArea(typeid, CommonUtils.teacher, account, other, time); } else { } int allpagesize = (int) Math.ceil((double) counts / (double) queryPageSize); dataMap.put("result", "success"); dataMap.put("message", teacherlist); dataMap.put("counts", counts); dataMap.put("allpagesize", allpagesize); for (user_entity ue : teacherlist) { String userid = ue.getUserid(); String sql1 = "select * from table_babycomment where teacherid='" + userid + "'"; String sql2 = "select * from table_trends where userid='" + userid + "'"; int commentnum; try { commentnum = link_db.getInstance().executeQuery_noobj(sql1); int notinum = link_db.getInstance().executeQuery_noobj(sql2); ue.setDianpingshu(commentnum + ""); ue.setBangjitongzhi(notinum + ""); copylist.add(ue); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } dataMap.put("message", copylist); return SUCCESS; } /** * 根据下拉列表获取家长列表 * * @return */ public String getParentsBySelect() { dataMap = new HashMap(); String typeid = this.request.getParameter("typeid"); String type = this.request.getParameter("type"); String classid = this.request.getParameter("classid"); String account = this.request.getParameter("account"); String schoolid = (String) request.getSession() .getAttribute("schoolid"); String pageindex = request.getParameter("pageindex"); String pagesize = request.getParameter("pagesize"); String userType = (String) request.getSession() .getAttribute("usertype"); String other = request.getParameter("other"); String time = request.getParameter("time"); if (pageindex == null || pageindex.length() == 0) { dataMap.put("result", "faild"); dataMap.put("message", "请输入页码"); } if (pagesize == null || pagesize.length() == 0) { dataMap.put("result", "faild"); dataMap.put("message", "请输入每页显示数量"); } if (account == null || account.length() == 0) { account = ""; } UserManagerServiceImpl usermanager = new UserManagerService(); dataMap.put("result", "success"); ArrayList parentslist = null; int pagequeryIndex = Integer.parseInt(pageindex) * Integer.parseInt(pagesize); int queryPageSize = Integer.parseInt(pagesize); int counts = 0; int allpagesize; if (userType.equals(CommonUtils.userTypeForAdmin) || userType.equals(CommonUtils.business)) { if (type.equals(CommonUtils.str_province)) { parentslist = usermanager.getUserListByProvinceid( pagequeryIndex, queryPageSize, typeid, CommonUtils.parent, account, other, time); counts = usermanager.getTeacherCountByProvince(typeid, CommonUtils.parent, account, other, time); } else if (type.equals(CommonUtils.str_city)) { parentslist = usermanager.getUserListByCityid(pagequeryIndex, queryPageSize, typeid, CommonUtils.parent, account, other, time); counts = usermanager.getTeacherCountByCity(typeid, CommonUtils.parent, account, other, time); } else if (type.equals(CommonUtils.str_area)) { parentslist = usermanager.getUserListByAreaid(pagequeryIndex, queryPageSize, typeid, CommonUtils.parent, account, other, time); counts = usermanager.getTeacherCountByArea(typeid, CommonUtils.parent, account, other, time); } else if (type.equals(CommonUtils.str_school)) { parentslist = usermanager.getUserListBySchoolid(pagequeryIndex, queryPageSize, typeid, CommonUtils.parent, account, other, time); counts = usermanager.getTeacherCount(typeid, CommonUtils.parent, account, other, time); } else { parentslist = usermanager.getUserListByClass(pagequeryIndex, queryPageSize, typeid, CommonUtils.parent, account, other, time); counts = usermanager.getPaeretCountByClassid(typeid, CommonUtils.parent, account, other, time); } } else { parentslist = usermanager.getUserListByClassid(pagequeryIndex, queryPageSize, classid, "0", account, schoolid, CommonUtils.userTypeForParkAdmin, CommonUtils.all); counts = usermanager .getPaeretCount(classid, "0", account, schoolid, CommonUtils.userTypeForParkAdmin, CommonUtils.all); } dataMap.put("message", parentslist); allpagesize = (int) Math.ceil((double) counts / (double) queryPageSize); dataMap.put("result", "success"); dataMap.put("counts", counts); dataMap.put("allpagesize", allpagesize); return SUCCESS; } /** * 根据USERID 获取宝宝信息 */ public String getBabyInformation() { this.dataMap = new HashMap(); String userid = request.getParameter("userid"); if (userid == null || userid.length() == 0) { dataMap.put("result", "faild"); dataMap.put("msg", "请输入userid"); } else { UserManagerServiceImpl umanager = new UserManagerService(); dataMap.put("result", "success"); dataMap.put("msg", umanager.getBabyInformationById(userid)); } return SUCCESS; } /** * 批量设置视频时间 */ public String updateSetupTime() { dataMap = new HashMap(); String userid = request.getParameter("userid"); String endtime = request.getParameter("endtime"); UserManagerServiceImpl userManager = new UserManagerService(); if (userManager.setParentsWatchTime(endtime, userid)) { dataMap.put("result", "success"); dataMap.put("message", "修改成功"); } else { dataMap.put("result", "faild"); dataMap.put("message", "修改失败"); } return SUCCESS; } /** * 根据账户状态获取家长信息 */ public String getUserByOther() { dataMap = new HashMap(); String other = request.getParameter("other"); String condition = request.getParameter("condition"); String time = request.getParameter("time"); String pageindex = request.getParameter("pageindex"); String pagesize = request.getParameter("pagesize"); if (pageindex == null || pageindex.length() == 0) { dataMap.put("result", "faild"); dataMap.put("message", "请输入页码"); } if (pagesize == null || pagesize.length() == 0) { dataMap.put("result", "faild"); dataMap.put("message", "请输入每页显示数量"); } UserManagerServiceImpl usermanager = new UserManagerService(); dataMap.put("result", "success"); ArrayList parentslist = null; int pagequeryIndex = Integer.parseInt(pageindex) * Integer.parseInt(pagesize); int queryPageSize = Integer.parseInt(pagesize); int counts = 0; int allpagesize; parentslist = usermanager.getUserByOther(pagequeryIndex, queryPageSize, other, CommonUtils.parent, time, condition); counts = usermanager.getUserByOtherCount(other, CommonUtils.parent, time, condition); dataMap.put("message", parentslist); allpagesize = (int) Math.ceil((double) counts / (double) queryPageSize); dataMap.put("result", "success"); dataMap.put("counts", counts); dataMap.put("allpagesize", allpagesize); return SUCCESS; } /*** * 以省为条件查询所有附属市的信息 yhz * * @return */ public String getCityListByProvince() { String usertype = this.request.getParameter("usertype"); String areaid = this.request.getParameter("areaid"); String pageNum = request.getParameter("pageNum"); String pageSize = request.getParameter("pageSize"); dataMap = new HashMap(); UserManagerServiceImpl umanager = new UserManagerService(); List l = umanager.getCityListByProvince(usertype, areaid); List rl = new ArrayList<>(); int pn = Integer.parseInt(pageNum); int ps = Integer.parseInt(pageSize); if (pn > 0) { dataMap.put("haspre", true); } else { dataMap.put("haspre", false); } if ((pn + 1) > (l.size() % ps == 0 ? l.size() / ps : (l.size() / ps + 1))) { dataMap.put("hasnext", true); } else { dataMap.put("hasnext", false); } if (l.size() >= (pn + 1) * ps) { rl = l.subList(pn * ps, (pn + 1) * ps); } else { rl = l.subList(pn * ps, l.size()); } dataMap.put("total", l.size()); dataMap.put("result", "success"); dataMap.put("message", rl); return SUCCESS; } /*** * 以省为条件查询所有附属县的信息 yhz * * @return */ public String getTownDetailsByProvince() { String usertype = this.request.getParameter("usertype"); String areaid = this.request.getParameter("areaid"); String pageNum = request.getParameter("pageNum"); String pageSize = request.getParameter("pageSize"); dataMap = new HashMap(); UserManagerServiceImpl umanager = new UserManagerService(); List l = umanager.getTownDetailsByProvince(usertype, areaid); List rl = new ArrayList<>(); int pn = Integer.parseInt(pageNum); int ps = Integer.parseInt(pageSize); if (pn > 0) { dataMap.put("haspre", true); } else { dataMap.put("haspre", false); } if ((pn + 1) > (l.size() % ps == 0 ? l.size() / ps : (l.size() / ps + 1))) { dataMap.put("hasnext", true); } else { dataMap.put("hasnext", false); } if (l.size() >= (pn + 1) * ps) { rl = l.subList(pn * ps, (pn + 1) * ps); } else { rl = l.subList(pn * ps, l.size()); } dataMap.put("total", l.size()); dataMap.put("result", "success"); dataMap.put("message", rl); return SUCCESS; } /*** * 以市为条件查询所有附属县的信息 yhz * * @return */ public String getTownDetailsByCity() { String usertype = this.request.getParameter("usertype"); String areaid = this.request.getParameter("areaid"); String pageNum = request.getParameter("pageNum"); String pageSize = request.getParameter("pageSize"); dataMap = new HashMap(); UserManagerServiceImpl umanager = new UserManagerService(); List l = umanager.getTownDetailsByCity(usertype, areaid); List rl = new ArrayList<>(); int pn = Integer.parseInt(pageNum); int ps = Integer.parseInt(pageSize); if (pn > 0) { dataMap.put("haspre", true); } else { dataMap.put("haspre", false); } if ((pn + 1) > (l.size() % ps == 0 ? l.size() / ps : (l.size() / ps + 1))) { dataMap.put("hasnext", true); } else { dataMap.put("hasnext", false); } if (l.size() >= (pn + 1) * ps) { rl = l.subList(pn * ps, (pn + 1) * ps); } else { rl = l.subList(pn * ps, l.size()); } dataMap.put("total", l.size()); dataMap.put("result", "success"); dataMap.put("message", rl); return SUCCESS; } /*** * 直接查询具体县的信息 yhz * * @return */ public String getTownDetails() { String usertype = this.request.getParameter("usertype"); String areaid = this.request.getParameter("areaid"); String pageNum = request.getParameter("pageNum"); String pageSize = request.getParameter("pageSize"); dataMap = new HashMap(); UserManagerServiceImpl umanager = new UserManagerService(); List l = umanager.getTownDetails(usertype, areaid); List rl = new ArrayList<>(); int pn = Integer.parseInt(pageNum); int ps = Integer.parseInt(pageSize); if (pn > 0) { dataMap.put("haspre", true); } else { dataMap.put("haspre", false); } if ((pn + 1) > (l.size() % ps == 0 ? l.size() / ps : (l.size() / ps + 1))) { dataMap.put("hasnext", true); } else { dataMap.put("hasnext", false); } if (l.size() >= (pn + 1) * ps) { rl = l.subList(pn * ps, (pn + 1) * ps); } else { rl = l.subList(pn * ps, l.size()); } dataMap.put("total", l.size()); dataMap.put("result", "success"); dataMap.put("message", rl); return SUCCESS; } /** * 根据学校ID获取教师列表 */ /** * 加载菜单信息 * * @create 2015年1月16日 上午9:10:19 */ public String menusInfo(){ dataMap = new HashMap(); manager_entity currUser = (manager_entity) getRequest().getSession().getAttribute("curuser"); if(currUser == null){ return "error"; //错误页面 } //超级管理员特殊处理 String super_user = BaseConf.get().getString(BaseConf._ADMINX_SECURITY_SUPER_USER); if(StringUtils.isBlank(StringUtils.trim(super_user))){ super_user = "admin"; //此处需要注意. } List> menusV = new ArrayList>(); List menuList = null; //超级管理加载所有菜单 否则加载用户拥有的菜单 if(super_user.equals(currUser.getUsername())){ menuList = menuInfoService .selectAllMenus(); //cm = new CommonMessage(true, menuList); }else{ UserManagerServiceImpl umanager = new UserManagerService(); Set menuIdSet = umanager.getUserMenuIds(currUser.getRoleIds()); //加载菜单信息列表 menuList = umanager.roLoadUserMenus(menuIdSet); } Map menu = null; for (MenuInfo menuInfo : menuList) { menu = new HashMap(); menu.put("id", menuInfo.getId()); menu.put("pid", menuInfo.getPid()); menu.put("name", menuInfo.getName()); menu.put("urlAddr", menuInfo.getUrlAddr()); menu.put("menuOrder", menuInfo.getMenuOrder()); menu.put("disFlag", menuInfo.getDisFlag()); menu.put("menuImgPath", menuInfo.getMenuImgPath()); menusV.add(menu); } List> menus = new TreeUtil(menusV,"id","pid").getTree(); /* cm = new CommonMessage(true, result); // } String rsMsg = gson.toJson(cm); printAjaxMessage(rsMsg);*/ dataMap.put("menus", menus); return SUCCESS; } /** * @return the menuInfoService */ public MenuInfoService getMenuInfoService() { return menuInfoService; } /** * @param menuInfoService the menuInfoService to set */ public void setMenuInfoService(MenuInfoService menuInfoService) { this.menuInfoService = menuInfoService; } }

2. TreeUtil.java
package com.lecheng.utils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;

import com.lecheng.entity.menu.MenuInfo;
import com.lecheng.utils.demo.SimpleNode;

/**
 * 树工具类
 * @author lengzl
 * @email [email protected]
 * @create 2017年2月22日 下午2:02:06
 */
public class TreeUtil {

	private List> list;
	private String id;
	private String parentId;

	public TreeUtil(List> list, String id, String parentId) {
		this.list = list;
		this.id = id;
		this.parentId = parentId;
	}
	
	/**
	 * 构建树形集合
	 * @return
	 */
	public List> getTree(){
		List> result = new ArrayList<>(); 
		for (Map tmp : list) {
			if (!hasParent(tmp)) {
				setChildren(tmp);
				result.add(tmp);
			}
		}
		return result;
	}
	
	/**
	 * map是否有父节点
	 * 

* list是与map同对象类型的集合 *

* @param map 目标map * @param list 遍历的list * @param id map的id * @param parentid map的父id * @return */ public boolean hasParent(Map map) { boolean flag = false; String key = MapUtils.getString(map, parentId); if (StringUtils.isNotBlank(key)) { for (Map tmp : list) { if (key.equals(MapUtils.getString(tmp, id))) { flag = true; break; } } } return flag; } /** * map是否有子节点 *

* list是与map同对象类型的集合 *

* @param map 目标map * @param list 遍历的list * @param id map的id * @param parentid map的父id * @return */ public boolean hasChild(Map map) { boolean flag = false; String key = MapUtils.getString(map, id); if (StringUtils.isNotBlank(key)) { for (Map tmp : list) { if (key.equals(MapUtils.getString(tmp, parentId))) { flag = true; break; } } } return flag; } /** * 设置子节点 *

* list是与map同对象类型的集合 *

* @param map 目标map * @param list 遍历的list * @param id map的id * @param parentid map的父id */ private void setChildren(Map map) { String key = MapUtils.getString(map, id); if (StringUtils.isNotBlank(key)) { for (Map tmp : list) { if (key.equals(MapUtils.getString(tmp, parentId))) { if (hasChild(tmp)) { setChildren(tmp); } List> children = null; if (map.get("children") == null) { children = new ArrayList<>(); } else { children = (List>) map.get("children"); } children.add(tmp); map.put("children", children); } } } } }


3.left.jsp
<%@page import="com.lecheng.utils.CommonUtils"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/common/commonYouyou.jsp"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String usertype=(String)session.getAttribute("usertype");
%>





有易通幼教综合管理平台








	
功能菜单
  • 三级菜单树的组装与遍历显示_第4张图片
  • 大小: 137.2 KB
  • 三级菜单树的组装与遍历显示_第5张图片
  • 大小: 138.8 KB
  • 三级菜单树的组装与遍历显示_第6张图片
  • 大小: 124.5 KB
  • menus的List-Map数据格式.zip (1.7 KB)
  • 下载次数: 1
  • 查看图片附件

你可能感兴趣的:(html,Jquery)