Пример #1
0
  public String execute() {
    //		System.out.println("DEFAULT_PAGESIZE   "+DEFAULT_PAGESIZE);
    UserDiamondStatsService userDiamondStatsService =
        ServiceCacheFactory.getServiceCache().getService(UserDiamondStatsService.class);
    IPage<UserDiamondStats> page = null;

    if (isCommit != null && isCommit == "TF" || isCommit.equalsIgnoreCase("TF")) {
      isCommit = "F";
    }
    // 判断是否是条件查询
    if (getStartDate() == null && getEndDate() == null) {
      page = userDiamondStatsService.findList(DEFAULT_PAGESIZE, super.getToPage());
    } else {
      page =
          userDiamondStatsService.findListInDate(
              DEFAULT_PAGESIZE, super.getToPage(), getStartDate(), getEndDate());
    }

    if (page != null) {
      statsList = (List<UserDiamondStats>) page.getData();
      for (UserDiamondStats stats : statsList) {
        int sysNum = stats.getSysNum();
        TGameServer tGameServer = DataSourceManager.getInstatnce().getGameServerMap().get(sysNum);
        stats.setServerName(tGameServer.getServerAlias());
      }
      super.setTotalPage(page.getTotalPage());
      super.setTotalSize(page.getTotalSize());
    }
    return SUCCESS;
  }
Пример #2
0
  public String execute() {
    UserRegLogService userRegLogService =
        ServiceCacheFactory.getServiceCache().getService(UserRegLogService.class);

    if (DTools.isEmpty(serverIds)) {
      return SUCCESS;
    }
    for (String serverId : serverIds.split(",")) {
      CustomerContextHolder.setSystemNum(Integer.valueOf(serverId.trim()));
      TGameServer gameServer =
          DataSourceManager.getInstatnce()
              .getGameServerMap()
              .get(CustomerContextHolder.getSystemNum());
      Date openDate = new Date(gameServer.getServerOpernTime().getTime());

      if (DateUtil.dayDiff(regStartDate, openDate) > 0) {
        super.setErroDescrip("\"" + gameServer.getServerAlias() + "\"在当前注册日期还没开服!");
        continue;
      }

      // 登录开始日期
      // super.getStartDate();
      // 登录结束日期
      // super.getEndDate();
      Map<String, Integer> tempMap =
          userRegLogService.findReLoginMap(
              regStartDate, regEndDate, super.getStartDate(), super.getEndDate());
      //		Calendar calendar = Calendar.getInstance();
      //		calendar.get(Calendar.DAY_OF_MONTH);

      // 再登录人数:在A时间段注册的人中 在B时间段登陆的人数
      Integer reLoginAmount = 0;

      // 在A时间段注册的人中 B时间段内,各个日期登陆的人数
      Map<String, Integer> dayAndAmountmap = new HashMap<String, Integer>();
      Iterator<Entry<String, Integer>> ite1 = tempMap.entrySet().iterator();
      while (ite1.hasNext()) {
        Entry<String, Integer> entry = ite1.next();

        Integer count = entry.getValue();
        reLoginAmount += count;

        String[] dayStrArr = entry.getKey().split(",");
        for (String dayStr : dayStrArr) {
          if (dayAndAmountmap.get(dayStr) == null) {
            dayAndAmountmap.put(dayStr, count);
          } else {
            dayAndAmountmap.put(dayStr, count + dayAndAmountmap.get(dayStr));
          }
        }
      }
      // 每天的再登录人数(总和): 在A时间段注册的人中  B时间段内,每天登陆的人数 的总和
      Integer allDayAmount = 0;
      Iterator<Entry<String, Integer>> ite2 = dayAndAmountmap.entrySet().iterator();
      while (ite2.hasNext()) {
        Entry<String, Integer> entry = ite2.next();
        allDayAmount += entry.getValue();
      }

      // A时间段注册的人数
      String[] dates = new String[2];
      Calendar c = Calendar.getInstance();
      c.setTimeInMillis(regStartDate.getTime());
      dates[0] =
          c.get(Calendar.YEAR)
              + "-"
              + (c.get(Calendar.MONTH) + 1)
              + "-"
              + c.get(Calendar.DATE)
              + " 00:00:00";
      c.setTimeInMillis(regEndDate.getTime());
      dates[1] =
          c.get(Calendar.YEAR)
              + "-"
              + (c.get(Calendar.MONTH) + 1)
              + "-"
              + c.get(Calendar.DATE)
              + " 23:59:59";
      int regAmount = userRegLogService.findRegUserNumInSomeTime(dates);

      // 当前服务器的统计数据
      Map<String, Integer> serverMap = new HashMap<String, Integer>();
      serverMap.put("regAmount", regAmount);
      serverMap.put("reLoginAmount", reLoginAmount);
      serverMap.put("allDayAmount", allDayAmount);

      map.put(gameServer.getServerAlias(), serverMap);
    }
    return SUCCESS;
  }
Пример #3
0
  @Override
  public String execute() {
    UserMallRankStatsService userMallRankStatsService =
        ServiceCacheFactory.getServiceCache().getService(UserMallRankStatsService.class);
    TTreasureConstantService treasureConstantService =
        ServiceCacheFactory.getServiceCache().getService(TTreasureConstantService.class);
    treasureIdNameMap = treasureConstantService.findMallTreasureIdNameMap();
    IPage<UserMallRankStats> page = null;
    if (getStartDate() != null && getEndDate() != null) {
      page =
          userMallRankStatsService.findListInDate(
              super.getPageSize(), super.getToPage(), getStartDate(), getEndDate());
    } else {
      page = userMallRankStatsService.findList(super.getPageSize(), super.getToPage());
    }
    if (page != null) {
      List<UserMallRankStats> list = (List<UserMallRankStats>) page.getData();
      if (list != null && list.size() > 0) {
        for (UserMallRankStats stats : list) {
          String date = DateUtil.dateToString(stats.getTime(), DateUtil.LONG_DATE_FORMAT);
          if (statsMap.containsKey(date)) {
            statsMap.get(date).add(stats);
          } else {
            List<UserMallRankStats> ll = new ArrayList<UserMallRankStats>();
            ll.add(stats);
            statsMap.put(date, ll);
          }
        }
      }
      super.setTotalPage(page.getTotalPage());
      super.setTotalSize(page.getTotalSize());
    }
    if (statsMap.size() > 0) {
      for (List<UserMallRankStats> list : statsMap.values()) {
        Collections.sort(
            list,
            new Comparator<UserMallRankStats>() {

              @Override
              public int compare(UserMallRankStats o1, UserMallRankStats o2) {
                // TODO Auto-generated method stub
                if (o1.getRank().intValue() > o2.getRank().intValue()) {
                  return 1;
                } else {
                  return -1;
                }
              }
            });
      }
    }
    // 排序
    if (statsMap.size() > 0) {
      mappingList = new ArrayList<Map.Entry<String, List<UserMallRankStats>>>(statsMap.entrySet());
      Collections.sort(
          mappingList,
          new Comparator<Map.Entry<String, List<UserMallRankStats>>>() {
            public int compare(
                Map.Entry<String, List<UserMallRankStats>> mapping1,
                Map.Entry<String, List<UserMallRankStats>> mapping2) {
              return mapping2.getKey().compareTo(mapping1.getKey());
            }
          });
    }
    return SUCCESS;
  }