some imdg refactoring
This commit is contained in:
parent
295a48a4d1
commit
10dd8bdd1d
54 changed files with 213 additions and 721 deletions
|
|
@ -55,7 +55,6 @@
|
|||
<dependency>
|
||||
<groupId>com.mchange</groupId>
|
||||
<artifactId>c3p0</artifactId>
|
||||
<version>0.9.5.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- IMDG для MapStore -->
|
||||
|
|
|
|||
|
|
@ -81,7 +81,6 @@ public abstract class ObjectBaseMapStore<T extends SpcexObjectBase> extends Simp
|
|||
return rs.getObject(columnName, Long.class);
|
||||
}
|
||||
|
||||
// todo отрефакторить метод - длинное название
|
||||
protected Instant getInstantFromTimestamp(ResultSet rs, String column) throws SQLException {
|
||||
Timestamp date = rs.getTimestamp(column);
|
||||
return date != null ? date.toInstant() : null;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import org.springframework.jdbc.core.SqlTypeValue;
|
|||
import org.springframework.jdbc.core.StatementCreatorUtils;
|
||||
import org.springframework.lang.NonNull;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.utils.text.TextUtil;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
|
@ -16,6 +17,7 @@ import java.sql.Timestamp;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* MapStore для выгрузки обычных объектов
|
||||
|
|
@ -25,9 +27,9 @@ import java.util.*;
|
|||
public abstract class SimpleObjectMapStore<T extends SpcexObjectBase> implements MapStore<Long, T> {
|
||||
protected final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
protected SimpleDateFormat FIREBIRD_DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd");//todo уже не firebird, а PostgreSQL
|
||||
private final static int BATCH_SIZE = 1000;
|
||||
protected SimpleDateFormat DB_DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd");
|
||||
protected final JdbcTemplate jdbcTemplate;
|
||||
private final int bathSize = 1000;
|
||||
|
||||
protected SimpleObjectMapStore(JdbcTemplate jdbcTemplate) {
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
|
|
@ -37,13 +39,8 @@ public abstract class SimpleObjectMapStore<T extends SpcexObjectBase> implements
|
|||
|
||||
public abstract String[] getFields();
|
||||
|
||||
private boolean oidIsPresentInTheFields = Arrays.stream(getFields()).anyMatch(anotherString -> {
|
||||
if (anotherString == null) return false;
|
||||
return "oid".equalsIgnoreCase(anotherString.trim());
|
||||
});
|
||||
|
||||
public boolean deleteIsSupported() {
|
||||
return !oidIsPresentInTheFields;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -91,7 +88,8 @@ public abstract class SimpleObjectMapStore<T extends SpcexObjectBase> implements
|
|||
for (Long id : collection)
|
||||
listOfID.add(new Object[]{id});
|
||||
try {
|
||||
jdbcTemplate.batchUpdate("DELETE FROM " + getTableName() + " WHERE id=?", listOfID);
|
||||
String sql = String.format("DELETE FROM %s WHERE id = ?", getTableName());
|
||||
jdbcTemplate.batchUpdate(sql, listOfID);
|
||||
} catch (Exception e) {
|
||||
log.error("SQL error at batch DELETE FROM {}\n{}", getTableName(), ExceptionUtils.getStackTrace(e));
|
||||
log.info("List of non deleted ID {}", collection); // показать список неудалённых UUID
|
||||
|
|
@ -124,25 +122,9 @@ public abstract class SimpleObjectMapStore<T extends SpcexObjectBase> implements
|
|||
return keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Загружает ключи только за текущий день.
|
||||
* <code>where CAST(tradingday as DATE) = ?</code>
|
||||
* Осторожно со знаком: в некоторых случаях требуется за текущий и будущие дни, тогда этот метод не подходит.
|
||||
* См. так же loadAllKeys().
|
||||
*
|
||||
* @return список id
|
||||
*/
|
||||
protected List<Long> defaultLoadAllKeysOnTradingDay() {
|
||||
log.debug("loadAllKeys from " + getTableName());
|
||||
return jdbcTemplate.query("select id from " + getTableName() + " where CAST(tradingday as DATE) = ?",
|
||||
new Object[]{FIREBIRD_DATE_FORMATTER.format(new Date())},
|
||||
(resultSet, i) -> resultSet.getObject("id", Long.class));
|
||||
}
|
||||
|
||||
|
||||
protected void batchInsertUpdate(@NonNull String insertStatement, @NonNull List<Object[]> args) {
|
||||
try {
|
||||
int[][] ret = jdbcTemplate.batchUpdate(insertStatement, args, bathSize, (ps, params) -> {
|
||||
int[][] ret = jdbcTemplate.batchUpdate(insertStatement, args, BATCH_SIZE, (ps, params) -> {
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
Object value = params[i];
|
||||
try {
|
||||
|
|
@ -165,8 +147,22 @@ public abstract class SimpleObjectMapStore<T extends SpcexObjectBase> implements
|
|||
return date != null ? date.toInstant() : null;
|
||||
}
|
||||
|
||||
protected Timestamp timestampFromInstant(Instant instant) {
|
||||
if (instant == null) return null;
|
||||
return Timestamp.from(instant);
|
||||
protected String makeInsertSql(String tableName, String[] fields, String matchingKey) {
|
||||
String INSERT_TEMPLATE = "INSERT INTO ${tableName} (${columnsEnumeration}) VALUES (${valuesEnumeration}) ON CONFLICT (${matchingKey}) DO UPDATE SET ${excludedColumns}";
|
||||
|
||||
String columnsEnumeration = Arrays.stream(fields).map(f -> "" + f.toUpperCase() + "").collect(Collectors.joining(", "));
|
||||
String valuesEnumeration = String.join(", ", Collections.nCopies(fields.length, "?"));
|
||||
String excludedColumns = Arrays.stream(fields).filter(f -> !matchingKey.equalsIgnoreCase(f)).
|
||||
map(f -> "" + f.toUpperCase() + "=EXCLUDED." + f.toUpperCase() + "").collect(Collectors.joining(", "));
|
||||
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("tableName", tableName);
|
||||
params.put("columnsEnumeration", columnsEnumeration);
|
||||
params.put("valuesEnumeration", valuesEnumeration);
|
||||
params.put("matchingKey", matchingKey.toUpperCase());
|
||||
params.put("excludedColumns", excludedColumns);
|
||||
|
||||
|
||||
return TextUtil.format(INSERT_TEMPLATE, params);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ package ru.spcex.clearing.imdg.base;
|
|||
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import ru.clearing.classes.objects.BusinessEvent;
|
||||
import ru.clearing.classes.objects.BusinessObject;
|
||||
import ru.spcex.clearing.imdg.utils.DbUtilsHelper;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
|
||||
import java.util.*;
|
||||
|
|
@ -13,7 +11,7 @@ public abstract class TemplateEventMapStore<T extends BusinessEvent<? extends Sp
|
|||
implements AutoconfiguredMap<T> {
|
||||
|
||||
protected final int validateSize = getFields().length;
|
||||
protected final String insertStatement = DbUtilsHelper.createUpdateOrInsert(getTableName(), getFields(), "id");
|
||||
protected final String insertStatement = makeInsertSql(getTableName(), getFields(), "id");
|
||||
|
||||
public TemplateEventMapStore(JdbcTemplate jdbcTemplate) {
|
||||
super(jdbcTemplate);
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@ package ru.spcex.clearing.imdg.base;
|
|||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import ru.clearing.classes.objects.BusinessEvent;
|
||||
import ru.clearing.classes.objects.BusinessObject;
|
||||
import ru.spcex.clearing.imdg.utils.DbUtilsHelper;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
|
@ -16,7 +15,7 @@ import java.util.Map;
|
|||
public abstract class TemplateHistoryMapStore<T extends BusinessObject, TU extends BusinessEvent<T>> extends BusinessEventMapStore<TU> {
|
||||
|
||||
protected final int validateSize = getFields().length;
|
||||
protected final String insertStatement = DbUtilsHelper.createUpdateOrInsert(getTableName(), getFields(), "id");
|
||||
protected final String insertStatement = makeInsertSql(getTableName(), getFields(), "id");
|
||||
|
||||
public TemplateHistoryMapStore(JdbcTemplate jdbcTemplate) {
|
||||
super(jdbcTemplate);
|
||||
|
|
@ -45,7 +44,7 @@ public abstract class TemplateHistoryMapStore<T extends BusinessObject, TU exten
|
|||
protected Object[] objectToField(TU updateObject, T object) {
|
||||
ArrayList<Object> lst=new ArrayList<>();
|
||||
lst.add(updateObject.getId());
|
||||
lst.add(TimeUtil.fromInstant(updateObject.getEventTime()));
|
||||
lst.add(TimeUtil.toDateFromInstant(updateObject.getEventTime()));
|
||||
lst.add(updateObject.getUserId());
|
||||
lst.addAll(Arrays.asList(objectToField(object)));
|
||||
//todo order?
|
||||
|
|
@ -55,12 +54,12 @@ public abstract class TemplateHistoryMapStore<T extends BusinessObject, TU exten
|
|||
// companyUpdate.getUserId(),
|
||||
// new Object[]{
|
||||
// companyUpdate.getId(),
|
||||
// TimeUtil.fromInstant(companyUpdate.getEventTime()),
|
||||
// TimeUtil.toDateFromInstant(companyUpdate.getEventTime()),
|
||||
// companyUpdate.getUserId(),
|
||||
//
|
||||
// company.getId(), // company_id
|
||||
// TimeUtil.fromInstant(company.getCreated()),
|
||||
// TimeUtil.fromInstant(company.getUpdated()),
|
||||
// TimeUtil.toDateFromInstant(company.getCreated()),
|
||||
// TimeUtil.toDateFromInstant(company.getUpdated()),
|
||||
// company.getStatusId(),
|
||||
// company.getClearingCode(),
|
||||
// company.getExchangeCode()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package ru.spcex.clearing.imdg.base;
|
||||
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import ru.spcex.clearing.imdg.utils.DbUtilsHelper;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
|
|
@ -16,27 +15,12 @@ public abstract class TemplateMapStore<T extends SpcexObjectBase> extends Object
|
|||
|
||||
protected final int validateSize = getFields().length;
|
||||
|
||||
protected final String insertStatement = DbUtilsHelper.createUpdateOrInsert(getTableName(), getFields(), "id");
|
||||
protected final String insertStatement = makeInsertSql(getTableName(), getFields(), "id");
|
||||
|
||||
public TemplateMapStore(JdbcTemplate jdbcTemplate) {
|
||||
super(jdbcTemplate);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public String getTableName() {
|
||||
// return "COMPANY_ROLE_SET";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String[] getFields() {
|
||||
// return new String[]{"id", "roleid", "companyid"};
|
||||
// }
|
||||
|
||||
// //todo TradingDay флаг
|
||||
// protected boolean useTradingDay() {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return IMDGDistributedNames.*
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import ru.clearing.classes.statics.data.account.Account;
|
|||
import ru.clearing.classes.statics.data.account.AccountHistory;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateEventMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
@Component
|
||||
public class AccountHistoryMapStore extends TemplateEventMapStore<AccountHistory> {
|
||||
|
|
@ -41,8 +41,8 @@ public class AccountHistoryMapStore extends TemplateEventMapStore<AccountHistory
|
|||
updateLog.getUserId(),
|
||||
|
||||
object.getId(),
|
||||
TimeUtil.fromInstant(object.getCreated()),
|
||||
TimeUtil.fromInstant(object.getUpdated()),
|
||||
TimeUtil.toDateFromInstant(object.getCreated()),
|
||||
TimeUtil.toDateFromInstant(object.getUpdated()),
|
||||
object.getAccount(),
|
||||
object.getAccountType(),
|
||||
object.getRelationId(),
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@ import ru.clearing.classes.statics.data.company.Company;
|
|||
import ru.clearing.classes.statics.data.company.CompanyHistory;
|
||||
import ru.clearing.classes.statics.data.profile.CompanyInfo;
|
||||
import ru.spcex.clearing.imdg.base.BusinessEventMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.DbUtilsHelper;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
|
@ -43,8 +42,8 @@ public class CompanyHistoryMapStore extends BusinessEventMapStore<CompanyHistory
|
|||
};
|
||||
}
|
||||
|
||||
protected final String insertStatement = DbUtilsHelper.createUpdateOrInsert(getTableName(), getFields(), "id");
|
||||
protected final String insertCompanyInfoStatement = DbUtilsHelper.createUpdateOrInsert("COMPANY_INFO", getFieldsForCompanyInfo(), "id");
|
||||
protected final String insertStatement = makeInsertSql(getTableName(), getFields(), "id");
|
||||
protected final String insertCompanyInfoStatement = makeInsertSql("COMPANY_INFO", getFieldsForCompanyInfo(), "id");
|
||||
|
||||
@Override
|
||||
public void store(Map<Long, CompanyHistory> map) {
|
||||
|
|
@ -57,12 +56,12 @@ public class CompanyHistoryMapStore extends BusinessEventMapStore<CompanyHistory
|
|||
|
||||
Object[] args = new Object[]{
|
||||
companyHistory.getId(),
|
||||
TimeUtil.fromInstant(companyHistory.getEventTime()),
|
||||
TimeUtil.toDateFromInstant(companyHistory.getEventTime()),
|
||||
companyHistory.getUserId(),
|
||||
|
||||
company.getId(), // company_id
|
||||
TimeUtil.fromInstant(company.getCreated()),
|
||||
TimeUtil.fromInstant(company.getUpdated()),
|
||||
TimeUtil.toDateFromInstant(company.getCreated()),
|
||||
TimeUtil.toDateFromInstant(company.getUpdated()),
|
||||
company.getTradingCode(),
|
||||
company.getClearingCode(),
|
||||
company.getRegistrationCode(),
|
||||
|
|
@ -93,7 +92,7 @@ public class CompanyHistoryMapStore extends BusinessEventMapStore<CompanyHistory
|
|||
protected List<Object> companyInfoToSQLArgs(@NonNull CompanyInfo companyInfo, CompanyHistory rootUpdate) {
|
||||
return new ArrayList<>(Arrays.asList(
|
||||
rootUpdate.getId(),
|
||||
TimeUtil.fromInstant(rootUpdate.getEventTime()),
|
||||
TimeUtil.toDateFromInstant(rootUpdate.getEventTime()),
|
||||
rootUpdate.getUserId(),
|
||||
|
||||
companyInfo.getId(), // company_info_id
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import ru.clearing.classes.statics.data.company.relation.Relation;
|
|||
import ru.clearing.classes.statics.data.company.relation.RelationHistory;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateEventMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
|
||||
@Component
|
||||
|
|
@ -42,8 +42,8 @@ public class RelationHistoryMapStore extends TemplateEventMapStore<RelationHisto
|
|||
updateLog.getUserId(),
|
||||
|
||||
object.getId(),
|
||||
TimeUtil.fromInstant(object.getCreated()),
|
||||
TimeUtil.fromInstant(object.getUpdated()),
|
||||
TimeUtil.toDateFromInstant(object.getCreated()),
|
||||
TimeUtil.toDateFromInstant(object.getUpdated()),
|
||||
object.getConsumerId(),
|
||||
object.getSupplierId(),
|
||||
object.getServiceStatus(),
|
||||
|
|
|
|||
|
|
@ -6,12 +6,7 @@ import ru.clearing.classes.statics.data.security.Security;
|
|||
import ru.clearing.classes.statics.data.security.SecurityHistory;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateEventMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.DbUtilsHelper;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
@Component
|
||||
public class SecurityHistoryMapStore extends TemplateEventMapStore<SecurityHistory> {
|
||||
|
|
@ -46,8 +41,8 @@ public class SecurityHistoryMapStore extends TemplateEventMapStore<SecurityHisto
|
|||
updateLog.getUserId(),
|
||||
|
||||
object.getId(),
|
||||
TimeUtil.fromInstant(object.getCreated()),
|
||||
TimeUtil.fromInstant(object.getUpdated()),
|
||||
TimeUtil.toDateFromInstant(object.getCreated()),
|
||||
TimeUtil.toDateFromInstant(object.getUpdated()),
|
||||
object.getInstrumentType(),
|
||||
object.getIssuerId(),
|
||||
object.getShortName(),
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import ru.clearing.classes.statics.data.user.UserConnect;
|
|||
import ru.clearing.classes.statics.data.user.UserConnectHistory;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateEventMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
@Component
|
||||
public class UserConnectHistoryMapStore extends TemplateEventMapStore<UserConnectHistory> {
|
||||
|
|
@ -41,15 +41,15 @@ public class UserConnectHistoryMapStore extends TemplateEventMapStore<UserConnec
|
|||
historyLog.getUserId(),
|
||||
|
||||
object.getId(),
|
||||
TimeUtil.fromInstant(object.getCreated()),
|
||||
TimeUtil.fromInstant(object.getUpdated()),
|
||||
TimeUtil.toDateFromInstant(object.getCreated()),
|
||||
TimeUtil.toDateFromInstant(object.getUpdated()),
|
||||
object.getUserId(),
|
||||
TimeUtil.fromInstant(object.getConnectionTime()),
|
||||
TimeUtil.fromInstant(object.getDisconnectionTime()),
|
||||
TimeUtil.toDateFromInstant(object.getConnectionTime()),
|
||||
TimeUtil.toDateFromInstant(object.getDisconnectionTime()),
|
||||
object.getServerIP(),
|
||||
object.getClientIP(),
|
||||
object.getConnectionState(),
|
||||
TimeUtil.fromInstant(object.getClearingDate()),
|
||||
TimeUtil.toDateFromInstant(object.getClearingDate()),
|
||||
object.getErrorCode(),
|
||||
object.getErrorText()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import ru.clearing.classes.statics.data.user.User;
|
|||
import ru.clearing.classes.statics.data.user.UserHistory;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateEventMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
@Component
|
||||
public class UserHistoryMapStore extends TemplateEventMapStore<UserHistory> {
|
||||
|
|
@ -41,8 +41,8 @@ public class UserHistoryMapStore extends TemplateEventMapStore<UserHistory> {
|
|||
historyLog.getUserId(),
|
||||
|
||||
object.getId(),
|
||||
TimeUtil.fromInstant(object.getCreated()),
|
||||
TimeUtil.fromInstant(object.getUpdated()),
|
||||
TimeUtil.toDateFromInstant(object.getCreated()),
|
||||
TimeUtil.toDateFromInstant(object.getUpdated()),
|
||||
object.getIdentifier()
|
||||
};
|
||||
return args;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
|
@ -52,8 +52,8 @@ public class AccountMapStore extends TemplateMapStore<Account> {
|
|||
public Object[] objectToField(Account object) {
|
||||
Object[] args = new Object[]{
|
||||
object.getId(),
|
||||
TimeUtil.fromInstant(object.getCreated()),
|
||||
TimeUtil.fromInstant(object.getUpdated()),
|
||||
TimeUtil.toDateFromInstant(object.getCreated()),
|
||||
TimeUtil.toDateFromInstant(object.getUpdated()),
|
||||
object.getAccount(),
|
||||
object.getAccountType(),
|
||||
object.getRelationId(),
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.profile.CompanyInfo;
|
||||
import ru.spcex.clearing.imdg.base.BusinessObjectMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.DbUtilsHelper;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
|
@ -39,8 +38,8 @@ public class CompanyMapStore extends BusinessObjectMapStore<Company> {
|
|||
};
|
||||
}
|
||||
|
||||
protected final String insertStatement = DbUtilsHelper.createUpdateOrInsert(getTableName(), getFields(), "id");
|
||||
protected final String insertCompanyInfoStatement = DbUtilsHelper.createUpdateOrInsert("COMPANY_INFO", getFieldsForCompanyInfo(), "id");
|
||||
protected final String insertStatement = makeInsertSql(getTableName(), getFields(), "id");
|
||||
protected final String insertCompanyInfoStatement = makeInsertSql("COMPANY_INFO", getFieldsForCompanyInfo(), "id");
|
||||
|
||||
@Override
|
||||
public Collection<Company> load(Collection<Long> keys) {
|
||||
|
|
@ -70,8 +69,8 @@ public class CompanyMapStore extends BusinessObjectMapStore<Company> {
|
|||
|
||||
Object[] args = new Object[]{
|
||||
company.getId(),
|
||||
TimeUtil.fromInstant(company.getCreated()),
|
||||
TimeUtil.fromInstant(company.getUpdated()),
|
||||
TimeUtil.toDateFromInstant(company.getCreated()),
|
||||
TimeUtil.toDateFromInstant(company.getUpdated()),
|
||||
company.getTradingCode(),
|
||||
company.getClearingCode(),
|
||||
company.getRegistrationCode(),
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.messages.ErrorText;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
|
@ -51,12 +51,12 @@ public class ErrorTextMapStore extends TemplateMapStore<ErrorText> {
|
|||
public Object[] objectToField(ErrorText object) {
|
||||
Object[] args = new Object[]{
|
||||
object.getId(),
|
||||
TimeUtil.fromInstant(object.getCreated()),
|
||||
TimeUtil.fromInstant(object.getUpdated()),
|
||||
TimeUtil.toDateFromInstant(object.getCreated()),
|
||||
TimeUtil.toDateFromInstant(object.getUpdated()),
|
||||
object.getErrorCode(),
|
||||
object.getText(),
|
||||
object.getUserId(),
|
||||
TimeUtil.fromInstant(object.getClearingDate())
|
||||
TimeUtil.toDateFromInstant(object.getClearingDate())
|
||||
};
|
||||
return args;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
|
@ -53,8 +53,8 @@ public class RelationMapStore extends TemplateMapStore<Relation> {
|
|||
public Object[] objectToField(Relation object) {
|
||||
Object[] args = new Object[]{
|
||||
object.getId(),
|
||||
TimeUtil.fromInstant(object.getCreated()),
|
||||
TimeUtil.fromInstant(object.getUpdated()),
|
||||
TimeUtil.toDateFromInstant(object.getCreated()),
|
||||
TimeUtil.toDateFromInstant(object.getUpdated()),
|
||||
object.getConsumerId(),
|
||||
object.getSupplierId(),
|
||||
object.getServiceStatus(),
|
||||
|
|
|
|||
|
|
@ -5,12 +5,10 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.scheduler.Scheduler;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.DbUtilsHelper;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class SchedulerMapStore extends TemplateMapStore<Scheduler> {
|
||||
|
|
@ -55,11 +53,11 @@ public class SchedulerMapStore extends TemplateMapStore<Scheduler> {
|
|||
public Object[] objectToField(Scheduler object) {
|
||||
Object[] args = new Object[]{
|
||||
object.getId(),
|
||||
TimeUtil.fromInstant(object.getCreated()),
|
||||
TimeUtil.fromInstant(object.getUpdated()),
|
||||
TimeUtil.toDateFromInstant(object.getCreated()),
|
||||
TimeUtil.toDateFromInstant(object.getUpdated()),
|
||||
object.getTask(),
|
||||
TimeUtil.fromInstant(object.getTaskTime()),
|
||||
TimeUtil.fromInstant(object.getClearingDate()),
|
||||
TimeUtil.toDateFromInstant(object.getTaskTime()),
|
||||
TimeUtil.toDateFromInstant(object.getClearingDate()),
|
||||
object.getMarket(),
|
||||
object.getTaskStatus(),
|
||||
object.getSecurityId()
|
||||
|
|
|
|||
|
|
@ -5,12 +5,10 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.security.Security;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.DbUtilsHelper;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class SecurityMapStore extends TemplateMapStore<Security> {
|
||||
|
|
@ -57,8 +55,8 @@ public class SecurityMapStore extends TemplateMapStore<Security> {
|
|||
public Object[] objectToField(Security object) {
|
||||
Object[] args = new Object[]{
|
||||
object.getId(),
|
||||
TimeUtil.fromInstant(object.getCreated()),
|
||||
TimeUtil.fromInstant(object.getUpdated()),
|
||||
TimeUtil.toDateFromInstant(object.getCreated()),
|
||||
TimeUtil.toDateFromInstant(object.getUpdated()),
|
||||
object.getInstrumentType(),
|
||||
object.getIssuerId(),
|
||||
object.getShortName(),
|
||||
|
|
|
|||
|
|
@ -5,13 +5,11 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.statement.Statement;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.DbUtilsHelper;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class StatementMapStore extends TemplateMapStore<Statement> {
|
||||
|
|
@ -69,15 +67,15 @@ public class StatementMapStore extends TemplateMapStore<Statement> {
|
|||
object.getId(),
|
||||
object.getAddresseeId(),
|
||||
object.getSenderId(),
|
||||
TimeUtil.fromInstant(object.getCreated()),
|
||||
TimeUtil.fromInstant(object.getUpdated()),
|
||||
TimeUtil.fromInstant(object.getClearingDate()),
|
||||
TimeUtil.toDateFromInstant(object.getCreated()),
|
||||
TimeUtil.toDateFromInstant(object.getUpdated()),
|
||||
TimeUtil.toDateFromInstant(object.getClearingDate()),
|
||||
object.getStatementTypeId(),
|
||||
object.getComment(),
|
||||
object.getAccountId(),
|
||||
object.getAccount(),
|
||||
object.getInOutDirection(),
|
||||
TimeUtil.fromInstant(object.getSettlementDate()),
|
||||
TimeUtil.toDateFromInstant(object.getSettlementDate()),
|
||||
object.getAmount(),
|
||||
object.getCashMovementCurrencyCode(),
|
||||
object.getStatus(),
|
||||
|
|
|
|||
|
|
@ -5,12 +5,10 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.scheduler.TaskRunner;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.DbUtilsHelper;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class TaskRunnerMapStore extends TemplateMapStore<TaskRunner> {
|
||||
|
|
@ -51,8 +49,8 @@ public class TaskRunnerMapStore extends TemplateMapStore<TaskRunner> {
|
|||
public Object[] objectToField(TaskRunner object) {
|
||||
Object[] args = new Object[]{
|
||||
object.getId(),
|
||||
TimeUtil.fromInstant(object.getCreated()),
|
||||
TimeUtil.fromInstant(object.getUpdated()),
|
||||
TimeUtil.toDateFromInstant(object.getCreated()),
|
||||
TimeUtil.toDateFromInstant(object.getUpdated()),
|
||||
object.getSenderId(),
|
||||
object.getTask()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,12 +5,10 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.scheduler.Timetable;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.DbUtilsHelper;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class TimetableMapStore extends TemplateMapStore<Timetable> {
|
||||
|
|
@ -52,10 +50,10 @@ public class TimetableMapStore extends TemplateMapStore<Timetable> {
|
|||
public Object[] objectToField(Timetable object) {
|
||||
Object[] args = new Object[]{
|
||||
object.getId(),
|
||||
TimeUtil.fromInstant(object.getCreated()),
|
||||
TimeUtil.fromInstant(object.getUpdated()),
|
||||
TimeUtil.toDateFromInstant(object.getCreated()),
|
||||
TimeUtil.toDateFromInstant(object.getUpdated()),
|
||||
object.getTask(),
|
||||
TimeUtil.fromInstant(object.getTaskTime()),
|
||||
TimeUtil.toDateFromInstant(object.getTaskTime()),
|
||||
object.getTaskStatus()
|
||||
};
|
||||
return args;
|
||||
|
|
|
|||
|
|
@ -5,12 +5,10 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.scheduler.TradingCalendar;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.DbUtilsHelper;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class TradingCalendarMapStore extends TemplateMapStore<TradingCalendar> {
|
||||
|
|
@ -52,9 +50,9 @@ public class TradingCalendarMapStore extends TemplateMapStore<TradingCalendar> {
|
|||
public Object[] objectToField(TradingCalendar object) {
|
||||
Object[] args = new Object[]{
|
||||
object.getId(),
|
||||
TimeUtil.fromInstant(object.getCreated()),
|
||||
TimeUtil.fromInstant(object.getUpdated()),
|
||||
TimeUtil.fromInstant(object.getClearingDate()),
|
||||
TimeUtil.toDateFromInstant(object.getCreated()),
|
||||
TimeUtil.toDateFromInstant(object.getUpdated()),
|
||||
TimeUtil.toDateFromInstant(object.getClearingDate()),
|
||||
object.getCompanyId(),
|
||||
object.getTradingStatus()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,12 +5,10 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.user.UserConnect;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.DbUtilsHelper;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class UserConnectMapStore extends TemplateMapStore<UserConnect> {
|
||||
|
|
@ -58,15 +56,15 @@ public class UserConnectMapStore extends TemplateMapStore<UserConnect> {
|
|||
public Object[] objectToField(UserConnect object) {
|
||||
Object[] args = new Object[]{
|
||||
object.getId(),
|
||||
TimeUtil.fromInstant(object.getCreated()),
|
||||
TimeUtil.fromInstant(object.getUpdated()),
|
||||
TimeUtil.toDateFromInstant(object.getCreated()),
|
||||
TimeUtil.toDateFromInstant(object.getUpdated()),
|
||||
object.getUserId(),
|
||||
TimeUtil.fromInstant(object.getConnectionTime()),
|
||||
TimeUtil.fromInstant(object.getDisconnectionTime()),
|
||||
TimeUtil.toDateFromInstant(object.getConnectionTime()),
|
||||
TimeUtil.toDateFromInstant(object.getDisconnectionTime()),
|
||||
object.getServerIP(),
|
||||
object.getClientIP(),
|
||||
object.getConnectionState(),
|
||||
TimeUtil.fromInstant(object.getClearingDate()),
|
||||
TimeUtil.toDateFromInstant(object.getClearingDate()),
|
||||
object.getErrorCode(),
|
||||
object.getErrorText()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.user.User;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
|
@ -48,8 +48,8 @@ public class UserMapStore extends TemplateMapStore<User> {
|
|||
public Object[] objectToField(User object) {
|
||||
Object[] args = new Object[]{
|
||||
object.getId(),
|
||||
TimeUtil.fromInstant(object.getCreated()),
|
||||
TimeUtil.fromInstant(object.getUpdated()),
|
||||
TimeUtil.toDateFromInstant(object.getCreated()),
|
||||
TimeUtil.toDateFromInstant(object.getUpdated()),
|
||||
object.getIdentifier()
|
||||
};
|
||||
return args;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
|||
import org.springframework.stereotype.Component;
|
||||
import ru.clearing.classes.statics.data.company.CompanySymbols;
|
||||
import ru.spcex.clearing.imdg.base.ObjectBaseMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.DbUtilsHelper;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
|
@ -27,7 +26,7 @@ public class CompanySymbolsMapStore extends ObjectBaseMapStore<CompanySymbols> {
|
|||
};
|
||||
}
|
||||
|
||||
protected final String insertStatement = DbUtilsHelper.createUpdateOrInsert(getTableName(), getFields(), "id");
|
||||
protected final String insertStatement = makeInsertSql(getTableName(), getFields(), "id");
|
||||
|
||||
@Override
|
||||
public Collection<CompanySymbols> load(Collection<Long> keys) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
|||
import org.springframework.stereotype.Component;
|
||||
import ru.clearing.classes.statics.data.profile.Contact;
|
||||
import ru.spcex.clearing.imdg.base.ObjectBaseMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.DbUtilsHelper;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
|
@ -27,7 +26,7 @@ public class ContactMapStore extends ObjectBaseMapStore<Contact> {
|
|||
};
|
||||
}
|
||||
|
||||
protected final String insertStatement = DbUtilsHelper.createUpdateOrInsert(getTableName(), getFields(), "id");
|
||||
protected final String insertStatement = makeInsertSql(getTableName(), getFields(), "id");
|
||||
|
||||
@Override
|
||||
public Collection<Contact> load(Collection<Long> keys) {
|
||||
|
|
|
|||
|
|
@ -5,13 +5,11 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.journal.InDocumentJournal;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.DbUtilsHelper;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class InDocumentJournalMapStore extends TemplateMapStore<InDocumentJournal> {
|
||||
|
|
@ -61,19 +59,19 @@ public class InDocumentJournalMapStore extends TemplateMapStore<InDocumentJourna
|
|||
public Object[] objectToField(InDocumentJournal object) {
|
||||
Object[] args = new Object[]{
|
||||
object.getId(),
|
||||
TimeUtil.fromInstant(object.getRegistrationDate()),
|
||||
TimeUtil.fromInstant(object.getRegistrationTime()),
|
||||
TimeUtil.toDateFromInstant(object.getRegistrationDate()),
|
||||
TimeUtil.toDateFromInstant(object.getRegistrationTime()),
|
||||
object.getRegistrationNumber(),
|
||||
object.getDocumentName(),
|
||||
object.getSenderId(),
|
||||
object.getQuantity(),
|
||||
object.getClearingCode(),
|
||||
object.getCourierType(),
|
||||
TimeUtil.fromInstant(object.getEmailDate()),
|
||||
TimeUtil.toDateFromInstant(object.getEmailDate()),
|
||||
object.getAmount(),
|
||||
object.getDossierNumber(),
|
||||
object.getComment(),
|
||||
TimeUtil.fromInstant(object.getReceiptDate())
|
||||
TimeUtil.toDateFromInstant(object.getReceiptDate())
|
||||
};
|
||||
return args;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ package ru.spcex.clearing.imdg.object;
|
|||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.clearing.classes.statics.data.misc.KeyRate;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
|
@ -54,8 +54,8 @@ public class KeyRateMapStore extends TemplateMapStore<KeyRate> {
|
|||
Object[] args = new Object[]{
|
||||
partnerList.getId(),
|
||||
partnerList.getRate(),
|
||||
TimeUtil.fromInstant(partnerList.getStartDate()),
|
||||
TimeUtil.fromInstant(partnerList.getEndDate()),
|
||||
TimeUtil.toDateFromInstant(partnerList.getStartDate()),
|
||||
TimeUtil.toDateFromInstant(partnerList.getEndDate()),
|
||||
partnerList.getDocument(),
|
||||
partnerList.getWorkflowStatus()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ package ru.spcex.clearing.imdg.object;
|
|||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.clearing.classes.statics.data.misc.MoneyMarketSecurity;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
|
|
@ -60,8 +60,8 @@ public class MoneyMarketSecurityMapStore extends TemplateMapStore<MoneyMarketSec
|
|||
moneyMarketSecurity.getId(),
|
||||
moneyMarketSecurity.getSecurityId(),
|
||||
moneyMarketSecurity.getDescription(),
|
||||
TimeUtil.fromInstant(moneyMarketSecurity.getStartDate()),
|
||||
TimeUtil.fromInstant(moneyMarketSecurity.getEndDate()),
|
||||
TimeUtil.toDateFromInstant(moneyMarketSecurity.getStartDate()),
|
||||
TimeUtil.toDateFromInstant(moneyMarketSecurity.getEndDate()),
|
||||
moneyMarketSecurity.getNominalValue(),
|
||||
moneyMarketSecurity.getNominalCurrency(),
|
||||
moneyMarketSecurity.getInstrumentType(),
|
||||
|
|
|
|||
|
|
@ -5,13 +5,11 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.journal.OutDocumentJournal;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.DbUtilsHelper;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class OutDocumentJournalMapStore extends TemplateMapStore<OutDocumentJournal> {
|
||||
|
|
@ -60,18 +58,18 @@ public class OutDocumentJournalMapStore extends TemplateMapStore<OutDocumentJour
|
|||
public Object[] objectToField(OutDocumentJournal object) {
|
||||
Object[] args = new Object[]{
|
||||
object.getId(),
|
||||
TimeUtil.fromInstant(object.getRegistrationDate()),
|
||||
TimeUtil.fromInstant(object.getRegistrationTime()),
|
||||
TimeUtil.toDateFromInstant(object.getRegistrationDate()),
|
||||
TimeUtil.toDateFromInstant(object.getRegistrationTime()),
|
||||
object.getRegistrationNumber(),
|
||||
object.getDocumentName(),
|
||||
object.getAddresseeId(),
|
||||
object.getQuantity(),
|
||||
object.getClearingCode(),
|
||||
object.getCourierType(),
|
||||
TimeUtil.fromInstant(object.getEmailDate()),
|
||||
TimeUtil.toDateFromInstant(object.getEmailDate()),
|
||||
object.getAmount(),
|
||||
object.getDossierNumber(),
|
||||
TimeUtil.fromInstant(object.getPostDate())
|
||||
TimeUtil.toDateFromInstant(object.getPostDate())
|
||||
};
|
||||
return args;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
|||
import org.springframework.stereotype.Component;
|
||||
import ru.clearing.classes.statics.data.profile.ProfileDocument;
|
||||
import ru.spcex.clearing.imdg.base.ObjectBaseMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.DbUtilsHelper;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
|
@ -29,7 +28,7 @@ public class ProfileDocumentMapStore extends ObjectBaseMapStore<ProfileDocument>
|
|||
};
|
||||
}
|
||||
|
||||
protected final String insertStatement = DbUtilsHelper.createUpdateOrInsert(getTableName(), getFields(), "id");
|
||||
protected final String insertStatement = makeInsertSql(getTableName(), getFields(), "id");
|
||||
|
||||
@Override
|
||||
public Collection<ProfileDocument> load(Collection<Long> keys) {
|
||||
|
|
@ -65,15 +64,15 @@ public class ProfileDocumentMapStore extends ObjectBaseMapStore<ProfileDocument>
|
|||
profileDocument.getId(),
|
||||
profileDocument.getCompanyId(),
|
||||
profileDocument.getDocumentType(),
|
||||
TimeUtil.fromInstant(profileDocument.getIssueDate()),
|
||||
TimeUtil.toDateFromInstant(profileDocument.getIssueDate()),
|
||||
profileDocument.getIssuePlace(),
|
||||
profileDocument.getIssuer(),
|
||||
profileDocument.getIssuerCode(),
|
||||
profileDocument.getName(),
|
||||
profileDocument.getNumber(),
|
||||
profileDocument.getPlace(),
|
||||
TimeUtil.fromInstant(profileDocument.getValidFromDate()),
|
||||
TimeUtil.fromInstant(profileDocument.getValidToDate()),
|
||||
TimeUtil.toDateFromInstant(profileDocument.getValidFromDate()),
|
||||
TimeUtil.toDateFromInstant(profileDocument.getValidToDate()),
|
||||
profileDocument.getLink()
|
||||
};
|
||||
batchArgs.add(args);
|
||||
|
|
|
|||
|
|
@ -5,12 +5,10 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.sdf.SDf01;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.DbUtilsHelper;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class SDf01MapStore extends TemplateMapStore<SDf01> {
|
||||
|
|
@ -75,7 +73,7 @@ public class SDf01MapStore extends TemplateMapStore<SDf01> {
|
|||
object.getSumunblock(),
|
||||
object.getFile_type(),
|
||||
object.getFileName(),
|
||||
TimeUtil.fromInstant(object.getGenerationTime()),
|
||||
TimeUtil.toDateFromInstant(object.getGenerationTime()),
|
||||
object.getGenerationId()
|
||||
};
|
||||
return args;
|
||||
|
|
|
|||
|
|
@ -5,12 +5,10 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.sdf.SDf02;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.DbUtilsHelper;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class SDf02MapStore extends TemplateMapStore<SDf02> {
|
||||
|
|
@ -76,7 +74,7 @@ public class SDf02MapStore extends TemplateMapStore<SDf02> {
|
|||
object.getSumunblock(),
|
||||
object.getFile_type(),
|
||||
object.getResult(),
|
||||
TimeUtil.fromInstant(object.getGenerationTime()),
|
||||
TimeUtil.toDateFromInstant(object.getGenerationTime()),
|
||||
object.getGenerationId(),
|
||||
object.getInSDf01Id()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.sdf.SDf03;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
|
@ -142,7 +142,7 @@ public class SDf03MapStore extends TemplateMapStore<SDf03> {
|
|||
object.getServdate(),
|
||||
object.getDoc_result(),
|
||||
object.getImp_result(),
|
||||
TimeUtil.fromInstant(object.getGenerationTime()),
|
||||
TimeUtil.toDateFromInstant(object.getGenerationTime()),
|
||||
object.getGenerationId()
|
||||
};
|
||||
return args;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.sdf.SDf05;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
|
|
@ -53,10 +53,10 @@ public class SDf05MapStore extends TemplateMapStore<SDf05> {
|
|||
Object[] args = new Object[]{
|
||||
object.getId(),
|
||||
object.getTp(),
|
||||
TimeUtil.from(object.getDt()),
|
||||
TimeUtil.from(object.getTm()),
|
||||
TimeUtil.toDateFromLocalDate(object.getDt()),
|
||||
TimeUtil.toDateFromLocalTime(object.getTm()),
|
||||
object.getPr(),
|
||||
TimeUtil.fromInstant(object.getGenerationTime()),
|
||||
TimeUtil.toDateFromInstant(object.getGenerationTime()),
|
||||
object.getGenerationId()
|
||||
};
|
||||
return args;
|
||||
|
|
|
|||
|
|
@ -5,13 +5,11 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.sdf.SDf08;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.DbUtilsHelper;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class SDf08MapStore extends TemplateMapStore<SDf08> {
|
||||
|
|
@ -53,8 +51,8 @@ public class SDf08MapStore extends TemplateMapStore<SDf08> {
|
|||
Object[] args = new Object[]{
|
||||
object.getId(),
|
||||
object.getNumber(),
|
||||
TimeUtil.fromInstant(object.getDatetime()),
|
||||
TimeUtil.fromInstant(object.getGenerationTime()),
|
||||
TimeUtil.toDateFromInstant(object.getDatetime()),
|
||||
TimeUtil.toDateFromInstant(object.getGenerationTime()),
|
||||
object.getGenerationId()
|
||||
};
|
||||
return args;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.sdf.SDf10;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
|
|
@ -62,7 +62,7 @@ public class SDf10MapStore extends TemplateMapStore<SDf10> {
|
|||
object.getNumber(),
|
||||
object.getINN(),
|
||||
object.getResult(),
|
||||
TimeUtil.fromInstant(object.getGenerationTime()),
|
||||
TimeUtil.toDateFromInstant(object.getGenerationTime()),
|
||||
object.getGenerationId(),
|
||||
object.getIn_s_df09_id()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.sdf.SDf11;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
|
@ -142,7 +142,7 @@ public class SDf11MapStore extends TemplateMapStore<SDf11> {
|
|||
object.getSend_type(),
|
||||
object.getServdate(),
|
||||
object.getDoc_result(),
|
||||
TimeUtil.fromInstant(object.getGenerationTime()),
|
||||
TimeUtil.toDateFromInstant(object.getGenerationTime()),
|
||||
object.getGenerationId()
|
||||
};
|
||||
return args;
|
||||
|
|
|
|||
|
|
@ -6,13 +6,11 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.sdf.SDf12;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.DbUtilsHelper;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class SDf12MapStore extends TemplateMapStore<SDf12> {
|
||||
|
|
@ -59,7 +57,7 @@ public class SDf12MapStore extends TemplateMapStore<SDf12> {
|
|||
object.getDeal(),
|
||||
object.getStatus(),
|
||||
object.getFileName(),
|
||||
TimeUtil.fromInstant(object.getGenerationTime()),
|
||||
TimeUtil.toDateFromInstant(object.getGenerationTime()),
|
||||
object.getGenerationId()
|
||||
};
|
||||
return args;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.sdf.SDf13;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
|
@ -140,7 +140,7 @@ public class SDf13MapStore extends TemplateMapStore<SDf13> {
|
|||
object.getSend_type(),
|
||||
object.getServdate(),
|
||||
object.getDoc_result(),
|
||||
TimeUtil.fromInstant(object.getGenerationTime()),
|
||||
TimeUtil.toDateFromInstant(object.getGenerationTime()),
|
||||
object.getGenerationId()
|
||||
};
|
||||
return args;
|
||||
|
|
|
|||
|
|
@ -5,13 +5,11 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.sdf.SDf16;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.DbUtilsHelper;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class SDf16MapStore extends TemplateMapStore<SDf16> {
|
||||
|
|
@ -61,7 +59,7 @@ public class SDf16MapStore extends TemplateMapStore<SDf16> {
|
|||
public Object[] objectToField(SDf16 object) {
|
||||
Object[] args = new Object[]{
|
||||
object.getId(),
|
||||
TimeUtil.fromInstant(object.getDate()),
|
||||
TimeUtil.toDateFromInstant(object.getDate()),
|
||||
object.getAccount(),
|
||||
object.getSum(),
|
||||
object.getMarket(),
|
||||
|
|
@ -72,7 +70,7 @@ public class SDf16MapStore extends TemplateMapStore<SDf16> {
|
|||
object.getNumber(),
|
||||
object.getResultCode(),
|
||||
object.getFileName(),
|
||||
TimeUtil.fromInstant(object.getGenerationTime()),
|
||||
TimeUtil.toDateFromInstant(object.getGenerationTime()),
|
||||
object.getGenerationId()
|
||||
};
|
||||
return args;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.sdf.SDf17;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
|
|
@ -67,7 +67,7 @@ public class SDf17MapStore extends TemplateMapStore<SDf17> {
|
|||
object.getSPEC(),
|
||||
object.getNumber(),
|
||||
object.getResult(),
|
||||
TimeUtil.fromInstant(object.getGenerationTime()),
|
||||
TimeUtil.toDateFromInstant(object.getGenerationTime()),
|
||||
object.getGenerationId(),
|
||||
object.getIn_s_df16_id()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,16 +2,14 @@ package ru.spcex.clearing.imdg.object;
|
|||
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.clearing.classes.statics.data.sdf.SDf18;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.DbUtilsHelper;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class SDf18MapStore extends TemplateMapStore<SDf18> {
|
||||
|
|
@ -59,7 +57,7 @@ public class SDf18MapStore extends TemplateMapStore<SDf18> {
|
|||
object.getDeal(),
|
||||
object.getStatus(),
|
||||
object.getResult(),
|
||||
TimeUtil.fromInstant(object.getGenerationTime()),
|
||||
TimeUtil.toDateFromInstant(object.getGenerationTime()),
|
||||
object.getGenerationId(),
|
||||
object.getInSDf12Id()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,12 +5,10 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.scheduler.SchedulerAllToday;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.DbUtilsHelper;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class SchedulerAllTodayMapStore extends TemplateMapStore<SchedulerAllToday> {
|
||||
|
|
@ -56,8 +54,8 @@ public class SchedulerAllTodayMapStore extends TemplateMapStore<SchedulerAllToda
|
|||
Object[] args = new Object[]{
|
||||
object.getId(),
|
||||
object.getTask(),
|
||||
TimeUtil.fromInstant(object.getTaskTime()),
|
||||
TimeUtil.fromInstant(object.getClearingDate()),
|
||||
TimeUtil.toDateFromInstant(object.getTaskTime()),
|
||||
TimeUtil.toDateFromInstant(object.getClearingDate()),
|
||||
object.getMarket(),
|
||||
object.getTaskStatus(),
|
||||
object.getSecurityId(),
|
||||
|
|
|
|||
|
|
@ -5,12 +5,9 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.user.UserRoleSession;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.DbUtilsHelper;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class UserRoleSessionMapStore extends TemplateMapStore<UserRoleSession> {
|
||||
|
|
|
|||
|
|
@ -5,12 +5,9 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.user.UserSettings;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.utils.DbUtilsHelper;
|
||||
import ru.spcex.clearing.imdg.utils.TimeUtil;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class UserSettingsMapStore extends TemplateMapStore<UserSettings> {
|
||||
|
|
|
|||
|
|
@ -1,111 +0,0 @@
|
|||
package ru.spcex.clearing.imdg.utils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
|
||||
public class BigDecimalUtil {
|
||||
|
||||
private static final DecimalFormat defaultDecimalFormat;
|
||||
|
||||
static {
|
||||
DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols();
|
||||
decimalFormatSymbols.setDecimalSeparator('.');
|
||||
decimalFormatSymbols.setGroupingSeparator(' ');
|
||||
defaultDecimalFormat = new DecimalFormat("#,###.00", decimalFormatSymbols);
|
||||
}
|
||||
|
||||
public static BigDecimal sum(BigDecimal num1, BigDecimal num2) {
|
||||
BigDecimal sum = BigDecimal.ZERO;
|
||||
if (num1 != null)
|
||||
sum = sum.add(num1);
|
||||
if (num2 != null)
|
||||
sum = sum.add(num2);
|
||||
return sum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value
|
||||
* @param dbSize общее кол-во позиций
|
||||
* @param dbScale кол-во позиций под дробную часть
|
||||
* @return true, если размер целой части не превышает значения, указанные в параметрах
|
||||
*/
|
||||
public static boolean checkSize(BigDecimal value, int dbSize, int dbScale) {
|
||||
if (value == null)
|
||||
return true;
|
||||
return value.precision() - value.scale() <= dbSize - dbScale;
|
||||
}
|
||||
|
||||
public static BigDecimal genMaxValueForInsert(int dbSize, int dbScale) {
|
||||
int maxIntSizeForInsert = dbSize - dbScale;
|
||||
long newLongValue = new BigDecimal(Math.pow(10, maxIntSizeForInsert)).longValue();
|
||||
return new BigDecimal(newLongValue - 1);
|
||||
}
|
||||
|
||||
public static BigDecimal chooseHighest(BigDecimal oldPrice, BigDecimal newPrice) {
|
||||
if (newPrice != null && (oldPrice == null || isLess(oldPrice, newPrice))) {
|
||||
return newPrice;
|
||||
} else {
|
||||
return oldPrice;
|
||||
}
|
||||
}
|
||||
|
||||
public static BigDecimal chooseSmallest(BigDecimal oldPrice, BigDecimal newPrice) {
|
||||
if (newPrice != null && (oldPrice == null || isLess(newPrice, oldPrice))) {
|
||||
return newPrice;
|
||||
} else {
|
||||
return oldPrice;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Если bestPrice меньше price, то true, иначе false
|
||||
*
|
||||
* @param bestPrice
|
||||
* @param price
|
||||
* @return
|
||||
*/
|
||||
public static boolean isLess(BigDecimal bestPrice, BigDecimal price) {
|
||||
return price != null && bestPrice != null && bestPrice.compareTo(price) < 0;
|
||||
}
|
||||
|
||||
public static Integer nullSafeAdd(Integer a, Integer b) {
|
||||
if (a == null) {
|
||||
return b;
|
||||
} else if (b == null) {
|
||||
return a;
|
||||
} else {
|
||||
return a + b;
|
||||
}
|
||||
}
|
||||
|
||||
public static BigDecimal nullSafeAdd(BigDecimal a, BigDecimal b) {
|
||||
if (a == null) {
|
||||
return b;
|
||||
} else if (b == null) {
|
||||
return a;
|
||||
} else {
|
||||
return a.add(b);
|
||||
}
|
||||
}
|
||||
|
||||
public static Long nullSafeAdd(Long a, Long b) {
|
||||
if (a == null) {
|
||||
return b;
|
||||
} else if (b == null) {
|
||||
return a;
|
||||
} else {
|
||||
return a + b;
|
||||
}
|
||||
}
|
||||
|
||||
public static String defaultFormatValue(BigDecimal val) {
|
||||
DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols();
|
||||
decimalFormatSymbols.setDecimalSeparator('.');
|
||||
decimalFormatSymbols.setGroupingSeparator(' ');
|
||||
if (val == null) {
|
||||
return "";
|
||||
}
|
||||
return defaultDecimalFormat.format(val);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
package ru.spcex.clearing.imdg.utils;
|
||||
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
public class DbDefaultConfig {
|
||||
public static DataSource getEmbeddedDatabase(String embeddedFilePath) {
|
||||
throw new UnsupportedOperationException("Are PostgreSQL not supported embedded DB?");//todo PsotgreSQL для юнит тестов
|
||||
}
|
||||
}
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
package ru.spcex.clearing.imdg.utils;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
//todo зарефакторить
|
||||
public class DbUtilsHelper {
|
||||
|
||||
private static String generateValuesBlock(int querySignCount) {
|
||||
return StringUtils.rightPad("(?", querySignCount * 3 - 1, ", ?") + ")";
|
||||
}
|
||||
|
||||
private static Pattern pGetColumns = Pattern.compile("(?m)(?i)INTO\\s+[0-9a-z\" _$]+\\s+\\(\\s*([0-9a-z_\\- ,\"\\n+]*?)\\s*\\)");
|
||||
|
||||
public static String fillValuesBlock(String insertStatement) {
|
||||
|
||||
Matcher m = pGetColumns.matcher(insertStatement);
|
||||
if (m.find()) {
|
||||
String g = m.group(1);
|
||||
String block = generateValuesBlock(g.split(",").length);
|
||||
return insertStatement.replaceAll("%values_block%", block);
|
||||
} else {
|
||||
return insertStatement;
|
||||
}
|
||||
}
|
||||
|
||||
public static String createInsert(String tableName, String[] fields) {
|
||||
return "INSERT INTO " + tableName +
|
||||
" (" + Arrays.stream(fields).map(f -> "\"" + f.toUpperCase() + "\"").collect(Collectors.joining(", ")) + ") values (" +
|
||||
// Arrays.stream(fields).map(f -> "\"" + f.toUpperCase() + "\"").collect(Collectors.joining(", ", ":", ""));
|
||||
String.join(", ", Collections.nCopies(fields.length, "?")) +
|
||||
")";
|
||||
}
|
||||
|
||||
public static String createUpdateOrInsert(String tableName, String[] fields, String matchingKey) {
|
||||
String updateOrInsert = "INSERT INTO " + tableName +
|
||||
" (" + Arrays.stream(fields).map(f -> "" + f.toUpperCase() + "").collect(Collectors.joining(", ")) + ") values (" +
|
||||
// Arrays.stream(fields).map(f -> "\"" + f.toUpperCase() + "\"").collect(Collectors.joining(", ", ":", ""));
|
||||
String.join(", ", Collections.nCopies(fields.length, "?")) +
|
||||
") ON CONFLICT ";
|
||||
updateOrInsert += "(" + matchingKey.toUpperCase()+")";
|
||||
updateOrInsert += " DO UPDATE SET " + Arrays.stream(fields).filter(f->!matchingKey.equalsIgnoreCase(f)).map(f -> "" + f.toUpperCase() + "=EXCLUDED." + f.toUpperCase() + "").collect(Collectors.joining(", "));
|
||||
|
||||
return updateOrInsert;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,294 +0,0 @@
|
|||
package ru.spcex.clearing.imdg.utils;
|
||||
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.sql.Time;
|
||||
import java.time.*;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Для работы с java.util.Date
|
||||
* И конвертация в новый формат
|
||||
* todo добавить юниттест.
|
||||
* todo зарефакторить
|
||||
*/
|
||||
public class TimeUtil {
|
||||
private static final Logger log = LoggerFactory.getLogger(TimeUtil.class);
|
||||
public static final ZoneId zone = ZoneId.systemDefault();
|
||||
|
||||
/**
|
||||
* Получить дату без времени (начало дня)
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
public static Date getDateOnStartOfDay(Date date) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить начало следующего дня
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
public static Date getDateNextDay(Date date) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
public static LocalDateTime toDateTime(Date fromDate) {
|
||||
if (fromDate == null)
|
||||
return null;
|
||||
if (fromDate instanceof java.sql.Timestamp)
|
||||
return ((java.sql.Timestamp) fromDate).toLocalDateTime();
|
||||
if (fromDate instanceof java.sql.Date || fromDate instanceof java.sql.Time)
|
||||
log.debug("Warning at converting date/time: for class {} may not contain date or time. unixtime={}", fromDate.getClass(), fromDate.getTime());
|
||||
return toDateTime0(fromDate);
|
||||
}
|
||||
|
||||
private static LocalDateTime toDateTime0(Date fromDate) {
|
||||
try {
|
||||
if (fromDate instanceof java.sql.Date) {
|
||||
Instant instant = Instant.now(); //can be LocalDateTime
|
||||
ZoneId systemZone = ZoneId.systemDefault(); // my timezone
|
||||
ZoneOffset currentOffsetForMyZone = systemZone.getRules().getOffset(instant);
|
||||
return LocalDateTime.ofEpochSecond(fromDate.getTime() / 1000, 0, currentOffsetForMyZone);
|
||||
}
|
||||
return LocalDateTime.ofInstant(fromDate.toInstant(), ZoneId.systemDefault());
|
||||
} catch (UnsupportedOperationException ue) {
|
||||
log.warn("Error(warn) convert type of date/time: {}({}) class: {}. Retry", fromDate, fromDate.getTime(), fromDate.getClass());
|
||||
try {
|
||||
Instant instant = Instant.now(); //can be LocalDateTime
|
||||
ZoneId systemZone = ZoneId.systemDefault(); // my timezone
|
||||
ZoneOffset currentOffsetForMyZone = systemZone.getRules().getOffset(instant);
|
||||
return LocalDateTime.ofEpochSecond(fromDate.getTime() / 1000, 0, currentOffsetForMyZone);
|
||||
} catch (Exception e) {
|
||||
log.error("Error convert type2 of date/time: {} class: {}\n{}", fromDate, fromDate.getClass(), ExceptionUtils.getStackTrace(ue));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// Date out = Date.from(ldt.atZone(ZoneId.systemDefault()).toInstant());
|
||||
}
|
||||
|
||||
public static LocalDate toDate(Date fromDate) {
|
||||
if (fromDate == null)
|
||||
return null;
|
||||
if (fromDate instanceof java.sql.Date)
|
||||
return ((java.sql.Date) fromDate).toLocalDate();
|
||||
if (fromDate instanceof java.sql.Time)
|
||||
log.debug("Warning at converting date/time: for class {} may not contain date. unixtime={}", fromDate.getClass(), fromDate.getTime());
|
||||
return toDateTime0(fromDate).toLocalDate();
|
||||
}
|
||||
|
||||
public static LocalTime toTime(Date fromDate) {
|
||||
if (fromDate == null)
|
||||
return null;
|
||||
if (fromDate instanceof java.sql.Time)
|
||||
return ((java.sql.Time) fromDate).toLocalTime();
|
||||
if (fromDate instanceof java.sql.Date)
|
||||
log.debug("Warning at converting date/time: for class {} may not contain time. unixtime={}", fromDate.getClass(), fromDate.getTime());
|
||||
return toDateTime0(fromDate).toLocalTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Последовательный ряд дат дней между двумя датами.
|
||||
*
|
||||
* @param from с даты, включительно
|
||||
* @param to по дату, включительно.
|
||||
* @return
|
||||
*/
|
||||
public static Date[] makeDateRange(Date from, Date to) {
|
||||
ArrayList<Date> datesL = new ArrayList<Date>();
|
||||
LocalDate fromDate = toDate(from);
|
||||
LocalDate toDate = toDate(to);
|
||||
datesL.add(from);
|
||||
for (LocalDate dateI = fromDate.plusDays(1); dateI.isBefore(toDate); dateI = dateI.plusDays(1)) {
|
||||
Date date = Date.from(dateI.atStartOfDay(ZoneId.systemDefault()).toInstant());
|
||||
datesL.add(date);
|
||||
}
|
||||
if (!fromDate.equals(toDate))
|
||||
datesL.add(to);
|
||||
Date[] dates = datesL.toArray(new Date[0]);
|
||||
return dates;
|
||||
}
|
||||
|
||||
public static Date fromInstant(Instant instant) {
|
||||
if (instant == null) return null;
|
||||
return Date.from(instant);
|
||||
}
|
||||
|
||||
public static Date from(LocalDateTime localDateTime) {
|
||||
return localDateTime != null ? Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()) : null;
|
||||
}
|
||||
|
||||
public static Time from(LocalTime localTime) {
|
||||
return localTime != null ? Time.valueOf(localTime) : null;
|
||||
}
|
||||
|
||||
public static Date from(LocalDate localDate) {
|
||||
return localDate != null ? Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* иногда встречается java.sql.Date
|
||||
* у них toInstant() не поддерживается
|
||||
*/
|
||||
public static Instant fromDate(Date dateToConvert) {
|
||||
try {
|
||||
if (dateToConvert == null) return null;
|
||||
return dateToConvert.toInstant();
|
||||
} catch (UnsupportedOperationException e) {
|
||||
// log.warn("java.sql.Date");
|
||||
if (dateToConvert instanceof java.sql.Date) {
|
||||
return ((java.sql.Date) dateToConvert).toLocalDate().atStartOfDay(ZoneId.systemDefault()).toInstant();
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Instant fromDate(LocalDate dateToConvert) {
|
||||
return dateToConvert == null ? null : dateToConvert.atStartOfDay(ZoneId.systemDefault()).toInstant();
|
||||
}
|
||||
|
||||
public static LocalDateTime toDateTime(Instant instant) {
|
||||
if (instant == null) {
|
||||
return null;
|
||||
} else {
|
||||
return LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
|
||||
}
|
||||
}
|
||||
|
||||
public static Date toUtilDate(java.sql.Date sqlDate) {
|
||||
return sqlDate != null ? new Date(sqlDate.getTime()) : null;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isCurrentTradingDay(Date date) {
|
||||
Date tradingDay = getDateOnStartOfDay(date);
|
||||
Date currentDay = getDateOnStartOfDay(new Date());
|
||||
return currentDay.equals(tradingDay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Начало дня по текущей временной зоне
|
||||
*/
|
||||
public static Instant startOfDayNow() {
|
||||
ZonedDateTime zdtStart = ZonedDateTime.now();
|
||||
zdtStart = zdtStart.truncatedTo(ChronoUnit.DAYS);
|
||||
return zdtStart.toInstant();
|
||||
}
|
||||
|
||||
/**
|
||||
* Начало дня по текущей временной зоне.
|
||||
*
|
||||
* @param from
|
||||
* @return
|
||||
*/
|
||||
public static Instant startOfDay(Instant from) {
|
||||
ZonedDateTime zdtStart = from.atZone(ZoneId.systemDefault());
|
||||
zdtStart = zdtStart.truncatedTo(ChronoUnit.DAYS);
|
||||
return zdtStart.toInstant();
|
||||
}
|
||||
|
||||
public static ZonedDateTime toZoned(Instant instant) {
|
||||
if (instant == null) return null;
|
||||
return instant.atZone(zone);
|
||||
}
|
||||
|
||||
public static LocalDate toDate(Instant instant) {
|
||||
ZonedDateTime zoned = toZoned(instant);
|
||||
if (zoned == null) return null;
|
||||
return zoned.toLocalDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Сегодня (от начала дня) или позднее
|
||||
*
|
||||
* @param instant дата, может ыть null
|
||||
* @return
|
||||
*/
|
||||
public static boolean afterToday(Instant instant) {
|
||||
LocalDate localDate = toDate(instant);
|
||||
return afterToday(localDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Сегодня (от начала дня) или позднее
|
||||
*
|
||||
* @param date дата, может ыть null
|
||||
* @return
|
||||
*/
|
||||
public static boolean afterToday(Date date) {
|
||||
LocalDate localDate = toDate(date);
|
||||
return afterToday(localDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Сегодня (от начала дня) или позднее
|
||||
*
|
||||
* @param localDate дата, может ыть null
|
||||
* @return
|
||||
*/
|
||||
public static boolean afterToday(LocalDate localDate) {
|
||||
if (localDate == null) return false;
|
||||
return !localDate.isBefore(LocalDate.now());
|
||||
}
|
||||
|
||||
public static boolean isToday(Instant instant) {
|
||||
LocalDate localDate = toDate(instant);
|
||||
return isToday(localDate);
|
||||
}
|
||||
|
||||
public static boolean isToday(Date date) {
|
||||
LocalDate localDate = toDate(date);
|
||||
return isToday(localDate);
|
||||
}
|
||||
|
||||
public static boolean isToday(LocalDate localDate) {
|
||||
if (localDate == null) return false;
|
||||
return localDate.equals(LocalDate.now());
|
||||
}
|
||||
|
||||
/**
|
||||
* Если instant без даты (1970 год), то берёт из него время и добавляет текущую дату.
|
||||
*
|
||||
* @param time может быть null
|
||||
* @return time, или если не указана дата, то текущая дата + время из <code>time</code>
|
||||
*/
|
||||
public static Instant addDateTodayToTimeIfNeeded(Instant time) {
|
||||
if (time == null)
|
||||
return null;
|
||||
LocalDateTime ldt = TimeUtil.toDateTime(time);
|
||||
if (ldt.getYear() == 1970 && ldt.getMonth() == Month.JANUARY && ldt.getDayOfMonth() == 1) {
|
||||
// time without date
|
||||
ldt = LocalDateTime.of(LocalDate.now(), ldt.toLocalTime());
|
||||
return ldt.atZone(ZoneId.systemDefault()).toInstant();
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
public static String formatInstantToString(DateTimeFormatter formatter, Instant date) {
|
||||
if (formatter == null || date == null) return "";
|
||||
return formatter.format(date);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
package ru.spcex.clearing.imdg.utils;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
public class DbUtilsHelperTest {
|
||||
|
||||
@org.testng.annotations.Test
|
||||
public void testCreateUpdateOrInsert() {
|
||||
String sql = DbUtilsHelper.createUpdateOrInsert("ENERGY",
|
||||
new String[]{"id", "power", "circle", "of", "fantasy", "prime"}, "id");
|
||||
assertEquals(sql,
|
||||
"INSERT INTO ENERGY (ID, POWER, CIRCLE, OF, FANTASY, PRIME) values (?, ?, ?, ?, ?, ?) ON CONFLICT (ID) DO UPDATE SET POWER=EXCLUDED.POWER, CIRCLE=EXCLUDED.CIRCLE, OF=EXCLUDED.OF, FANTASY=EXCLUDED.FANTASY, PRIME=EXCLUDED.PRIME"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package ru.spcex.platform.utils.text;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class TextUtil {
|
||||
public static String format(String template, Map<String, Object> parameters) {
|
||||
StringBuilder newTemplate = new StringBuilder(template);
|
||||
List<Object> valueList = new ArrayList<>();
|
||||
|
||||
Matcher matcher = Pattern.compile("[$][{](\\w+)}").matcher(template);
|
||||
|
||||
while (matcher.find()) {
|
||||
String key = matcher.group(1);
|
||||
|
||||
String paramName = "${" + key + "}";
|
||||
int index = newTemplate.indexOf(paramName);
|
||||
if (index != -1) {
|
||||
newTemplate.replace(index, index + paramName.length(), "%s");
|
||||
valueList.add(parameters.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
return String.format(newTemplate.toString(), valueList.toArray());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package ru.spcex.platform.utils.time;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.sql.Time;
|
||||
import java.time.*;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
public class TimeUtil {
|
||||
|
|
@ -22,6 +22,23 @@ public class TimeUtil {
|
|||
return formatter.format(date.atZone(zone));
|
||||
}
|
||||
|
||||
public static Date toDateFromInstant(Instant instant) {
|
||||
if (instant == null) return null;
|
||||
return Date.from(instant);
|
||||
}
|
||||
|
||||
public static Date toDateFromLocalDateTime(LocalDateTime localDateTime) {
|
||||
return localDateTime != null ? Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()) : null;
|
||||
}
|
||||
|
||||
public static Time toDateFromLocalTime(LocalTime localTime) {
|
||||
return localTime != null ? Time.valueOf(localTime) : null;
|
||||
}
|
||||
|
||||
public static Date toDateFromLocalDate(LocalDate localDate) {
|
||||
return localDate != null ? Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()) : null;
|
||||
}
|
||||
|
||||
public static Instant today() {
|
||||
return localDateToInstant(LocalDate.now());
|
||||
}
|
||||
|
|
|
|||
2
pom.xml
2
pom.xml
|
|
@ -129,7 +129,7 @@
|
|||
<dependency>
|
||||
<groupId>com.mchange</groupId>
|
||||
<artifactId>c3p0</artifactId>
|
||||
<version>0.9.5.2</version>
|
||||
<version>0.9.5.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.kafka</groupId>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue