Esempio n. 1
0
  private String assemblyCurSubDeptTree(List<Department> subDeptList) {
    StringBuffer strBuf = new StringBuffer();
    for (Department department : subDeptList) {
      strBuf.append("{\"text\" : \"" + department.getDeptName() + "\",");
      strBuf.append("\"id\" : \"" + department.getId() + "\",");
      strBuf.append("\"deptType\" : \"" + department.getDeptType() + "\",");
      HashMap<String, Integer> nameMap = new HashMap<String, Integer>();
      nameMap.put("parentId", department.getId());
      List<Department> list = entityDao.getDepartmentList(nameMap);
      if (list != null && list.size() > 0) {
        strBuf.append("\"leaf\" : false ,");
        strBuf.append("\"cls\" :\"fold\"");
      } else {
        strBuf.append("\"cls\" :'file',");
        strBuf.append("\"leaf\" : true");
      }
      strBuf.append("},");
    }

    if (strBuf.length() > 0) {
      strBuf.delete(strBuf.length() - 1, strBuf.length());
    }

    return strBuf.toString();
  }
Esempio n. 2
0
 private String assemblyParentDeptTree(List<Department> subDeptList) {
   StringBuffer strBuf = new StringBuffer();
   for (int i = subDeptList.size() - 1; i >= 0; i--) {
     Department department = subDeptList.get(i);
     if (i > 0) {
       if (i == subDeptList.size() - 1) {
         strBuf.append("{\"text\" : \"" + department.getDeptName() + "\",");
         strBuf.append("\"id\" : \"" + department.getId() + "\",");
         strBuf.append("\"deptType\" : \"" + department.getDeptType() + "\",");
         strBuf.append("\"leaf\" : false ,");
         strBuf.append("\"cls\" :\"fold\",");
         strBuf.append("\"children\" :[");
       } else {
         strBuf.append("{\"text\" : \"" + department.getDeptName() + "\",");
         strBuf.append("\"id\" : \"" + department.getId() + "\",");
         strBuf.append("\"deptType\" : \"" + department.getDeptType() + "\",");
         strBuf.append("\"leaf\" : false ,");
         strBuf.append("\"cls\" :\"fold\",");
         strBuf.append("\"children\" :[");
       }
     } else {
       strBuf.append("{\"text\" : \"" + department.getDeptName() + "\",");
       strBuf.append("\"id\" : \"" + department.getId() + "\",");
       strBuf.append("\"deptType\" : \"" + department.getDeptType() + "\",");
       strBuf.append("\"cls\" :'file',");
       strBuf.append("\"leaf\" : true");
       for (int j = subDeptList.size() - 1; j >= 0; j--) {
         strBuf.append("}");
         strBuf.append("]");
       }
     }
   }
   if (strBuf.length() > 0) {
     strBuf.delete(strBuf.length() - 1, strBuf.length());
   }
   return strBuf.toString();
 }
Esempio n. 3
0
  public void insertDepartment(Department o) {
    try {
      if (o.getParentId() == 0) {
        o.setParentId(Department.rootNode);
        // o.setParentName(o.getDeptName());
        entityDao.insert(o);
      } else {
        Department dept = this.getDepartmentId(o.getParentId());
        dept.setIsLeaf("n");
        entityDao.update(dept);
        String idPath = dept.getFullIdPath() == null ? "" : dept.getFullIdPath();
        String namePath = dept.getFullNamePath() == null ? "" : dept.getFullNamePath();
        // id全路径格式:/1/2/
        o.setFullIdPath(idPath + dept.getId() + "/");
        o.setFullNamePath(namePath + dept.getDeptName() + "/");
        o.setOrgLever(Integer.valueOf((dept.getOrgLever().intValue() + 1)));

        // o.setParentName(dept.getDeptName());
        entityDao.insert(o);
      }
    } finally {

    }
  }
Esempio n. 4
0
 public String getDepartmentById(String deptId) {
   Department department = this.entityDao.get(Long.valueOf(deptId));
   String deptName = department.getDeptName();
   return deptName;
 }