Ejemplo n.º 1
0
 @Override
 public List<DepartmentModel> getAllDepartments() throws ServiceException {
   // TODO Auto-generated method stub
   //		List<DepartmentModel> list= departmentDAO.getAllDepartments();
   //		for(DepartmentModel d:list){
   //			System.out.println(d.getSubordinateSchoolDepartments().size());
   //		}
   return departmentDAO.getAllDepartments();
 }
Ejemplo n.º 2
0
 @Override
 public Boolean deleteDepartment(String id) throws ServiceException {
   // TODO Auto-generated method stub
   //		DepartmentModel model=departmentDAO.get(id);
   //		if(model==null)return false;
   //		departmentDAO.remove(model);
   String sql = "delete from xdjy_department where id =" + id;
   departmentDAO.execUpdateByNativeSQL(sql);
   return true;
 }
Ejemplo n.º 3
0
  @Override
  public DepartmentModel saveDepartment(
      DepartmentModel clientDepartment,
      String parentDepartmentId,
      String headSchoolDepartmentId,
      String masterUserIds,
      String leaderUserIds) {
    if (StringUtils.isEmpty(clientDepartment.getId())) {
      if (StringUtils.isNotEmpty(masterUserIds)) {
        String[] masterIds = masterUserIds.split(";");
        for (String id : masterIds) {
          UserModel user = userDAO.get(id);
          if (user != null && !clientDepartment.getMasterStaffs().contains(user))
            clientDepartment.getMasterStaffs().add(user);
        }
      }
      if (StringUtils.isNotEmpty(leaderUserIds)) {
        String[] leaderIds = leaderUserIds.split(";");
        for (String id : leaderIds) {
          UserModel user = userDAO.get(id);
          if (user != null && !clientDepartment.getLeaderStaffs().contains(user))
            clientDepartment.getLeaderStaffs().add(user);
        }
      }
      if (StringUtils.isEmpty(parentDepartmentId)) {
        if (StringUtils.isNotEmpty(headSchoolDepartmentId)) {
          clientDepartment
              .getHeadSchoolLeaderDepartments()
              .add(departmentDAO.get(headSchoolDepartmentId));
        }
        departmentDAO.saveOrUpdate(clientDepartment);
        return clientDepartment;
      } else {
        DepartmentModel parent = departmentDAO.get(parentDepartmentId);
        if (parent == null) return null;
        else {
          // 以下代码 2012.4.5 ysc 解决增加报错问题
          departmentDAO.saveOrUpdate(clientDepartment);
          // 以上代码 2012.4.5 ysc 解决增加报错问题
          parent.getChildDepartments().add(clientDepartment);
          if (StringUtils.isNotEmpty(headSchoolDepartmentId)) {
            clientDepartment
                .getHeadSchoolLeaderDepartments()
                .add(departmentDAO.get(headSchoolDepartmentId));
          }
          departmentDAO.saveOrUpdate(parent);
          return clientDepartment;
        }
      }
    } else {

      DepartmentModel dbDepartment = departmentDAO.get(clientDepartment.getId());
      dbDepartment.setName(clientDepartment.getName());
      dbDepartment.setDetail(clientDepartment.getDetail());
      dbDepartment.setLevel(clientDepartment.getLevel());
      dbDepartment.setPhone(clientDepartment.getPhone());
      dbDepartment.setCreationDate(clientDepartment.getCreationDate());
      dbDepartment.setSequence(clientDepartment.getSequence());
      dbDepartment.setSchoolId(clientDepartment.getSchoolId());
      dbDepartment.setHrFlag(clientDepartment.getHrFlag());
      dbDepartment.setLearnManageFlag(clientDepartment.getLearnManageFlag());
      dbDepartment.setTechFlag(clientDepartment.getTechFlag());
      dbDepartment.setConsultFlag(clientDepartment.getConsultFlag());
      dbDepartment.setConsultantFlag(clientDepartment.getConsultantFlag());
      if (StringUtils.isNotEmpty(headSchoolDepartmentId)) {
        dbDepartment.getHeadSchoolLeaderDepartments().clear();
        dbDepartment
            .getHeadSchoolLeaderDepartments()
            .add(departmentDAO.get(headSchoolDepartmentId));
      }
      dbDepartment.getMasterStaffs().clear();
      if (StringUtils.isNotEmpty(masterUserIds)) {
        String[] masterIds = masterUserIds.split(";");
        for (String id : masterIds) {
          UserModel user = userDAO.get(id);
          if (user != null && !dbDepartment.getMasterStaffs().contains(user))
            dbDepartment.getMasterStaffs().add(user);
        }
      }
      dbDepartment.getLeaderStaffs().clear();
      if (StringUtils.isNotEmpty(leaderUserIds)) {
        String[] leaderIds = leaderUserIds.split(";");
        for (String id : leaderIds) {
          UserModel user = userDAO.get(id);
          if (user != null && !dbDepartment.getLeaderStaffs().contains(user))
            dbDepartment.getLeaderStaffs().add(user);
        }
      }
      departmentDAO.saveOrUpdate(dbDepartment);
      return dbDepartment;
    }
  }
Ejemplo n.º 4
0
 @Override
 public List<DepartmentModel> getAllFirstLevelDepartments() throws ServiceException {
   return departmentDAO.getAllFirstLevelDepartments();
 }
Ejemplo n.º 5
0
 @Override
 public List<DepartmentModel> getDepartmentBySchool(String school) throws ServiceException {
   // TODO Auto-generated method stub
   return departmentDAO.getDepartmentBySchool(school);
 }
Ejemplo n.º 6
0
 @Override
 public DepartmentModel getDepartment(String id) throws ServiceException {
   // TODO Auto-generated method stub
   return departmentDAO.get(id);
 }