package com.zcloud.controller.system; import java.util.*; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.zcloud.aspect.DockAnnotation; import com.zcloud.entity.system.User; import com.zcloud.service.system.PostService; import com.zcloud.service.system.SupervisionDepartmentService; import com.zcloud.util.DateUtil; import com.zcloud.util.ObjectExcelView; import net.sf.json.JSONArray; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.checkerframework.checker.units.qual.A; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.zcloud.controller.base.BaseController; import com.zcloud.entity.Page; import com.zcloud.entity.PageData; import com.zcloud.entity.system.Department; import com.zcloud.service.bus.ListManagerService; import com.zcloud.service.system.DepartmentService; import com.zcloud.service.system.UsersService; import com.zcloud.util.Jurisdiction; import com.zcloud.util.Tools; import org.springframework.web.servlet.ModelAndView; /** * 说明:组织机构 * 作者:luoxiaobao * 官网:www.fhadmin. org */ @Controller @RequestMapping("/department") public class DepartmentController extends BaseController { @Autowired private DepartmentService departmentService; @Autowired private UsersService usersService; @Autowired private ListManagerService listManagerService; @Autowired private SupervisionDepartmentService supervisionDepartmentService; @Autowired private PostService postService; /** * 新增 * * @param * @throws Exception */ @RequestMapping(value = "/add") @RequiresPermissions("department:add") @ResponseBody @DockAnnotation(isAdd = true) public Object add(Page page) throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); PageData pageData1 = new PageData(); pageData1.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); pageData1.put("NAME", pd.getString("NAME")); List varList1 = departmentService.isrepeat(pageData1); if (varList1.size() > 0) { map.put("msg", "部门机构已经重复"); return map; } pd.put("DEPARTMENT_ID", this.get32UUID()); //主键 pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业 departmentService.save(pd); // 存储监管单位 if (pd != null && pd.get("ISSUPERVISE") != null && Tools.notEmpty(pd.get("ISSUPERVISE").toString()) && "1".equals(pd.get("ISSUPERVISE").toString()) && pd.get("checkedIds") != null && Tools.notEmpty(pd.get("checkedIds").toString()) && pd.get("checkedIds").toString().length() > 0) { String checkedIds[] = pd.get("checkedIds").toString().split(","); for (String subId : checkedIds) { PageData sd = new PageData(); sd.put("SUPERVISIONDEPARTMENT_ID", this.get32UUID()); sd.put("SUP_DEPARTMENT_ID", pd.get("DEPARTMENT_ID")); sd.put("SUB_DEPARTMENT_ID", subId); sd.put("ISDELETE", "0"); sd.put("CORPINFO_ID", pd.get("CORPINFO_ID")); sd.put("CREATOR", Jurisdiction.getName()); // 添加人 sd.put("CREATTIME", DateUtil.date2Str(new Date())); // 创建时间 sd.put("OPERATOR", Jurisdiction.getName()); // 修改人 sd.put("OPERATTIME", DateUtil.date2Str(new Date())); supervisionDepartmentService.save(sd); } } map.put("result", errInfo); //返回结果 map.put("dockData", JSON.toJSONString(pd)); return map; } /** * 显示列表ztree(只查企业端部门) * * @return */ @RequestMapping(value = "/listTreeManageAndCorp2") @ResponseBody public Object listTreeManageAndCorp2() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd.put("DEPARTMENT_ID", "0"); //查询父节点为0的根节点数据 List rootList = departmentService.listTreeManageAndCorp2(pd); JSONArray arr = JSONArray.fromObject(rootList); map.put("zTreeNodes", arr.toString()); map.put("result", errInfo); return map; } /** * 显示列表ztree(只查某几个企业端部门) * * @return */ @RequestMapping(value = "/listTreeManageAndCorpNum") @ResponseBody public Object listTreeManageAndCorpNum() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); String[] lists = pd.getString("INVOLVING_CORPS").split(","); List corpId = new ArrayList<>(); for (int i = 0; i < lists.length; i++) { corpId.add(lists[i]); } pd.put("corpId", corpId); List rootList = departmentService.listTreeManageAndCorpNum(pd); JSONArray arr = JSONArray.fromObject(rootList); map.put("zTreeNodes", arr.toString()); map.put("result", errInfo); return map; } /** * 删除 * * @param DEPARTMENT_ID * @param * @throws Exception */ @RequestMapping(value = "/delete") @RequiresPermissions("department:del") @ResponseBody @DockAnnotation public Object delete(@RequestParam String DEPARTMENT_ID) throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd.put("DEPARTMENT_ID", DEPARTMENT_ID); if (departmentService.listSubDepartmentByParentId(DEPARTMENT_ID).size() > 0) {//判断是否有子级,是:不允许删除 errInfo = "fail"; map.put("result", "errInfo"); //返回结果 map.put("msg", "该部门有下级部门,请先删除下级部门"); return map; } else if (usersService.listUserbyDep(pd).size() > 0) { errInfo = "haveUser"; map.put("msg", "此部门内有相关人员,无法删除"); } else if (listManagerService.listListByDep(pd).size() > 0) { errInfo = "havelist"; map.put("msg", "此部门内有部门清单,无法删除"); } else if (postService.listAll(pd).size() > 0) { errInfo = "havelist"; map.put("msg", "此部门内有岗位,无法删除"); } else { departmentService.delete(pd); //执行删除 } map.put("dockData","对接接口"); map.put("result", errInfo); //返回结果 return map; } /** * 修改 * * @param * @throws Exception */ @RequestMapping(value = "/edit") @RequiresPermissions("department:edit") @ResponseBody @DockAnnotation public Object edit() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = this.getPageData(); PageData pageData1 = new PageData(); pageData1.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); pageData1.put("NAME", pd.getString("NAME")); List varList1 = departmentService.isrepeat(pageData1); if (varList1.size() > 1) { map.put("msg", "部门机构已经重复"); return map; } else { // 只有一个 看看是不是自己 如果是自己那么修改 if (varList1.size() > 0) { PageData sData = varList1.get(0); if (!sData.getString("DEPARTMENT_ID").equals(pd.getString("DEPARTMENT_ID"))) { map.put("msg", "部门机构已经重复"); return map; } } } departmentService.edit(pd); // 删除旧的监管单位 PageData pd2 = new PageData(); pd2.put("SUP_DEPARTMENT_ID", pd.get("DEPARTMENT_ID")); pd2.put("OPERATOR", Jurisdiction.getName()); // 修改人 pd2.put("OPERATTIME", DateUtil.date2Str(new Date())); supervisionDepartmentService.deleteByDept(pd2); // 存储监管单位 if (pd != null && pd.get("ISSUPERVISE") != null && Tools.notEmpty(pd.get("ISSUPERVISE").toString()) && "1".equals(pd.get("ISSUPERVISE").toString()) && pd.get("checkedIds") != null && Tools.notEmpty(pd.get("checkedIds").toString()) && pd.get("checkedIds").toString().length() > 0) { String checkedIds[] = pd.get("checkedIds").toString().split(","); for (String subId : checkedIds) { PageData sd = new PageData(); sd.put("SUPERVISIONDEPARTMENT_ID", this.get32UUID()); sd.put("SUP_DEPARTMENT_ID", pd.get("DEPARTMENT_ID")); sd.put("SUB_DEPARTMENT_ID", subId); sd.put("ISDELETE", "0"); sd.put("CORPINFO_ID", pd.get("CORPINFO_ID")); sd.put("CREATOR", Jurisdiction.getName()); // 添加人 sd.put("CREATTIME", DateUtil.date2Str(new Date())); // 创建时间 sd.put("OPERATOR", Jurisdiction.getName()); // 修改人 sd.put("OPERATTIME", DateUtil.date2Str(new Date())); supervisionDepartmentService.save(sd); } } map.put("result", errInfo); //返回结果 map.put("dockData","对接接口"); return map; } /** * 列表 * * @param page * @throws Exception */ @RequestMapping(value = "/list") @RequiresPermissions("department:list") @ResponseBody public Object list(Page page) throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); String CORPINFO_ID = Jurisdiction.getCORPINFO_ID(); String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件 if (Tools.notEmpty(KEYWORDS)) pd.put("keywords", KEYWORDS.trim()); String DEPARTMENT_ID = null == pd.get("DEPARTMENT_ID") ? "" : pd.get("DEPARTMENT_ID").toString(); pd.put("DEPARTMENT_ID", DEPARTMENT_ID); //当作上级ID pd.put("CORPINFO_ID", CORPINFO_ID); //当作上级ID page.setPd(pd); List varList = departmentService.listForLevelName(page); //列出Department列表 if ("".equals(DEPARTMENT_ID) || "0".equals(DEPARTMENT_ID)) { map.put("PARENT_ID", "0"); //上级ID } else { map.put("PARENT_ID", departmentService.findById(pd).getString("PARENT_ID")); //上级ID map.put("LEVEL", departmentService.findById(pd).getString("LEVEL")); } map.put("varList", varList); map.put("page", page); map.put("result", errInfo); return map; } /** * 显示列表ztree * * @return */ @RequestMapping(value = "/listTree") @RequiresPermissions("department:list") @ResponseBody public Object listTree() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); String url = pd.get("url") == null ? "department_list.html?DEPARTMENT_ID=" : pd.getString("url"); // String ZDEPARTMENT_ID = Jurisdiction.getDEPARTMENT_ID(); // ZDEPARTMENT_ID = "".equals(ZDEPARTMENT_ID)?"0":ZDEPARTMENT_ID; // List zdepartmentPdList = new ArrayList(); // // PageData dept = new PageData(); // dept.put("DEPARTMENT_ID",ZDEPARTMENT_ID); // dept=this.departmentService.findById(dept); //获取部门下拉树 List zdepartmentPdList = new ArrayList(); PageData dept = new PageData(); dept.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); dept = this.departmentService.findByCorpId(dept); Department depar = new Department(); depar.setDEPARTMENT_ID(dept.getString("DEPARTMENT_ID")); depar.setPARENT_ID(dept.getString("PARENT_ID")); depar.setBIANMA(dept.getString("LEVEL")); depar.setNAME(dept.getString("NAME")); depar.setTreeurl(url + depar.getDEPARTMENT_ID()); depar.setSubDepartment(this.departmentService.listAllDepartment(depar.getDEPARTMENT_ID(), url)); depar.setTarget("treeFrame"); depar.setIcon("../../../assets/images/user.gif"); zdepartmentPdList.add(depar); // zdepartmentPdList.addAll(departmentService.listAllDepartment(ZDEPARTMENT_ID)); JSONArray arr = JSONArray.fromObject(zdepartmentPdList); String json = arr.toString(); json = json.replaceAll("DEPARTMENT_ID", "id").replaceAll("PARENT_ID", "pId").replaceAll("NAME", "name").replaceAll("subDepartment", "nodes").replaceAll("hasDepartment", "checked").replaceAll("treeurl", "url").replaceAll("BIANMA", "LEVEL"); map.put("USER_ID", Jurisdiction.getUSER_ID()); map.put("zTreeNodes", json); map.put("result", errInfo); return map; } /** * 显示列表ztree * * @return */ @RequestMapping(value = "/scanlistTree") @ResponseBody public Object scanlistTree() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); String url = pd.get("url") == null ? "department_list.html?DEPARTMENT_ID=" : pd.getString("url"); //获取部门下拉树 List zdepartmentPdList = new ArrayList(); PageData dept = new PageData(); dept.put("CORPINFO_ID", "13cf0f4ec77e4d98ae8cdd9c3386ae0c"); dept = this.departmentService.findByCorpId(dept); Department depar = new Department(); depar.setDEPARTMENT_ID(dept.getString("DEPARTMENT_ID")); depar.setPARENT_ID(dept.getString("PARENT_ID")); depar.setBIANMA(dept.getString("BIANMA")); depar.setNAME(dept.getString("NAME")); depar.setTreeurl(url + depar.getDEPARTMENT_ID()); depar.setSubDepartment(this.departmentService.listAllDepartment(depar.getDEPARTMENT_ID(), url)); depar.setTarget("treeFrame"); depar.setIcon("../../../assets/images/user.gif"); zdepartmentPdList.add(depar); // zdepartmentPdList.addAll(departmentService.listAllDepartment(ZDEPARTMENT_ID)); JSONArray arr = JSONArray.fromObject(zdepartmentPdList); String json = arr.toString(); json = json.replaceAll("DEPARTMENT_ID", "id").replaceAll("PARENT_ID", "pId").replaceAll("NAME", "name").replaceAll("subDepartment", "nodes").replaceAll("hasDepartment", "checked").replaceAll("treeurl", "url").replaceAll("BIANMA", "LEVEL"); //map.put("USER_ID", Jurisdiction.getUSER_ID()); map.put("zTreeNodes", json); map.put("result", errInfo); return map; } /** * 去新增页面 * * @param * @throws Exception */ @RequestMapping(value = "/goAdd") @RequiresPermissions("department:add") @ResponseBody public Object goAdd() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); String DEPARTMENT_ID = ""; if (!Tools.isEmpty(pd.get("DEPARTMENT_ID"))) { DEPARTMENT_ID = pd.get("DEPARTMENT_ID").toString(); } PageData dept = departmentService.findById(pd); if (dept.getString("DEPARTMENT_ID").equals(Jurisdiction.getCORPINFO_ID())) { dept.put("LEVEL", "departmentLevel0001"); } pd.put("DEPARTMENT_ID", DEPARTMENT_ID); //上级ID map.put("pds", dept); //传入上级所有信息 map.put("result", errInfo); return map; } /** * 去修改页面 * * @param * @throws Exception */ @RequestMapping(value = "/goEdit") @RequiresPermissions("department:edit") @ResponseBody public Object goEdit() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); pd = departmentService.findById(pd); //根据ID读取 List userList = usersService.getDepartmentId(pd.getString("PARENT_ID")); List thisDepartmanetList = usersService.getDepartmentId(pd.getString("DEPARTMENT_ID")); if (Tools.notEmpty(pd.getString("checkedIds"))) { String[] checkedIds = pd.getString("checkedIds").split(","); String DEPENAME = ""; for (int i = 0; i < checkedIds.length; i++) { PageData pd1 = new PageData(); pd1.put("DEPARTMENT_ID", checkedIds[i]); PageData de = departmentService.findById(pd1); if (null != de) { if (i == 0) { DEPENAME += de.getString("NAME"); } else { DEPENAME += "," + de.getString("NAME"); } } } pd.put("DEPTNAME", DEPENAME); } map.put("pd", pd); //放入视图容器 // pd.put("DEPARTMENT_ID",pd.get("PARENT_ID").toString()); //用作上级信息 map.put("pds", departmentService.findById(pd)); //传入上级所有信息 map.put("LEADER_CHARGE", userList); map.put("THISDEPARTMENT", thisDepartmanetList); map.put("result", errInfo); return map; } /** * 去修改页面 * * @param * @throws Exception */ @RequestMapping(value = "/getById") @ResponseBody public Object getById() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); pd = departmentService.findById(pd); //根据ID读取 map.put("pd", pd); //放入视图容器 map.put("result", errInfo); return map; } /** * 判断编码是否存在 * * @return */ @RequestMapping(value = "/hasBianma") @ResponseBody public Object hasBianma() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); if (departmentService.findByBianma(pd) != null) { errInfo = "fail"; } map.put("result", errInfo); //返回结果 return map; } /** * 判断部门等级 如果没有上一级就是1 * * @return */ @RequestMapping(value = "/parentGrade") @ResponseBody public Object parentGrade() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); String deptGrade = getparentId(pd.getString("deptGrade")) + ""; map.put("deptGrade", deptGrade); map.put("result", errInfo); //返回结果 return map; } /** * @return */ public Integer getparentId(String parentId) throws Exception { Integer parentGrade = 1; PageData parentDepePd = new PageData(); parentDepePd.put("DEPARTMENT_ID", parentId); PageData parent = departmentService.findById(parentDepePd); if (!Tools.isEmpty(parent)) { parentId = parent.getString("PARENT_ID"); if (!"0".equals(parentId)) { parentGrade = getparentId(parentId); parentGrade++; } } return parentGrade; } /** * 判断同等级的名字是否重复 * * @return */ @RequestMapping(value = "/hasName") @ResponseBody public Object hasName() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); PageData parentDepePd = new PageData(); parentDepePd.put("NAME", pd.getString("name")); parentDepePd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); parentDepePd.put("ISEDIT", "1"); parentDepePd.put("DEPARTMENT_ID", pd.get("DEPARTMENT_ID")); //就是父id相同的名字 PageData parent = departmentService.findByName(parentDepePd); if (!Tools.isEmpty(parent)) { errInfo = "fail"; } map.put("result", errInfo); //返回结果 return map; } @RequestMapping(value = "/listAllByState") @ResponseBody public Object listAllDict() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); List deptByState = departmentService.listAll(pd); JSONArray arr = JSONArray.fromObject(deptByState); String json = arr.toString(); json = json.replaceAll("DEPARTMENT_ID", "id").replaceAll("PARENT_ID", "pId").replaceAll("NAME", "name").replaceAll("subDict", "nodes").replaceAll("hasDict", "checked").replaceAll("treeurl", "url"); map.put("zTreeNodes", json); map.put("result", errInfo); return map; } /** * 显示列表ztree * * @return */ @RequestMapping(value = "/listTreeCorpDept") @ResponseBody public Object listTreeCorpDept() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); pd.put("DEPARTMENT_ID", Jurisdiction.getCORPINFO_ID()); //查询父节点为0的根节点数据 List rootList = departmentService.listTreeCorpDept(pd); JSONArray arr = JSONArray.fromObject(rootList); map.put("zTreeNodes", arr.toString()); map.put("result", errInfo); return map; } /** * 去修改页面 * * @param * @throws Exception */ @RequestMapping(value = "/goEditByLeaderOrCharge") @RequiresPermissions("department:edit") @ResponseBody @DockAnnotation public Object goEditByLeader() throws Exception { Map map = new HashMap(); String errInfo = "fail"; PageData pd = new PageData(); pd = this.getPageData(); PageData goEditPd = new PageData(); goEditPd.put("DEPARTMENT_ID", pd.getString("DEPARTMENT_ID")); if ("1".equals(pd.getString("type"))) { goEditPd.put("HEADMAN", pd.get("HEADMAN")); } else if ("2".equals(pd.getString("type"))) { goEditPd.put("LEADER_CHARGE", pd.get("LEADER_CHARGE")); } else { map.put("result", errInfo); return map; } departmentService.editByLeaderOrCharge(goEditPd); map.put("result", "success"); map.put("dockData","对接接口"); return map; } /** * 去修改页面 * * @param * @throws Exception */ @RequestMapping(value = "/goUserByLeaderOrCharge") @RequiresPermissions("department:edit") @ResponseBody public Object goUserByLeaderOrCharge() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); PageData goEditPd = new PageData(); PageData depart = departmentService.findById(pd); PageData user = new PageData(); if (!Tools.isEmpty(depart)) { PageData userPd = new PageData(); if ("".equals(pd.getString("type"))) { userPd.put("USER_ID", depart.getString("HEADMAN")); } if ("".equals(pd.getString("type"))) { userPd.put("USER_ID", depart.getString("LEADER_CHARGE")); } user = usersService.findById(userPd); } map.put("departPerson", user); map.put("result", "success"); return map; } /** * 列表 * * @throws Exception */ @RequestMapping(value = "/listForDoor") @ResponseBody public Object listForDoor() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); String CORPINFO_ID = Jurisdiction.getCORPINFO_ID(); pd.put("CORPINFO_ID", CORPINFO_ID); //当作上级ID List varList = departmentService.listForDoor(pd); //列出Department列表 map.put("list", varList); map.put("result", errInfo); return map; } /** * 导出到excel * * @param * @throws Exception */ @RequestMapping(value = "/excels") // @RequiresPermissions("toExcel") public ModelAndView exportExcels() throws Exception { ModelAndView mv = new ModelAndView(); PageData pd = new PageData(); pd = this.getPageData(); pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); Map dataMap = new HashMap(); List titles = new ArrayList(); titles.add("名称"); //1 titles.add("负责人"); //2 titles.add("部门级别"); //3 dataMap.put("titles", titles); List varOList = departmentService.islistAll(pd); List varList = new ArrayList(); for (int i = 0; i < varOList.size(); i++) { PageData vpd = new PageData(); vpd.put("var1", varOList.get(i).getString("NAME")); //1 vpd.put("var2", varOList.get(i).getString("HEADMAN_NAME")); //2 vpd.put("var3", varOList.get(i).getString("leName")); //3 varList.add(vpd); } dataMap.put("varList", varList); dataMap.put("filename", "部门信息"); ObjectExcelView erv = new ObjectExcelView(); mv = new ModelAndView(erv, dataMap); return mv; } /** * 显示列表ztree * * @return */ @RequestMapping(value = "/listTreeV2") @RequiresPermissions("department:list") @ResponseBody public Object listTreeV2() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); String url = pd.get("url") == null ? "department_list.html?DEPARTMENT_ID=" : pd.getString("url"); JSONArray arr = JSONArray.fromObject(this.departmentService.listAllDepartmentV2("0", url)); String json = arr.toString(); json = json.replaceAll("DEPARTMENT_ID", "id").replaceAll("PARENT_ID", "pId").replaceAll("NAME", "name").replaceAll("subDepartment", "nodes").replaceAll("hasDepartment", "checked").replaceAll("treeurl", "url").replaceAll("BIANMA", "LEVEL"); map.put("USER_ID", Jurisdiction.getUSER_ID()); map.put("zTreeNodes", json); map.put("result", errInfo); return map; } /** * 显示列表ztree(只查监管端部门) * * @return */ @RequestMapping(value = "/listTreeManageAndCorp1") @ResponseBody public Object listTreeManageAndCorp1() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd.put("DEPARTMENT_ID", "0"); //查询父节点为0的根节点数据 List rootList = departmentService.listTreeManageAndCorp1(pd); JSONArray arr = JSONArray.fromObject(rootList); map.put("zTreeNodes", arr.toString()); map.put("result", errInfo); return map; } /** * 显示列表ztree(集团部门+子公司部门) * * @return */ @RequestMapping(value = "/listTreeManageAndCorpForPcPunishThePerson") @ResponseBody public Object listTreeManageAndCorpForPcPunishThePerson() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); String ids = pd.getString("ids"); if (!Tools.isEmpty(ids)) { List list = JSONObject.parseArray(ids,String.class); if (list.size()==0){ map.put("zTreeNodes", "[]"); map.put("result", errInfo); return map; }else { pd.put("ids", list); } } pd.put("DEPARTMENT_ID", "0"); //查询父节点为0的根节点数据 List rootList = departmentService.listTreeManageAndCorpForPcPunishThePerson(pd); JSONArray arr = JSONArray.fromObject(rootList); map.put("zTreeNodes", arr.toString()); map.put("result", errInfo); return map; } }