1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- 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<Map<String, Object>> result = getDeptById(deptdao , parent_id);
- String resultStr = JsonPluginsUtil.listToJson(result);
- log.info("用户习惯使用模块查询::"+resultStr);
- return resultStr;
- }
- public List<Map<String, Object>> getDeptById(DepartmentExcelDao deptdao,String id){
- List<Map<String, Object>> result = deptdao.getDeptByID(id);
- List<Map<String, Object>> depts = new ArrayList<Map<String,Object>>();
-
- if(!result.isEmpty()){
- for(int i=0;i<result.size();i++){
- Map<String, Object> 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<Map<String, Object>> 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;
- }
-
- }
|