Exemplo n.º 1
0
  private TeamListVo convertFromTeamToVo(Team team) {
    TeamListVo teamVo = new TeamListVo();
    teamVo.setId(team.getId());
    teamVo.setName(team.getName());
    teamVo.setCode(team.getCode());
    teamVo.setDescription(team.getDescription());
    List<Members> stafflist = membersDao.findMemberByTeam(team.getId()); // 查所有人
    if (stafflist.size() > 0) {
      teamVo.setPeople(stafflist.size());
    } else {
      teamVo.setPeople(0);
    }
    List<Members> membersList = membersDao.findStaffByTeam(team.getId(), 0); // 查成员 修改时显示
    teamVo.setMembersList(membersList);

    List<Members> managerlist = membersDao.findStaffByTeam(team.getId(), 1); // 查负责人   修改时显示
    teamVo.setManagersList(managerlist);

    String manager = "";
    if (managerlist.size() > 0) {
      for (int i = 0; i < managerlist.size(); i++) {
        Members member = new Members();
        member = managerlist.get(i);
        manager = member.getStaff().getName() + "   " + manager;
      }
    }
    teamVo.setManager(manager); // 得到负责人的名字在列表显示
    return teamVo;
  }
  private ChooseOrganizationResponse queryGroup(ChooseOrganizationRequest request) {
    UserContext context = new UserContext();
    context.setCorporationId(request.getSession().getCorporationId());
    context.setUserId(request.getSession().getToken());
    context.setLoginName(request.getSession().getLoginName());
    context.setUserRoles(UserRoleTool.adaptToRole(request.getSession().getUserRoles()));

    TeamListVo teamListVo = new TeamListVo();
    if (request.getCriteria().getPagination() != null) {
      PaginationDetail detail = new PaginationDetail();
      detail.setLimit(request.getCriteria().getPagination().getLimit());
      detail.setStart(request.getCriteria().getPagination().getStart());

      teamListVo.setPaginationDetail(detail);
    }
    if (request.getCriteria().getKey() != null) teamListVo.setName(request.getCriteria().getKey());

    if (request.getCriteria().getSorting() != null) {
      SortingDetail sortingDetail = new SortingDetail();
      sortingDetail.setSort(request.getCriteria().getSorting().getSort());
      sortingDetail.setDirection(request.getCriteria().getSorting().getDirection());
      teamListVo.setSortingDetail(sortingDetail);
    }

    OrganSearchResult rs = new OrganSearchResult();
    List<OrganicationClient> lt = new ArrayList<OrganicationClient>();

    PageStore<TeamListVo> volist = teamService.teamList(context, teamListVo);
    for (TeamListVo team : volist.getResultList()) {
      OrganicationClient client = new OrganicationClient();
      client.setId(team.getId());
      client.setName(team.getName());
      client.setType(OrganType.GROUP);
      lt.add(client);
    }

    rs.setResult(lt);
    rs.setTotal(volist.getResultCount());
    return new ChooseOrganizationResponse(rs);
  }