public void calculateData() {

    this.upFlushKb = CommonUtils.formatBToKb(this.upFlush);
    this.downFlushKb = CommonUtils.formatBToKb(this.downFlush);
    this.totalFlushKb = CommonUtils.formatBToKb(this.totalFlush);

    this.upFlushMb = CommonUtils.formatBToMb(this.upFlush);
    this.downFlushMb = CommonUtils.formatBToMb(this.downFlush);
    this.totalFlushMb = CommonUtils.formatBToMb(this.totalFlush);

    this.upFlushGb = CommonUtils.formatBToGb(this.upFlush);
    this.downFlushGb = CommonUtils.formatBToGb(this.downFlush);
    this.totalFlushGb = CommonUtils.formatBToGb(this.totalFlush);

    NumberFormat germanformat = NumberFormat.getInstance(Locale.CHINA);

    this.formatUpFlush = germanformat.format(this.upFlush);
    this.formatUpFlushKb = germanformat.format(this.upFlushKb);
    this.formatUpFlushMb = germanformat.format(this.upFlushMb);
    this.formatUpFlushGb = germanformat.format(this.upFlushGb);

    this.formatDownFlush = germanformat.format(this.downFlush);
    this.formatDownFlushKb = germanformat.format(this.downFlushKb);
    this.formatDownFlushMb = germanformat.format(this.downFlushMb);
    this.formatDownFlushGb = germanformat.format(this.downFlushGb);

    this.formatTotalFlush = germanformat.format(this.totalFlush);
    this.formatTotalFlushKb = germanformat.format(this.totalFlushKb);
    this.formatTotalFlushMb = germanformat.format(this.totalFlushMb);
    this.formatTotalFlushGb = germanformat.format(this.totalFlushGb);

    this.formatCount = germanformat.format(this.count);

    this.fullDate = this.year + "-" + this.month;
  }
  /** 页面视图数据 */
  private List formatViewData(List<TbBaseUserInfo> list) {
    List maplist = new ArrayList();
    Map map;
    TbBaseUserInfo bean;
    if (list != null && list.size() > 0) {
      for (int i = 0; i < list.size(); i++) {
        bean = list.get(i);
        VBaseUserInfo view = baseUserInfoManager.converBeanToView(bean);
        map = new LinkedHashMap();
        map.put("id", view.getId());
        map.put("vcLoginName", CommonUtils.killNull(view.getVcLoginName()));
        map.put("vcUserName", CommonUtils.killNull(view.getVcUserName()));
        map.put("vcMobel", CommonUtils.killNull(view.getVcMobel()));
        map.put("vcEmail", CommonUtils.killNull(view.getVcEmail()));
        map.put("vcTelephone", CommonUtils.killNull(view.getVcTelephone()));
        map.put("roleName", CommonUtils.killNull(view.getRoleName()));
        map.put("deptName", CommonUtils.killNull(view.getDeptName()));

        map.put("tiUserType", CommonUtils.killNull(view.getTiUserType()));
        map.put("vcPassword", CommonUtils.killNull(view.getVcPassword()));
        maplist.add(map);
      }
    }
    return maplist;
  }
 /** 导出 */
 public void export() throws ServletException, IOException {
   if (this.searchdate == null) {
     this.searchdate = CommonUtils.getSYestoday();
   }
   List<TopStat> list = null;
   GridServerHandler gridServerHandler =
       new GridServerHandler(Struts2Utils.getRequest(), Struts2Utils.getResponse());
   list = topFlushAndImsiManager.findTopStatImsi(raittype, stattype, searchdate);
   String exportmsg = ExportMsg.EXPORT_FLUSH_TOPUSER + "(" + searchdate + ")";
   commonManagerImpl.log(Struts2Utils.getRequest(), exportmsg);
   gridServerHandler.exportXLS(list, TopStat.class);
 }
  /**
   * 组装总流量数据
   *
   * @param dataType
   * @param spaceLevel
   * @param areaName
   * @param timeLevel
   * @param time
   * @return
   */
  public String packTotalData(
      String dataType,
      String spaceLevel,
      String areaName,
      String timeLevel,
      String time,
      int pageSize) {
    Page<CommonFlush> newPage = new Page<CommonFlush>();
    newPage.setPageNo(1);
    newPage.setOrder("desc");
    newPage.setOrderBy("nmFlush");
    newPage.setPageSize(pageSize);
    newPage =
        spaceDistributeBusinessManager.query(
            newPage,
            Integer.parseInt(dataType),
            Common.StringToInt(spaceLevel),
            areaName,
            Common.StringToInt(timeLevel),
            time);
    List<CommonFlush> totalList = newPage.getResult();

    // 去掉名称为其他的数据
    totalList = DataFormatUtils.exceptCommonFlush(totalList, "其他");
    if (totalList.size() > 20) { // 如果数据大于20条
      totalList.remove(20);
    }

    if (Common.StringToInt(timeLevel) == 3) {
      time = CommonUtils.getDayInnerWeek(time);
    }
    String chartLabel = time + " 总流量TOP20分布图";
    String totalXml =
        "<root><chart id=\"1\"leftformat=\"true\"  name=\"" + chartLabel + "\" fields=\"流量|\">";
    if (totalList != null && !totalList.isEmpty()) {
      for (CommonFlush c : totalList) {
        totalXml =
            totalXml
                + "<data label=\""
                + c.getBusinessName()
                + "\" shortlabel=\""
                + formatChartName(c.getBusinessName())
                + "\" total=\""
                + c.getTotalFlush()
                + "\"/>";
      }
    }
    totalXml = totalXml + "</chart></root>";
    return totalXml;
  }
  /** 查询数据 */
  public void query() throws ServletException, IOException {
    HttpServletRequest request = Struts2Utils.getRequest();
    List<TopStat> list = null;
    if (this.searchdate == null) {
      this.searchdate = CommonUtils.getSYestoday();
    }
    logger.info("stattype:" + stattype + "--searchdate:" + searchdate + "--raittype:" + raittype);
    GridServerHandler gridServerHandler =
        new GridServerHandler(Struts2Utils.getRequest(), Struts2Utils.getResponse());
    try {
      list = topFlushAndImsiManager.findTopStatImsi(raittype, stattype, searchdate);

    } catch (Exception e) {
      logger.error(e.getMessage());
    }
    gridServerHandler.setData(list, TopStat.class);
    Struts2Utils.renderJson(gridServerHandler.getLoadResponseText());
  }
public class TopUserAction extends BaseDispatchAction {

  @Autowired private TopFlushAndImsiManager topFlushAndImsiManager;

  @Resource(name = "commonManagerImpl")
  public ICommonManager commonManagerImpl;

  private String exportFileName;

  private String stattype = "2"; // 粒度

  private String searchdate = CommonUtils.getSYestoday(); // 时间点

  private int raittype = 1; // 1-gprs 2-TD

  public String getExportFileName() {
    return exportFileName;
  }

  public void setExportFileName(String exportFileName) {
    this.exportFileName = exportFileName;
  }

  public String getStattype() {
    return stattype;
  }

  public void setStattype(String stattype) {
    this.stattype = stattype;
  }

  public String getSearchdate() {
    return searchdate;
  }

  public void setSearchdate(String searchdate) {
    this.searchdate = searchdate;
  }

  public int getRaittype() {
    return raittype;
  }

  public void setRaittype(int raittype) {
    this.raittype = raittype;
  }

  /** 查询数据 */
  public void query() throws ServletException, IOException {
    HttpServletRequest request = Struts2Utils.getRequest();
    List<TopStat> list = null;
    if (this.searchdate == null) {
      this.searchdate = CommonUtils.getSYestoday();
    }
    logger.info("stattype:" + stattype + "--searchdate:" + searchdate + "--raittype:" + raittype);
    GridServerHandler gridServerHandler =
        new GridServerHandler(Struts2Utils.getRequest(), Struts2Utils.getResponse());
    try {
      list = topFlushAndImsiManager.findTopStatImsi(raittype, stattype, searchdate);

    } catch (Exception e) {
      logger.error(e.getMessage());
    }
    gridServerHandler.setData(list, TopStat.class);
    Struts2Utils.renderJson(gridServerHandler.getLoadResponseText());
  }

  /** 导出 */
  public void export() throws ServletException, IOException {
    if (this.searchdate == null) {
      this.searchdate = CommonUtils.getSYestoday();
    }
    List<TopStat> list = null;
    GridServerHandler gridServerHandler =
        new GridServerHandler(Struts2Utils.getRequest(), Struts2Utils.getResponse());
    list = topFlushAndImsiManager.findTopStatImsi(raittype, stattype, searchdate);
    String exportmsg = ExportMsg.EXPORT_FLUSH_TOPUSER + "(" + searchdate + ")";
    commonManagerImpl.log(Struts2Utils.getRequest(), exportmsg);
    gridServerHandler.exportXLS(list, TopStat.class);
  }
}