This commit is contained in:
AKurakin 2023-09-08 12:10:57 +03:00
parent 5135ddcd99
commit ccdd38ad1a

View file

@ -1,5 +1,6 @@
package ru.spcex.clearing.imdg.businessobject;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import ru.clearing.classes.statics.data.registry.Registry;
@ -10,6 +11,7 @@ import ru.spcex.platform.utils.time.TimeUtil;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDate;
import java.util.*;
@Component
@ -34,6 +36,26 @@ public class RegistryMapStore extends TemplateMapStore<Registry> {
return new String[]{"sessionId"};
}
@Override
public Iterable<Long> loadAllKeys() {
LocalDate today = LocalDate.now();
log.debug("loadAllKeys from {} with condition and today {}", getTableName(), today);
List<Long> keys;
String sql = "select id from " + getTableName() + " WHERE registry_designation='A' OR " +
"(registry_designation='D' AND (clearing_date = ? OR registry_status='PROC' OR registry_status='MNG')) OR" +
"((registry_designation='C' OR registry_designation='L') AND clearing_date=?) OR" +
"((registry_designation='O' OR registry_designation='T') AND (clearing_date=? OR registry_status='PROC' OR registry_status='MNG'))";
try {
keys = jdbcTemplate.query(sql,
(resultSet, i) -> resultSet.getLong("id"),
new Object[]{today, today, today});
} catch (Throwable e) {
log.error("At load keys from {} (sql \"{}\"): {}", getTableName(), sql, ExceptionUtils.getStackTrace(e));
throw e;
}
return keys;
}
@Override
public String[] getFields() {
return new String[]{