示例#1
0
  public String getProjectByCompanyId() throws Exception {
    String content = "<option value=\"\">" + CommonUtils.ALL + "</option>"; // 默认值

    String companyId = request.getParameter("companyId");
    try {

      LinkedHashMap<String, String> projectMap =
          HengDaUtils.getProjectsByCompanyId(Integer.parseInt(companyId));

      StringBuffer sb = new StringBuffer();

      if (projectMap.keySet().size() > 1) {
        Set<String> keys = projectMap.keySet();
        for (String key : keys) {
          String value = projectMap.get(key);
          sb.append("<option value=\"").append(key).append("\">").append(value).append("</option>");
        }
      }

      String getContent = sb.toString();
      if (!CustomerUtils.isStrEmpty(getContent)) {
        content = getContent;
      }

    } catch (Exception e) {

    }

    CustomerUtils.writeResponse(response, content);

    return null;
  }
示例#2
0
  private void initSelProject(boolean isGet) {
    selProject = new LinkedHashMap<String, String>();
    selProject.put("", CommonUtils.ALL);

    if (isGet) {
      String getCompanyId = saleWeekCond.getCompanyId();
      if (!CustomerUtils.isStrEmpty(getCompanyId) && !"0".equals(getCompanyId)) {
        selProject = HengDaUtils.getProjectsByCompanyId(Integer.parseInt(getCompanyId));
      }
    }
  }
示例#3
0
  @SuppressWarnings("unchecked")
  public String downLoadWeek() throws Exception {

    try {
      HttpSession session = request.getSession();

      Object getObject = session.getAttribute("saleTypeList");
      List<SaleMonitor> getList = new ArrayList<SaleMonitor>();
      if (getObject != null) {
        getList = (List<SaleMonitor>) getObject;
      }

      HengDaUtils.downLoadTemplate(
          "saleTypeList",
          getList,
          "saleType.xls",
          "download-" + CustomerUtils.getNowForString() + "-.xls",
          response);

    } catch (Exception e) {
      e.printStackTrace();
    }
    return null;
  }
示例#4
0
  public String searchWeek() throws Exception {
    HttpSession session = request.getSession();

    if (saleWeekCond == null) {
      saleWeekCond = new SaleMonitorCond();
    }
    if (CustomerUtils.isStrEmpty(saleWeekCond.getDate1())) {
      saleWeekCond.setDate1(CommonUtils.getWeekFirstForString());
    }
    if (CustomerUtils.isStrEmpty(saleWeekCond.getDate2())) {
      saleWeekCond.setDate2(CommonUtils.getWeekEndForString());
    }

    List<Integer> projectIds = new ArrayList<Integer>();

    String from = request.getParameter("from");
    if ("left".equals(from)) {
      // 此时总是为该登陆用户的projectId

      projectIds = HengDaUtils.getUserProjects();
    } else {
      String getCompanyId = saleWeekCond.getCompanyId();
      int getProjectId = saleWeekCond.getProjectId();

      projectIds = HengDaUtils.getUserProjects();

      if (!CustomerUtils.isStrEmpty(getCompanyId)) {

        if (getProjectId != 0) {
          // 选了单个项目

          projectIds.clear();
          projectIds.add(getProjectId);
        } else {
          // 单个公司下的所有项目

          projectIds =
              HengDaUtils.getUserProjectsByCompanyId(Integer.parseInt(getCompanyId), projectIds);
        }
      }
    }

    initSelCompany();
    initSelProject(true);

    saleWeekCond.setProjectIds(projectIds);
    if (!projectIds.isEmpty()) {
      // 为空时表示该用户在该查询组合下没有符合的记录,不用再去查数据库
      saleTypeList = saleMonitorServices.findSaleMonitorList(saleWeekCond);
    }

    amount = initSaleMonitorWeekAmount(amount, saleTypeList);

    session.setAttribute("saleTypeList", saleTypeList); // 下载使用 ,没有分页不用利用saleWeekCond再查询一次
    session.setAttribute("companyId", saleWeekCond.getCompanyId());
    session.setAttribute("projectId", saleWeekCond.getProjectId());

    // 判断是否公司及项目都是一个,如果都是一个,那么就让公司项目处于选择状态
    LinkedHashMap<String, String> getSelPro = HengDaUtils.setSessionIfCompanyAndProjectOne(request);
    if (getSelPro != null) {
      selProject = getSelPro;
    }

    return "searchWeek";
  }
示例#5
0
 private void initSelCompany() {
   selCompany = HengDaUtils.getSelCompany();
 }