Esempio n. 1
0
  /**
   * @param args
   * @throws java.io.IOException
   */
  public static void main(String[] args) throws IOException {
    String input = args[0];
    if (!new File(input).exists()) {
      System.out.println("File Not Exist ! => " + input);
      return;
    }

    String name = "";
    if (args.length > 1) {
      name = args[1];
    }

    Map<String, List<String[]>> today = MapUtils.map(Utils.read(input), CTRL_A);

    Map<String, String[]> lsMap = MapUtils.toMap(today.get("ls"));
    //  Map<String, String[]> ipvMap = MapUtils.toMap(today.get("ipv"));

    Report report = Report.newReport(name + "统计");

    Map<String, Table> marketMap = new HashMap<String, Table>();

    for (Entry<String, String[]> entry : lsMap.entrySet()) {

      String key = entry.getKey(); // eg: 针织-针织衫市场

      String[] ls = entry.getValue(); // value[0]:pv,value[1]:uv,value[2]:mid;

      String[] keys = StringUtils.split(key, "-");

      Table market = marketMap.get(keys[1]);

      if (market == null) {
        market = report.newViewTable(keys[1], keys[1]);
        market
            .addCol("活动页面")
            .addCol("PV")
            .addCol("UV")
            .addCol("UV(MID)")
            .addCol(Report.BREAK_VALUE);
        marketMap.put(keys[1], market);
      }
      market.addCol(keys[0]).addCol(ls[0]).addCol(ls[1]).addCol(ls[2]).addCol(Report.BREAK_VALUE);
    }

    XmlReportFactory.dump(report, new FileOutputStream(args[0] + ".xml"));
  }
Esempio n. 2
0
  /**
   * @param args
   * @throws java.io.IOException
   */
  public static void main(String[] args) throws IOException {
    String input = args[0];
    if (!new File(input).exists()) {
      return;
    }
    Map<String, Long> statusMap = getMap(input);
    if (statusMap == null) return;
    Report report = Report.newReport("闲置新发布商品来源跟踪");
    if (true) {
      Table table = report.newGroupTable("all", "商品发布来源分布", "来源", "数量");

      for (String key : SOURCE) {
        table.addCol(key, sum(statusMap, key));
      }
    }

    if (true) {
      for (String key : SOURCE) {
        Table table = report.newGroupTable("lite_" + key, key + "发布来源分布", "状态", "数量");
        for (String status : ItemUtils.allStatus) {
          Long _num = statusMap.get(key + "^" + status);
          if (_num == null) {
            _num = 0L;
          }
          table.addCol(status, ItemUtils.getItemStatusName(status), String.valueOf(_num));
        }
      }
    }

    if (true) {
      Map<String, List<String[]>> today = MapUtils.map(Utils.read(input, (String[]) null));
      if (true && today.containsKey("cat")) {
        Map<String, Long> _countMap = new HashMap<String, Long>();
        for (String[] array : today.get("cat")) {
          String catId = array[0];
          if (null != Category.getCategory(catId)) {
            catId = Category.getCategory(catId).getRootId();
          }
          long value = NumberUtils.toLong(array[1]);
          Long _v = _countMap.get(catId);
          if (_v == null) {
            _v = 0L;
          }
          _v = _v + value;
          _countMap.put(catId, _v);
        }
        Table table = report.newGroupTable("cat", "今天发布商品的各个类目分布");
        for (Map.Entry<String, Long> entry : _countMap.entrySet()) {
          table.addCol(
              entry.getKey(),
              Category.getCategoryName(entry.getKey()),
              String.valueOf(entry.getValue()));
        }
        table.sort(Table.SORT_VALUE);
      }
    }
    XmlReportFactory.dump(report, new FileOutputStream(args[0] + ".xml"));
  }