コード例 #1
0
 private Match exists(Match match) {
   try {
     Map<String, Object> paramMap = new HashMap<String, Object>();
     paramMap.put("matchId", match.getMatchId());
     paramMap.put("bookieId", match.getBookieId());
     paramMap.put("feedTypeId", match.getFeedTypeId());
     return jdbcTemplate.queryForObject(READ_EXISTS_SQL, paramMap, matchRowMapper);
   } catch (EmptyResultDataAccessException e) {
     return null;
   }
 }
コード例 #2
0
  @Override
  public void createMatch(Match match) {
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug(String.format("createMatch(match=%s)", match.toString()));
    }
    Match dbMatch = exists(match);
    if (dbMatch == null) {
      if (LOGGER.isInfoEnabled()) {
        LOGGER.info("Creating Match key - " + match.toString());
      }
      try {
        /** Create match. */
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("matchId", match.getMatchId());
        paramMap.put("leagueName", match.getLeagueName());
        paramMap.put("homeTeamName", match.getHomeTeamName());
        paramMap.put("awayTeamName", match.getAwayTeamName());
        paramMap.put("matchTime", match.getMatchTime());
        paramMap.put("runningInd", match.getRunningIndicator());
        paramMap.put("homeScore", match.getHomeScore());
        paramMap.put("awayScore", match.getAwayScore());
        paramMap.put("timeGameLive", match.getTimeGameLive());
        paramMap.put("leagueId", match.getLeagueId());
        paramMap.put("homeTeamId", match.getHomeTeamId());
        paramMap.put("awayTeamId", match.getAwayTeamId());
        paramMap.put("feedTypeId", match.getFeedTypeId());
        paramMap.put("timeFirstGoal", match.getTimeFirstGoal());
        paramMap.put("kickOffHomePrice", match.getKoHomePrice());
        paramMap.put("kickOffAwayPrice", match.getKoAwayPrice());
        paramMap.put("kickOffOuHfPrice", match.getKoOuHfPrice());
        paramMap.put("kickOffDrawPrice", match.getKoDrawPrice());
        paramMap.put("matchDate", new java.sql.Date(match.getMatchDate().getMillis()));
        paramMap.put("bookieId", match.getBookieId());
        paramMap.put("ouHfHandicap", match.getOuHandicapValue());

        jdbcTemplate.update(INSERT_SQL, paramMap);

        /** Create match minutes for each bookie with odds on the match. */
        matchTimeDao.createMatchTime(
            match.getMatchId(), match.getFeedTypeId(), match.getBookieId());
      } catch (Exception e) {
        LOGGER.info("Exception=" + e.getMessage());
      }
    } else {
      /** Has match started? */
      if (dbMatch.getRunningIndicator().intValue() == 0) {
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("matchId", match.getMatchId());
        paramMap.put("feedTypeId", match.getFeedTypeId());
        paramMap.put("bookieId", match.getBookieId());

        if (hasPriceChanged(match.getKoHomePrice(), dbMatch.getKoHomePrice())) {
          if (LOGGER.isInfoEnabled()) {
            LOGGER.info(
                "Update Home Price "
                    + dbMatch.getKoHomePrice()
                    + " for Match - "
                    + match.toString());
          }
          paramMap.put("homePrice", match.getKoHomePrice());
          jdbcTemplate.update(UPDATE_KO_HOME_PRICE_SQL, paramMap);
        }
        if (hasPriceChanged(match.getKoAwayPrice(), dbMatch.getKoAwayPrice())) {
          if (LOGGER.isInfoEnabled()) {
            LOGGER.info(
                "Update Away Price "
                    + dbMatch.getKoAwayPrice()
                    + " for Match - "
                    + match.toString());
          }
          paramMap.put("awayPrice", match.getKoAwayPrice());
          jdbcTemplate.update(UPDATE_KO_AWAY_PRICE_SQL, paramMap);
        }
        if (hasPriceChanged(match.getKoDrawPrice(), dbMatch.getKoDrawPrice())) {
          if (LOGGER.isInfoEnabled()) {
            LOGGER.info(
                "Update Draw Price "
                    + dbMatch.getKoDrawPrice()
                    + " for Match - "
                    + match.toString());
          }
          paramMap.put("drawPrice", match.getKoDrawPrice());
          jdbcTemplate.update(UPDATE_KO_DRAW_PRICE_SQL, paramMap);
        }
        if (hasPriceChanged(match.getKoOuHfPrice(), dbMatch.getKoOuHfPrice())) {
          if (LOGGER.isInfoEnabled()) {
            LOGGER.info(
                "Update OU HT 0.5 Price "
                    + dbMatch.getKoOuHfPrice()
                    + " for Match - "
                    + match.toString());
          }
          paramMap.put("ouHfPrice", match.getKoOuHfPrice());
          jdbcTemplate.update(UPDATE_KO_UOHT_PRICE_SQL, paramMap);
        }
      }
    }
  }