add history mapstores
This commit is contained in:
parent
86a76a4488
commit
1d36a64dd5
2 changed files with 31 additions and 32 deletions
|
|
@ -76,15 +76,17 @@ public abstract class AbstractSliceMapLoader<T extends WithId> implements Autoco
|
|||
@Override
|
||||
public Iterable<Long> loadAllKeys() {
|
||||
//fixme понять какое поле подходит большинству таблиц. created_at???
|
||||
return Collections.emptyList();
|
||||
// log.debug("loading all keys from {}...", getTableName());
|
||||
//fixme пока выгружаются все ключи безотносительно даты
|
||||
// return Collections.emptyList();
|
||||
// Instant yesterdayInstant = Instant.now().minus(0, ChronoUnit.DAYS);
|
||||
// Instant halfYearAgo = yesterdayInstant.minus(365, ChronoUnit.DAYS);
|
||||
// List<Long> ids = jdbcTemplate.query("select id from " + getTableName() + " where CAST(tradingday as DATE) <= ? and CAST(tradingday as DATE) >= ? ",
|
||||
// new Object[]{FIREBIRD_INSTANT_FORMATTER.format(yesterdayInstant), FIREBIRD_INSTANT_FORMATTER.format(halfYearAgo)},
|
||||
// (resultSet, i) -> resultSet.getObject("id", Long.class));
|
||||
// log.debug("loading all keys from {} done; size={}", getTableName(), ids.size());
|
||||
// return ids;
|
||||
log.debug("loading all keys from {}...", getTableName());
|
||||
List<Long> ids = jdbcTemplate.query("select id from " + getTableName(),
|
||||
(resultSet, i) -> resultSet.getObject("id", Long.class));
|
||||
log.debug("loading all keys from {} done; size={}", getTableName(), ids.size());
|
||||
return ids;
|
||||
}
|
||||
|
||||
protected LocalDate getLocalDateFromSqlDate(ResultSet rs, String column) throws SQLException {
|
||||
|
|
|
|||
|
|
@ -5,11 +5,8 @@ import org.springframework.stereotype.Component;
|
|||
import ru.spcex.clearing.historyimdg.index.SearchProxyMoneyBalanceRegister;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
|
|
@ -22,30 +19,30 @@ public class SearchMoneyBalanceRegisterMapStore extends AbstractSliceMapLoader<S
|
|||
protected String getTableName() {
|
||||
return "money_balance_register";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Long> loadAllKeys() {
|
||||
//пример loadAllKeys
|
||||
log.debug("loading all keys from {}...", getTableName());
|
||||
LocalDate upperInstant = LocalDate.now().plus(1, ChronoUnit.DAYS);
|
||||
LocalDate halfYearAgo = upperInstant.minus(365, ChronoUnit.DAYS);
|
||||
List<Long> ids = jdbcTemplate.query("select id from " + getTableName() + " where CAST(created_at as DATE) <= ? and CAST(created_at as DATE) >= ? ",
|
||||
new Object[]{upperInstant, halfYearAgo},
|
||||
(resultSet, i) -> resultSet.getObject("id", Long.class));
|
||||
log.debug("loading all keys from {} done; size={}", getTableName(), ids.size());
|
||||
return ids;
|
||||
//LocalDate today = LocalDate.now();
|
||||
// log.debug("loadAllKeys from {} on {} {} today", getTableName(), dateField, canBeGreat ? ">=" : "=");
|
||||
// List<Long> keys;
|
||||
// try {
|
||||
// keys = jdbcTemplate.query("select id from " + getTableName() + " where " + dateField + (canBeGreat ? " >= ?" : " = ?"),
|
||||
// (resultSet, i) -> resultSet.getLong("id"),
|
||||
// new Object[]{today});
|
||||
// } catch (Throwable e) {
|
||||
// log.error("At load keys from {} (by field {}): {}", getTableName(), dateField, ExceptionUtils.getStackTrace(e));
|
||||
// throw e;
|
||||
// }
|
||||
}
|
||||
//
|
||||
// @Override
|
||||
// public Iterable<Long> loadAllKeys() {
|
||||
// //пример loadAllKeys
|
||||
// log.debug("loading all keys from {}...", getTableName());
|
||||
// LocalDate upperInstant = LocalDate.now().plus(1, ChronoUnit.DAYS);
|
||||
// LocalDate halfYearAgo = upperInstant.minus(365, ChronoUnit.DAYS);
|
||||
// List<Long> ids = jdbcTemplate.query("select id from " + getTableName() + " where CAST(created_at as DATE) <= ? and CAST(created_at as DATE) >= ? ",
|
||||
// new Object[]{upperInstant, halfYearAgo},
|
||||
// (resultSet, i) -> resultSet.getObject("id", Long.class));
|
||||
// log.debug("loading all keys from {} done; size={}", getTableName(), ids.size());
|
||||
// return ids;
|
||||
// //LocalDate today = LocalDate.now();
|
||||
// // log.debug("loadAllKeys from {} on {} {} today", getTableName(), dateField, canBeGreat ? ">=" : "=");
|
||||
// // List<Long> keys;
|
||||
// // try {
|
||||
// // keys = jdbcTemplate.query("select id from " + getTableName() + " where " + dateField + (canBeGreat ? " >= ?" : " = ?"),
|
||||
// // (resultSet, i) -> resultSet.getLong("id"),
|
||||
// // new Object[]{today});
|
||||
// // } catch (Throwable e) {
|
||||
// // log.error("At load keys from {} (by field {}): {}", getTableName(), dateField, ExceptionUtils.getStackTrace(e));
|
||||
// // throw e;
|
||||
// // }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public Collection<SearchProxyMoneyBalanceRegister> load(Collection<Long> keys) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue