@Override
  public void execute(Tuple tuple, BasicOutputCollector collector) {
    // refresh gamecfg
    _prop = _gamecfgLoader.loadCfg(_gamecfg, _prop);

    String game_abbr = tuple.getString(0);
    String platform_id = tuple.getString(1);
    String server_id = tuple.getString(2);
    Long todayDate = tuple.getLong(3);
    Long datetime = tuple.getLong(4);
    int count1 = tuple.getInteger(5);
    int countip = tuple.getInteger(6);
    String hour = tuple.getString(7);
    int count2 = tuple.getInteger(8);
    String job_id = tuple.getString(9);
    int count3 = tuple.getInteger(10);
    String adplanning_id = tuple.getString(11);
    String chunion_subid = tuple.getString(12);
    int count5min = tuple.getInteger(13);
    Long tis_datetime_5min = tuple.getLong(14);
    int count1hour = tuple.getInteger(15);
    Long tis_datetime_1hour = tuple.getLong(16);
    String todayStr = tuple.getString(17);

    String jobRegDbCol = (String) _jobList.get(Integer.parseInt(job_id));
    String hourlyRegDbCol = "T" + hour;

    String ins_sql =
        String.format(
            "INSERT INTO adplanning_signinLogin_today (adplanning_id, chunion_subid, platform, server, date, up_time, %s, daily_characters, %s, charip)"
                + " VALUES (%s, %s, %s, %s, %d, %d, %d, %d, %d, %d) ON DUPLICATE KEY UPDATE up_time=%d, %s=%d, daily_characters=%d, %s=%d, charip=%d;",
            jobRegDbCol,
            hourlyRegDbCol,
            adplanning_id,
            chunion_subid,
            platform_id,
            server_id,
            todayDate,
            datetime,
            count3,
            count1,
            count2,
            countip,
            datetime,
            jobRegDbCol,
            count3,
            count1,
            hourlyRegDbCol,
            count2,
            countip);

    // 写入ad_realtime表
    String ad_realtime_tbname = "ad_realtime_" + todayStr;
    String create_ad_realtime_sql =
        String.format(
            "CREATE TABLE IF NOT EXISTS %s (`id` int(11) unsigned NOT NULL AUTO_INCREMENT,`adplanning_id` int(11) unsigned NOT NULL,"
                + "`chunion_subid` int(11) unsigned NOT NULL DEFAULT 0,`datetime` int(11) unsigned NOT NULL,`duration_type` tinyint(3) unsigned NOT NULL,"
                + "`p_reg` int(11) unsigned NOT NULL DEFAULT 0,`characters` int(11) unsigned NOT NULL DEFAULT 0,`ip` int(11) unsigned NOT NULL DEFAULT 0,"
                + "`pv` int(11) unsigned NOT NULL DEFAULT 0,PRIMARY KEY (`id`),UNIQUE KEY (`adplanning_id`, `chunion_subid`, `datetime`, `duration_type`)) "
                + "ENGINE=MyISAM DEFAULT CHARSET=utf8;",
            ad_realtime_tbname);
    String ins_ad_realtime_5min_sql =
        String.format(
            "INSERT INTO %s (adplanning_id, chunion_subid, datetime, duration_type, characters) VALUES (%s, %s, %d, 1, %d) "
                + "ON DUPLICATE KEY UPDATE characters=%d;",
            ad_realtime_tbname,
            adplanning_id,
            chunion_subid,
            tis_datetime_5min,
            count5min,
            count5min);
    String ins_ad_realtime_1hour_sql =
        String.format(
            "INSERT INTO %s (adplanning_id, chunion_subid, datetime, duration_type, characters) VALUES (%s, %s, %d, 2, %d) "
                + "ON DUPLICATE KEY UPDATE characters=%d;",
            ad_realtime_tbname,
            adplanning_id,
            chunion_subid,
            tis_datetime_1hour,
            count1hour,
            count1hour);

    // flush to mysql
    String mysql_host = _prop.getProperty("game." + game_abbr + ".mysql_host");
    String mysql_port = _prop.getProperty("game." + game_abbr + ".mysql_port");
    String mysql_db = _prop.getProperty("game." + game_abbr + ".mysql_db");
    String mysql_user = _prop.getProperty("game." + game_abbr + ".mysql_user");
    String mysql_passwd = _prop.getProperty("game." + game_abbr + ".mysql_passwd");

    if (mysql.getConnection(
        game_abbr, mysql_host, mysql_port, mysql_db, mysql_user, mysql_passwd)) {
      boolean sql_ret;
      try {
        System.out.println(ins_sql);
        sql_ret = _dbconnect.DirectUpdate(game_abbr, ins_sql);
        System.out.println(sql_ret);
      } catch (SQLException e) {
        e.printStackTrace();
      }

      try {
        System.out.println(create_ad_realtime_sql);
        sql_ret = _dbconnect.DirectUpdate(game_abbr, create_ad_realtime_sql);
        System.out.println(sql_ret);
      } catch (SQLException e) {
        e.printStackTrace();
      }

      try {
        System.out.println(ins_ad_realtime_5min_sql);
        sql_ret = _dbconnect.DirectUpdate(game_abbr, ins_ad_realtime_5min_sql);
        System.out.println(sql_ret);
      } catch (SQLException e) {
        e.printStackTrace();
      }

      try {
        System.out.println(ins_ad_realtime_1hour_sql);
        sql_ret = _dbconnect.DirectUpdate(game_abbr, ins_ad_realtime_1hour_sql);
        System.out.println(sql_ret);
      } catch (SQLException e) {
        e.printStackTrace();
      }
    }
    /*if (!_tc.push(game_abbr, ins_sql)) {
        _tc.pullAndFlush(game_abbr);
    }*/

    System.out.println("@@@@@@ " + ins_sql);
  }
Пример #2
0
  @Override
  public void execute(Tuple tuple, BasicOutputCollector collector) {
    // refresh gamecfg
    _prop = _gamecfgLoader.loadCfg(_gamecfg, _prop);

    String game_abbr = tuple.getStringByField("game_abbr");
    String platform_id = tuple.getStringByField("platform_id");
    String server_id = tuple.getStringByField("server_id");
    String startup_datetime = tuple.getStringByField("startup_datetime");
    String devid = tuple.getStringByField("devid");
    String system = tuple.getStringByField("system");
    String appver = tuple.getStringByField("appver");
    String model = tuple.getStringByField("model");
    String resolution = tuple.getStringByField("resolution");
    String sp = tuple.getStringByField("sp");
    String network = tuple.getStringByField("network");
    String client_ip = tuple.getStringByField("client_ip");
    String district = tuple.getStringByField("district");
    String osver = tuple.getStringByField("osver");
    String osbuilder = tuple.getStringByField("osbuilder");
    String devtype = tuple.getStringByField("devtype");

    if (common.isNumber(platform_id) && common.isNumber(server_id)) {

      Long startup_datetime_int = Long.parseLong(startup_datetime);
      String todayStr = date.timestamp2str(startup_datetime_int, "yyyyMMdd");
      String todayHourStr = date.timestamp2str(startup_datetime_int, "yyyyMMdd-HH");
      String todayMinuteStr = date.timestamp2str(startup_datetime_int, "yyyyMMdd-HHmm");
      String curHour = date.timestamp2str(startup_datetime_int, "H");

      Long todayDate = date.str2timestamp(todayStr, "yyyyMMdd");
      Long todayMinuteDate = date.str2timestamp(todayMinuteStr, "yyyyMMdd-HHmm");

      Integer client = system2client.turnSystem2ClientId(system);
      Integer ifAbroad = platform2ifabroad.turnPlatform2ifabroad(platform_id);

      // 记录启动列表
      String mstartupListKey =
          "mstartup:" + game_abbr + ":" + platform_id + ":" + server_id + ":" + devid + ":record";
      String mstartupListValue =
          "mstartup:"
              + game_abbr
              + ":"
              + platform_id
              + ":"
              + server_id
              + ":"
              + devid
              + ":"
              + startup_datetime
              + ":record:detail";
      _jedis.rpush(mstartupListKey, mstartupListValue);

      Map mstartupListDetailMap = new HashMap();
      mstartupListDetailMap.put("os", system);
      mstartupListDetailMap.put("appver", appver);
      mstartupListDetailMap.put("model", model);
      mstartupListDetailMap.put("resolution", resolution);
      mstartupListDetailMap.put("operator", sp);
      mstartupListDetailMap.put("network", network);
      mstartupListDetailMap.put("clientip", client_ip);
      mstartupListDetailMap.put("district", district);
      mstartupListDetailMap.put("osver", osver);
      mstartupListDetailMap.put("osbuilder", osbuilder);
      mstartupListDetailMap.put("devtype", devtype);
      _jedis.hmset(mstartupListValue, mstartupListDetailMap);

      // 全局累计数据key
      String overallKey =
          "overalldata:" + game_abbr + ":" + system + ":" + platform_id + ":hash:incr";
      String overallAbroadKey =
          "overalldata:" + game_abbr + ":" + system + ":" + ifAbroad + ":hash:abroad:incr";

      // 1. 各系统所有启动设备列表
      String startupDevListKey =
          "mstartup:" + game_abbr + ":" + system + ":" + platform_id + ":total:dev:set";
      String startupDevListAbroadKey =
          "mstartup:" + game_abbr + ":" + system + ":" + ifAbroad + ":total:dev:abroad:set";
      // String startupIosDevListKey = "mstartup:" + game_abbr + ":iostotal" + platform_id +
      // ":total:dev:set";
      _jedis.sadd(startupDevListKey, devid);
      _jedis.sadd(startupDevListAbroadKey, devid);

      Long overalldata_launchdev = 0L;
      Long overalldata_devjbs = 0L;
      Long overalldata_launchdev_abroad = 0L;
      Long overalldata_devjbs_abroad = 0L;
      //        Long specNum = _jedis.scard(startupDevListKey);
      //
      //        if ("iosjb".equals(system)) {
      //            overalldata_devjbs = specNum;
      //            overalldata_launchdev = specNum + (!_jedis.exists("mstartup:" + game_abbr +
      // ":ios:" + platform_id + ":total:dev:set") ?
      //                    0L : _jedis.scard("mstartup:" + game_abbr + ":ios:" + platform_id +
      // ":total:dev:set"));
      //        } else {
      //            overalldata_launchdev = specNum;
      //        }

      // 2. 各系统当天所有启动设备列表
      String startupDevListDailyKey =
          "mstartup:" + game_abbr + ":" + system + ":" + platform_id + ":" + todayStr + ":dev:set";
      String startupDevListDailyAbroadKey =
          "mstartup:"
              + game_abbr
              + ":"
              + system
              + ":"
              + ifAbroad
              + ":"
              + todayStr
              + ":dev:abroad:set";
      _jedis.sadd(startupDevListDailyKey, devid);
      _jedis.expire(startupDevListDailyKey, 60 * 24 * 60 * 60);
      _jedis.sadd(startupDevListDailyAbroadKey, devid);
      _jedis.expire(startupDevListDailyAbroadKey, 60 * 24 * 60 * 60);

      Long overalldatadaily_launchdev = 0L;
      Long overalldatadaily_devjbs = 0L;
      Long overalldatadaily_launchdev_abroad = 0L;
      Long overalldatadaily_devjbs_abroad = 0L;

      if ("iosjb".equals(system) || "ios".equals(system)) {
        // String startupDevOppositeListKey = "mstartup:" + game_abbr + ":";
        if ("iosjb".equals(system)) {
          overalldata_devjbs = overalldata_launchdev = _jedis.scard(startupDevListKey);
          overalldatadaily_devjbs =
              overalldatadaily_launchdev = _jedis.scard(startupDevListDailyKey);
          overalldata_devjbs_abroad =
              overalldata_launchdev_abroad = _jedis.scard(startupDevListAbroadKey);
          overalldatadaily_devjbs_abroad =
              overalldatadaily_launchdev_abroad = _jedis.scard(startupDevListDailyAbroadKey);
          // startupDevOppositeListKey += "ios:" + platform_id + ":total:dev:set";
        } else {
          overalldata_launchdev = _jedis.scard(startupDevListKey);
          overalldatadaily_launchdev = _jedis.scard(startupDevListDailyKey);
          overalldata_launchdev_abroad = _jedis.scard(startupDevListAbroadKey);
          overalldatadaily_launchdev_abroad = _jedis.scard(startupDevListDailyAbroadKey);
          // startupDevOppositeListKey += "iosjb:" + platform_id + ":total:dev:set";
        }
        // _jedis.sunionstore(startupIosDevListKey, startupDevListKey, startupDevOppositeListKey);
        // overalldata_launchdev = _jedis.scard(startupIosDevListKey);
      } else {
        overalldata_launchdev = _jedis.scard(startupDevListKey);
        overalldatadaily_launchdev = _jedis.scard(startupDevListDailyKey);
        overalldata_launchdev_abroad = _jedis.scard(startupDevListAbroadKey);
        overalldatadaily_launchdev_abroad = _jedis.scard(startupDevListDailyAbroadKey);
      }

      _jedis.hset(overallKey, "launchdev", overalldata_launchdev.toString());
      _jedis.hset(overallKey, "devjbs", overalldata_devjbs.toString());
      _jedis.hset(overallAbroadKey, "launchdev", overalldata_launchdev_abroad.toString());
      _jedis.hset(overallAbroadKey, "devjbs", overalldata_devjbs_abroad.toString());

      // Long overalldatadaily_launchdev = _jedis.scard(startupDevListDailyKey);

      _jedis.hset(overallKey, "launchdev:" + todayStr, overalldatadaily_launchdev.toString());
      _jedis.hset(overallKey, "devjbs:" + todayStr, overalldatadaily_devjbs.toString());
      _jedis.hset(
          overallAbroadKey, "launchdev:" + todayStr, overalldatadaily_launchdev_abroad.toString());
      _jedis.hset(
          overallAbroadKey, "devjbs:" + todayStr, overalldatadaily_devjbs_abroad.toString());

      // 3. 各系统当天各时段所有启动设备列表
      String startupDevListHourlyKey =
          "mstartup:"
              + game_abbr
              + ":"
              + system
              + ":"
              + platform_id
              + ":"
              + todayHourStr
              + ":dev:set";
      String startupDevListHourlyAbroadKey =
          "mstartup:"
              + game_abbr
              + ":"
              + system
              + ":"
              + ifAbroad
              + ":"
              + todayHourStr
              + ":dev:abroad:set";
      _jedis.sadd(startupDevListHourlyKey, devid);
      _jedis.expire(startupDevListHourlyKey, 60 * 24 * 60 * 60);
      _jedis.sadd(startupDevListHourlyAbroadKey, devid);
      _jedis.expire(startupDevListHourlyAbroadKey, 60 * 24 * 60 * 60);

      Long overalldatahourly_launchdev = _jedis.scard(startupDevListHourlyKey);
      Long overalldatahourly_launchdev_abroad = _jedis.scard(startupDevListHourlyAbroadKey);

      _jedis.hset(
          overallKey,
          "launchdev:" + todayStr + ":" + curHour,
          overalldatahourly_launchdev.toString());
      _jedis.hset(
          overallAbroadKey,
          "launchdev:" + todayStr + ":" + curHour,
          overalldatahourly_launchdev_abroad.toString());

      // 4. 各系统当天各版本所有启动设备列表
      String startupDevListDailyVerlyKey =
          "mstartup:"
              + game_abbr
              + ":"
              + system
              + ":"
              + platform_id
              + ":"
              + todayStr
              + ":"
              + appver
              + ":dev:set";
      String startupDevListDailyVerlyAbroadKey =
          "mstartup:"
              + game_abbr
              + ":"
              + system
              + ":"
              + ifAbroad
              + ":"
              + todayStr
              + ":"
              + appver
              + ":dev:abroad:set";
      _jedis.sadd(startupDevListDailyVerlyKey, devid);
      _jedis.expire(startupDevListDailyVerlyKey, 60 * 24 * 60 * 60);
      _jedis.sadd(startupDevListDailyVerlyAbroadKey, devid);
      _jedis.expire(startupDevListDailyVerlyAbroadKey, 60 * 24 * 60 * 60);

      Long overalldatadailyverly_launchdev = _jedis.scard(startupDevListDailyVerlyKey);
      Long overalldatadailyverly_launchdev_abroad = _jedis.scard(startupDevListDailyVerlyAbroadKey);

      _jedis.hset(
          overallKey,
          "launchdev:" + todayStr + ":" + appver,
          overalldatadailyverly_launchdev.toString());
      _jedis.hset(
          overallAbroadKey,
          "launchdev:" + todayStr + ":" + appver,
          overalldatadailyverly_launchdev_abroad.toString());

      // 5. 各系统当天各区服各版本启动设备列表
      String startupDevListSvrDailyKey =
          "mstartup:"
              + game_abbr
              + ":"
              + system
              + ":"
              + platform_id
              + ":"
              + server_id
              + ":"
              + todayStr
              + ":"
              + appver
              + ":dev:set";
      _jedis.sadd(startupDevListSvrDailyKey, devid);
      _jedis.expire(startupDevListSvrDailyKey, 60 * 24 * 60 * 60);

      Long signinlogindaily_launchdev = _jedis.scard(startupDevListSvrDailyKey);

      // 6. 各系统当天各区服各版本设备启动次数
      String startupDevNumSvrDailyKey =
          "mstartup:"
              + game_abbr
              + ":"
              + system
              + ":"
              + platform_id
              + ":"
              + server_id
              + ":"
              + todayStr
              + ":"
              + appver
              + ":dev:incr";
      _jedis.incr(startupDevNumSvrDailyKey);
      _jedis.expire(startupDevNumSvrDailyKey, 60 * 24 * 60 * 60);

      Integer signinlogindaily_launch = Integer.parseInt(_jedis.get(startupDevNumSvrDailyKey));

      // 7. 各系统当天各时段各区服各版本启动设备列表
      String startupDevListSvrHourlyKey =
          "mstartup:"
              + game_abbr
              + ":"
              + system
              + ":"
              + platform_id
              + ":"
              + server_id
              + ":"
              + todayHourStr
              + ":"
              + appver
              + ":dev:set";
      _jedis.sadd(startupDevListSvrHourlyKey, devid);
      _jedis.expire(startupDevListSvrHourlyKey, 60 * 24 * 60 * 60);

      Long signinloginhourly_launchdev = _jedis.scard(startupDevListSvrHourlyKey);

      // 8. 各系统当天各区服各版本各时段设备启动次数
      String startupDevNumSvrHourlyKey =
          "mstartup:"
              + game_abbr
              + ":"
              + system
              + ":"
              + platform_id
              + ":"
              + server_id
              + ":"
              + todayHourStr
              + ":"
              + appver
              + ":dev:incr";
      _jedis.incr(startupDevNumSvrHourlyKey);
      _jedis.expire(startupDevNumSvrHourlyKey, 60 * 24 * 60 * 60);

      Integer signinloginhourly_launch = Integer.parseInt(_jedis.get(startupDevNumSvrHourlyKey));

      String startupDevListSvrKey =
          "mstartup:" + game_abbr + ":" + system + ":" + platform_id + ":" + server_id + ":dev:set";
      // 9. 各系统当天各区服各版本新增启动设备列表
      String startupDevListSvrNewKey =
          "mstartup:"
              + game_abbr
              + ":"
              + system
              + ":"
              + platform_id
              + ":"
              + server_id
              + ":"
              + todayStr
              + ":"
              + appver
              + ":dev:new:set";
      // 10. 各系统当天各时段各区服各版本新增启动设备列表
      String startupDevListSvrHourlyNewKey =
          "mstartup:"
              + game_abbr
              + ":"
              + system
              + ":"
              + platform_id
              + ":"
              + server_id
              + ":"
              + todayHourStr
              + ":"
              + appver
              + ":dev:new:set";
      // 11. 各系统当天各时段各分钟各区服各版本新增启动设备列表
      String startupDevListSvrMinlyNewKey =
          "mstartup:"
              + game_abbr
              + ":"
              + system
              + ":"
              + platform_id
              + ":"
              + server_id
              + ":"
              + todayMinuteStr
              + ":"
              + appver
              + ":dev:new:set";
      if (1L == _jedis.sadd(startupDevListSvrKey, devid)) {
        _jedis.sadd(startupDevListSvrNewKey, devid);
        _jedis.expire(startupDevListSvrNewKey, 60 * 24 * 60 * 60);
        _jedis.sadd(startupDevListSvrHourlyNewKey, devid);
        _jedis.expire(startupDevListSvrHourlyNewKey, 60 * 24 * 60 * 60);
        _jedis.sadd(startupDevListSvrMinlyNewKey, devid);
        _jedis.expire(startupDevListSvrMinlyNewKey, 60 * 24 * 60 * 60);
      }

      Long signinlogindaily_newdev =
          !_jedis.exists(startupDevListSvrNewKey) ? 0L : _jedis.scard(startupDevListSvrNewKey);
      Long signinloginhourly_newdev =
          !_jedis.exists(startupDevListSvrHourlyNewKey)
              ? 0L
              : _jedis.scard(startupDevListSvrHourlyNewKey);
      Long newonlinert_newdev =
          !_jedis.exists(startupDevListSvrMinlyNewKey)
              ? 0L
              : _jedis.scard(startupDevListSvrMinlyNewKey);

      // flush to mstartup daily list
      String mstartupDailyListKey = "mstartup:" + game_abbr + ":" + todayDate + ":record";
      String mstartupDailyListValue =
          startup_datetime
              + ":"
              + client
              + ":"
              + platform_id
              + ":"
              + server_id
              + ":"
              + appver
              + ":"
              + devid
              + ":"
              + system
              + ":"
              + model
              + ":"
              + resolution
              + ":"
              + sp
              + ":"
              + network
              + ":"
              + client_ip
              + ":"
              + district
              + ":"
              + osver
              + ":"
              + osbuilder
              + ":"
              + devtype;
      _jedis.rpush(mstartupDailyListKey, mstartupDailyListValue);

      // flush to mysql
      String mysql_host = _prop.getProperty("game." + game_abbr + ".mysql_host");
      String mysql_port = _prop.getProperty("game." + game_abbr + ".mysql_port");
      String mysql_db = _prop.getProperty("game." + game_abbr + ".mysql_db");
      String mysql_user = _prop.getProperty("game." + game_abbr + ".mysql_user");
      String mysql_passwd = _prop.getProperty("game." + game_abbr + ".mysql_passwd");

      if (mysql.getConnection(
          game_abbr, mysql_host, mysql_port, mysql_db, mysql_user, mysql_passwd)) {
        boolean sql_ret = false;
        String inssql_overalldata = "";
        String inssql_overalldatadaily = "";
        String dmlsql_overalldatahourly_tb = "";
        String inssql_overalldatahourly = "";
        String inssql_overalldatadailyverly = "";
        String inssql_signinlogindaily = "";
        String dmlsql_signinloginhourly_tb = "";
        String inssql_signinloginhourly = "";
        String dmlsql_startuplist_tb = "";
        String inssql_startuplist = "";
        String dmlsql_newonlinert_tb = "";
        String inssql_newonlinert = "";

        if (_dbFlushTimer.ifItsTime2FlushDb(client.toString() + platform_id + server_id + appver)) {
          inssql_overalldata =
              String.format(
                  "INSERT INTO overalldata (client, platform, launchdev, devjbs)"
                      + " VALUES (%d, '%s', %d, %d) ON DUPLICATE KEY UPDATE launchdev=%d, devjbs=%d;",
                  client,
                  platform_id,
                  overalldata_launchdev,
                  overalldata_devjbs,
                  overalldata_launchdev,
                  overalldata_devjbs);

          inssql_overalldatadaily =
              String.format(
                  "INSERT INTO overalldatadaily (client, platform, date, launchdev)"
                      + " VALUES (%d, '%s', %d, %d) ON DUPLICATE KEY UPDATE launchdev=%d;",
                  client,
                  platform_id,
                  todayDate,
                  overalldatadaily_launchdev,
                  overalldatadaily_launchdev);

          String overalldatahourly_tb = "overalldatahourly_" + todayStr;
          dmlsql_overalldatahourly_tb =
              String.format(
                  "CREATE TABLE IF NOT EXISTS %s ("
                      + "`id` int(11) unsigned NOT NULL AUTO_INCREMENT,"
                      + "`client` tinyint(3) unsigned NOT NULL,"
                      + "`platform` mediumint(5) unsigned NOT NULL,"
                      + "`hour` tinyint(3) unsigned NOT NULL,"
                      + "`hau` int(11) unsigned NOT NULL DEFAULT 0,"
                      + "`maxonline` int(11) unsigned NOT NULL DEFAULT 0,"
                      + "`launchdev` int(11) unsigned NOT NULL DEFAULT 0,"
                      + "PRIMARY KEY (`id`),"
                      + "UNIQUE KEY `platform` (`client`, `platform`, `hour`)"
                      + ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
                  overalldatahourly_tb);
          inssql_overalldatahourly =
              String.format(
                  "INSERT INTO %s (client, platform, hour, launchdev) VALUES "
                      + "(%d, '%s', '%s', %d) ON DUPLICATE KEY UPDATE launchdev=%d;",
                  overalldatahourly_tb,
                  client,
                  platform_id,
                  curHour,
                  overalldatahourly_launchdev,
                  overalldatahourly_launchdev);

          inssql_overalldatadailyverly =
              String.format(
                  "INSERT INTO overalldatadailyverly (client, platform, "
                      + "date, version, launchdev) VALUES (%d, '%s', %d, %s, %d) ON DUPLICATE KEY UPDATE launchdev=%d;",
                  client,
                  platform_id,
                  todayDate,
                  appver,
                  overalldatadailyverly_launchdev,
                  overalldatadailyverly_launchdev);

          inssql_signinlogindaily =
              String.format(
                  "INSERT INTO signinlogindaily (client, platform, server, date,"
                      + "version, newdev, launchdev, launch) VALUES (%d, '%s', '%s', %d, '%s', %d, %d, %d) ON DUPLICATE KEY UPDATE"
                      + " newdev=%d, launchdev=%d, launch=%d;",
                  client,
                  platform_id,
                  server_id,
                  todayDate,
                  appver,
                  signinlogindaily_newdev,
                  signinlogindaily_launchdev,
                  signinlogindaily_launch,
                  signinlogindaily_newdev,
                  signinlogindaily_launchdev,
                  signinlogindaily_launch);

          String signinloginhourly_tb = "signinloginhourly_" + todayStr;
          dmlsql_signinloginhourly_tb =
              String.format(
                  "CREATE TABLE IF NOT EXISTS %s ("
                      + "`id` int(11) unsigned NOT NULL AUTO_INCREMENT,"
                      + "`client` tinyint(3) unsigned NOT NULL,"
                      + "`platform` mediumint(5) unsigned NOT NULL,"
                      + "`server` mediumint(5) unsigned NOT NULL,"
                      + "`hour` tinyint(3) unsigned NOT NULL,"
                      + "`version` char(10) CHARACTER SET UTF8 NOT NULL,"
                      + "`newdev` int(11) unsigned NOT NULL DEFAULT 0,"
                      + "`newacc` int(11) unsigned NOT NULL DEFAULT 0,"
                      + "`logins` int(11) unsigned NOT NULL DEFAULT 0,"
                      + "`launchdev` int(11) unsigned NOT NULL DEFAULT 0,"
                      + "`launch` int(11) unsigned NOT NULL DEFAULT 0,"
                      + "`lasttime` int(11) unsigned NOT NULL DEFAULT 0,"
                      + "PRIMARY KEY (`id`),"
                      + "UNIQUE KEY `platform` (`client`, `platform`, `server`, `hour`, `version`)"
                      + ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
                  signinloginhourly_tb);
          inssql_signinloginhourly =
              String.format(
                  "INSERT INTO %s (client, platform, server, hour, version,"
                      + "newdev, launchdev, launch) VALUES (%d, '%s', '%s', '%s', '%s', %d, %d, %d) ON DUPLICATE KEY UPDATE "
                      + "newdev=%d, launchdev=%d, launch=%d;",
                  signinloginhourly_tb,
                  client,
                  platform_id,
                  server_id,
                  curHour,
                  appver,
                  signinloginhourly_newdev,
                  signinloginhourly_launchdev,
                  signinloginhourly_launch,
                  signinloginhourly_newdev,
                  signinloginhourly_launchdev,
                  signinloginhourly_launch);

          String newonlinert_tb = "newonlinert_" + todayStr;
          dmlsql_newonlinert_tb =
              String.format(
                  "CREATE TABLE IF NOT EXISTS %s ("
                      + "`id` int(11) unsigned NOT NULL AUTO_INCREMENT,"
                      + "`client` tinyint(3) unsigned NOT NULL,"
                      + "`platform` mediumint(5) unsigned NOT NULL,"
                      + "`server` mediumint(5) unsigned NOT NULL,"
                      + "`datetime` int(11) unsigned NOT NULL,"
                      + "`version` char(10) CHARACTER SET UTF8 NOT NULL,"
                      + "`online` int(10) unsigned NOT NULL DEFAULT 0,"
                      + "`newdev` int(11) unsigned NOT NULL DEFAULT 0,"
                      + "`newacc` int(11) unsigned NOT NULL DEFAULT 0,"
                      + "PRIMARY KEY (`id`),"
                      + "UNIQUE KEY `platform` (`client`, `platform`, `server`, `datetime`, `version`)"
                      + ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
                  newonlinert_tb);
          inssql_newonlinert =
              String.format(
                  "INSERT INTO %s (client, platform, server, datetime, version, newdev)"
                      + " VALUES (%d, '%s', '%s', %d, '%s', %d) ON DUPLICATE KEY UPDATE newdev=%d;",
                  newonlinert_tb,
                  client,
                  platform_id,
                  server_id,
                  todayMinuteDate,
                  appver,
                  newonlinert_newdev,
                  newonlinert_newdev);

          //            try {
          //                sql_ret = _dbconnect.DirectUpdate(game_abbr, inssql_overalldata);
          //            } catch (SQLException e) {
          //                e.printStackTrace();
          //            }
          //            try {
          //                sql_ret = _dbconnect.DirectUpdate(game_abbr, inssql_overalldatadaily);
          //            } catch (SQLException e) {
          //                e.printStackTrace();
          //            }
          //            try {
          //                sql_ret = _dbconnect.DirectUpdate(game_abbr,
          // dmlsql_overalldatahourly_tb);
          //            } catch (SQLException e) {
          //                e.printStackTrace();
          //            }
          //            try {
          //                sql_ret = _dbconnect.DirectUpdate(game_abbr, inssql_overalldatahourly);
          //            } catch (SQLException e) {
          //                e.printStackTrace();
          //            }
          //            try {
          //                sql_ret = _dbconnect.DirectUpdate(game_abbr,
          // inssql_overalldatadailyverly);
          //            } catch (SQLException e) {
          //                e.printStackTrace();
          //            }
          //            try {
          //                sql_ret = _dbconnect.DirectUpdate(game_abbr, inssql_signinlogindaily);
          //            } catch (SQLException e) {
          //                e.printStackTrace();
          //            }
          //            try {
          //                sql_ret = _dbconnect.DirectUpdate(game_abbr,
          // dmlsql_signinloginhourly_tb);
          //            } catch (SQLException e) {
          //                e.printStackTrace();
          //            }
          //            try {
          //                sql_ret = _dbconnect.DirectUpdate(game_abbr, inssql_signinloginhourly);
          //            } catch (SQLException e) {
          //                e.printStackTrace();
          //            }
          //            try {
          //                sql_ret = _dbconnect.DirectUpdate(game_abbr, dmlsql_startuplist_tb);
          //            } catch (SQLException e) {
          //                e.printStackTrace();
          //            }
          //            try {
          //                sql_ret = _dbconnect.DirectUpdate(game_abbr, inssql_startuplist);
          //            } catch (SQLException e) {
          //                e.printStackTrace();
          //            }
          //            try {
          //                sql_ret = _dbconnect.DirectUpdate(game_abbr, dmlsql_newonlinert_tb);
          //            } catch (SQLException e) {
          //                e.printStackTrace();
          //            }
          //            try {
          //                sql_ret = _dbconnect.DirectUpdate(game_abbr, inssql_newonlinert);
          //            } catch (SQLException e) {
          //                e.printStackTrace();
          //            }
        }

        String startuplist_tb = "startuplist_" + todayStr;
        dmlsql_startuplist_tb =
            String.format(
                "CREATE TABLE IF NOT EXISTS %s ("
                    + "`id` int(11) unsigned NOT NULL AUTO_INCREMENT,"
                    + "`client` tinyint(3) unsigned NOT NULL,"
                    + "`platform` mediumint(5) unsigned NOT NULL,"
                    + "`server` mediumint(5) unsigned NOT NULL,"
                    + "`version` char(10) CHARACTER SET UTF8 NOT NULL,"
                    + "`account` char(128) CHARACTER SET UTF8 NOT NULL,"
                    + "`devid` char(128) CHARACTER SET UTF8 NOT NULL,"
                    + "PRIMARY KEY (`id`)"
                    + ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
                startuplist_tb);
        inssql_startuplist =
            String.format(
                "INSERT INTO %s (client, platform, server, version, account, "
                    + "devid) VALUES (%d, '%s', '%s', '%s', '%s', '%s');",
                startuplist_tb, client, platform_id, server_id, appver, "", devid);

        String sql = inssql_overalldata;
        sql += inssql_overalldatadaily;
        sql += dmlsql_overalldatahourly_tb;
        sql += inssql_overalldatahourly;
        sql += inssql_overalldatadailyverly;
        sql += inssql_signinlogindaily;
        sql += dmlsql_signinloginhourly_tb;
        sql += inssql_signinloginhourly;
        sql += dmlsql_startuplist_tb;
        sql += inssql_startuplist;
        sql += dmlsql_newonlinert_tb;
        sql += inssql_newonlinert;

        System.out.println(sql);
        try {
          sql_ret = _dbconnect.DirectUpdateBatch(game_abbr, sql);
        } catch (SQLException e) {
          e.printStackTrace();
        }
        System.out.println("|||||-----batch update result: " + sql_ret);
      }
    } else {
      System.out.println("platform or server id is not a number!");
    }

    /*collector.emit(new Values(game_abbr, client, platform_id, server_id, devid, todayDate, todayStr, todayHourStr, curHour,
    overalldata_launchdev, overalldata_devjbs, overalldatadaily_launchdev, overalldatahourly_launchdev,
    overalldatadailyverly_launchdev, signinlogindaily_launchdev, signinlogindaily_launch, signinloginhourly_launchdev,
    signinloginhourly_launch));*/
  }