Пример #1
0
  @RequestMapping(value = "/usageDept", produces = "text/html")
  public String usageDept(HttpServletRequest req, HttpServletResponse resp) {

    Hashtable<String, List> deptHash = new Hashtable<String, List>();
    if (Commons.getCurrentSession() != null && Commons.getCurrentSession().getCompanyId() > 0) {
      Company c = Company.findCompany(Commons.getCurrentSession().getCompanyId());
      req.setAttribute("currency", c.getCurrency());
      Set<Department> depts = c.getDepartments();

      for (Iterator iterator = depts.iterator(); iterator.hasNext(); ) {
        Department department = (Department) iterator.next();
        deptHash.put(department.getName(), reportService.findAssets4Department(department.getId()));
      }
    } else {
      List<Company> comps = Company.findAllCompanys();
      req.setAttribute("currency", "All");
      for (Iterator iterator = comps.iterator(); iterator.hasNext(); ) {
        Company company = (Company) iterator.next();
        Set<Department> depts = company.getDepartments();
        for (Iterator iterator1 = depts.iterator(); iterator1.hasNext(); ) {
          Department department = (Department) iterator1.next();
          deptHash.put(
              department.getName() + " @ " + department.getCompany().getName(),
              reportService.findAssets4Department(department.getId()));
        }
      }
    }
    req.setAttribute("deptHash", deptHash);

    return "reports/usageDept";
  }
Пример #2
0
  @RequestMapping(value = "/usageUser", produces = "text/html")
  public String usageUser(HttpServletRequest req, HttpServletResponse resp) {
    Hashtable<String, List> userHash = new Hashtable<String, List>();
    Hashtable<String, String> userSummaryHash = new Hashtable<String, String>();
    if (Commons.getCurrentSession() != null && Commons.getCurrentSession().getCompanyId() > 0) {
      List<User> users = new ArrayList<User>();
      Company c = Company.findCompany(Commons.getCurrentSession().getCompanyId());
      req.setAttribute("currency", c.getCurrency());
      if (Commons.getCurrentUser().getRole().getName().equals(Commons.ROLE.ROLE_SUPERADMIN + "")
          || Commons.getCurrentUser().getRole().getName().equals(Commons.ROLE.ROLE_MANAGER + "")
          || Commons.getCurrentUser().getRole().getName().equals(Commons.ROLE.ROLE_ADMIN + "")) {

        users = User.findUsersByCompany(c).getResultList();
      } else {
        users.add(User.findUser(Commons.getCurrentUser().getId()));
      }

      for (Iterator iterator = users.iterator(); iterator.hasNext(); ) {
        User user = (User) iterator.next();
        // userSummaryHash.put(user.getEmail(), getCost(reportService.findAssets4User(user.getId()))
        // + "");
        userHash.put(user.getEmail(), reportService.findAssets4User(user.getId()));
      }
    } else {
      List<User> users = User.findAllUsers();
      req.setAttribute("currency", "All");
      for (Iterator iterator = users.iterator(); iterator.hasNext(); ) {
        User user = (User) iterator.next();
        // userSummaryHash.put(user.getEmail(), getCost(reportService.findAssets4User(user.getId()))
        // + "");
        userHash.put(user.getEmail(), reportService.findAssets4User(user.getId()));
      }
    }
    req.setAttribute("userHash", userHash);
    // req.setAttribute("userSummaryHash", userSummaryHash);
    return "reports/usageUser";
  }