Beispiel #1
0
  /**
   * 导出积分发放详细
   *
   * @author zhliu
   * @date 2015年7月8日
   * @parm
   * @return
   */
  @RequestMapping("exportPointsGrantDetail")
  public String exportPointsGrantDetail(
      HttpServletResponse response,
      HttpServletRequest request,
      Long distributeId,
      String staffName) {
    List<Object[]> datas = new ArrayList<Object[]>();
    String[] titles = {"工号", "姓名", "性别", "手机号码", "部门", "邮箱", "状态"};
    String excelName = "pointsGrantDetail.xls";
    try {
      // 查询性别字典信息
      List<Dictionary> dictionaryList =
          dictionaryManager.getDictionariesByDictionaryId(IBSConstants.SEX_CONSTANT);
      PageSearch page = preparePage(request);
      PageSearchInit.initcurrentPage(page, request);
      page.setPageSize(Integer.MAX_VALUE);

      page.getFilters()
          .add(
              new PropertyFilter(
                  "PointDistrubute", "EQL_distributeId", String.valueOf(distributeId)));
      if (!org.apache.commons.lang3.StringUtils.isEmpty(staffName)) {
        page.getFilters()
            .add(new PropertyFilter("PointDistrubute", "EQS_staffName", String.valueOf(staffName)));
      }
      List<PointDistrubuteStaff> PointDistrubuteStaffList =
          pointDistrubuteStaffManager.selectPointStaffList(page);

      for (PointDistrubuteStaff pointDis : PointDistrubuteStaffList) {
        String sex = ""; // 性别
        String status = ""; // 状态
        for (Dictionary dict : dictionaryList) {
          if (pointDis.getSex() != null && pointDis.getSex().equals(dict.getValue())) {
            sex = dict.getName();
            break;
          }
        }
        if (pointDis.getStatus() == 0) {
          status = "未领取";
        } else if (pointDis.getStatus() == 1) {
          status = "已领取";
        } else {
          status = "待确认";
        }

        Object[] arr = new Object[titles.length];
        arr[0] = pointDis.getWorkNo();
        arr[1] = pointDis.getStaffName();
        arr[2] = sex;
        arr[3] = pointDis.getTelephone();
        arr[4] = pointDis.getDeptName();
        arr[5] = pointDis.getEmail();
        arr[6] = status;
        datas.add(arr);
      }
      ExcelUtil excelUtil = new ExcelUtil();
      excelUtil.exportExcel(response, datas, titles, excelName);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return null;
  }