package com.sinosoft.lz.system.department; import java.util.*; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.ProduceMime; import org.apache.log4j.Logger; import com.formaction.Utils; import com.sinosoft.common.excel.JsonPluginsUtil; public class DepartmentExcelServise { private final static Logger log = Logger.getLogger(DepartmentExcelServise.class); /** * 查询所有模块 * @param params * @return */ @ProduceMime("application/json") @POST @Path("/getAllDepartment/") public String getAllDepartment(String params){ String parent_id = Utils.getParameter("parent_id", params) == null ? "" : Utils.getParameter("parent_id", params); if("".equals(parent_id)){ parent_id = "BBD3C37F68094363AABC3CAD5FEE0AF8"; } String outerStr = "{\"state\":\"ok\",\"length\":0}"; StringBuffer json = new StringBuffer(); DepartmentExcelDao deptdao = new DepartmentExcelDao(); List> result = getDeptById(deptdao , parent_id); String resultStr = JsonPluginsUtil.listToJson(result); log.info("用户习惯使用模块查询::"+resultStr); return resultStr; } public List> getDeptById(DepartmentExcelDao deptdao,String id){ List> result = deptdao.getDeptByID(id); List> depts = new ArrayList>(); if(!result.isEmpty()){ for(int i=0;i resultMap = result.get(i); String dept_level = resultMap.get("dept_level")+""; String dept_id = resultMap.get("dept_id")+""; if(dept_level!=null&&!"null".equals(dept_level)&&!"".equals(dept_level)){ List> childDept = getDeptById(deptdao,dept_id); //resultMap.put("hasDept", true); if("BBD3C37F68094363AABC3CAD5FEE0AF8".equals(id)){ resultMap.put("open", true); }else{ resultMap.put("open", false); } resultMap.put("children", childDept); depts.add(resultMap); }else{ //resultMap.put("hasDept", false); resultMap.put("open", false); resultMap.put("children", null); depts.add(resultMap); } } } return depts; } }