Merge branch 'refs/heads/db_direct' into dev
This commit is contained in:
commit
bee974f113
42 changed files with 1660 additions and 629 deletions
|
|
@ -51,6 +51,12 @@
|
|||
<version>1.4.19</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JDBC -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- DOC -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
|
|
@ -126,6 +132,15 @@
|
|||
<artifactId>spring-boot-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mchange</groupId>
|
||||
<artifactId>c3p0</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>42.7.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ report-service
|
|||
Сервис для генерации отчётов.
|
||||
|
||||
|
||||
Формат xml, docx.
|
||||
Формат xml, docx, csv.
|
||||
|
||||
|
||||
Параметры запуска
|
||||
|
|
@ -12,6 +12,7 @@ report-service
|
|||
|
||||
--spring.config.location= путь к папке с файлом настроек application.properties
|
||||
--console - признак, что надо запуститься не как сервис, слушающий очередь kafka, а как утилита для генерации отчётов за текущий день/месяц и выключиться.
|
||||
-Dspring.profiles.active=dev - позволяет выгружать данные из БД в обход IMDG (нужны соответствующие настройки подключения)
|
||||
|
||||
По умолчанию запускается в режиме сервиса.
|
||||
|
||||
|
|
@ -48,6 +49,8 @@ DAILY - все ежедневные
|
|||
|
||||
reports-service.kafka-consumer - группа настроек для подключения к очереди kafka
|
||||
|
||||
reports-service.direct-db - группа настроек для подключения к базе (если нужно получать данные напрямую из БД в обход IMDG)
|
||||
|
||||
и другие настройки.
|
||||
|
||||
Рабочие папки
|
||||
|
|
|
|||
|
|
@ -4,10 +4,12 @@ import org.apache.commons.lang3.exception.ExceptionUtils;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
@SpringBootApplication
|
||||
//@SpringBootApplication
|
||||
@SpringBootApplication(exclude={DataSourceAutoConfiguration.class})
|
||||
public class ReportsServiceApplication {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -1,20 +1,5 @@
|
|||
package ru.spcex.clearing.reports.builders;
|
||||
|
||||
import com.opencsv.CSVWriter;
|
||||
import com.opencsv.ICSVWriter;
|
||||
import com.opencsv.bean.*;
|
||||
import com.opencsv.exceptions.CsvBadConverterException;
|
||||
import com.opencsv.exceptions.CsvChainedException;
|
||||
import com.opencsv.exceptions.CsvFieldAssignmentException;
|
||||
import com.opencsv.exceptions.CsvRequiredFieldEmptyException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import ru.clearing.classes.statics.data.misc.Session;
|
||||
import ru.spcex.platform.enumeration.ReportBuilderType;
|
||||
import ru.spcex.platform.enumeration.ReportKeys;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
|
@ -26,8 +11,34 @@ import java.time.LocalDate;
|
|||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import com.opencsv.CSVWriter;
|
||||
import com.opencsv.ICSVWriter;
|
||||
import com.opencsv.bean.AbstractCsvConverter;
|
||||
import com.opencsv.bean.BeanField;
|
||||
import com.opencsv.bean.ColumnPositionMappingStrategy;
|
||||
import com.opencsv.bean.ConverterNumber;
|
||||
import com.opencsv.bean.CsvBindByName;
|
||||
import com.opencsv.bean.CsvBindByPosition;
|
||||
import com.opencsv.bean.CsvConverter;
|
||||
import com.opencsv.bean.CsvNumber;
|
||||
import com.opencsv.bean.StatefulBeanToCsv;
|
||||
import com.opencsv.bean.StatefulBeanToCsvBuilder;
|
||||
import com.opencsv.exceptions.CsvBadConverterException;
|
||||
import com.opencsv.exceptions.CsvChainedException;
|
||||
import com.opencsv.exceptions.CsvFieldAssignmentException;
|
||||
import com.opencsv.exceptions.CsvRequiredFieldEmptyException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import ru.clearing.classes.statics.data.misc.Session;
|
||||
import ru.spcex.platform.enumeration.ReportBuilderType;
|
||||
import ru.spcex.platform.enumeration.ReportKeys;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
|
||||
/**
|
||||
* Класс для построения отчетов в формате CSV
|
||||
|
|
@ -136,10 +147,8 @@ public abstract class CSVReportBuilder<P, R> {
|
|||
}
|
||||
|
||||
protected List<Long> getSessionIdsForCurrentDate(Imdg<Session> sessionImdg) {
|
||||
Collection<Session> sessionForCurrentDay = sessionImdg.getCollectionObjectsByFieldValues(
|
||||
Map.of(
|
||||
"clearingDate", LocalDate.now()
|
||||
)
|
||||
Collection<Session> sessionForCurrentDay = sessionImdg.getCollectionObjectsByPredicate(
|
||||
sessionImdg.predicateBuilder().equals("clearingDate", LocalDate.now())
|
||||
);
|
||||
Set<Long> sessionIds = sessionForCurrentDay.stream().map(Session::getId).collect(Collectors.toSet());
|
||||
return sessionIds.stream().toList();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
package ru.spcex.clearing.reports.builders.ks;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
|
|
@ -10,7 +16,16 @@ import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
|||
import ru.spcex.clearing.reports.builders.CSVReportBuilder;
|
||||
import ru.spcex.clearing.reports.builders.EmptyParams;
|
||||
import ru.spcex.clearing.reports.builders.bean.KSCommissionTradesReport;
|
||||
import ru.spcex.platform.enumeration.*;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.enumeration.MarketCode;
|
||||
import ru.spcex.platform.enumeration.RegistryStatus;
|
||||
import ru.spcex.platform.enumeration.RegistryTradingParams;
|
||||
import ru.spcex.platform.enumeration.RegistryUnit;
|
||||
import ru.spcex.platform.enumeration.ReportBuilderType;
|
||||
import ru.spcex.platform.enumeration.ReportKeys;
|
||||
import ru.spcex.platform.enumeration.Section;
|
||||
import ru.spcex.platform.enumeration.SessionType;
|
||||
import ru.spcex.platform.enumeration.WorkflowStatus;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
|
|
@ -18,14 +33,6 @@ import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
|||
import ru.spcex.platform.imdg.api.predicate.specific.RegistryCodeSqlBuilder;
|
||||
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class KSCommissionTradesReportBuilder extends CSVReportBuilder<EmptyParams, KSCommissionTradesReport> {
|
||||
protected DateTimeFormatter dateFormatter_ddMMyy = DateTimeFormatter.ofPattern("ddMMyy");
|
||||
|
|
@ -81,9 +88,9 @@ public class KSCommissionTradesReportBuilder extends CSVReportBuilder<EmptyParam
|
|||
LocalDate nowDate = LocalDate.now();
|
||||
|
||||
ImdgPredicateBuilder pb = registryImdg.predicateBuilder();
|
||||
String sql = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.TS_T).build();
|
||||
ImdgPredicate registryPredicate = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.TS_T).buildPredicate(pb);
|
||||
ImdgPredicate finalPredicate = pb.and(
|
||||
pb.sql(sql),
|
||||
registryPredicate,
|
||||
pb.greatEqual("refundDate", nowDate),
|
||||
pb.lessEqual("valueDate", nowDate),
|
||||
pb.in("sessionType", SessionType.XDEP.getKey(), SessionType.FINL.getKey(), SessionType.MEDM.getKey())
|
||||
|
|
@ -170,11 +177,14 @@ public class KSCommissionTradesReportBuilder extends CSVReportBuilder<EmptyParam
|
|||
if (accountType == AccountType.Clrn) {
|
||||
account = registry.getAccount();
|
||||
} else if (accountType == AccountType.Info) {
|
||||
Account accountFromImdg = accountImdg.getFirstObjectByFieldValues(Map.of(
|
||||
"accountType", AccountType.Anlt.getKey(),
|
||||
"companyId", 1L
|
||||
));
|
||||
account = accountFromImdg.getAccount();
|
||||
pb = accountImdg.predicateBuilder();
|
||||
Account accountFromImdg = accountImdg.getFirstObjectByPredicate(
|
||||
pb.and(
|
||||
pb.equals("accountType", AccountType.Anlt.getKey()),
|
||||
pb.equals("companyId", 1L)
|
||||
)
|
||||
);
|
||||
account = accountFromImdg != null ? accountFromImdg.getAccount() : null;
|
||||
}
|
||||
|
||||
String tkrInitiator = null;
|
||||
|
|
@ -193,11 +203,13 @@ public class KSCommissionTradesReportBuilder extends CSVReportBuilder<EmptyParam
|
|||
if (accountType == AccountType.Clrn) {
|
||||
accountInitiator = tmtRegistry.getAccount();
|
||||
} else if (accountType == AccountType.Info) {
|
||||
Account accountFromImdg = accountImdg.getFirstObjectByFieldValues(Map.of(
|
||||
"accountType", AccountType.Anlt.getKey(),
|
||||
"companyId", 1L
|
||||
));
|
||||
accountInitiator = accountFromImdg.getAccount();
|
||||
Account accountFromImdg = accountImdg.getFirstObjectByPredicate(
|
||||
pb.and(
|
||||
pb.equals("accountType", AccountType.Anlt.getKey()),
|
||||
pb.equals("companyId", 1L)
|
||||
)
|
||||
);
|
||||
accountInitiator = accountFromImdg != null ? accountFromImdg.getAccount() : null;
|
||||
}
|
||||
}
|
||||
Session session = sessionImdg.getSingleObjectByID(registry.getSessionId());
|
||||
|
|
|
|||
|
|
@ -14,8 +14,6 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.misc.Session;
|
||||
import ru.clearing.classes.statics.data.registry.Registry;
|
||||
import ru.clearing.classes.statics.data.security.CurrencyPairSecurity;
|
||||
import ru.clearing.platform.dictionary.CurrencyPairDictionary;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.reports.builders.CSVReportBuilder;
|
||||
import ru.spcex.clearing.reports.builders.PairRegistryId;
|
||||
|
|
@ -23,6 +21,7 @@ import ru.spcex.clearing.reports.builders.SessionIdParam;
|
|||
import ru.spcex.clearing.reports.builders.bean.KSRepCashNettoReport;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.enumeration.RegistryDesignation;
|
||||
import ru.spcex.platform.enumeration.RegistryStatus;
|
||||
import ru.spcex.platform.enumeration.RegistryTradingParams;
|
||||
import ru.spcex.platform.enumeration.ReportBuilderType;
|
||||
import ru.spcex.platform.enumeration.ReportKeys;
|
||||
|
|
@ -40,8 +39,6 @@ public class KSRepCashNettoReportBuilder extends CSVReportBuilder<SessionIdParam
|
|||
private final Imdg<Registry> registryImdg;
|
||||
private final Imdg<Session> sessionImdg;
|
||||
private final Imdg<Account> accountImdg;
|
||||
private final Imdg<CurrencyPairDictionary> currencyPairDictionaryImdg;
|
||||
private final Imdg<CurrencyPairSecurity> currencyPairSecurityImdg;
|
||||
|
||||
private List<KSRepCashNettoReport> rows = null;
|
||||
|
||||
|
|
@ -49,8 +46,6 @@ public class KSRepCashNettoReportBuilder extends CSVReportBuilder<SessionIdParam
|
|||
registryImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Registry, Registry.class);
|
||||
sessionImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Session, Session.class);
|
||||
accountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
currencyPairDictionaryImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_CurrencyPairDictionary, CurrencyPairDictionary.class);
|
||||
currencyPairSecurityImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_CurrencyPairSecurity, CurrencyPairSecurity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -83,13 +78,14 @@ public class KSRepCashNettoReportBuilder extends CSVReportBuilder<SessionIdParam
|
|||
LocalDate nowDate = LocalDate.now();
|
||||
|
||||
ImdgPredicateBuilder pb = registryImdg.predicateBuilder();
|
||||
String sql = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.CM_T, RegistryTradingParams.LM_T).build();
|
||||
ImdgPredicate registryPredicate = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.OM_T, RegistryTradingParams.TM_T).buildPredicate(pb);
|
||||
List<Long> sessionIds = params.getSessionId();
|
||||
if (sessionIds == null || sessionIds.isEmpty()) sessionIds = getSessionIdsForCurrentDate(sessionImdg);
|
||||
ImdgPredicate finalPredicate = pb.and(
|
||||
pb.in("sessionId", sessionIds.toArray(new Long[0])),
|
||||
pb.equals("clearingDate", nowDate),
|
||||
pb.sql(sql),
|
||||
registryPredicate,
|
||||
pb.in("registryStatus", RegistryStatus.OK.getKey(), RegistryStatus.CLRD.getKey()),
|
||||
pb.or(
|
||||
pb.equals("accountType", AccountType.Clrn.getKey()),
|
||||
pb.equals("accountType", AccountType.Info.getKey())
|
||||
|
|
@ -106,7 +102,7 @@ public class KSRepCashNettoReportBuilder extends CSVReportBuilder<SessionIdParam
|
|||
List<Registry> groupedRegistry = entry.getValue();
|
||||
try {
|
||||
if (groupedRegistry.isEmpty()) {
|
||||
log.warn("Empty LM_T and CM_T registries for account = {} and session_id = {}. Registries with id = [{}] was skipped",
|
||||
log.warn("Empty TM_T and OM_T registries for account = {} and session_id = {}. Registries with id = [{}] was skipped",
|
||||
pairRegistryId.getAccount(),
|
||||
pairRegistryId.getSessionId(),
|
||||
groupedRegistry.stream().map(r -> String.valueOf(r.getId())).collect(Collectors.joining(", "))
|
||||
|
|
@ -114,52 +110,52 @@ public class KSRepCashNettoReportBuilder extends CSVReportBuilder<SessionIdParam
|
|||
continue;
|
||||
}
|
||||
|
||||
List<Registry> cmtRegistries = new ArrayList<>();
|
||||
List<Registry> lmtRegistries = new ArrayList<>();
|
||||
List<Registry> omtRegistries = new ArrayList<>();
|
||||
List<Registry> tmtRegistries = new ArrayList<>();
|
||||
Registry registry = null;
|
||||
for (Registry currRegistry : groupedRegistry) {
|
||||
registry = currRegistry;
|
||||
if (RegistryDesignation.L.equalsByKey(currRegistry.getRegistryDesignation()))
|
||||
lmtRegistries.add(currRegistry);
|
||||
if (RegistryDesignation.C.equalsByKey(currRegistry.getRegistryDesignation()))
|
||||
cmtRegistries.add(currRegistry);
|
||||
if (RegistryDesignation.T.equalsByKey(currRegistry.getRegistryDesignation()))
|
||||
tmtRegistries.add(currRegistry);
|
||||
if (RegistryDesignation.O.equalsByKey(currRegistry.getRegistryDesignation()))
|
||||
omtRegistries.add(currRegistry);
|
||||
}
|
||||
|
||||
boolean invalid = false;
|
||||
if (!cmtRegistries.isEmpty() || !lmtRegistries.isEmpty()) {
|
||||
if (!omtRegistries.isEmpty() || !tmtRegistries.isEmpty()) {
|
||||
String sourceTradingCode = null;
|
||||
String sourceTkr = null;
|
||||
if (!cmtRegistries.isEmpty()) {
|
||||
Registry next = cmtRegistries.iterator().next();
|
||||
if (!omtRegistries.isEmpty()) {
|
||||
Registry next = omtRegistries.iterator().next();
|
||||
sourceTradingCode = next.getTradingCode();
|
||||
sourceTkr = next.getTradingClearingRegistry();
|
||||
}
|
||||
if (!lmtRegistries.isEmpty()) {
|
||||
Registry next = lmtRegistries.iterator().next();
|
||||
if (!tmtRegistries.isEmpty()) {
|
||||
Registry next = tmtRegistries.iterator().next();
|
||||
sourceTradingCode = next.getTradingCode();
|
||||
sourceTkr = next.getTradingClearingRegistry();
|
||||
}
|
||||
for (Registry currRegistry : cmtRegistries) {
|
||||
for (Registry currRegistry : omtRegistries) {
|
||||
if (!Objects.equals(sourceTradingCode, currRegistry.getTradingCode())) {
|
||||
invalid = true;
|
||||
log.warn("Invalid CM_T registries set, tradingCode not equals. Registries was skipped");
|
||||
log.warn("Invalid OM_T registries set, tradingCode not equals. Registries was skipped");
|
||||
break;
|
||||
}
|
||||
if (!Objects.equals(sourceTkr, currRegistry.getTradingClearingRegistry())) {
|
||||
invalid = true;
|
||||
log.warn("Invalid CM_T registries set, tradingClearingRegistry not equals. Registries was skipped");
|
||||
log.warn("Invalid OM_T registries set, tradingClearingRegistry not equals. Registries was skipped");
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (Registry currRegistry : lmtRegistries) {
|
||||
for (Registry currRegistry : tmtRegistries) {
|
||||
if (!Objects.equals(sourceTradingCode, currRegistry.getTradingCode())) {
|
||||
invalid = true;
|
||||
log.warn("Invalid LM_T registries set, tradingCode not equals. Registries was skipped");
|
||||
log.warn("Invalid TM_T registries set, tradingCode not equals. Registries was skipped");
|
||||
break;
|
||||
}
|
||||
if (!Objects.equals(sourceTkr, currRegistry.getTradingClearingRegistry())) {
|
||||
invalid = true;
|
||||
log.warn("Invalid CM_T registries set, tradingClearingRegistry not equals. Registries was skipped");
|
||||
log.warn("Invalid OM_T registries set, tradingClearingRegistry not equals. Registries was skipped");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -181,20 +177,22 @@ public class KSRepCashNettoReportBuilder extends CSVReportBuilder<SessionIdParam
|
|||
if (accountType == AccountType.Clrn) {
|
||||
account = registry.getAccount();
|
||||
} else if (accountType == AccountType.Info) {
|
||||
Account accountFromIMDG = accountImdg.getFirstObjectByFieldValues(Map.of(
|
||||
"companyId", 1L,
|
||||
"accountType", AccountType.Anlt.getKey()
|
||||
));
|
||||
if (accountFromIMDG != null) account = accountFromIMDG.getAccount();
|
||||
Account accountFromImdg = accountImdg.getFirstObjectByPredicate(
|
||||
pb.and(
|
||||
pb.equals("accountType", AccountType.Anlt.getKey()),
|
||||
pb.equals("companyId", 1L)
|
||||
)
|
||||
);
|
||||
account = accountFromImdg != null ? accountFromImdg.getAccount() : null;
|
||||
}
|
||||
ksRepCashNettoReport.setAccount(account);
|
||||
ksRepCashNettoReport.setTkr(registry.getTradingClearingRegistry());
|
||||
ksRepCashNettoReport.setDate(nowDate);
|
||||
|
||||
BigDecimal cmtCurrencyNetto = BigDecimal.ZERO;
|
||||
BigDecimal lmtCurrencyNetto = BigDecimal.ZERO;
|
||||
BigDecimal cmtBalance = BigDecimal.ZERO;
|
||||
BigDecimal lmtBalance = BigDecimal.ZERO;
|
||||
BigDecimal omtCurrencyNetto = BigDecimal.ZERO;
|
||||
BigDecimal tmtCurrencyNetto = BigDecimal.ZERO;
|
||||
BigDecimal omtBalance = BigDecimal.ZERO;
|
||||
BigDecimal tmtBalance = BigDecimal.ZERO;
|
||||
BigDecimal oblValue = BigDecimal.ZERO;
|
||||
BigDecimal reqValue = BigDecimal.ZERO;
|
||||
boolean withValue = false;
|
||||
|
|
@ -212,44 +210,44 @@ public class KSRepCashNettoReportBuilder extends CSVReportBuilder<SessionIdParam
|
|||
SessionType.MEDM,
|
||||
SessionType.XDEP
|
||||
);
|
||||
for (Registry cmtRegistry : cmtRegistries) {
|
||||
if (cmtRegistry.getBalance() != null) {
|
||||
SessionType sessionType = IEnumKey.getEnumByKey(SessionType.class, cmtRegistry.getSessionType());
|
||||
Section section = IEnumKey.getEnumByKey(Section.class, cmtRegistry.getSection());
|
||||
for (Registry omtRegistry : omtRegistries) {
|
||||
if (omtRegistry.getBalance() != null) {
|
||||
SessionType sessionType = IEnumKey.getEnumByKey(SessionType.class, omtRegistry.getSessionType());
|
||||
Section section = IEnumKey.getEnumByKey(Section.class, omtRegistry.getSection());
|
||||
if (section == Section.FOND || sessionTypeForValue.contains(sessionType)) {
|
||||
cmtBalance = cmtBalance.add(cmtRegistry.getBalance());
|
||||
omtBalance = omtBalance.add(omtRegistry.getBalance());
|
||||
withValue = true;
|
||||
}
|
||||
if (section == Section.MKR || sessionTypeForOblReqValue.contains(sessionType)) {
|
||||
reqValue = reqValue.add(cmtRegistry.getBalance());
|
||||
reqValue = reqValue.add(omtRegistry.getBalance());
|
||||
withOblReqValue = true;
|
||||
}
|
||||
if (section == Section.CURR || sessionType == SessionType.CURR) {
|
||||
cmtCurrencyNetto = cmtCurrencyNetto.add(cmtRegistry.getBalance());
|
||||
omtCurrencyNetto = omtCurrencyNetto.add(omtRegistry.getBalance());
|
||||
withCurrencyNetto = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Registry lmtRegistry : lmtRegistries) {
|
||||
if (lmtRegistry.getBalance() != null) {
|
||||
SessionType sessionType = IEnumKey.getEnumByKey(SessionType.class, lmtRegistry.getSessionType());
|
||||
Section section = IEnumKey.getEnumByKey(Section.class, lmtRegistry.getSection());
|
||||
for (Registry tmtRegistry : tmtRegistries) {
|
||||
if (tmtRegistry.getBalance() != null) {
|
||||
SessionType sessionType = IEnumKey.getEnumByKey(SessionType.class, tmtRegistry.getSessionType());
|
||||
Section section = IEnumKey.getEnumByKey(Section.class, tmtRegistry.getSection());
|
||||
if (section == Section.FOND || sessionTypeForValue.contains(sessionType)) {
|
||||
lmtBalance = lmtBalance.add(lmtRegistry.getBalance());
|
||||
tmtBalance = tmtBalance.add(tmtRegistry.getBalance());
|
||||
withValue = true;
|
||||
}
|
||||
if (section == Section.MKR || sessionTypeForOblReqValue.contains(sessionType)) {
|
||||
oblValue = oblValue.add(lmtRegistry.getBalance());
|
||||
oblValue = oblValue.add(tmtRegistry.getBalance());
|
||||
withOblReqValue = true;
|
||||
}
|
||||
if (section == Section.CURR || sessionType == SessionType.CURR) {
|
||||
lmtCurrencyNetto = lmtCurrencyNetto.add(lmtRegistry.getBalance());
|
||||
tmtCurrencyNetto = tmtCurrencyNetto.add(tmtRegistry.getBalance());
|
||||
withCurrencyNetto = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
BigDecimal value;
|
||||
value = cmtBalance.subtract(lmtBalance);
|
||||
value = omtBalance.subtract(tmtBalance);
|
||||
ksRepCashNettoReport.setLotCurrency(registry.getSecuritySymbol());
|
||||
if (withValue) {
|
||||
KSRepCashNettoReport withoutValueClone = ksRepCashNettoReport.cloneWithoutValues();
|
||||
|
|
@ -264,7 +262,7 @@ public class KSRepCashNettoReportBuilder extends CSVReportBuilder<SessionIdParam
|
|||
}
|
||||
if (withCurrencyNetto) {
|
||||
KSRepCashNettoReport withoutValueClone = ksRepCashNettoReport.cloneWithoutValues();
|
||||
withoutValueClone.setCurrencyNetto(cmtCurrencyNetto.subtract(lmtCurrencyNetto));
|
||||
withoutValueClone.setCurrencyNetto(omtCurrencyNetto.subtract(tmtCurrencyNetto));
|
||||
withoutValueClone.setTrExecDate(LocalDate.now());
|
||||
rows.add(withoutValueClone);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import java.time.temporal.ChronoUnit;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
|
|
@ -83,7 +82,6 @@ public class KSRepCashRegisterSumsReportBuilder extends CSVReportBuilder<EmptyPa
|
|||
pb.equals("registryStatus", RegistryStatus.OK.getKey()),
|
||||
pb.notNull("tradingClearingRegistry"),
|
||||
registryPredicate
|
||||
|
||||
);
|
||||
Collection<Registry> registries = registryImdg.getCollectionObjectsByPredicate(finalPredicate);
|
||||
log.debug("Found {} registries by query: {}", registries.size(), finalPredicate);
|
||||
|
|
@ -121,10 +119,12 @@ public class KSRepCashRegisterSumsReportBuilder extends CSVReportBuilder<EmptyPa
|
|||
if (accountType == AccountType.Clrn) {
|
||||
account = registry.getAccount();
|
||||
} else if (accountType == AccountType.Info) {
|
||||
Account accountFromIMDG = accountImdg.getFirstObjectByFieldValues(Map.of(
|
||||
"companyId", 1L,
|
||||
"accountType", AccountType.Anlt.getKey()
|
||||
));
|
||||
Account accountFromIMDG = accountImdg.getFirstObjectByPredicate(
|
||||
pb.and(
|
||||
pb.equals("accountType", AccountType.Anlt.getKey()),
|
||||
pb.equals("companyId", 1L)
|
||||
)
|
||||
);
|
||||
if (accountFromIMDG != null) account = accountFromIMDG.getAccount();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
|
|
@ -117,11 +116,13 @@ public class KSRepCashRegistersReportBuilder extends CSVReportBuilder<EmptyParam
|
|||
account = registry.getAccount();
|
||||
|
||||
} else if (accountType == AccountType.Info) {
|
||||
Account accountFromIMDG = accountImdg.getFirstObjectByFieldValues(Map.of(
|
||||
"companyId", 1L,
|
||||
"accountType", AccountType.Anlt.getKey(),
|
||||
"currency", registry.getSecuritySymbol()
|
||||
));
|
||||
Account accountFromIMDG = accountImdg.getFirstObjectByPredicate(
|
||||
pb.and(
|
||||
pb.equals("accountType", AccountType.Anlt.getKey()),
|
||||
pb.equals("companyId", 1L),
|
||||
pb.equals("currency", registry.getSecuritySymbol())
|
||||
)
|
||||
);
|
||||
if (accountFromIMDG != null) account = accountFromIMDG.getAccount();
|
||||
}
|
||||
KSRepCashRegistersReport ksRepCashRegistersReport = new KSRepCashRegistersReport();
|
||||
|
|
@ -138,54 +139,58 @@ public class KSRepCashRegistersReportBuilder extends CSVReportBuilder<EmptyParam
|
|||
ksRepCashRegistersReport.setRemarks(null);
|
||||
ksRepCashRegistersReport.setTradeNum(null);
|
||||
|
||||
RegistryCodeDictionary registryCodeDictionary = registryCodeDictionaryImdg.getFirstObjectByFieldValues(Map.of("code", registry.getRegistryCode()));
|
||||
RegistryCodeDictionary registryCodeDictionary = registryCodeDictionaryImdg.getFirstObjectByPredicate(
|
||||
registryCodeDictionaryImdg.predicateBuilder().equals("code", registry.getRegistryCode())
|
||||
);
|
||||
if (registryCodeDictionary != null) ksRepCashRegistersReport.setRegisterName(registryCodeDictionary.getName());
|
||||
|
||||
|
||||
Collection<Session> sessionsForDay = sessionImdg.getCollectionObjectsByFieldValues(Map.of("clearingDate", LocalDate.now()));
|
||||
Collection<Session> sessionsForDay = sessionImdg.getCollectionObjectsByPredicate(
|
||||
sessionImdg.predicateBuilder().equals("clearingDate", LocalDate.now())
|
||||
);
|
||||
Long[] sessionIds = sessionsForDay.stream().map(Session::getId).toArray(Long[]::new);
|
||||
ImdgPredicate cmtPredicate = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.CM_T).buildPredicate(pb);
|
||||
Collection<Registry> cmtRegistries = registryImdg.getCollectionObjectsByPredicate(
|
||||
ImdgPredicate omtPredicate = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.OM_T).buildPredicate(pb);
|
||||
Collection<Registry> omtRegistries = registryImdg.getCollectionObjectsByPredicate(
|
||||
pb.and(
|
||||
cmtPredicate,
|
||||
omtPredicate,
|
||||
pb.in("sessionId", sessionIds),
|
||||
pb.equals("tradingCode", registry.getTradingCode()),
|
||||
pb.equals("companyId", registry.getCompanyId()),
|
||||
pb.equals("account", registry.getAccount()),
|
||||
pb.equals("registryStatus", RegistryStatus.CLRD.getKey())
|
||||
pb.in("registryStatus", RegistryStatus.OK.getKey(), RegistryStatus.CLRD.getKey())
|
||||
)
|
||||
);
|
||||
ImdgPredicate lmtPredicate = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.LM_T).buildPredicate(pb);
|
||||
Collection<Registry> lmtRegistries = registryImdg.getCollectionObjectsByPredicate(
|
||||
ImdgPredicate tmtPredicate = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.TM_T).buildPredicate(pb);
|
||||
Collection<Registry> tmtRegistries = registryImdg.getCollectionObjectsByPredicate(
|
||||
pb.and(
|
||||
lmtPredicate,
|
||||
tmtPredicate,
|
||||
pb.in("sessionId", sessionIds),
|
||||
pb.equals("tradingCode", registry.getTradingCode()),
|
||||
pb.equals("companyId", registry.getCompanyId()),
|
||||
pb.equals("account", registry.getAccount()),
|
||||
pb.equals("registryStatus", RegistryStatus.CLRD.getKey())
|
||||
pb.in("registryStatus", RegistryStatus.OK.getKey(), RegistryStatus.CLRD.getKey())
|
||||
)
|
||||
);
|
||||
Set<String> contracts = new HashSet<>();
|
||||
BigDecimal cmtBalanceSum = BigDecimal.ZERO;
|
||||
for (Registry cmtRegistry : cmtRegistries) {
|
||||
Long counterPartyId = cmtRegistry.getCounterPartyId();
|
||||
BigDecimal omtBalanceSum = BigDecimal.ZERO;
|
||||
for (Registry omtRegistry : omtRegistries) {
|
||||
Long counterPartyId = omtRegistry.getCounterPartyId();
|
||||
if (counterPartyId != null) {
|
||||
Collection<ClearingMemberCategory> clearingMemberCategory = clearingMemberCategoryImdg.getCollectionObjectsByFieldValues(
|
||||
Map.of("companyId", counterPartyId)
|
||||
Collection<ClearingMemberCategory> clearingMemberCategory = clearingMemberCategoryImdg.getCollectionObjectsByPredicate(
|
||||
clearingMemberCategoryImdg.predicateBuilder().equals("companyId", counterPartyId)
|
||||
);
|
||||
if (!clearingMemberCategory.isEmpty()) {
|
||||
ClearingMemberCategory next = clearingMemberCategory.iterator().next();
|
||||
ClearingCategory category = IEnumKey.getEnumByKey(ClearingCategory.class, next.getClearingMemberCategory());
|
||||
SessionType sessionType = IEnumKey.getEnumByKey(SessionType.class, cmtRegistry.getSessionType());
|
||||
SessionType sessionType = IEnumKey.getEnumByKey(SessionType.class, omtRegistry.getSessionType());
|
||||
if (category == ClearingCategory.I && sessionType == SessionType.XDEP) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
BigDecimal balance = cmtRegistry.getBalance();
|
||||
cmtBalanceSum = cmtBalanceSum.add(balance);
|
||||
contracts.add(cmtRegistry.getContract());
|
||||
BigDecimal balance = omtRegistry.getBalance();
|
||||
omtBalanceSum = omtBalanceSum.add(balance);
|
||||
contracts.add(omtRegistry.getContract());
|
||||
}
|
||||
ImdgPredicate dmxPredicate = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.DM_X).buildPredicate(pb);
|
||||
Collection<Registry> dmxRegistries = registryImdg.getCollectionObjectsByPredicate(
|
||||
|
|
@ -199,12 +204,12 @@ public class KSRepCashRegistersReportBuilder extends CSVReportBuilder<EmptyParam
|
|||
)
|
||||
);
|
||||
BigDecimal dmxBalanceSum = dmxRegistries.stream().map(Registry::getBalance).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
BigDecimal lmtBalanceSum = lmtRegistries.stream()
|
||||
BigDecimal tmtBalanceSum = tmtRegistries.stream()
|
||||
.filter(reg -> {
|
||||
Long counterPartyId = reg.getCounterPartyId();
|
||||
if (counterPartyId != null) {
|
||||
Collection<ClearingMemberCategory> clearingMemberCategory = clearingMemberCategoryImdg.getCollectionObjectsByFieldValues(
|
||||
Map.of("companyId", counterPartyId)
|
||||
Collection<ClearingMemberCategory> clearingMemberCategory = clearingMemberCategoryImdg.getCollectionObjectsByPredicate(
|
||||
clearingMemberCategoryImdg.predicateBuilder().equals("companyId", counterPartyId)
|
||||
);
|
||||
if (!clearingMemberCategory.isEmpty()) {
|
||||
ClearingMemberCategory next = clearingMemberCategory.iterator().next();
|
||||
|
|
@ -217,7 +222,7 @@ public class KSRepCashRegistersReportBuilder extends CSVReportBuilder<EmptyParam
|
|||
})
|
||||
.map(Registry::getBalance)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
ksRepCashRegistersReport.setChangeBalance(cmtBalanceSum.subtract(lmtBalanceSum).subtract(dmxBalanceSum));
|
||||
ksRepCashRegistersReport.setChangeBalance(omtBalanceSum.subtract(tmtBalanceSum).subtract(dmxBalanceSum));
|
||||
|
||||
|
||||
registryPredicate = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.DM_I).buildPredicate(pb);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,14 @@
|
|||
package ru.spcex.clearing.reports.builders.ks;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.clearing.classes.statics.data.account.AccountSymbols;
|
||||
|
|
@ -10,19 +19,18 @@ import ru.spcex.clearing.reports.builders.CSVReportBuilder;
|
|||
import ru.spcex.clearing.reports.builders.PairRegistry3Id;
|
||||
import ru.spcex.clearing.reports.builders.SessionIdParam;
|
||||
import ru.spcex.clearing.reports.builders.bean.KSRepDepoNettoReport;
|
||||
import ru.spcex.platform.enumeration.*;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.enumeration.RegistryDesignation;
|
||||
import ru.spcex.platform.enumeration.RegistryStatus;
|
||||
import ru.spcex.platform.enumeration.RegistryTradingParams;
|
||||
import ru.spcex.platform.enumeration.ReportBuilderType;
|
||||
import ru.spcex.platform.enumeration.ReportKeys;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
import ru.spcex.platform.imdg.api.predicate.specific.RegistryCodeSqlBuilder;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class KSRepDepoNettoReportBuilder extends CSVReportBuilder<SessionIdParam, KSRepDepoNettoReport> {
|
||||
private final Imdg<Registry> registryImdg;
|
||||
|
|
@ -69,11 +77,12 @@ public class KSRepDepoNettoReportBuilder extends CSVReportBuilder<SessionIdParam
|
|||
ImdgPredicateBuilder pb = registryImdg.predicateBuilder();
|
||||
List<Long> sessionIds = params.getSessionId();
|
||||
if (sessionIds == null || sessionIds.isEmpty()) sessionIds = getSessionIdsForCurrentDate(sessionImdg);
|
||||
String sql = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.CS_T, RegistryTradingParams.LS_T).build();
|
||||
ImdgPredicate registryPredicate = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.OS_T, RegistryTradingParams.TS_T).buildPredicate(pb);
|
||||
ImdgPredicate finalPredicate = pb.and(
|
||||
pb.in("sessionId", sessionIds.toArray(new Long[0])),
|
||||
pb.equals("clearingDate", nowDate),
|
||||
pb.sql(sql),
|
||||
registryPredicate,
|
||||
pb.in("registryStatus", RegistryStatus.OK.getKey(), RegistryStatus.CLRD.getKey()),
|
||||
pb.equals("accountType", AccountType.Depo.getKey()),
|
||||
pb.notNull("account")
|
||||
);
|
||||
|
|
@ -87,38 +96,38 @@ public class KSRepDepoNettoReportBuilder extends CSVReportBuilder<SessionIdParam
|
|||
List<Registry> groupedRegistry = entry.getValue();
|
||||
try {
|
||||
if (groupedRegistry.isEmpty()) {
|
||||
log.warn("Empty LS_T and CS_T registries for {}",
|
||||
log.warn("Empty TS_T and OS_T registries for {}",
|
||||
pairRegistryId
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
List<Registry> cstRegistries = new ArrayList<>();
|
||||
List<Registry> lstRegistries = new ArrayList<>();
|
||||
List<Registry> ostRegistries = new ArrayList<>();
|
||||
List<Registry> tstRegistries = new ArrayList<>();
|
||||
Registry registry = null;
|
||||
for (Registry currRegistry : groupedRegistry) {
|
||||
registry = currRegistry;
|
||||
if (RegistryDesignation.L.equalsByKey(currRegistry.getRegistryDesignation()))
|
||||
lstRegistries.add(currRegistry);
|
||||
if (RegistryDesignation.C.equalsByKey(currRegistry.getRegistryDesignation()))
|
||||
cstRegistries.add(currRegistry);
|
||||
if (RegistryDesignation.T.equalsByKey(currRegistry.getRegistryDesignation()))
|
||||
tstRegistries.add(currRegistry);
|
||||
if (RegistryDesignation.O.equalsByKey(currRegistry.getRegistryDesignation()))
|
||||
ostRegistries.add(currRegistry);
|
||||
}
|
||||
|
||||
boolean invalid = false;
|
||||
if (!cstRegistries.isEmpty() || !lstRegistries.isEmpty()) {
|
||||
if (!ostRegistries.isEmpty() || !tstRegistries.isEmpty()) {
|
||||
String sourceTradingCode = null;
|
||||
if (!cstRegistries.isEmpty()) sourceTradingCode = cstRegistries.iterator().next().getTradingCode();
|
||||
if (!lstRegistries.isEmpty()) sourceTradingCode = lstRegistries.iterator().next().getTradingCode();
|
||||
for (Registry currRegistry : cstRegistries) {
|
||||
if (!ostRegistries.isEmpty()) sourceTradingCode = ostRegistries.iterator().next().getTradingCode();
|
||||
if (!tstRegistries.isEmpty()) sourceTradingCode = tstRegistries.iterator().next().getTradingCode();
|
||||
for (Registry currRegistry : ostRegistries) {
|
||||
if (Objects.equals(sourceTradingCode, currRegistry.getTradingCode())) continue;
|
||||
invalid = true;
|
||||
log.warn("Invalid CS_T registries set, tradingCode not equals. Registries was skipped");
|
||||
log.warn("Invalid OS_T registries set, tradingCode not equals. Registries was skipped");
|
||||
break;
|
||||
}
|
||||
for (Registry currRegistry : lstRegistries) {
|
||||
for (Registry currRegistry : tstRegistries) {
|
||||
if (Objects.equals(sourceTradingCode, currRegistry.getTradingCode())) continue;
|
||||
invalid = true;
|
||||
log.warn("Invalid LS_T registries set, tradingCode not equals. Registries was skipped");
|
||||
log.warn("Invalid TS_T registries set, tradingCode not equals. Registries was skipped");
|
||||
break;
|
||||
}
|
||||
if (invalid) continue;
|
||||
|
|
@ -130,7 +139,9 @@ public class KSRepDepoNettoReportBuilder extends CSVReportBuilder<SessionIdParam
|
|||
ksRepDepoNettoReport.setTkr(registry.getTradingClearingRegistry());
|
||||
|
||||
String account = registry.getAccount();
|
||||
AccountSymbols accountSymbols = accountSymbolsImdg.getFirstObjectByFieldValues(Map.of("accountId", registry.getAccountId()));
|
||||
AccountSymbols accountSymbols = accountSymbolsImdg.getFirstObjectByPredicate(
|
||||
accountSymbolsImdg.predicateBuilder().equals("accountId", registry.getAccountId())
|
||||
);
|
||||
if (accountSymbols != null && !StringUtils.isBlank(accountSymbols.getAccountSymbolValue()))
|
||||
account = accountSymbols.getAccountSymbolValue();
|
||||
ksRepDepoNettoReport.setAccount(account);
|
||||
|
|
@ -142,15 +153,15 @@ public class KSRepDepoNettoReportBuilder extends CSVReportBuilder<SessionIdParam
|
|||
if (session != null && session.getCreated() != null)
|
||||
ksRepDepoNettoReport.setSessionDate(LocalDateTime.ofInstant(session.getCreated(), getReportZoneId()));
|
||||
|
||||
BigDecimal cstBalance = BigDecimal.ZERO;
|
||||
BigDecimal lstBalance = BigDecimal.ZERO;
|
||||
for (Registry cstRegistry : cstRegistries) {
|
||||
if (cstRegistry.getBalance() != null) cstBalance = cstBalance.add(cstRegistry.getBalance());
|
||||
BigDecimal ostBalance = BigDecimal.ZERO;
|
||||
BigDecimal tstBalance = BigDecimal.ZERO;
|
||||
for (Registry ostRegistry : ostRegistries) {
|
||||
if (ostRegistry.getBalance() != null) ostBalance = ostBalance.add(ostRegistry.getBalance());
|
||||
}
|
||||
for (Registry lstRegistry : lstRegistries) {
|
||||
if (lstRegistry.getBalance() != null) lstBalance = lstBalance.add(lstRegistry.getBalance());
|
||||
for (Registry tstRegistry : tstRegistries) {
|
||||
if (tstRegistry.getBalance() != null) tstBalance = tstBalance.add(tstRegistry.getBalance());
|
||||
}
|
||||
ksRepDepoNettoReport.setValue(cstBalance.subtract(lstBalance));
|
||||
ksRepDepoNettoReport.setValue(ostBalance.subtract(tstBalance));
|
||||
|
||||
rows.add(ksRepDepoNettoReport);
|
||||
} catch (Throwable e) {
|
||||
|
|
|
|||
|
|
@ -8,14 +8,11 @@ import java.time.temporal.ChronoUnit;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.clearing.classes.statics.data.account.AccountSymbols;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.registry.Registry;
|
||||
import ru.clearing.classes.statics.data.security.CurrencyPairSecurity;
|
||||
import ru.clearing.platform.dictionary.CurrencyPairDictionary;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.reports.builders.CSVReportBuilder;
|
||||
import ru.spcex.clearing.reports.builders.EmptyParams;
|
||||
|
|
@ -39,8 +36,6 @@ public class KSRepDepoRegisterQuantitiesReportBuilder extends CSVReportBuilder<E
|
|||
private final Imdg<Registry> registryImdg;
|
||||
private final Imdg<Company> companyImdg;
|
||||
private final Imdg<AccountSymbols> accountSymbolsImdg;
|
||||
private final Imdg<CurrencyPairDictionary> currencyPairDictionaryImdg;
|
||||
private final Imdg<CurrencyPairSecurity> currencyPairSecurityImdg;
|
||||
|
||||
private List<KSRepDepoRegisterQuantitiesReport> rows = null;
|
||||
|
||||
|
|
@ -48,8 +43,6 @@ public class KSRepDepoRegisterQuantitiesReportBuilder extends CSVReportBuilder<E
|
|||
registryImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Registry, Registry.class);
|
||||
companyImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Company, Company.class);
|
||||
accountSymbolsImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_AccountSymbols, AccountSymbols.class);
|
||||
currencyPairDictionaryImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_CurrencyPairDictionary, CurrencyPairDictionary.class);
|
||||
currencyPairSecurityImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_CurrencyPairSecurity, CurrencyPairSecurity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -124,8 +117,11 @@ public class KSRepDepoRegisterQuantitiesReportBuilder extends CSVReportBuilder<E
|
|||
|
||||
String account = registry.getAccount();
|
||||
AccountSymbols accountSymbols = null;
|
||||
if (IEnumKey.getEnumByKey(AccountType.class, registry.getAccountType()) == AccountType.Depo)
|
||||
accountSymbols = accountSymbolsImdg.getFirstObjectByFieldValues(Map.of("accountId", registry.getAccountId()));
|
||||
if (IEnumKey.getEnumByKey(AccountType.class, registry.getAccountType()) == AccountType.Depo) {
|
||||
accountSymbols = accountSymbolsImdg.getFirstObjectByPredicate(
|
||||
accountSymbolsImdg.predicateBuilder().equals("accountId", registry.getAccountId())
|
||||
);
|
||||
}
|
||||
if (accountSymbols != null && !StringUtils.isBlank(accountSymbols.getAccountSymbolValue()))
|
||||
account = accountSymbols.getAccountSymbolValue();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,12 @@
|
|||
package ru.spcex.clearing.reports.builders.ks;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.clearing.classes.statics.data.account.AccountSymbols;
|
||||
|
|
@ -10,22 +17,18 @@ import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
|||
import ru.spcex.clearing.reports.builders.CSVReportBuilder;
|
||||
import ru.spcex.clearing.reports.builders.EmptyParams;
|
||||
import ru.spcex.clearing.reports.builders.bean.KSRepDepoRegistersReport;
|
||||
import ru.spcex.platform.enumeration.*;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.enumeration.RegistryStatus;
|
||||
import ru.spcex.platform.enumeration.RegistryTradingParams;
|
||||
import ru.spcex.platform.enumeration.ReportBuilderType;
|
||||
import ru.spcex.platform.enumeration.ReportKeys;
|
||||
import ru.spcex.platform.enumeration.WorkflowStatus;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
import ru.spcex.platform.imdg.api.predicate.specific.RegistryCodeSqlBuilder;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class KSRepDepoRegistersReportBuilder extends CSVReportBuilder<EmptyParams, KSRepDepoRegistersReport> {
|
||||
private final Imdg<Registry> registryImdg;
|
||||
|
|
@ -98,7 +101,9 @@ public class KSRepDepoRegistersReportBuilder extends CSVReportBuilder<EmptyParam
|
|||
ksRepDepoRegistersReport.setFirmId(registry.getTradingCode());
|
||||
|
||||
String account = registry.getAccount();
|
||||
AccountSymbols accountSymbols = accountSymbolsImdg.getFirstObjectByFieldValues(Map.of("accountId", registry.getAccountId()));
|
||||
AccountSymbols accountSymbols = accountSymbolsImdg.getFirstObjectByPredicate(
|
||||
accountSymbolsImdg.predicateBuilder().equals("accountId", registry.getAccountId())
|
||||
);
|
||||
if (accountSymbols != null && !StringUtils.isBlank(accountSymbols.getAccountSymbolValue()))
|
||||
account = accountSymbols.getAccountSymbolValue();
|
||||
ksRepDepoRegistersReport.setAccount(account);
|
||||
|
|
@ -114,7 +119,9 @@ public class KSRepDepoRegistersReportBuilder extends CSVReportBuilder<EmptyParam
|
|||
ksRepDepoRegistersReport.setRemarks(null);
|
||||
ksRepDepoRegistersReport.setTradeNum(null);
|
||||
|
||||
RegistryCodeDictionary registryCodeDescription = registryCodeDictionaryImdg.getFirstObjectByFieldValues(Map.of("code", registry.getRegistryCode()));
|
||||
RegistryCodeDictionary registryCodeDescription = registryCodeDictionaryImdg.getFirstObjectByPredicate(
|
||||
registryCodeDictionaryImdg.predicateBuilder().equals("code", registry.getRegistryCode())
|
||||
);
|
||||
if (registryCodeDescription != null) ksRepDepoRegistersReport.setRegisterName(registryCodeDescription.getName());
|
||||
|
||||
BigDecimal settledCredit = registry.getSettledCredit() != null ? registry.getSettledCredit() : BigDecimal.ZERO;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package ru.spcex.clearing.reports.builders.ks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.company.CompanySymbols;
|
||||
|
|
@ -8,14 +11,14 @@ import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
|||
import ru.spcex.clearing.reports.builders.CSVReportBuilder;
|
||||
import ru.spcex.clearing.reports.builders.EmptyParams;
|
||||
import ru.spcex.clearing.reports.builders.bean.KSRepFirmDetailsReport;
|
||||
import ru.spcex.platform.enumeration.*;
|
||||
import ru.spcex.platform.enumeration.CompanySymbol;
|
||||
import ru.spcex.platform.enumeration.DocumentTypes;
|
||||
import ru.spcex.platform.enumeration.ReportBuilderType;
|
||||
import ru.spcex.platform.enumeration.ReportKeys;
|
||||
import ru.spcex.platform.enumeration.WorkflowStatus;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
|
||||
@Deprecated
|
||||
@Component
|
||||
|
|
@ -59,31 +62,35 @@ public class KSRepFirmDetailsReportBuilder extends CSVReportBuilder<EmptyParams,
|
|||
|
||||
@Override
|
||||
protected void collect(EmptyParams params) {
|
||||
Collection<Company> companies = companyImdg.getCollectionObjectsByFieldValues(Map.of("workflowStatus", WorkflowStatus.Active.getKey()));
|
||||
Collection<Company> companies = companyImdg.getCollectionObjectsByPredicate(
|
||||
companyImdg.predicateBuilder().equals("workflowStatus", WorkflowStatus.Active.getKey())
|
||||
);
|
||||
log.debug("Found {} Company", companies.size());
|
||||
|
||||
rows = new ArrayList<>(companies.size());
|
||||
for (Company company : companies) {
|
||||
try {
|
||||
CompanySymbols innCompanySymbol = companySymbolsImdg.getFirstObjectByFieldValues(
|
||||
Map.of(
|
||||
"companyId", company.getId(),
|
||||
"companySymbol", CompanySymbol.INN.getKey()
|
||||
)
|
||||
ImdgPredicateBuilder pb = companySymbolsImdg.predicateBuilder();
|
||||
CompanySymbols innCompanySymbol = companySymbolsImdg.getFirstObjectByPredicate(
|
||||
pb.and(
|
||||
pb.equals("companyId", company.getId()),
|
||||
pb.equals("companySymbol", CompanySymbol.INN.getKey())
|
||||
)
|
||||
);
|
||||
|
||||
CompanySymbols cppCompanySymbol = companySymbolsImdg.getFirstObjectByFieldValues(
|
||||
Map.of(
|
||||
"companyId", company.getId(),
|
||||
"companySymbol", CompanySymbol.CPP.getKey()
|
||||
)
|
||||
CompanySymbols cppCompanySymbol = companySymbolsImdg.getFirstObjectByPredicate(
|
||||
pb.and(
|
||||
pb.equals("companyId", company.getId()),
|
||||
pb.equals("companySymbol", CompanySymbol.CPP.getKey())
|
||||
)
|
||||
);
|
||||
|
||||
ProfileDocument profileDocument = profileDocumentImdg.getFirstObjectByFieldValues(
|
||||
Map.of(
|
||||
"companyId", company.getId(),
|
||||
"documentType", DocumentTypes.cntr.getKey()
|
||||
)
|
||||
pb = profileDocumentImdg.predicateBuilder();
|
||||
ProfileDocument profileDocument = profileDocumentImdg.getFirstObjectByPredicate(
|
||||
pb.and(
|
||||
pb.equals("companyId", company.getId()),
|
||||
pb.equals("documentType", DocumentTypes.cntr.getKey())
|
||||
)
|
||||
);
|
||||
|
||||
KSRepFirmDetailsReport ksRepFirmDetailsReport = new KSRepFirmDetailsReport();
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import ru.spcex.platform.enumeration.ReportKeys;
|
|||
import ru.spcex.platform.enumeration.Side;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
import ru.spcex.platform.imdg.api.predicate.specific.RegistryCodeSqlBuilder;
|
||||
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||
|
|
@ -144,7 +145,7 @@ public class KSRepTradesReportBuilder extends CSVReportBuilder<EmptyParams, KSRe
|
|||
if (coverage == CoverageStatus.DEND) {
|
||||
if (execution instanceof ExecutionFond) {
|
||||
ImdgPredicateBuilder pbRegistry = registryImdg.predicateBuilder();
|
||||
String registryPredicateStr = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams._S_T).build();
|
||||
ImdgPredicate registryPredicate = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams._S_T).buildPredicate(pbRegistry);
|
||||
Collection<Registry> registryCollection = registryImdg.getCollectionObjectsByPredicate(
|
||||
pbRegistry.and(
|
||||
pbRegistry.equals("groupId", groupId),
|
||||
|
|
@ -154,7 +155,7 @@ public class KSRepTradesReportBuilder extends CSVReportBuilder<EmptyParams, KSRe
|
|||
RegistryStatus.NACK.getKey(),
|
||||
RegistryStatus.FAIL.getKey(),
|
||||
RegistryStatus.UNCV.getKey()),
|
||||
pbRegistry.sql(registryPredicateStr)
|
||||
registryPredicate
|
||||
)
|
||||
);
|
||||
if (registryCollection.isEmpty()) {
|
||||
|
|
@ -197,10 +198,13 @@ public class KSRepTradesReportBuilder extends CSVReportBuilder<EmptyParams, KSRe
|
|||
Account moneyAccountFromImdg = accountImdg.getSingleObjectByID(tkr.getMoneyAccountId());
|
||||
if (moneyAccountFromImdg != null) {
|
||||
if (AccountType.Info.equalsByKey(moneyAccountFromImdg.getAccountType())) {
|
||||
moneyAccountFromImdg = accountImdg.getFirstObjectByFieldValues(Map.of(
|
||||
"companyId", 1L,
|
||||
"accountType", AccountType.Anlt.getKey()
|
||||
));
|
||||
ImdgPredicateBuilder pb = accountImdg.predicateBuilder();
|
||||
moneyAccountFromImdg = accountImdg.getFirstObjectByPredicate(
|
||||
pb.and(
|
||||
pb.equals("companyId", 1L),
|
||||
pb.equals("accountType", AccountType.Anlt.getKey())
|
||||
)
|
||||
);
|
||||
}
|
||||
account = moneyAccountFromImdg.getAccount();
|
||||
}
|
||||
|
|
@ -248,9 +252,9 @@ public class KSRepTradesReportBuilder extends CSVReportBuilder<EmptyParams, KSRe
|
|||
} else if (execution instanceof ExecutionFond executionFond) {
|
||||
|
||||
if (tkr.getDepoAccountId() != null) {
|
||||
AccountSymbols accountSymbols = accountSymbolsImdg.getFirstObjectByFieldValues(Map.of(
|
||||
"accountId", tkr.getDepoAccountId()
|
||||
));
|
||||
AccountSymbols accountSymbols = accountSymbolsImdg.getFirstObjectByPredicate(
|
||||
accountSymbolsImdg.predicateBuilder().equals("accountId", tkr.getDepoAccountId())
|
||||
);
|
||||
if (accountSymbols != null) {
|
||||
depoAccount = accountSymbols.getAccountSymbolValue();
|
||||
} else {
|
||||
|
|
@ -326,9 +330,9 @@ public class KSRepTradesReportBuilder extends CSVReportBuilder<EmptyParams, KSRe
|
|||
continue;
|
||||
}
|
||||
|
||||
CurrencyPairSecurity currencyPairSecurity = currencyPairSecurityImdg.getFirstObjectByFieldValues(Map.of(
|
||||
"securityId", executionCurrency.getSecurityId()
|
||||
));
|
||||
CurrencyPairSecurity currencyPairSecurity = currencyPairSecurityImdg.getFirstObjectByPredicate(
|
||||
currencyPairSecurityImdg.predicateBuilder().equals("securityId", executionCurrency.getSecurityId())
|
||||
);
|
||||
if (currencyPairSecurity != null) {
|
||||
CurrencyPairDictionary currencyPairDictionary = currencyPairDictionaryImdg.getSingleObjectByID(
|
||||
currencyPairSecurity.getCurrencyPairId()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
package ru.spcex.clearing.reports.builders.ks;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.clearing.classes.statics.data.misc.Session;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
|
|
@ -10,13 +15,7 @@ import ru.spcex.platform.enumeration.ReportBuilderType;
|
|||
import ru.spcex.platform.enumeration.ReportKeys;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
|
||||
@Component
|
||||
public class KSSessionListReportBuilder extends CSVReportBuilder<EmptyParams, KSSessionListReport> {
|
||||
|
|
@ -55,9 +54,9 @@ public class KSSessionListReportBuilder extends CSVReportBuilder<EmptyParams, KS
|
|||
|
||||
@Override
|
||||
protected void collect(EmptyParams params) {
|
||||
Map<String, LocalDate> query = Map.of("clearingDate", LocalDate.now());
|
||||
Collection<Session> sessions = sessionImdg.getCollectionObjectsByFieldValues(query);
|
||||
log.debug("Found {} Session by query: {}", sessions.size(), query);
|
||||
ImdgPredicate predicate = sessionImdg.predicateBuilder().equals("clearingDate", LocalDate.now());
|
||||
Collection<Session> sessions = sessionImdg.getCollectionObjectsByPredicate(predicate);
|
||||
log.debug("Found {} Session by query: {}", sessions.size(), predicate.toString());
|
||||
rows = new ArrayList<>(sessions.size());
|
||||
for (Session session : sessions) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
package ru.spcex.clearing.reports.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import java.beans.PropertyVetoException;
|
||||
import com.mchange.v2.c3p0.ComboPooledDataSource;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import ru.spcex.clearing.reports.config.settings.ReportsServiceSettings;
|
||||
import ru.spcex.clearing.reports.db_direct.DBProvider;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
||||
|
||||
|
|
@ -19,29 +21,36 @@ public class ClearingImdgConfig {
|
|||
}
|
||||
pool.setCorePoolSize(maxPoolSz);
|
||||
pool.setWaitForTasksToCompleteOnShutdown(waitForCompletion);
|
||||
pool.initialize();
|
||||
return pool;
|
||||
}
|
||||
|
||||
@Bean(name = "taskExecutorHazelcastClientInitializer")
|
||||
public ThreadPoolTaskExecutor taskExecutorHazelcastClientInitializer() {
|
||||
return createThreadPoolTaskExecutor(1, true);
|
||||
}
|
||||
|
||||
@Bean(name = "taskExecutorIdGeneratorAwaiter")
|
||||
public ThreadPoolTaskExecutor taskExecutorIdGeneratorAwaiter() {
|
||||
return createThreadPoolTaskExecutor(1, false);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
@Bean
|
||||
public ImdgProvider imdgProvider(
|
||||
@Qualifier("taskExecutorHazelcastClientInitializer") ThreadPoolTaskExecutor taskExecutorHazelcastClientInitializer,
|
||||
@Qualifier("taskExecutorIdGeneratorAwaiter") ThreadPoolTaskExecutor taskExecutorIdGeneratorAwaiter,
|
||||
ReportsServiceSettings settings
|
||||
) {
|
||||
return new HazelcastService(taskExecutorHazelcastClientInitializer,
|
||||
taskExecutorIdGeneratorAwaiter,
|
||||
settings.getHazelcast());
|
||||
public ImdgProvider imdgProvider(ReportsServiceSettings settings) throws PropertyVetoException {
|
||||
boolean directDb = settings.getDirectDb() != null && settings.getDirectDb().getEnable() != null && settings.getDirectDb().getEnable();
|
||||
if (!directDb) {
|
||||
ThreadPoolTaskExecutor hazelcastClientInitializerPool = taskExecutorHazelcastClientInitializer();
|
||||
ThreadPoolTaskExecutor idGeneratorAwaiterPool = taskExecutorIdGeneratorAwaiter();
|
||||
return new HazelcastService(hazelcastClientInitializerPool, idGeneratorAwaiterPool, settings.getHazelcast());
|
||||
} else {
|
||||
ComboPooledDataSource dataSource = new ComboPooledDataSource();
|
||||
dataSource.setDriverClass(settings.getDirectDb().getDriver());
|
||||
dataSource.setJdbcUrl(settings.getDirectDb().getUrl());
|
||||
dataSource.setUser(settings.getDirectDb().getLogin());
|
||||
dataSource.setPassword(settings.getDirectDb().getPassword());
|
||||
dataSource.setMinPoolSize(Integer.parseInt(settings.getDirectDb().getMinPoolSize()));
|
||||
dataSource.setMaxPoolSize(Integer.parseInt(settings.getDirectDb().getMaxPoolSize()));
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
return new DBProvider(jdbcTemplate);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.kafka.core.ProducerFactory;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.config.KafkaConsumerFactory;
|
||||
import ru.spcex.clearing.platform.messaging.config.KafkaProducerFactory;
|
||||
|
|
@ -16,9 +17,11 @@ import ru.spcex.clearing.platform.messaging.config.element.KafkaProducerSettings
|
|||
import ru.spcex.clearing.platform.messaging.service.RequestInfo;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.clearing.reports.config.settings.ReportsServiceSettings;
|
||||
import ru.spcex.clearing.reports.db_direct.DBProvider;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgId;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
||||
|
||||
@Configuration
|
||||
public class KafkaConfig {
|
||||
|
|
@ -48,14 +51,26 @@ public class KafkaConfig {
|
|||
|
||||
@Autowired
|
||||
@Bean
|
||||
public KafkaSender kafkaSender(KafkaTemplate<String, Object> kafkaTemplate, ImdgProvider imdgProvider) {
|
||||
ImdgId imdgIdGenerator = imdgProvider.getImdgIdGenerator();
|
||||
public KafkaSender kafkaSender(KafkaTemplate<String, Object> kafkaTemplate, ImdgProvider imdgProvider, ReportsServiceSettings settings) {
|
||||
final ImdgProvider provider;
|
||||
if (imdgProvider instanceof DBProvider) {
|
||||
ThreadPoolTaskExecutor hazelcastClientInitializerPool = new ThreadPoolTaskExecutor();
|
||||
hazelcastClientInitializerPool.setCorePoolSize(1);
|
||||
hazelcastClientInitializerPool.setWaitForTasksToCompleteOnShutdown(true);
|
||||
ThreadPoolTaskExecutor idGeneratorAwaiterPool = new ThreadPoolTaskExecutor();
|
||||
idGeneratorAwaiterPool.setCorePoolSize(1);
|
||||
idGeneratorAwaiterPool.setWaitForTasksToCompleteOnShutdown(false);
|
||||
provider = new HazelcastService(hazelcastClientInitializerPool, idGeneratorAwaiterPool, settings.getHazelcast());
|
||||
} else {
|
||||
provider = imdgProvider;
|
||||
}
|
||||
ImdgId imdgIdGenerator = provider.getImdgIdGenerator();
|
||||
return KafkaSender
|
||||
.setup()
|
||||
.setKafkaTemplate(kafkaTemplate)
|
||||
.idGenerator(imdgIdGenerator::nextId)
|
||||
.imdgProvider(s -> {
|
||||
Imdg<RequestInfo> imdg = imdgProvider.getImdg(IMDGDistributedNames.Map_RequestInfo, RequestInfo.class);
|
||||
Imdg<RequestInfo> imdg = provider.getImdg(IMDGDistributedNames.Map_RequestInfo, RequestInfo.class);
|
||||
return imdg::insert;
|
||||
})
|
||||
.build();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,67 @@
|
|||
package ru.spcex.clearing.reports.config.settings;
|
||||
|
||||
public class DirectDB {
|
||||
private String login;
|
||||
private String password;
|
||||
private String url;
|
||||
private String driver;
|
||||
private String minPoolSize;
|
||||
private String maxPoolSize;
|
||||
private Boolean enable;
|
||||
|
||||
public String getLogin() {
|
||||
return login;
|
||||
}
|
||||
|
||||
public void setLogin(String login) {
|
||||
this.login = login;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getMinPoolSize() {
|
||||
return minPoolSize;
|
||||
}
|
||||
|
||||
public void setMinPoolSize(String minPoolSize) {
|
||||
this.minPoolSize = minPoolSize;
|
||||
}
|
||||
|
||||
public String getMaxPoolSize() {
|
||||
return maxPoolSize;
|
||||
}
|
||||
|
||||
public void setMaxPoolSize(String maxPoolSize) {
|
||||
this.maxPoolSize = maxPoolSize;
|
||||
}
|
||||
|
||||
public String getDriver() {
|
||||
return driver;
|
||||
}
|
||||
|
||||
public void setDriver(String driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public Boolean getEnable() {
|
||||
return enable;
|
||||
}
|
||||
|
||||
public void setEnable(Boolean enable) {
|
||||
this.enable = enable;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package ru.spcex.clearing.reports.config.settings;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
|
@ -8,8 +9,6 @@ import ru.spcex.clearing.platform.messaging.config.element.KafkaConsumerSettings
|
|||
import ru.spcex.clearing.platform.messaging.config.element.KafkaProducerSettings;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.config.HazelcastClientParams;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@PropertySource("file:${spring.config.location}/application.properties")
|
||||
@ConfigurationProperties("reports-service")
|
||||
|
|
@ -19,6 +18,7 @@ public class ReportsServiceSettings {
|
|||
private KafkaProducerSettings kafkaProducer;
|
||||
private Store reportsStore;
|
||||
private Store notificationsStore;
|
||||
private DirectDB directDb;
|
||||
|
||||
@Value("#{'${reports-service.reports.pfx-class-codes}'.split('\\s*,\\s*')}")
|
||||
private List<String> pfxClassCodes;
|
||||
|
|
@ -71,4 +71,12 @@ public class ReportsServiceSettings {
|
|||
public void setPfxClassCodes(List<String> pfxClassCodes) {
|
||||
this.pfxClassCodes = pfxClassCodes;
|
||||
}
|
||||
|
||||
public DirectDB getDirectDb() {
|
||||
return directDb;
|
||||
}
|
||||
|
||||
public void setDirectDb(DirectDB directDb) {
|
||||
this.directDb = directDb;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,165 @@
|
|||
package ru.spcex.clearing.reports.db_direct;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.sql.Date;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Time;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
|
||||
public class DBMap<T extends SpcexObjectBase> implements Imdg<T> {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final DateTimeFormatter localDateFormatter = DateTimeFormatter.ISO_LOCAL_DATE;
|
||||
private final DateTimeFormatter localTimeFormatter = DateTimeFormatter.ISO_LOCAL_TIME;
|
||||
private final DateTimeFormatter localDateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
|
||||
private final Class<T> clazz;
|
||||
private final Map<String, String> fieldMatcherMap;
|
||||
private final String tableName;
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
private final ReflectionRowMapper<T> reflectionRowMapper;
|
||||
|
||||
public DBMap(Map<String, String> fieldMatcherMap,
|
||||
String tableName,
|
||||
JdbcTemplate jdbcTemplate, Class<T> clazz) {
|
||||
this.fieldMatcherMap = fieldMatcherMap;
|
||||
this.tableName = tableName;
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
this.clazz = clazz;
|
||||
reflectionRowMapper = new ReflectionRowMapper<>(clazz, fieldMatcherMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getSingleObjectByID(Long id) {
|
||||
List<T> result;
|
||||
try {
|
||||
result = jdbcTemplate.query("select * from %s where ID = %d limit 1".formatted(tableName, id), reflectionRowMapper);
|
||||
} catch (Exception e) {
|
||||
log.warn("Query error", e);
|
||||
return null;
|
||||
}
|
||||
if (result.isEmpty()) return null;
|
||||
return result.iterator().next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<T> getCollectionObjectsByPredicate(ImdgPredicate predicate) {
|
||||
String sql = predicate.toString();
|
||||
List<T> result;
|
||||
try {
|
||||
result = jdbcTemplate.query("select * from %s where (%s)".formatted(tableName, sql), reflectionRowMapper);
|
||||
} catch (Exception e) {
|
||||
log.warn("Query error", e);
|
||||
return null;
|
||||
}
|
||||
if (result.isEmpty()) return Collections.emptyList();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getFirstObjectByPredicate(ImdgPredicate predicate) {
|
||||
String sql = predicate.toString();
|
||||
List<T> result;
|
||||
try {
|
||||
result = jdbcTemplate.query("select * from %s where (%s) limit 1".formatted(tableName, sql), reflectionRowMapper);
|
||||
} catch (Exception e) {
|
||||
log.warn("Query error", e);
|
||||
return null;
|
||||
}
|
||||
if (result.isEmpty()) return null;
|
||||
return result.iterator().next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImdgPredicateBuilder predicateBuilder() {
|
||||
return new DBPredicateBuilder(fieldMatcherMap);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Позволяет по матчеру (fieldMatcherMap) создать объект нужного типа (clazz) из ResultSet
|
||||
*/
|
||||
static class ReflectionRowMapper<T extends SpcexObjectBase> implements RowMapper<T> {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final Class<T> clazz;
|
||||
private final Map<String, String> fieldMatcherMap;
|
||||
|
||||
private ReflectionRowMapper(Class<T> clazz, Map<String, String> fieldMatcherMap) {
|
||||
this.clazz = clazz;
|
||||
this.fieldMatcherMap = fieldMatcherMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T mapRow(ResultSet rs, int rowNum) {
|
||||
T result;
|
||||
try {
|
||||
Constructor<T> constructor = clazz.getDeclaredConstructor();
|
||||
result = constructor.newInstance();
|
||||
for (Map.Entry<String, String> entry : fieldMatcherMap.entrySet()) {
|
||||
String pojoName = entry.getKey();
|
||||
String dbName = entry.getValue();
|
||||
Field field = null;
|
||||
Object value;
|
||||
try {
|
||||
try {
|
||||
field = clazz.getDeclaredField(pojoName);
|
||||
} catch (NoSuchFieldException ignored) {}
|
||||
if (field == null) {
|
||||
Class<?> superClass = clazz;
|
||||
do {
|
||||
superClass = superClass.getSuperclass();
|
||||
if (superClass == null) break;
|
||||
try {
|
||||
field = superClass.getDeclaredField(pojoName);
|
||||
} catch (NoSuchFieldException ignored) {}
|
||||
} while (field == null);
|
||||
}
|
||||
if (field == null) continue;
|
||||
value = rs.getObject(dbName);
|
||||
} catch (SQLException e) {
|
||||
continue;
|
||||
}
|
||||
setFieldWithCorrectType(field, result, value);
|
||||
}
|
||||
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException |
|
||||
IllegalAccessException e) {
|
||||
log.error("ReflectionRowMapper error, check code", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void setFieldWithCorrectType(Field field, T obj, Object value) throws IllegalAccessException {
|
||||
if (obj == null) return;
|
||||
field.setAccessible(true);
|
||||
if (value instanceof Date dateValue) {
|
||||
field.set(obj, dateValue.toLocalDate());
|
||||
} else if (value instanceof Time timeValue) {
|
||||
field.set(obj, timeValue.toLocalTime());
|
||||
} else if (value instanceof Timestamp timestampValue) {
|
||||
if (field.getType() == Instant.class) {
|
||||
field.set(obj, timestampValue.toInstant());
|
||||
} else if (field.getType() == LocalDateTime.class) {
|
||||
field.set(obj, timestampValue.toLocalDateTime());
|
||||
}
|
||||
} else field.set(obj, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package ru.spcex.clearing.reports.db_direct;
|
||||
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
|
||||
public class DBPredicate implements ImdgPredicate {
|
||||
private final String predicate;
|
||||
|
||||
public DBPredicate(String predicate) {
|
||||
this.predicate = predicate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return predicate;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
package ru.spcex.clearing.reports.db_direct;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.adapter.predicate.ImdgPredicateBuilderHazelcast;
|
||||
|
||||
public class DBPredicateBuilder extends ImdgPredicateBuilderHazelcast {
|
||||
private final DateTimeFormatter localDateFormatter = DateTimeFormatter.ISO_LOCAL_DATE;
|
||||
private final DateTimeFormatter localTimeFormatter = DateTimeFormatter.ISO_LOCAL_TIME;
|
||||
private final DateTimeFormatter localDateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
|
||||
private final Map<String, String> fieldMatcherMap;
|
||||
|
||||
public DBPredicateBuilder(Map<String, String> fieldMatcherMap) {
|
||||
this.fieldMatcherMap = fieldMatcherMap;
|
||||
}
|
||||
|
||||
private String replaceKey(String key) {
|
||||
String result = fieldMatcherMap.get(key);
|
||||
return result == null ? key : result;
|
||||
}
|
||||
|
||||
private String replaceValue(Object object) {
|
||||
if (object == null)
|
||||
throw new UnsupportedOperationException("For compare 'is null' or 'is not null' use methods isNull() and notNull()");
|
||||
|
||||
if (object instanceof String strObj) return " '%s' ".formatted(strObj);
|
||||
if (object instanceof Character charObj) return " '%s' ".formatted(charObj);
|
||||
if (object instanceof LocalDate ldObj) return " '%s' ".formatted(ldObj.format(localDateFormatter));
|
||||
if (object instanceof LocalTime ltObj) return " '%s' ".formatted(ltObj.format(localTimeFormatter));
|
||||
if (object instanceof LocalDateTime ldtObj) return " '%s' ".formatted(ldtObj.format(localDateTimeFormatter));
|
||||
if (object instanceof Instant instantObj) return " '%s' ".formatted(localDateTimeFormatter.withZone(ZoneId.systemDefault()).format(instantObj));
|
||||
return " %s ".formatted(object.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImdgPredicate equals(String key, Object value) {
|
||||
if (value == null) return isNull(key);
|
||||
return new DBPredicate(" (%s = %s) ".formatted(replaceKey(key), replaceValue(value)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImdgPredicate greatEqual(String key, Comparable value) {
|
||||
if (value == null) return isNull(key);
|
||||
return new DBPredicate(" (%s >= %s) ".formatted(replaceKey(key), replaceValue(value)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImdgPredicate lessEqual(String key, Comparable value) {
|
||||
if (value == null) return isNull(key);
|
||||
return new DBPredicate(" (%s <= %s) ".formatted(replaceKey(key), replaceValue(value)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImdgPredicate greater(String key, Comparable value) {
|
||||
return new DBPredicate(" (%s > %s) ".formatted(replaceKey(key), replaceValue(value)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImdgPredicate less(String key, Comparable value) {
|
||||
return new DBPredicate(" (%s < %s) ".formatted(replaceKey(key), replaceValue(value)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImdgPredicate notNull(String key) {
|
||||
return new DBPredicate(" (%s is not null) ".formatted(replaceKey(key)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImdgPredicate isNull(String key) {
|
||||
return new DBPredicate(" (%s is null) ".formatted(replaceKey(key)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImdgPredicate in(String key, Comparable... values) {
|
||||
if (values == null || values.length == 0) {
|
||||
return new DBPredicate(" (false) ");
|
||||
}
|
||||
return new DBPredicate(
|
||||
" (%s in (%s)) ".formatted(
|
||||
replaceKey(key),
|
||||
Arrays.stream(values)
|
||||
.map(this::replaceValue)
|
||||
.collect(Collectors.joining(","))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImdgPredicate ilike(String key, String pattern) {
|
||||
throw new UnsupportedOperationException("not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImdgPredicate not(ImdgPredicate param) {
|
||||
return new DBPredicate(" (not (%s)) ".formatted(param.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImdgPredicate and(ImdgPredicate paramA, ImdgPredicate paramB) {
|
||||
return new DBPredicate(" ((%s) and (%s)) ".formatted(paramA.toString(), paramB.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImdgPredicate and(ImdgPredicate... param) {
|
||||
return new DBPredicate(
|
||||
" (%s) ".formatted(
|
||||
Arrays.stream(param)
|
||||
.map(predicate -> " (%s) ".formatted(predicate.toString()))
|
||||
.collect(Collectors.joining(" and "))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImdgPredicate or(ImdgPredicate paramA, ImdgPredicate paramB) {
|
||||
return new DBPredicate(" ((%s) or (%s)) ".formatted(paramA.toString(), paramB.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImdgPredicate or(ImdgPredicate... param) {
|
||||
return new DBPredicate(
|
||||
" (%s) ".formatted(
|
||||
Arrays.stream(param)
|
||||
.map(predicate -> " (%s) ".formatted(predicate.toString()))
|
||||
.collect(Collectors.joining(" or "))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImdgPredicate sql(String sql) {
|
||||
return new DBPredicate(sql);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,349 @@
|
|||
package ru.spcex.clearing.reports.db_direct;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.AccountSymbols;
|
||||
import ru.clearing.classes.statics.data.company.ClearingMemberCategory;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.execution.ExecutionCurrency;
|
||||
import ru.clearing.classes.statics.data.execution.ExecutionDeposit;
|
||||
import ru.clearing.classes.statics.data.execution.ExecutionFond;
|
||||
import ru.clearing.classes.statics.data.misc.Session;
|
||||
import ru.clearing.classes.statics.data.profile.ProfileDocument;
|
||||
import ru.clearing.classes.statics.data.registry.Registry;
|
||||
import ru.clearing.classes.statics.data.registry.TradingClearingRegistry;
|
||||
import ru.clearing.classes.statics.data.security.CurrencyPairSecurity;
|
||||
import ru.clearing.platform.dictionary.CurrencyPairDictionary;
|
||||
import ru.clearing.platform.dictionary.ErrorCodeDictionary;
|
||||
import ru.clearing.platform.dictionary.RegistryCodeDictionary;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgId;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.ImdgTransaction;
|
||||
|
||||
public class DBProvider implements ImdgProvider {
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
private final Map<Class<?>, Map<String, String>> fieldsMatcherForTable = new HashMap<>();
|
||||
private final Map<Class<?>, String> tableNameForClass = new HashMap<>();
|
||||
|
||||
public DBProvider(JdbcTemplate jdbcTemplate) {
|
||||
initFieldsMatcherForTable();
|
||||
initTableNames();
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends SpcexObjectBase> Imdg<T> getImdg(String key, Class<T> clazz) {
|
||||
Map<String, String> fieldsMatcherMap = fieldsMatcherForTable.get(clazz);
|
||||
String tableName = tableNameForClass.get(clazz);
|
||||
return new DBMap<>(fieldsMatcherMap, tableName, jdbcTemplate, clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImdgId getImdgIdGenerator() {
|
||||
throw new UnsupportedOperationException("not implemented for direct DB provider");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImdgTransaction newTransaction() {
|
||||
throw new UnsupportedOperationException("not implemented for direct DB provider");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void waitAvailable() {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
|
||||
private void initFieldsMatcherForTable() {
|
||||
Map<String, String> accountMatcher = new HashMap<>();
|
||||
accountMatcher.put("id", "id");
|
||||
accountMatcher.put("updated", "updated_at");
|
||||
accountMatcher.put("created", "created_at");
|
||||
accountMatcher.put("account", "account");
|
||||
accountMatcher.put("accountType", "account_type");
|
||||
accountMatcher.put("relationId", "relation_id");
|
||||
accountMatcher.put("status", "status");
|
||||
accountMatcher.put("processingSign", "processing_sign");
|
||||
accountMatcher.put("companyId", "companyId");
|
||||
accountMatcher.put("currency", "currency");
|
||||
this.fieldsMatcherForTable.put(Account.class, accountMatcher);
|
||||
|
||||
Map<String, String> executionDepositMatcher = new HashMap<>();
|
||||
executionDepositMatcher.put("id", "id");
|
||||
executionDepositMatcher.put("updated", "updated_at");
|
||||
executionDepositMatcher.put("created", "created_at");
|
||||
executionDepositMatcher.put("exchangeExecutionId", "exchange_execution_id");
|
||||
executionDepositMatcher.put("side", "side");
|
||||
executionDepositMatcher.put("market", "market");
|
||||
executionDepositMatcher.put("tradingDate", "trading_date");
|
||||
executionDepositMatcher.put("securitySymbol", "security_symbol");
|
||||
executionDepositMatcher.put("securityId", "security_id");
|
||||
executionDepositMatcher.put("interestAmount", "interest_amount");
|
||||
executionDepositMatcher.put("exchangeOrderId", "exchange_order_id");
|
||||
executionDepositMatcher.put("price", "price");
|
||||
executionDepositMatcher.put("lots", "lots");
|
||||
executionDepositMatcher.put("quantity", "quantity");
|
||||
executionDepositMatcher.put("exchangeExecutionTime", "exchange_execution_time");
|
||||
executionDepositMatcher.put("duration", "duration");
|
||||
executionDepositMatcher.put("tradingClearingRegistryId", "trading_clearing_registry_id");
|
||||
executionDepositMatcher.put("companyId", "company_id");
|
||||
executionDepositMatcher.put("counterPartyId", "counter_party_id");
|
||||
executionDepositMatcher.put("securityFullName", "security_full_name");
|
||||
executionDepositMatcher.put("settlementCurrency", "settlement_currency");
|
||||
executionDepositMatcher.put("coverageStatus", "coverage_status");
|
||||
executionDepositMatcher.put("sessionId", "session_id");
|
||||
executionDepositMatcher.put("counterPartyTradingClearingRegistryId", "counter_party_trading_clearing_registry_id");
|
||||
executionDepositMatcher.put("partyTradingClearingRegistry", "party_trading_clearing_registry");
|
||||
executionDepositMatcher.put("counterPartyTradingClearingRegistry", "counter_party_trading_clearing_registry");
|
||||
executionDepositMatcher.put("secondLegSettlementDate", "second_leg_settlement_date");
|
||||
executionDepositMatcher.put("secondLegSettlementCode", "second_leg_settlement_code");
|
||||
executionDepositMatcher.put("firstLegSettlementCode", "first_leg_settlement_code");
|
||||
executionDepositMatcher.put("contract", "contract");
|
||||
executionDepositMatcher.put("firstLegAmount", "first_leg_amount");
|
||||
executionDepositMatcher.put("firstLegSettlementDate", "first_leg_settlement_date");
|
||||
executionDepositMatcher.put("secondLegAmount", "second_leg_amount");
|
||||
executionDepositMatcher.put("securityCode", "security_code");
|
||||
this.fieldsMatcherForTable.put(ExecutionDeposit.class, executionDepositMatcher);
|
||||
|
||||
Map<String, String> executionFondMatcher = new HashMap<>();
|
||||
executionFondMatcher.put("id", "id");
|
||||
executionFondMatcher.put("updated", "updated_at");
|
||||
executionFondMatcher.put("created", "created_at");
|
||||
executionFondMatcher.put("exchangeExecutionId", "exchange_execution_id");
|
||||
executionFondMatcher.put("side", "side");
|
||||
executionFondMatcher.put("market", "market");
|
||||
executionFondMatcher.put("tradingDate", "trading_date");
|
||||
executionFondMatcher.put("securitySymbol", "security_symbol");
|
||||
executionFondMatcher.put("securityId", "security_id");
|
||||
executionFondMatcher.put("interestAmount", "interest_amount");
|
||||
executionFondMatcher.put("exchangeOrderId", "exchange_order_id");
|
||||
executionFondMatcher.put("price", "price");
|
||||
executionFondMatcher.put("settlementAmount", "settlement_amount");
|
||||
executionFondMatcher.put("lots", "lots");
|
||||
executionFondMatcher.put("quantity", "quantity");
|
||||
executionFondMatcher.put("exchangeExecutionTime", "exchange_execution_time");
|
||||
executionFondMatcher.put("duration", "duration");
|
||||
executionFondMatcher.put("tradingClearingRegistryId", "trading_clearing_registry_id");
|
||||
executionFondMatcher.put("comment", "comment");
|
||||
executionFondMatcher.put("clientCodeId", "client_code_id");
|
||||
executionFondMatcher.put("settlementCode", "settlement_code");
|
||||
executionFondMatcher.put("companyId", "company_id");
|
||||
executionFondMatcher.put("counterPartyId", "counter_party_id");
|
||||
executionFondMatcher.put("securityFullName", "security_full_name");
|
||||
executionFondMatcher.put("settlementDate", "settlement_date");
|
||||
executionFondMatcher.put("settlementCurrency", "settlement_currency");
|
||||
executionFondMatcher.put("exchangeExecutionMicroseconds", "exchange_execution_microseconds");
|
||||
executionFondMatcher.put("coverageStatus", "coverage_status");
|
||||
executionFondMatcher.put("sessionId", "session_id");
|
||||
executionFondMatcher.put("counterPartyTradingClearingRegistryId", "counter_party_trading_clearing_registry_id");
|
||||
executionFondMatcher.put("partyTradingClearingRegistry", "party_trading_clearing_registry");
|
||||
executionFondMatcher.put("counterPartyTradingClearingRegistry", "counter_party_trading_clearing_registry");
|
||||
this.fieldsMatcherForTable.put(ExecutionFond.class, executionFondMatcher);
|
||||
|
||||
Map<String, String> companyMatcher = new HashMap<>();
|
||||
companyMatcher.put("id", "id");
|
||||
companyMatcher.put("updated", "updated_at");
|
||||
companyMatcher.put("created", "created_at");
|
||||
companyMatcher.put("shortName", "short_name");
|
||||
companyMatcher.put("fullName", "full_name");
|
||||
companyMatcher.put("tradingCode", "trading_code");
|
||||
companyMatcher.put("clearingCode", "clearing_code");
|
||||
companyMatcher.put("registrationCode", "registration_code");
|
||||
companyMatcher.put("workflowStatus", "workflow_status");
|
||||
this.fieldsMatcherForTable.put(Company.class, companyMatcher);
|
||||
|
||||
Map<String, String> registryMatcher = new HashMap<>();
|
||||
registryMatcher.put("id", "id");
|
||||
registryMatcher.put("updated", "updated_at");
|
||||
registryMatcher.put("created", "created_at");
|
||||
registryMatcher.put("companyId", "company_id");
|
||||
registryMatcher.put("tradingCode", "trading_code");
|
||||
registryMatcher.put("clearingCode", "clearing_code");
|
||||
registryMatcher.put("shortName", "short_name");
|
||||
registryMatcher.put("fullName", "full_name");
|
||||
registryMatcher.put("accountId", "account_id");
|
||||
registryMatcher.put("accountType", "account_type");
|
||||
registryMatcher.put("account", "account");
|
||||
registryMatcher.put("registryDesignation", "registry_designation");
|
||||
registryMatcher.put("registryInstrumentType", "registry_instrument_type");
|
||||
registryMatcher.put("registryCapacity", "registry_capacity");
|
||||
registryMatcher.put("registryUnit", "registry_unit");
|
||||
registryMatcher.put("registryCode", "registry_code");
|
||||
registryMatcher.put("tradingClearingRegistryId", "trading_clearing_registry_id");
|
||||
registryMatcher.put("tradingClearingRegistry", "trading_clearing_registry");
|
||||
registryMatcher.put("registryStatus", "registry_status");
|
||||
registryMatcher.put("securityId", "security_id");
|
||||
registryMatcher.put("securitySymbol", "security_symbol");
|
||||
registryMatcher.put("balance", "balance");
|
||||
registryMatcher.put("openBalance", "open_balance");
|
||||
registryMatcher.put("closeBalance", "close_balance");
|
||||
registryMatcher.put("credit", "credit");
|
||||
registryMatcher.put("debit", "debit");
|
||||
registryMatcher.put("settledCredit", "settled_credit");
|
||||
registryMatcher.put("settledDebit", "settled_debit");
|
||||
registryMatcher.put("checkBalance", "check_balance");
|
||||
registryMatcher.put("diffBalance", "diff_balance");
|
||||
registryMatcher.put("planBalance", "plan_balance");
|
||||
registryMatcher.put("balanceDimension", "balance_dimension");
|
||||
registryMatcher.put("settlementDate", "settlement_date");
|
||||
registryMatcher.put("settlementCode", "settlement_code");
|
||||
registryMatcher.put("tradingDate", "trading_date");
|
||||
registryMatcher.put("clearingDate", "clearing_date");
|
||||
registryMatcher.put("refundDate", "refund_date");
|
||||
registryMatcher.put("valueDate", "value_date");
|
||||
registryMatcher.put("price", "price");
|
||||
registryMatcher.put("contract", "contract");
|
||||
registryMatcher.put("counterPartyId", "counter_party_id");
|
||||
registryMatcher.put("comment", "comment");
|
||||
registryMatcher.put("parentId", "parent_id");
|
||||
registryMatcher.put("groupId", "group_id");
|
||||
registryMatcher.put("sessionId", "session_id");
|
||||
registryMatcher.put("sessionType", "session_type");
|
||||
registryMatcher.put("paymentId", "payment_id");
|
||||
this.fieldsMatcherForTable.put(Registry.class, registryMatcher);
|
||||
|
||||
Map<String, String> sessionMatcher = new HashMap<>();
|
||||
sessionMatcher.put("id", "id");
|
||||
sessionMatcher.put("updated", "updated_at");
|
||||
sessionMatcher.put("created", "created_at");
|
||||
sessionMatcher.put("clearingDate", "clearing_date");
|
||||
sessionMatcher.put("sessionStatus", "session_status");
|
||||
sessionMatcher.put("companyId", "company_id");
|
||||
sessionMatcher.put("securityId", "security_id");
|
||||
sessionMatcher.put("userId", "user_id");
|
||||
sessionMatcher.put("section", "section");
|
||||
sessionMatcher.put("sessionType", "session_type");
|
||||
sessionMatcher.put("workflowStatus", "workflow_status");
|
||||
this.fieldsMatcherForTable.put(Session.class, sessionMatcher);
|
||||
|
||||
Map<String, String> currencyPairDictionaryMatcher = new HashMap<>();
|
||||
currencyPairDictionaryMatcher.put("id", "id");
|
||||
currencyPairDictionaryMatcher.put("code", "code");
|
||||
currencyPairDictionaryMatcher.put("baseCurrencyId", "base_currency_id");
|
||||
currencyPairDictionaryMatcher.put("quoteCurrencyId", "quote_currency_id");
|
||||
currencyPairDictionaryMatcher.put("majorSign", "major_sign");
|
||||
this.fieldsMatcherForTable.put(CurrencyPairDictionary.class, currencyPairDictionaryMatcher);
|
||||
|
||||
Map<String, String> currencyPairSecurityMatcher = new HashMap<>();
|
||||
currencyPairSecurityMatcher.put("id", "id");
|
||||
currencyPairSecurityMatcher.put("updated", "updated_at");
|
||||
currencyPairSecurityMatcher.put("created", "created_at");
|
||||
currencyPairSecurityMatcher.put("baseUnitSize", "base_unit_size");
|
||||
currencyPairSecurityMatcher.put("currencyPairId", "currency_pair_id");
|
||||
currencyPairSecurityMatcher.put("code", "code");
|
||||
currencyPairSecurityMatcher.put("settlementType", "settlement_type");
|
||||
currencyPairSecurityMatcher.put("clearingOrganization", "clearing_organization");
|
||||
currencyPairSecurityMatcher.put("settlementOrganization", "settlement_organization");
|
||||
currencyPairSecurityMatcher.put("securityId", "security_id");
|
||||
this.fieldsMatcherForTable.put(CurrencyPairSecurity.class, currencyPairSecurityMatcher);
|
||||
|
||||
Map<String, String> registryCodeDictionaryMatcher = new HashMap<>();
|
||||
registryCodeDictionaryMatcher.put("id", "id");
|
||||
registryCodeDictionaryMatcher.put("code", "code");
|
||||
registryCodeDictionaryMatcher.put("name", "name");
|
||||
this.fieldsMatcherForTable.put(RegistryCodeDictionary.class, registryCodeDictionaryMatcher);
|
||||
|
||||
Map<String, String> clearingMemberCategoryMatcher = new HashMap<>();
|
||||
clearingMemberCategoryMatcher.put("companyId", "company_id");
|
||||
clearingMemberCategoryMatcher.put("clearingMemberCategory", "clearing_member_category");
|
||||
clearingMemberCategoryMatcher.put("id", "id");
|
||||
this.fieldsMatcherForTable.put(ClearingMemberCategory.class, clearingMemberCategoryMatcher);
|
||||
|
||||
Map<String, String> accountSymbolsMatcher = new HashMap<>();
|
||||
accountSymbolsMatcher.put("id", "id");
|
||||
accountSymbolsMatcher.put("accountId", "account_id");
|
||||
accountSymbolsMatcher.put("accountSymbolValue", "account_symbol_value");
|
||||
this.fieldsMatcherForTable.put(AccountSymbols.class, accountSymbolsMatcher);
|
||||
|
||||
Map<String, String> profileDocumentMatcher = new HashMap<>();
|
||||
profileDocumentMatcher.put("companyId", "company_id");
|
||||
profileDocumentMatcher.put("documentType", "document_type");
|
||||
profileDocumentMatcher.put("issueDate", "issue_date");
|
||||
profileDocumentMatcher.put("issuePlace", "issue_place");
|
||||
profileDocumentMatcher.put("issuer", "issuer");
|
||||
profileDocumentMatcher.put("issuerCode", "issuer_code");
|
||||
profileDocumentMatcher.put("name", "name");
|
||||
profileDocumentMatcher.put("number", "number");
|
||||
profileDocumentMatcher.put("place", "place");
|
||||
profileDocumentMatcher.put("validFromDate", "valid_from_date");
|
||||
profileDocumentMatcher.put("validToDate", "valid_to_date");
|
||||
profileDocumentMatcher.put("link", "link");
|
||||
profileDocumentMatcher.put("id", "id");
|
||||
this.fieldsMatcherForTable.put(ProfileDocument.class, profileDocumentMatcher);
|
||||
|
||||
Map<String, String> executionCurrencyMatcher = new HashMap<>();
|
||||
executionCurrencyMatcher.put("id", "id");
|
||||
executionCurrencyMatcher.put("updated", "updated_at");
|
||||
executionCurrencyMatcher.put("created", "created_at");
|
||||
executionCurrencyMatcher.put("exchangeExecutionId", "exchange_execution_id");
|
||||
executionCurrencyMatcher.put("exchangeExecutionTime", "exchange_execution_time");
|
||||
executionCurrencyMatcher.put("exchangeExecutionMicroseconds", "exchange_execution_microseconds");
|
||||
executionCurrencyMatcher.put("tradingDate", "trading_date");
|
||||
executionCurrencyMatcher.put("settlementDate", "settlement_date");
|
||||
executionCurrencyMatcher.put("settlementCode", "settlement_code");
|
||||
executionCurrencyMatcher.put("securityId", "security_id");
|
||||
executionCurrencyMatcher.put("securitySymbol", "security_symbol");
|
||||
executionCurrencyMatcher.put("securityName", "security_name");
|
||||
executionCurrencyMatcher.put("companyId", "company_id");
|
||||
executionCurrencyMatcher.put("partyTradingClearingRegistryId", "party_trading_clearing_registry_id");
|
||||
executionCurrencyMatcher.put("partyTradingClearingRegistry", "party_trading_clearing_registry");
|
||||
executionCurrencyMatcher.put("counterPartyId", "counter_party_id");
|
||||
executionCurrencyMatcher.put("counterPartyTradingClearingRegistryId", "counter_party_trading_clearing_registry_id");
|
||||
executionCurrencyMatcher.put("counterPartyTradingClearingRegistry", "counter_party_trading_clearing_registry");
|
||||
executionCurrencyMatcher.put("market", "market");
|
||||
executionCurrencyMatcher.put("price", "price");
|
||||
executionCurrencyMatcher.put("lots", "lots");
|
||||
executionCurrencyMatcher.put("settlementAmount", "settlement_amount");
|
||||
executionCurrencyMatcher.put("quantity", "quantity");
|
||||
executionCurrencyMatcher.put("side", "side");
|
||||
executionCurrencyMatcher.put("currencyCode", "currency_code");
|
||||
executionCurrencyMatcher.put("settlementOrganization", "settlement_organization");
|
||||
executionCurrencyMatcher.put("coverageStatus", "coverage_status");
|
||||
executionCurrencyMatcher.put("sessionId", "session_id");
|
||||
executionCurrencyMatcher.put("clearingDate", "clearing_date");
|
||||
this.fieldsMatcherForTable.put(ExecutionCurrency.class, executionCurrencyMatcher);
|
||||
|
||||
Map<String, String> tradingClearingRegistryMatcher = new HashMap<>();
|
||||
tradingClearingRegistryMatcher.put("id", "id");
|
||||
tradingClearingRegistryMatcher.put("updated", "updated_at");
|
||||
tradingClearingRegistryMatcher.put("created", "created_at");
|
||||
tradingClearingRegistryMatcher.put("companyId", "company_id");
|
||||
tradingClearingRegistryMatcher.put("code", "code");
|
||||
tradingClearingRegistryMatcher.put("moneyAccountId", "money_account_id");
|
||||
tradingClearingRegistryMatcher.put("depoAccountId", "depo_account_id");
|
||||
tradingClearingRegistryMatcher.put("tradingClearingRegistryType", "trading_clearing_registry_type");
|
||||
tradingClearingRegistryMatcher.put("tradingClearingRegistryLevel", "trading_clearing_registry_level");
|
||||
tradingClearingRegistryMatcher.put("tradingClearingRegistryPurpose", "trading_clearing_registry_purpose");
|
||||
tradingClearingRegistryMatcher.put("status", "status");
|
||||
this.fieldsMatcherForTable.put(TradingClearingRegistry.class, tradingClearingRegistryMatcher);
|
||||
|
||||
Map<String, String> errorCodeDictionaryMatcher = new HashMap<>();
|
||||
errorCodeDictionaryMatcher.put("id", "id");
|
||||
errorCodeDictionaryMatcher.put("code", "code");
|
||||
errorCodeDictionaryMatcher.put("name", "name");
|
||||
this.fieldsMatcherForTable.put(ErrorCodeDictionary.class, errorCodeDictionaryMatcher);
|
||||
}
|
||||
|
||||
private void initTableNames() {
|
||||
this.tableNameForClass.put(Account.class, "ACCOUNT");
|
||||
this.tableNameForClass.put(ExecutionFond.class, "EXECUTION_FOND");
|
||||
this.tableNameForClass.put(ExecutionDeposit.class, "EXECUTION_DEPOSIT");
|
||||
this.tableNameForClass.put(Company.class, "COMPANY");
|
||||
this.tableNameForClass.put(Registry.class, "REGISTRY");
|
||||
this.tableNameForClass.put(Session.class, "SESSION");
|
||||
this.tableNameForClass.put(CurrencyPairDictionary.class, "CURRENCY_PAIR_DICTIONARY");
|
||||
this.tableNameForClass.put(CurrencyPairSecurity.class, "CURRENCY_PAIR_SECURITY");
|
||||
this.tableNameForClass.put(RegistryCodeDictionary.class, "REGISTRY_CODE_DICTIONARY");
|
||||
this.tableNameForClass.put(ClearingMemberCategory.class, "CLEARING_MEMBER_CATEGORY");
|
||||
this.tableNameForClass.put(AccountSymbols.class, "ACCOUNT_SYMBOLS");
|
||||
this.tableNameForClass.put(ProfileDocument.class, "PROFILE_DOCUMENT");
|
||||
this.tableNameForClass.put(ExecutionCurrency.class, "EXECUTION_CURRENCY");
|
||||
this.tableNameForClass.put(TradingClearingRegistry.class, "TRADING_CLEARING_REGISTRY");
|
||||
this.tableNameForClass.put(ErrorCodeDictionary.class, "ERROR_CODE_DICTIONARY");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +1,11 @@
|
|||
package ru.spcex.clearing.reports.notifications;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -9,16 +15,12 @@ import ru.clearing.classes.statics.data.company.Company;
|
|||
import ru.clearing.classes.statics.data.company.CompanySymbols;
|
||||
import ru.clearing.classes.statics.data.profile.ProfileDocument;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.enumeration.CompanySymbol;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
|
||||
@Component
|
||||
public class NCMPNotificationBuilder extends NotificationBuilder {
|
||||
|
|
@ -49,27 +51,54 @@ public class NCMPNotificationBuilder extends NotificationBuilder {
|
|||
return null;
|
||||
}
|
||||
|
||||
String profileDocumentSql = "companyId = %d AND documentType = CLRN".formatted(consumerId);
|
||||
ImdgPredicateBuilder pb = profileDocumentImdg.predicateBuilder();
|
||||
ImdgPredicate predicate = pb.and(
|
||||
pb.equals("companyId", consumerId),
|
||||
pb.equals("documentType", "CLRN")
|
||||
);
|
||||
ProfileDocument profileDocument = null;
|
||||
Collection<ProfileDocument> profileDocuments = profileDocumentImdg.getCollectionObjectsBySQL(profileDocumentSql);
|
||||
Collection<ProfileDocument> profileDocuments = profileDocumentImdg.getCollectionObjectsByPredicate(predicate);
|
||||
if (profileDocuments.size() >= 1) {
|
||||
profileDocument = profileDocuments.iterator().next();
|
||||
} else {
|
||||
log.warn("ProfileDocument with sql {} not found", profileDocumentSql);
|
||||
log.warn("ProfileDocument with sql {} not found", predicate.toString());
|
||||
return null;
|
||||
}
|
||||
|
||||
String companySymbolsValueINN = getCompanySymbolValue("companyId = %d AND companySymbol = %s".formatted(consumerId, CompanySymbol.INN.getKey()), companySymbolsImdg);
|
||||
String companySymbolValueCLRC = getCompanySymbolValue("companyId = %d AND companySymbol = %s".formatted(consumerId, CompanySymbol.CLRC.getKey()), companySymbolsImdg);
|
||||
String companySymbolValueRGRC = getCompanySymbolValue("companyId = %d AND companySymbol = %s".formatted(consumerId, CompanySymbol.RGRC.getKey()), companySymbolsImdg);
|
||||
pb = companySymbolsImdg.predicateBuilder();
|
||||
String companySymbolsValueINN = getCompanySymbolValue(
|
||||
pb.and(
|
||||
pb.equals("companyId", consumerId),
|
||||
pb.equals("companySymbol", CompanySymbol.INN.getKey())
|
||||
),
|
||||
companySymbolsImdg
|
||||
);
|
||||
String companySymbolValueCLRC = getCompanySymbolValue(
|
||||
pb.and(
|
||||
pb.equals("companyId", consumerId),
|
||||
pb.equals("companySymbol", CompanySymbol.CLRC.getKey())
|
||||
),
|
||||
companySymbolsImdg
|
||||
);
|
||||
String companySymbolValueRGRC = getCompanySymbolValue(
|
||||
pb.and(
|
||||
pb.equals("companyId", consumerId),
|
||||
pb.equals("companySymbol", CompanySymbol.RGRC.getKey())
|
||||
),
|
||||
companySymbolsImdg
|
||||
);
|
||||
|
||||
String accountSql = "companyId = %d AND accountType = INFO".formatted(consumerId);
|
||||
Account account = null;
|
||||
Collection<Account> accounts = accountImdg.getCollectionObjectsBySQL(accountSql);
|
||||
if (profileDocuments.size() >= 1) {
|
||||
pb = accountImdg.predicateBuilder();
|
||||
predicate = pb.and(
|
||||
pb.equals("companyId", consumerId),
|
||||
pb.equals("accountType", AccountType.Info.getKey())
|
||||
);
|
||||
Collection<Account> accounts = accountImdg.getCollectionObjectsByPredicate(predicate);
|
||||
if (!profileDocuments.isEmpty()) {
|
||||
account = accounts.iterator().next();
|
||||
} else {
|
||||
log.warn("Account with sql {} not found", accountSql);
|
||||
log.warn("Account with sql {} not found", predicate.toString());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
package ru.spcex.clearing.reports.notifications;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -11,13 +17,7 @@ import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
|||
import ru.spcex.platform.enumeration.CompanySymbol;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
|
||||
@Component
|
||||
public class NTCRNotificationBuilder extends NotificationBuilder {
|
||||
|
|
@ -59,7 +59,15 @@ public class NTCRNotificationBuilder extends NotificationBuilder {
|
|||
return null;
|
||||
}
|
||||
|
||||
String companySymbolValueCLRC = getCompanySymbolValue("companyId = %d AND companySymbol = %s".formatted(consumerId, CompanySymbol.INN.getKey()), companySymbolsImdg);
|
||||
ImdgPredicateBuilder pb = companySymbolsImdg.predicateBuilder();
|
||||
|
||||
String companySymbolValueCLRC = getCompanySymbolValue(
|
||||
pb.and(
|
||||
pb.equals("companyId", consumerId),
|
||||
pb.equals("companySymbol", CompanySymbol.INN.getKey())
|
||||
),
|
||||
companySymbolsImdg
|
||||
);
|
||||
|
||||
|
||||
Map<String, String> valuesForTemplate = new HashMap<>();
|
||||
|
|
|
|||
|
|
@ -1,11 +1,5 @@
|
|||
package ru.spcex.clearing.reports.notifications;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import ru.clearing.classes.statics.data.company.CompanySymbols;
|
||||
import ru.spcex.clearing.reports.exceptions.ConfigException;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.time.LocalDate;
|
||||
|
|
@ -15,6 +9,12 @@ import java.time.format.TextStyle;
|
|||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import ru.clearing.classes.statics.data.company.CompanySymbols;
|
||||
import ru.spcex.clearing.reports.exceptions.ConfigException;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
|
||||
public abstract class NotificationBuilder {
|
||||
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
|
@ -76,9 +76,9 @@ public abstract class NotificationBuilder {
|
|||
return filename;
|
||||
}
|
||||
|
||||
protected String getCompanySymbolValue(String companySymbolsSql, Imdg<CompanySymbols> companySymbolsImdg) {
|
||||
protected String getCompanySymbolValue(ImdgPredicate predicate, Imdg<CompanySymbols> companySymbolsImdg) {
|
||||
CompanySymbols companySymbols;
|
||||
Collection<CompanySymbols> companySymbolsCollection = companySymbolsImdg.getCollectionObjectsBySQL(companySymbolsSql);
|
||||
Collection<CompanySymbols> companySymbolsCollection = companySymbolsImdg.getCollectionObjectsByPredicate(predicate);
|
||||
if (companySymbolsCollection.size() >= 1) {
|
||||
companySymbols = companySymbolsCollection.iterator().next();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,12 @@
|
|||
package ru.spcex.clearing.reports.notifications;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -7,14 +14,11 @@ import org.springframework.stereotype.Component;
|
|||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.profile.ProfileDocument;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.platform.enumeration.DocumentTypes;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.TextStyle;
|
||||
import java.util.*;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
|
||||
@Component
|
||||
public class REXNotificationBuilder extends NotificationBuilder {
|
||||
|
|
@ -31,7 +35,12 @@ public class REXNotificationBuilder extends NotificationBuilder {
|
|||
@Override
|
||||
public File buildNotification(Long consumerId) {
|
||||
String sql = "companyId = %d AND documentType = 'XCNT'".formatted(consumerId);
|
||||
Collection<ProfileDocument> profileDocuments = profileDocumentImdg.getCollectionObjectsBySQL(sql);
|
||||
ImdgPredicateBuilder pb = profileDocumentImdg.predicateBuilder();
|
||||
ImdgPredicate predicate = pb.and(
|
||||
pb.equals("companyId", consumerId),
|
||||
pb.equals("documentType", DocumentTypes.xcnt.getKey())
|
||||
);
|
||||
Collection<ProfileDocument> profileDocuments = profileDocumentImdg.getCollectionObjectsByPredicate(predicate);
|
||||
ProfileDocument currentProfileDocument = null;
|
||||
if (profileDocuments.size() >= 1) {
|
||||
Optional<ProfileDocument> profileDocumentOptional = profileDocuments.stream().max((o1, o2) -> {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
package ru.spcex.clearing.reports.notifications;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -9,13 +17,11 @@ import ru.clearing.classes.statics.data.company.Company;
|
|||
import ru.clearing.classes.statics.data.company.CompanySymbols;
|
||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.platform.enumeration.CompanySymbol;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
|
||||
@Component
|
||||
public class ROOT_ACTV_NotificationBuilder extends NotificationBuilder {
|
||||
|
|
@ -44,14 +50,14 @@ public class ROOT_ACTV_NotificationBuilder extends NotificationBuilder {
|
|||
return null;
|
||||
}
|
||||
|
||||
String relationsSql = "consumerId = %d".formatted(consumerId);
|
||||
Relation relation = null;
|
||||
Collection<Relation> relations = relationImdg.getCollectionObjectsBySQL(relationsSql);
|
||||
if (relations.size() >= 1) {
|
||||
ImdgPredicate predicate = relationImdg.predicateBuilder().equals("consumerId", consumerId);
|
||||
Collection<Relation> relations = relationImdg.getCollectionObjectsByPredicate(predicate);
|
||||
if (!relations.isEmpty()) {
|
||||
Optional<Relation> relationOptional = relations.stream().max(Comparator.comparing(BusinessObject::getUpdated));
|
||||
relation = relationOptional.get();
|
||||
} else {
|
||||
log.warn("Relation with sql {} not found", relationsSql);
|
||||
log.warn("Relation with sql {} not found", predicate.toString());
|
||||
return null;
|
||||
}
|
||||
Long notificationId = relation.getId();
|
||||
|
|
@ -61,13 +67,17 @@ public class ROOT_ACTV_NotificationBuilder extends NotificationBuilder {
|
|||
return null;
|
||||
}
|
||||
|
||||
String companySymbolsSql = "companyId = %d AND companySymbol = INN";
|
||||
ImdgPredicateBuilder pb = companySymbolsImdg.predicateBuilder();
|
||||
predicate = pb.and(
|
||||
pb.equals("companyId", consumerId),
|
||||
pb.equals("companySymbol", CompanySymbol.INN.getKey())
|
||||
);
|
||||
CompanySymbols companySymbols = null;
|
||||
Collection<CompanySymbols> companySymbolsCollection = companySymbolsImdg.getCollectionObjectsBySQL(companySymbolsSql);
|
||||
if (companySymbolsCollection.size() >= 1) {
|
||||
Collection<CompanySymbols> companySymbolsCollection = companySymbolsImdg.getCollectionObjectsByPredicate(predicate);
|
||||
if (!companySymbolsCollection.isEmpty()) {
|
||||
companySymbols = companySymbolsCollection.iterator().next();
|
||||
} else {
|
||||
log.warn("CompanySymbols with sql {} not found", companySymbolsSql);
|
||||
log.warn("CompanySymbols with sql {} not found", predicate.toString());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
package ru.spcex.clearing.reports.notifications;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -9,13 +17,11 @@ import ru.clearing.classes.statics.data.company.Company;
|
|||
import ru.clearing.classes.statics.data.company.CompanySymbols;
|
||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.platform.enumeration.CompanySymbol;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
|
||||
@Component
|
||||
public class ROOT_BLKD_NotificationBuilder extends NotificationBuilder {
|
||||
|
|
@ -44,14 +50,14 @@ public class ROOT_BLKD_NotificationBuilder extends NotificationBuilder {
|
|||
return null;
|
||||
}
|
||||
|
||||
String relationsSql = "consumerId = %d".formatted(consumerId);
|
||||
Relation relation = null;
|
||||
Collection<Relation> relations = relationImdg.getCollectionObjectsBySQL(relationsSql);
|
||||
if (relations.size() >= 1) {
|
||||
ImdgPredicate predicate = relationImdg.predicateBuilder().equals("consumerId", consumerId);
|
||||
Collection<Relation> relations = relationImdg.getCollectionObjectsByPredicate(predicate);
|
||||
if (!relations.isEmpty()) {
|
||||
Optional<Relation> relationOptional = relations.stream().max(Comparator.comparing(BusinessObject::getUpdated));
|
||||
relation = relationOptional.get();
|
||||
} else {
|
||||
log.warn("Relation with sql {} not found", relationsSql);
|
||||
log.warn("Relation with sql {} not found", predicate.toString());
|
||||
return null;
|
||||
}
|
||||
Long notificationId = relation.getId();
|
||||
|
|
@ -61,13 +67,17 @@ public class ROOT_BLKD_NotificationBuilder extends NotificationBuilder {
|
|||
return null;
|
||||
}
|
||||
|
||||
String companySymbolsSql = "companyId = %d AND companySymbol = INN";
|
||||
CompanySymbols companySymbols = null;
|
||||
Collection<CompanySymbols> companySymbolsCollection = companySymbolsImdg.getCollectionObjectsBySQL(companySymbolsSql);
|
||||
if (companySymbolsCollection.size() >= 1) {
|
||||
ImdgPredicateBuilder pb = companySymbolsImdg.predicateBuilder();
|
||||
predicate = pb.and(
|
||||
pb.equals("companyId", consumerId),
|
||||
pb.equals("companySymbol", CompanySymbol.INN.getKey())
|
||||
);
|
||||
Collection<CompanySymbols> companySymbolsCollection = companySymbolsImdg.getCollectionObjectsByPredicate(predicate);
|
||||
if (!companySymbolsCollection.isEmpty()) {
|
||||
companySymbols = companySymbolsCollection.iterator().next();
|
||||
} else {
|
||||
log.warn("CompanySymbols with sql {} not found", companySymbolsSql);
|
||||
log.warn("CompanySymbols with sql {} not found", predicate.toString());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,12 @@
|
|||
package ru.spcex.clearing.reports.notifications;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -8,14 +15,12 @@ import ru.clearing.classes.statics.data.company.Company;
|
|||
import ru.clearing.classes.statics.data.company.CompanySymbols;
|
||||
import ru.clearing.classes.statics.data.profile.ProfileDocument;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.platform.enumeration.CompanySymbol;
|
||||
import ru.spcex.platform.enumeration.DocumentTypes;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.TextStyle;
|
||||
import java.util.*;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
|
||||
@Component
|
||||
public class ROOT_CLOS_NotificationBuilder extends NotificationBuilder {
|
||||
|
|
@ -33,10 +38,14 @@ public class ROOT_CLOS_NotificationBuilder extends NotificationBuilder {
|
|||
|
||||
@Override
|
||||
public File buildNotification(Long consumerId) {
|
||||
String sql = "companyId = %d AND documentType = 'CNTR'".formatted(consumerId);
|
||||
Collection<ProfileDocument> profileDocuments = profileDocumentImdg.getCollectionObjectsBySQL(sql);
|
||||
ImdgPredicateBuilder pb = profileDocumentImdg.predicateBuilder();
|
||||
ImdgPredicate predicate = pb.and(
|
||||
pb.equals("companyId", consumerId),
|
||||
pb.equals("documentType", DocumentTypes.cntr.toString())
|
||||
);
|
||||
Collection<ProfileDocument> profileDocuments = profileDocumentImdg.getCollectionObjectsByPredicate(predicate);
|
||||
ProfileDocument currentProfileDocument = null;
|
||||
if (profileDocuments.size() >= 1) {
|
||||
if (!profileDocuments.isEmpty()) {
|
||||
Optional<ProfileDocument> profileDocumentOptional = profileDocuments.stream().max((o1, o2) -> {
|
||||
LocalDate o1ValidFromDate = o1.getValidFromDate();
|
||||
LocalDate o2ValidFromDate = o2.getValidFromDate();
|
||||
|
|
@ -46,7 +55,7 @@ public class ROOT_CLOS_NotificationBuilder extends NotificationBuilder {
|
|||
});
|
||||
currentProfileDocument = profileDocumentOptional.get();
|
||||
} else {
|
||||
log.warn("Profile_document with sql {} not found", sql);
|
||||
log.warn("Profile_document with sql {} not found", predicate.toString());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -72,13 +81,17 @@ public class ROOT_CLOS_NotificationBuilder extends NotificationBuilder {
|
|||
return null;
|
||||
}
|
||||
|
||||
String companySymbolsSql = "companyId = %d AND companySymbol = INN";
|
||||
CompanySymbols companySymbols = null;
|
||||
Collection<CompanySymbols> companySymbolsCollection = companySymbolsImdg.getCollectionObjectsBySQL(companySymbolsSql);
|
||||
if (companySymbolsCollection.size() >= 1) {
|
||||
pb = companySymbolsImdg.predicateBuilder();
|
||||
predicate = pb.and(
|
||||
pb.equals("companyId", consumerId),
|
||||
pb.equals("companySymbol", CompanySymbol.INN.getKey())
|
||||
);
|
||||
Collection<CompanySymbols> companySymbolsCollection = companySymbolsImdg.getCollectionObjectsByPredicate(predicate);
|
||||
if (!companySymbolsCollection.isEmpty()) {
|
||||
companySymbols = companySymbolsCollection.iterator().next();
|
||||
} else {
|
||||
log.warn("CompanySymbols with sql {} not found", companySymbolsSql);
|
||||
log.warn("CompanySymbols with sql {} not found", predicate.toString());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,12 @@
|
|||
package ru.spcex.clearing.reports.notifications;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -8,14 +15,12 @@ import ru.clearing.classes.statics.data.company.Company;
|
|||
import ru.clearing.classes.statics.data.company.CompanySymbols;
|
||||
import ru.clearing.classes.statics.data.profile.ProfileDocument;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.platform.enumeration.CompanySymbol;
|
||||
import ru.spcex.platform.enumeration.DocumentTypes;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.TextStyle;
|
||||
import java.util.*;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
|
||||
@Component
|
||||
public class ROOT_NEW_NotificationBuilder extends NotificationBuilder {
|
||||
|
|
@ -33,8 +38,12 @@ public class ROOT_NEW_NotificationBuilder extends NotificationBuilder {
|
|||
|
||||
@Override
|
||||
public File buildNotification(Long consumerId) {
|
||||
String sql = "companyId = %d AND documentType = 'CNTR'".formatted(consumerId);
|
||||
Collection<ProfileDocument> profileDocuments = profileDocumentImdg.getCollectionObjectsBySQL(sql);
|
||||
ImdgPredicateBuilder pb = profileDocumentImdg.predicateBuilder();
|
||||
ImdgPredicate predicate = pb.and(
|
||||
pb.equals("companyId", consumerId),
|
||||
pb.equals("documentType", DocumentTypes.cntr.toString())
|
||||
);
|
||||
Collection<ProfileDocument> profileDocuments = profileDocumentImdg.getCollectionObjectsByPredicate(predicate);
|
||||
ProfileDocument currentProfileDocument = null;
|
||||
if (profileDocuments.size() >= 1) {
|
||||
Optional<ProfileDocument> profileDocumentOptional = profileDocuments.stream().max((o1, o2) -> {
|
||||
|
|
@ -46,7 +55,7 @@ public class ROOT_NEW_NotificationBuilder extends NotificationBuilder {
|
|||
});
|
||||
currentProfileDocument = profileDocumentOptional.get();
|
||||
} else {
|
||||
log.warn("Profile_document with sql {} not found", sql);
|
||||
log.warn("Profile_document with sql {} not found", predicate.toString());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -72,13 +81,17 @@ public class ROOT_NEW_NotificationBuilder extends NotificationBuilder {
|
|||
return null;
|
||||
}
|
||||
|
||||
String companySymbolsSql = "companyId = %d AND companySymbol = INN";
|
||||
CompanySymbols companySymbols = null;
|
||||
Collection<CompanySymbols> companySymbolsCollection = companySymbolsImdg.getCollectionObjectsBySQL(companySymbolsSql);
|
||||
if (companySymbolsCollection.size() >= 1) {
|
||||
pb = companySymbolsImdg.predicateBuilder();
|
||||
predicate = pb.and(
|
||||
pb.equals("companyId", consumerId),
|
||||
pb.equals("companySymbol", CompanySymbol.INN.getKey())
|
||||
);
|
||||
Collection<CompanySymbols> companySymbolsCollection = companySymbolsImdg.getCollectionObjectsByPredicate(predicate);
|
||||
if (!companySymbolsCollection.isEmpty()) {
|
||||
companySymbols = companySymbolsCollection.iterator().next();
|
||||
} else {
|
||||
log.warn("CompanySymbols with sql {} not found", companySymbolsSql);
|
||||
log.warn("CompanySymbols with sql {} not found", predicate.toString());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
package ru.spcex.clearing.reports.notifications;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -9,13 +17,11 @@ import ru.clearing.classes.statics.data.company.Company;
|
|||
import ru.clearing.classes.statics.data.company.CompanySymbols;
|
||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.platform.enumeration.CompanySymbol;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
|
||||
@Component
|
||||
public class ROOT_SSPD_NotificationBuilder extends NotificationBuilder {
|
||||
|
|
@ -44,14 +50,14 @@ public class ROOT_SSPD_NotificationBuilder extends NotificationBuilder {
|
|||
return null;
|
||||
}
|
||||
|
||||
String relationsSql = "consumerId = %d".formatted(consumerId);
|
||||
Relation relation = null;
|
||||
Collection<Relation> relations = relationImdg.getCollectionObjectsBySQL(relationsSql);
|
||||
if (relations.size() >= 1) {
|
||||
ImdgPredicate predicate = relationImdg.predicateBuilder().equals("consumerId", consumerId);
|
||||
Collection<Relation> relations = relationImdg.getCollectionObjectsByPredicate(predicate);
|
||||
if (!relations.isEmpty()) {
|
||||
Optional<Relation> relationOptional = relations.stream().max(Comparator.comparing(BusinessObject::getUpdated));
|
||||
relation = relationOptional.get();
|
||||
} else {
|
||||
log.warn("Relation with sql {} not found", relationsSql);
|
||||
log.warn("Relation with sql {} not found", predicate.toString());
|
||||
return null;
|
||||
}
|
||||
Long notificationId = relation.getId();
|
||||
|
|
@ -61,13 +67,17 @@ public class ROOT_SSPD_NotificationBuilder extends NotificationBuilder {
|
|||
return null;
|
||||
}
|
||||
|
||||
String companySymbolsSql = "companyId = %d AND companySymbol = INN";
|
||||
CompanySymbols companySymbols = null;
|
||||
Collection<CompanySymbols> companySymbolsCollection = companySymbolsImdg.getCollectionObjectsBySQL(companySymbolsSql);
|
||||
if (companySymbolsCollection.size() >= 1) {
|
||||
ImdgPredicateBuilder pb = companySymbolsImdg.predicateBuilder();
|
||||
predicate = pb.and(
|
||||
pb.equals("companyId", consumerId),
|
||||
pb.equals("companySymbol", CompanySymbol.INN.getKey())
|
||||
);
|
||||
Collection<CompanySymbols> companySymbolsCollection = companySymbolsImdg.getCollectionObjectsByPredicate(predicate);
|
||||
if (!companySymbolsCollection.isEmpty()) {
|
||||
companySymbols = companySymbolsCollection.iterator().next();
|
||||
} else {
|
||||
log.warn("CompanySymbols with sql {} not found", companySymbolsSql);
|
||||
log.warn("CompanySymbols with sql {} not found", predicate.toString());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
package ru.spcex.clearing.reports.notifications;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -9,13 +17,11 @@ import ru.clearing.classes.statics.data.company.Company;
|
|||
import ru.clearing.classes.statics.data.company.CompanySymbols;
|
||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.platform.enumeration.CompanySymbol;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
|
||||
@Component
|
||||
public class RRPCNotificationBuilder extends NotificationBuilder {
|
||||
|
|
@ -44,14 +50,14 @@ public class RRPCNotificationBuilder extends NotificationBuilder {
|
|||
return null;
|
||||
}
|
||||
|
||||
String relationsSql = "consumerId = %d".formatted(consumerId);
|
||||
Relation relation = null;
|
||||
Collection<Relation> relations = relationImdg.getCollectionObjectsBySQL(relationsSql);
|
||||
if (relations.size() >= 1) {
|
||||
ImdgPredicate predicate = relationImdg.predicateBuilder().equals("consumerId", consumerId);
|
||||
Collection<Relation> relations = relationImdg.getCollectionObjectsByPredicate(predicate);
|
||||
if (!relations.isEmpty()) {
|
||||
Optional<Relation> relationOptional = relations.stream().max(Comparator.comparing(BusinessObject::getUpdated));
|
||||
relation = relationOptional.get();
|
||||
} else {
|
||||
log.warn("Relation with sql {} not found", relationsSql);
|
||||
log.warn("Relation with sql {} not found", predicate.toString());
|
||||
return null;
|
||||
}
|
||||
Long notificationId = relation.getId();
|
||||
|
|
@ -61,13 +67,17 @@ public class RRPCNotificationBuilder extends NotificationBuilder {
|
|||
return null;
|
||||
}
|
||||
|
||||
String companySymbolsSql = "companyId = %d AND companySymbol = INN";
|
||||
CompanySymbols companySymbols = null;
|
||||
Collection<CompanySymbols> companySymbolsCollection = companySymbolsImdg.getCollectionObjectsBySQL(companySymbolsSql);
|
||||
ImdgPredicateBuilder pb = companySymbolsImdg.predicateBuilder();
|
||||
predicate = pb.and(
|
||||
pb.equals("companyId", consumerId),
|
||||
pb.equals("companySymbol", CompanySymbol.INN.getKey())
|
||||
);
|
||||
Collection<CompanySymbols> companySymbolsCollection = companySymbolsImdg.getCollectionObjectsByPredicate(predicate);
|
||||
if (companySymbolsCollection.size() >= 1) {
|
||||
companySymbols = companySymbolsCollection.iterator().next();
|
||||
} else {
|
||||
log.warn("CompanySymbols with sql {} not found", companySymbolsSql);
|
||||
log.warn("CompanySymbols with sql {} not found", predicate.toString());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
package ru.spcex.clearing.reports.services;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -35,11 +43,6 @@ import ru.spcex.platform.imdg.api.ImdgProvider;
|
|||
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class ReportService extends QueueConsumer implements InitializingBean {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
|
@ -146,147 +149,167 @@ public class ReportService extends QueueConsumer implements InitializingBean {
|
|||
public RequestInfoUpdate createReport(BaseRequest<ReportRequest> userRequest) {
|
||||
log.debug("ReportRequest received");
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, reportRequestValidator);
|
||||
if (requestInfoUpdate != null) return null;
|
||||
try {
|
||||
RequestInfoUpdate requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, reportRequestValidator);
|
||||
if (requestInfoUpdate != null) return null;
|
||||
|
||||
ReportRequest req = userRequest.getRequestPayload();
|
||||
ReportRequest req = userRequest.getRequestPayload();
|
||||
|
||||
logUnknownProperties(userRequest);
|
||||
logUnknownProperties(userRequest);
|
||||
|
||||
log.debug("Create report type {}...", req.getReportId());
|
||||
log.debug("Create report type {}...", req.getReportId());
|
||||
|
||||
List<CSVReportBuilder<EmptyParams, ?>> builders = reportBuildersWithoutParams.get(
|
||||
List<CSVReportBuilder<EmptyParams, ?>> builders = reportBuildersWithoutParams.get(
|
||||
IEnumKey.getEnumByKey(ReportBuilderType.class, req.getReportId())
|
||||
);
|
||||
List<String> outFilenames = new ArrayList<>();
|
||||
List<File> outFiles = new ArrayList<>();
|
||||
for (CSVReportBuilder<EmptyParams, ?> builder : builders) {
|
||||
File outFile = builder.createReport(new EmptyParams(), outFolder);
|
||||
if (outFile == null) continue;
|
||||
outFilenames.add(outFile.getAbsolutePath());
|
||||
outFiles.add(outFile);
|
||||
}
|
||||
);
|
||||
List<String> outFilenames = new ArrayList<>();
|
||||
List<File> outFiles = new ArrayList<>();
|
||||
for (CSVReportBuilder<EmptyParams, ?> builder : builders) {
|
||||
File outFile = builder.createReport(new EmptyParams(), outFolder);
|
||||
if (outFile == null) continue;
|
||||
outFilenames.add(outFile.getAbsolutePath());
|
||||
outFiles.add(outFile);
|
||||
}
|
||||
|
||||
int outFilesCnt = outFilenames.size();
|
||||
if (outFilesCnt == 0) {
|
||||
log.error("Create report {} failed, see log", req.getReportId());
|
||||
} else if (outFilesCnt < builders.size()) {
|
||||
log.error("Create some error for {} failed, see log", req.getReportId());
|
||||
} else {
|
||||
log.debug("Reports {} successfully created. Output files: {}", req.getReportId(), String.join(", ", outFilenames));
|
||||
}
|
||||
int outFilesCnt = outFilenames.size();
|
||||
if (outFilesCnt == 0) {
|
||||
log.error("Create report {} failed, see log", req.getReportId());
|
||||
} else if (outFilesCnt < builders.size()) {
|
||||
log.error("Create some error for {} failed, see log", req.getReportId());
|
||||
} else {
|
||||
log.debug("Reports {} successfully created. Output files: {}", req.getReportId(), String.join(", ", outFilenames));
|
||||
}
|
||||
|
||||
sendFilesToSftp(outFiles);
|
||||
sendFilesToSftp(outFiles);
|
||||
} catch (Exception e) {
|
||||
log.error("Unexpected exception", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestInfoUpdate createReportForSessionId(BaseRequest<ReportRequestWithSessionId> userRequest) {
|
||||
log.debug("ReportRequestWithSessionId received");
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, reportRequestWithSessionIdValidator);
|
||||
if (requestInfoUpdate != null) return null;
|
||||
try {
|
||||
RequestInfoUpdate requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, reportRequestWithSessionIdValidator);
|
||||
if (requestInfoUpdate != null) return null;
|
||||
|
||||
ReportRequestWithSessionId req = userRequest.getRequestPayload();
|
||||
ReportRequestWithSessionId req = userRequest.getRequestPayload();
|
||||
|
||||
logUnknownProperties(userRequest);
|
||||
logUnknownProperties(userRequest);
|
||||
|
||||
log.debug("Create report type {}...", req.getReportId());
|
||||
log.debug("Create report type {}...", req.getReportId());
|
||||
|
||||
List<CSVReportBuilder<SessionIdParam, ?>> builders = reportBuildersWithSessionIdParam.get(
|
||||
List<CSVReportBuilder<SessionIdParam, ?>> builders = reportBuildersWithSessionIdParam.get(
|
||||
IEnumKey.getEnumByKey(ReportBuilderType.class, req.getReportId())
|
||||
);
|
||||
List<String> outFilenames = new ArrayList<>();
|
||||
List<File> outFiles = new ArrayList<>();
|
||||
for (CSVReportBuilder<SessionIdParam, ?> builder : builders) {
|
||||
SessionIdParam sessionIdParam = new SessionIdParam();
|
||||
sessionIdParam.setSessionId(List.of(req.getSessionId()));
|
||||
File outFile = builder.createReport(sessionIdParam, outFolder);
|
||||
if (outFile == null) continue;
|
||||
outFilenames.add(outFile.getAbsolutePath());
|
||||
}
|
||||
);
|
||||
List<String> outFilenames = new ArrayList<>();
|
||||
List<File> outFiles = new ArrayList<>();
|
||||
for (CSVReportBuilder<SessionIdParam, ?> builder : builders) {
|
||||
SessionIdParam sessionIdParam = new SessionIdParam();
|
||||
sessionIdParam.setSessionId(List.of(req.getSessionId()));
|
||||
File outFile = builder.createReport(sessionIdParam, outFolder);
|
||||
if (outFile == null) continue;
|
||||
outFilenames.add(outFile.getAbsolutePath());
|
||||
}
|
||||
|
||||
int outFilesCnt = outFilenames.size();
|
||||
if (outFilesCnt == 0) {
|
||||
log.error("Create report {} failed, see log", req.getReportId());
|
||||
} else if (outFilesCnt < builders.size()) {
|
||||
log.error("Create some error for {} failed, see log", req.getReportId());
|
||||
} else {
|
||||
log.debug("Reports {} successfully created. Output files: {}", req.getReportId(), String.join(", ", outFilenames));
|
||||
}
|
||||
int outFilesCnt = outFilenames.size();
|
||||
if (outFilesCnt == 0) {
|
||||
log.error("Create report {} failed, see log", req.getReportId());
|
||||
} else if (outFilesCnt < builders.size()) {
|
||||
log.error("Create some error for {} failed, see log", req.getReportId());
|
||||
} else {
|
||||
log.debug("Reports {} successfully created. Output files: {}", req.getReportId(), String.join(", ", outFilenames));
|
||||
}
|
||||
|
||||
sendFilesToSftp(outFiles);
|
||||
sendFilesToSftp(outFiles);
|
||||
} catch (Exception e) {
|
||||
log.error("Unexpected exception", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestInfoUpdate createReportForGREP(BaseRequest<LauncherCommandRequest> userRequest) {
|
||||
log.debug("GREP task received");
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, reportRequestGREPValidator);
|
||||
if (requestInfoUpdate != null) return null;
|
||||
logUnknownProperties(userRequest);
|
||||
try {
|
||||
RequestInfoUpdate requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, reportRequestGREPValidator);
|
||||
if (requestInfoUpdate != null) return null;
|
||||
logUnknownProperties(userRequest);
|
||||
|
||||
List<Long> sessionIds = null;
|
||||
if (userRequest.getRequestPayload().getSessionId() != null) {
|
||||
sessionIds = List.of(userRequest.getRequestPayload().getSessionId());
|
||||
List<Long> sessionIds = null;
|
||||
if (userRequest.getRequestPayload().getSessionId() != null) {
|
||||
sessionIds = List.of(userRequest.getRequestPayload().getSessionId());
|
||||
}
|
||||
Map<File, ReportInfo> outFiles = createReportsForTask(sessionIds, reportBuildersForGREP.values());
|
||||
|
||||
sendReportsToGateway(sessionIds, outFiles, ReportType.REPORT_KS_TMP.getKey());
|
||||
sendFilesToSftp(outFiles.keySet());
|
||||
} catch (Exception e) {
|
||||
log.error("Unexpected exception", e);
|
||||
}
|
||||
Map<File, ReportInfo> outFiles = createReportsForTask(sessionIds, reportBuildersForGREP.values());
|
||||
|
||||
sendReportsToGateway(sessionIds, outFiles, ReportType.REPORT_KS_TMP.getKey());
|
||||
sendFilesToSftp(outFiles.keySet());
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestInfoUpdate createReportForGRET(BaseRequest<LauncherCommandRequest> userRequest) {
|
||||
log.debug("GRET task received");
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, reportRequestGRETValidator);
|
||||
if (requestInfoUpdate != null) return null;
|
||||
logUnknownProperties(userRequest);
|
||||
try {
|
||||
RequestInfoUpdate requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, reportRequestGRETValidator);
|
||||
if (requestInfoUpdate != null) return null;
|
||||
logUnknownProperties(userRequest);
|
||||
|
||||
List<Long> sessionIds = null;
|
||||
if (userRequest.getRequestPayload().getSessionId() != null) {
|
||||
sessionIds = List.of(userRequest.getRequestPayload().getSessionId());
|
||||
}
|
||||
Map<File, ReportInfo> outFiles = createReportsForTask(sessionIds, reportBuildersForGRET.values());
|
||||
|
||||
Map<File, ReportInfo> outFilesWithReportType_PFX64 = new HashMap<>();
|
||||
Map<File, ReportInfo> outFilesWithReportType_PFX65 = new HashMap<>();
|
||||
for (Map.Entry<File, ReportInfo> entry : outFiles.entrySet()) {
|
||||
File reportFile = entry.getKey();
|
||||
ReportInfo reportInfo = entry.getValue();
|
||||
ReportKeys reportKey = IEnumKey.getEnumByKey(ReportKeys.class, reportInfo.reportKey());
|
||||
if (reportKey == ReportKeys.KS_BR_PFX65_DEALS) {
|
||||
outFilesWithReportType_PFX65.put(reportFile, reportInfo);
|
||||
} else if (
|
||||
reportKey == ReportKeys.KS_BR_PFX64_INFTYPE_1 ||
|
||||
reportKey == ReportKeys.KS_BR_PFX64_INFTYPE_2 ||
|
||||
reportKey == ReportKeys.KS_BR_PFX64_INFTYPE_3 ||
|
||||
reportKey == ReportKeys.KS_BR_PFX64_INFTYPE_4
|
||||
) {
|
||||
outFilesWithReportType_PFX64.put(reportFile, reportInfo);
|
||||
List<Long> sessionIds = null;
|
||||
if (userRequest.getRequestPayload().getSessionId() != null) {
|
||||
sessionIds = List.of(userRequest.getRequestPayload().getSessionId());
|
||||
}
|
||||
Map<File, ReportInfo> outFiles = createReportsForTask(sessionIds, reportBuildersForGRET.values());
|
||||
|
||||
Map<File, ReportInfo> outFilesWithReportType_PFX64 = new HashMap<>();
|
||||
Map<File, ReportInfo> outFilesWithReportType_PFX65 = new HashMap<>();
|
||||
for (Map.Entry<File, ReportInfo> entry : outFiles.entrySet()) {
|
||||
File reportFile = entry.getKey();
|
||||
ReportInfo reportInfo = entry.getValue();
|
||||
ReportKeys reportKey = IEnumKey.getEnumByKey(ReportKeys.class, reportInfo.reportKey());
|
||||
if (reportKey == ReportKeys.KS_BR_PFX65_DEALS) {
|
||||
outFilesWithReportType_PFX65.put(reportFile, reportInfo);
|
||||
} else if (
|
||||
reportKey == ReportKeys.KS_BR_PFX64_INFTYPE_1 ||
|
||||
reportKey == ReportKeys.KS_BR_PFX64_INFTYPE_2 ||
|
||||
reportKey == ReportKeys.KS_BR_PFX64_INFTYPE_3 ||
|
||||
reportKey == ReportKeys.KS_BR_PFX64_INFTYPE_4
|
||||
) {
|
||||
outFilesWithReportType_PFX64.put(reportFile, reportInfo);
|
||||
}
|
||||
}
|
||||
sendReportsToGateway(sessionIds, outFilesWithReportType_PFX64, ReportType.PFX64.getKey());
|
||||
sendReportsToGateway(sessionIds, outFilesWithReportType_PFX65, ReportType.PFX65.getKey());
|
||||
sendFilesToSftp(outFiles.keySet());
|
||||
} catch (Exception e) {
|
||||
log.error("Unexpected exception", e);
|
||||
}
|
||||
sendReportsToGateway(sessionIds, outFilesWithReportType_PFX64, ReportType.PFX64.getKey());
|
||||
sendReportsToGateway(sessionIds, outFilesWithReportType_PFX65, ReportType.PFX65.getKey());
|
||||
sendFilesToSftp(outFiles.keySet());
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestInfoUpdate createReportForGREF(BaseRequest<LauncherCommandRequest> userRequest) {
|
||||
log.debug("GREF task received");
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, reportRequestGREFValidator);
|
||||
if (requestInfoUpdate != null) return null;
|
||||
logUnknownProperties(userRequest);
|
||||
try {
|
||||
RequestInfoUpdate requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, reportRequestGREFValidator);
|
||||
if (requestInfoUpdate != null) return null;
|
||||
logUnknownProperties(userRequest);
|
||||
|
||||
List<Long> sessionIds = null;
|
||||
if (userRequest.getRequestPayload().getSessionId() != null) {
|
||||
sessionIds = List.of(userRequest.getRequestPayload().getSessionId());
|
||||
List<Long> sessionIds = null;
|
||||
if (userRequest.getRequestPayload().getSessionId() != null) {
|
||||
sessionIds = List.of(userRequest.getRequestPayload().getSessionId());
|
||||
}
|
||||
Map<File, ReportInfo> outFiles = createReportsForTask(sessionIds, reportBuildersForGREF.values());
|
||||
|
||||
sendReportsToGateway(sessionIds, outFiles, ReportType.REPORT_KS_FINAL.getKey());
|
||||
sendFilesToSftp(outFiles.keySet());
|
||||
} catch (Exception e) {
|
||||
log.error("Unexpected exception", e);
|
||||
}
|
||||
Map<File, ReportInfo> outFiles = createReportsForTask(sessionIds, reportBuildersForGREF.values());
|
||||
|
||||
sendReportsToGateway(sessionIds, outFiles, ReportType.REPORT_KS_FINAL.getKey());
|
||||
sendFilesToSftp(outFiles.keySet());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,3 +34,11 @@ reports-service.notifications-store.server-port=2222
|
|||
reports-service.notifications-store.delete-after-send=true
|
||||
|
||||
reports-service.reports.pfx-class-codes=BKVC,SKVC,UKVC,NKVC,DKVC,BMVC,SMVC,UMVC,DMVC,MMVC,BMFC,SMFC,UMFC,DMFC,MMFC,BMMC,SMMC,UMMC,DMMC,MMMC,BMIC,SMIC,UMIC,DMIC,MMIC
|
||||
|
||||
reports-service.direct-db.enable=true
|
||||
reports-service.direct-db.login=clearing
|
||||
reports-service.direct-db.password=Aa111111
|
||||
reports-service.direct-db.url=jdbc:postgresql://10.200.200.133:5432/clearing?currentSchema=clearing_prod
|
||||
reports-service.direct-db.driver=org.postgresql.Driver
|
||||
reports-service.direct-db.min-pool-size=10
|
||||
reports-service.direct-db.max-pool-size=30
|
||||
|
|
@ -1,7 +1,12 @@
|
|||
package ru.spcex.clearing.reports.notifications;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.mockito.Mockito.*;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.company.CompanySymbols;
|
||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||
|
|
@ -9,15 +14,7 @@ import ru.clearing.classes.statics.data.profile.ProfileDocument;
|
|||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.adapter.predicate.ImdgPredicateBuilderHazelcast;
|
||||
|
||||
class NotificationBuilderTest {
|
||||
static ImdgProvider imdgProviderMock;
|
||||
|
|
@ -59,7 +56,8 @@ class NotificationBuilderTest {
|
|||
testProfileDocument_2.setValidFromDate(LocalDate.of(2019, 1, 1));
|
||||
testProfileDocument_2.setNumber("TEST_NUMBER_2");
|
||||
profileDocumentImdgMock = mock(Imdg.class);
|
||||
when(profileDocumentImdgMock.getCollectionObjectsBySQL(any())).thenReturn(Arrays.asList(testProfileDocument_1, testProfileDocument_2));
|
||||
when(profileDocumentImdgMock.getCollectionObjectsByPredicate(any())).thenReturn(Arrays.asList(testProfileDocument_1, testProfileDocument_2));
|
||||
when(profileDocumentImdgMock.predicateBuilder()).thenReturn(new ImdgPredicateBuilderHazelcast());
|
||||
when(imdgProviderMock.getImdg(eq(IMDGDistributedNames.Map_ProfileDocument), eq(ProfileDocument.class))).thenReturn(profileDocumentImdgMock);
|
||||
|
||||
testRelation_1 = new Relation();
|
||||
|
|
@ -71,7 +69,8 @@ class NotificationBuilderTest {
|
|||
testRelation_2.setConsumerId(777L);
|
||||
testRelation_2.setUpdated(LocalDate.of(2019, 1, 1).atStartOfDay(ZoneId.systemDefault()).toInstant());
|
||||
relationImdgMock = mock(Imdg.class);
|
||||
when(relationImdgMock.getCollectionObjectsBySQL(any())).thenReturn(Arrays.asList(testRelation_1, testRelation_2));
|
||||
when(relationImdgMock.getCollectionObjectsByPredicate(any())).thenReturn(Arrays.asList(testRelation_1, testRelation_2));
|
||||
when(relationImdgMock.predicateBuilder()).thenReturn(new ImdgPredicateBuilderHazelcast());
|
||||
when(imdgProviderMock.getImdg(eq(IMDGDistributedNames.Map_Relation), eq(Relation.class))).thenReturn(relationImdgMock);
|
||||
|
||||
testCompanySymbols_1 = new CompanySymbols();
|
||||
|
|
@ -85,7 +84,8 @@ class NotificationBuilderTest {
|
|||
testCompanySymbols_2.setCompanySymbol("TEST_COMPANY_SYMBOL_2");
|
||||
testCompanySymbols_2.setCompanySymbolValue("TEST_COMPANY_SYMBOL_VALUE_2");
|
||||
companySymbolsImdgMock = mock(Imdg.class);
|
||||
when(companySymbolsImdgMock.getCollectionObjectsBySQL(any())).thenReturn(Arrays.asList(testCompanySymbols_1, testCompanySymbols_2));
|
||||
when(companySymbolsImdgMock.getCollectionObjectsByPredicate(any())).thenReturn(Arrays.asList(testCompanySymbols_1, testCompanySymbols_2));
|
||||
when(companySymbolsImdgMock.predicateBuilder()).thenReturn(new ImdgPredicateBuilderHazelcast());
|
||||
when(imdgProviderMock.getImdg(eq(IMDGDistributedNames.Map_CompanySymbols), eq(CompanySymbols.class))).thenReturn(companySymbolsImdgMock);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,34 @@
|
|||
package ru.spcex.clearing.reports.services;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.opencsv.CSVParser;
|
||||
import com.opencsv.CSVParserBuilder;
|
||||
import com.opencsv.CSVReader;
|
||||
import com.opencsv.CSVReaderBuilder;
|
||||
import com.opencsv.exceptions.CsvValidationException;
|
||||
import javax.annotation.PostConstruct;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.kafka.clients.consumer.MockConsumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
|
|
@ -36,22 +56,18 @@ import ru.spcex.clearing.reports.config.validation.ValidationConfig;
|
|||
import ru.spcex.clearing.test.TestUtils;
|
||||
import ru.spcex.clearing.test.config.ImdgTestConfig;
|
||||
import ru.spcex.clearing.test.config.KafkaTestConfig;
|
||||
import ru.spcex.platform.enumeration.*;
|
||||
import ru.spcex.platform.enumeration.Allowed;
|
||||
import ru.spcex.platform.enumeration.InOutDirection;
|
||||
import ru.spcex.platform.enumeration.Market;
|
||||
import ru.spcex.platform.enumeration.RegistryDesignation;
|
||||
import ru.spcex.platform.enumeration.RegistryInstrumentType;
|
||||
import ru.spcex.platform.enumeration.RegistryUnit;
|
||||
import ru.spcex.platform.enumeration.ReportBuilderType;
|
||||
import ru.spcex.platform.enumeration.Side;
|
||||
import ru.spcex.platform.enumeration.WorkflowStatus;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {
|
||||
BeanConfiguration.class,
|
||||
|
|
@ -600,9 +616,9 @@ public class ReportServiceTest_BP {
|
|||
testRegistry_1.setTradingClearingRegistry(TEST_TRADING_CLEARING_REGISTRY_1);
|
||||
Long TEST_MONEY_ACCOUNT_1 = 11L;
|
||||
testRegistry_1.setAccountId(TEST_MONEY_ACCOUNT_1);
|
||||
String TEST_REGISTRY_CODE_1 = "CM";
|
||||
String TEST_REGISTRY_CODE_1 = "OM";
|
||||
testRegistry_1.setRegistryCode(TEST_REGISTRY_CODE_1);
|
||||
testRegistry_1.setRegistryDesignation(RegistryDesignation.C.getKey());
|
||||
testRegistry_1.setRegistryDesignation(RegistryDesignation.O.getKey());
|
||||
testRegistry_1.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
||||
testRegistry_1.setOpenBalance(TEST_OPEN_BALANCE_1);
|
||||
testRegistry_1.setCloseBalance(TEST_CLOSE_BALANCE_1);
|
||||
|
|
@ -620,9 +636,9 @@ public class ReportServiceTest_BP {
|
|||
testRegistry_2.setTradingClearingRegistry(TEST_TRADING_CLEARING_REGISTRY_2);
|
||||
Long TEST_MONEY_ACCOUNT_2 = 12L;
|
||||
testRegistry_2.setAccountId(TEST_MONEY_ACCOUNT_2);
|
||||
String TEST_REGISTRY_CODE_2 = "CM";
|
||||
String TEST_REGISTRY_CODE_2 = "OM";
|
||||
testRegistry_2.setRegistryCode(TEST_REGISTRY_CODE_2);
|
||||
testRegistry_2.setRegistryDesignation(RegistryDesignation.C.getKey());
|
||||
testRegistry_2.setRegistryDesignation(RegistryDesignation.O.getKey());
|
||||
testRegistry_2.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
||||
testRegistry_2.setOpenBalance(TEST_OPEN_BALANCE_2);
|
||||
testRegistry_2.setCloseBalance(TEST_CLOSE_BALANCE_2);
|
||||
|
|
|
|||
|
|
@ -212,97 +212,97 @@ public class ReportServiceTest_KS {
|
|||
sessionForDay.setClearingDate(LocalDate.now());
|
||||
Long SESSION_ID_FOR_DAY = sessionImdg.insert(sessionForDay);
|
||||
|
||||
Registry cmtRegistry_1 = new Registry();
|
||||
cmtRegistry_1.setRegistryCode("CM_T");
|
||||
cmtRegistry_1.setRegistryDesignation(RegistryDesignation.C.getKey());
|
||||
cmtRegistry_1.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
||||
cmtRegistry_1.setRegistryUnit(RegistryUnit.T.getKey());
|
||||
cmtRegistry_1.setSessionId(SESSION_ID_FOR_DAY);
|
||||
cmtRegistry_1.setTradingCode("TRADING_CODE");
|
||||
cmtRegistry_1.setCompanyId(COMPANY_ID);
|
||||
cmtRegistry_1.setAccount("ACCOUNT");
|
||||
cmtRegistry_1.setRegistryStatus(RegistryStatus.CLRD.getKey());
|
||||
cmtRegistry_1.setBalance(BigDecimal.valueOf(111L));
|
||||
cmtRegistry_1.setContract("CONTRACT_1");
|
||||
registryImdg.insert(cmtRegistry_1);
|
||||
Registry omtRegistry_1 = new Registry();
|
||||
omtRegistry_1.setRegistryCode("OM_T");
|
||||
omtRegistry_1.setRegistryDesignation(RegistryDesignation.O.getKey());
|
||||
omtRegistry_1.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
||||
omtRegistry_1.setRegistryUnit(RegistryUnit.T.getKey());
|
||||
omtRegistry_1.setSessionId(SESSION_ID_FOR_DAY);
|
||||
omtRegistry_1.setTradingCode("TRADING_CODE");
|
||||
omtRegistry_1.setCompanyId(COMPANY_ID);
|
||||
omtRegistry_1.setAccount("ACCOUNT");
|
||||
omtRegistry_1.setRegistryStatus(RegistryStatus.CLRD.getKey());
|
||||
omtRegistry_1.setBalance(BigDecimal.valueOf(111L));
|
||||
omtRegistry_1.setContract("CONTRACT_1");
|
||||
registryImdg.insert(omtRegistry_1);
|
||||
|
||||
Registry cmtRegistry_2 = new Registry();
|
||||
cmtRegistry_2.setRegistryCode("CM_T");
|
||||
cmtRegistry_2.setRegistryDesignation(RegistryDesignation.C.getKey());
|
||||
cmtRegistry_2.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
||||
cmtRegistry_2.setRegistryUnit(RegistryUnit.T.getKey());
|
||||
Registry omtRegistry_2 = new Registry();
|
||||
omtRegistry_2.setRegistryCode("OM_T");
|
||||
omtRegistry_2.setRegistryDesignation(RegistryDesignation.O.getKey());
|
||||
omtRegistry_2.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
||||
omtRegistry_2.setRegistryUnit(RegistryUnit.T.getKey());
|
||||
|
||||
ClearingMemberCategory clearingMemberCategory = new ClearingMemberCategory();
|
||||
clearingMemberCategory.setCompanyId(COMPANY_ID);
|
||||
clearingMemberCategory.setClearingMemberCategory(ClearingCategory.I.getKey());
|
||||
clearingMemberCategoryImdg.insert(clearingMemberCategory);
|
||||
cmtRegistry_2.setSessionType(SessionType.XDEP.getKey());
|
||||
cmtRegistry_2.setCounterPartyId(COMPANY_ID);
|
||||
omtRegistry_2.setSessionType(SessionType.XDEP.getKey());
|
||||
omtRegistry_2.setCounterPartyId(COMPANY_ID);
|
||||
|
||||
cmtRegistry_2.setSessionId(SESSION_ID_FOR_DAY);
|
||||
cmtRegistry_2.setTradingCode("TRADING_CODE");
|
||||
cmtRegistry_2.setCompanyId(COMPANY_ID);
|
||||
cmtRegistry_2.setAccount("ACCOUNT");
|
||||
cmtRegistry_2.setRegistryStatus(RegistryStatus.CLRD.getKey());
|
||||
cmtRegistry_2.setBalance(BigDecimal.valueOf(111L));
|
||||
cmtRegistry_2.setContract("CONTRACT_2");
|
||||
registryImdg.insert(cmtRegistry_2);
|
||||
omtRegistry_2.setSessionId(SESSION_ID_FOR_DAY);
|
||||
omtRegistry_2.setTradingCode("TRADING_CODE");
|
||||
omtRegistry_2.setCompanyId(COMPANY_ID);
|
||||
omtRegistry_2.setAccount("ACCOUNT");
|
||||
omtRegistry_2.setRegistryStatus(RegistryStatus.CLRD.getKey());
|
||||
omtRegistry_2.setBalance(BigDecimal.valueOf(111L));
|
||||
omtRegistry_2.setContract("CONTRACT_2");
|
||||
registryImdg.insert(omtRegistry_2);
|
||||
|
||||
Registry cmtRegistry_3 = new Registry();
|
||||
cmtRegistry_3.setRegistryCode("CM_T");
|
||||
cmtRegistry_3.setRegistryDesignation(RegistryDesignation.C.getKey());
|
||||
cmtRegistry_3.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
||||
cmtRegistry_3.setRegistryUnit(RegistryUnit.T.getKey());
|
||||
cmtRegistry_3.setSessionId(SESSION_ID_FOR_DAY);
|
||||
cmtRegistry_3.setTradingCode("TRADING_CODE");
|
||||
cmtRegistry_3.setCompanyId(COMPANY_ID);
|
||||
cmtRegistry_3.setAccount("ACCOUNT");
|
||||
cmtRegistry_3.setRegistryStatus(RegistryStatus.CLRD.getKey());
|
||||
cmtRegistry_3.setBalance(BigDecimal.valueOf(111L));
|
||||
registryImdg.insert(cmtRegistry_3);
|
||||
Registry omtRegistry_3 = new Registry();
|
||||
omtRegistry_3.setRegistryCode("OM_T");
|
||||
omtRegistry_3.setRegistryDesignation(RegistryDesignation.O.getKey());
|
||||
omtRegistry_3.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
||||
omtRegistry_3.setRegistryUnit(RegistryUnit.T.getKey());
|
||||
omtRegistry_3.setSessionId(SESSION_ID_FOR_DAY);
|
||||
omtRegistry_3.setTradingCode("TRADING_CODE");
|
||||
omtRegistry_3.setCompanyId(COMPANY_ID);
|
||||
omtRegistry_3.setAccount("ACCOUNT");
|
||||
omtRegistry_3.setRegistryStatus(RegistryStatus.CLRD.getKey());
|
||||
omtRegistry_3.setBalance(BigDecimal.valueOf(111L));
|
||||
registryImdg.insert(omtRegistry_3);
|
||||
|
||||
Registry lmtRegistry_1 = new Registry();
|
||||
lmtRegistry_1.setRegistryCode("LM_T");
|
||||
lmtRegistry_1.setRegistryDesignation(RegistryDesignation.L.getKey());
|
||||
lmtRegistry_1.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
||||
lmtRegistry_1.setRegistryUnit(RegistryUnit.T.getKey());
|
||||
lmtRegistry_1.setSessionId(SESSION_ID_FOR_DAY);
|
||||
lmtRegistry_1.setTradingCode("TRADING_CODE");
|
||||
lmtRegistry_1.setCompanyId(COMPANY_ID);
|
||||
lmtRegistry_1.setAccount("ACCOUNT");
|
||||
lmtRegistry_1.setRegistryStatus(RegistryStatus.CLRD.getKey());
|
||||
lmtRegistry_1.setBalance(BigDecimal.valueOf(11L));
|
||||
registryImdg.insert(lmtRegistry_1);
|
||||
Registry tmtRegistry_1 = new Registry();
|
||||
tmtRegistry_1.setRegistryCode("TM_T");
|
||||
tmtRegistry_1.setRegistryDesignation(RegistryDesignation.T.getKey());
|
||||
tmtRegistry_1.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
||||
tmtRegistry_1.setRegistryUnit(RegistryUnit.T.getKey());
|
||||
tmtRegistry_1.setSessionId(SESSION_ID_FOR_DAY);
|
||||
tmtRegistry_1.setTradingCode("TRADING_CODE");
|
||||
tmtRegistry_1.setCompanyId(COMPANY_ID);
|
||||
tmtRegistry_1.setAccount("ACCOUNT");
|
||||
tmtRegistry_1.setRegistryStatus(RegistryStatus.CLRD.getKey());
|
||||
tmtRegistry_1.setBalance(BigDecimal.valueOf(11L));
|
||||
registryImdg.insert(tmtRegistry_1);
|
||||
|
||||
Registry lmtRegistry_2 = new Registry();
|
||||
lmtRegistry_2.setRegistryCode("LM_T");
|
||||
lmtRegistry_2.setRegistryDesignation(RegistryDesignation.L.getKey());
|
||||
lmtRegistry_2.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
||||
lmtRegistry_2.setRegistryUnit(RegistryUnit.T.getKey());
|
||||
Registry tmtRegistry_2 = new Registry();
|
||||
tmtRegistry_2.setRegistryCode("TM_T");
|
||||
tmtRegistry_2.setRegistryDesignation(RegistryDesignation.T.getKey());
|
||||
tmtRegistry_2.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
||||
tmtRegistry_2.setRegistryUnit(RegistryUnit.T.getKey());
|
||||
|
||||
lmtRegistry_2.setSessionType(SessionType.XDEP.getKey());
|
||||
lmtRegistry_2.setCounterPartyId(COMPANY_ID);
|
||||
tmtRegistry_2.setSessionType(SessionType.XDEP.getKey());
|
||||
tmtRegistry_2.setCounterPartyId(COMPANY_ID);
|
||||
|
||||
lmtRegistry_2.setSessionId(SESSION_ID_FOR_DAY);
|
||||
lmtRegistry_2.setTradingCode("TRADING_CODE");
|
||||
lmtRegistry_2.setCompanyId(COMPANY_ID);
|
||||
lmtRegistry_2.setAccount("ACCOUNT");
|
||||
lmtRegistry_2.setRegistryStatus(RegistryStatus.CLRD.getKey());
|
||||
lmtRegistry_2.setBalance(BigDecimal.valueOf(11L));
|
||||
registryImdg.insert(lmtRegistry_2);
|
||||
tmtRegistry_2.setSessionId(SESSION_ID_FOR_DAY);
|
||||
tmtRegistry_2.setTradingCode("TRADING_CODE");
|
||||
tmtRegistry_2.setCompanyId(COMPANY_ID);
|
||||
tmtRegistry_2.setAccount("ACCOUNT");
|
||||
tmtRegistry_2.setRegistryStatus(RegistryStatus.CLRD.getKey());
|
||||
tmtRegistry_2.setBalance(BigDecimal.valueOf(11L));
|
||||
registryImdg.insert(tmtRegistry_2);
|
||||
|
||||
Registry lmtRegistry_3 = new Registry();
|
||||
lmtRegistry_3.setRegistryCode("LM_T");
|
||||
lmtRegistry_3.setRegistryDesignation(RegistryDesignation.L.getKey());
|
||||
lmtRegistry_3.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
||||
lmtRegistry_3.setRegistryUnit(RegistryUnit.T.getKey());
|
||||
lmtRegistry_3.setSessionId(SESSION_ID_FOR_DAY);
|
||||
lmtRegistry_3.setTradingCode("TRADING_CODE");
|
||||
lmtRegistry_3.setCompanyId(COMPANY_ID);
|
||||
lmtRegistry_3.setAccount("ACCOUNT");
|
||||
lmtRegistry_3.setRegistryStatus(RegistryStatus.CLRD.getKey());
|
||||
lmtRegistry_3.setBalance(BigDecimal.valueOf(11L));
|
||||
registryImdg.insert(lmtRegistry_3);
|
||||
Registry tmtRegistry_3 = new Registry();
|
||||
tmtRegistry_3.setRegistryCode("TM_T");
|
||||
tmtRegistry_3.setRegistryDesignation(RegistryDesignation.T.getKey());
|
||||
tmtRegistry_3.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
||||
tmtRegistry_3.setRegistryUnit(RegistryUnit.T.getKey());
|
||||
tmtRegistry_3.setSessionId(SESSION_ID_FOR_DAY);
|
||||
tmtRegistry_3.setTradingCode("TRADING_CODE");
|
||||
tmtRegistry_3.setCompanyId(COMPANY_ID);
|
||||
tmtRegistry_3.setAccount("ACCOUNT");
|
||||
tmtRegistry_3.setRegistryStatus(RegistryStatus.CLRD.getKey());
|
||||
tmtRegistry_3.setBalance(BigDecimal.valueOf(11L));
|
||||
registryImdg.insert(tmtRegistry_3);
|
||||
|
||||
Registry dmxRegistry_1 = new Registry();
|
||||
dmxRegistry_1.setRegistryCode("DM_X");
|
||||
|
|
@ -392,12 +392,12 @@ public class ReportServiceTest_KS {
|
|||
registryImdg.delete(addWithdrawRegistry_1);
|
||||
registryImdg.delete(addWithdrawRegistry_2);
|
||||
registryImdg.delete(addWithdrawRegistry_3);
|
||||
registryImdg.delete(cmtRegistry_1);
|
||||
registryImdg.delete(cmtRegistry_2);
|
||||
registryImdg.delete(cmtRegistry_3);
|
||||
registryImdg.delete(lmtRegistry_1);
|
||||
registryImdg.delete(lmtRegistry_2);
|
||||
registryImdg.delete(lmtRegistry_3);
|
||||
registryImdg.delete(omtRegistry_1);
|
||||
registryImdg.delete(omtRegistry_2);
|
||||
registryImdg.delete(omtRegistry_3);
|
||||
registryImdg.delete(tmtRegistry_1);
|
||||
registryImdg.delete(tmtRegistry_2);
|
||||
registryImdg.delete(tmtRegistry_3);
|
||||
registryImdg.delete(dmxRegistry_1);
|
||||
registryImdg.delete(dmxRegistry_2);
|
||||
sessionImdg.delete(sessionForDay);
|
||||
|
|
@ -821,11 +821,11 @@ public class ReportServiceTest_KS {
|
|||
registry_1.setSettlementDate(LocalDate.now());
|
||||
registry_1.setGroupId(Long.MAX_VALUE);
|
||||
registry_1.setClearingDate(LocalDate.now());
|
||||
registry_1.setRegistryCode("LM_T");
|
||||
registry_1.setRegistryCode("TM_T");
|
||||
registry_1.setTradingClearingRegistry("TKR");
|
||||
registry_1.setSessionType(SessionType.IPO0.getKey());
|
||||
registry_1.setRegistryStatus(RegistryStatus.PROC.getKey());
|
||||
registry_1.setRegistryDesignation(RegistryDesignation.L.getKey());
|
||||
registry_1.setRegistryStatus(RegistryStatus.OK.getKey());
|
||||
registry_1.setRegistryDesignation(RegistryDesignation.T.getKey());
|
||||
registry_1.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
||||
registry_1.setRegistryUnit(RegistryUnit.T.getKey());
|
||||
registry_1.setSessionId(sessionId);
|
||||
|
|
@ -840,10 +840,10 @@ public class ReportServiceTest_KS {
|
|||
registry_2.setGroupId(Long.MAX_VALUE);
|
||||
registry_2.setClearingDate(LocalDate.now());
|
||||
registry_2.setSessionType(SessionType.IPO0.getKey());
|
||||
registry_2.setRegistryCode("CM_T");
|
||||
registry_2.setRegistryCode("OM_T");
|
||||
registry_2.setTradingClearingRegistry("TKR");
|
||||
registry_2.setRegistryStatus(RegistryStatus.PROC.getKey());
|
||||
registry_2.setRegistryDesignation(RegistryDesignation.C.getKey());
|
||||
registry_2.setRegistryStatus(RegistryStatus.OK.getKey());
|
||||
registry_2.setRegistryDesignation(RegistryDesignation.O.getKey());
|
||||
registry_2.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
||||
registry_2.setRegistryUnit(RegistryUnit.T.getKey());
|
||||
registry_2.setSessionId(sessionId);
|
||||
|
|
@ -863,11 +863,11 @@ public class ReportServiceTest_KS {
|
|||
registry_3.setSettlementDate(LocalDate.now());
|
||||
registry_3.setGroupId(Long.MAX_VALUE);
|
||||
registry_3.setClearingDate(LocalDate.now());
|
||||
registry_3.setRegistryCode("LM_T");
|
||||
registry_3.setRegistryCode("TM_T");
|
||||
registry_3.setSessionType(SessionType.FINL.getKey());
|
||||
registry_3.setTradingClearingRegistry("TKR");
|
||||
registry_3.setRegistryStatus(RegistryStatus.PROC.getKey());
|
||||
registry_3.setRegistryDesignation(RegistryDesignation.L.getKey());
|
||||
registry_3.setRegistryStatus(RegistryStatus.OK.getKey());
|
||||
registry_3.setRegistryDesignation(RegistryDesignation.T.getKey());
|
||||
registry_3.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
||||
registry_3.setRegistryUnit(RegistryUnit.T.getKey());
|
||||
registry_3.setSessionId(sessionId);
|
||||
|
|
@ -882,10 +882,10 @@ public class ReportServiceTest_KS {
|
|||
registry_4.setGroupId(Long.MAX_VALUE);
|
||||
registry_4.setSessionType(SessionType.FINL.getKey());
|
||||
registry_4.setClearingDate(LocalDate.now());
|
||||
registry_4.setRegistryCode("CM_T");
|
||||
registry_4.setRegistryCode("OM_T");
|
||||
registry_4.setTradingClearingRegistry("TKR");
|
||||
registry_4.setRegistryStatus(RegistryStatus.PROC.getKey());
|
||||
registry_4.setRegistryDesignation(RegistryDesignation.C.getKey());
|
||||
registry_4.setRegistryStatus(RegistryStatus.OK.getKey());
|
||||
registry_4.setRegistryDesignation(RegistryDesignation.O.getKey());
|
||||
registry_4.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
||||
registry_4.setRegistryUnit(RegistryUnit.T.getKey());
|
||||
registry_4.setSessionId(sessionId);
|
||||
|
|
@ -939,11 +939,11 @@ public class ReportServiceTest_KS {
|
|||
registry_1.setClearingDate(LocalDate.now());
|
||||
registry_1.setGroupId(Long.MAX_VALUE);
|
||||
registry_1.setSettlementDate(LocalDate.now());
|
||||
registry_1.setRegistryCode("CS_T");
|
||||
registry_1.setRegistryCode("OS_T");
|
||||
registry_1.setTradingClearingRegistry("TKR");
|
||||
registry_1.setRegistryDesignation(RegistryDesignation.C.getKey());
|
||||
registry_1.setRegistryDesignation(RegistryDesignation.O.getKey());
|
||||
registry_1.setRegistryInstrumentType(RegistryInstrumentType.S.getKey());
|
||||
registry_1.setRegistryStatus(RegistryStatus.PROC.getKey());
|
||||
registry_1.setRegistryStatus(RegistryStatus.OK.getKey());
|
||||
registry_1.setRegistryUnit(RegistryUnit.T.getKey());
|
||||
registry_1.setSecuritySymbol("SECURITY_SYMBOL");
|
||||
registry_1.setSessionId(sessionId);
|
||||
|
|
@ -958,12 +958,12 @@ public class ReportServiceTest_KS {
|
|||
registry_2.setClearingDate(LocalDate.now());
|
||||
registry_2.setGroupId(Long.MAX_VALUE);
|
||||
registry_2.setSettlementDate(LocalDate.now());
|
||||
registry_2.setRegistryCode("LS_T");
|
||||
registry_2.setRegistryCode("TS_T");
|
||||
registry_2.setTradingClearingRegistry("TKR");
|
||||
registry_2.setRegistryDesignation(RegistryDesignation.L.getKey());
|
||||
registry_2.setRegistryDesignation(RegistryDesignation.T.getKey());
|
||||
registry_2.setRegistryInstrumentType(RegistryInstrumentType.S.getKey());
|
||||
registry_2.setRegistryUnit(RegistryUnit.T.getKey());
|
||||
registry_2.setRegistryStatus(RegistryStatus.PROC.getKey());
|
||||
registry_2.setRegistryStatus(RegistryStatus.OK.getKey());
|
||||
registry_2.setSecuritySymbol("SECURITY_SYMBOL");
|
||||
registry_2.setSessionId(sessionId);
|
||||
registry_2.setAccount("ACCOUNT");
|
||||
|
|
@ -1189,6 +1189,8 @@ public class ReportServiceTest_KS {
|
|||
@Order(11)
|
||||
public void ksRepCashNettoExtendedTest() throws IOException, CsvValidationException {
|
||||
clearTestDir();
|
||||
Collection<Registry> allValues = registryImdg.getAllValues();
|
||||
for (Registry registry : allValues) registryImdg.delete(registry);
|
||||
|
||||
Session session = new Session();
|
||||
session.setCreated(
|
||||
|
|
@ -1234,6 +1236,7 @@ public class ReportServiceTest_KS {
|
|||
registry.setRegistryCapacity(row[10]);
|
||||
registry.setRegistryUnit(row[11]);
|
||||
registry.setRegistryCode(row[12]);
|
||||
registry.setRegistryStatus(row[15]);
|
||||
registry.setAccountType(row[6]);
|
||||
registry.setAccount(row[7]);
|
||||
if (row[6].equalsIgnoreCase(AccountType.Info.getKey())) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
"FIRMID","SESSION_ID","SESSION_DATE","ACCOUNT","TKR","VALUE","DATE","OBL_VALUE","REQ_VALUE","LOT_CURRENCY","CURRENCY_NETTO","TR_EXECDATE"
|
||||
"TRADING_CODE","146","20.01.1970T02:49:58","ACCOUNT","TKR","22.22","26.06.2024",,,,,
|
||||
"TRADING_CODE","146","20.01.1970T02:49:58","ACCOUNT_FROM_ACCOUNT","TKR",,"26.06.2024","22.22","44.44",,,
|
||||
"TRADING_CODE","146","20.01.1970T02:49:58","ACCOUNT","TKR","22.22","06.08.2024",,,,,
|
||||
"TRADING_CODE","146","20.01.1970T02:49:58","ACCOUNT_FROM_ACCOUNT","TKR",,"06.08.2024","22.22","44.44",,,
|
||||
|
|
|
|||
|
|
|
@ -1,2 +1,3 @@
|
|||
"FIRMID","ACCOUNT","TKR","DATE","REGISTER_CODE","REGISTER_NAME","OPEN_BALANCE","CHANGE_BALANCE","ADD_WITHDRAW","CLOSE_BALANCE","REMARKS","TRADE_NUM","CURRENCY"
|
||||
"TRADING_CODE","ACCOUNT","TRADING_CLEARING_REGISTRY","01.07.2024","AM_T","AM_T_NAME","77.78","189.00","111.00","377.78",,,
|
||||
"TRADING_CODE","ACCOUNT_FROM_ACCOUNT","TRADING_CLEARING_REGISTRY","06.08.2024","AM_T","AM_T_NAME","77.78","189.00","111.00","377.78",,,
|
||||
"TRADING_CODE","ACCOUNT","TRADING_CLEARING_REGISTRY","06.08.2024","AM_T","AM_T_NAME","77.78","189.00","111.00","377.78",,,
|
||||
|
|
|
|||
|
|
|
@ -1,19 +1,19 @@
|
|||
company_id;trading_code;clearing_code;short_name;full_name;account_id;account_type;account;registry_designation;registry_instrument_type;registry_capacity;registry_unit;registry_code;trading_clearing_registry_id;trading_clearing_registry;registry_status;security_id;security_symbol;balance;open_balance;close_balance;credit;debit;settled_credit;settled_debit;check_balance;diff_balance;plan_balance;balance_dimension;settlement_date;settlement_code;trading_date;clearing_date;refund_date;value_date;price;contract;counter_party_id;comment;parent_id;group_id;session_id;session_type;payment_id;id;created_at;updated_at;section
|
||||
4500120;95;95;Банк ВТБ (ПАО);Банк ВТБ (публичное акционерное общество);4410078;CLRN;30411810300000002094;C;M;A;T;CMAT;21240012;0095CAT00001;CLRD;643;RUB;69,75;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;69,7515;38840009;80162;(null);(null);507;47580029;UNIT;(null);47580094;24.06.2024 14:16;24.06.2024 15:19;CURR
|
||||
80162;8;8;ПАО Сбербанк;Публичное акционерное общество «Сбербанк России»;38690096;CLRN;3,04118607E+019;C;M;A;T;CMAT;130040;0008MAT00001;CLRD;860;UZS;10000;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;69,7515;38840009;4500120;(null);(null);507;47580029;UNIT;(null);47580076;24.06.2024 14:16;24.06.2024 15:19;CURR
|
||||
80022;472;472;ПАО "Промсвязьбанк";Публичное акционерное общество «Промсвязьбанк» ;38690028;CLRN;3,04111569E+019;C;M;A;T;CMAT;1860016;0472CAT00001;CLRD;156;CNY;10;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;12,9575;38840004;4500072;(null);(null);508;47580029;UNIT;(null);47580074;24.06.2024 14:16;24.06.2024 15:19;CURR
|
||||
80136;45;45;АО "АБ "РОССИЯ";Акционерное общество «Акционерный Банк «РОССИЯ»;130023;CLRN;3,04118103E+019;C;M;A;T;CMAT;1860025;0045CAT00001;CLRD;643;RUB;3000000000;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;25.06.2024;24.06.2024;17,12;DT1000S001U/240624/45/24062400000001;80074;(null);(null);24062400000001;47580029;UNIT;(null);47580072;24.06.2024 14:16;24.06.2024 15:19;MKR
|
||||
4500072;234;234;Банк "ВБРР" (АО);Акционерное общество "Всероссийский банк развития регионов";47130002;INFO;3,99118600000001E+019;C;M;A;T;CMAT;47130004;0234CAT00001;CLRD;860;UZS;10000000;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;69,7575;38840005;80022;(null);(null);1518298;47580029;UNIT;(null);47580093;24.06.2024 14:16;24.06.2024 15:19;CURR
|
||||
80162;8;8;ПАО Сбербанк;Публичное акционерное общество «Сбербанк России»;130013;CLRN;3,041181E+019;C;M;A;T;CMAT;1930000;0008CAT00001;CLRD;643;RUB;7000000000;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;25.06.2024;24.06.2024;16,88;DT1000S001U/240624/8/24062400000002;80074;(null);(null);24062400000002;47580029;UNIT;(null);47580079;24.06.2024 14:16;24.06.2024 15:19;MKR
|
||||
4500072;234;234;Банк "ВБРР" (АО);Акционерное общество "Всероссийский банк развития регионов";4410023;INFO;3,99118100000003E+019;C;M;A;T;CMAT;47130004;0234CAT00001;CLRD;643;RUB;129,58;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;12,9575;38840004;80022;(null);(null);508;47580029;UNIT;(null);47580073;24.06.2024 14:16;24.06.2024 15:19;CURR
|
||||
80162;8;8;ПАО Сбербанк;Публичное акционерное общество «Сбербанк России»;130013;CLRN;3,041181E+019;C;M;A;T;CMAT;1930000;0008CAT00001;CLRD;643;RUB;9743,9;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;97;(null);80022;(null);(null);1461034;47580029;UNIT;(null);47580085;24.06.2024 14:16;24.06.2024 15:19;FOND
|
||||
80022;472;472;ПАО "Промсвязьбанк";Публичное акционерное общество «Промсвязьбанк» ;130005;CLRN;3,0411810101E+019;C;M;A;T;CMAT;1860016;0472CAT00001;CLRD;643;RUB;69757,5;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;69,7575;38840005;4500072;(null);(null);1518298;47580029;UNIT;(null);47580090;24.06.2024 14:16;24.06.2024 15:19;CURR
|
||||
80022;472;472;ПАО "Промсвязьбанк";Публичное акционерное общество «Промсвязьбанк» ;38690032;CLRN;3,04118605E+019;L;M;A;T;LMAT;1860016;0472CAT00001;CLRD;860;UZS;10000000;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;69,7575;38840005;4500072;(null);(null);1518298;47580029;UNIT;(null);47580075;24.06.2024 14:16;24.06.2024 15:19;CURR
|
||||
4500072;234;234;Банк "ВБРР" (АО);Акционерное общество "Всероссийский банк развития регионов";47130000;INFO;3,99111560000002E+019;L;M;A;T;LMAT;47130004;0234CAT00001;CLRD;156;CNY;10;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;12,9575;38840004;80022;(null);(null);508;47580029;UNIT;(null);47580087;24.06.2024 14:16;24.06.2024 15:19;CURR
|
||||
80022;472;472;ПАО "Промсвязьбанк";Публичное акционерное общество «Промсвязьбанк» ;130005;CLRN;3,0411810101E+019;L;M;A;T;LMAT;1860016;0472CAT00001;CLRD;643;RUB;129,58;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;12,9575;38840004;4500072;(null);(null);508;47580029;UNIT;(null);47580083;24.06.2024 14:16;24.06.2024 15:19;CURR
|
||||
80022;472;472;ПАО "Промсвязьбанк";Публичное акционерное общество «Промсвязьбанк» ;130005;CLRN;3,0411810101E+019;L;M;A;T;LMAT;1860016;0472CAT00001;CLRD;643;RUB;9743,9;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;97;(null);80162;(null);(null);1461034;47580029;UNIT;(null);47580095;24.06.2024 14:16;24.06.2024 15:19;FOND
|
||||
80074;302;302;Комитет финансов СПб;Комитет финансов Санкт-Петербурга;130019;CLRN;3,04118107E+019;L;M;A;T;LMAT;130034;0302MAT00001;CLRD;643;RUB;7000000000;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;25.06.2024;24.06.2024;16,88;DT1000S001U/240624/8/24062400000002;80162;(null);(null);24062400000002;47580029;UNIT;(null);47580089;24.06.2024 14:16;24.06.2024 15:19;MKR
|
||||
4500072;234;234;Банк "ВБРР" (АО);Акционерное общество "Всероссийский банк развития регионов";4410023;INFO;3,99118100000003E+019;L;M;A;T;LMAT;47130004;0234CAT00001;CLRD;643;RUB;69757,5;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;69,7575;38840005;80022;(null);(null);1518298;47580029;UNIT;(null);47580078;24.06.2024 14:16;24.06.2024 15:19;CURR
|
||||
80074;302;302;Комитет финансов СПб;Комитет финансов Санкт-Петербурга;130019;CLRN;3,04118107E+019;L;M;A;T;LMAT;130034;0302MAT00001;CLRD;643;RUB;3000000000;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;25.06.2024;24.06.2024;17,12;DT1000S001U/240624/45/24062400000001;80136;(null);(null);24062400000001;47580029;UNIT;(null);47580086;24.06.2024 14:16;24.06.2024 15:19;MKR
|
||||
80162;8;8;ПАО Сбербанк;Публичное акционерное общество «Сбербанк России»;130017;CLRN;3,04118102E+019;L;M;A;T;LMAT;130040;0008MAT00001;CLRD;643;RUB;69,75;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;69,7515;38840009;4500120;(null);(null);507;47580029;UNIT;(null);47580084;24.06.2024 14:16;24.06.2024 15:19;CURR
|
||||
4500120;95;95;Банк ВТБ (ПАО);Банк ВТБ (публичное акционерное общество);38690016;CLRN;30411810300000002049;L;M;A;T;LMAT;21240012;0095CAT00001;CLRD;860;UZS;10000;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;69,7515;38840009;80162;(null);(null);507;47580029;UNIT;(null);47580088;24.06.2024 14:16;24.06.2024 15:19;CURR
|
||||
4500120;95;95;Банк ВТБ (ПАО);Банк ВТБ (публичное акционерное общество);4410078;CLRN;30411810300000002094;O;M;A;T;OMAT;21240012;0095CAT00001;CLRD;643;RUB;69,75;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;69,7515;38840009;80162;(null);(null);507;47580029;UNIT;(null);47580094;24.06.2024 14:16;24.06.2024 15:19;CURR
|
||||
80162;8;8;ПАО Сбербанк;Публичное акционерное общество «Сбербанк России»;38690096;CLRN;3,04118607E+019;O;M;A;T;OMAT;130040;0008MAT00001;CLRD;860;UZS;10000;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;69,7515;38840009;4500120;(null);(null);507;47580029;UNIT;(null);47580076;24.06.2024 14:16;24.06.2024 15:19;CURR
|
||||
80022;472;472;ПАО "Промсвязьбанк";Публичное акционерное общество «Промсвязьбанк» ;38690028;CLRN;3,04111569E+019;O;M;A;T;OMAT;1860016;0472CAT00001;CLRD;156;CNY;10;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;12,9575;38840004;4500072;(null);(null);508;47580029;UNIT;(null);47580074;24.06.2024 14:16;24.06.2024 15:19;CURR
|
||||
80136;45;45;АО "АБ "РОССИЯ";Акционерное общество «Акционерный Банк «РОССИЯ»;130023;CLRN;3,04118103E+019;O;M;A;T;OMAT;1860025;0045CAT00001;CLRD;643;RUB;3000000000;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;25.06.2024;24.06.2024;17,12;DT1000S001U/240624/45/24062400000001;80074;(null);(null);24062400000001;47580029;UNIT;(null);47580072;24.06.2024 14:16;24.06.2024 15:19;MKR
|
||||
4500072;234;234;Банк "ВБРР" (АО);Акционерное общество "Всероссийский банк развития регионов";47130002;INFO;3,99118600000001E+019;O;M;A;T;OMAT;47130004;0234CAT00001;CLRD;860;UZS;10000000;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;69,7575;38840005;80022;(null);(null);1518298;47580029;UNIT;(null);47580093;24.06.2024 14:16;24.06.2024 15:19;CURR
|
||||
80162;8;8;ПАО Сбербанк;Публичное акционерное общество «Сбербанк России»;130013;CLRN;3,041181E+019;O;M;A;T;OMAT;1930000;0008CAT00001;CLRD;643;RUB;7000000000;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;25.06.2024;24.06.2024;16,88;DT1000S001U/240624/8/24062400000002;80074;(null);(null);24062400000002;47580029;UNIT;(null);47580079;24.06.2024 14:16;24.06.2024 15:19;MKR
|
||||
4500072;234;234;Банк "ВБРР" (АО);Акционерное общество "Всероссийский банк развития регионов";4410023;INFO;3,99118100000003E+019;O;M;A;T;OMAT;47130004;0234CAT00001;CLRD;643;RUB;129,58;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;12,9575;38840004;80022;(null);(null);508;47580029;UNIT;(null);47580073;24.06.2024 14:16;24.06.2024 15:19;CURR
|
||||
80162;8;8;ПАО Сбербанк;Публичное акционерное общество «Сбербанк России»;130013;CLRN;3,041181E+019;O;M;A;T;OMAT;1930000;0008CAT00001;CLRD;643;RUB;9743,9;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;97;(null);80022;(null);(null);1461034;47580029;UNIT;(null);47580085;24.06.2024 14:16;24.06.2024 15:19;FOND
|
||||
80022;472;472;ПАО "Промсвязьбанк";Публичное акционерное общество «Промсвязьбанк» ;130005;CLRN;3,0411810101E+019;O;M;A;T;OMAT;1860016;0472CAT00001;CLRD;643;RUB;69757,5;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;69,7575;38840005;4500072;(null);(null);1518298;47580029;UNIT;(null);47580090;24.06.2024 14:16;24.06.2024 15:19;CURR
|
||||
80022;472;472;ПАО "Промсвязьбанк";Публичное акционерное общество «Промсвязьбанк» ;38690032;CLRN;3,04118605E+019;T;M;A;T;TMAT;1860016;0472CAT00001;CLRD;860;UZS;10000000;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;69,7575;38840005;4500072;(null);(null);1518298;47580029;UNIT;(null);47580075;24.06.2024 14:16;24.06.2024 15:19;CURR
|
||||
4500072;234;234;Банк "ВБРР" (АО);Акционерное общество "Всероссийский банк развития регионов";47130000;INFO;3,99111560000002E+019;T;M;A;T;TMAT;47130004;0234CAT00001;CLRD;156;CNY;10;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;12,9575;38840004;80022;(null);(null);508;47580029;UNIT;(null);47580087;24.06.2024 14:16;24.06.2024 15:19;CURR
|
||||
80022;472;472;ПАО "Промсвязьбанк";Публичное акционерное общество «Промсвязьбанк» ;130005;CLRN;3,0411810101E+019;T;M;A;T;TMAT;1860016;0472CAT00001;CLRD;643;RUB;129,58;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;12,9575;38840004;4500072;(null);(null);508;47580029;UNIT;(null);47580083;24.06.2024 14:16;24.06.2024 15:19;CURR
|
||||
80022;472;472;ПАО "Промсвязьбанк";Публичное акционерное общество «Промсвязьбанк» ;130005;CLRN;3,0411810101E+019;T;M;A;T;TMAT;1860016;0472CAT00001;CLRD;643;RUB;9743,9;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;97;(null);80162;(null);(null);1461034;47580029;UNIT;(null);47580095;24.06.2024 14:16;24.06.2024 15:19;FOND
|
||||
80074;302;302;Комитет финансов СПб;Комитет финансов Санкт-Петербурга;130019;CLRN;3,04118107E+019;T;M;A;T;TMAT;130034;0302MAT00001;CLRD;643;RUB;7000000000;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;25.06.2024;24.06.2024;16,88;DT1000S001U/240624/8/24062400000002;80162;(null);(null);24062400000002;47580029;UNIT;(null);47580089;24.06.2024 14:16;24.06.2024 15:19;MKR
|
||||
4500072;234;234;Банк "ВБРР" (АО);Акционерное общество "Всероссийский банк развития регионов";4410023;INFO;3,99118100000003E+019;T;M;A;T;TMAT;47130004;0234CAT00001;CLRD;643;RUB;69757,5;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;69,7575;38840005;80022;(null);(null);1518298;47580029;UNIT;(null);47580078;24.06.2024 14:16;24.06.2024 15:19;CURR
|
||||
80074;302;302;Комитет финансов СПб;Комитет финансов Санкт-Петербурга;130019;CLRN;3,04118107E+019;T;M;A;T;TMAT;130034;0302MAT00001;CLRD;643;RUB;3000000000;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;25.06.2024;24.06.2024;17,12;DT1000S001U/240624/45/24062400000001;80136;(null);(null);24062400000001;47580029;UNIT;(null);47580086;24.06.2024 14:16;24.06.2024 15:19;MKR
|
||||
80162;8;8;ПАО Сбербанк;Публичное акционерное общество «Сбербанк России»;130017;CLRN;3,04118102E+019;T;M;A;T;TMAT;130040;0008MAT00001;CLRD;643;RUB;69,75;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;69,7515;38840009;4500120;(null);(null);507;47580029;UNIT;(null);47580084;24.06.2024 14:16;24.06.2024 15:19;CURR
|
||||
4500120;95;95;Банк ВТБ (ПАО);Банк ВТБ (публичное акционерное общество);38690016;CLRN;30411810300000002049;T;M;A;T;TMAT;21240012;0095CAT00001;CLRD;860;UZS;10000;(null);(null);0;0;0;0;0;0;0;MONY;24.06.2024;T0;24.06.2024;24.06.2024;(null);24.06.2024;69,7515;38840009;80162;(null);(null);507;47580029;UNIT;(null);47580088;24.06.2024 14:16;24.06.2024 15:19;CURR
|
||||
|
|
|
|||
|
Can't render this file because it contains an unexpected character in line 4 and column 22.
|
|
|
@ -0,0 +1,15 @@
|
|||
package ru.spcex.platform.imdg.api.predicate.specific;
|
||||
|
||||
import java.util.List;
|
||||
import ru.spcex.platform.enumeration.RegistryTradingParams;
|
||||
|
||||
public class RegistryCodeRawSqlBuilder extends RegistryCodeSqlBuilder {
|
||||
RegistryCodeRawSqlBuilder(List<RegistryTradingParams> tradingParams) {
|
||||
super(tradingParams);
|
||||
registryDesignation = "registry_designation";
|
||||
registryInstrumentType = "registry_instrument_type";
|
||||
registryCapacity = "registry_capacity";
|
||||
registryUnit = "registry_unit";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,33 +1,46 @@
|
|||
package ru.spcex.platform.imdg.api.predicate.specific;
|
||||
|
||||
import ru.spcex.platform.enumeration.RegistryTradingParams;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import ru.spcex.platform.enumeration.RegistryTradingParams;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
|
||||
public class RegistryCodeSqlBuilder {
|
||||
|
||||
private List<RegistryTradingParams> registryTradingParams;
|
||||
private String prefix = null;
|
||||
protected String registryDesignation = "registryDesignation";
|
||||
protected String registryInstrumentType = "registryInstrumentType";
|
||||
protected String registryCapacity = "registryCapacity";
|
||||
protected String registryUnit = "registryUnit";
|
||||
|
||||
public static RegistryCodeSqlBuilder getInstance(RegistryTradingParams... tradingParams) {
|
||||
return new RegistryCodeSqlBuilder(Arrays.asList(tradingParams));
|
||||
return getInstance(false, tradingParams);
|
||||
}
|
||||
|
||||
private RegistryCodeSqlBuilder(List<RegistryTradingParams> tradingParams) {
|
||||
public static RegistryCodeSqlBuilder getInstance(boolean directDB, RegistryTradingParams... tradingParams) {
|
||||
RegistryCodeSqlBuilder builder;
|
||||
if (directDB) {
|
||||
builder = new RegistryCodeRawSqlBuilder(Arrays.asList(tradingParams));
|
||||
} else {
|
||||
builder = new RegistryCodeSqlBuilder(Arrays.asList(tradingParams));
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
RegistryCodeSqlBuilder(List<RegistryTradingParams> tradingParams) {
|
||||
this.registryTradingParams = tradingParams;
|
||||
}
|
||||
|
||||
public String build() {
|
||||
List<StringBuilder> conditions = new ArrayList<>();
|
||||
String REGISTRY_DESIGNATION_FORMAT = "registryDesignation = '%s'";
|
||||
String REGISTRY_INSTRUMENT_TYPE_FORMAT = "registryInstrumentType = '%s'";
|
||||
String REGISTRY_CAPACITY_FORMAT = "registryCapacity = '%s'";
|
||||
String REGISTRY_UNIT_FORMAT = "registryUnit = '%s'";
|
||||
String REGISTRY_DESIGNATION_FORMAT = registryDesignation + " = '%s'";
|
||||
String REGISTRY_INSTRUMENT_TYPE_FORMAT = registryInstrumentType + " = '%s'";
|
||||
String REGISTRY_CAPACITY_FORMAT = registryCapacity + " = '%s'";
|
||||
String REGISTRY_UNIT_FORMAT = registryUnit + " = '%s'";
|
||||
if (prefix != null) {
|
||||
REGISTRY_DESIGNATION_FORMAT = "%s.%s".formatted(prefix, REGISTRY_DESIGNATION_FORMAT);
|
||||
REGISTRY_INSTRUMENT_TYPE_FORMAT = "%s.%s".formatted(prefix, REGISTRY_INSTRUMENT_TYPE_FORMAT);
|
||||
|
|
@ -75,10 +88,10 @@ public class RegistryCodeSqlBuilder {
|
|||
|
||||
public ImdgPredicate buildPredicate(ImdgPredicateBuilder pb) {
|
||||
List<ImdgPredicate> conditionsOr = new ArrayList<>();
|
||||
String REGISTRY_DESIGNATION_FIELD = "registryDesignation";
|
||||
String REGISTRY_INSTRUMENT_TYPE_FIELD = "registryInstrumentType";
|
||||
String REGISTRY_CAPACITY_FIELD = "registryCapacity";
|
||||
String REGISTRY_UNIT_FIELD = "registryUnit";
|
||||
String REGISTRY_DESIGNATION_FIELD = registryDesignation;
|
||||
String REGISTRY_INSTRUMENT_TYPE_FIELD = registryInstrumentType;
|
||||
String REGISTRY_CAPACITY_FIELD = registryCapacity;
|
||||
String REGISTRY_UNIT_FIELD = registryUnit;
|
||||
if (prefix != null) {
|
||||
REGISTRY_DESIGNATION_FIELD = "%s.%s".formatted(prefix, REGISTRY_DESIGNATION_FIELD);
|
||||
REGISTRY_INSTRUMENT_TYPE_FIELD = "%s.%s".formatted(prefix, REGISTRY_INSTRUMENT_TYPE_FIELD);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue