registry-service http://jira.mfd.msk:8088/browse/CLS-680 удаление и перенос из register_utility (в основном код писал akulikov)
This commit is contained in:
parent
eed10a1eec
commit
4ff7dbf586
131 changed files with 5197 additions and 4944 deletions
38
clearing-parent/registry-service/README.md
Normal file
38
clearing-parent/registry-service/README.md
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
registry-service
|
||||
================
|
||||
|
||||
Описание
|
||||
--------
|
||||
Утилита для создания отчётов за разные даты registry-service. Использует jdbc (прямое соединение с базой) вместо imdg.
|
||||
|
||||
Запуск
|
||||
------
|
||||
java -jar registry-service.jar "--spring.config.location=E:\MFD_GIT_REPO\clearing\registry-service" --report --startDate=24.01.2024 --endDate=31.01.2024
|
||||
|
||||
#####Параметры запуска
|
||||
* --service запуск в режиме сервиса (по умолчанию)
|
||||
* --report запуск для формирования одного отчёта, выключиться по завершении
|
||||
* --startDate=24.01.2024 в режиме --report дата начала (включительно)
|
||||
* --endDate=31.01.2024 в режиме --report дата завершения (включительно)
|
||||
|
||||
Для запуска в режиме сервиса надо добавить в настройки параметры кафки.
|
||||
|
||||
Настройки в application.properties.
|
||||
registry-service.kafka-consumer.* и registry-service.kafka-producer.* не обязательны, если не запускается в режиме --service
|
||||
|
||||
Структура кода
|
||||
--------------
|
||||
|
||||
* RegisterUtilityRunner - порядок выгрузки и создания отчётов
|
||||
* loaders/* - загрузчики данных, почти как MapStore, но грузят все связанные объекты.
|
||||
* builders/* - построители отчётов
|
||||
* bean/* - классы, enum
|
||||
|
||||
Соответствие отчётам
|
||||
--------------------
|
||||
executionDepositLoader + executionFondLoader = executionRegisterReportBuilder (contract_register)
|
||||
depoInstructionLoader = depoPaymentInstructionBuilder (rdc_register)
|
||||
moneyPaymentInstructionLoader = moneyPaymentInstructionRegisterReportBuilder (prc_register)
|
||||
moneyBalanceLoader = moneyBalanceRegisterReportBuilder (money_register)
|
||||
depoBalanceLoader = depoBalanceRegisterReportBuilder (security_register)
|
||||
registryLoader = liabilitiesRegistryReportBuilder (registry)
|
||||
|
|
@ -15,46 +15,63 @@
|
|||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<poi.version>5.2.5</poi.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<!-- <spring.version>2.6.3</spring.version>-->
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- Clearing Kafka -->
|
||||
<dependency>
|
||||
<groupId>ru.spcex.platform</groupId>
|
||||
<artifactId>platform-messaging</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.platform</groupId>
|
||||
<artifactId>platform-imdg-api-hazelcast-impl</artifactId>
|
||||
<artifactId>platform-enum</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>classes</artifactId>
|
||||
<groupId>ru.spcex.platform</groupId>
|
||||
<artifactId>platform-classes-base</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>dictionary</artifactId>
|
||||
</dependency>-->
|
||||
|
||||
|
||||
<!-- Spring -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-jdbc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-ldap</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-sftp</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- БД -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<groupId>com.mchange</groupId>
|
||||
<artifactId>c3p0</artifactId>
|
||||
<version>0.9.5.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>dictionary</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>test-clearing</artifactId>
|
||||
<scope>test</scope>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- CSV -->
|
||||
|
|
@ -76,7 +93,56 @@
|
|||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- special logging -->
|
||||
<!-- Тесты -->
|
||||
<dependency>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>test-clearing</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Логирование -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.logstash.logback</groupId>
|
||||
<artifactId>logstash-logback-encoder</artifactId>
|
||||
|
|
|
|||
|
|
@ -1,12 +1,60 @@
|
|||
package ru.spcex.clearing.registry;
|
||||
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import ru.spcex.clearing.registry.service.RegisterUtilityRunner;
|
||||
import ru.spcex.clearing.registry.service.RegisterUtilityService;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Параметры запуска:
|
||||
* --service запуск как сервис (по умолчанию);
|
||||
* --report запустить один раз, выполнить все отчёты и завершиться.
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class RegistryServiceApplication {
|
||||
public class RegistryServiceApplication implements CommandLineRunner {
|
||||
final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final RegisterUtilityRunner runner;
|
||||
@Autowired
|
||||
ConfigurableApplicationContext context;
|
||||
|
||||
public RegistryServiceApplication(RegisterUtilityRunner runner) {
|
||||
this.runner = runner;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication springApplication = new SpringApplication(RegistryServiceApplication.class);
|
||||
springApplication.run(args);
|
||||
SpringApplication.run(RegistryServiceApplication.class, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws InterruptedException {
|
||||
log.info("{} start with CMD: \"{}\"", this.getClass().getSimpleName(), Arrays.toString(args));
|
||||
log.info("Available CMD option: --report or --service");
|
||||
boolean asService = true;
|
||||
for (String arg : args) {
|
||||
if ("--service".equalsIgnoreCase(arg))
|
||||
asService = true;
|
||||
if ("--report".equalsIgnoreCase(arg))
|
||||
asService = false;
|
||||
}
|
||||
try {
|
||||
if (!asService) {
|
||||
log.info("Запуск всех отчётов.");
|
||||
runner.process();
|
||||
} else {
|
||||
log.info("Запуск в режиме ожидания команд, как сервис.");
|
||||
RegisterUtilityService service = context.getBean(RegisterUtilityService.class);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
log.error("{}", ExceptionUtils.getStackTrace(e));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
package ru.spcex.clearing.registry.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD})
|
||||
public @interface BindByName {
|
||||
String column();
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package ru.spcex.clearing.registry.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD})
|
||||
public @interface BindByPosition {
|
||||
int position();
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package ru.spcex.clearing.registry.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD})
|
||||
public @interface ReportDate {
|
||||
String value() default "yyyyMMdd'T'HHmmss";
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package ru.spcex.clearing.registry.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD})
|
||||
public @interface ReportNumber {
|
||||
String value();
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
package ru.spcex.clearing.registry.conf;
|
||||
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import ru.spcex.clearing.registry.conf.properties.AProperties;
|
||||
import ru.spcex.clearing.registry.exceptions.ConfigurationException;
|
||||
import ru.spcex.clearing.registry.service.RegisterUtilityRunner;
|
||||
import ru.spcex.clearing.registry.service.RegisterUtilityService;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@Configuration
|
||||
public class BeanConfig {
|
||||
Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Bean("outFolder")
|
||||
public File outFolder(AProperties properties) {
|
||||
File outFolder = new File(properties.getOutFolder());
|
||||
if (outFolder.exists() && !outFolder.isDirectory())
|
||||
throw new ConfigurationException("Путь %s не является директорией".formatted(properties.getOutFolder()));
|
||||
if (!outFolder.exists()) {
|
||||
boolean mkdirs = outFolder.mkdirs();
|
||||
if (!mkdirs) throw new ConfigurationException("Не удалось создать директорию для отчетов");
|
||||
}
|
||||
return outFolder;
|
||||
}
|
||||
|
||||
@Autowired(required = false)
|
||||
@Lazy
|
||||
@Bean
|
||||
public RegisterUtilityService RegisterUtilityService(RegisterUtilityRunner runner,
|
||||
AProperties properties, CmdArgsParser cmdArgsParser,
|
||||
Consumer<String, Object> kafkaQueue,
|
||||
Producer<String, Object> kafkaResponseQueue) {
|
||||
if (kafkaQueue == null) {
|
||||
log.info("KafkaQueue was not configured.");
|
||||
return null;
|
||||
}
|
||||
if (kafkaResponseQueue == null) {
|
||||
log.info("kafkaResponseQueue was not configured.");
|
||||
return null;
|
||||
}
|
||||
if (runner == null)
|
||||
throw new IllegalStateException("Required bean RegisterUtilityRunner");
|
||||
if (properties == null)
|
||||
throw new IllegalStateException("Required bean AProperties");
|
||||
RegisterUtilityService service = new RegisterUtilityService(runner, properties, cmdArgsParser,
|
||||
kafkaQueue, kafkaResponseQueue);
|
||||
return service;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
package ru.spcex.clearing.registry.conf;
|
||||
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.spcex.clearing.registry.conf.properties.PeriodProperties;
|
||||
import ru.spcex.clearing.registry.exceptions.CmdArgsParserException;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Component
|
||||
public class CmdArgsParser {
|
||||
private final ApplicationArguments applicationArguments;
|
||||
public final String START_DATE_OPTION = "startDate";
|
||||
public final String END_DATE_OPTION = "endDate";
|
||||
|
||||
public CmdArgsParser(ApplicationArguments applicationArguments) {
|
||||
this.applicationArguments = applicationArguments;
|
||||
}
|
||||
|
||||
public PeriodProperties parsePeriodProperties() {
|
||||
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("dd.MM.yyyy");
|
||||
Set<String> optionNames = applicationArguments.getOptionNames();
|
||||
PeriodProperties periodProperties = new PeriodProperties();
|
||||
String startDateStr;
|
||||
String endDateStr;
|
||||
for (String option : optionNames) {
|
||||
if (option.equalsIgnoreCase(START_DATE_OPTION)) {
|
||||
if (periodProperties.getStartDate() != null) throw new CmdArgsParserException("Более одной опции --start");
|
||||
List<String> optionValues = applicationArguments.getOptionValues(option);
|
||||
if (optionValues.size() != 1)
|
||||
throw new CmdArgsParserException("Для опции --"+START_DATE_OPTION+" должно быть указано одно значение в формате ДД.ММ.ГГГГ");
|
||||
startDateStr = optionValues.iterator().next();
|
||||
try {
|
||||
LocalDate startDate = LocalDate.parse(startDateStr, dateFormatter);
|
||||
periodProperties.setStartDate(startDate);
|
||||
} catch (Exception e) {
|
||||
throw new CmdArgsParserException("Опция --"+START_DATE_OPTION+" должна быть указана в формате ДД.ММ.ГГГГ");
|
||||
}
|
||||
}
|
||||
if (option.equalsIgnoreCase(END_DATE_OPTION)) {
|
||||
if (periodProperties.getEndDate() != null) throw new CmdArgsParserException("Более одной опции --end");
|
||||
List<String> optionValues = applicationArguments.getOptionValues(option);
|
||||
if (optionValues.size() != 1)
|
||||
throw new CmdArgsParserException("Для опции --"+END_DATE_OPTION+" должно быть указано одно значение в формате ДД.ММ.ГГГГ");
|
||||
endDateStr = optionValues.iterator().next();
|
||||
try {
|
||||
LocalDate endDate = LocalDate.parse(endDateStr, dateFormatter);
|
||||
periodProperties.setEndDate(endDate);
|
||||
} catch (Exception e) {
|
||||
throw new CmdArgsParserException("Опция --"+END_DATE_OPTION+" должна быть указана в формате ДД.ММ.ГГГГ");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (periodProperties.getStartDate() == null && periodProperties.getEndDate() == null) {
|
||||
periodProperties.setStartDate(LocalDate.now());
|
||||
periodProperties.setEndDate(LocalDate.now());
|
||||
}
|
||||
if (periodProperties.getEndDate() == null) periodProperties.setEndDate(periodProperties.getStartDate());
|
||||
validatePeriodProperties(periodProperties);
|
||||
|
||||
return periodProperties;
|
||||
}
|
||||
|
||||
public void validatePeriodProperties(PeriodProperties periodProperties) throws CmdArgsParserException {
|
||||
if (periodProperties.getStartDate()==null)
|
||||
throw new CmdArgsParserException("Дата " + START_DATE_OPTION + " должна быть указана.");
|
||||
if (periodProperties.getEndDate()==null)
|
||||
throw new CmdArgsParserException("Дата " + END_DATE_OPTION + " должна быть указана.");
|
||||
if (periodProperties.getStartDate().isAfter(periodProperties.getEndDate())) {
|
||||
throw new CmdArgsParserException("Дата " + START_DATE_OPTION + "=" + periodProperties.getStartDate() + " должна быть до " + END_DATE_OPTION + "=" + periodProperties.getEndDate());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package ru.spcex.clearing.registry.conf;
|
||||
|
||||
import com.mchange.v2.c3p0.ComboPooledDataSource;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
import ru.spcex.clearing.registry.conf.properties.AProperties;
|
||||
import ru.spcex.clearing.registry.conf.properties.DevProperties;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.beans.PropertyVetoException;
|
||||
|
||||
@Configuration
|
||||
public class DBConfiguration {
|
||||
|
||||
@Bean("indicJdbcTemplate")
|
||||
public NamedParameterJdbcTemplate indicJdbcTemplate(@Qualifier("clearingDataSource") DataSource indicDataSource) {
|
||||
return new NamedParameterJdbcTemplate(indicDataSource);
|
||||
}
|
||||
|
||||
@Bean("clearingDataSource")
|
||||
public DataSource indicDataSource(AProperties properties, DevProperties devProperties) throws PropertyVetoException {
|
||||
ComboPooledDataSource clearingDataSource = new ComboPooledDataSource();
|
||||
clearingDataSource.setDriverClass(properties.getDbClearing().getDriver());
|
||||
clearingDataSource.setJdbcUrl(properties.getDbClearing().getUrl());
|
||||
clearingDataSource.setUser(properties.getDbClearing().getUsername());
|
||||
clearingDataSource.setPassword(properties.getDbClearing().getPassword());
|
||||
clearingDataSource.setAcquireIncrement(devProperties.getC3p0AcquireIncrement());
|
||||
clearingDataSource.setInitialPoolSize(devProperties.getC3p0InitialPoolSize());
|
||||
clearingDataSource.setMinPoolSize(devProperties.getC3p0MinPoolSize());
|
||||
clearingDataSource.setMaxPoolSize(devProperties.getC3p0MaxPoolSize());
|
||||
return clearingDataSource;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package ru.spcex.clearing.registry.conf;
|
||||
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
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 ru.spcex.clearing.platform.messaging.config.KafkaConsumerFactory;
|
||||
import ru.spcex.clearing.platform.messaging.config.KafkaProducerFactory;
|
||||
import ru.spcex.clearing.platform.messaging.config.element.KafkaConsumerSettings;
|
||||
import ru.spcex.clearing.platform.messaging.config.element.KafkaProducerSettings;
|
||||
import ru.spcex.clearing.registry.conf.properties.AProperties;
|
||||
|
||||
@Configuration
|
||||
public class KafkaConfig {
|
||||
@Autowired
|
||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
@Bean
|
||||
public Consumer<String, Object> createConsumer(AProperties settings) {
|
||||
KafkaConsumerSettings kafkaSettings = settings.getKafkaConsumer();
|
||||
if (kafkaSettings == null || kafkaSettings.getBootstrapServers() == null) {
|
||||
return null;
|
||||
}
|
||||
return KafkaConsumerFactory.consumer(kafkaSettings);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
@Bean
|
||||
public Producer<String, Object> createProducer(AProperties settings) {
|
||||
KafkaProducerSettings kafkaSettings = settings.getKafkaProducer();
|
||||
if (kafkaSettings == null || kafkaSettings.getBootstrapServers() == null) {
|
||||
return null;
|
||||
}
|
||||
return KafkaProducerFactory.producer(kafkaSettings);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
@Bean
|
||||
public ProducerFactory<String, Object> pf(AProperties settings) {
|
||||
KafkaProducerSettings kafkaSettings = settings.getKafkaProducer();
|
||||
if (kafkaSettings == null || kafkaSettings.getBootstrapServers() == null) {
|
||||
return null;
|
||||
}
|
||||
return KafkaProducerFactory.producerFactory(kafkaSettings);
|
||||
}
|
||||
|
||||
@Autowired(required = false)
|
||||
@Bean
|
||||
public KafkaTemplate<String, Object> kafkaTemplate(ProducerFactory<String, Object> pf) {
|
||||
if (pf == null)
|
||||
return null;
|
||||
return new KafkaTemplate<>(pf);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
package ru.spcex.clearing.registry.conf;
|
||||
|
||||
import com.jcraft.jsch.ChannelSftp;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.expression.common.LiteralExpression;
|
||||
import org.springframework.integration.annotation.Gateway;
|
||||
import org.springframework.integration.annotation.MessagingGateway;
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.file.remote.session.CachingSessionFactory;
|
||||
import org.springframework.integration.file.remote.session.SessionFactory;
|
||||
import org.springframework.integration.sftp.gateway.SftpOutboundGateway;
|
||||
import org.springframework.integration.sftp.outbound.SftpMessageHandler;
|
||||
import org.springframework.integration.sftp.session.DefaultSftpSessionFactory;
|
||||
import org.springframework.integration.sftp.session.SftpFileInfo;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import ru.spcex.clearing.registry.conf.properties.AProperties;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import static org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway.Command.LS;
|
||||
|
||||
//@Configuration
|
||||
public class SFTPReportsConfig {
|
||||
// protected Logger log = LoggerFactory.getLogger(getClass());
|
||||
// private final AProperties settings;
|
||||
//
|
||||
// @Autowired(required = false)
|
||||
// public SFTPReportsConfig(AProperties settings) {
|
||||
// this.settings = settings;
|
||||
// }
|
||||
//
|
||||
// @Bean("reportsSftpSessionFactory")
|
||||
// public SessionFactory<ChannelSftp.LsEntry> sftpSessionFactory() {
|
||||
// if (settings.getReportsStore()==null) {
|
||||
// log.info("SFTP reports-store not set in config. Disabled.");
|
||||
// return null;
|
||||
// }
|
||||
// DefaultSftpSessionFactory factory = new DefaultSftpSessionFactory(true);
|
||||
// factory.setHost(settings.getReportsStore().getServerIp());
|
||||
// factory.setPort(settings.getReportsStore().getServerPort());
|
||||
// factory.setUser(settings.getReportsStore().getUser());
|
||||
// factory.setPassword(settings.getReportsStore().getPassword());
|
||||
// factory.setAllowUnknownKeys(true);
|
||||
// return new CachingSessionFactory<>(factory);
|
||||
// }
|
||||
//
|
||||
// @Bean("reportsSftpHandler")
|
||||
// @Autowired(required = false)
|
||||
// @ServiceActivator(inputChannel = "reportsToSftpChannel")
|
||||
// public MessageHandler handler(@Qualifier("reportsSftpSessionFactory") SessionFactory<ChannelSftp.LsEntry> sessionFactory) {
|
||||
// if (sessionFactory == null || settings.getReportsStore()==null) {
|
||||
// log.info("reportsToSftpChannel disabled.");
|
||||
// return null;
|
||||
// }
|
||||
// SftpMessageHandler handler = new SftpMessageHandler(sessionFactory);
|
||||
// handler.setRemoteDirectoryExpression(new LiteralExpression(settings.getReportsStore().getOutDir()));
|
||||
// log.info("Configure sftp output directory \"{}\"", settings.getReportsStore().getOutDir());
|
||||
// handler.setAutoCreateDirectory(true);
|
||||
// handler.setFileNameGenerator(message -> {
|
||||
// if (message.getPayload() instanceof File) {
|
||||
// return ((File) message.getPayload()).getName();
|
||||
// } else {
|
||||
// throw new IllegalArgumentException("File must expected as payload.");
|
||||
// }
|
||||
// });
|
||||
// return handler;
|
||||
// }
|
||||
//
|
||||
// @Autowired(required = false)
|
||||
// @Bean("reportsListSftpChannel")
|
||||
// public MessageChannel listSftpChannel(@Qualifier("reportsSftpHandlerList") MessageHandler handler) {
|
||||
// if (handler==null)
|
||||
// return null;
|
||||
// DirectChannel dc = new DirectChannel();
|
||||
// dc.subscribe(handler);
|
||||
// return dc;
|
||||
// }
|
||||
//
|
||||
// @Autowired(required = false)
|
||||
// @Bean("reportsToSftpChannel")
|
||||
// public MessageChannel toSftpChannel(@Qualifier("reportsSftpHandler") MessageHandler handler) {
|
||||
// if (handler==null)
|
||||
// return null;
|
||||
// DirectChannel dc = new DirectChannel();
|
||||
// dc.subscribe(handler);
|
||||
// return dc;
|
||||
// }
|
||||
//
|
||||
// @Autowired(required = false)
|
||||
// @Bean("reportsSftpHandlerList")
|
||||
// @ServiceActivator(inputChannel = "reportsListSftpChannel")
|
||||
// public MessageHandler handlerList(@Qualifier("reportsSftpSessionFactory") SessionFactory<ChannelSftp.LsEntry> sessionFactory) {
|
||||
// if (sessionFactory==null)
|
||||
// return null;
|
||||
// String expression = "'/%s'".formatted(settings.getReportsStore().getOutDir());
|
||||
// return new SftpOutboundGateway(sessionFactory, LS.getCommand(), expression);
|
||||
// }
|
||||
//
|
||||
// @Autowired(required = false)
|
||||
// @Bean("reportsSftpOutboundListFlow")
|
||||
// public IntegrationFlow sftpOutboundListFlow(@Qualifier("reportsSftpSessionFactory") SessionFactory<ChannelSftp.LsEntry> sessionFactory) {
|
||||
// if (sessionFactory==null)
|
||||
// return null;
|
||||
// return IntegrationFlows.from("reportsListSftpChannel")
|
||||
// .handle(new SftpOutboundGateway(sessionFactory, "ls", "payload"))
|
||||
// .get();
|
||||
// }
|
||||
//
|
||||
@MessagingGateway(name = "reportsSftpGateway")
|
||||
public interface ReportsGateway {
|
||||
@Gateway(requestChannel = "reportsToSftpChannel")
|
||||
void sendToSftp(File file);
|
||||
|
||||
@Gateway(requestChannel = "reportsListSftpChannel")
|
||||
List<SftpFileInfo> listFiles(String dir);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
package ru.spcex.clearing.registry.conf.properties;
|
||||
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import ru.spcex.clearing.platform.messaging.config.element.KafkaConsumerSettings;
|
||||
import ru.spcex.clearing.platform.messaging.config.element.KafkaProducerSettings;
|
||||
import ru.spcex.clearing.registry.conf.CmdArgsParser;
|
||||
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "registry-service")
|
||||
@PropertySource(value = {"file:${spring.config.location}/application.properties"})
|
||||
public class AProperties {
|
||||
private DBProperties dbClearing;
|
||||
private PeriodProperties period;
|
||||
private ReportsStore reportsStore; // localTempDir
|
||||
|
||||
private KafkaConsumerSettings kafkaConsumer;
|
||||
private KafkaProducerSettings kafkaProducer;
|
||||
|
||||
@Value("${registry-service.outFolder}")
|
||||
private String outFolder;
|
||||
|
||||
public AProperties(CmdArgsParser argsParser) {
|
||||
period = argsParser.parsePeriodProperties();
|
||||
LoggerFactory.getLogger(getClass()).info("Period from CMD: {}", period);
|
||||
}
|
||||
|
||||
public DBProperties getDbClearing() {
|
||||
return dbClearing;
|
||||
}
|
||||
|
||||
public void setDbClearing(DBProperties dbClearing) {
|
||||
this.dbClearing = dbClearing;
|
||||
}
|
||||
|
||||
public PeriodProperties getPeriod() {
|
||||
return period;
|
||||
}
|
||||
|
||||
public void setPeriod(PeriodProperties period) {
|
||||
this.period = period;
|
||||
}
|
||||
|
||||
public String getOutFolder() {
|
||||
return outFolder;
|
||||
}
|
||||
|
||||
public void setOutFolder(String outFolder) {
|
||||
this.outFolder = outFolder;
|
||||
}
|
||||
|
||||
public ReportsStore getReportsStore() {
|
||||
return reportsStore;
|
||||
}
|
||||
|
||||
public void setReportsStore(ReportsStore reportsStore) {
|
||||
this.reportsStore = reportsStore;
|
||||
}
|
||||
|
||||
public KafkaConsumerSettings getKafkaConsumer() {
|
||||
return kafkaConsumer;
|
||||
}
|
||||
|
||||
public void setKafkaConsumer(KafkaConsumerSettings kafkaConsumer) {
|
||||
this.kafkaConsumer = kafkaConsumer;
|
||||
}
|
||||
|
||||
public KafkaProducerSettings getKafkaProducer() {
|
||||
return kafkaProducer;
|
||||
}
|
||||
|
||||
public void setKafkaProducer(KafkaProducerSettings kafkaProducer) {
|
||||
this.kafkaProducer = kafkaProducer;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package ru.spcex.clearing.registry.conf.properties;
|
||||
|
||||
public class DBProperties {
|
||||
private String url;
|
||||
private String driver;
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getDriver() {
|
||||
return driver;
|
||||
}
|
||||
|
||||
public void setDriver(String driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package ru.spcex.clearing.registry.conf.properties;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "registry-service.dev")
|
||||
@PropertySource(value = "classpath:dev.properties")
|
||||
public class DevProperties {
|
||||
private int c3p0MinPoolSize;
|
||||
private int c3p0MaxPoolSize;
|
||||
private int c3p0InitialPoolSize;
|
||||
private int c3p0AcquireIncrement;
|
||||
|
||||
|
||||
public int getC3p0MinPoolSize() {
|
||||
return c3p0MinPoolSize;
|
||||
}
|
||||
|
||||
public void setC3p0MinPoolSize(int c3p0MinPoolSize) {
|
||||
this.c3p0MinPoolSize = c3p0MinPoolSize;
|
||||
}
|
||||
|
||||
public int getC3p0MaxPoolSize() {
|
||||
return c3p0MaxPoolSize;
|
||||
}
|
||||
|
||||
public void setC3p0MaxPoolSize(int c3p0MaxPoolSize) {
|
||||
this.c3p0MaxPoolSize = c3p0MaxPoolSize;
|
||||
}
|
||||
|
||||
public int getC3p0InitialPoolSize() {
|
||||
return c3p0InitialPoolSize;
|
||||
}
|
||||
|
||||
public void setC3p0InitialPoolSize(int c3p0InitialPoolSize) {
|
||||
this.c3p0InitialPoolSize = c3p0InitialPoolSize;
|
||||
}
|
||||
|
||||
public int getC3p0AcquireIncrement() {
|
||||
return c3p0AcquireIncrement;
|
||||
}
|
||||
|
||||
public void setC3p0AcquireIncrement(int c3p0AcquireIncrement) {
|
||||
this.c3p0AcquireIncrement = c3p0AcquireIncrement;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package ru.spcex.clearing.registry.conf.properties;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class PeriodProperties {
|
||||
private LocalDate startDate;
|
||||
private LocalDate endDate;
|
||||
|
||||
public LocalDate getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(LocalDate startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public LocalDate getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(LocalDate endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[startDate=" + startDate + ", endDate=" + endDate + "]";
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package ru.spcex.clearing.registry.config.settings;
|
||||
package ru.spcex.clearing.registry.conf.properties;
|
||||
|
||||
public class ReportsStore {
|
||||
private String outDir;
|
||||
private String localTempDir;
|
||||
// private String localTempDir;
|
||||
private String user;
|
||||
private String password;
|
||||
private String serverIp;
|
||||
|
|
@ -58,11 +58,4 @@ public class ReportsStore {
|
|||
this.outDir = outDir;
|
||||
}
|
||||
|
||||
public String getLocalTempDir() {
|
||||
return localTempDir;
|
||||
}
|
||||
|
||||
public void setLocalTempDir(String localTempDir) {
|
||||
this.localTempDir = localTempDir;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
package ru.spcex.clearing.registry.config;
|
||||
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import ru.spcex.clearing.platform.messaging.config.KafkaConsumerFactory;
|
||||
import ru.spcex.clearing.platform.messaging.config.KafkaProducerFactory;
|
||||
import ru.spcex.clearing.registry.config.settings.RegistryServiceSettings;
|
||||
|
||||
@Configuration
|
||||
public class KafkaConfig {
|
||||
@Autowired
|
||||
@Bean
|
||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public Consumer<String, Object> createConsumer(RegistryServiceSettings settings) {
|
||||
return KafkaConsumerFactory.consumer(settings.getKafkaConsumer());
|
||||
}
|
||||
|
||||
@Autowired
|
||||
@Bean
|
||||
public Producer<String, Object> createProducer(RegistryServiceSettings settings) {
|
||||
return KafkaProducerFactory.producer(settings.getKafkaProducer());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
package ru.spcex.clearing.registry.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.spcex.clearing.registry.config.settings.RegistryServiceSettings;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@Configuration
|
||||
public class RegistryServiceConfig {
|
||||
@Bean("reportOutDir")
|
||||
public File outDir(RegistryServiceSettings settings) {
|
||||
File outFolder = new File(settings.getReportsStore().getLocalTempDir());
|
||||
if (!outFolder.exists()) {
|
||||
boolean mkDirOk = outFolder.mkdirs();
|
||||
if (!mkDirOk) throw new IllegalStateException("Can't create output directory for reports, registry-service was terminated");
|
||||
} else if (!outFolder.isDirectory()) {
|
||||
throw new IllegalStateException("Output reports path from settings is not directory!");
|
||||
}
|
||||
return outFolder;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
package ru.spcex.clearing.registry.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import ru.spcex.clearing.registry.config.settings.RegistryServiceSettings;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
||||
|
||||
@Configuration
|
||||
public class RegistryServiceImdgConfig {
|
||||
private static ThreadPoolTaskExecutor createThreadPoolTaskExecutor(int maxPoolSz, boolean waitForCompletion) {
|
||||
ThreadPoolTaskExecutor pool = new ThreadPoolTaskExecutor();
|
||||
if (maxPoolSz > 2) {
|
||||
pool.setKeepAliveSeconds(60);
|
||||
pool.setAllowCoreThreadTimeOut(true);
|
||||
}
|
||||
pool.setCorePoolSize(maxPoolSz);
|
||||
pool.setWaitForTasksToCompleteOnShutdown(waitForCompletion);
|
||||
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,
|
||||
RegistryServiceSettings settings
|
||||
) {
|
||||
return new HazelcastService(taskExecutorHazelcastClientInitializer,
|
||||
taskExecutorIdGeneratorAwaiter,
|
||||
settings.getHazelcast());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,104 +0,0 @@
|
|||
package ru.spcex.clearing.registry.config;
|
||||
|
||||
import com.jcraft.jsch.ChannelSftp;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.expression.common.LiteralExpression;
|
||||
import org.springframework.integration.annotation.Gateway;
|
||||
import org.springframework.integration.annotation.MessagingGateway;
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.file.remote.session.CachingSessionFactory;
|
||||
import org.springframework.integration.file.remote.session.SessionFactory;
|
||||
import org.springframework.integration.sftp.gateway.SftpOutboundGateway;
|
||||
import org.springframework.integration.sftp.outbound.SftpMessageHandler;
|
||||
import org.springframework.integration.sftp.session.DefaultSftpSessionFactory;
|
||||
import org.springframework.integration.sftp.session.SftpFileInfo;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import ru.spcex.clearing.registry.config.settings.RegistryServiceSettings;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import static org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway.Command.LS;
|
||||
|
||||
@Configuration
|
||||
public class SFTPReportsConfig {
|
||||
protected Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final RegistryServiceSettings settings;
|
||||
|
||||
public SFTPReportsConfig(RegistryServiceSettings settings) {
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@Bean("reportsSftpSessionFactory")
|
||||
public SessionFactory<ChannelSftp.LsEntry> sftpSessionFactory() {
|
||||
DefaultSftpSessionFactory factory = new DefaultSftpSessionFactory(true);
|
||||
factory.setHost(settings.getReportsStore().getServerIp());
|
||||
factory.setPort(settings.getReportsStore().getServerPort());
|
||||
factory.setUser(settings.getReportsStore().getUser());
|
||||
factory.setPassword(settings.getReportsStore().getPassword());
|
||||
factory.setAllowUnknownKeys(true);
|
||||
return new CachingSessionFactory<>(factory);
|
||||
}
|
||||
|
||||
@Bean("reportsSftpHandler")
|
||||
@ServiceActivator(inputChannel = "reportsToSftpChannel")
|
||||
public MessageHandler handler(@Qualifier("reportsSftpSessionFactory") SessionFactory<ChannelSftp.LsEntry> sessionFactory) {
|
||||
SftpMessageHandler handler = new SftpMessageHandler(sessionFactory);
|
||||
handler.setRemoteDirectoryExpression(new LiteralExpression(settings.getReportsStore().getOutDir()));
|
||||
log.info("Configure sftp output directory \"{}\"", settings.getReportsStore().getOutDir());
|
||||
handler.setAutoCreateDirectory(true);
|
||||
handler.setFileNameGenerator(message -> {
|
||||
if (message.getPayload() instanceof File) {
|
||||
return ((File) message.getPayload()).getName();
|
||||
} else {
|
||||
throw new IllegalArgumentException("File must expected as payload.");
|
||||
}
|
||||
});
|
||||
return handler;
|
||||
}
|
||||
|
||||
@Bean("reportsListSftpChannel")
|
||||
public MessageChannel listSftpChannel(@Qualifier("reportsSftpHandlerList") MessageHandler handler) {
|
||||
DirectChannel dc = new DirectChannel();
|
||||
dc.subscribe(handler);
|
||||
return dc;
|
||||
}
|
||||
|
||||
@Bean("reportsToSftpChannel")
|
||||
public MessageChannel toSftpChannel(@Qualifier("reportsSftpHandler") MessageHandler handler) {
|
||||
DirectChannel dc = new DirectChannel();
|
||||
dc.subscribe(handler);
|
||||
return dc;
|
||||
}
|
||||
|
||||
@Bean("reportsSftpHandlerList")
|
||||
@ServiceActivator(inputChannel = "reportsListSftpChannel")
|
||||
public MessageHandler handlerList(@Qualifier("reportsSftpSessionFactory") SessionFactory<ChannelSftp.LsEntry> sessionFactory) {
|
||||
String expression = "'/%s'".formatted(settings.getReportsStore().getOutDir());
|
||||
return new SftpOutboundGateway(sessionFactory, LS.getCommand(), expression);
|
||||
}
|
||||
|
||||
@Bean("reportsSftpOutboundListFlow")
|
||||
public IntegrationFlow sftpOutboundListFlow(@Qualifier("reportsSftpSessionFactory") SessionFactory<ChannelSftp.LsEntry> sessionFactory) {
|
||||
return IntegrationFlows.from("reportsListSftpChannel")
|
||||
.handle(new SftpOutboundGateway(sessionFactory, "ls", "payload"))
|
||||
.get();
|
||||
}
|
||||
|
||||
@MessagingGateway(name = "reportsSftpGateway")
|
||||
public interface ReportsGateway {
|
||||
@Gateway(requestChannel = "reportsToSftpChannel")
|
||||
void sendToSftp(File file);
|
||||
|
||||
@Gateway(requestChannel = "reportsListSftpChannel")
|
||||
List<SftpFileInfo> listFiles(String dir);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
package ru.spcex.clearing.registry.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.spcex.clearing.registry.validation.ValuesOfMapNonNullRule;
|
||||
import ru.spcex.platform.imdg.validation.ImdgValidationContext;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
import ru.spcex.platform.utils.validation.ValidatorImpl;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Configuration
|
||||
public class ValidationConfig {
|
||||
|
||||
@Bean("fieldValuesValidator")
|
||||
public Function<Map<String, ?>, IValidator> fieldValuesValidator() {
|
||||
return map -> {
|
||||
ImdgValidationContext<Map<String, ?>> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(map);
|
||||
return new ValidatorImpl<>(context,
|
||||
new ValuesOfMapNonNullRule()
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
package ru.spcex.clearing.registry.config.settings;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.stereotype.Component;
|
||||
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;
|
||||
|
||||
@Component
|
||||
@PropertySource("file:${spring.config.location}/application.properties")
|
||||
@ConfigurationProperties("registry-service")
|
||||
public class RegistryServiceSettings {
|
||||
private HazelcastClientParams hazelcast;
|
||||
private KafkaConsumerSettings kafkaConsumer;
|
||||
private KafkaProducerSettings kafkaProducer;
|
||||
private ReportsStore reportsStore;
|
||||
private boolean csvMode = false;
|
||||
|
||||
public HazelcastClientParams getHazelcast() {
|
||||
return hazelcast;
|
||||
}
|
||||
|
||||
public void setHazelcast(HazelcastClientParams hazelcast) {
|
||||
this.hazelcast = hazelcast;
|
||||
}
|
||||
|
||||
public KafkaConsumerSettings getKafkaConsumer() {
|
||||
return kafkaConsumer;
|
||||
}
|
||||
|
||||
public void setKafkaConsumer(KafkaConsumerSettings kafkaConsumer) {
|
||||
this.kafkaConsumer = kafkaConsumer;
|
||||
}
|
||||
|
||||
public KafkaProducerSettings getKafkaProducer() {
|
||||
return kafkaProducer;
|
||||
}
|
||||
|
||||
public void setKafkaProducer(KafkaProducerSettings kafkaProducer) {
|
||||
this.kafkaProducer = kafkaProducer;
|
||||
}
|
||||
|
||||
public ReportsStore getReportsStore() {
|
||||
return reportsStore;
|
||||
}
|
||||
|
||||
public void setReportsStore(ReportsStore reportsStore) {
|
||||
this.reportsStore = reportsStore;
|
||||
}
|
||||
|
||||
public boolean isCsvMode() {
|
||||
return csvMode;
|
||||
}
|
||||
|
||||
public void setCsvMode(boolean csvMode) {
|
||||
this.csvMode = csvMode;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package ru.spcex.clearing.registry.exceptions;
|
||||
|
||||
public class CmdArgsParserException extends RuntimeException {
|
||||
public CmdArgsParserException(String message) {
|
||||
super(message);
|
||||
}
|
||||
public CmdArgsParserException() {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package ru.spcex.clearing.registry.exceptions;
|
||||
|
||||
public class ConfigurationException extends RuntimeException {
|
||||
public ConfigurationException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,17 +2,38 @@ package ru.spcex.clearing.registry.reports;
|
|||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import ru.spcex.clearing.registry.config.SFTPReportsConfig;
|
||||
import ru.spcex.clearing.registry.conf.SFTPReportsConfig;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.Date;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Collection;
|
||||
|
||||
public class ReportUtils {
|
||||
private final static Logger log = LoggerFactory.getLogger(ReportUtils.class);
|
||||
|
||||
public static Instant getInstantFromTimestamp(ResultSet rs, String column) throws SQLException {
|
||||
Timestamp date = rs.getTimestamp(column);
|
||||
return date != null ? date.toInstant() : null;
|
||||
}
|
||||
|
||||
public static LocalDate getLocalDateFromSqlDate(ResultSet rs, String column) throws SQLException {
|
||||
Date date = rs.getDate(column);
|
||||
return date != null ? date.toLocalDate() : null;
|
||||
}
|
||||
|
||||
public static void sendFilesToSftp(Collection<File> files,
|
||||
SFTPReportsConfig.ReportsGateway reportsGateway,
|
||||
boolean deleteAfterSend) {
|
||||
if (reportsGateway == null) {
|
||||
log.debug("SFTP disabled. Do not send files.");
|
||||
return;
|
||||
}
|
||||
log.debug("Send file {} to SFTP...", files);
|
||||
for (File file : files) {
|
||||
reportsGateway.sendToSftp(file);
|
||||
if (deleteAfterSend) {
|
||||
|
|
@ -23,6 +44,4 @@ public class ReportUtils {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
|
||||
public abstract class AbstractDictionary extends SpcexDBBase implements Dictionary {
|
||||
protected String code;
|
||||
protected String name;
|
||||
|
||||
@Override
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + "{" +
|
||||
"id=" + id +
|
||||
", code='" + code + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
|
||||
public class Account {
|
||||
private Long id;
|
||||
private String account;
|
||||
private String accountType;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAccountType() {
|
||||
return accountType;
|
||||
}
|
||||
|
||||
public void setAccountType(String accountType) {
|
||||
this.accountType = accountType;
|
||||
}
|
||||
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(String account) {
|
||||
this.account = account;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
|
||||
/**
|
||||
* Database table: ALLOWED_DICTIONARY
|
||||
*/
|
||||
public class AllowedDictionary extends AbstractDictionary {
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
public abstract class BusinessEvent<T extends SpcexDBBase> extends SpcexDBBase {
|
||||
|
||||
private Instant eventTime;
|
||||
private Long userId;
|
||||
private String eventType;
|
||||
|
||||
public Instant getEventTime() {
|
||||
return eventTime;
|
||||
}
|
||||
|
||||
public void setEventTime(Instant eventTime) {
|
||||
this.eventTime = eventTime;
|
||||
}
|
||||
|
||||
public String getEventType() {
|
||||
return eventType;
|
||||
}
|
||||
|
||||
public void setEventType(String eventType) {
|
||||
this.eventType = eventType;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public abstract T getObject();
|
||||
|
||||
public abstract void setObject(T object);
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + "{" +
|
||||
"eventTime=" + eventTime +
|
||||
"eventType=" + eventType +
|
||||
", userId=" + userId +
|
||||
", object=" + getObject() +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* UUID - Long based with field object
|
||||
*/
|
||||
public abstract class BusinessObject extends SpcexDBBase {
|
||||
private Instant created;
|
||||
private Instant updated;
|
||||
|
||||
public Instant getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(Instant created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public Instant getUpdated() {
|
||||
return updated;
|
||||
}
|
||||
|
||||
public void setUpdated(Instant updated) {
|
||||
this.updated = updated;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
|
||||
public class Company {
|
||||
private Long id;
|
||||
private String clearingCode;
|
||||
private String shortName;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getClearingCode() {
|
||||
return clearingCode;
|
||||
}
|
||||
|
||||
public void setClearingCode(String clearingCode) {
|
||||
this.clearingCode = clearingCode;
|
||||
}
|
||||
|
||||
public String getShortName() {
|
||||
return shortName;
|
||||
}
|
||||
|
||||
public void setShortName(String shortName) {
|
||||
this.shortName = shortName;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.IEnumKey;
|
||||
|
||||
public enum CompanySymbol implements IEnumKey {
|
||||
OCVD("OCVD"),
|
||||
CPP("CPP"),
|
||||
OCPO("OCPO"),
|
||||
OGRN("OGRN"),
|
||||
INN("INN"),
|
||||
BIC("BIC"),
|
||||
CIO("CIO"),
|
||||
UUID("UUID"),
|
||||
TRDC("TRDC"),
|
||||
CLRC("CLRC"),
|
||||
INTC("INTC"),
|
||||
RGRC("RGRC"),
|
||||
LICB("LICB"),
|
||||
LICR("LICR"),
|
||||
LICD("LICD"),
|
||||
LICT("LICT"),
|
||||
LICC("LICC"),
|
||||
LICF("LICF"),
|
||||
;
|
||||
|
||||
private final String key;
|
||||
|
||||
CompanySymbol(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
|
||||
/**
|
||||
* DB: COMPANY_SYMBOLS
|
||||
*/
|
||||
public class CompanySymbols extends SpcexDBBase {
|
||||
private Long companyId;
|
||||
private String companySymbol;
|
||||
private String companySymbolValue;
|
||||
|
||||
public Long getCompanyId() {
|
||||
return companyId;
|
||||
}
|
||||
|
||||
public void setCompanyId(Long companyId) {
|
||||
this.companyId = companyId;
|
||||
}
|
||||
|
||||
public String getCompanySymbol() {
|
||||
return companySymbol;
|
||||
}
|
||||
|
||||
public void setCompanySymbol(String companySymbol) {
|
||||
this.companySymbol = companySymbol;
|
||||
}
|
||||
|
||||
public String getCompanySymbolValue() {
|
||||
return companySymbolValue;
|
||||
}
|
||||
|
||||
public void setCompanySymbolValue(String companySymbolValue) {
|
||||
this.companySymbolValue = companySymbolValue;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Словарь.
|
||||
*/
|
||||
public interface Dictionary extends Serializable {
|
||||
|
||||
Long getId();
|
||||
|
||||
void setId(Long id);
|
||||
|
||||
String getCode();
|
||||
|
||||
void setCode(String code);
|
||||
|
||||
String getName();
|
||||
|
||||
void setName(String name);
|
||||
}
|
||||
|
|
@ -0,0 +1,320 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
|
||||
public abstract class ExecutionCommon extends BusinessObject {
|
||||
protected Long exchangeExecutionId;
|
||||
protected Instant exchangeExecutionTime;
|
||||
protected LocalDate tradingDate;
|
||||
protected Long tradingClearingRegistryId;
|
||||
protected String partyTradingClearingRegistry;
|
||||
protected String counterPartyTradingClearingRegistry;
|
||||
protected String market;
|
||||
protected BigDecimal price;
|
||||
protected BigDecimal lots;
|
||||
protected BigDecimal quantity;
|
||||
protected BigDecimal interestAmount;
|
||||
protected String side;
|
||||
protected String settlementCurrency;
|
||||
protected Long companyId;
|
||||
protected Long duration;
|
||||
protected String securityFullName;
|
||||
protected String securitySymbol;
|
||||
protected Long securityId;
|
||||
protected Long counterPartyId;
|
||||
protected String coverageStatus;
|
||||
protected Long sessionId;
|
||||
protected LocalDate clearingDate;
|
||||
protected Long counterPartyTradingClearingRegistryId;
|
||||
|
||||
// No DB fields
|
||||
private String sellerTkrCode;
|
||||
private String buyerTkrCode;
|
||||
private String counterPartyIdFromCompany;
|
||||
private String companyIdFromCompany;
|
||||
|
||||
private String buyerCode;
|
||||
private String sellerCode;
|
||||
private String buyer;
|
||||
private String seller;
|
||||
|
||||
private String status;
|
||||
|
||||
|
||||
public abstract ExecutionType type();
|
||||
|
||||
public LocalDate getClearingDate() {
|
||||
return clearingDate;
|
||||
}
|
||||
|
||||
public void setClearingDate(LocalDate value) {
|
||||
this.clearingDate = value;
|
||||
}
|
||||
|
||||
public Long getExchangeExecutionId() {
|
||||
return exchangeExecutionId;
|
||||
}
|
||||
|
||||
public void setExchangeExecutionId(Long value) {
|
||||
this.exchangeExecutionId = value;
|
||||
}
|
||||
|
||||
public String getSide() {
|
||||
return side;
|
||||
}
|
||||
|
||||
public void setSide(String value) {
|
||||
this.side = value;
|
||||
}
|
||||
|
||||
public String getMarket() {
|
||||
return market;
|
||||
}
|
||||
|
||||
public void setMarket(String value) {
|
||||
this.market = value;
|
||||
}
|
||||
|
||||
public LocalDate getTradingDate() {
|
||||
return tradingDate;
|
||||
}
|
||||
|
||||
public void setTradingDate(LocalDate value) {
|
||||
this.tradingDate = value;
|
||||
}
|
||||
|
||||
public String getSecuritySymbol() {
|
||||
return securitySymbol;
|
||||
}
|
||||
|
||||
public void setSecuritySymbol(String value) {
|
||||
this.securitySymbol = value;
|
||||
}
|
||||
|
||||
public Long getSecurityId() {
|
||||
return securityId;
|
||||
}
|
||||
|
||||
public void setSecurityId(Long value) {
|
||||
this.securityId = value;
|
||||
}
|
||||
|
||||
public BigDecimal getInterestAmount() {
|
||||
return interestAmount;
|
||||
}
|
||||
|
||||
public void setInterestAmount(BigDecimal value) {
|
||||
this.interestAmount = value;
|
||||
}
|
||||
|
||||
public BigDecimal getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(BigDecimal value) {
|
||||
this.price = value;
|
||||
}
|
||||
|
||||
public BigDecimal getLots() {
|
||||
return lots;
|
||||
}
|
||||
|
||||
public void setLots(BigDecimal value) {
|
||||
this.lots = value;
|
||||
}
|
||||
|
||||
public BigDecimal getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public void setQuantity(BigDecimal value) {
|
||||
this.quantity = value;
|
||||
}
|
||||
|
||||
public Instant getExchangeExecutionTime() {
|
||||
return exchangeExecutionTime;
|
||||
}
|
||||
|
||||
public void setExchangeExecutionTime(Instant value) {
|
||||
this.exchangeExecutionTime = value;
|
||||
}
|
||||
|
||||
public Long getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(Long value) {
|
||||
this.duration = value;
|
||||
}
|
||||
|
||||
public Long getTradingClearingRegistryId() {
|
||||
return tradingClearingRegistryId;
|
||||
}
|
||||
|
||||
public void setTradingClearingRegistryId(Long value) {
|
||||
this.tradingClearingRegistryId = value;
|
||||
}
|
||||
|
||||
public String getPartyTradingClearingRegistry() {
|
||||
return partyTradingClearingRegistry;
|
||||
}
|
||||
|
||||
public void setPartyTradingClearingRegistry(String partyTradingClearingRegistry) {
|
||||
this.partyTradingClearingRegistry = partyTradingClearingRegistry;
|
||||
}
|
||||
|
||||
public String getCounterPartyTradingClearingRegistry() {
|
||||
return counterPartyTradingClearingRegistry;
|
||||
}
|
||||
|
||||
public void setCounterPartyTradingClearingRegistry(String counterPartyTradingClearingRegistry) {
|
||||
this.counterPartyTradingClearingRegistry = counterPartyTradingClearingRegistry;
|
||||
}
|
||||
|
||||
public Long getCompanyId() {
|
||||
return companyId;
|
||||
}
|
||||
|
||||
public void setCompanyId(Long value) {
|
||||
this.companyId = value;
|
||||
}
|
||||
|
||||
public Long getCounterPartyId() {
|
||||
return counterPartyId;
|
||||
}
|
||||
|
||||
public void setCounterPartyId(Long value) {
|
||||
this.counterPartyId = value;
|
||||
}
|
||||
|
||||
public String getSecurityFullName() {
|
||||
return securityFullName;
|
||||
}
|
||||
|
||||
public void setSecurityFullName(String value) {
|
||||
this.securityFullName = value;
|
||||
}
|
||||
|
||||
public String getSettlementCurrency() {
|
||||
return settlementCurrency;
|
||||
}
|
||||
|
||||
public void setSettlementCurrency(String value) {
|
||||
this.settlementCurrency = value;
|
||||
}
|
||||
|
||||
public String getCoverageStatus() {
|
||||
return coverageStatus;
|
||||
}
|
||||
|
||||
public void setCoverageStatus(String value) {
|
||||
this.coverageStatus = value;
|
||||
}
|
||||
|
||||
public Long getSessionId() {
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
public void setSessionId(Long value) {
|
||||
this.sessionId = value;
|
||||
}
|
||||
|
||||
public Long getCounterPartyTradingClearingRegistryId() {
|
||||
return counterPartyTradingClearingRegistryId;
|
||||
}
|
||||
|
||||
public void setCounterPartyTradingClearingRegistryId(Long counterPartyTradingClearingRegistryId) {
|
||||
this.counterPartyTradingClearingRegistryId = counterPartyTradingClearingRegistryId;
|
||||
}
|
||||
|
||||
public String getSellerTkrCode() {
|
||||
return sellerTkrCode;
|
||||
}
|
||||
|
||||
public void setSellerTkrCode(String sellerTkrCode) {
|
||||
this.sellerTkrCode = sellerTkrCode;
|
||||
}
|
||||
|
||||
public String getCounterPartyIdFromCompany() {
|
||||
return counterPartyIdFromCompany;
|
||||
}
|
||||
|
||||
public void setCounterPartyIdFromCompany(String counterPartyIdFromCompany) {
|
||||
this.counterPartyIdFromCompany = counterPartyIdFromCompany;
|
||||
}
|
||||
|
||||
public String getCompanyIdFromCompany() {
|
||||
return companyIdFromCompany;
|
||||
}
|
||||
|
||||
public void setCompanyIdFromCompany(String companyIdFromCompany) {
|
||||
this.companyIdFromCompany = companyIdFromCompany;
|
||||
}
|
||||
|
||||
public String getBuyerCode() {
|
||||
return buyerCode;
|
||||
}
|
||||
|
||||
public void setBuyerCode(String buyerCode) {
|
||||
this.buyerCode = buyerCode;
|
||||
}
|
||||
|
||||
public String getSellerCode() {
|
||||
return sellerCode;
|
||||
}
|
||||
|
||||
public void setSellerCode(String sellerCode) {
|
||||
this.sellerCode = sellerCode;
|
||||
}
|
||||
|
||||
public String getBuyer() {
|
||||
return buyer;
|
||||
}
|
||||
|
||||
public void setBuyer(String buyer) {
|
||||
this.buyer = buyer;
|
||||
}
|
||||
|
||||
public String getSeller() {
|
||||
return seller;
|
||||
}
|
||||
|
||||
public void setSeller(String seller) {
|
||||
this.seller = seller;
|
||||
}
|
||||
|
||||
public String getBuyerTkrCode() {
|
||||
return buyerTkrCode;
|
||||
}
|
||||
|
||||
public void setBuyerTkrCode(String buyerTkrCode) {
|
||||
this.buyerTkrCode = buyerTkrCode;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ExecutionCommon that = (ExecutionCommon) o;
|
||||
|
||||
return getExchangeExecutionId() != null ? getExchangeExecutionId().equals(that.getExchangeExecutionId()) : that.getExchangeExecutionId() == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 1;
|
||||
result = 31 * result + (getExchangeExecutionId() != null ? getExchangeExecutionId().hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
|
||||
import ru.spcex.clearing.registry.reports.loaders.IDBObject;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class ExecutionDeposit extends ExecutionCommon implements IDBObject {
|
||||
private BigDecimal firstLegAmount;
|
||||
private BigDecimal secondLegAmount;
|
||||
private LocalDate firstLegSettlementDate;
|
||||
private LocalDate secondLegSettlementDate;
|
||||
private String firstLegSettlementCode;
|
||||
private String secondLegSettlementCode;
|
||||
private String contract;
|
||||
private String securityCode;
|
||||
|
||||
@Override
|
||||
public ExecutionType type() {
|
||||
return ExecutionType.ExecutionDeposit;
|
||||
}
|
||||
|
||||
public BigDecimal getFirstLegAmount() {
|
||||
return firstLegAmount;
|
||||
}
|
||||
|
||||
public void setFirstLegAmount(BigDecimal firstLegAmount) {
|
||||
this.firstLegAmount = firstLegAmount;
|
||||
}
|
||||
|
||||
public BigDecimal getSecondLegAmount() {
|
||||
return secondLegAmount;
|
||||
}
|
||||
|
||||
public void setSecondLegAmount(BigDecimal secondLegAmount) {
|
||||
this.secondLegAmount = secondLegAmount;
|
||||
}
|
||||
|
||||
public LocalDate getFirstLegSettlementDate() {
|
||||
return firstLegSettlementDate;
|
||||
}
|
||||
|
||||
public void setFirstLegSettlementDate(LocalDate firstLegSettlementDate) {
|
||||
this.firstLegSettlementDate = firstLegSettlementDate;
|
||||
}
|
||||
|
||||
public LocalDate getSecondLegSettlementDate() {
|
||||
return secondLegSettlementDate;
|
||||
}
|
||||
|
||||
public void setSecondLegSettlementDate(LocalDate secondLegSettlementDate) {
|
||||
this.secondLegSettlementDate = secondLegSettlementDate;
|
||||
}
|
||||
|
||||
public String getFirstLegSettlementCode() {
|
||||
return firstLegSettlementCode;
|
||||
}
|
||||
|
||||
public void setFirstLegSettlementCode(String firstLegSettlementCode) {
|
||||
this.firstLegSettlementCode = firstLegSettlementCode;
|
||||
}
|
||||
|
||||
public String getSecondLegSettlementCode() {
|
||||
return secondLegSettlementCode;
|
||||
}
|
||||
|
||||
public void setSecondLegSettlementCode(String secondLegSettlementCode) {
|
||||
this.secondLegSettlementCode = secondLegSettlementCode;
|
||||
}
|
||||
|
||||
public String getContract() {
|
||||
return contract;
|
||||
}
|
||||
|
||||
public void setContract(String contract) {
|
||||
this.contract = contract;
|
||||
}
|
||||
|
||||
public String getSecurityCode() {
|
||||
return securityCode;
|
||||
}
|
||||
|
||||
public void setSecurityCode(String securityCode) {
|
||||
this.securityCode = securityCode;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
|
||||
import ru.spcex.clearing.registry.reports.loaders.IDBObject;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class ExecutionFond extends ExecutionCommon implements IDBObject {
|
||||
private Long exchangeOrderId;
|
||||
private BigDecimal settlementAmount;
|
||||
private String comment;
|
||||
private Long clientCodeId;
|
||||
private String settlementCode;
|
||||
private LocalDate settlementDate;
|
||||
private Instant exchangeExecutionMicroseconds;
|
||||
|
||||
@Override
|
||||
public ExecutionType type() {
|
||||
return ExecutionType.ExecutionFond;
|
||||
}
|
||||
|
||||
public Long getExchangeOrderId() {
|
||||
return exchangeOrderId;
|
||||
}
|
||||
|
||||
public void setExchangeOrderId(Long exchangeOrderId) {
|
||||
this.exchangeOrderId = exchangeOrderId;
|
||||
}
|
||||
|
||||
public BigDecimal getSettlementAmount() {
|
||||
return settlementAmount;
|
||||
}
|
||||
|
||||
public void setSettlementAmount(BigDecimal settlementAmount) {
|
||||
this.settlementAmount = settlementAmount;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public Long getClientCodeId() {
|
||||
return clientCodeId;
|
||||
}
|
||||
|
||||
public void setClientCodeId(Long clientCodeId) {
|
||||
this.clientCodeId = clientCodeId;
|
||||
}
|
||||
|
||||
public String getSettlementCode() {
|
||||
return settlementCode;
|
||||
}
|
||||
|
||||
public void setSettlementCode(String settlementCode) {
|
||||
this.settlementCode = settlementCode;
|
||||
}
|
||||
|
||||
public LocalDate getSettlementDate() {
|
||||
return settlementDate;
|
||||
}
|
||||
|
||||
public void setSettlementDate(LocalDate settlementDate) {
|
||||
this.settlementDate = settlementDate;
|
||||
}
|
||||
|
||||
public Instant getExchangeExecutionMicroseconds() {
|
||||
return exchangeExecutionMicroseconds;
|
||||
}
|
||||
|
||||
public void setExchangeExecutionMicroseconds(Instant exchangeExecutionMicroseconds) {
|
||||
this.exchangeExecutionMicroseconds = exchangeExecutionMicroseconds;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
|
||||
public enum ExecutionType {
|
||||
ExecutionDeposit, ExecutionFond;
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
|
||||
public interface FileReport {
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.IEnumKey;
|
||||
|
||||
public enum MoneyFlowSide implements IEnumKey {
|
||||
BUY("BUY"),
|
||||
SELL("SELL"),
|
||||
;
|
||||
|
||||
private final String key;
|
||||
|
||||
MoneyFlowSide(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
|
||||
public enum ObjectType {
|
||||
EXECUTION_FOND, EXECUTION_DEPOSIT, MONEY_PAYMENT_INSTRUCTION, DEPO_PAYMENT_INSTRUCTION, REGISTRY_HISTORY
|
||||
}
|
||||
|
|
@ -0,0 +1,360 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
|
||||
import ru.spcex.clearing.registry.reports.loaders.IDBObject;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class PaymentInstruction extends BusinessObject implements IDBObject {
|
||||
private Long senderId;
|
||||
private Long addresseeId;
|
||||
private String payeeBic;
|
||||
private String addresseeBic;
|
||||
private String payeeBankName;
|
||||
private String addresseeBankName;
|
||||
private Instant paymentDate;
|
||||
private String paymentPurpose;
|
||||
private LocalDate settlementDate;
|
||||
private BigDecimal creditLeg_amount;
|
||||
private BigDecimal debitLeg_amount;
|
||||
private Long creditLeg_accountId;
|
||||
private String credit_csAccount;
|
||||
private String creditLeg_account;
|
||||
private Long debitLeg_accountId;
|
||||
private String debit_csAccount;
|
||||
private String debitLeg_account;
|
||||
private String creditLeg_direction;
|
||||
private String debitLeg_direction;
|
||||
private String creditLeg_currencyCode;
|
||||
private String debitLeg_currencyCode;
|
||||
private Long creditLeg_securityId;
|
||||
private Long debitLeg_securityId;
|
||||
private String transactionStatus;
|
||||
private String documentNumber;
|
||||
private LocalDate clearingDate;
|
||||
private Long sessionId;
|
||||
|
||||
// No DB fields (for depoInstruction)
|
||||
private String creditLegAccountStr;
|
||||
private String debitLegAccountStr;
|
||||
private String senderCompanyShortName;
|
||||
private String senderCompanyClearingCode;
|
||||
private String addresseeCompanyShortName;
|
||||
private String addresseeCompanyClearingCode;
|
||||
|
||||
// No DB fields (for moneyInstruction)
|
||||
private String sender;
|
||||
private String senderClearingCode;
|
||||
private String addressee;
|
||||
private String addresseeClearingCode;
|
||||
|
||||
// No DB fields (for depoInstruction)
|
||||
private String security;
|
||||
|
||||
|
||||
|
||||
public Long getSenderId() {
|
||||
return senderId;
|
||||
}
|
||||
|
||||
public void setSenderId(Long senderId) {
|
||||
this.senderId = senderId;
|
||||
}
|
||||
|
||||
public Long getAddresseeId() {
|
||||
return addresseeId;
|
||||
}
|
||||
|
||||
public void setAddresseeId(Long addresseeId) {
|
||||
this.addresseeId = addresseeId;
|
||||
}
|
||||
|
||||
public String getPayeeBic() {
|
||||
return payeeBic;
|
||||
}
|
||||
|
||||
public void setPayeeBic(String payeeBic) {
|
||||
this.payeeBic = payeeBic;
|
||||
}
|
||||
|
||||
public String getAddresseeBic() {
|
||||
return addresseeBic;
|
||||
}
|
||||
|
||||
public void setAddresseeBic(String addresseeBic) {
|
||||
this.addresseeBic = addresseeBic;
|
||||
}
|
||||
|
||||
public String getPayeeBankName() {
|
||||
return payeeBankName;
|
||||
}
|
||||
|
||||
public void setPayeeBankName(String payeeBankName) {
|
||||
this.payeeBankName = payeeBankName;
|
||||
}
|
||||
|
||||
public String getAddresseeBankName() {
|
||||
return addresseeBankName;
|
||||
}
|
||||
|
||||
public void setAddresseeBankName(String addresseeBankName) {
|
||||
this.addresseeBankName = addresseeBankName;
|
||||
}
|
||||
|
||||
public Instant getPaymentDate() {
|
||||
return paymentDate;
|
||||
}
|
||||
|
||||
public void setPaymentDate(Instant paymentDate) {
|
||||
this.paymentDate = paymentDate;
|
||||
}
|
||||
|
||||
public String getPaymentPurpose() {
|
||||
return paymentPurpose;
|
||||
}
|
||||
|
||||
public void setPaymentPurpose(String paymentPurpose) {
|
||||
this.paymentPurpose = paymentPurpose;
|
||||
}
|
||||
|
||||
public LocalDate getSettlementDate() {
|
||||
return settlementDate;
|
||||
}
|
||||
|
||||
public void setSettlementDate(LocalDate settlementDate) {
|
||||
this.settlementDate = settlementDate;
|
||||
}
|
||||
|
||||
public BigDecimal getCreditLeg_amount() {
|
||||
return creditLeg_amount;
|
||||
}
|
||||
|
||||
public void setCreditLeg_amount(BigDecimal creditLeg_amount) {
|
||||
this.creditLeg_amount = creditLeg_amount;
|
||||
}
|
||||
|
||||
public BigDecimal getDebitLeg_amount() {
|
||||
return debitLeg_amount;
|
||||
}
|
||||
|
||||
public void setDebitLeg_amount(BigDecimal debitLeg_amount) {
|
||||
this.debitLeg_amount = debitLeg_amount;
|
||||
}
|
||||
|
||||
public Long getCreditLeg_accountId() {
|
||||
return creditLeg_accountId;
|
||||
}
|
||||
|
||||
public void setCreditLeg_accountId(Long creditLeg_accountId) {
|
||||
this.creditLeg_accountId = creditLeg_accountId;
|
||||
}
|
||||
|
||||
public String getCredit_csAccount() {
|
||||
return credit_csAccount;
|
||||
}
|
||||
|
||||
public void setCredit_csAccount(String credit_csAccount) {
|
||||
this.credit_csAccount = credit_csAccount;
|
||||
}
|
||||
|
||||
public String getCreditLeg_account() {
|
||||
return creditLeg_account;
|
||||
}
|
||||
|
||||
public void setCreditLeg_account(String creditLeg_account) {
|
||||
this.creditLeg_account = creditLeg_account;
|
||||
}
|
||||
|
||||
public Long getDebitLeg_accountId() {
|
||||
return debitLeg_accountId;
|
||||
}
|
||||
|
||||
public void setDebitLeg_accountId(Long debitLeg_accountId) {
|
||||
this.debitLeg_accountId = debitLeg_accountId;
|
||||
}
|
||||
|
||||
public String getDebit_csAccount() {
|
||||
return debit_csAccount;
|
||||
}
|
||||
|
||||
public void setDebit_csAccount(String debit_csAccount) {
|
||||
this.debit_csAccount = debit_csAccount;
|
||||
}
|
||||
|
||||
public String getDebitLeg_account() {
|
||||
return debitLeg_account;
|
||||
}
|
||||
|
||||
public void setDebitLeg_account(String debitLeg_account) {
|
||||
this.debitLeg_account = debitLeg_account;
|
||||
}
|
||||
|
||||
public String getCreditLeg_direction() {
|
||||
return creditLeg_direction;
|
||||
}
|
||||
|
||||
public void setCreditLeg_direction(String creditLeg_direction) {
|
||||
this.creditLeg_direction = creditLeg_direction;
|
||||
}
|
||||
|
||||
public String getDebitLeg_direction() {
|
||||
return debitLeg_direction;
|
||||
}
|
||||
|
||||
public void setDebitLeg_direction(String debitLeg_direction) {
|
||||
this.debitLeg_direction = debitLeg_direction;
|
||||
}
|
||||
|
||||
public String getCreditLeg_currencyCode() {
|
||||
return creditLeg_currencyCode;
|
||||
}
|
||||
|
||||
public void setCreditLeg_currencyCode(String creditLeg_currencyCode) {
|
||||
this.creditLeg_currencyCode = creditLeg_currencyCode;
|
||||
}
|
||||
|
||||
public String getDebitLeg_currencyCode() {
|
||||
return debitLeg_currencyCode;
|
||||
}
|
||||
|
||||
public void setDebitLeg_currencyCode(String debitLeg_currencyCode) {
|
||||
this.debitLeg_currencyCode = debitLeg_currencyCode;
|
||||
}
|
||||
|
||||
public Long getCreditLeg_securityId() {
|
||||
return creditLeg_securityId;
|
||||
}
|
||||
|
||||
public void setCreditLeg_securityId(Long creditLeg_securityId) {
|
||||
this.creditLeg_securityId = creditLeg_securityId;
|
||||
}
|
||||
|
||||
public Long getDebitLeg_securityId() {
|
||||
return debitLeg_securityId;
|
||||
}
|
||||
|
||||
public void setDebitLeg_securityId(Long debitLeg_securityId) {
|
||||
this.debitLeg_securityId = debitLeg_securityId;
|
||||
}
|
||||
|
||||
public String getTransactionStatus() {
|
||||
return transactionStatus;
|
||||
}
|
||||
|
||||
public void setTransactionStatus(String transactionStatus) {
|
||||
this.transactionStatus = transactionStatus;
|
||||
}
|
||||
|
||||
public String getDocumentNumber() {
|
||||
return documentNumber;
|
||||
}
|
||||
|
||||
public void setDocumentNumber(String documentNumber) {
|
||||
this.documentNumber = documentNumber;
|
||||
}
|
||||
|
||||
public LocalDate getClearingDate() {
|
||||
return clearingDate;
|
||||
}
|
||||
|
||||
public void setClearingDate(LocalDate clearingDate) {
|
||||
this.clearingDate = clearingDate;
|
||||
}
|
||||
|
||||
public Long getSessionId() {
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
public void setSessionId(Long sessionId) {
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
public String getCreditLegAccountStr() {
|
||||
return creditLegAccountStr;
|
||||
}
|
||||
|
||||
public void setCreditLegAccountStr(String creditLegAccountStr) {
|
||||
this.creditLegAccountStr = creditLegAccountStr;
|
||||
}
|
||||
|
||||
public String getDebitLegAccountStr() {
|
||||
return debitLegAccountStr;
|
||||
}
|
||||
|
||||
public void setDebitLegAccountStr(String debitLegAccountStr) {
|
||||
this.debitLegAccountStr = debitLegAccountStr;
|
||||
}
|
||||
|
||||
public String getSenderCompanyShortName() {
|
||||
return senderCompanyShortName;
|
||||
}
|
||||
|
||||
public void setSenderCompanyShortName(String senderCompanyShortName) {
|
||||
this.senderCompanyShortName = senderCompanyShortName;
|
||||
}
|
||||
|
||||
public String getSenderCompanyClearingCode() {
|
||||
return senderCompanyClearingCode;
|
||||
}
|
||||
|
||||
public void setSenderCompanyClearingCode(String senderCompanyClearingCode) {
|
||||
this.senderCompanyClearingCode = senderCompanyClearingCode;
|
||||
}
|
||||
|
||||
public String getAddresseeCompanyShortName() {
|
||||
return addresseeCompanyShortName;
|
||||
}
|
||||
|
||||
public void setAddresseeCompanyShortName(String addresseeCompanyShortName) {
|
||||
this.addresseeCompanyShortName = addresseeCompanyShortName;
|
||||
}
|
||||
|
||||
public String getAddresseeCompanyClearingCode() {
|
||||
return addresseeCompanyClearingCode;
|
||||
}
|
||||
|
||||
public void setAddresseeCompanyClearingCode(String addresseeCompanyClearingCode) {
|
||||
this.addresseeCompanyClearingCode = addresseeCompanyClearingCode;
|
||||
}
|
||||
|
||||
public String getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
public void setSender(String sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
public String getAddressee() {
|
||||
return addressee;
|
||||
}
|
||||
|
||||
public void setAddressee(String addressee) {
|
||||
this.addressee = addressee;
|
||||
}
|
||||
|
||||
public String getSenderClearingCode() {
|
||||
return senderClearingCode;
|
||||
}
|
||||
|
||||
public void setSenderClearingCode(String senderClearingCode) {
|
||||
this.senderClearingCode = senderClearingCode;
|
||||
}
|
||||
|
||||
public String getAddresseeClearingCode() {
|
||||
return addresseeClearingCode;
|
||||
}
|
||||
|
||||
public void setAddresseeClearingCode(String addresseeClearingCode) {
|
||||
this.addresseeClearingCode = addresseeClearingCode;
|
||||
}
|
||||
|
||||
public String getSecurity() {
|
||||
return security;
|
||||
}
|
||||
|
||||
public void setSecurity(String security) {
|
||||
this.security = security;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,430 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
|
||||
import ru.spcex.clearing.registry.reports.loaders.IDBObject;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class Registry extends BusinessObject implements IDBObject {
|
||||
private Long companyId;
|
||||
private String tradingCode;
|
||||
private String clearingCode;
|
||||
private String shortName;
|
||||
private String fullName;
|
||||
private Long accountId;
|
||||
private String accountType;
|
||||
private String account;
|
||||
private String registryDesignation;
|
||||
private String registryInstrumentType;
|
||||
private String registryCapacity;
|
||||
private String registryUnit;
|
||||
private String registryCode;
|
||||
private Long tradingClearingRegistryId;
|
||||
private String tradingClearingRegistry;
|
||||
private String registryStatus;
|
||||
private String registryStatus_dictionary;
|
||||
private Long securityId;
|
||||
private String securitySymbol;
|
||||
private BigDecimal balance;
|
||||
private BigDecimal openBalance;
|
||||
private BigDecimal closeBalance;
|
||||
private BigDecimal credit;
|
||||
private BigDecimal debit;
|
||||
private BigDecimal settledCredit;
|
||||
private BigDecimal settledDebit;
|
||||
private BigDecimal checkBalance;
|
||||
private BigDecimal diffBalance;
|
||||
private BigDecimal planBalance;
|
||||
private String balanceDimension;
|
||||
private LocalDate settlementDate;
|
||||
private String settlementCode;
|
||||
private LocalDate tradingDate;
|
||||
private LocalDate clearingDate;
|
||||
private LocalDate refundDate;
|
||||
private LocalDate valueDate;
|
||||
private BigDecimal price;
|
||||
private String contract;
|
||||
private Long counterPartyId;
|
||||
private String comment;
|
||||
private Long parentId;
|
||||
private Long groupId;
|
||||
private Long sessionId;
|
||||
private String sessionType;
|
||||
private String sessionType_dictionary;
|
||||
private Long paymentId;
|
||||
|
||||
public Long getCompanyId() {
|
||||
return companyId;
|
||||
}
|
||||
|
||||
public void setCompanyId(Long companyId) {
|
||||
this.companyId = companyId;
|
||||
}
|
||||
|
||||
public String getTradingCode() {
|
||||
return tradingCode;
|
||||
}
|
||||
|
||||
public void setTradingCode(String tradingCode) {
|
||||
this.tradingCode = tradingCode;
|
||||
}
|
||||
|
||||
public String getClearingCode() {
|
||||
return clearingCode;
|
||||
}
|
||||
|
||||
public void setClearingCode(String clearingCode) {
|
||||
this.clearingCode = clearingCode;
|
||||
}
|
||||
|
||||
public String getShortName() {
|
||||
return shortName;
|
||||
}
|
||||
|
||||
public void setShortName(String shortName) {
|
||||
this.shortName = shortName;
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
public void setFullName(String fullName) {
|
||||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
public Long getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public void setAccountId(Long accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
public String getAccountType() {
|
||||
return accountType;
|
||||
}
|
||||
|
||||
public void setAccountType(String accountType) {
|
||||
this.accountType = accountType;
|
||||
}
|
||||
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(String account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public String getRegistryDesignation() {
|
||||
return registryDesignation;
|
||||
}
|
||||
|
||||
public void setRegistryDesignation(String registryDesignation) {
|
||||
this.registryDesignation = registryDesignation;
|
||||
}
|
||||
|
||||
public String getRegistryInstrumentType() {
|
||||
return registryInstrumentType;
|
||||
}
|
||||
|
||||
public void setRegistryInstrumentType(String registryInstrumentType) {
|
||||
this.registryInstrumentType = registryInstrumentType;
|
||||
}
|
||||
|
||||
public String getRegistryCapacity() {
|
||||
return registryCapacity;
|
||||
}
|
||||
|
||||
public void setRegistryCapacity(String registryCapacity) {
|
||||
this.registryCapacity = registryCapacity;
|
||||
}
|
||||
|
||||
public String getRegistryUnit() {
|
||||
return registryUnit;
|
||||
}
|
||||
|
||||
public void setRegistryUnit(String registryUnit) {
|
||||
this.registryUnit = registryUnit;
|
||||
}
|
||||
|
||||
public String getRegistryCode() {
|
||||
return registryCode;
|
||||
}
|
||||
|
||||
public void setRegistryCode(String registryCode) {
|
||||
this.registryCode = registryCode;
|
||||
}
|
||||
|
||||
public Long getTradingClearingRegistryId() {
|
||||
return tradingClearingRegistryId;
|
||||
}
|
||||
|
||||
public void setTradingClearingRegistryId(Long tradingClearingRegistryId) {
|
||||
this.tradingClearingRegistryId = tradingClearingRegistryId;
|
||||
}
|
||||
|
||||
public String getTradingClearingRegistry() {
|
||||
return tradingClearingRegistry;
|
||||
}
|
||||
|
||||
public void setTradingClearingRegistry(String tradingClearingRegistry) {
|
||||
this.tradingClearingRegistry = tradingClearingRegistry;
|
||||
}
|
||||
|
||||
public String getRegistryStatus() {
|
||||
return registryStatus;
|
||||
}
|
||||
|
||||
public void setRegistryStatus(String registryStatus) {
|
||||
this.registryStatus = registryStatus;
|
||||
}
|
||||
|
||||
public String getRegistryStatus_dictionary() {
|
||||
return registryStatus_dictionary;
|
||||
}
|
||||
|
||||
public void setRegistryStatus_dictionary(String registryStatus_dictionary) {
|
||||
this.registryStatus_dictionary = registryStatus_dictionary;
|
||||
}
|
||||
|
||||
public Long getSecurityId() {
|
||||
return securityId;
|
||||
}
|
||||
|
||||
public void setSecurityId(Long securityId) {
|
||||
this.securityId = securityId;
|
||||
}
|
||||
|
||||
public String getSecuritySymbol() {
|
||||
return securitySymbol;
|
||||
}
|
||||
|
||||
public void setSecuritySymbol(String securitySymbol) {
|
||||
this.securitySymbol = securitySymbol;
|
||||
}
|
||||
|
||||
public BigDecimal getBalance() {
|
||||
if (balance == null) {
|
||||
balance = BigDecimal.ZERO;
|
||||
}
|
||||
return balance;
|
||||
}
|
||||
|
||||
public void setBalance(BigDecimal balance) {
|
||||
if (balance == null) {
|
||||
balance = BigDecimal.ZERO;
|
||||
}
|
||||
this.balance = balance;
|
||||
}
|
||||
|
||||
public BigDecimal getOpenBalance() {
|
||||
return openBalance;
|
||||
}
|
||||
|
||||
public void setOpenBalance(BigDecimal openBalance) {
|
||||
this.openBalance = openBalance;
|
||||
}
|
||||
|
||||
public BigDecimal getCloseBalance() {
|
||||
return closeBalance;
|
||||
}
|
||||
|
||||
public void setCloseBalance(BigDecimal closeBalance) {
|
||||
this.closeBalance = closeBalance;
|
||||
}
|
||||
|
||||
public BigDecimal getCredit() {
|
||||
return credit;
|
||||
}
|
||||
|
||||
public void setCredit(BigDecimal credit) {
|
||||
this.credit = credit;
|
||||
}
|
||||
|
||||
public BigDecimal getDebit() {
|
||||
return debit;
|
||||
}
|
||||
|
||||
public void setDebit(BigDecimal debit) {
|
||||
this.debit = debit;
|
||||
}
|
||||
|
||||
public BigDecimal getSettledCredit() {
|
||||
return settledCredit;
|
||||
}
|
||||
|
||||
public void setSettledCredit(BigDecimal settledCredit) {
|
||||
this.settledCredit = settledCredit;
|
||||
}
|
||||
|
||||
public BigDecimal getSettledDebit() {
|
||||
return settledDebit;
|
||||
}
|
||||
|
||||
public void setSettledDebit(BigDecimal settledDebit) {
|
||||
this.settledDebit = settledDebit;
|
||||
}
|
||||
|
||||
public BigDecimal getCheckBalance() {
|
||||
return checkBalance;
|
||||
}
|
||||
|
||||
public void setCheckBalance(BigDecimal checkBalance) {
|
||||
this.checkBalance = checkBalance;
|
||||
}
|
||||
|
||||
public BigDecimal getDiffBalance() {
|
||||
return diffBalance;
|
||||
}
|
||||
|
||||
public void setDiffBalance(BigDecimal diffBalance) {
|
||||
this.diffBalance = diffBalance;
|
||||
}
|
||||
|
||||
public BigDecimal getPlanBalance() {
|
||||
return planBalance;
|
||||
}
|
||||
|
||||
public void setPlanBalance(BigDecimal planBalance) {
|
||||
this.planBalance = planBalance;
|
||||
}
|
||||
|
||||
public String getBalanceDimension() {
|
||||
return balanceDimension;
|
||||
}
|
||||
|
||||
public void setBalanceDimension(String balanceDimension) {
|
||||
this.balanceDimension = balanceDimension;
|
||||
}
|
||||
|
||||
public LocalDate getSettlementDate() {
|
||||
return settlementDate;
|
||||
}
|
||||
|
||||
public void setSettlementDate(LocalDate settlementDate) {
|
||||
this.settlementDate = settlementDate;
|
||||
}
|
||||
|
||||
public String getSettlementCode() {
|
||||
return settlementCode;
|
||||
}
|
||||
|
||||
public void setSettlementCode(String settlementCode) {
|
||||
this.settlementCode = settlementCode;
|
||||
}
|
||||
|
||||
public LocalDate getTradingDate() {
|
||||
return tradingDate;
|
||||
}
|
||||
|
||||
public void setTradingDate(LocalDate tradingDate) {
|
||||
this.tradingDate = tradingDate;
|
||||
}
|
||||
|
||||
public LocalDate getClearingDate() {
|
||||
return clearingDate;
|
||||
}
|
||||
|
||||
public void setClearingDate(LocalDate clearingDate) {
|
||||
this.clearingDate = clearingDate;
|
||||
}
|
||||
|
||||
public LocalDate getRefundDate() {
|
||||
return refundDate;
|
||||
}
|
||||
|
||||
public void setRefundDate(LocalDate refundDate) {
|
||||
this.refundDate = refundDate;
|
||||
}
|
||||
|
||||
public LocalDate getValueDate() {
|
||||
return valueDate;
|
||||
}
|
||||
|
||||
public void setValueDate(LocalDate valueDate) {
|
||||
this.valueDate = valueDate;
|
||||
}
|
||||
|
||||
public BigDecimal getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(BigDecimal price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public String getContract() {
|
||||
return contract;
|
||||
}
|
||||
|
||||
public void setContract(String contract) {
|
||||
this.contract = contract;
|
||||
}
|
||||
|
||||
public Long getCounterPartyId() {
|
||||
return counterPartyId;
|
||||
}
|
||||
|
||||
public void setCounterPartyId(Long counterPartyId) {
|
||||
this.counterPartyId = counterPartyId;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public Long getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Long parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public Long getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(Long groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public Long getSessionId() {
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
public void setSessionId(Long sessionId) {
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
public String getSessionType() {
|
||||
return sessionType;
|
||||
}
|
||||
|
||||
public void setSessionType(String sessionType) {
|
||||
this.sessionType = sessionType;
|
||||
}
|
||||
|
||||
public String getSessionType_dictionary() {
|
||||
return sessionType_dictionary;
|
||||
}
|
||||
|
||||
public void setSessionType_dictionary(String sessionType_dictionary) {
|
||||
this.sessionType_dictionary = sessionType_dictionary;
|
||||
}
|
||||
|
||||
public Long getPaymentId() {
|
||||
return paymentId;
|
||||
}
|
||||
|
||||
public void setPaymentId(Long paymentId) {
|
||||
this.paymentId = paymentId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
|
||||
import ru.spcex.clearing.registry.reports.loaders.IDBObject;
|
||||
|
||||
public class RegistryHistory extends BusinessEvent<Registry> implements IDBObject {
|
||||
private Registry object;
|
||||
|
||||
// No DB fields
|
||||
private String houseName;
|
||||
private String account;
|
||||
|
||||
@Override
|
||||
public Registry getObject() {
|
||||
return object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setObject(Registry object) {
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
public String getHouseName() {
|
||||
return houseName;
|
||||
}
|
||||
|
||||
public void setHouseName(String houseName) {
|
||||
this.houseName = houseName;
|
||||
}
|
||||
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(String account) {
|
||||
this.account = account;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.IEnumKey;
|
||||
|
||||
public enum RegistryStatus implements IEnumKey {
|
||||
OK("OK"),
|
||||
CLRD("CLRD"),
|
||||
PROC("PROC"),
|
||||
NACK("NACK"),
|
||||
NACC("NACC"),
|
||||
FAIL("FAIL"),
|
||||
UNCV("UNCV"),
|
||||
MNG("MNG"),
|
||||
POOL("POOL"),
|
||||
SPLT("SPLT")
|
||||
;
|
||||
|
||||
private final String key;
|
||||
|
||||
RegistryStatus(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
|
||||
|
||||
/**
|
||||
* Справочник статусов регистров
|
||||
*
|
||||
* Dictionary DB table: REGISTRY_STATUS_DICTIONARY
|
||||
**/
|
||||
public class RegistryStatusDictionary extends AbstractDictionary {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
|
||||
/**
|
||||
* Инструменты
|
||||
* DB table: SECURITY
|
||||
**/
|
||||
public class Security extends BusinessObject {
|
||||
private String securitySymbol;
|
||||
|
||||
public String getSecuritySymbol() {
|
||||
return securitySymbol;
|
||||
}
|
||||
|
||||
public void setSecuritySymbol(String securitySymbol) {
|
||||
this.securitySymbol = securitySymbol;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
|
||||
/**
|
||||
* Справочник типов клиринговых сессий
|
||||
*
|
||||
* Dictionary DB table: SESSION_TYPE_DICTIONARY
|
||||
**/
|
||||
public class SessionTypeDictionary extends AbstractDictionary {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.IEnumKey;
|
||||
|
||||
public enum Side implements IEnumKey {
|
||||
BUY("B"),
|
||||
SELL("S"),
|
||||
;
|
||||
|
||||
private final String key;
|
||||
|
||||
Side(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public abstract class SpcexDBBase implements Serializable {
|
||||
|
||||
protected Long id;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s{id=%d}", getClass().getSimpleName(), getId());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
SpcexDBBase clrxObject = (SpcexDBBase) o;
|
||||
|
||||
return id.equals(clrxObject.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id.hashCode();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
|
||||
/**
|
||||
* Торгово-клиринговый регистр
|
||||
* <p>
|
||||
* DB table: TRADING_CLEARING_REGISTRY
|
||||
**/
|
||||
public class TradingClearingRegistry extends BusinessObject {
|
||||
private String code;
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,163 +0,0 @@
|
|||
package ru.spcex.clearing.registry.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.spcex.clearing.registry.reports.bean.FileReport;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.charset.Charset;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Класс для построения отчетов в формате CSV
|
||||
*/
|
||||
public abstract class CSVReportBuilder<R extends FileReport, I extends SpcexObjectBase> {
|
||||
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||
protected static DateTimeFormatter dateTimeFormatter_YYMMDDHHmmssSSS = DateTimeFormatter.ofPattern("yyMMddHHmmssSSS");
|
||||
|
||||
/**
|
||||
* Имя отчета (для имени файла)
|
||||
*/
|
||||
protected abstract String reportName();
|
||||
|
||||
/**
|
||||
* Преобразовать объект в строку отчета
|
||||
*/
|
||||
protected abstract R toRow(I input);
|
||||
|
||||
/**
|
||||
* Сортировка строк перед формированием отчета
|
||||
*/
|
||||
protected Collection<I> sortInput(Collection<I> input) {
|
||||
return input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Сортировка строк после формирования отчета
|
||||
*/
|
||||
protected Collection<R> sortOutput(Collection<R> rows) {
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Название отчета, используется для формирования имени отчета (без указания формата)
|
||||
*/
|
||||
protected String getReportFilename() {
|
||||
return "%s_%s".formatted(reportName(), dateTimeFormatter_YYMMDDHHmmssSSS.format(LocalDateTime.now()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Формирование отчета на основе объектов
|
||||
*/
|
||||
public File buildReport(Collection<I> inputObj, File outFolder, Charset outputEncoding) {
|
||||
assert outFolder != null && outFolder.isDirectory() && inputObj != null;
|
||||
List<R> rows = new ArrayList<>(inputObj.size());
|
||||
inputObj = sortInput(inputObj);
|
||||
for (I input : inputObj) rows.add(toRow(input));
|
||||
rows = sortOutput(rows).stream().toList();
|
||||
|
||||
File reportFile = new File(outFolder, normalizeFilenameForOS(getReportFilename() + ".csv"));
|
||||
|
||||
try (Writer writer = new FileWriter(reportFile, outputEncoding);
|
||||
ICSVWriter icsvWriter = new CustomCSVWriter(writer)) {
|
||||
CustomStrategy<R> customStrategy = new CustomStrategy<>();
|
||||
customStrategy.setType(getReportClass());
|
||||
StatefulBeanToCsv<R> sbc = new StatefulBeanToCsvBuilder<R>(icsvWriter)
|
||||
.withMappingStrategy(customStrategy)
|
||||
.build();
|
||||
if (!rows.isEmpty()) sbc.write(rows);
|
||||
else {
|
||||
// Для записи заголовков в пустой файл
|
||||
Constructor<? extends R> constructor = Objects.requireNonNull(getReportClass()).getDeclaredConstructor();
|
||||
R obj = constructor.newInstance();
|
||||
String[] headers = customStrategy.generateHeader(obj);
|
||||
writer.write("\"" + String.join("\",\"", headers) + "\"");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("Can't create CSV report", e);
|
||||
return null;
|
||||
}
|
||||
|
||||
return reportFile;
|
||||
}
|
||||
|
||||
protected abstract Class<R> getReportClass();
|
||||
|
||||
protected String normalizeFilenameForOS(String filename) {
|
||||
if (System.getProperty("os.name").toLowerCase().contains("windows"))
|
||||
return filename.replace(":", "_");
|
||||
return filename;
|
||||
}
|
||||
|
||||
static class CustomCSVWriter extends CSVWriter {
|
||||
public CustomCSVWriter(Writer writer) {
|
||||
super(writer, ',', '\"', '\"', System.lineSeparator());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeNext(String[] nextLine, boolean applyQuotesToAll, Appendable appendable) throws IOException {
|
||||
if (nextLine != null) {
|
||||
for (int i = 0; i < nextLine.length; i++) {
|
||||
if (StringUtils.isEmpty(nextLine[i])) {
|
||||
nextLine[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
super.writeNext(nextLine, applyQuotesToAll, appendable);
|
||||
}
|
||||
}
|
||||
|
||||
static class CustomStrategy<T> extends ColumnPositionMappingStrategy<T> {
|
||||
public String[] generateHeader(T bean) throws CsvRequiredFieldEmptyException {
|
||||
super.generateHeader(bean);
|
||||
String[] headers = new String[this.getFieldMap().values().size()];
|
||||
for (BeanField<T, Integer> field : this.getFieldMap().values()) {
|
||||
CsvBindByPosition positionAnnotation = field.getField().getAnnotation(CsvBindByPosition.class);
|
||||
CsvBindByName nameAnnotation = field.getField().getAnnotation(CsvBindByName.class);
|
||||
headers[positionAnnotation.position()] = nameAnnotation.column();
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] transmuteBean(T bean) throws CsvFieldAssignmentException, CsvChainedException {
|
||||
return super.transmuteBean(bean);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CsvConverter determineConverter(Field field, Class<?> elementType, String locale, String writeLocale, Class<? extends AbstractCsvConverter> customConverter) throws CsvBadConverterException {
|
||||
CsvConverter csvConverter = super.determineConverter(field, elementType, locale, writeLocale, customConverter);
|
||||
if (csvConverter instanceof ConverterNumber && field.getType() == BigDecimal.class) {
|
||||
CsvNumber csvNumberAnnotation = field.getAnnotation(CsvNumber.class);
|
||||
String formatValue = csvNumberAnnotation.value();
|
||||
String writeFormat = csvNumberAnnotation.writeFormat();
|
||||
csvConverter = new ConverterNumber(BigDecimal.class,
|
||||
Locale.getDefault().toString(),
|
||||
Locale.getDefault().toString(),
|
||||
Locale.getDefault(),
|
||||
formatValue,
|
||||
writeFormat);
|
||||
}
|
||||
return csvConverter;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +1,13 @@
|
|||
package ru.spcex.clearing.registry.reports.builders;
|
||||
|
||||
import ru.clearing.classes.objects.BusinessEvent;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.registry.Registry;
|
||||
import ru.clearing.classes.statics.data.registry.RegistryHistory;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.registry.reports.bean.DepoBalanceRegisterReport;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.spcex.clearing.registry.reports.bean.BusinessEvent;
|
||||
import ru.spcex.clearing.registry.reports.bean.Registry;
|
||||
import ru.spcex.clearing.registry.reports.bean.RegistryHistory;
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.AccountType;
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.IEnumKey;
|
||||
import ru.spcex.clearing.registry.reports.report.DepoBalanceRegisterReport;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
|
@ -19,15 +17,10 @@ import java.util.Collection;
|
|||
import java.util.Comparator;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class DepoBalanceRegisterReportBuilder extends XLSXReportBuilder<DepoBalanceRegisterReport, RegistryHistory> {
|
||||
private final static DateTimeFormatter yyyyMMddFormat = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||
|
||||
private final Imdg<Company> companyImdg;
|
||||
|
||||
public DepoBalanceRegisterReportBuilder(ImdgProvider imdgProvider) {
|
||||
companyImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Company, Company.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String reportName() {
|
||||
return "security_register";
|
||||
|
|
@ -41,19 +34,21 @@ public class DepoBalanceRegisterReportBuilder extends XLSXReportBuilder<DepoBala
|
|||
@Override
|
||||
protected DepoBalanceRegisterReport toRow(RegistryHistory registryHistory) {
|
||||
Registry input = registryHistory.getObject();
|
||||
|
||||
LocalDateTime nowTime = LocalDateTime.ofInstant(registryHistory.getEventTime(), ZoneId.systemDefault());
|
||||
LocalDate now = nowTime.toLocalDate();
|
||||
DepoBalanceRegisterReport entity = new DepoBalanceRegisterReport();
|
||||
|
||||
AccountType accountType = IEnumKey.getEnumByKey(AccountType.class, input.getAccountType());
|
||||
if (accountType != AccountType.Depo) return null;
|
||||
entity.setAccount(input.getAccount());
|
||||
|
||||
entity.setHouseName("АО РДЦ");
|
||||
entity.setNumber(yyyyMMddFormat.format(now));
|
||||
entity.setDate(now);
|
||||
entity.setTime(nowTime);
|
||||
entity.setCompany(input.getShortName());
|
||||
|
||||
AccountType accountType = IEnumKey.getEnumByKey(AccountType.class, input.getAccountType());
|
||||
if (accountType == AccountType.Depo) entity.setAccount(input.getAccount());
|
||||
|
||||
entity.setSecurity(input.getSecuritySymbol());
|
||||
entity.setSum(input.getBalance());
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
package ru.spcex.clearing.registry.reports.builders;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.spcex.clearing.registry.reports.bean.PaymentInstruction;
|
||||
import ru.spcex.clearing.registry.reports.report.DepoPaymentInstructionRegisterReport;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
|
||||
@Component
|
||||
public class DepoPaymentInstructionBuilder extends XLSXReportBuilder<DepoPaymentInstructionRegisterReport, PaymentInstruction> {
|
||||
@Override
|
||||
protected String reportName() {
|
||||
return "rdc_register";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DepoPaymentInstructionRegisterReport toRow(PaymentInstruction input) {
|
||||
DepoPaymentInstructionRegisterReport entity = new DepoPaymentInstructionRegisterReport();
|
||||
|
||||
if (input.getSessionId() != null) entity.setNumber(input.getSessionId());
|
||||
else entity.setNumber(input.getId());
|
||||
|
||||
entity.setDate(input.getClearingDate());
|
||||
|
||||
if (input.getCreated() != null)
|
||||
entity.setTime(LocalDateTime.from(input.getCreated().atZone(ZoneId.systemDefault())));
|
||||
|
||||
entity.setAccountSender(input.getCreditLegAccountStr());
|
||||
entity.setAccountAddressee(input.getDebitLegAccountStr());
|
||||
|
||||
entity.setAddressee(input.getAddressee());
|
||||
entity.setCodeAddressee(input.getAddresseeClearingCode());
|
||||
entity.setSender(input.getSender());
|
||||
entity.setCodeSender(input.getSenderClearingCode());
|
||||
|
||||
entity.setSecurity(input.getSecurity());
|
||||
entity.setAmount(input.getCreditLeg_amount());
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<DepoPaymentInstructionRegisterReport> getReportClass() {
|
||||
return DepoPaymentInstructionRegisterReport.class;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,95 +0,0 @@
|
|||
package ru.spcex.clearing.registry.reports.builders;
|
||||
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.payment.PaymentInstruction;
|
||||
import ru.clearing.classes.statics.data.security.Security;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.registry.reports.bean.DepoPaymentInstructionRegisterReport;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DepoPaymentInstructionRegisterReportBuilder extends XLSXReportBuilder<DepoPaymentInstructionRegisterReport, PaymentInstruction> {
|
||||
|
||||
private final Imdg<Account> accountImdg;
|
||||
private final Imdg<Company> companyImdg;
|
||||
private final Imdg<Security> securityImdg;
|
||||
|
||||
public DepoPaymentInstructionRegisterReportBuilder(ImdgProvider imdgProvider) {
|
||||
companyImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Company, Company.class);
|
||||
accountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
securityImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Security, Security.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String reportName() {
|
||||
return "rdc_register";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<DepoPaymentInstructionRegisterReport> getReportClass() {
|
||||
return DepoPaymentInstructionRegisterReport.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DepoPaymentInstructionRegisterReport toRow(PaymentInstruction input) {
|
||||
DepoPaymentInstructionRegisterReport entity = new DepoPaymentInstructionRegisterReport();
|
||||
|
||||
if (input.getSessionId() == null)
|
||||
entity.setNumber(input.getId());
|
||||
else
|
||||
entity.setNumber(input.getSessionId());
|
||||
entity.setDate(input.getClearingDate());
|
||||
|
||||
if (input.getCreated() != null) entity.setTime(LocalDateTime.from(input.getCreated().atZone(ZoneId.systemDefault())));
|
||||
|
||||
if (input.getCreditLeg_accountId() != null) {
|
||||
Account account = accountImdg.getSingleObjectByID(input.getCreditLeg_accountId());
|
||||
if (account != null) entity.setAccountSender(account.getAccount());
|
||||
}
|
||||
|
||||
if (input.getSenderId() != null) {
|
||||
Company company = companyImdg.getSingleObjectByID(input.getSenderId());
|
||||
if (company != null) {
|
||||
entity.setSender(company.getShortName());
|
||||
entity.setCodeSender(company.getClearingCode());
|
||||
}
|
||||
}
|
||||
|
||||
if (input.getDebitLeg_accountId() != null) {
|
||||
Account account = accountImdg.getSingleObjectByID(input.getDebitLeg_accountId());
|
||||
if (account != null) entity.setAccountAddressee(account.getAccount());
|
||||
}
|
||||
|
||||
if (input.getAddresseeId() != null) {
|
||||
Company company = companyImdg.getSingleObjectByID(input.getAddresseeId());
|
||||
if (company != null) {
|
||||
entity.setAddressee(company.getShortName());
|
||||
entity.setCodeAddressee(company.getClearingCode());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (input.getCreditLeg_securityId() != null) {
|
||||
Security security = securityImdg.getSingleObjectByID(input.getCreditLeg_securityId());
|
||||
if (security != null) entity.setSecurity(security.getSecuritySymbol());
|
||||
}
|
||||
entity.setAmount(input.getCreditLeg_amount());
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<PaymentInstruction> sortInput(Collection<PaymentInstruction> input) {
|
||||
return input.stream()
|
||||
.sorted(Comparator.comparing(PaymentInstruction::getCreated))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,45 +1,20 @@
|
|||
package ru.spcex.clearing.registry.reports.builders;
|
||||
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.company.CompanySymbols;
|
||||
import ru.clearing.classes.statics.data.execution.ExecutionCommon;
|
||||
import ru.clearing.classes.statics.data.execution.ExecutionDeposit;
|
||||
import ru.clearing.classes.statics.data.execution.ExecutionFond;
|
||||
import ru.clearing.classes.statics.data.registry.TradingClearingRegistry;
|
||||
import ru.clearing.platform.dictionary.AllowedDictionary;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.registry.reports.bean.ExecutionRegisterReport;
|
||||
import ru.spcex.platform.enumeration.CompanySymbol;
|
||||
import ru.spcex.platform.enumeration.MoneyFlowSide;
|
||||
import ru.spcex.platform.enumeration.Side;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.utils.number.BigDecimalUtil;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.spcex.clearing.registry.reports.bean.ExecutionCommon;
|
||||
import ru.spcex.clearing.registry.reports.bean.ExecutionDeposit;
|
||||
import ru.spcex.clearing.registry.reports.bean.ExecutionFond;
|
||||
import ru.spcex.clearing.registry.reports.report.ExecutionRegisterReport;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class ExecutionRegisterReportBuilder extends XLSXReportBuilder<ExecutionRegisterReport, ExecutionCommon> {
|
||||
private final static DateTimeFormatter yyyyMMddFormat = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||
|
||||
private final Imdg<Company> companyImdg;
|
||||
private final Imdg<CompanySymbols> companySymbolsImdg;
|
||||
private final Imdg<AllowedDictionary> allowedDictionaryImdg;
|
||||
private final Imdg<TradingClearingRegistry> tradingClearingRegistryImdg;
|
||||
|
||||
public ExecutionRegisterReportBuilder(ImdgProvider imdgProvider) {
|
||||
companyImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Company, Company.class);
|
||||
companySymbolsImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_CompanySymbols, CompanySymbols.class);
|
||||
allowedDictionaryImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_AllowedDictionary, AllowedDictionary.class);
|
||||
tradingClearingRegistryImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_TradingClearingRegistry, TradingClearingRegistry.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String reportName() {
|
||||
return "contract_register";
|
||||
|
|
@ -58,64 +33,12 @@ public class ExecutionRegisterReportBuilder extends XLSXReportBuilder<ExecutionR
|
|||
entity.setTradingDate(input.getTradingDate());
|
||||
entity.setExchangeExecutionId(input.getExchangeExecutionId());
|
||||
|
||||
if (input.getTradingClearingRegistryId() != null) {
|
||||
TradingClearingRegistry tkr = tradingClearingRegistryImdg.getSingleObjectByID(input.getTradingClearingRegistryId());
|
||||
if (tkr != null) entity.setSellerTkr(tkr.getCode());
|
||||
}
|
||||
|
||||
if (input.getSide() != null && input.getCompanyId() != null && input.getCounterPartyId() != null) {
|
||||
CompanySymbols companySymbolsByCompanyId = companySymbolsImdg.getFirstObjectByFieldValues(
|
||||
Map.of(
|
||||
"companySymbol", CompanySymbol.CLRC.getKey(),
|
||||
"companyId", input.getCompanyId()
|
||||
)
|
||||
);
|
||||
CompanySymbols companySymbolsByCounterPartyId = companySymbolsImdg.getFirstObjectByFieldValues(
|
||||
Map.of(
|
||||
"companySymbol", CompanySymbol.CLRC.getKey(),
|
||||
"companyId", input.getCounterPartyId()
|
||||
)
|
||||
);
|
||||
Company companyByCounterPartyId = companyImdg.getSingleObjectByID(input.getCounterPartyId());
|
||||
Company companyByCompanyId = companyImdg.getSingleObjectByID(input.getCompanyId());
|
||||
|
||||
if (Arrays.asList(Side.BUY.getKey(), MoneyFlowSide.BUY.getKey()).contains(input.getSide().toUpperCase())) {
|
||||
if (companyByCompanyId != null) {
|
||||
entity.setBuyer(companyByCompanyId.getShortName());
|
||||
}
|
||||
if (companyByCounterPartyId != null) {
|
||||
entity.setSeller(companyByCounterPartyId.getShortName());
|
||||
}
|
||||
if (companySymbolsByCounterPartyId != null) {
|
||||
entity.setSellerCode(companySymbolsByCounterPartyId.getCompanySymbolValue());
|
||||
}
|
||||
if (companySymbolsByCompanyId != null) {
|
||||
entity.setBuyerCode(companySymbolsByCompanyId.getCompanySymbolValue());
|
||||
}
|
||||
entity.setBuyerTkr(input.getPartyTradingClearingRegistry());
|
||||
} else
|
||||
if (Arrays.asList(Side.SELL.getKey(), MoneyFlowSide.SELL.getKey()).contains(input.getSide().toUpperCase())) {
|
||||
if (companyByCompanyId != null) {
|
||||
entity.setSeller(companyByCompanyId.getShortName());
|
||||
}
|
||||
if (companyByCounterPartyId != null) {
|
||||
entity.setBuyer(companyByCounterPartyId.getShortName());
|
||||
}
|
||||
if (companySymbolsByCompanyId != null) {
|
||||
entity.setSellerCode(companySymbolsByCompanyId.getCompanySymbolValue());
|
||||
}
|
||||
if (companySymbolsByCounterPartyId != null) {
|
||||
entity.setBuyerCode(companySymbolsByCounterPartyId.getCompanySymbolValue());
|
||||
}
|
||||
entity.setBuyerTkr(input.getCounterPartyTradingClearingRegistry());
|
||||
} else {
|
||||
log.warn("{}[{}] has wrong or empty field: side={}. Can not fill buyer/seller.",
|
||||
input.getClass().getSimpleName(), input.getId(), input.getSide());
|
||||
}
|
||||
} else {
|
||||
log.warn("{}[{}] has wrong or empty field: side={} CompanyId={} CounterPartyId={}. Can not fill buyer/seller.",
|
||||
input.getClass().getSimpleName(), input.getId(), input.getSide(), input.getCompanyId(), input.getCounterPartyId());
|
||||
}
|
||||
entity.setSellerTkr(input.getSellerTkrCode());
|
||||
entity.setBuyerTkr(input.getBuyerTkrCode());
|
||||
entity.setSeller(input.getSeller());
|
||||
entity.setSellerCode(input.getSellerCode());
|
||||
entity.setBuyer(input.getBuyer());
|
||||
entity.setBuyerCode(input.getBuyerCode());
|
||||
|
||||
if (input.getExchangeExecutionTime() != null)
|
||||
entity.setExchangeExecutionTime(LocalDateTime.from(input.getExchangeExecutionTime().atZone(ZoneId.systemDefault())));
|
||||
|
|
@ -128,16 +51,12 @@ public class ExecutionRegisterReportBuilder extends XLSXReportBuilder<ExecutionR
|
|||
} else if (input instanceof ExecutionFond fond) {
|
||||
entity.setSettlementDate(fond.getSettlementDate());
|
||||
entity.setSecurity(fond.getSecuritySymbol());
|
||||
entity.setAmount(BigDecimalUtil.safeSumBD(fond.getSettlementAmount(), fond.getInterestAmount()));
|
||||
BigDecimal sum = fond.getSettlementAmount() != null ? fond.getSettlementAmount() : BigDecimal.ZERO;
|
||||
if (fond.getInterestAmount() != null) sum = sum.add(fond.getInterestAmount());
|
||||
entity.setAmount(sum);
|
||||
entity.setQuantity(fond.getQuantity());
|
||||
}
|
||||
|
||||
if (input.getCoverageStatus() != null) {
|
||||
AllowedDictionary allowed = allowedDictionaryImdg.getFirstObjectByFieldValues(
|
||||
Map.of("code", input.getCoverageStatus())
|
||||
);
|
||||
if (allowed != null) entity.setStatus(allowed.getName());
|
||||
}
|
||||
entity.setStatus(input.getStatus());
|
||||
entity.setMarket(input.getMarket());
|
||||
|
||||
return entity;
|
||||
|
|
|
|||
|
|
@ -1,27 +1,16 @@
|
|||
package ru.spcex.clearing.registry.reports.builders;
|
||||
|
||||
import ru.clearing.classes.statics.data.registry.Registry;
|
||||
import ru.clearing.platform.dictionary.RegistryStatusDictionary;
|
||||
import ru.clearing.platform.dictionary.SessionTypeDictionary;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.registry.reports.bean.LiabilitiesRegistryReport;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.spcex.clearing.registry.reports.bean.Registry;
|
||||
import ru.spcex.clearing.registry.reports.report.LiabilitiesRegistryReport;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class LiabilitiesRegistryReportBuilder extends XLSXReportBuilder<LiabilitiesRegistryReport, Registry> {
|
||||
|
||||
private final Imdg<RegistryStatusDictionary> registryStatusDictionaryImdg;
|
||||
private final Imdg<SessionTypeDictionary> sessionTypesDictionaryImdg;
|
||||
|
||||
public LiabilitiesRegistryReportBuilder(ImdgProvider imdgProvider) {
|
||||
registryStatusDictionaryImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_RegistryStatusDictionary, RegistryStatusDictionary.class);
|
||||
sessionTypesDictionaryImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_SessionTypeDictionary, SessionTypeDictionary.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String reportName() {
|
||||
|
|
@ -41,46 +30,16 @@ public class LiabilitiesRegistryReportBuilder extends XLSXReportBuilder<Liabilit
|
|||
entity.setClearing_code(input.getClearingCode());
|
||||
entity.setAccount(input.getAccount());
|
||||
entity.setRegistry_code(input.getRegistryCode());
|
||||
entity.setRegistry_status(describeRegistryStatus(input.getRegistryStatus())); // CLRD
|
||||
entity.setRegistry_status(input.getRegistryStatus_dictionary()); //describeRegistryStatus(input.getRegistryStatus())); // CLRD
|
||||
entity.setSecurity_symbol(input.getSecuritySymbol());
|
||||
entity.setBalance(input.getBalance());
|
||||
entity.setSettlement_date(input.getSettlementDate());
|
||||
entity.setContract(input.getContract());
|
||||
entity.setSession_type(describeSessionType(input.getSessionType()));
|
||||
entity.setSession_type(input.getSessionType_dictionary());
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param registryStatus 'CLRD', ...
|
||||
* @return из справочника
|
||||
*/
|
||||
private String describeRegistryStatus(String registryStatus) {
|
||||
if (registryStatus == null)
|
||||
return registryStatus;
|
||||
RegistryStatusDictionary dictionary = registryStatusDictionaryImdg.getFirstObjectByFieldValues(Map.of(
|
||||
"code", registryStatus
|
||||
));
|
||||
if (dictionary == null) {
|
||||
log.warn("Dictionary not found for status=\"{}\"", registryStatus);
|
||||
return registryStatus;
|
||||
}
|
||||
return dictionary.getName();
|
||||
}
|
||||
|
||||
private String describeSessionType(String sessionType) {
|
||||
if (sessionType == null)
|
||||
return sessionType;
|
||||
SessionTypeDictionary dictionary = sessionTypesDictionaryImdg.getFirstObjectByFieldValues(Map.of(
|
||||
"code", sessionType
|
||||
));
|
||||
if (dictionary == null) {
|
||||
log.warn("Dictionary not found for sessionType=\"{}\"", sessionType);
|
||||
return sessionType;
|
||||
}
|
||||
return dictionary.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<Registry> sortInput(Collection<Registry> input) {
|
||||
return input.stream()
|
||||
|
|
|
|||
|
|
@ -1,15 +1,12 @@
|
|||
package ru.spcex.clearing.registry.reports.builders;
|
||||
|
||||
import ru.clearing.classes.objects.BusinessEvent;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.registry.Registry;
|
||||
import ru.clearing.classes.statics.data.registry.RegistryHistory;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.registry.reports.bean.MoneyBalanceRegisterReport;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.spcex.clearing.registry.reports.bean.BusinessEvent;
|
||||
import ru.spcex.clearing.registry.reports.bean.Registry;
|
||||
import ru.spcex.clearing.registry.reports.bean.RegistryHistory;
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.AccountType;
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.IEnumKey;
|
||||
import ru.spcex.clearing.registry.reports.report.MoneyBalanceRegisterReport;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
|
@ -19,15 +16,10 @@ import java.util.Collection;
|
|||
import java.util.Comparator;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class MoneyBalanceRegisterReportBuilder extends XLSXReportBuilder<MoneyBalanceRegisterReport, RegistryHistory> {
|
||||
private final static DateTimeFormatter yyyyMMddFormat = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||
|
||||
private final Imdg<Company> companyImdg;
|
||||
|
||||
public MoneyBalanceRegisterReportBuilder(ImdgProvider imdgProvider) {
|
||||
companyImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Company, Company.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String reportName() {
|
||||
return "money_register";
|
||||
|
|
@ -44,10 +36,7 @@ public class MoneyBalanceRegisterReportBuilder extends XLSXReportBuilder<MoneyBa
|
|||
LocalDateTime nowTime = LocalDateTime.ofInstant(registryHistory.getEventTime(), ZoneId.systemDefault());
|
||||
LocalDate now = nowTime.toLocalDate();
|
||||
MoneyBalanceRegisterReport entity = new MoneyBalanceRegisterReport();
|
||||
|
||||
Company company = companyImdg.getSingleObjectByID(2L);
|
||||
if (company != null) entity.setHouseName(company.getShortName());
|
||||
|
||||
entity.setHouseName(registryHistory.getHouseName());
|
||||
entity.setNumber(yyyyMMddFormat.format(now));
|
||||
entity.setDate(now);
|
||||
entity.setTime(nowTime);
|
||||
|
|
@ -55,8 +44,16 @@ public class MoneyBalanceRegisterReportBuilder extends XLSXReportBuilder<MoneyBa
|
|||
entity.setCompany(input.getShortName());
|
||||
|
||||
AccountType accountType = IEnumKey.getEnumByKey(AccountType.class, input.getAccountType());
|
||||
if (accountType == AccountType.Clrn || accountType == AccountType.Info) entity.setAccount(input.getAccount());
|
||||
|
||||
// if (accountType == AccountType.Info || BigDecimal.ZERO.compareTo(registryHistory.getObject().getDiffBalance()) == 0) {
|
||||
// // account_type==info or DiffBalance==0 попадает в отчёт
|
||||
// } else {
|
||||
// log.trace("Ignore id={}, cause diffBalance is not zero.", registryHistory.getObject().getId());
|
||||
// return null;
|
||||
// //else: оставлять записи, где: accountType == AccountType.Info ИЛИ DiffBalance == 0.0
|
||||
// }
|
||||
|
||||
entity.setAccount(input.getAccount());
|
||||
entity.setSum(input.getBalance());
|
||||
|
||||
return entity;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,8 @@
|
|||
package ru.spcex.clearing.registry.reports.builders;
|
||||
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.payment.PaymentInstruction;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.registry.reports.bean.MoneyPaymentInstructionRegisterReport;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.spcex.clearing.registry.reports.bean.PaymentInstruction;
|
||||
import ru.spcex.clearing.registry.reports.report.MoneyPaymentInstructionRegisterReport;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
|
|
@ -14,16 +10,9 @@ import java.util.Collection;
|
|||
import java.util.Comparator;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class MoneyPaymentInstructionRegisterReportBuilder extends XLSXReportBuilder<MoneyPaymentInstructionRegisterReport, PaymentInstruction> {
|
||||
|
||||
private final Imdg<Account> accountImdg;
|
||||
private final Imdg<Company> companyImdg;
|
||||
|
||||
public MoneyPaymentInstructionRegisterReportBuilder(ImdgProvider imdgProvider) {
|
||||
companyImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Company, Company.class);
|
||||
accountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String reportName() {
|
||||
return "prc_register";
|
||||
|
|
@ -38,39 +27,19 @@ public class MoneyPaymentInstructionRegisterReportBuilder extends XLSXReportBuil
|
|||
protected MoneyPaymentInstructionRegisterReport toRow(PaymentInstruction input) {
|
||||
MoneyPaymentInstructionRegisterReport entity = new MoneyPaymentInstructionRegisterReport();
|
||||
|
||||
if (input.getSessionId() == null)
|
||||
entity.setNumber(input.getId());
|
||||
else
|
||||
entity.setNumber(input.getSessionId());
|
||||
if (input.getSessionId() != null) entity.setNumber(input.getSessionId());
|
||||
else entity.setNumber(input.getId());
|
||||
|
||||
entity.setDate(input.getClearingDate());
|
||||
|
||||
if (input.getCreated() != null) entity.setTime(LocalDateTime.from(input.getCreated().atZone(ZoneId.systemDefault())));
|
||||
|
||||
if (input.getCreditLeg_accountId() != null) {
|
||||
Account account = accountImdg.getSingleObjectByID(input.getCreditLeg_accountId());
|
||||
if (account != null) entity.setAccountSender(account.getAccount());
|
||||
}
|
||||
|
||||
if (input.getSenderId() != null) {
|
||||
Company company = companyImdg.getSingleObjectByID(input.getSenderId());
|
||||
if (company != null) {
|
||||
entity.setSender(company.getShortName());
|
||||
entity.setCodeSender(company.getClearingCode());
|
||||
}
|
||||
}
|
||||
|
||||
if (input.getDebitLeg_accountId() != null) {
|
||||
Account account = accountImdg.getSingleObjectByID(input.getDebitLeg_accountId());
|
||||
if (account != null) entity.setAccountAddressee(account.getAccount());
|
||||
}
|
||||
|
||||
if (input.getAddresseeId() != null) {
|
||||
Company company = companyImdg.getSingleObjectByID(input.getAddresseeId());
|
||||
if (company != null) {
|
||||
entity.setAddressee(company.getShortName());
|
||||
entity.setCodeAddressee(company.getClearingCode());
|
||||
}
|
||||
}
|
||||
entity.setAccountSender(input.getCreditLegAccountStr());
|
||||
entity.setSender(input.getSender());
|
||||
entity.setCodeSender(input.getSenderClearingCode());
|
||||
entity.setAccountAddressee(input.getDebitLegAccountStr());
|
||||
entity.setAddressee(input.getAddressee());
|
||||
entity.setCodeAddressee(input.getAddresseeClearingCode());
|
||||
|
||||
entity.setCurrencyCode(input.getCreditLeg_currencyCode());
|
||||
entity.setSum(input.getCreditLeg_amount());
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
package ru.spcex.clearing.registry.reports.builders;
|
||||
|
||||
import com.opencsv.bean.CsvBindByName;
|
||||
import com.opencsv.bean.CsvBindByPosition;
|
||||
import com.opencsv.bean.CsvDate;
|
||||
import com.opencsv.bean.CsvNumber;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import ru.spcex.clearing.registry.reports.bean.FileReport;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.clearing.registry.annotation.BindByName;
|
||||
import ru.spcex.clearing.registry.annotation.BindByPosition;
|
||||
import ru.spcex.clearing.registry.annotation.ReportDate;
|
||||
import ru.spcex.clearing.registry.annotation.ReportNumber;
|
||||
import ru.spcex.clearing.registry.reports.bean.SpcexDBBase;
|
||||
import ru.spcex.clearing.registry.reports.report.FileReport;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
|
|
@ -24,7 +24,7 @@ import java.util.*;
|
|||
/**
|
||||
* Класс для построения отчетов в формате CSV
|
||||
*/
|
||||
public abstract class XLSXReportBuilder<R extends FileReport, I extends SpcexObjectBase> {
|
||||
public abstract class XLSXReportBuilder<R extends FileReport, I extends SpcexDBBase> {
|
||||
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||
protected static DateTimeFormatter dateTimeFormatter_YYMMDDHHmmssSSS = DateTimeFormatter.ofPattern("yyMMddHHmmssSSS");
|
||||
|
||||
|
|
@ -64,10 +64,18 @@ public abstract class XLSXReportBuilder<R extends FileReport, I extends SpcexObj
|
|||
*/
|
||||
public File buildReport(Collection<I> inputObj, File outFolder) {
|
||||
assert outFolder != null && outFolder.isDirectory() && inputObj != null;
|
||||
List<R> rows = new ArrayList<>(inputObj.size());
|
||||
inputObj = sortInput(inputObj);
|
||||
for (I input : inputObj) rows.add(toRow(input));
|
||||
rows = sortOutput(rows).stream().toList();
|
||||
List<R> rows;
|
||||
try {
|
||||
rows = new ArrayList<>(inputObj.size());
|
||||
inputObj = sortInput(inputObj);
|
||||
for (I input : inputObj) {
|
||||
R row = toRow(input);
|
||||
if (row != null) rows.add(row);
|
||||
}
|
||||
rows = sortOutput(rows).stream().toList();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Unknown exception", e);
|
||||
}
|
||||
|
||||
File reportFile = new File(outFolder, normalizeFilenameForOS(getReportFilename() + ".xlsx"));
|
||||
log.debug("Создание отчёта {} в файл \"{}\"", reportName(), reportFile.getPath());
|
||||
|
|
@ -78,8 +86,8 @@ public abstract class XLSXReportBuilder<R extends FileReport, I extends SpcexObj
|
|||
Field[] declaredFields = objTemplate.getClass().getDeclaredFields();
|
||||
List<String> headers = new ArrayList<>();
|
||||
for (Field field : declaredFields) {
|
||||
CsvBindByPosition positionAnnotation = field.getAnnotation(CsvBindByPosition.class);
|
||||
CsvBindByName nameAnnotation = field.getAnnotation(CsvBindByName.class);
|
||||
BindByPosition positionAnnotation = field.getAnnotation(BindByPosition.class);
|
||||
BindByName nameAnnotation = field.getAnnotation(BindByName.class);
|
||||
if (positionAnnotation == null || nameAnnotation == null) continue;
|
||||
int position = positionAnnotation.position();
|
||||
String columnName = nameAnnotation.column();
|
||||
|
|
@ -101,7 +109,7 @@ public abstract class XLSXReportBuilder<R extends FileReport, I extends SpcexObj
|
|||
for (R obj : rows) {
|
||||
xlsxRow = sheet.createRow(rowIdx++);
|
||||
for (Field field : obj.getClass().getDeclaredFields()) {
|
||||
CsvBindByPosition positionAnnotation = field.getAnnotation(CsvBindByPosition.class);
|
||||
BindByPosition positionAnnotation = field.getAnnotation(BindByPosition.class);
|
||||
if (positionAnnotation == null) continue;
|
||||
field.setAccessible(true);
|
||||
Object rawValue = field.get(obj);
|
||||
|
|
@ -112,8 +120,8 @@ public abstract class XLSXReportBuilder<R extends FileReport, I extends SpcexObj
|
|||
Class<?> type = field.getType();
|
||||
if (type == BigDecimal.class || type == Long.class || type == Integer.class) {
|
||||
if (type == BigDecimal.class) {
|
||||
CsvNumber csvNumberAnnotation = field.getAnnotation(CsvNumber.class);
|
||||
String writeFormat = csvNumberAnnotation.writeFormat();
|
||||
ReportNumber csvNumberAnnotation = field.getAnnotation(ReportNumber.class);
|
||||
String writeFormat = csvNumberAnnotation.value();
|
||||
CellStyle style = numberStyles.get(writeFormat);
|
||||
if (style == null) {
|
||||
style = workbook.createCellStyle();
|
||||
|
|
@ -129,7 +137,7 @@ public abstract class XLSXReportBuilder<R extends FileReport, I extends SpcexObj
|
|||
cell.setCellValue(number.longValue());
|
||||
}
|
||||
} else if (type == LocalDate.class || type == LocalDateTime.class) {
|
||||
CsvDate csvDateAnnotation = field.getAnnotation(CsvDate.class);
|
||||
ReportDate csvDateAnnotation = field.getAnnotation(ReportDate.class);
|
||||
String formatStr = csvDateAnnotation.value();
|
||||
CellStyle cellStyle = dateStyles.get(formatStr);
|
||||
if (cellStyle == null) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
package ru.spcex.clearing.registry.reports.loaders;
|
||||
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.spcex.clearing.registry.conf.properties.AProperties;
|
||||
import ru.spcex.clearing.registry.reports.bean.RegistryHistory;
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.RegistryCodeSqlBuilder;
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.RegistryTradingParams;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class DepoBalanceLoader extends RegistryHistoryLoader {
|
||||
protected DepoBalanceLoader(AProperties properties, NamedParameterJdbcTemplate clearingJdbc) {
|
||||
super(properties, clearingJdbc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RegistryHistory> loadObjects() {
|
||||
List<RegistryHistory> result = super.loadObjects();
|
||||
return result.stream()
|
||||
.filter(registryHistory -> registryHistory.getObject().getDiffBalance().compareTo(BigDecimal.ZERO) == 0)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String sqlQuery() {
|
||||
RegistryCodeSqlBuilder registryCodeSqlBuilder = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.AS_T);
|
||||
return "select * from REGISTRY_HISTORY where EVENT_TIME >= :startDate and EVENT_TIME < :endDate and (%s) and TRADING_CLEARING_REGISTRY is not null"
|
||||
.formatted(registryCodeSqlBuilder.buildSql());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
package ru.spcex.clearing.registry.reports.loaders;
|
||||
|
||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.spcex.clearing.registry.conf.properties.AProperties;
|
||||
import ru.spcex.clearing.registry.reports.bean.Account;
|
||||
import ru.spcex.clearing.registry.reports.bean.Company;
|
||||
import ru.spcex.clearing.registry.reports.bean.PaymentInstruction;
|
||||
import ru.spcex.clearing.registry.reports.bean.Security;
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.AccountRowMapper;
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.AccountType;
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.CompanyRowMapper;
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.SecurityRowMapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class DepoInstructionLoader extends PaymentInstructionLoader {
|
||||
private final Set<String> DEPO_ACCOUNT_TYPES = Set.of(AccountType.Depo.getKey(), AccountType.Dtrn.getKey());
|
||||
|
||||
protected DepoInstructionLoader(AProperties properties, NamedParameterJdbcTemplate clearingJdbc) {
|
||||
super(properties, clearingJdbc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PaymentInstruction> loadObjects() {
|
||||
List<PaymentInstruction> result = new ArrayList<>();
|
||||
|
||||
List<PaymentInstruction> paymentInstructions = super.loadObjects();
|
||||
if (paymentInstructions.isEmpty()) {
|
||||
log.warn("PaymentInstructions not found.");
|
||||
return result;
|
||||
}
|
||||
Map<Long, List<PaymentInstruction>> groupedPaymentInstruction = paymentInstructions.stream()
|
||||
.collect(Collectors.groupingBy(PaymentInstruction::getCreditLeg_accountId));
|
||||
List<Long> ids = paymentInstructions.stream().map(PaymentInstruction::getCreditLeg_accountId).toList();
|
||||
MapSqlParameterSource parameterSource = new MapSqlParameterSource();
|
||||
parameterSource.addValue("ids", ids);
|
||||
List<Account> accounts = clearingJdbc.query(
|
||||
"select ID, ACCOUNT_TYPE from ACCOUNT where ID in (:ids)",
|
||||
parameterSource, new AccountRowMapper()
|
||||
);
|
||||
for (Account account : accounts) {
|
||||
if (account.getAccountType() != null && !DEPO_ACCOUNT_TYPES.contains(account.getAccountType().toUpperCase()))
|
||||
continue;
|
||||
Long id = account.getId();
|
||||
List<PaymentInstruction> payments = groupedPaymentInstruction.get(id);
|
||||
if (!payments.isEmpty()) result.addAll(payments);
|
||||
}
|
||||
|
||||
Map<Long, List<PaymentInstruction>> groupedBySenderIds = paymentInstructions.stream()
|
||||
.collect(Collectors.groupingBy(PaymentInstruction::getSenderId));
|
||||
Map<Long, List<PaymentInstruction>> groupedByAddresseeIds = paymentInstructions.stream()
|
||||
.collect(Collectors.groupingBy(PaymentInstruction::getAddresseeId));
|
||||
List<Long> senderIds = new ArrayList<>(groupedBySenderIds.keySet());
|
||||
List<Long> addresseeIds = new ArrayList<>(groupedByAddresseeIds.keySet());
|
||||
parameterSource = new MapSqlParameterSource();
|
||||
parameterSource.addValue("ids", senderIds);
|
||||
List<Company> companiesSenderIds = clearingJdbc.query(
|
||||
"select ID, CLEARING_CODE, SHORT_NAME from COMPANY where ID in (:ids)",
|
||||
parameterSource, new CompanyRowMapper()
|
||||
);
|
||||
for (Company company : companiesSenderIds) {
|
||||
List<PaymentInstruction> payments = groupedBySenderIds.get(company.getId());
|
||||
if (payments != null) {
|
||||
for (PaymentInstruction paymentInstruction : payments) {
|
||||
paymentInstruction.setSender(company.getShortName());
|
||||
paymentInstruction.setSenderClearingCode(company.getClearingCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
parameterSource = new MapSqlParameterSource();
|
||||
parameterSource.addValue("ids", addresseeIds);
|
||||
List<Company> companiesAddresseeId = clearingJdbc.query(
|
||||
"select ID, CLEARING_CODE, SHORT_NAME from COMPANY where ID in (:ids)",
|
||||
parameterSource, new CompanyRowMapper()
|
||||
);
|
||||
for (Company company : companiesAddresseeId) {
|
||||
List<PaymentInstruction> payments = groupedByAddresseeIds.get(company.getId());
|
||||
if (payments != null) {
|
||||
for (PaymentInstruction paymentInstruction : payments) {
|
||||
paymentInstruction.setAddressee(company.getShortName());
|
||||
paymentInstruction.setAddresseeClearingCode(company.getClearingCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<Long, List<PaymentInstruction>> groupedBySecurityId = paymentInstructions.stream()
|
||||
.collect(Collectors.groupingBy(PaymentInstruction::getCreditLeg_securityId));
|
||||
Set<Long> securityIds = groupedBySecurityId.keySet();
|
||||
MapSqlParameterSource parameterSourceSecurityIds = new MapSqlParameterSource();
|
||||
parameterSourceSecurityIds.addValue("ids", securityIds);
|
||||
List<Security> securities = clearingJdbc.query(
|
||||
"select ID, SECURITY_SYMBOL from SECURITY where ID in (:ids)",
|
||||
parameterSourceSecurityIds, new SecurityRowMapper()
|
||||
);
|
||||
for (Security security : securities) {
|
||||
List<PaymentInstruction> paymentInstructionList = groupedBySecurityId.get(security.getId());
|
||||
if (paymentInstructionList != null) {
|
||||
for (PaymentInstruction paymentInstruction : paymentInstructionList) {
|
||||
paymentInstruction.setSecurity(security.getSecuritySymbol());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,221 @@
|
|||
package ru.spcex.clearing.registry.reports.loaders;
|
||||
|
||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.spcex.clearing.registry.conf.properties.AProperties;
|
||||
import ru.spcex.clearing.registry.reports.ReportUtils;
|
||||
import ru.spcex.clearing.registry.reports.bean.*;
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.AllowedDictionaryRowMapper;
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.CompanyRowMapper;
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.CompanySymbolsRowMapper;
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.TradingClearingRegistryRowMapper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Component
|
||||
public class ExecutionDepositLoader extends IDBLoader<ExecutionDeposit> {
|
||||
public ExecutionDepositLoader(AProperties properties, NamedParameterJdbcTemplate clearingJdbc) {
|
||||
super(properties.getPeriod(), clearingJdbc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sqlQuery() {
|
||||
return "select * from EXECUTION_DEPOSIT where CLEARING_DATE >= :startDate and CLEARING_DATE < :endDate";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<ExecutionDeposit> getDBObjectClass() {
|
||||
return ExecutionDeposit.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExecutionDeposit> loadObjects() {
|
||||
try {
|
||||
List<ExecutionDeposit> executionDeposits = super.loadObjects();
|
||||
|
||||
Map<Long, List<ExecutionDeposit>> groupedExecutionDepositForTKR = executionDeposits.stream()
|
||||
.collect(Collectors.groupingBy(ExecutionDeposit::getTradingClearingRegistryId));
|
||||
if (executionDeposits.isEmpty()) {
|
||||
log.warn("ExecutionDeposit not found.");
|
||||
return new ArrayList<>();
|
||||
}
|
||||
Set<Long> tkrIds = groupedExecutionDepositForTKR.keySet();
|
||||
MapSqlParameterSource parameterSource = new MapSqlParameterSource();
|
||||
parameterSource.addValue("ids", tkrIds);
|
||||
List<TradingClearingRegistry> tradingClearingRegistries = clearingJdbc.query(
|
||||
"select ID, CODE from TRADING_CLEARING_REGISTRY where ID in (:ids)",
|
||||
parameterSource, new TradingClearingRegistryRowMapper()
|
||||
);
|
||||
for (TradingClearingRegistry tkr : tradingClearingRegistries) {
|
||||
List<ExecutionDeposit> executionDepositList = groupedExecutionDepositForTKR.get(tkr.getId());
|
||||
for (ExecutionDeposit deposit : executionDepositList) {
|
||||
deposit.setSellerTkrCode(tkr.getCode());
|
||||
}
|
||||
}
|
||||
|
||||
Map<Long, List<CompanySymbols>> companySymbolsForCompanyIdMap;
|
||||
{
|
||||
Set<Long> companyIds = executionDeposits.stream().map(ExecutionDeposit::getCompanyId).collect(Collectors.toSet());
|
||||
parameterSource = new MapSqlParameterSource();
|
||||
parameterSource.addValue("ids", companyIds);
|
||||
parameterSource.addValue("cs", CompanySymbol.CLRC.getKey());
|
||||
List<CompanySymbols> companySymbolsForCompanyId = clearingJdbc.query(
|
||||
"select ID, COMPANY_ID, COMPANY_SYMBOL, COMPANY_SYMBOL_VALUE from COMPANY_SYMBOLS where COMPANY_ID in (:ids) and COMPANY_SYMBOL = :cs",
|
||||
parameterSource, new CompanySymbolsRowMapper()
|
||||
);
|
||||
companySymbolsForCompanyIdMap = companySymbolsForCompanyId.stream().collect(Collectors.groupingBy(CompanySymbols::getCompanyId));
|
||||
}
|
||||
|
||||
Map<Long, List<CompanySymbols>> companySymbolsForCounterPartyIdMap;
|
||||
{
|
||||
Set<Long> counterPartyIds = executionDeposits.stream().map(ExecutionDeposit::getCounterPartyId).collect(Collectors.toSet());
|
||||
parameterSource = new MapSqlParameterSource();
|
||||
parameterSource.addValue("ids", counterPartyIds);
|
||||
parameterSource.addValue("companySymbol", CompanySymbol.CLRC.getKey());
|
||||
List<CompanySymbols> companySymbolsForCounterPartyId = clearingJdbc.query(
|
||||
"select ID, COMPANY_ID, COMPANY_SYMBOL, COMPANY_SYMBOL_VALUE from COMPANY_SYMBOLS where COMPANY_ID in (:ids) and COMPANY_SYMBOL = :companySymbol",
|
||||
parameterSource, new CompanySymbolsRowMapper()
|
||||
);
|
||||
companySymbolsForCounterPartyIdMap = companySymbolsForCounterPartyId.stream().collect(Collectors.groupingBy(CompanySymbols::getCompanyId));
|
||||
}
|
||||
|
||||
Map<Long, Company> companyById;
|
||||
{
|
||||
Set<Long> allCompanyIds = Stream.concat(
|
||||
executionDeposits.stream().map(ExecutionDeposit::getCompanyId),
|
||||
executionDeposits.stream().map(ExecutionDeposit::getCounterPartyId))
|
||||
.collect(Collectors.toSet());
|
||||
parameterSource = new MapSqlParameterSource();
|
||||
parameterSource.addValue("ids", allCompanyIds);
|
||||
List<Company> companyForCompanyId = clearingJdbc.query(
|
||||
"select ID, CLEARING_CODE, SHORT_NAME from COMPANY where ID in (:ids)",
|
||||
parameterSource, new CompanyRowMapper()
|
||||
);
|
||||
companyById = companyForCompanyId.stream()
|
||||
.collect(Collectors.toMap(Company::getId, o -> o));
|
||||
}
|
||||
|
||||
Set<String> coverageStatuses = executionDeposits.stream().map(ExecutionDeposit::getCoverageStatus).collect(Collectors.toSet());
|
||||
parameterSource = new MapSqlParameterSource();
|
||||
parameterSource.addValue("coverageStatuses", coverageStatuses);
|
||||
List<AllowedDictionary> allowedDictionaries = clearingJdbc.query(
|
||||
"select * from ALLOWED_DICTIONARY where CODE in (:coverageStatuses)",
|
||||
parameterSource, new AllowedDictionaryRowMapper()
|
||||
);
|
||||
Map<String, List<AllowedDictionary>> allowedDictionariesByCode = allowedDictionaries.stream()
|
||||
.collect(Collectors.groupingBy(AllowedDictionary::getCode));
|
||||
|
||||
for (ExecutionDeposit executionDeposit : executionDeposits) {
|
||||
Company companyByCompanyId = companyById.get(executionDeposit.getCompanyId());
|
||||
Company companyByCounterPartyId = companyById.get(executionDeposit.getCounterPartyId());
|
||||
String side = executionDeposit.getSide() == null ? null : executionDeposit.getSide().toUpperCase();
|
||||
if (MoneyFlowSide.SELL.equalsByKey(side) || Side.SELL.equalsByKey(side)) {
|
||||
if (companyByCompanyId != null) {
|
||||
executionDeposit.setSeller(companyByCompanyId.getShortName());
|
||||
}
|
||||
if (companyByCounterPartyId != null) {
|
||||
executionDeposit.setBuyer(companyByCounterPartyId.getShortName());
|
||||
}
|
||||
{
|
||||
List<CompanySymbols> cSymbols = companySymbolsForCompanyIdMap.get(executionDeposit.getCompanyId());
|
||||
if (cSymbols != null && !cSymbols.isEmpty()) {
|
||||
CompanySymbols companySymbols = cSymbols.iterator().next();
|
||||
executionDeposit.setSellerCode(companySymbols.getCompanySymbolValue());
|
||||
}
|
||||
}
|
||||
{
|
||||
List<CompanySymbols> cSymbols = companySymbolsForCounterPartyIdMap.get(executionDeposit.getCounterPartyId());
|
||||
if (cSymbols != null && !cSymbols.isEmpty()) {
|
||||
CompanySymbols companySymbols = cSymbols.iterator().next();
|
||||
executionDeposit.setBuyerCode(companySymbols.getCompanySymbolValue());
|
||||
}
|
||||
}
|
||||
executionDeposit.setBuyerTkrCode(executionDeposit.getCounterPartyTradingClearingRegistry());
|
||||
} else if (MoneyFlowSide.BUY.equalsByKey(side) || Side.BUY.equalsByKey(side)) {
|
||||
if (companyByCompanyId != null) {
|
||||
executionDeposit.setBuyer(companyByCompanyId.getShortName());
|
||||
}
|
||||
if (companyByCounterPartyId != null) {
|
||||
executionDeposit.setSeller(companyByCounterPartyId.getShortName());
|
||||
}
|
||||
{
|
||||
List<CompanySymbols> cSymbols = companySymbolsForCompanyIdMap.get(executionDeposit.getCompanyId());
|
||||
if (cSymbols != null && !cSymbols.isEmpty()) {
|
||||
CompanySymbols companySymbols = cSymbols.iterator().next();
|
||||
executionDeposit.setBuyerCode(companySymbols.getCompanySymbolValue());
|
||||
}
|
||||
}
|
||||
{
|
||||
List<CompanySymbols> cSymbols = companySymbolsForCounterPartyIdMap.get(executionDeposit.getCounterPartyId());
|
||||
if (cSymbols != null && !cSymbols.isEmpty()) {
|
||||
CompanySymbols companySymbols = cSymbols.iterator().next();
|
||||
executionDeposit.setSellerCode(companySymbols.getCompanySymbolValue());
|
||||
}
|
||||
}
|
||||
executionDeposit.setBuyerTkrCode(executionDeposit.getPartyTradingClearingRegistry());
|
||||
} else {
|
||||
log.warn("Unknown executionDeposit[{}].side={}", executionDeposit.getId(), executionDeposit.getSide());
|
||||
}
|
||||
List<AllowedDictionary> allowed = allowedDictionariesByCode.get(executionDeposit.getCoverageStatus());
|
||||
if (allowed != null && !allowed.isEmpty()) {
|
||||
executionDeposit.setStatus(allowed.iterator().next().getName());
|
||||
}
|
||||
}
|
||||
|
||||
return executionDeposits;
|
||||
} catch (Exception e) {
|
||||
log.error("Can not load ExecutionDeposit: ", e);
|
||||
throw new RuntimeException("At ExecutionDeposit", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExecutionDeposit fromRS(ResultSet resultSet) throws SQLException {
|
||||
ExecutionDeposit object = new ExecutionDeposit();
|
||||
object.setId(resultSet.getObject("ID", Long.class));
|
||||
object.setCreated(ReportUtils.getInstantFromTimestamp(resultSet, "CREATED_AT"));
|
||||
object.setUpdated(ReportUtils.getInstantFromTimestamp(resultSet, "UPDATED_AT"));
|
||||
object.setExchangeExecutionId(resultSet.getObject("EXCHANGE_EXECUTION_ID", Long.class));
|
||||
object.setExchangeExecutionTime(ReportUtils.getInstantFromTimestamp(resultSet, "EXCHANGE_EXECUTION_TIME"));
|
||||
object.setTradingDate(ReportUtils.getLocalDateFromSqlDate(resultSet, "TRADING_DATE"));
|
||||
object.setTradingClearingRegistryId(resultSet.getObject("TRADING_CLEARING_REGISTRY_ID", Long.class));
|
||||
object.setPartyTradingClearingRegistry(resultSet.getObject("PARTY_TRADING_CLEARING_REGISTRY", String.class));
|
||||
object.setCounterPartyTradingClearingRegistry(resultSet.getObject("COUNTER_PARTY_TRADING_CLEARING_REGISTRY", String.class));
|
||||
object.setMarket(resultSet.getObject("MARKET", String.class));
|
||||
object.setPrice(resultSet.getObject("PRICE", BigDecimal.class));
|
||||
object.setLots(resultSet.getObject("LOTS", BigDecimal.class));
|
||||
object.setQuantity(resultSet.getObject("QUANTITY", BigDecimal.class));
|
||||
object.setFirstLegAmount(resultSet.getObject("FIRST_LEG_AMOUNT", BigDecimal.class));
|
||||
object.setSecondLegAmount(resultSet.getObject("SECOND_LEG_AMOUNT", BigDecimal.class));
|
||||
object.setInterestAmount(resultSet.getObject("INTEREST_AMOUNT", BigDecimal.class));
|
||||
object.setSide(resultSet.getObject("SIDE", String.class));
|
||||
object.setSettlementCurrency(resultSet.getObject("SETTLEMENT_CURRENCY", String.class));
|
||||
object.setCompanyId(resultSet.getObject("COMPANY_ID", Long.class));
|
||||
object.setDuration(resultSet.getObject("DURATION", Long.class));
|
||||
object.setFirstLegSettlementDate(ReportUtils.getLocalDateFromSqlDate(resultSet, "FIRST_LEG_SETTLEMENT_DATE"));
|
||||
object.setSecondLegSettlementDate(ReportUtils.getLocalDateFromSqlDate(resultSet, "SECOND_LEG_SETTLEMENT_DATE"));
|
||||
object.setFirstLegSettlementCode(resultSet.getObject("FIRST_LEG_SETTLEMENT_CODE", String.class));
|
||||
object.setSecondLegSettlementCode(resultSet.getObject("SECOND_LEG_SETTLEMENT_CODE", String.class));
|
||||
object.setSecurityFullName(resultSet.getObject("SECURITY_FULL_NAME", String.class));
|
||||
object.setSecuritySymbol(resultSet.getObject("SECURITY_SYMBOL", String.class));
|
||||
object.setSecurityCode(resultSet.getObject("SECURITY_CODE", String.class));
|
||||
object.setSecurityId(resultSet.getObject("SECURITY_ID", Long.class));
|
||||
object.setContract(resultSet.getObject("CONTRACT", String.class));
|
||||
object.setCounterPartyId(resultSet.getObject("COUNTER_PARTY_ID", Long.class));
|
||||
object.setCoverageStatus(resultSet.getObject("COVERAGE_STATUS", String.class));
|
||||
object.setSessionId(resultSet.getObject("SESSION_ID", Long.class));
|
||||
object.setClearingDate(ReportUtils.getLocalDateFromSqlDate(resultSet, "CLEARING_DATE"));
|
||||
object.setCounterPartyTradingClearingRegistryId(resultSet.getObject("COUNTER_PARTY_TRADING_CLEARING_REGISTRY_ID", Long.class));
|
||||
return object;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,220 @@
|
|||
package ru.spcex.clearing.registry.reports.loaders;
|
||||
|
||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.spcex.clearing.registry.conf.properties.AProperties;
|
||||
import ru.spcex.clearing.registry.reports.ReportUtils;
|
||||
import ru.spcex.clearing.registry.reports.bean.*;
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.AllowedDictionaryRowMapper;
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.CompanyRowMapper;
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.CompanySymbolsRowMapper;
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.TradingClearingRegistryRowMapper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Component
|
||||
public class ExecutionFondLoader extends IDBLoader<ExecutionFond> {
|
||||
protected ExecutionFondLoader(AProperties properties, NamedParameterJdbcTemplate clearingJdbc) {
|
||||
super(properties.getPeriod(), clearingJdbc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ExecutionFond> loadObjects() {
|
||||
try {
|
||||
List<ExecutionFond> executionFonds = super.loadObjects();
|
||||
if (executionFonds.isEmpty()) {
|
||||
log.warn("ExecutionFond not found.");
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
Map<Long, List<ExecutionFond>> groupedExecutionFondForTKR = executionFonds.stream()
|
||||
.collect(Collectors.groupingBy(ExecutionFond::getTradingClearingRegistryId));
|
||||
Set<Long> tkrIds = groupedExecutionFondForTKR.keySet();
|
||||
MapSqlParameterSource parameterSource = new MapSqlParameterSource();
|
||||
parameterSource.addValue("ids", tkrIds);
|
||||
List<TradingClearingRegistry> tradingClearingRegistries = clearingJdbc.query(
|
||||
"select ID, CODE from TRADING_CLEARING_REGISTRY where ID in (:ids)",
|
||||
parameterSource, new TradingClearingRegistryRowMapper()
|
||||
);
|
||||
for (TradingClearingRegistry tkr : tradingClearingRegistries) {
|
||||
List<ExecutionFond> executionFondList = groupedExecutionFondForTKR.get(tkr.getId());
|
||||
for (ExecutionFond fond : executionFondList) {
|
||||
fond.setSellerTkrCode(tkr.getCode());
|
||||
}
|
||||
}
|
||||
|
||||
Map<Long, List<CompanySymbols>> companySymbolsForCompanyIdMap;
|
||||
{
|
||||
Set<Long> companyIds = executionFonds.stream().map(ExecutionFond::getCompanyId).collect(Collectors.toSet());
|
||||
parameterSource = new MapSqlParameterSource();
|
||||
parameterSource.addValue("ids", companyIds);
|
||||
parameterSource.addValue("cs", CompanySymbol.CLRC.getKey());
|
||||
List<CompanySymbols> companySymbolsForCompanyId = clearingJdbc.query(
|
||||
"select ID, COMPANY_ID, COMPANY_SYMBOL, COMPANY_SYMBOL_VALUE from COMPANY_SYMBOLS where COMPANY_ID in (:ids) and COMPANY_SYMBOL = :cs",
|
||||
parameterSource, new CompanySymbolsRowMapper()
|
||||
);
|
||||
companySymbolsForCompanyIdMap = companySymbolsForCompanyId.stream().collect(Collectors.groupingBy(CompanySymbols::getCompanyId));
|
||||
}
|
||||
|
||||
Map<Long, List<CompanySymbols>> companySymbolsForCounterPartyIdMap;
|
||||
{
|
||||
Set<Long> counterPartyIds = executionFonds.stream().map(ExecutionFond::getCounterPartyId).collect(Collectors.toSet());
|
||||
parameterSource = new MapSqlParameterSource();
|
||||
parameterSource.addValue("ids", counterPartyIds);
|
||||
parameterSource.addValue("companySymbol", CompanySymbol.CLRC.getKey());
|
||||
List<CompanySymbols> companySymbolsForCounterPartyId = clearingJdbc.query(
|
||||
"select ID, COMPANY_ID, COMPANY_SYMBOL, COMPANY_SYMBOL_VALUE from COMPANY_SYMBOLS where COMPANY_ID in (:ids) and COMPANY_SYMBOL = :companySymbol",
|
||||
parameterSource, new CompanySymbolsRowMapper()
|
||||
);
|
||||
companySymbolsForCounterPartyIdMap = companySymbolsForCounterPartyId.stream().collect(Collectors.groupingBy(CompanySymbols::getCompanyId));
|
||||
}
|
||||
|
||||
Map<Long, Company> companyById;
|
||||
{
|
||||
Set<Long> allCompanyIds = Stream.concat(
|
||||
executionFonds.stream().map(ExecutionFond::getCompanyId),
|
||||
executionFonds.stream().map(ExecutionFond::getCounterPartyId))
|
||||
.collect(Collectors.toSet());
|
||||
parameterSource = new MapSqlParameterSource();
|
||||
parameterSource.addValue("ids", allCompanyIds);
|
||||
List<Company> companyForCompanyId = clearingJdbc.query(
|
||||
"select ID, CLEARING_CODE, SHORT_NAME from COMPANY where ID in (:ids)",
|
||||
parameterSource, new CompanyRowMapper()
|
||||
);
|
||||
companyById = companyForCompanyId.stream()
|
||||
.collect(Collectors.toMap(Company::getId, o -> o));
|
||||
}
|
||||
|
||||
Set<String> coverageStatuses = executionFonds.stream().map(ExecutionFond::getCoverageStatus).collect(Collectors.toSet());
|
||||
parameterSource = new MapSqlParameterSource();
|
||||
parameterSource.addValue("coverageStatuses", coverageStatuses);
|
||||
List<AllowedDictionary> allowedDictionaries = clearingJdbc.query(
|
||||
"select CODE, NAME from ALLOWED_DICTIONARY where CODE in (:coverageStatuses)",
|
||||
parameterSource, new AllowedDictionaryRowMapper()
|
||||
);
|
||||
Map<String, List<AllowedDictionary>> allowedDictionariesByCode = allowedDictionaries.stream()
|
||||
.collect(Collectors.groupingBy(AllowedDictionary::getCode));
|
||||
|
||||
for (ExecutionFond executionFond : executionFonds) {
|
||||
Company companyByCompanyId = companyById.get(executionFond.getCompanyId());
|
||||
Company companyByCounterPartyId = companyById.get(executionFond.getCounterPartyId());
|
||||
String side = executionFond.getSide() == null ? null : executionFond.getSide().toUpperCase();
|
||||
if (MoneyFlowSide.SELL.equalsByKey(side) || Side.SELL.equalsByKey(side)) {
|
||||
if (companyByCompanyId != null) {
|
||||
executionFond.setSeller(companyByCompanyId.getShortName());
|
||||
}
|
||||
if (companyByCounterPartyId != null) {
|
||||
executionFond.setBuyer(companyByCounterPartyId.getShortName());
|
||||
}
|
||||
{
|
||||
List<CompanySymbols> cSymbols = companySymbolsForCompanyIdMap.get(executionFond.getCompanyId());
|
||||
if (cSymbols != null && !cSymbols.isEmpty()) {
|
||||
CompanySymbols companySymbols = cSymbols.iterator().next();
|
||||
executionFond.setSellerCode(companySymbols.getCompanySymbolValue());
|
||||
}
|
||||
}
|
||||
{
|
||||
List<CompanySymbols> cSymbols = companySymbolsForCounterPartyIdMap.get(executionFond.getCounterPartyId());
|
||||
if (cSymbols != null && !cSymbols.isEmpty()) {
|
||||
CompanySymbols companySymbols = cSymbols.iterator().next();
|
||||
executionFond.setBuyerCode(companySymbols.getCompanySymbolValue());
|
||||
}
|
||||
}
|
||||
executionFond.setBuyerTkrCode(executionFond.getCounterPartyTradingClearingRegistry());
|
||||
} else if (MoneyFlowSide.BUY.equalsByKey(side) || Side.BUY.equalsByKey(side)) {
|
||||
if (companyByCompanyId != null) {
|
||||
executionFond.setBuyer(companyByCompanyId.getShortName());
|
||||
}
|
||||
if (companyByCounterPartyId != null) {
|
||||
executionFond.setSeller(companyByCounterPartyId.getShortName());
|
||||
}
|
||||
{
|
||||
List<CompanySymbols> cSymbols = companySymbolsForCompanyIdMap.get(executionFond.getCompanyId());
|
||||
if (cSymbols != null && !cSymbols.isEmpty()) {
|
||||
CompanySymbols companySymbols = cSymbols.iterator().next();
|
||||
executionFond.setBuyerCode(companySymbols.getCompanySymbolValue());
|
||||
}
|
||||
}
|
||||
{
|
||||
List<CompanySymbols> cSymbols = companySymbolsForCounterPartyIdMap.get(executionFond.getCounterPartyId());
|
||||
if (cSymbols != null && !cSymbols.isEmpty()) {
|
||||
CompanySymbols companySymbols = cSymbols.iterator().next();
|
||||
executionFond.setSellerCode(companySymbols.getCompanySymbolValue());
|
||||
}
|
||||
}
|
||||
executionFond.setBuyerTkrCode(executionFond.getPartyTradingClearingRegistry());
|
||||
} else {
|
||||
log.warn("Unknown executionFond[{}].side={}", executionFond.getId(), executionFond.getSide());
|
||||
}
|
||||
List<AllowedDictionary> allowed = allowedDictionariesByCode.get(executionFond.getCoverageStatus());
|
||||
if (allowed != null && !allowed.isEmpty()) {
|
||||
executionFond.setStatus(allowed.iterator().next().getName());
|
||||
}
|
||||
}
|
||||
|
||||
return executionFonds;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("At ExecutionFondLoader", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected ExecutionFond fromRS(ResultSet resultSet) throws SQLException {
|
||||
ExecutionFond object = new ExecutionFond();
|
||||
object.setId(resultSet.getObject("ID", Long.class));
|
||||
object.setCreated(ReportUtils.getInstantFromTimestamp(resultSet, "CREATED_AT"));
|
||||
object.setUpdated(ReportUtils.getInstantFromTimestamp(resultSet, "UPDATED_AT"));
|
||||
object.setClearingDate(ReportUtils.getLocalDateFromSqlDate(resultSet, "CLEARING_DATE"));
|
||||
object.setExchangeExecutionId(resultSet.getObject("EXCHANGE_EXECUTION_ID", Long.class));
|
||||
object.setSide(resultSet.getObject("SIDE", String.class));
|
||||
object.setMarket(resultSet.getObject("MARKET", String.class));
|
||||
object.setTradingDate(ReportUtils.getLocalDateFromSqlDate(resultSet, "TRADING_DATE"));
|
||||
object.setSecuritySymbol(resultSet.getObject("SECURITY_SYMBOL", String.class));
|
||||
object.setSecurityId(resultSet.getObject("SECURITY_ID", Long.class));
|
||||
object.setInterestAmount(resultSet.getObject("INTEREST_AMOUNT", BigDecimal.class));
|
||||
object.setExchangeOrderId(resultSet.getObject("EXCHANGE_ORDER_ID", Long.class));
|
||||
object.setPrice(resultSet.getObject("PRICE", BigDecimal.class));
|
||||
object.setSettlementAmount(resultSet.getObject("SETTLEMENT_AMOUNT", BigDecimal.class));
|
||||
object.setLots(resultSet.getObject("LOTS", BigDecimal.class));
|
||||
object.setQuantity(resultSet.getObject("QUANTITY", BigDecimal.class));
|
||||
object.setExchangeExecutionTime(ReportUtils.getInstantFromTimestamp(resultSet, "EXCHANGE_EXECUTION_TIME"));
|
||||
object.setDuration(resultSet.getObject("DURATION", Long.class));
|
||||
object.setTradingClearingRegistryId(resultSet.getObject("TRADING_CLEARING_REGISTRY_ID", Long.class));
|
||||
object.setPartyTradingClearingRegistry(resultSet.getObject("PARTY_TRADING_CLEARING_REGISTRY", String.class));
|
||||
object.setCounterPartyTradingClearingRegistry(resultSet.getObject("COUNTER_PARTY_TRADING_CLEARING_REGISTRY", String.class));
|
||||
object.setComment(resultSet.getObject("COMMENT", String.class));
|
||||
object.setClientCodeId(resultSet.getObject("CLIENT_CODE_ID", Long.class));
|
||||
object.setSettlementCode(resultSet.getObject("SETTLEMENT_CODE", String.class));
|
||||
object.setCompanyId(resultSet.getObject("COMPANY_ID", Long.class));
|
||||
object.setCounterPartyId(resultSet.getObject("COUNTER_PARTY_ID", Long.class));
|
||||
object.setSecurityFullName(resultSet.getObject("SECURITY_FULL_NAME", String.class));
|
||||
object.setSettlementDate(ReportUtils.getLocalDateFromSqlDate(resultSet, "SETTLEMENT_DATE"));
|
||||
object.setSettlementCurrency(resultSet.getObject("SETTLEMENT_CURRENCY", String.class));
|
||||
object.setExchangeExecutionMicroseconds(ReportUtils.getInstantFromTimestamp(resultSet, "EXCHANGE_EXECUTION_MICROSECONDS"));
|
||||
object.setCoverageStatus(resultSet.getObject("COVERAGE_STATUS", String.class));
|
||||
object.setSessionId(resultSet.getObject("SESSION_ID", Long.class));
|
||||
object.setCounterPartyTradingClearingRegistryId(resultSet.getObject("COUNTER_PARTY_TRADING_CLEARING_REGISTRY_ID", Long.class));
|
||||
return object;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String sqlQuery() {
|
||||
return "select * from EXECUTION_FOND where CLEARING_DATE >= :startDate and CLEARING_DATE < :endDate";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<ExecutionFond> getDBObjectClass() {
|
||||
return ExecutionFond.class;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package ru.spcex.clearing.registry.reports.loaders;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
import ru.spcex.clearing.registry.conf.properties.PeriodProperties;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class IDBLoader<T extends IDBObject> {
|
||||
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||
protected final PeriodProperties periodProperties;
|
||||
protected final NamedParameterJdbcTemplate clearingJdbc;
|
||||
|
||||
protected IDBLoader(PeriodProperties periodProperties, NamedParameterJdbcTemplate clearingJdbc) {
|
||||
this.periodProperties = periodProperties;
|
||||
this.clearingJdbc = clearingJdbc;
|
||||
}
|
||||
|
||||
public List<T> loadObjects() {
|
||||
log.trace("Загрузчик {}", getClass().getSimpleName());
|
||||
long timer = System.currentTimeMillis();
|
||||
try {
|
||||
String sql = sqlQuery();
|
||||
assert sql.contains(":startDate") && sql.contains(":endDate");
|
||||
MapSqlParameterSource parameterSource = new MapSqlParameterSource();
|
||||
parameterSource.addValue("startDate", periodProperties.getStartDate());
|
||||
LocalDate endDate = periodProperties.getEndDate();
|
||||
endDate = endDate.plusDays(1); // startDate <= x < endDate, в базе может быть как DATE, TIMESTAMP
|
||||
parameterSource.addValue("endDate", endDate);
|
||||
log.debug("Запрос SQL: \"{}\", с параметрами: startDate={}, endDate={}",
|
||||
sql, periodProperties.getStartDate(), endDate);
|
||||
return clearingJdbc.query(sql, parameterSource, (rs, rowNum) -> fromRS(rs));
|
||||
} catch (Exception e) {
|
||||
log.error("Не могу загрузить объект класса %s, причина:".formatted(getDBObjectClass()), e);
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
timer = System.currentTimeMillis() - timer;
|
||||
log.debug("Загрузка {} завершена за {} ms", getDBObjectClass().getSimpleName(), timer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Метод должен возвращать либо объект, либо null если объект не подходит под условия
|
||||
* (тогда он не будет включен в выборку)
|
||||
*/
|
||||
protected abstract T fromRS(ResultSet rs) throws SQLException;
|
||||
|
||||
/**
|
||||
* В созданном запросе обязательно должны быть параметры startDate и endDate
|
||||
*/
|
||||
protected abstract String sqlQuery();
|
||||
|
||||
protected abstract Class<T> getDBObjectClass();
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
package ru.spcex.clearing.registry.reports.loaders;
|
||||
|
||||
public interface IDBObject {
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package ru.spcex.clearing.registry.reports.loaders;
|
||||
|
||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.spcex.clearing.registry.conf.properties.AProperties;
|
||||
import ru.spcex.clearing.registry.exceptions.ConfigurationException;
|
||||
import ru.spcex.clearing.registry.reports.bean.Company;
|
||||
import ru.spcex.clearing.registry.reports.bean.RegistryHistory;
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class MoneyBalanceLoader extends RegistryHistoryLoader {
|
||||
private String houseName = "";
|
||||
|
||||
protected MoneyBalanceLoader(AProperties properties, NamedParameterJdbcTemplate clearingJdbc) {
|
||||
super(properties, clearingJdbc);
|
||||
MapSqlParameterSource parameterSource = new MapSqlParameterSource();
|
||||
parameterSource.addValue("houseId", 2L);
|
||||
List<Company> result = null;
|
||||
try {
|
||||
result = clearingJdbc.query(
|
||||
"select ID, CLEARING_CODE, SHORT_NAME from COMPANY where id = :houseId",
|
||||
parameterSource, new CompanyRowMapper()
|
||||
);
|
||||
} catch (Exception e) {
|
||||
throw new ConfigurationException("Не могу получить объект companyId = 2 из БД");
|
||||
}
|
||||
if (!result.isEmpty()) houseName = result.iterator().next().getShortName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RegistryHistory> loadObjects() {
|
||||
List<RegistryHistory> result = super.loadObjects();
|
||||
result = result.stream()
|
||||
.filter(registryHistory -> registryHistory.getObject().getDiffBalance().compareTo(BigDecimal.ZERO) == 0)
|
||||
.collect(Collectors.toList());
|
||||
for (RegistryHistory registryHistory : result) {
|
||||
registryHistory.setHouseName(houseName);
|
||||
AccountType accountType = IEnumKey.getEnumByKey(AccountType.class, registryHistory.getObject().getAccountType());
|
||||
String account;
|
||||
if (accountType == AccountType.Clrn || accountType == AccountType.Info) {
|
||||
account = registryHistory.getObject().getAccount();
|
||||
registryHistory.setAccount(account);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String sqlQuery() {
|
||||
RegistryCodeSqlBuilder registryCodeSqlBuilder = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.AM_T);
|
||||
return ("select * from REGISTRY_HISTORY where EVENT_TIME >= :startDate and EVENT_TIME < :endDate and (%s) " +
|
||||
"and TRADING_CLEARING_REGISTRY is not null and (diff_balance=0 or account_type='INFO')")
|
||||
// diff_balance=0 то же что и check_balance=balance
|
||||
.formatted(registryCodeSqlBuilder.buildSql());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
package ru.spcex.clearing.registry.reports.loaders;
|
||||
|
||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.spcex.clearing.registry.conf.properties.AProperties;
|
||||
import ru.spcex.clearing.registry.reports.bean.Account;
|
||||
import ru.spcex.clearing.registry.reports.bean.Company;
|
||||
import ru.spcex.clearing.registry.reports.bean.PaymentInstruction;
|
||||
import ru.spcex.clearing.registry.reports.bean.Security;
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.AccountRowMapper;
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.AccountType;
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.CompanyRowMapper;
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.SecurityRowMapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class MoneyInstructionLoader extends PaymentInstructionLoader {
|
||||
private final Set<String> MONEY_ACCOUNT_TYPES = Set.of(
|
||||
AccountType.Clrn.getKey(),
|
||||
AccountType.Info.getKey(),
|
||||
AccountType.Anlt.getKey(),
|
||||
AccountType.Tran.getKey()
|
||||
);
|
||||
|
||||
protected MoneyInstructionLoader(AProperties properties, NamedParameterJdbcTemplate clearingJdbc) {
|
||||
super(properties, clearingJdbc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PaymentInstruction> loadObjects() {
|
||||
List<PaymentInstruction> result = new ArrayList<>();
|
||||
|
||||
List<PaymentInstruction> paymentInstructions = super.loadObjects();
|
||||
if (paymentInstructions.isEmpty()) {
|
||||
log.warn("PaymentInstructions not found.");
|
||||
return result;
|
||||
}
|
||||
Map<Long, List<PaymentInstruction>> groupedPaymentInstruction = paymentInstructions.stream()
|
||||
.collect(Collectors.groupingBy(PaymentInstruction::getCreditLeg_accountId));
|
||||
List<Long> ids = paymentInstructions.stream().map(PaymentInstruction::getCreditLeg_accountId).toList();
|
||||
MapSqlParameterSource parameterSource = new MapSqlParameterSource();
|
||||
parameterSource.addValue("ids", ids);
|
||||
List<Account> accounts = clearingJdbc.query(
|
||||
"select ID, ACCOUNT_TYPE from ACCOUNT where ID in (:ids)",
|
||||
parameterSource, new AccountRowMapper()
|
||||
);
|
||||
for (Account account : accounts) {
|
||||
if (account.getAccountType() != null && !MONEY_ACCOUNT_TYPES.contains(account.getAccountType().toUpperCase()))
|
||||
continue;
|
||||
Long id = account.getId();
|
||||
List<PaymentInstruction> payments = groupedPaymentInstruction.get(id);
|
||||
if (!payments.isEmpty()) result.addAll(payments);
|
||||
}
|
||||
|
||||
{
|
||||
Map<Long, List<PaymentInstruction>> groupedPaymentInstructionBySenderId = paymentInstructions.stream()
|
||||
.collect(Collectors.groupingBy(PaymentInstruction::getSenderId));
|
||||
List<Long> senderIds = new ArrayList<>(groupedPaymentInstructionBySenderId.keySet());
|
||||
parameterSource = new MapSqlParameterSource();
|
||||
parameterSource.addValue("ids", senderIds);
|
||||
List<Company> companies = clearingJdbc.query(
|
||||
"select ID, CLEARING_CODE, SHORT_NAME from COMPANY where ID in (:ids)",
|
||||
parameterSource, new CompanyRowMapper()
|
||||
);
|
||||
for (Company company : companies) {
|
||||
Long id = company.getId();
|
||||
List<PaymentInstruction> payments = groupedPaymentInstructionBySenderId.get(id);
|
||||
if (payments != null) {
|
||||
for (PaymentInstruction paymentInstruction : payments) {
|
||||
paymentInstruction.setSender(company.getShortName());
|
||||
paymentInstruction.setSenderClearingCode(company.getClearingCode());
|
||||
paymentInstruction.setSenderCompanyClearingCode(company.getClearingCode());
|
||||
paymentInstruction.setSenderCompanyShortName(company.getShortName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
Map<Long, List<PaymentInstruction>> groupedPaymentInstructionByAddresseeId = paymentInstructions.stream()
|
||||
.collect(Collectors.groupingBy(PaymentInstruction::getAddresseeId));
|
||||
List<Long> addresseeIds = new ArrayList<>(groupedPaymentInstructionByAddresseeId.keySet());
|
||||
parameterSource = new MapSqlParameterSource();
|
||||
parameterSource.addValue("ids", addresseeIds);
|
||||
List<Company> companies = clearingJdbc.query(
|
||||
"select ID, CLEARING_CODE, SHORT_NAME from COMPANY where ID in (:ids)",
|
||||
parameterSource, new CompanyRowMapper()
|
||||
);
|
||||
for (Company company : companies) {
|
||||
Long id = company.getId();
|
||||
List<PaymentInstruction> payments = groupedPaymentInstructionByAddresseeId.get(id);
|
||||
if (payments != null) {
|
||||
for (PaymentInstruction paymentInstruction : payments) {
|
||||
paymentInstruction.setAddressee(company.getShortName());
|
||||
paymentInstruction.setAddresseeClearingCode(company.getClearingCode());
|
||||
paymentInstruction.setAddresseeCompanyClearingCode(company.getClearingCode());
|
||||
paymentInstruction.setAddresseeCompanyShortName(company.getShortName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<Long, List<PaymentInstruction>> groupedBySecurityId = paymentInstructions.stream()
|
||||
.collect(Collectors.groupingBy(PaymentInstruction::getCreditLeg_securityId));
|
||||
Set<Long> securityIds = groupedBySecurityId.keySet();
|
||||
MapSqlParameterSource parameterSourceSecurityIds = new MapSqlParameterSource();
|
||||
parameterSourceSecurityIds.addValue("ids", securityIds);
|
||||
List<Security> securities = clearingJdbc.query(
|
||||
"select ID, SECURITY_SYMBOL from SECURITY where ID in (:ids)",
|
||||
parameterSourceSecurityIds, new SecurityRowMapper()
|
||||
);
|
||||
for (Security security : securities) {
|
||||
List<PaymentInstruction> paymentInstructionList = groupedBySecurityId.get(security.getId());
|
||||
if (paymentInstructionList != null) {
|
||||
for (PaymentInstruction paymentInstruction : paymentInstructionList) {
|
||||
paymentInstruction.setSecurity(security.getSecuritySymbol());
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
package ru.spcex.clearing.registry.reports.loaders;
|
||||
|
||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.spcex.clearing.registry.conf.properties.AProperties;
|
||||
import ru.spcex.clearing.registry.reports.ReportUtils;
|
||||
import ru.spcex.clearing.registry.reports.bean.Account;
|
||||
import ru.spcex.clearing.registry.reports.bean.PaymentInstruction;
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.Account2RowMapper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public abstract class PaymentInstructionLoader extends IDBLoader<PaymentInstruction> {
|
||||
protected PaymentInstructionLoader(AProperties properties, NamedParameterJdbcTemplate clearingJdbc) {
|
||||
super(properties.getPeriod(), clearingJdbc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PaymentInstruction> loadObjects() {
|
||||
List<PaymentInstruction> paymentInstructions = super.loadObjects();
|
||||
if (paymentInstructions.isEmpty()) {
|
||||
log.warn("PaymentInstruction not found.");
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
Collection<Long> allAccountIds = paymentInstructions.stream()
|
||||
.map(PaymentInstruction::getCreditLeg_accountId)
|
||||
.collect(Collectors.toSet());
|
||||
allAccountIds.addAll(paymentInstructions.stream()
|
||||
.map(PaymentInstruction::getDebitLeg_accountId)
|
||||
.collect(Collectors.toSet()));
|
||||
|
||||
MapSqlParameterSource parameterSource = new MapSqlParameterSource();
|
||||
parameterSource.addValue("ids", allAccountIds);
|
||||
List<Account> accounts = clearingJdbc.query(
|
||||
"select ID, ACCOUNT_TYPE, ACCOUNT from ACCOUNT where ID in (:ids)",
|
||||
parameterSource, new Account2RowMapper()
|
||||
);
|
||||
Map<Long, Account> accountIdMap = accounts.stream().collect(Collectors.toMap(Account::getId, o -> o));
|
||||
|
||||
for (PaymentInstruction p : paymentInstructions) {
|
||||
Account creditLegAccount = accountIdMap.get(p.getCreditLeg_accountId());
|
||||
if (creditLegAccount != null)
|
||||
p.setCreditLegAccountStr(creditLegAccount.getAccount());
|
||||
Account debitLegAccount = accountIdMap.get(p.getDebitLeg_accountId());
|
||||
if (debitLegAccount != null)
|
||||
p.setDebitLegAccountStr(debitLegAccount.getAccount());
|
||||
}
|
||||
|
||||
return paymentInstructions;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PaymentInstruction fromRS(ResultSet resultSet) throws SQLException {
|
||||
PaymentInstruction object = new PaymentInstruction();
|
||||
object.setId(resultSet.getObject("ID", Long.class));
|
||||
object.setSenderId(resultSet.getObject("SENDER_ID", Long.class));
|
||||
object.setAddresseeId(resultSet.getObject("ADDRESSEE_ID", Long.class));
|
||||
object.setPayeeBic(resultSet.getObject("PAYEE_BIC", String.class));
|
||||
object.setAddresseeBic(resultSet.getObject("ADRESSEE_BIC", String.class));
|
||||
object.setPayeeBankName(resultSet.getObject("PAYEE_BANK_NAME", String.class));
|
||||
object.setAddresseeBankName(resultSet.getObject("ADDRESSEE_BANK_NAME", String.class));
|
||||
object.setPaymentDate(ReportUtils.getInstantFromTimestamp(resultSet, "PAYMENT_DATE"));
|
||||
object.setPaymentPurpose(resultSet.getObject("PAYMENT_PURPOSE", String.class));
|
||||
object.setSettlementDate(ReportUtils.getLocalDateFromSqlDate(resultSet, "SETTLEMENT_DATE"));
|
||||
object.setCreditLeg_amount(resultSet.getObject("CREDIT_LEG_AMOUNT", BigDecimal.class));
|
||||
object.setDebitLeg_amount(resultSet.getObject("DEBIT_LEG_AMOUNT", BigDecimal.class));
|
||||
object.setCreditLeg_accountId(resultSet.getObject("CREDIT_LEG_ACCOUNT_ID", Long.class));
|
||||
object.setCredit_csAccount(resultSet.getObject("CREDIT_CS_ACCOUNT", String.class));
|
||||
object.setCreditLeg_account(resultSet.getObject("CREDIT_LEG_ACCOUNT", String.class));
|
||||
object.setDebitLeg_accountId(resultSet.getObject("DEBIT_LEG_ACCOUNT_ID", Long.class));
|
||||
object.setDebit_csAccount(resultSet.getObject("DEBIT_CS_ACCOUNT", String.class));
|
||||
object.setDebitLeg_account(resultSet.getObject("DEBIT_LEG_ACCOUNT", String.class));
|
||||
object.setCreditLeg_direction(resultSet.getObject("CREDIT_LEG_DIRECTION", String.class));
|
||||
object.setDebitLeg_direction(resultSet.getObject("DEBIT_LEG_DIRECTION", String.class));
|
||||
object.setCreditLeg_currencyCode(resultSet.getObject("CREDIT_LEG_CURRENCY_CODE", String.class));
|
||||
object.setDebitLeg_currencyCode(resultSet.getObject("DEBIT_LEG_CURRENCY_CODE", String.class));
|
||||
object.setCreditLeg_securityId(resultSet.getObject("CREDIT_LEG_SECURITY_ID", Long.class));
|
||||
object.setDebitLeg_securityId(resultSet.getObject("DEBIT_LEG_SECURITY_ID", Long.class));
|
||||
object.setTransactionStatus(resultSet.getObject("TRANSACTION_STATUS", String.class));
|
||||
object.setDocumentNumber(resultSet.getObject("DOCUMENT_NUMBER", String.class));
|
||||
object.setCreated(ReportUtils.getInstantFromTimestamp(resultSet, "CREATED_AT"));
|
||||
object.setUpdated(ReportUtils.getInstantFromTimestamp(resultSet, "UPDATED_AT"));
|
||||
object.setClearingDate(ReportUtils.getLocalDateFromSqlDate(resultSet, "CLEARING_DATE"));
|
||||
object.setSessionId(resultSet.getObject("SESSION_ID", Long.class));
|
||||
return object;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<PaymentInstruction> getDBObjectClass() {
|
||||
return PaymentInstruction.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String sqlQuery() {
|
||||
return "select * from PAYMENT_INSTRUCTION where CLEARING_DATE >= :startDate and CLEARING_DATE < :endDate";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
package ru.spcex.clearing.registry.reports.loaders;
|
||||
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.spcex.clearing.registry.conf.properties.AProperties;
|
||||
import ru.spcex.clearing.registry.reports.ReportUtils;
|
||||
import ru.spcex.clearing.registry.reports.bean.Registry;
|
||||
import ru.spcex.clearing.registry.reports.bean.RegistryHistory;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
@Component
|
||||
public abstract class RegistryHistoryLoader extends IDBLoader<RegistryHistory> {
|
||||
protected RegistryHistoryLoader(AProperties properties,
|
||||
NamedParameterJdbcTemplate clearingJdbc) {
|
||||
super(properties.getPeriod(), clearingJdbc);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RegistryHistory fromRS(ResultSet resultSet) throws SQLException {
|
||||
RegistryHistory historyObject = new RegistryHistory();
|
||||
Registry object = new Registry();
|
||||
|
||||
historyObject.setId(resultSet.getObject("ID", Long.class));
|
||||
historyObject.setEventTime(ReportUtils.getInstantFromTimestamp(resultSet, "EVENT_TIME"));
|
||||
historyObject.setUserId(resultSet.getObject("EVENT_USER_ID", Long.class));
|
||||
historyObject.setEventType(resultSet.getObject("EVENT_TYPE", String.class));
|
||||
|
||||
object.setCreated(ReportUtils.getInstantFromTimestamp(resultSet, "CREATED_AT"));
|
||||
object.setUpdated(ReportUtils.getInstantFromTimestamp(resultSet, "UPDATED_AT"));
|
||||
|
||||
object.setId(resultSet.getObject("REGISTRY_ID", Long.class));
|
||||
object.setCompanyId(resultSet.getObject("COMPANY_ID", Long.class));
|
||||
object.setTradingCode(resultSet.getObject("TRADING_CODE", String.class));
|
||||
object.setClearingCode(resultSet.getObject("CLEARING_CODE", String.class));
|
||||
object.setShortName(resultSet.getObject("SHORT_NAME", String.class));
|
||||
object.setFullName(resultSet.getObject("FULL_NAME", String.class));
|
||||
object.setAccountId(resultSet.getObject("ACCOUNT_ID", Long.class));
|
||||
|
||||
object.setAccountType(resultSet.getObject("ACCOUNT_TYPE", String.class));
|
||||
object.setAccount(resultSet.getObject("ACCOUNT", String.class));
|
||||
object.setRegistryDesignation(resultSet.getObject("REGISTRY_DESIGNATION", String.class));
|
||||
object.setRegistryInstrumentType(resultSet.getObject("REGISTRY_INSTRUMENT_TYPE", String.class));
|
||||
object.setRegistryCapacity(resultSet.getObject("REGISTRY_CAPACITY", String.class));
|
||||
|
||||
object.setRegistryUnit(resultSet.getObject("REGISTRY_UNIT", String.class));
|
||||
object.setRegistryCode(resultSet.getObject("REGISTRY_CODE", String.class));
|
||||
object.setTradingClearingRegistryId(resultSet.getObject("TRADING_CLEARING_REGISTRY_ID", Long.class));
|
||||
object.setTradingClearingRegistry(resultSet.getObject("TRADING_CLEARING_REGISTRY", String.class));
|
||||
|
||||
object.setRegistryStatus(resultSet.getObject("REGISTRY_STATUS", String.class));
|
||||
object.setSecurityId(resultSet.getObject("SECURITY_ID", Long.class));
|
||||
object.setSecuritySymbol(resultSet.getObject("SECURITY_SYMBOL", String.class));
|
||||
object.setBalance(resultSet.getObject("BALANCE", BigDecimal.class));
|
||||
object.setOpenBalance(resultSet.getObject("OPEN_BALANCE", BigDecimal.class));
|
||||
object.setCloseBalance(resultSet.getObject("CLOSE_BALANCE", BigDecimal.class));
|
||||
|
||||
object.setCredit(resultSet.getObject("CREDIT", BigDecimal.class));
|
||||
object.setDebit(resultSet.getObject("DEBIT", BigDecimal.class));
|
||||
object.setSettledCredit(resultSet.getObject("SETTLED_CREDIT", BigDecimal.class));
|
||||
object.setSettledDebit(resultSet.getObject("SETTLED_DEBIT", BigDecimal.class));
|
||||
object.setCheckBalance(resultSet.getObject("CHECK_BALANCE", BigDecimal.class));
|
||||
object.setDiffBalance(resultSet.getObject("DIFF_BALANCE", BigDecimal.class));
|
||||
object.setPlanBalance(resultSet.getObject("PLAN_BALANCE", BigDecimal.class));
|
||||
|
||||
object.setBalanceDimension(resultSet.getObject("BALANCE_DIMENSION", String.class));
|
||||
object.setSettlementDate(ReportUtils.getLocalDateFromSqlDate(resultSet, "SETTLEMENT_DATE"));
|
||||
object.setSettlementCode(resultSet.getObject("SETTLEMENT_CODE", String.class));
|
||||
object.setTradingDate(ReportUtils.getLocalDateFromSqlDate(resultSet, "TRADING_DATE"));
|
||||
object.setClearingDate(ReportUtils.getLocalDateFromSqlDate(resultSet, "CLEARING_DATE"));
|
||||
object.setRefundDate(ReportUtils.getLocalDateFromSqlDate(resultSet, "REFUND_DATE"));
|
||||
|
||||
object.setValueDate(ReportUtils.getLocalDateFromSqlDate(resultSet, "VALUE_DATE"));
|
||||
object.setPrice(resultSet.getObject("PRICE", BigDecimal.class));
|
||||
object.setContract(resultSet.getObject("CONTRACT", String.class));
|
||||
object.setCounterPartyId(resultSet.getObject("COUNTER_PARTY_ID", Long.class));
|
||||
object.setComment(resultSet.getObject("COMMENT", String.class));
|
||||
object.setParentId(resultSet.getObject("PARENT_ID", Long.class));
|
||||
object.setGroupId(resultSet.getObject("GROUP_ID", Long.class));
|
||||
object.setSessionId(resultSet.getObject("SESSION_ID", Long.class));
|
||||
|
||||
object.setSessionType(resultSet.getObject("SESSION_TYPE", String.class));
|
||||
object.setPaymentId(resultSet.getObject("PAYMENT_ID", Long.class));
|
||||
|
||||
historyObject.setObject(object);
|
||||
return historyObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String sqlQuery() {
|
||||
return "select * from REGISTRY_HISTORY where EVENT_TIME >= :startDate and EVENT_TIME < :endDate";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<RegistryHistory> getDBObjectClass() {
|
||||
return RegistryHistory.class;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
package ru.spcex.clearing.registry.reports.loaders;
|
||||
|
||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.spcex.clearing.registry.conf.properties.AProperties;
|
||||
import ru.spcex.clearing.registry.reports.ReportUtils;
|
||||
import ru.spcex.clearing.registry.reports.bean.*;
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.ADictionaryRowMapper;
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.RegistryCodeSqlBuilder;
|
||||
import ru.spcex.clearing.registry.reports.loaders.helpers.RegistryTradingParams;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class RegistryLoader extends IDBLoader<Registry> {
|
||||
protected RegistryLoader(AProperties properties, NamedParameterJdbcTemplate clearingJdbc) {
|
||||
super(properties.getPeriod(), clearingJdbc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Registry> loadObjects() {
|
||||
List<Registry> result = super.loadObjects();
|
||||
if (result.isEmpty()) {
|
||||
log.warn("Registries not found.");
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
// Мэппинг словаря здесь, а не в LiabilitiesRegistryReportBuilder
|
||||
{
|
||||
Set<String> registryStatuses = result.stream().map(Registry::getRegistryStatus).collect(Collectors.toSet());
|
||||
MapSqlParameterSource parameterSource = new MapSqlParameterSource();
|
||||
parameterSource.addValue("expectedStatuses", registryStatuses);
|
||||
List<RegistryStatusDictionary> registryStatusDictionaries = clearingJdbc.query(
|
||||
"select CODE, NAME from registry_status_dictionary where CODE in (:expectedStatuses)",
|
||||
parameterSource, ADictionaryRowMapper.forRegistryStatusDictionary()
|
||||
);
|
||||
mappingField(result, registryStatusDictionaries, Registry::getRegistryStatus, Registry::setRegistryStatus_dictionary);
|
||||
}
|
||||
{
|
||||
Set<String> sessionTypes = result.stream().map(Registry::getSessionType).collect(Collectors.toSet());
|
||||
MapSqlParameterSource parameterSource = new MapSqlParameterSource();
|
||||
parameterSource.addValue("sessionTypes", sessionTypes);
|
||||
List<SessionTypeDictionary> sessionTypeDictionaries = clearingJdbc.query(
|
||||
"select CODE, NAME from session_type_dictionary where CODE in (:sessionTypes)",
|
||||
parameterSource, ADictionaryRowMapper.forSessionTypeDictionary()
|
||||
);
|
||||
mappingField(result, sessionTypeDictionaries, Registry::getSessionType, Registry::setSessionType_dictionary);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private <D extends AbstractDictionary> void mappingField(Collection<Registry> inRows,
|
||||
List<D> dictionaryLst,
|
||||
Function<Registry, String> getter, BiConsumer<Registry, String> setter) {
|
||||
Map<String, List<D>> registryStatusDictionariesByCode = dictionaryLst.stream()
|
||||
.collect(Collectors.groupingBy(D::getCode));
|
||||
for (Registry registry : inRows) {
|
||||
String key = getter.apply(registry);
|
||||
List<D> regStatuses = registryStatusDictionariesByCode.get(key);
|
||||
String value = key;
|
||||
if (regStatuses != null && !regStatuses.isEmpty()) {
|
||||
value = regStatuses.iterator().next().getName();
|
||||
}
|
||||
setter.accept(registry, value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String sqlQuery() {
|
||||
RegistryCodeSqlBuilder registryCodeSqlBuilder = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.OM_T, RegistryTradingParams.OS_T);
|
||||
return ("select * from REGISTRY where SETTLEMENT_DATE >= :startDate and SETTLEMENT_DATE < :endDate " +
|
||||
"and %s and REGISTRY_STATUS='%s'") // and TRADING_CLEARING_REGISTRY is not null
|
||||
.formatted(registryCodeSqlBuilder.buildSql(), RegistryStatus.CLRD.getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<Registry> getDBObjectClass() {
|
||||
return Registry.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Registry fromRS(ResultSet resultSet) throws SQLException {
|
||||
Registry object = new Registry();
|
||||
object.setCompanyId(resultSet.getObject("COMPANY_ID", Long.class));
|
||||
object.setTradingCode(resultSet.getObject("TRADING_CODE", String.class));
|
||||
object.setClearingCode(resultSet.getObject("CLEARING_CODE", String.class));
|
||||
object.setShortName(resultSet.getObject("SHORT_NAME", String.class));
|
||||
object.setFullName(resultSet.getObject("FULL_NAME", String.class));
|
||||
object.setAccountId(resultSet.getObject("ACCOUNT_ID", Long.class));
|
||||
object.setAccountType(resultSet.getObject("ACCOUNT_TYPE", String.class));
|
||||
object.setAccount(resultSet.getObject("ACCOUNT", String.class));
|
||||
object.setRegistryDesignation(resultSet.getObject("REGISTRY_DESIGNATION", String.class));
|
||||
object.setRegistryInstrumentType(resultSet.getObject("REGISTRY_INSTRUMENT_TYPE", String.class));
|
||||
object.setRegistryCapacity(resultSet.getObject("REGISTRY_CAPACITY", String.class));
|
||||
object.setRegistryUnit(resultSet.getObject("REGISTRY_UNIT", String.class));
|
||||
object.setRegistryCode(resultSet.getObject("REGISTRY_CODE", String.class));
|
||||
object.setTradingClearingRegistryId(resultSet.getObject("TRADING_CLEARING_REGISTRY_ID", Long.class));
|
||||
object.setTradingClearingRegistry(resultSet.getObject("TRADING_CLEARING_REGISTRY", String.class));
|
||||
object.setRegistryStatus(resultSet.getObject("REGISTRY_STATUS", String.class));
|
||||
object.setSecurityId(resultSet.getObject("SECURITY_ID", Long.class));
|
||||
object.setSecuritySymbol(resultSet.getObject("SECURITY_SYMBOL", String.class));
|
||||
object.setBalance(resultSet.getObject("BALANCE", BigDecimal.class));
|
||||
object.setOpenBalance(resultSet.getObject("OPEN_BALANCE", BigDecimal.class));
|
||||
object.setCloseBalance(resultSet.getObject("CLOSE_BALANCE", BigDecimal.class));
|
||||
object.setCredit(resultSet.getObject("CREDIT", BigDecimal.class));
|
||||
object.setDebit(resultSet.getObject("DEBIT", BigDecimal.class));
|
||||
object.setSettledCredit(resultSet.getObject("SETTLED_CREDIT", BigDecimal.class));
|
||||
object.setSettledDebit(resultSet.getObject("SETTLED_DEBIT", BigDecimal.class));
|
||||
object.setCheckBalance(resultSet.getObject("CHECK_BALANCE", BigDecimal.class));
|
||||
object.setDiffBalance(resultSet.getObject("DIFF_BALANCE", BigDecimal.class));
|
||||
object.setPlanBalance(resultSet.getObject("PLAN_BALANCE", BigDecimal.class));
|
||||
object.setBalanceDimension(resultSet.getObject("BALANCE_DIMENSION", String.class));
|
||||
object.setSettlementDate(ReportUtils.getLocalDateFromSqlDate(resultSet, "SETTLEMENT_DATE"));
|
||||
object.setSettlementCode(resultSet.getObject("SETTLEMENT_CODE", String.class));
|
||||
object.setTradingDate(ReportUtils.getLocalDateFromSqlDate(resultSet, "TRADING_DATE"));
|
||||
object.setClearingDate(ReportUtils.getLocalDateFromSqlDate(resultSet, "CLEARING_DATE"));
|
||||
object.setRefundDate(ReportUtils.getLocalDateFromSqlDate(resultSet, "REFUND_DATE"));
|
||||
object.setValueDate(ReportUtils.getLocalDateFromSqlDate(resultSet, "VALUE_DATE"));
|
||||
object.setPrice(resultSet.getObject("PRICE", BigDecimal.class));
|
||||
object.setContract(resultSet.getObject("CONTRACT", String.class));
|
||||
object.setCounterPartyId(resultSet.getObject("COUNTER_PARTY_ID", Long.class));
|
||||
object.setComment(resultSet.getObject("COMMENT", String.class));
|
||||
object.setParentId(resultSet.getObject("PARENT_ID", Long.class));
|
||||
object.setGroupId(resultSet.getObject("GROUP_ID", Long.class));
|
||||
object.setSessionId(resultSet.getObject("SESSION_ID", Long.class));
|
||||
object.setSessionType(resultSet.getObject("SESSION_TYPE", String.class));
|
||||
object.setPaymentId(resultSet.getObject("PAYMENT_ID", Long.class));
|
||||
object.setId(resultSet.getObject("ID", Long.class));
|
||||
object.setCreated(ReportUtils.getInstantFromTimestamp(resultSet, "CREATED_AT"));
|
||||
object.setUpdated(ReportUtils.getInstantFromTimestamp(resultSet, "UPDATED_AT"));
|
||||
return object;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package ru.spcex.clearing.registry.reports.loaders.helpers;
|
||||
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import ru.spcex.clearing.registry.reports.bean.AbstractDictionary;
|
||||
import ru.spcex.clearing.registry.reports.bean.AllowedDictionary;
|
||||
import ru.spcex.clearing.registry.reports.bean.RegistryStatusDictionary;
|
||||
import ru.spcex.clearing.registry.reports.bean.SessionTypeDictionary;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ADictionaryRowMapper<T extends AbstractDictionary> implements RowMapper<T> {
|
||||
protected final Supplier<T> objectCreator;
|
||||
|
||||
public ADictionaryRowMapper(Supplier<T> objectCreator) {
|
||||
this.objectCreator = Objects.requireNonNull(objectCreator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
T registryStatusDictionary = objectCreator.get();
|
||||
registryStatusDictionary.setCode(rs.getString("CODE"));
|
||||
registryStatusDictionary.setName(rs.getString("NAME"));
|
||||
return registryStatusDictionary;
|
||||
}
|
||||
|
||||
public static ADictionaryRowMapper<AllowedDictionary> forAllowedDictionary() {
|
||||
return new ADictionaryRowMapper<>(AllowedDictionary::new);
|
||||
}
|
||||
|
||||
public static ADictionaryRowMapper<RegistryStatusDictionary> forRegistryStatusDictionary() {
|
||||
return new ADictionaryRowMapper<>(RegistryStatusDictionary::new);
|
||||
}
|
||||
|
||||
public static ADictionaryRowMapper<SessionTypeDictionary> forSessionTypeDictionary() {
|
||||
return new ADictionaryRowMapper<>(SessionTypeDictionary::new);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package ru.spcex.clearing.registry.reports.loaders.helpers;
|
||||
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import ru.spcex.clearing.registry.reports.bean.Account;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class Account2RowMapper implements RowMapper<Account> {
|
||||
@Override
|
||||
public Account mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
Account account = new Account();
|
||||
account.setId(rs.getLong("ID"));
|
||||
account.setAccountType(rs.getString("ACCOUNT_TYPE"));
|
||||
account.setAccount(rs.getString("ACCOUNT"));
|
||||
return account;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package ru.spcex.clearing.registry.reports.loaders.helpers;
|
||||
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import ru.spcex.clearing.registry.reports.bean.Account;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class AccountRowMapper implements RowMapper<Account> {
|
||||
@Override
|
||||
public Account mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
Account account = new Account();
|
||||
account.setId(rs.getLong("ID"));
|
||||
account.setAccountType(rs.getString("ACCOUNT_TYPE"));
|
||||
return account;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package ru.spcex.clearing.registry.reports.loaders.helpers;
|
||||
|
||||
public enum AccountType implements IEnumKey {
|
||||
Clrn("CLRN"), Bank("BANK"), Info("INFO"), Tran("TRAN"), Corr("CORR"), Anlt("ANLT"), Depo("DEPO"),
|
||||
Dtrn("DTRN");
|
||||
|
||||
private final String key;
|
||||
|
||||
AccountType(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package ru.spcex.clearing.registry.reports.loaders.helpers;
|
||||
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import ru.spcex.clearing.registry.reports.bean.AllowedDictionary;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class AllowedDictionaryRowMapper implements RowMapper<AllowedDictionary> {
|
||||
@Override
|
||||
public AllowedDictionary mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
AllowedDictionary allowedDictionary = new AllowedDictionary();
|
||||
allowedDictionary.setCode(rs.getString("CODE"));
|
||||
allowedDictionary.setName(rs.getString("NAME"));
|
||||
return allowedDictionary;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package ru.spcex.clearing.registry.reports.loaders.helpers;
|
||||
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import ru.spcex.clearing.registry.reports.bean.Company;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class CompanyRowMapper implements RowMapper<Company> {
|
||||
@Override
|
||||
public Company mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
Company company = new Company();
|
||||
company.setId(rs.getLong("ID"));
|
||||
company.setClearingCode(rs.getString("CLEARING_CODE"));
|
||||
company.setShortName(rs.getString("SHORT_NAME"));
|
||||
return company;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package ru.spcex.clearing.registry.reports.loaders.helpers;
|
||||
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import ru.spcex.clearing.registry.reports.bean.CompanySymbols;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class CompanySymbolsRowMapper implements RowMapper<CompanySymbols> {
|
||||
@Override
|
||||
public CompanySymbols mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
CompanySymbols companySymbols = new CompanySymbols();
|
||||
companySymbols.setId(rs.getLong("ID"));
|
||||
companySymbols.setCompanyId(rs.getLong("COMPANY_ID"));
|
||||
companySymbols.setCompanySymbol(rs.getString("COMPANY_SYMBOL"));
|
||||
companySymbols.setCompanySymbolValue(rs.getString("COMPANY_SYMBOL_VALUE"));
|
||||
return companySymbols;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
package ru.spcex.clearing.registry.reports.loaders.helpers;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
public interface IEnumKey extends Serializable {
|
||||
String getKey();
|
||||
|
||||
default boolean equalsByKey(String key) {
|
||||
return key != null && getKey().equalsIgnoreCase(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверяет что среди данного набора Enum, присутствует элемент с данным id
|
||||
* id может быть null
|
||||
*/
|
||||
static <T extends Enum<T> & IEnumKey> boolean contains(String id, T... enumSet) {
|
||||
for (T e : enumSet) {
|
||||
if (Objects.equals(id, e.getKey()))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static <T extends Enum<T> & IEnumKey> boolean contains(T e, T... enumSet) {
|
||||
for (T enumEl : enumSet) {
|
||||
if (enumEl.equals(e))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверяет что среди всех Enum данного класса, присутствует элемент с данным id
|
||||
* id может быть null
|
||||
*/
|
||||
static <T extends Enum<T> & IEnumKey> boolean contains(String key, Class<T> enumClass) {
|
||||
for (T e : enumClass.getEnumConstants()) {
|
||||
if (Objects.equals(key, e.getKey()))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает Enum по id, если в заданном классе такой определен
|
||||
* id может быть null
|
||||
*
|
||||
* @return Enum если нашел, иначе <tt>null</tt>
|
||||
*/
|
||||
static <T extends Enum<T> & IEnumKey> T getEnumByKey(Class<T> enumClass, String key) {
|
||||
for (T e : enumClass.getEnumConstants()) {
|
||||
if (Objects.equals(key, e.getKey()))
|
||||
return e;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static <T extends Enum<T> & IEnumKey> T getEnumByKeyOrUndefined(Class<T> enumClass, String key) {
|
||||
T enumByKey = getEnumByKey(enumClass, key);
|
||||
return enumByKey == null ? getUndefined(enumClass) : enumByKey;
|
||||
}
|
||||
|
||||
static <T extends Enum<T> & IEnumKey> T getUndefined(Class<T> enumClass) {
|
||||
T enumByKey = getEnumByKey(enumClass, UNDEFINED_VALUE);
|
||||
if (enumByKey == null) {
|
||||
throw new IllegalArgumentException("Undefined value not found in enum " + enumClass);
|
||||
}
|
||||
return enumByKey;
|
||||
}
|
||||
|
||||
static String getKeyOrNull(IEnumKey enumVal) {
|
||||
return enumVal == null ? null : enumVal.getKey();
|
||||
}
|
||||
|
||||
String UNDEFINED_VALUE = "_Undefined";
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package ru.spcex.clearing.registry.reports.loaders.helpers;
|
||||
|
||||
public enum RegistryCapacity implements IEnumKey {
|
||||
A("A"),
|
||||
B("B"),
|
||||
Z("Z"),
|
||||
C("C"),
|
||||
E("E"),
|
||||
P("P")
|
||||
;
|
||||
|
||||
private final String key;
|
||||
|
||||
RegistryCapacity(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
package ru.spcex.clearing.registry.reports.loaders.helpers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class RegistryCodeSqlBuilder {
|
||||
|
||||
private List<RegistryTradingParams> registryTradingParams;
|
||||
|
||||
public static RegistryCodeSqlBuilder getInstance(RegistryTradingParams... tradingParams) {
|
||||
return new RegistryCodeSqlBuilder(Arrays.asList(tradingParams));
|
||||
}
|
||||
|
||||
private RegistryCodeSqlBuilder(List<RegistryTradingParams> tradingParams) {
|
||||
this.registryTradingParams = tradingParams;
|
||||
}
|
||||
|
||||
public String buildSql() {
|
||||
List<StringBuilder> conditions = new ArrayList<>();
|
||||
String REGISTRY_DESIGNATION_FORMAT = "REGISTRY_DESIGNATION = '%s'";
|
||||
String REGISTRY_INSTRUMENT_TYPE_FORMAT = "REGISTRY_INSTRUMENT_TYPE = '%s'";
|
||||
String REGISTRY_CAPACITY_FORMAT = "REGISTRY_CAPACITY = '%s'";
|
||||
String REGISTRY_UNIT_FORMAT = "REGISTRY_UNIT = '%s'";
|
||||
for (RegistryTradingParams tradingParams : this.registryTradingParams) {
|
||||
StringBuilder condition = new StringBuilder();
|
||||
boolean wasAddedCondition = false;
|
||||
if (tradingParams.registryDesignation() != null) {
|
||||
condition.append(String.format(REGISTRY_DESIGNATION_FORMAT, tradingParams.registryDesignation().getKey()));
|
||||
wasAddedCondition = true;
|
||||
}
|
||||
if (wasAddedCondition) {
|
||||
condition.append(" and ");
|
||||
wasAddedCondition = false;
|
||||
}
|
||||
if (tradingParams.registryInstrumentType() != null) {
|
||||
condition.append(String.format(REGISTRY_INSTRUMENT_TYPE_FORMAT, tradingParams.registryInstrumentType().getKey()));
|
||||
wasAddedCondition = true;
|
||||
}
|
||||
if (wasAddedCondition) {
|
||||
condition.append(" and ");
|
||||
wasAddedCondition = false;
|
||||
}
|
||||
if (tradingParams.registryCapacity() != null) {
|
||||
condition.append(String.format(REGISTRY_CAPACITY_FORMAT, tradingParams.registryCapacity().getKey()));
|
||||
wasAddedCondition = true;
|
||||
}
|
||||
if (wasAddedCondition) {
|
||||
condition.append(" and ");
|
||||
wasAddedCondition = false;
|
||||
}
|
||||
if (tradingParams.registryUnit() != null) {
|
||||
condition.append(String.format(REGISTRY_UNIT_FORMAT, tradingParams.registryUnit().getKey()));
|
||||
wasAddedCondition = true;
|
||||
}
|
||||
if (!wasAddedCondition) {
|
||||
condition.delete(condition.length() - " and ".length(), condition.length());
|
||||
}
|
||||
conditions.add(condition);
|
||||
}
|
||||
return conditions.stream().collect(Collectors.joining(") or (", "(", ")"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package ru.spcex.clearing.registry.reports.loaders.helpers;
|
||||
|
||||
public enum RegistryDesignation implements IEnumKey {
|
||||
A("A"),
|
||||
O("O"),
|
||||
T("T"),
|
||||
D("D"),
|
||||
L("L"),
|
||||
C("C")
|
||||
;
|
||||
|
||||
private final String key;
|
||||
|
||||
RegistryDesignation(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package ru.spcex.clearing.registry.reports.loaders.helpers;
|
||||
|
||||
public enum RegistryInstrumentType implements IEnumKey {
|
||||
M("M"),
|
||||
S("S"),
|
||||
;
|
||||
|
||||
private final String key;
|
||||
|
||||
RegistryInstrumentType(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,263 @@
|
|||
package ru.spcex.clearing.registry.reports.loaders.helpers;
|
||||
|
||||
public record RegistryTradingParams(RegistryDesignation registryDesignation,
|
||||
RegistryInstrumentType registryInstrumentType,
|
||||
RegistryCapacity registryCapacity,
|
||||
RegistryUnit registryUnit) {
|
||||
|
||||
public boolean equalByRegistry(RegistryDesignation registryDesignation, RegistryInstrumentType registryInstrumentType,
|
||||
RegistryCapacity registryCapacity, RegistryUnit registryUnit) {
|
||||
boolean isEqualDesignation = this.registryDesignation == null || registryDesignation == this.registryDesignation;
|
||||
boolean isEqualInstrumentType = this.registryInstrumentType == null || registryInstrumentType == this.registryInstrumentType;
|
||||
boolean isEqualCapacity = this.registryCapacity == null || registryCapacity == this.registryCapacity;
|
||||
boolean isEqualUnit = this.registryUnit == null || registryUnit == this.registryUnit;
|
||||
return isEqualDesignation && isEqualInstrumentType && isEqualCapacity && isEqualUnit;
|
||||
}
|
||||
|
||||
public RegistryTradingParams dsgn(RegistryDesignation registryDesignation) {
|
||||
return new RegistryTradingParams(registryDesignation,
|
||||
registryInstrumentType,
|
||||
registryCapacity,
|
||||
registryUnit);
|
||||
}
|
||||
|
||||
public RegistryTradingParams dsgn(String registryDesignationS) {
|
||||
RegistryDesignation registryDesignation = IEnumKey.getEnumByKey(RegistryDesignation.class, registryDesignationS);
|
||||
return new RegistryTradingParams(registryDesignation,
|
||||
registryInstrumentType,
|
||||
registryCapacity,
|
||||
registryUnit);
|
||||
}
|
||||
|
||||
public RegistryTradingParams type(RegistryInstrumentType registryInstrumentType) {
|
||||
return new RegistryTradingParams(registryDesignation,
|
||||
registryInstrumentType,
|
||||
registryCapacity,
|
||||
registryUnit);
|
||||
}
|
||||
|
||||
public RegistryTradingParams type(String registryInstrumentTypeS) {
|
||||
RegistryInstrumentType registryInstrumentType = IEnumKey.getEnumByKey(RegistryInstrumentType.class,
|
||||
registryInstrumentTypeS);
|
||||
return new RegistryTradingParams(registryDesignation,
|
||||
registryInstrumentType,
|
||||
registryCapacity,
|
||||
registryUnit);
|
||||
}
|
||||
|
||||
public RegistryTradingParams cpcty(RegistryCapacity registryCapacity) {
|
||||
return new RegistryTradingParams(registryDesignation,
|
||||
registryInstrumentType,
|
||||
registryCapacity,
|
||||
registryUnit);
|
||||
}
|
||||
|
||||
public RegistryTradingParams cpcty(String registryCapacityS) {
|
||||
RegistryCapacity registryCapacity = IEnumKey.getEnumByKey(RegistryCapacity.class, registryCapacityS);
|
||||
return new RegistryTradingParams(registryDesignation,
|
||||
registryInstrumentType,
|
||||
registryCapacity,
|
||||
registryUnit);
|
||||
}
|
||||
|
||||
public RegistryTradingParams unit(RegistryUnit registryUnit) {
|
||||
return new RegistryTradingParams(registryDesignation,
|
||||
registryInstrumentType,
|
||||
registryCapacity,
|
||||
registryUnit);
|
||||
}
|
||||
|
||||
public RegistryTradingParams unit(String registryUnitS) {
|
||||
RegistryUnit registryUnit = IEnumKey.getEnumByKey(RegistryUnit.class, registryUnitS);
|
||||
return new RegistryTradingParams(registryDesignation,
|
||||
registryInstrumentType,
|
||||
registryCapacity,
|
||||
registryUnit);
|
||||
}
|
||||
|
||||
public final static RegistryTradingParams OS_T;
|
||||
public final static RegistryTradingParams OM_T;
|
||||
public final static RegistryTradingParams TS_T;
|
||||
public final static RegistryTradingParams TM_T;
|
||||
public final static RegistryTradingParams DM_X;
|
||||
public final static RegistryTradingParams DM_T;
|
||||
public final static RegistryTradingParams DM_I;
|
||||
public final static RegistryTradingParams AM_F;
|
||||
public final static RegistryTradingParams AM_T;
|
||||
public final static RegistryTradingParams AM_B;
|
||||
public final static RegistryTradingParams A__B;
|
||||
public final static RegistryTradingParams A__F;
|
||||
public final static RegistryTradingParams A__T;
|
||||
public final static RegistryTradingParams AS_T;
|
||||
public final static RegistryTradingParams DS_I;
|
||||
public final static RegistryTradingParams DS_T;
|
||||
public final static RegistryTradingParams AS_B;
|
||||
public final static RegistryTradingParams AS_F;
|
||||
public final static RegistryTradingParams CM_T;
|
||||
public final static RegistryTradingParams LM_T;
|
||||
public final static RegistryTradingParams CS_T;
|
||||
public final static RegistryTradingParams LS_T;
|
||||
public final static RegistryTradingParams L__T;
|
||||
public final static RegistryTradingParams DM__;
|
||||
public final static RegistryTradingParams AM__;
|
||||
public final static RegistryTradingParams AS__;
|
||||
public final static RegistryTradingParams CM__;
|
||||
public final static RegistryTradingParams C__T;
|
||||
public final static RegistryTradingParams O__T;
|
||||
public final static RegistryTradingParams T__T;
|
||||
public final static RegistryTradingParams LM__;
|
||||
public final static RegistryTradingParams DMAU;
|
||||
public final static RegistryTradingParams DMAI;
|
||||
public final static RegistryTradingParams D__I;
|
||||
public final static RegistryTradingParams D__V;
|
||||
public final static RegistryTradingParams _S_T;
|
||||
|
||||
static {
|
||||
OS_T = new RegistryTradingParams(RegistryDesignation.O,
|
||||
RegistryInstrumentType.S,
|
||||
null,
|
||||
RegistryUnit.T);
|
||||
OM_T = new RegistryTradingParams(RegistryDesignation.O,
|
||||
RegistryInstrumentType.M,
|
||||
null,
|
||||
RegistryUnit.T);
|
||||
TS_T = new RegistryTradingParams(RegistryDesignation.T,
|
||||
RegistryInstrumentType.S,
|
||||
null,
|
||||
RegistryUnit.T);
|
||||
|
||||
TM_T = new RegistryTradingParams(RegistryDesignation.T,
|
||||
RegistryInstrumentType.M,
|
||||
null,
|
||||
RegistryUnit.T);
|
||||
DM_X = new RegistryTradingParams(RegistryDesignation.D,
|
||||
RegistryInstrumentType.M,
|
||||
null,
|
||||
RegistryUnit.X);
|
||||
DM_T = new RegistryTradingParams(RegistryDesignation.D,
|
||||
RegistryInstrumentType.M,
|
||||
null,
|
||||
RegistryUnit.T);
|
||||
DM_I = new RegistryTradingParams(RegistryDesignation.D,
|
||||
RegistryInstrumentType.M,
|
||||
null,
|
||||
RegistryUnit.I);
|
||||
AM_F = new RegistryTradingParams(RegistryDesignation.A,
|
||||
RegistryInstrumentType.M,
|
||||
null,
|
||||
RegistryUnit.F);
|
||||
AM_T = new RegistryTradingParams(RegistryDesignation.A,
|
||||
RegistryInstrumentType.M,
|
||||
null,
|
||||
RegistryUnit.T);
|
||||
AM_B = new RegistryTradingParams(RegistryDesignation.A,
|
||||
RegistryInstrumentType.M,
|
||||
null,
|
||||
RegistryUnit.B);
|
||||
A__B = new RegistryTradingParams(RegistryDesignation.A,
|
||||
null,
|
||||
null,
|
||||
RegistryUnit.B);
|
||||
A__F = new RegistryTradingParams(RegistryDesignation.A,
|
||||
null,
|
||||
null,
|
||||
RegistryUnit.F);
|
||||
A__T = new RegistryTradingParams(RegistryDesignation.A,
|
||||
null,
|
||||
null,
|
||||
RegistryUnit.T);
|
||||
AS_T = new RegistryTradingParams(RegistryDesignation.A,
|
||||
RegistryInstrumentType.S,
|
||||
null,
|
||||
RegistryUnit.T);
|
||||
AS_B = new RegistryTradingParams(RegistryDesignation.A,
|
||||
RegistryInstrumentType.S,
|
||||
null,
|
||||
RegistryUnit.B);
|
||||
AS_F = new RegistryTradingParams(RegistryDesignation.A,
|
||||
RegistryInstrumentType.S,
|
||||
null,
|
||||
RegistryUnit.F);
|
||||
CM_T = new RegistryTradingParams(RegistryDesignation.C,
|
||||
RegistryInstrumentType.M,
|
||||
null,
|
||||
RegistryUnit.T);
|
||||
LM_T = new RegistryTradingParams(RegistryDesignation.L,
|
||||
RegistryInstrumentType.M,
|
||||
null,
|
||||
RegistryUnit.T);
|
||||
CS_T = new RegistryTradingParams(RegistryDesignation.C,
|
||||
RegistryInstrumentType.S,
|
||||
null,
|
||||
RegistryUnit.T);
|
||||
LS_T = new RegistryTradingParams(RegistryDesignation.L,
|
||||
RegistryInstrumentType.S,
|
||||
null,
|
||||
RegistryUnit.T);
|
||||
L__T = new RegistryTradingParams(RegistryDesignation.L,
|
||||
null,
|
||||
null,
|
||||
RegistryUnit.T);
|
||||
DM__ = new RegistryTradingParams(RegistryDesignation.D,
|
||||
RegistryInstrumentType.M,
|
||||
null,
|
||||
null);
|
||||
AM__ = new RegistryTradingParams(RegistryDesignation.A,
|
||||
RegistryInstrumentType.M,
|
||||
null,
|
||||
null);
|
||||
AS__ = new RegistryTradingParams(RegistryDesignation.A,
|
||||
RegistryInstrumentType.S,
|
||||
null,
|
||||
null);
|
||||
CM__ = new RegistryTradingParams(RegistryDesignation.C,
|
||||
RegistryInstrumentType.M,
|
||||
null,
|
||||
null);
|
||||
LM__ = new RegistryTradingParams(RegistryDesignation.L,
|
||||
RegistryInstrumentType.M,
|
||||
null,
|
||||
null);
|
||||
DMAU = new RegistryTradingParams(RegistryDesignation.D,
|
||||
RegistryInstrumentType.M,
|
||||
RegistryCapacity.A,
|
||||
RegistryUnit.U);
|
||||
DMAI = new RegistryTradingParams(RegistryDesignation.D,
|
||||
RegistryInstrumentType.M,
|
||||
RegistryCapacity.A,
|
||||
RegistryUnit.I);
|
||||
DS_I = new RegistryTradingParams(RegistryDesignation.D,
|
||||
RegistryInstrumentType.S,
|
||||
null,
|
||||
RegistryUnit.I);
|
||||
DS_T = new RegistryTradingParams(RegistryDesignation.D,
|
||||
RegistryInstrumentType.S,
|
||||
null,
|
||||
RegistryUnit.T);
|
||||
D__I = new RegistryTradingParams(RegistryDesignation.D,
|
||||
null,
|
||||
null,
|
||||
RegistryUnit.I);
|
||||
D__V = new RegistryTradingParams(RegistryDesignation.D,
|
||||
null,
|
||||
null,
|
||||
RegistryUnit.V);
|
||||
C__T = new RegistryTradingParams(RegistryDesignation.C,
|
||||
null,
|
||||
null,
|
||||
RegistryUnit.T);
|
||||
O__T = new RegistryTradingParams(RegistryDesignation.O,
|
||||
null,
|
||||
null,
|
||||
RegistryUnit.T);
|
||||
T__T = new RegistryTradingParams(RegistryDesignation.T,
|
||||
null,
|
||||
null,
|
||||
RegistryUnit.T);
|
||||
_S_T = new RegistryTradingParams(null,
|
||||
RegistryInstrumentType.S,
|
||||
null,
|
||||
RegistryUnit.T);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package ru.spcex.clearing.registry.reports.loaders.helpers;
|
||||
|
||||
public enum RegistryUnit implements IEnumKey {
|
||||
T("T"),
|
||||
A("A"),
|
||||
R("R"),
|
||||
F("F"),
|
||||
B("B"),
|
||||
X("X"),
|
||||
U("U"),
|
||||
I("I"),
|
||||
V("V"),
|
||||
;
|
||||
|
||||
private final String key;
|
||||
|
||||
RegistryUnit(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package ru.spcex.clearing.registry.reports.loaders.helpers;
|
||||
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import ru.spcex.clearing.registry.reports.bean.Security;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class SecurityRowMapper implements RowMapper<Security> {
|
||||
@Override
|
||||
public Security mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
Security security = new Security();
|
||||
security.setId(rs.getLong("ID"));
|
||||
security.setSecuritySymbol(rs.getString("SECURITY_SYMBOL"));
|
||||
return security;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package ru.spcex.clearing.registry.reports.loaders.helpers;
|
||||
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import ru.spcex.clearing.registry.reports.bean.TradingClearingRegistry;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class TradingClearingRegistryRowMapper implements RowMapper<TradingClearingRegistry> {
|
||||
@Override
|
||||
public TradingClearingRegistry mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
TradingClearingRegistry tkr = new TradingClearingRegistry();
|
||||
tkr.setId(rs.getLong("ID"));
|
||||
tkr.setCode(rs.getString("CODE"));
|
||||
return tkr;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,48 +1,48 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
package ru.spcex.clearing.registry.reports.report;
|
||||
|
||||
import com.opencsv.bean.CsvBindByName;
|
||||
import com.opencsv.bean.CsvBindByPosition;
|
||||
import com.opencsv.bean.CsvDate;
|
||||
import com.opencsv.bean.CsvNumber;
|
||||
import ru.spcex.clearing.registry.annotation.BindByName;
|
||||
import ru.spcex.clearing.registry.annotation.BindByPosition;
|
||||
import ru.spcex.clearing.registry.annotation.ReportDate;
|
||||
import ru.spcex.clearing.registry.annotation.ReportNumber;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class DepoBalanceRegisterReport implements FileReport {
|
||||
@CsvBindByName(column = "Наименование Расчетного депозитария")
|
||||
@CsvBindByPosition(position = 0)
|
||||
@BindByName(column = "Наименование Расчетного депозитария")
|
||||
@BindByPosition(position = 0)
|
||||
private String houseName;
|
||||
|
||||
@CsvBindByName(column = "Номер отчета")
|
||||
@CsvBindByPosition(position = 1)
|
||||
@BindByName(column = "Номер отчета")
|
||||
@BindByPosition(position = 1)
|
||||
private String number;
|
||||
|
||||
@CsvBindByName(column = "Дата")
|
||||
@CsvBindByPosition(position = 2)
|
||||
@CsvDate(value = "dd.MM.yyyy")
|
||||
@BindByName(column = "Дата")
|
||||
@BindByPosition(position = 2)
|
||||
@ReportDate(value = "dd.MM.yyyy")
|
||||
private LocalDate date;
|
||||
|
||||
@CsvBindByName(column = "Время")
|
||||
@CsvBindByPosition(position = 3)
|
||||
@CsvDate(value = "HH:mm:ss")
|
||||
@BindByName(column = "Время")
|
||||
@BindByPosition(position = 3)
|
||||
@ReportDate(value = "HH:mm:ss")
|
||||
private LocalDateTime time;
|
||||
|
||||
@CsvBindByName(column = "Краткое наименование УК")
|
||||
@CsvBindByPosition(position = 4)
|
||||
@BindByName(column = "Краткое наименование УК")
|
||||
@BindByPosition(position = 4)
|
||||
private String company;
|
||||
|
||||
@CsvBindByName(column = "Номер торгового раздела счета депо/ код раздела «к размещению/выкупу»")
|
||||
@CsvBindByPosition(position = 5)
|
||||
@BindByName(column = "Номер торгового раздела счета депо/ код раздела «к размещению/выкупу»")
|
||||
@BindByPosition(position = 5)
|
||||
private String account;
|
||||
|
||||
@CsvBindByName(column = "Код ЦБ")
|
||||
@CsvBindByPosition(position = 6)
|
||||
@BindByName(column = "Код ЦБ")
|
||||
@BindByPosition(position = 6)
|
||||
private String security;
|
||||
|
||||
@CsvBindByName(column = "Количество ЦБ")
|
||||
@CsvBindByPosition(position = 7)
|
||||
@CsvNumber(value = "#0", writeFormat = "#0")
|
||||
@BindByName(column = "Количество ЦБ")
|
||||
@BindByPosition(position = 7)
|
||||
@ReportNumber(value = "#0")
|
||||
private BigDecimal sum;
|
||||
|
||||
public String getHouseName() {
|
||||
|
|
@ -1,60 +1,60 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
package ru.spcex.clearing.registry.reports.report;
|
||||
|
||||
import com.opencsv.bean.CsvBindByName;
|
||||
import com.opencsv.bean.CsvBindByPosition;
|
||||
import com.opencsv.bean.CsvDate;
|
||||
import com.opencsv.bean.CsvNumber;
|
||||
import ru.spcex.clearing.registry.annotation.BindByName;
|
||||
import ru.spcex.clearing.registry.annotation.BindByPosition;
|
||||
import ru.spcex.clearing.registry.annotation.ReportDate;
|
||||
import ru.spcex.clearing.registry.annotation.ReportNumber;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class DepoPaymentInstructionRegisterReport implements FileReport {
|
||||
@CsvBindByName(column = "Номер распоряжения")
|
||||
@CsvBindByPosition(position = 0)
|
||||
@BindByName(column = "Номер распоряжения")
|
||||
@BindByPosition(position = 0)
|
||||
private Long number;
|
||||
|
||||
@CsvBindByName(column = "Дата распоряжения")
|
||||
@CsvBindByPosition(position = 1)
|
||||
@CsvDate(value = "dd.MM.yyyy")
|
||||
@BindByName(column = "Дата распоряжения")
|
||||
@BindByPosition(position = 1)
|
||||
@ReportDate(value = "dd.MM.yyyy")
|
||||
private LocalDate date;
|
||||
|
||||
@CsvBindByName(column = "Время формирования")
|
||||
@CsvBindByPosition(position = 2)
|
||||
@CsvDate(value = "HH:mm:ss")
|
||||
@BindByName(column = "Время формирования")
|
||||
@BindByPosition(position = 2)
|
||||
@ReportDate(value = "HH:mm:ss")
|
||||
private LocalDateTime time;
|
||||
|
||||
@CsvBindByName(column = "Номер торгового банковского/клирингового счета списания")
|
||||
@CsvBindByPosition(position = 3)
|
||||
@BindByName(column = "Номер торгового банковского/клирингового счета списания")
|
||||
@BindByPosition(position = 3)
|
||||
private String accountSender;
|
||||
|
||||
@CsvBindByName(column = "Наименование владельца счета списания")
|
||||
@CsvBindByPosition(position = 4)
|
||||
@BindByName(column = "Наименование владельца счета списания")
|
||||
@BindByPosition(position = 4)
|
||||
private String sender;
|
||||
|
||||
@CsvBindByName(column = "Код владельца счета списания")
|
||||
@CsvBindByPosition(position = 5)
|
||||
@BindByName(column = "Код владельца счета списания")
|
||||
@BindByPosition(position = 5)
|
||||
private String codeSender;
|
||||
|
||||
@CsvBindByName(column = "Номер торгового банковского/клирингового счета зачисления")
|
||||
@CsvBindByPosition(position = 6)
|
||||
@BindByName(column = "Номер торгового банковского/клирингового счета зачисления")
|
||||
@BindByPosition(position = 6)
|
||||
private String accountAddressee;
|
||||
|
||||
@CsvBindByName(column = "Наименование владельца счета зачисления")
|
||||
@CsvBindByPosition(position = 7)
|
||||
@BindByName(column = "Наименование владельца счета зачисления")
|
||||
@BindByPosition(position = 7)
|
||||
private String addressee;
|
||||
|
||||
@CsvBindByName(column = "Код владельца счета зачисления")
|
||||
@CsvBindByPosition(position = 8)
|
||||
@BindByName(column = "Код владельца счета зачисления")
|
||||
@BindByPosition(position = 8)
|
||||
private String codeAddressee;
|
||||
|
||||
@CsvBindByName(column = "Код ЦБ")
|
||||
@CsvBindByPosition(position = 9)
|
||||
@BindByName(column = "Код ЦБ")
|
||||
@BindByPosition(position = 9)
|
||||
private String security;
|
||||
|
||||
@CsvBindByName(column = "Количество ЦБ")
|
||||
@CsvBindByPosition(position = 10)
|
||||
@CsvNumber(value = "#0", writeFormat = "#0")
|
||||
@BindByName(column = "Количество ЦБ")
|
||||
@BindByPosition(position = 10)
|
||||
@ReportNumber(value = "#0")
|
||||
private BigDecimal amount;
|
||||
|
||||
|
||||
|
|
@ -1,87 +1,87 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
package ru.spcex.clearing.registry.reports.report;
|
||||
|
||||
import com.opencsv.bean.CsvBindByName;
|
||||
import com.opencsv.bean.CsvBindByPosition;
|
||||
import com.opencsv.bean.CsvDate;
|
||||
import com.opencsv.bean.CsvNumber;
|
||||
import ru.spcex.clearing.registry.annotation.BindByName;
|
||||
import ru.spcex.clearing.registry.annotation.BindByPosition;
|
||||
import ru.spcex.clearing.registry.annotation.ReportDate;
|
||||
import ru.spcex.clearing.registry.annotation.ReportNumber;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class ExecutionRegisterReport implements FileReport {
|
||||
@CsvBindByName(column = "Наименование биржи")
|
||||
@CsvBindByPosition(position = 0)
|
||||
@BindByName(column = "Наименование биржи")
|
||||
@BindByPosition(position = 0)
|
||||
private String clearingOrganization;
|
||||
|
||||
@CsvBindByName(column = "Дата заключения сделки")
|
||||
@CsvBindByPosition(position = 1)
|
||||
@CsvDate(value = "dd.MM.yyyy")
|
||||
@BindByName(column = "Дата заключения сделки")
|
||||
@BindByPosition(position = 1)
|
||||
@ReportDate(value = "dd.MM.yyyy")
|
||||
private LocalDate tradingDate;
|
||||
|
||||
@CsvBindByName(column = "Дата исполнения")
|
||||
@CsvBindByPosition(position = 2)
|
||||
@CsvDate(value = "dd.MM.yyyy")
|
||||
@BindByName(column = "Дата исполнения")
|
||||
@BindByPosition(position = 2)
|
||||
@ReportDate(value = "dd.MM.yyyy")
|
||||
private LocalDate settlementDate;
|
||||
|
||||
@CsvBindByName(column = "Идентификационный номер сделки в Торговой системе")
|
||||
@CsvBindByPosition(position = 3)
|
||||
@BindByName(column = "Идентификационный номер сделки в Торговой системе")
|
||||
@BindByPosition(position = 3)
|
||||
private Long exchangeExecutionId;
|
||||
|
||||
@CsvBindByName(column = "Время заключения сделки в Торговой системе")
|
||||
@CsvBindByPosition(position = 4)
|
||||
@CsvDate(value = "HH:mm:ss")
|
||||
@BindByName(column = "Время заключения сделки в Торговой системе")
|
||||
@BindByPosition(position = 4)
|
||||
@ReportDate(value = "HH:mm:ss")
|
||||
private LocalDateTime exchangeExecutionTime;
|
||||
|
||||
@CsvBindByName(column = "Код БИ")
|
||||
@CsvBindByPosition(position = 5)
|
||||
@BindByName(column = "Код БИ")
|
||||
@BindByPosition(position = 5)
|
||||
private String security;
|
||||
|
||||
@CsvBindByName(column = "Дата возврата")
|
||||
@CsvBindByPosition(position = 6)
|
||||
@CsvDate(value = "dd.MM.yyyy")
|
||||
@BindByName(column = "Дата возврата")
|
||||
@BindByPosition(position = 6)
|
||||
@ReportDate(value = "dd.MM.yyyy")
|
||||
private LocalDate refundDate;
|
||||
|
||||
@CsvBindByName(column = "Код УК - продавца")
|
||||
@CsvBindByPosition(position = 7)
|
||||
@BindByName(column = "Код УК - продавца")
|
||||
@BindByPosition(position = 7)
|
||||
private String sellerCode;
|
||||
|
||||
@CsvBindByName(column = "Наименование УК - продавца")
|
||||
@CsvBindByPosition(position = 8)
|
||||
@BindByName(column = "Наименование УК - продавца")
|
||||
@BindByPosition(position = 8)
|
||||
private String seller;
|
||||
|
||||
@CsvBindByName(column = "ТКР продавца")
|
||||
@CsvBindByPosition(position = 9)
|
||||
@BindByName(column = "ТКР продавца")
|
||||
@BindByPosition(position = 9)
|
||||
private String sellerTkr;
|
||||
|
||||
@CsvBindByName(column = "Клиринговый код покупателя")
|
||||
@CsvBindByPosition(position = 10)
|
||||
@BindByName(column = "Клиринговый код покупателя")
|
||||
@BindByPosition(position = 10)
|
||||
private String buyerCode;
|
||||
|
||||
@CsvBindByName(column = "Наименование компании-покупателя")
|
||||
@CsvBindByPosition(position = 11)
|
||||
@BindByName(column = "Наименование компании-покупателя")
|
||||
@BindByPosition(position = 11)
|
||||
private String buyer;
|
||||
|
||||
@CsvBindByName(column = "Торгово-клиринговый регистр покупателя")
|
||||
@CsvBindByPosition(position = 12)
|
||||
@BindByName(column = "Торгово-клиринговый регистр покупателя")
|
||||
@BindByPosition(position = 12)
|
||||
private String buyerTkr;
|
||||
|
||||
@CsvBindByName(column = "Сумма сделки")
|
||||
@CsvBindByPosition(position = 13)
|
||||
@CsvNumber(value = "#0.00", writeFormat = "#0.00")
|
||||
@BindByName(column = "Сумма сделки")
|
||||
@BindByPosition(position = 13)
|
||||
@ReportNumber(value = "#0.00")
|
||||
private BigDecimal amount;
|
||||
|
||||
@CsvBindByName(column = "Количество ценных бумаг")
|
||||
@CsvBindByPosition(position = 14)
|
||||
@CsvNumber(value = "#0", writeFormat = "#0")
|
||||
@BindByName(column = "Количество ценных бумаг")
|
||||
@BindByPosition(position = 14)
|
||||
@ReportNumber(value = "#0")
|
||||
private BigDecimal quantity;
|
||||
|
||||
@CsvBindByName(column = "Статус")
|
||||
@CsvBindByPosition(position = 15)
|
||||
@BindByName(column = "Статус")
|
||||
@BindByPosition(position = 15)
|
||||
private String status;
|
||||
|
||||
@CsvBindByName(column = "Код режима")
|
||||
@CsvBindByPosition(position = 16)
|
||||
@BindByName(column = "Код режима")
|
||||
@BindByPosition(position = 16)
|
||||
private String market;
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
package ru.spcex.clearing.registry.reports.report;
|
||||
|
||||
public interface FileReport {
|
||||
}
|
||||
|
|
@ -1,54 +1,54 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
package ru.spcex.clearing.registry.reports.report;
|
||||
|
||||
import com.opencsv.bean.CsvBindByName;
|
||||
import com.opencsv.bean.CsvBindByPosition;
|
||||
import com.opencsv.bean.CsvDate;
|
||||
import com.opencsv.bean.CsvNumber;
|
||||
import ru.spcex.clearing.registry.annotation.BindByName;
|
||||
import ru.spcex.clearing.registry.annotation.BindByPosition;
|
||||
import ru.spcex.clearing.registry.annotation.ReportDate;
|
||||
import ru.spcex.clearing.registry.annotation.ReportNumber;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class LiabilitiesRegistryReport implements FileReport {
|
||||
@CsvBindByName(column = "имя")
|
||||
@CsvBindByPosition(position = 0)
|
||||
@BindByName(column = "имя")
|
||||
@BindByPosition(position = 0)
|
||||
private String short_name;
|
||||
|
||||
@CsvBindByName(column = "клиринговый код")
|
||||
@CsvBindByPosition(position = 0)
|
||||
@BindByName(column = "клиринговый код")
|
||||
@BindByPosition(position = 1)
|
||||
private String clearing_code;
|
||||
|
||||
@CsvBindByName(column = "счет")
|
||||
@CsvBindByPosition(position = 1)
|
||||
@BindByName(column = "счет")
|
||||
@BindByPosition(position = 2)
|
||||
private String account;
|
||||
|
||||
@CsvBindByName(column = "код регистра")
|
||||
@CsvBindByPosition(position = 2)
|
||||
@BindByName(column = "код регистра")
|
||||
@BindByPosition(position = 3)
|
||||
private String registry_code;
|
||||
|
||||
@CsvBindByName(column = "статус")
|
||||
@CsvBindByPosition(position = 3)
|
||||
@BindByName(column = "статус")
|
||||
@BindByPosition(position = 4)
|
||||
private String registry_status;
|
||||
|
||||
@CsvBindByName(column = "инструмент валюта")
|
||||
@CsvBindByPosition(position = 4)
|
||||
@BindByName(column = "инструмент валюта")
|
||||
@BindByPosition(position = 5)
|
||||
private String security_symbol;
|
||||
|
||||
@CsvBindByName(column = "баланс")
|
||||
@CsvBindByPosition(position = 5)
|
||||
@CsvNumber(value = "#0.00", writeFormat = "#0.00")
|
||||
@BindByName(column = "баланс")
|
||||
@BindByPosition(position = 6)
|
||||
@ReportNumber(value = "#0.00")
|
||||
private BigDecimal balance;
|
||||
|
||||
@CsvBindByName(column = "дата расчета")
|
||||
@CsvBindByPosition(position = 6)
|
||||
@CsvDate(value = "dd.MM.yyyy")
|
||||
@BindByName(column = "дата расчета")
|
||||
@BindByPosition(position = 7)
|
||||
@ReportDate(value = "dd.MM.yyyy")
|
||||
private LocalDate settlement_date;
|
||||
|
||||
@CsvBindByName(column = "продукт")
|
||||
@CsvBindByPosition(position = 7)
|
||||
@BindByName(column = "продукт")
|
||||
@BindByPosition(position = 8)
|
||||
private String contract;
|
||||
|
||||
@CsvBindByName(column = "тип сессии")
|
||||
@CsvBindByPosition(position = 8)
|
||||
@BindByName(column = "тип сессии")
|
||||
@BindByPosition(position = 9)
|
||||
private String session_type;
|
||||
|
||||
public String getShort_name() {
|
||||
|
|
@ -1,48 +1,48 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
package ru.spcex.clearing.registry.reports.report;
|
||||
|
||||
import com.opencsv.bean.CsvBindByName;
|
||||
import com.opencsv.bean.CsvBindByPosition;
|
||||
import com.opencsv.bean.CsvDate;
|
||||
import com.opencsv.bean.CsvNumber;
|
||||
import ru.spcex.clearing.registry.annotation.BindByName;
|
||||
import ru.spcex.clearing.registry.annotation.BindByPosition;
|
||||
import ru.spcex.clearing.registry.annotation.ReportDate;
|
||||
import ru.spcex.clearing.registry.annotation.ReportNumber;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class MoneyBalanceRegisterReport implements FileReport {
|
||||
@CsvBindByName(column = "Наименование Расчетного депозитария")
|
||||
@CsvBindByPosition(position = 0)
|
||||
@BindByName(column = "Наименование Расчетного депозитария")
|
||||
@BindByPosition(position = 0)
|
||||
private String houseName;
|
||||
|
||||
@CsvBindByName(column = "Номер отчета")
|
||||
@CsvBindByPosition(position = 1)
|
||||
@BindByName(column = "Номер отчета")
|
||||
@BindByPosition(position = 1)
|
||||
private String number;
|
||||
|
||||
@CsvBindByName(column = "Дата")
|
||||
@CsvBindByPosition(position = 2)
|
||||
@CsvDate(value = "dd.MM.yyyy")
|
||||
@BindByName(column = "Дата")
|
||||
@BindByPosition(position = 2)
|
||||
@ReportDate(value = "dd.MM.yyyy")
|
||||
private LocalDate date;
|
||||
|
||||
@CsvBindByName(column = "Время")
|
||||
@CsvBindByPosition(position = 3)
|
||||
@CsvDate(value = "HH:mm:ss")
|
||||
@BindByName(column = "Время")
|
||||
@BindByPosition(position = 3)
|
||||
@ReportDate(value = "HH:mm:ss")
|
||||
private LocalDateTime time;
|
||||
|
||||
@CsvBindByName(column = "Код валюты")
|
||||
@CsvBindByPosition(position = 4)
|
||||
@BindByName(column = "Код валюты")
|
||||
@BindByPosition(position = 4)
|
||||
private String currency;
|
||||
|
||||
@CsvBindByName(column = "Краткое наименование УК")
|
||||
@CsvBindByPosition(position = 5)
|
||||
@BindByName(column = "Краткое наименование УК")
|
||||
@BindByPosition(position = 5)
|
||||
private String company;
|
||||
|
||||
@CsvBindByName(column = "Номер торгового /клирингового счета/ счета внутреннего учета СПВБ")
|
||||
@CsvBindByPosition(position = 6)
|
||||
@BindByName(column = "Номер торгового /клирингового счета/ счета внутреннего учета СПВБ")
|
||||
@BindByPosition(position = 6)
|
||||
private String account;
|
||||
|
||||
@CsvBindByName(column = "Остаток денежных средств")
|
||||
@CsvBindByPosition(position = 7)
|
||||
@CsvNumber(value = "#0.00", writeFormat = "#0.00")
|
||||
@BindByName(column = "Остаток денежных средств")
|
||||
@BindByPosition(position = 7)
|
||||
@ReportNumber(value = "#0.00")
|
||||
private BigDecimal sum;
|
||||
|
||||
|
||||
|
|
@ -1,60 +1,60 @@
|
|||
package ru.spcex.clearing.registry.reports.bean;
|
||||
package ru.spcex.clearing.registry.reports.report;
|
||||
|
||||
import com.opencsv.bean.CsvBindByName;
|
||||
import com.opencsv.bean.CsvBindByPosition;
|
||||
import com.opencsv.bean.CsvDate;
|
||||
import com.opencsv.bean.CsvNumber;
|
||||
import ru.spcex.clearing.registry.annotation.BindByName;
|
||||
import ru.spcex.clearing.registry.annotation.BindByPosition;
|
||||
import ru.spcex.clearing.registry.annotation.ReportDate;
|
||||
import ru.spcex.clearing.registry.annotation.ReportNumber;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class MoneyPaymentInstructionRegisterReport implements FileReport {
|
||||
@CsvBindByName(column = "Номер распоряжения")
|
||||
@CsvBindByPosition(position = 0)
|
||||
@BindByName(column = "Номер распоряжения")
|
||||
@BindByPosition(position = 0)
|
||||
private Long number;
|
||||
|
||||
@CsvBindByName(column = "Дата распоряжения")
|
||||
@CsvBindByPosition(position = 1)
|
||||
@CsvDate(value = "dd.MM.yyyy")
|
||||
@BindByName(column = "Дата распоряжения")
|
||||
@BindByPosition(position = 1)
|
||||
@ReportDate(value = "dd.MM.yyyy")
|
||||
private LocalDate date;
|
||||
|
||||
@CsvBindByName(column = "Время формирования")
|
||||
@CsvBindByPosition(position = 2)
|
||||
@CsvDate(value = "HH:mm:ss")
|
||||
@BindByName(column = "Время формирования")
|
||||
@BindByPosition(position = 2)
|
||||
@ReportDate(value = "HH:mm:ss")
|
||||
private LocalDateTime time;
|
||||
|
||||
@CsvBindByName(column = "Номер торгового банковского/клирингового счета списания")
|
||||
@CsvBindByPosition(position = 3)
|
||||
@BindByName(column = "Номер торгового банковского/клирингового счета списания")
|
||||
@BindByPosition(position = 3)
|
||||
private String accountSender;
|
||||
|
||||
@CsvBindByName(column = "Наименование владельца счета списания")
|
||||
@CsvBindByPosition(position = 4)
|
||||
@BindByName(column = "Наименование владельца счета списания")
|
||||
@BindByPosition(position = 4)
|
||||
private String sender;
|
||||
|
||||
@CsvBindByName(column = "Код владельца счета списания")
|
||||
@CsvBindByPosition(position = 5)
|
||||
@BindByName(column = "Код владельца счета списания")
|
||||
@BindByPosition(position = 5)
|
||||
private String codeSender;
|
||||
|
||||
@CsvBindByName(column = "Номер торгового банковского/клирингового счета зачисления")
|
||||
@CsvBindByPosition(position = 6)
|
||||
@BindByName(column = "Номер торгового банковского/клирингового счета зачисления")
|
||||
@BindByPosition(position = 6)
|
||||
private String accountAddressee;
|
||||
|
||||
@CsvBindByName(column = "Наименование владельца счета зачисления")
|
||||
@CsvBindByPosition(position = 7)
|
||||
@BindByName(column = "Наименование владельца счета зачисления")
|
||||
@BindByPosition(position = 7)
|
||||
private String addressee;
|
||||
|
||||
@CsvBindByName(column = "Код владельца счета зачисления")
|
||||
@CsvBindByPosition(position = 8)
|
||||
@BindByName(column = "Код владельца счета зачисления")
|
||||
@BindByPosition(position = 8)
|
||||
private String codeAddressee;
|
||||
|
||||
@CsvBindByName(column = "Код валюты")
|
||||
@CsvBindByPosition(position = 9)
|
||||
@BindByName(column = "Код валюты")
|
||||
@BindByPosition(position = 9)
|
||||
private String currencyCode;
|
||||
|
||||
@CsvBindByName(column = "Сумма денежных средств")
|
||||
@CsvBindByPosition(position = 10)
|
||||
@CsvNumber(value = "#0.00", writeFormat = "#0.00")
|
||||
@BindByName(column = "Сумма денежных средств")
|
||||
@BindByPosition(position = 10)
|
||||
@ReportNumber(value = "#0.00")
|
||||
private BigDecimal sum;
|
||||
|
||||
|
||||
|
|
@ -1,153 +0,0 @@
|
|||
package ru.spcex.clearing.registry.service;
|
||||
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.register.AdmittedLiabilitiesRegister;
|
||||
import ru.clearing.classes.statics.data.registry.Registry;
|
||||
import ru.clearing.classes.statics.data.security.Security;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.registry.AdmittedLiabilitiesRegisterNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.schedule.LauncherCommandRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.clearing.registry.util.PreClearMap;
|
||||
import ru.spcex.platform.enumeration.RegistryDesignation;
|
||||
import ru.spcex.platform.enumeration.RegistryInstrumentType;
|
||||
import ru.spcex.platform.enumeration.RegistryStatus;
|
||||
import ru.spcex.platform.enumeration.RegistryUnit;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.predicate.specific.SecuritySelector;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static ru.spcex.platform.enumeration.Task.createRegistry_ADLR;
|
||||
|
||||
@Service
|
||||
public class AdmittedLiabilitiesRegisterService extends QueueConsumer implements InitializingBean, ICheckDuplicate<Registry, AdmittedLiabilitiesRegister> {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private final Imdg<AdmittedLiabilitiesRegister> admittedLiabilitiesRegisterMap;
|
||||
private final Imdg<Registry> registryMap;
|
||||
private final Imdg<Company> companyMap;
|
||||
private final SecuritySelector<Security> securitySelector;
|
||||
private final Function<Map<String, ?>, IValidator> fieldValuesValidator;
|
||||
private final PreClearMap<AdmittedLiabilitiesRegister> preClearMap;
|
||||
|
||||
@Autowired
|
||||
public AdmittedLiabilitiesRegisterService(Consumer<String, Object> kafkaQueue,
|
||||
Producer<String, Object> kafkaProducer,
|
||||
ImdgProvider imdgProvider,
|
||||
Function<Map<String, ?>, IValidator> fieldValuesValidator) {
|
||||
super(kafkaQueue, kafkaProducer);
|
||||
this.admittedLiabilitiesRegisterMap = imdgProvider.getImdg(IMDGDistributedNames.Map_AdmittedLiabilitiesRegister, AdmittedLiabilitiesRegister.class);
|
||||
this.registryMap = imdgProvider.getImdg(IMDGDistributedNames.Map_Registry, Registry.class);
|
||||
this.companyMap = imdgProvider.getImdg(IMDGDistributedNames.Map_Company, Company.class);
|
||||
this.securitySelector = new SecuritySelector<>(imdgProvider, Security.class);
|
||||
this.fieldValuesValidator = fieldValuesValidator;
|
||||
preClearMap = PreClearMap.instanceForInstantField(admittedLiabilitiesRegisterMap, "created");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
callback(AdmittedLiabilitiesRegisterNewRequest.class)
|
||||
.setConsumer(this::admittedLiabilitiesRegisterNew)
|
||||
.forDestination(Consts.REGISTRY_ADMITTED_LIABILITIES_REGISTER_NEW, callbacks::put);
|
||||
callback(LauncherCommandRequest.class)
|
||||
.setConsumer(this::admittedLiabilitiesRegisterNew)
|
||||
.forDestination(createRegistry_ADLR.topic(), callbacks::put);
|
||||
init();
|
||||
}
|
||||
|
||||
public void admittedLiabilitiesRegisterNew(BaseRequest<?> userRequest) {
|
||||
log.debug("AdmittedLiabilitiesRegisterNewRequest received from {}", Consts.REGISTRY_ADMITTED_LIABILITIES_REGISTER_NEW);
|
||||
String sqlConditionForRegistry = getSqlForRegistries();
|
||||
Collection<Registry> registries = registryMap.getCollectionObjectsBySQL(sqlConditionForRegistry);
|
||||
if (registries.isEmpty()) {
|
||||
log.debug("No registry with such conditions {}", sqlConditionForRegistry);
|
||||
return;
|
||||
}
|
||||
log.debug("Select {} Registry by query {}", registries.size(), registries);
|
||||
preClearMap.preClearMap();
|
||||
registries.forEach((registry -> {
|
||||
if (isDuplicateInMap(registry).isEmpty()) {
|
||||
insertAdmittedLiabilitiesRegister(registry);
|
||||
}
|
||||
}
|
||||
));
|
||||
log.debug("Successfully processed..");
|
||||
}
|
||||
|
||||
private void insertAdmittedLiabilitiesRegister(Registry registry) {
|
||||
log.trace("Started generating AdmittedLiabilitiesRegister entity...");
|
||||
AdmittedLiabilitiesRegister admittedLiabilitiesRegister = new AdmittedLiabilitiesRegister();
|
||||
Company company = companyMap.getFirstObjectByFieldValues(Map.of("id", 1L));
|
||||
Security security = securitySelector.selectSecurityById(registry.getSecurityId());
|
||||
String securityFullName = security != null ? security.getFullName() : null;
|
||||
String companyFullName = company != null ? company.getFullName() : null;
|
||||
admittedLiabilitiesRegister.setCompanyFullName(companyFullName);
|
||||
admittedLiabilitiesRegister.setSessionId(registry.getSessionId());
|
||||
admittedLiabilitiesRegister.setSecuritySymbol(registry.getSecuritySymbol());
|
||||
admittedLiabilitiesRegister.setSecurityFullName(securityFullName);
|
||||
admittedLiabilitiesRegister.setCompanyId(registry.getCompanyId());
|
||||
admittedLiabilitiesRegister.setClearingCode(registry.getClearingCode());
|
||||
admittedLiabilitiesRegister.setAccount(registry.getAccount());
|
||||
admittedLiabilitiesRegister.setAmount(registry.getBalance());
|
||||
admittedLiabilitiesRegister.setClearingDate(registry.getClearingDate());
|
||||
admittedLiabilitiesRegister.setCreated(Instant.now());
|
||||
admittedLiabilitiesRegister.setUpdated(Instant.now());
|
||||
admittedLiabilitiesRegisterMap.insert(admittedLiabilitiesRegister);
|
||||
log.debug("inserted successfully AdmittedLiabilitiesRegister entity with id: {}", admittedLiabilitiesRegister.getId());
|
||||
}
|
||||
|
||||
private String getSqlForRegistries() {
|
||||
return String.format("registryDesignation = '%s' and " +
|
||||
"registryInstrumentType in ('%s','%s') and " +
|
||||
"registryUnit = '%s' and " +
|
||||
"registryStatus in ('%s','%s','%s','%s','%s', '%s')"
|
||||
,
|
||||
RegistryDesignation.O.getKey(),
|
||||
RegistryInstrumentType.S.getKey(),
|
||||
RegistryInstrumentType.M.getKey(),
|
||||
RegistryUnit.T.getKey(),
|
||||
RegistryStatus.OK.getKey(),
|
||||
RegistryStatus.NACK.getKey(),
|
||||
RegistryStatus.UNCV.getKey(),
|
||||
RegistryStatus.NACC.getKey(),
|
||||
RegistryStatus.FAIL.getKey(),
|
||||
RegistryStatus.CLRD.getKey()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<AdmittedLiabilitiesRegister> isDuplicateInMap(Registry entity) {
|
||||
return Optional.empty();
|
||||
//для всех isDuplicateInMap: пока не используется, надо по критерию чистить мапу перед вставкой записей, preClearMap.
|
||||
// Map<String, ? extends Comparable<?>> fieldValues = Map.of(
|
||||
// "companyId", entity.getRegistryCode(),
|
||||
// "sessionId", entity.getSessionId(),
|
||||
// "securitySymbol", entity.getSecuritySymbol(),
|
||||
// "clearingDate", entity.getClearingDate(),
|
||||
// "account", entity.getAccount()
|
||||
// );
|
||||
// Optional<EnumMessage> message = fieldValuesValidator.apply(fieldValues).tillFirstError();
|
||||
// if (message.isPresent()) {
|
||||
// log.warn("Illegal value in map for request to imdg: {}", message.get());
|
||||
// throw new IllegalArgumentException(MessageFormat.format("Illegal value in request to imdg: {0}", message.get()));
|
||||
// }
|
||||
// return Optional.ofNullable(admittedLiabilitiesRegisterMap.getFirstObjectByFieldValues(fieldValues));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,141 +0,0 @@
|
|||
package ru.spcex.clearing.registry.service;
|
||||
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.register.CoveredLiabilitiesRegister;
|
||||
import ru.clearing.classes.statics.data.registry.Registry;
|
||||
import ru.clearing.classes.statics.data.security.Security;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.registry.CoveredLiabilitiesRegisterNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.schedule.LauncherCommandRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.clearing.registry.util.PreClearMap;
|
||||
import ru.spcex.platform.enumeration.RegistryDesignation;
|
||||
import ru.spcex.platform.enumeration.RegistryInstrumentType;
|
||||
import ru.spcex.platform.enumeration.RegistryStatus;
|
||||
import ru.spcex.platform.enumeration.RegistryUnit;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.predicate.specific.SecuritySelector;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static ru.spcex.platform.enumeration.Task.createRegistry_CDLR;
|
||||
|
||||
@Service
|
||||
public class CoveredLiabilitiesRegisterService extends QueueConsumer implements InitializingBean, ICheckDuplicate<Registry, CoveredLiabilitiesRegister> {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private final Imdg<CoveredLiabilitiesRegister> coveredLiabilitiesRegisterMap;
|
||||
private final Imdg<Registry> registryMap;
|
||||
private final Imdg<Company> companyMap;
|
||||
private final SecuritySelector<Security> securitySelector;
|
||||
private final Function<Map<String, ?>, IValidator> fieldValuesValidator;
|
||||
private final PreClearMap<CoveredLiabilitiesRegister> preClearMap;
|
||||
|
||||
@Autowired
|
||||
public CoveredLiabilitiesRegisterService(Consumer<String, Object> kafkaQueue,
|
||||
Producer<String, Object> kafkaProducer,
|
||||
ImdgProvider imdgProvider,
|
||||
Function<Map<String, ?>, IValidator> fieldValuesValidator) {
|
||||
super(kafkaQueue, kafkaProducer);
|
||||
this.coveredLiabilitiesRegisterMap = imdgProvider.getImdg(IMDGDistributedNames.Map_CoveredLiabilitiesRegister, CoveredLiabilitiesRegister.class);
|
||||
this.registryMap = imdgProvider.getImdg(IMDGDistributedNames.Map_Registry, Registry.class);
|
||||
this.companyMap = imdgProvider.getImdg(IMDGDistributedNames.Map_Company, Company.class);
|
||||
this.securitySelector = new SecuritySelector<>(imdgProvider, Security.class);
|
||||
this.fieldValuesValidator = fieldValuesValidator;
|
||||
preClearMap = PreClearMap.instanceForInstantField(coveredLiabilitiesRegisterMap, "created");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
callback(CoveredLiabilitiesRegisterNewRequest.class)
|
||||
.setConsumer(this::coveredLiabilitiesRegisterNew)
|
||||
.forDestination(Consts.REGISTRY_COVERED_LIABILITIES_REGISTER_NEW, callbacks::put);
|
||||
callback(LauncherCommandRequest.class)
|
||||
.setConsumer(this::coveredLiabilitiesRegisterNew)
|
||||
.forDestination(createRegistry_CDLR.topic(), callbacks::put);
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
public void coveredLiabilitiesRegisterNew(BaseRequest<?> userRequest) {
|
||||
log.debug("CoveredLiabilitiesRegisterNew received");
|
||||
String sqlConditionForRegistry = getSqlForRegistries();
|
||||
Collection<Registry> registries = registryMap.getCollectionObjectsBySQL(sqlConditionForRegistry);
|
||||
if (registries.isEmpty()) {
|
||||
log.debug("No registry with such conditions {}", sqlConditionForRegistry);
|
||||
return;
|
||||
}
|
||||
log.debug("Select {} Registry by query {}", registries.size(), sqlConditionForRegistry);
|
||||
preClearMap.preClearMap();
|
||||
registries.forEach((registry -> {
|
||||
if (isDuplicateInMap(registry).isEmpty()) {
|
||||
insertCoveredLiabilitiesRegister(registry);
|
||||
}
|
||||
}
|
||||
));
|
||||
log.debug("successfully processed");
|
||||
}
|
||||
|
||||
private void insertCoveredLiabilitiesRegister(Registry registry) {
|
||||
log.trace("insert CoveredLiabilitiesRegister in map...");
|
||||
CoveredLiabilitiesRegister coveredLiabilitiesRegister = new CoveredLiabilitiesRegister();
|
||||
Company company = companyMap.getFirstObjectByFieldValues(Map.of("id", 1L));
|
||||
Security security = securitySelector.selectSecurityById(registry.getSecurityId());
|
||||
String securityFullName = security != null ? security.getFullName() : null;
|
||||
String companyFullName = company != null ? company.getFullName() : null;
|
||||
coveredLiabilitiesRegister.setCompanyFullName(companyFullName);
|
||||
coveredLiabilitiesRegister.setSessionId(registry.getSessionId());
|
||||
coveredLiabilitiesRegister.setSecuritySymbol(registry.getSecuritySymbol());
|
||||
coveredLiabilitiesRegister.setSecurityFullName(securityFullName);
|
||||
coveredLiabilitiesRegister.setCompanyId(registry.getCompanyId());
|
||||
coveredLiabilitiesRegister.setClearingCode(registry.getClearingCode());
|
||||
coveredLiabilitiesRegister.setAccount(registry.getAccount());
|
||||
coveredLiabilitiesRegister.setAmount(registry.getBalance());
|
||||
coveredLiabilitiesRegister.setClearingDate(registry.getClearingDate());
|
||||
coveredLiabilitiesRegister.setCreated(Instant.now());
|
||||
coveredLiabilitiesRegister.setUpdated(Instant.now());
|
||||
coveredLiabilitiesRegisterMap.insert(coveredLiabilitiesRegister);
|
||||
log.debug("CoveredLiabilitiesRegister inserted successfully with id: {}", coveredLiabilitiesRegister.getId());
|
||||
}
|
||||
|
||||
private String getSqlForRegistries() {
|
||||
return String.format("registryDesignation = '%s' and " +
|
||||
"registryInstrumentType in ('%s','%s') and " +
|
||||
"registryUnit = '%s' and " +
|
||||
"registryStatus in ('%s', '%s')",
|
||||
RegistryDesignation.O.getKey(),
|
||||
RegistryInstrumentType.S.getKey(),
|
||||
RegistryInstrumentType.M.getKey(),
|
||||
RegistryUnit.T.getKey(),
|
||||
RegistryStatus.OK.getKey(),
|
||||
RegistryStatus.CLRD.getKey()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<CoveredLiabilitiesRegister> isDuplicateInMap(Registry entity) {
|
||||
return Optional.empty();
|
||||
// Map<String, ? extends Comparable<?>> fieldValues = Map.of("companyId", entity.getCompanyId(), "sessionId", entity.getSessionId());
|
||||
// Optional<EnumMessage> message = fieldValuesValidator.apply(fieldValues).tillFirstError();
|
||||
// if (message.isPresent()) {
|
||||
// log.warn("Illegal value in map for request to imdg: {}", message.get());
|
||||
// throw new IllegalArgumentException(MessageFormat.format("Illegal value in request to imdg: {0}", message.get()));
|
||||
// }
|
||||
// return Optional.ofNullable(coveredLiabilitiesRegisterMap.getFirstObjectByFieldValues(fieldValues));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,151 +0,0 @@
|
|||
package ru.spcex.clearing.registry.service;
|
||||
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.register.DepoBalanceRegister;
|
||||
import ru.clearing.classes.statics.data.registry.Registry;
|
||||
import ru.clearing.classes.statics.data.registry.RegistryHistory;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.schedule.LauncherCommandRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.clearing.registry.config.SFTPReportsConfig;
|
||||
import ru.spcex.clearing.registry.config.settings.RegistryServiceSettings;
|
||||
import ru.spcex.clearing.registry.reports.ReportUtils;
|
||||
import ru.spcex.clearing.registry.reports.builders.DepoBalanceRegisterReportBuilder;
|
||||
import ru.spcex.clearing.registry.util.PreClearMap;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.enumeration.RegistryTradingParams;
|
||||
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;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static ru.spcex.platform.enumeration.Task.createRegistry_GRRT;
|
||||
|
||||
@Service
|
||||
public class DepoBalanceRegisterService extends QueueConsumer implements InitializingBean {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private final Imdg<DepoBalanceRegister> depoBalanceRegisterMap;
|
||||
private final Imdg<RegistryHistory> registryHistoryMap;
|
||||
private final PreClearMap<DepoBalanceRegister> preClearMap;
|
||||
|
||||
private final DepoBalanceRegisterReportBuilder reportBuilder;
|
||||
private final File outFolder;
|
||||
private final RegistryServiceSettings settings;
|
||||
|
||||
private final SFTPReportsConfig.ReportsGateway reportsSftpGateway;
|
||||
private final boolean deleteAfterSend;
|
||||
|
||||
@Autowired
|
||||
public DepoBalanceRegisterService(Consumer<String, Object> kafkaQueue,
|
||||
Producer<String, Object> kafkaProducer,
|
||||
ImdgProvider imdgProvider,
|
||||
RegistryServiceSettings settings,
|
||||
@Qualifier("reportOutDir") File outFolder,
|
||||
SFTPReportsConfig.ReportsGateway reportsSftpGateway) {
|
||||
super(kafkaQueue, kafkaProducer);
|
||||
this.depoBalanceRegisterMap = imdgProvider.getImdg(IMDGDistributedNames.Map_DepoBalanceRegister, DepoBalanceRegister.class);
|
||||
this.registryHistoryMap = imdgProvider.getImdg(IMDGDistributedNames.Map_RegistryHistory, RegistryHistory.class);
|
||||
preClearMap = PreClearMap.instanceForInstantField(depoBalanceRegisterMap, "created");
|
||||
reportBuilder = new DepoBalanceRegisterReportBuilder(imdgProvider);
|
||||
this.outFolder = outFolder;
|
||||
this.settings = settings;
|
||||
this.reportsSftpGateway = reportsSftpGateway;
|
||||
this.deleteAfterSend = settings.getReportsStore().isDeleteAfterSend();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
callback(LauncherCommandRequest.class)
|
||||
.setConsumer(this::depoBalanceRegisterNew)
|
||||
.forDestination(createRegistry_GRRT.topic(), callbacks::put);
|
||||
init();
|
||||
}
|
||||
|
||||
public void depoBalanceRegisterNew(BaseRequest<LauncherCommandRequest> userRequest) {
|
||||
boolean csvMode = settings.isCsvMode();
|
||||
log.debug("LauncherCommandRequest received from {}", createRegistry_GRRT.topic());
|
||||
ImdgPredicate predicate = getPredicateForRegistries(userRequest.getRequestPayload().getCompanyId());
|
||||
Collection<RegistryHistory> registryHistories = registryHistoryMap.getCollectionObjectsByPredicate(predicate);
|
||||
log.trace("Started searching depoBalanceRegister in register by '{}'", predicate);
|
||||
if (registryHistories.isEmpty()) {
|
||||
log.debug("No registry with such conditions '{}'", predicate);
|
||||
return;
|
||||
}
|
||||
log.debug("Select {} Registry history by query {}", registryHistories.size(), predicate);
|
||||
if (!csvMode) preClearMap.preClearMap();
|
||||
List<RegistryHistory> registryForReport = new ArrayList<>();
|
||||
for (RegistryHistory registryHistory : registryHistories) {
|
||||
if (BigDecimal.ZERO.compareTo(registryHistory.getObject().getDiffBalance()) != 0) continue;
|
||||
if (!csvMode) insertDepoBalanceRegister(registryHistory);
|
||||
else registryForReport.add(registryHistory);
|
||||
}
|
||||
if (csvMode) {
|
||||
File reportFile = reportBuilder.buildReport(registryForReport, outFolder);
|
||||
ReportUtils.sendFilesToSftp(List.of(reportFile), reportsSftpGateway, deleteAfterSend);
|
||||
}
|
||||
log.debug("Successfully processed");
|
||||
}
|
||||
|
||||
private void insertDepoBalanceRegister(RegistryHistory registryHistory) {
|
||||
log.trace("Started generating DepoBalanceRegister entity...");
|
||||
Registry registry = registryHistory.getObject();
|
||||
DepoBalanceRegister depoBalanceRegister = new DepoBalanceRegister();
|
||||
depoBalanceRegister.setUpdated(Instant.now());
|
||||
depoBalanceRegister.setCreated(depoBalanceRegister.getUpdated());
|
||||
depoBalanceRegister.setCompanyId(registry.getCompanyId());
|
||||
AccountType accountType = IEnumKey.getEnumByKey(AccountType.class, registry.getAccountType());
|
||||
if (AccountType.Depo == accountType) {
|
||||
depoBalanceRegister.setDepoCode(registry.getAccount());
|
||||
}
|
||||
depoBalanceRegister.setQuantity(registry.getBalance());
|
||||
depoBalanceRegister.setSecuritySymbol(registry.getSecuritySymbol());
|
||||
depoBalanceRegisterMap.insert(depoBalanceRegister);
|
||||
log.debug("inserted successfully DepoBalanceRegister entity with id: {}", depoBalanceRegister.getId());
|
||||
}
|
||||
|
||||
private ImdgPredicate getPredicateForRegistries(Long companyId) {
|
||||
Instant now = Instant.now().truncatedTo(ChronoUnit.DAYS);
|
||||
ImdgPredicateBuilder pb = registryHistoryMap.predicateBuilder();
|
||||
RegistryCodeSqlBuilder codeSql = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.AS_T).prefix("object");
|
||||
ImdgPredicate registryPredicate;
|
||||
if (companyId == null) {
|
||||
registryPredicate = pb.sql(codeSql.build());
|
||||
} else {
|
||||
registryPredicate = pb.and(
|
||||
pb.equals("object.companyId", companyId),
|
||||
pb.sql(codeSql.build())
|
||||
);
|
||||
}
|
||||
ImdgPredicate finalPredicate = pb.and(
|
||||
registryPredicate,
|
||||
pb.notNull("object.tradingClearingRegistry"),
|
||||
pb.and(
|
||||
pb.greatEqual("eventTime", now),
|
||||
pb.less("eventTime", now.plus(1, ChronoUnit.DAYS))
|
||||
)
|
||||
);
|
||||
|
||||
log.trace("sql predicate for registry_history {}", finalPredicate);
|
||||
return finalPredicate;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,178 +0,0 @@
|
|||
package ru.spcex.clearing.registry.service;
|
||||
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.misc.Session;
|
||||
import ru.clearing.classes.statics.data.payment.PaymentInstruction;
|
||||
import ru.clearing.classes.statics.data.register.DepoPaymentInstructionRegister;
|
||||
import ru.clearing.classes.statics.data.registry.TradingClearingRegistry;
|
||||
import ru.clearing.platform.dictionary.InOutDirectionDictionary;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.schedule.LauncherCommandRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.clearing.registry.config.SFTPReportsConfig;
|
||||
import ru.spcex.clearing.registry.config.settings.RegistryServiceSettings;
|
||||
import ru.spcex.clearing.registry.reports.ReportUtils;
|
||||
import ru.spcex.clearing.registry.reports.builders.DepoPaymentInstructionRegisterReportBuilder;
|
||||
import ru.spcex.clearing.registry.util.PreClearMap;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.enumeration.TransactionStatus;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
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.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static ru.spcex.platform.enumeration.Task.createRegistry_GORD;
|
||||
import static ru.spcex.platform.enumeration.Task.createRegistry_GORR;
|
||||
|
||||
@Service
|
||||
public class DepoPaymentInstructionRegisterService extends QueueConsumer implements InitializingBean, ICheckDuplicate<PaymentInstruction, DepoPaymentInstructionRegister> {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private final Imdg<DepoPaymentInstructionRegister> depoPaymentInstructionRegisterMap;
|
||||
private final Imdg<PaymentInstruction> paymentInstructionMap;
|
||||
private final Imdg<Session> sessionMap;
|
||||
private final Imdg<TradingClearingRegistry> tradingClearingRegistryMap;
|
||||
private final Imdg<InOutDirectionDictionary> InOutDirectionDictionaryMap;
|
||||
private final Imdg<Account> accountMap;
|
||||
private final Function<Map<String, ?>, IValidator> fieldValuesValidator;
|
||||
private final PreClearMap<DepoPaymentInstructionRegister> preClearMap;
|
||||
|
||||
private final DepoPaymentInstructionRegisterReportBuilder reportBuilder;
|
||||
private final File outFolder;
|
||||
private final RegistryServiceSettings settings;
|
||||
|
||||
private final SFTPReportsConfig.ReportsGateway reportsSftpGateway;
|
||||
private final boolean deleteAfterSend;
|
||||
|
||||
|
||||
@Autowired
|
||||
public DepoPaymentInstructionRegisterService(Consumer<String, Object> kafkaQueue,
|
||||
Producer<String, Object> kafkaProducer,
|
||||
ImdgProvider imdgProvider,
|
||||
Function<Map<String, ?>, IValidator> fieldValuesValidator,
|
||||
@Qualifier("reportOutDir") File outFolder,
|
||||
RegistryServiceSettings settings,
|
||||
SFTPReportsConfig.ReportsGateway reportsSftpGateway) {
|
||||
super(kafkaQueue, kafkaProducer);
|
||||
this.depoPaymentInstructionRegisterMap = imdgProvider.getImdg(IMDGDistributedNames.Map_DepoPaymentInstructionRegister, DepoPaymentInstructionRegister.class);
|
||||
this.paymentInstructionMap = imdgProvider.getImdg(IMDGDistributedNames.Map_PaymentInstruction, PaymentInstruction.class);
|
||||
this.sessionMap = imdgProvider.getImdg(IMDGDistributedNames.Map_Session, Session.class);
|
||||
this.tradingClearingRegistryMap = imdgProvider.getImdg(IMDGDistributedNames.Map_TradingClearingRegistry, TradingClearingRegistry.class);
|
||||
this.InOutDirectionDictionaryMap = imdgProvider.getImdg(IMDGDistributedNames.Map_InOutDirectionDictionary, InOutDirectionDictionary.class);
|
||||
this.accountMap = imdgProvider.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
this.fieldValuesValidator = fieldValuesValidator;
|
||||
preClearMap = PreClearMap.instanceForInstantField(depoPaymentInstructionRegisterMap, "created");
|
||||
reportBuilder = new DepoPaymentInstructionRegisterReportBuilder(imdgProvider);
|
||||
this.outFolder = outFolder;
|
||||
this.settings = settings;
|
||||
this.reportsSftpGateway = reportsSftpGateway;
|
||||
this.deleteAfterSend = settings.getReportsStore().isDeleteAfterSend();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
callback(LauncherCommandRequest.class)
|
||||
.setConsumer(this::depoPaymentInstructionRegisterNew)
|
||||
.forDestination(createRegistry_GORD.topic(), callbacks::put);
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
public void depoPaymentInstructionRegisterNew(BaseRequest<LauncherCommandRequest> userRequest) {
|
||||
boolean csvMode = settings.isCsvMode();
|
||||
log.debug("LauncherCommandRequest received from {}", createRegistry_GORR.topic());
|
||||
|
||||
String piQuery = "transactionStatus='" + TransactionStatus.sent.getKey() + "' OR transactionStatus = '" +
|
||||
TransactionStatus.stld.getKey() + "' OR transactionStatus = '" + TransactionStatus.ok.getKey() + "'";
|
||||
Collection<PaymentInstruction> paymentInstructions = paymentInstructionMap.getCollectionObjectsBySQL(piQuery);
|
||||
log.debug("Selected {} PaymentInstruction by query \"{}\", do filter by account...",
|
||||
paymentInstructions.size(), piQuery);
|
||||
Collection<PaymentInstruction> depoPaymentInstructions = new ArrayList<>();
|
||||
for (PaymentInstruction paymentInstruction : paymentInstructions) {
|
||||
// filter by accountType
|
||||
if (paymentInstruction.getCreditLeg_accountId() != null) {
|
||||
Account account = accountMap.getSingleObjectByID(paymentInstruction.getCreditLeg_accountId());
|
||||
if (account == null)
|
||||
log.warn("Account id={} not found for paymentInstruction.id={}",
|
||||
paymentInstruction.getCreditLeg_accountId(), paymentInstruction.getId());
|
||||
else {
|
||||
if (IEnumKey.contains(account.getAccountType(), AccountType.Depo, AccountType.Dtrn)) {
|
||||
depoPaymentInstructions.add(paymentInstruction);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
log.debug("Filtered {} PaymentInstruction, with depo account's", depoPaymentInstructions.size());
|
||||
if (!csvMode) preClearMap.preClearMap();
|
||||
List<PaymentInstruction> paymentInstructionsForReport = new ArrayList<>();
|
||||
for (PaymentInstruction paymentInstruction : depoPaymentInstructions) {
|
||||
if (isDuplicateInMap(paymentInstruction).isEmpty()) {
|
||||
if (!csvMode) insertDepoPaymentInstructionRegister(paymentInstruction);
|
||||
else if (LocalDate.now().equals(paymentInstruction.getClearingDate()))
|
||||
paymentInstructionsForReport.add(paymentInstruction);
|
||||
}
|
||||
}
|
||||
if (csvMode) {
|
||||
File reportFile = reportBuilder.buildReport(paymentInstructionsForReport, outFolder);
|
||||
ReportUtils.sendFilesToSftp(List.of(reportFile), reportsSftpGateway, deleteAfterSend);
|
||||
}
|
||||
|
||||
log.debug("successfully processed");
|
||||
}
|
||||
|
||||
private void insertDepoPaymentInstructionRegister(PaymentInstruction paymentInstruction) {
|
||||
log.trace("Started generating DepoPaymentInstructionRegister entity...");
|
||||
DepoPaymentInstructionRegister depoPaymentInstructionRegister = new DepoPaymentInstructionRegister();
|
||||
TradingClearingRegistry tradingClearingRegistry = null;
|
||||
if (paymentInstruction.getCreditLeg_accountId() != null && paymentInstruction.getSenderId() != null) {
|
||||
tradingClearingRegistry = tradingClearingRegistryMap.getFirstObjectByFieldValues(Map.of("companyId", paymentInstruction.getSenderId(), "depoAccountId", paymentInstruction.getCreditLeg_accountId()));
|
||||
}
|
||||
InOutDirectionDictionary inOutDirectionDictionary = InOutDirectionDictionaryMap.getFirstObjectByFieldValues(Map.of("code", paymentInstruction.getCreditLeg_direction()));
|
||||
depoPaymentInstructionRegister.setCreated(Instant.now());
|
||||
depoPaymentInstructionRegister.setUpdated(Instant.now());
|
||||
depoPaymentInstructionRegister.setCompanyId(paymentInstruction.getSenderId());
|
||||
if (tradingClearingRegistry == null) {
|
||||
log.warn("For paymentInstruction[{}].CreditLeg_accountId={} or SenderId={} can not find TradingClearingRegistry.",
|
||||
paymentInstruction.getId(), paymentInstruction.getCreditLeg_accountId(), paymentInstruction.getSenderId());
|
||||
} else {
|
||||
depoPaymentInstructionRegister.setTradingClearingRegistryType(tradingClearingRegistry.getTradingClearingRegistryType());
|
||||
depoPaymentInstructionRegister.setTradingClearingRegistry(tradingClearingRegistry.getCode());
|
||||
}
|
||||
depoPaymentInstructionRegister.setCbCode("RNCB-BE-01");
|
||||
depoPaymentInstructionRegister.setQuantity(paymentInstruction.getCreditLeg_amount());
|
||||
depoPaymentInstructionRegister.setDirection(inOutDirectionDictionary.getId());
|
||||
depoPaymentInstructionRegister.setSessionId(paymentInstruction.getSessionId());
|
||||
depoPaymentInstructionRegisterMap.insert(depoPaymentInstructionRegister);
|
||||
log.debug("inserted successfully DepoBalanceRegister entity with id: {}", depoPaymentInstructionRegister.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<DepoPaymentInstructionRegister> isDuplicateInMap(PaymentInstruction entity) {
|
||||
return Optional.empty();
|
||||
// Map<String, ? extends Comparable<?>> fieldValues = Map.of(
|
||||
// "companyId", entity.getSenderId(),
|
||||
// "sessionId", entity.getSessionId()
|
||||
// );
|
||||
// Optional<EnumMessage> message = fieldValuesValidator.apply(fieldValues).tillFirstError();
|
||||
// if (message.isPresent()) {
|
||||
// log.warn("Illegal value in map for request to imdg: {}", message.get());
|
||||
// throw new IllegalArgumentException(MessageFormat.format("Illegal value in request to imdg: {0}", message.get()));
|
||||
// }
|
||||
// return Optional.ofNullable(depoPaymentInstructionRegisterMap.getFirstObjectByFieldValues(fieldValues));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,167 +0,0 @@
|
|||
package ru.spcex.clearing.registry.service;
|
||||
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.instrument.issue.FixedIncomeSecurity;
|
||||
import ru.clearing.classes.statics.data.misc.Session;
|
||||
import ru.clearing.classes.statics.data.register.ExcludeLiabilitiesRegister;
|
||||
import ru.clearing.classes.statics.data.registry.Registry;
|
||||
import ru.clearing.classes.statics.data.security.MoneyMarketSecurity;
|
||||
import ru.clearing.classes.statics.data.security.Security;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.registry.ExcludeLiabilitiesRegisterNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.schedule.LauncherCommandRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.clearing.registry.util.PreClearMap;
|
||||
import ru.spcex.platform.enumeration.*;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.predicate.specific.SecuritySelector;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static ru.spcex.platform.enumeration.Task.createRegistry_EXLR;
|
||||
|
||||
@Service
|
||||
public class ExcludeLiabilitiesRegisterService extends QueueConsumer implements InitializingBean, ICheckDuplicate<Registry, ExcludeLiabilitiesRegister> {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private final Imdg<ExcludeLiabilitiesRegister> excludeLiabilitiesRegisterMap;
|
||||
private final Imdg<Registry> registryMap;
|
||||
private final Imdg<Session> sessionMap;
|
||||
private final Imdg<ru.clearing.classes.statics.data.company.CompanySymbols> companySymbolMap;
|
||||
private final SecuritySelector<Security> securitySelector;
|
||||
private final Function<Map<String, ?>, IValidator> fieldValuesValidator;
|
||||
private final PreClearMap<ExcludeLiabilitiesRegister> preClearMap;
|
||||
|
||||
@Autowired
|
||||
public ExcludeLiabilitiesRegisterService(Consumer<String, Object> kafkaQueue,
|
||||
Producer<String, Object> kafkaProducer,
|
||||
ImdgProvider imdgProvider,
|
||||
Function<Map<String, ?>, IValidator> fieldValuesValidator) {
|
||||
super(kafkaQueue, kafkaProducer);
|
||||
this.excludeLiabilitiesRegisterMap = imdgProvider.getImdg(IMDGDistributedNames.Map_ExcludeLiabilitiesRegister, ExcludeLiabilitiesRegister.class);
|
||||
this.registryMap = imdgProvider.getImdg(IMDGDistributedNames.Map_Registry, Registry.class);
|
||||
this.sessionMap = imdgProvider.getImdg(IMDGDistributedNames.Map_Session, Session.class);
|
||||
this.companySymbolMap = imdgProvider.getImdg(IMDGDistributedNames.Map_CompanySymbols, ru.clearing.classes.statics.data.company.CompanySymbols.class);
|
||||
this.securitySelector = new SecuritySelector<>(imdgProvider, Security.class);
|
||||
this.fieldValuesValidator = fieldValuesValidator;
|
||||
preClearMap = PreClearMap.instanceForInstantField(excludeLiabilitiesRegisterMap, "created");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
callback(ExcludeLiabilitiesRegisterNewRequest.class)
|
||||
.setConsumer(this::excludeLiabilitiesRegisterNew)
|
||||
.forDestination(Consts.REGISTRY_EXCLUDE_LIABILITIES_REGISTER_NEW, callbacks::put);
|
||||
callback(LauncherCommandRequest.class)
|
||||
.setConsumer(this::excludeLiabilitiesRegisterNew)
|
||||
.forDestination(createRegistry_EXLR.topic(), callbacks::put);
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
public void excludeLiabilitiesRegisterNew(BaseRequest<?> userRequest) {
|
||||
log.debug("ExcludeLiabilitiesRegisterNew received");
|
||||
String sqlForRegistries = getSqlForRegistries();
|
||||
Collection<Registry> registries = registryMap.getCollectionObjectsBySQL(sqlForRegistries);
|
||||
if (registries.isEmpty()) {
|
||||
log.debug("No registry with such conditions {}", sqlForRegistries);
|
||||
return;
|
||||
}
|
||||
log.debug("Select {} Registry by query {}", registries.size(), sqlForRegistries);
|
||||
preClearMap.preClearMap();
|
||||
registries.forEach((registry -> {
|
||||
if (isDuplicateInMap(registry).isEmpty()) {
|
||||
insertExcludeLiabilitiesRegister(registry);
|
||||
}
|
||||
}
|
||||
));
|
||||
log.debug("successfully processed");
|
||||
}
|
||||
|
||||
private void insertExcludeLiabilitiesRegister(Registry registry) {
|
||||
log.trace("Started generating ExcludeLiabilitiesRegister entity...");
|
||||
ExcludeLiabilitiesRegister excludeLiabilitiesRegister = new ExcludeLiabilitiesRegister();
|
||||
//hz communicating
|
||||
Session sessionBySessionId = sessionMap.getSingleObjectByID(registry.getSessionId());
|
||||
Map<String, ? extends Comparable<?>> innPredicates = Map.of(
|
||||
"companySymbol", CompanySymbol.INN.getKey(),
|
||||
"companyId", registry.getCompanyId()
|
||||
);
|
||||
ru.clearing.classes.statics.data.company.CompanySymbols companySymbol = companySymbolMap.getFirstObjectByFieldValues(innPredicates);
|
||||
Security security = securitySelector.selectSecurityById(registry.getSecurityId());
|
||||
|
||||
excludeLiabilitiesRegister.setSessionId(registry.getSessionId());
|
||||
excludeLiabilitiesRegister.setValidFromDate(sessionBySessionId.getClearingDate());
|
||||
LocalDate validToDate = TimeUtil.toLocalDate(sessionBySessionId.getUpdated());
|
||||
excludeLiabilitiesRegister.setValidToDate(validToDate);
|
||||
excludeLiabilitiesRegister.setCompanyId(registry.getCompanyId());
|
||||
excludeLiabilitiesRegister.setCompanyFullName(registry.getFullName());
|
||||
if (companySymbol != null) {
|
||||
excludeLiabilitiesRegister.setInn(companySymbol.getCompanySymbolValue());
|
||||
}
|
||||
excludeLiabilitiesRegister.setRegistryCode(registry.getRegistryCode());
|
||||
excludeLiabilitiesRegister.setAccount(registry.getAccount());
|
||||
excludeLiabilitiesRegister.setRegistryStatus(registry.getRegistryStatus());
|
||||
if (security == null) {
|
||||
log.warn("Security id={} not found for registry id={}", registry.getSecurityId(), registry.getId());
|
||||
} else {
|
||||
if (InstrumentType.RATE.equalsByKey(security.getInstrumentType())) {
|
||||
excludeLiabilitiesRegister.setCurrency(((MoneyMarketSecurity) security).getNominalCurrency());
|
||||
} else if (InstrumentType.BOND.equalsByKey(security.getInstrumentType())) {
|
||||
excludeLiabilitiesRegister.setCurrency(((FixedIncomeSecurity) security).getNominalCurrency());
|
||||
} else if (InstrumentType.EQTY.equalsByKey(security.getInstrumentType())) {
|
||||
// не заполняется Currency
|
||||
} else { // never
|
||||
log.warn("Unexpected security[{}] type {}", security.getId(), security.getInstrumentType());
|
||||
}
|
||||
}
|
||||
excludeLiabilitiesRegister.setSumLiabilities(registry.getBalance());
|
||||
excludeLiabilitiesRegister.setSettlementDate(registry.getSettlementDate());
|
||||
excludeLiabilitiesRegister.setCreated(Instant.now());
|
||||
excludeLiabilitiesRegister.setUpdated(excludeLiabilitiesRegister.getCreated());
|
||||
excludeLiabilitiesRegisterMap.insert(excludeLiabilitiesRegister);
|
||||
log.debug("inserted successfully ExcludeLiabilitiesRegister entity with id: {}", excludeLiabilitiesRegister.getId());
|
||||
}
|
||||
|
||||
protected String getSqlForRegistries() {
|
||||
return String.format("registryDesignation = '%s' and " +
|
||||
"registryInstrumentType in ('%s','%s') and " +
|
||||
"registryUnit = '%s' and " +
|
||||
"registryStatus in ('%s', '%s')",
|
||||
RegistryDesignation.O.getKey(),
|
||||
RegistryInstrumentType.S.getKey(),
|
||||
RegistryInstrumentType.M.getKey(),
|
||||
RegistryUnit.T.getKey(),
|
||||
RegistryStatus.FAIL.getKey(),
|
||||
RegistryStatus.UNCV.getKey()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ExcludeLiabilitiesRegister> isDuplicateInMap(Registry entity) {
|
||||
return Optional.empty();
|
||||
// Map<String, ? extends Comparable<?>> fieldValues = Map.of("companyId", entity.getCompanyId(), "sessionId", entity.getSessionId());
|
||||
// Optional<EnumMessage> message = fieldValuesValidator.apply(fieldValues).tillFirstError();
|
||||
// if (message.isPresent()) {
|
||||
// log.warn("Illegal value in map for request to imdg: {}", message.get());
|
||||
// throw new IllegalArgumentException(MessageFormat.format("Illegal value in request to imdg: {0}", message.get()));
|
||||
// }
|
||||
// return Optional.ofNullable(excludeLiabilitiesRegisterMap.getFirstObjectByFieldValues(fieldValues));
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue