Merge branch 'dev' into cls-301
# Conflicts: # clearing-parent/pom.xml
This commit is contained in:
commit
8e390eb272
33 changed files with 1208 additions and 81 deletions
|
|
@ -3,7 +3,6 @@ package ru.spcex.clearing.config;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.spcex.clearing.service.executors.*;
|
||||
import ru.spcex.clearing.service.executors.SdfLegacyExecutor;
|
||||
import ru.spcex.platform.enumeration.SdfTable;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
|
@ -13,7 +12,7 @@ import java.util.Map;
|
|||
public class SdfExecutorsConfig {
|
||||
|
||||
@Bean("sdfExecutors")
|
||||
public Map<SdfTable, AbstractExecutor<?>> executorsMap(SdfLegacyExecutor sdf01Executor,
|
||||
public Map<SdfTable, AbstractExecutor<?>> executorsMap(Sdf01Executor sdf01Executor,
|
||||
Sdf57Executor sdf57Executor,
|
||||
Sdf04Executor sdf04Executor,
|
||||
Sdf13Executor sdf13Executor) {
|
||||
|
|
|
|||
|
|
@ -23,16 +23,19 @@ public class ClearingService implements DisposableBean {
|
|||
private final VerificationResultComponent verificationResultComponent;
|
||||
private final Clearing clearing;
|
||||
private final ExecutionDepositComponent executionDepositComponent;
|
||||
private final ExecutionFondComponent executionFondComponent;
|
||||
|
||||
@Autowired
|
||||
public ClearingService(SdfCreatorBySTLDPayment sdfCreator, PaymentUpdateBySdf04 paymentUpdater,
|
||||
VerificationResultComponent verificationResultComponent, Clearing clearing,
|
||||
ExecutionDepositComponent executionDepositComponent) {
|
||||
ExecutionDepositComponent executionDepositComponent,
|
||||
ExecutionFondComponent executionFondComponent) {
|
||||
this.sdfCreator = sdfCreator;
|
||||
this.paymentUpdater = paymentUpdater;
|
||||
this.verificationResultComponent = verificationResultComponent;
|
||||
this.executionDepositComponent = executionDepositComponent;
|
||||
this.clearing = clearing;
|
||||
this.executionFondComponent = executionFondComponent;
|
||||
this.executor = Executors.newSingleThreadExecutor();
|
||||
}
|
||||
|
||||
|
|
@ -101,6 +104,7 @@ public class ClearingService implements DisposableBean {
|
|||
executor.execute(() -> {
|
||||
try {
|
||||
executionDepositComponent.processNewTS();
|
||||
executionFondComponent.processNewTS();
|
||||
} catch (Throwable e) {
|
||||
log.error("{}", ExceptionUtils.getStackTrace(e));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import ru.spcex.platform.imdg.api.predicate.specific.RegistryCodeSqlBuilder;
|
|||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.platform.utils.number.BigDecimalUtil;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
|
@ -47,6 +48,7 @@ import java.util.Map;
|
|||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Service
|
||||
public class Sdf01Executor extends AbstractExecutor<SDf01> {
|
||||
|
|
@ -143,23 +145,23 @@ public class Sdf01Executor extends AbstractExecutor<SDf01> {
|
|||
updateReg(stmt, rgs);
|
||||
registryImdg.update(rgs);
|
||||
};
|
||||
Consumer<RegistryDesignation> create = (dsgn) -> {
|
||||
Registry registry = createRegistryByStatement(stmt, company, account, dsgn);
|
||||
Registry registryF = registry.clone();
|
||||
registryF.setRegistryUnit(RegistryUnit.F.getKey());
|
||||
registryF.setRegistryCode(RegistryUtil.clearingCode(registryF));
|
||||
registryF.setId(imdgProvider.getImdgIdGenerator().nextId());
|
||||
Registry registryB = registry.clone();
|
||||
registryB.setRegistryUnit(RegistryUnit.B.getKey());
|
||||
registryB.setRegistryCode(RegistryUtil.clearingCode(registryB));
|
||||
registryB.setId(imdgProvider.getImdgIdGenerator().nextId());
|
||||
Supplier<Registry> create = () -> {
|
||||
Registry registry = createRegistryByStatement(stmt, company, account);
|
||||
registryImdg.insert(registry);
|
||||
registryImdg.insert(registryF);
|
||||
registryImdg.insert(registryB);
|
||||
return registry;
|
||||
};
|
||||
|
||||
findReg(stmt, RegistryInstrumentType.M).ifPresentOrElse(update, () -> create.accept(RegistryDesignation.A));
|
||||
findReg(stmt, RegistryInstrumentType.S).ifPresentOrElse(update, () -> create.accept(RegistryDesignation.D));
|
||||
Optional<Registry> reg = findReg(stmt);
|
||||
Registry regFinal;
|
||||
if (reg.isPresent()) {
|
||||
update.accept(reg.get());
|
||||
regFinal = reg.get();
|
||||
} else {
|
||||
regFinal = create.get();
|
||||
}
|
||||
//todo
|
||||
//1. stmt.setOperationStatus в зависимости от diffBalance = 0
|
||||
//2. отправить notification на backend
|
||||
stmt.setOperationStatus(OperationStatus.Executed.getKey());
|
||||
} else {
|
||||
stmt.setErrorCodeId(err.get().getSubject().getId()); // fixme ErrorText insert
|
||||
|
|
@ -254,7 +256,7 @@ public class Sdf01Executor extends AbstractExecutor<SDf01> {
|
|||
return Optional.empty();
|
||||
}
|
||||
|
||||
private Registry createRegistryByStatement(Statement statement, Company company, Account account, RegistryDesignation designation) {
|
||||
private Registry createRegistryByStatement(Statement statement, Company company, Account account) {
|
||||
Registry rgs = new Registry();
|
||||
rgs.setCompanyId(statement.getAddresseeId());
|
||||
rgs.setTradingCode(company.getTradingCode());
|
||||
|
|
@ -264,16 +266,14 @@ public class Sdf01Executor extends AbstractExecutor<SDf01> {
|
|||
rgs.setAccountId(account.getId());
|
||||
rgs.setAccountType(account.getAccountType());
|
||||
rgs.setAccount(account.getAccount());
|
||||
rgs.setRegistryDesignation(designation.getKey());
|
||||
rgs.setRegistryDesignation(RegistryDesignation.A.getKey());
|
||||
rgs.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
||||
|
||||
ClearingAccount accountForStatement = clearingAccountImdg.getSingleObjectByID(statement.getAccountId());
|
||||
if (accountForStatement != null) {
|
||||
rgs.setRegistryCapacity(accountForStatement.getClearingAccountType());
|
||||
}
|
||||
rgs.setRegistryUnit(RegistryUnit.T.getKey());
|
||||
rgs.setRegistryCode(RegistryUtil.clearingCode(rgs));
|
||||
|
||||
Collection<TradingClearingRegistry> tcrsByAccount = tradingClearingRegistryImdg.getCollectionObjectsByFieldValues(Map.of(
|
||||
"moneyAccountId", statement.getAccountId()
|
||||
));
|
||||
|
|
@ -291,25 +291,14 @@ public class Sdf01Executor extends AbstractExecutor<SDf01> {
|
|||
rgs.setSecuritySymbol(security.getSecuritySymbol());
|
||||
}
|
||||
}
|
||||
InOutDirection inOutDirection = IEnumKey.getEnumByKey(InOutDirection.class, statement.getInOutDirection());
|
||||
//считаю balance при создании нулевым и исхожу из этого
|
||||
//При добавлении (на базе изменения statement по sDf57):
|
||||
//Если значение statement.inOutDirection=IN, то:
|
||||
//= текущее значение registry.balance + statement.amount
|
||||
//
|
||||
//Если значение statement.inOutDirection=OUT, то:
|
||||
//= текущее значение registry.balance - statement.amount
|
||||
switch (inOutDirection) {
|
||||
case in -> rgs.setBalance(statement.getAmount());
|
||||
case out -> rgs.setBalance(statement.getAmount().negate());
|
||||
}
|
||||
rgs.setCheckBalance(BigDecimalUtil.safeBD(statement.getAmount()));
|
||||
rgs.setCheckBalance(rgs.getCheckBalance().negate());
|
||||
rgs.setBalanceDimension(BalanceDimension.MONY.getKey()); //fixme ! смотри описание и ссылка на начало html'ки
|
||||
//fixme !rgs.setSettlementCode();
|
||||
rgs.setTradingDate(statement.getSettlementDate()); //fixme ! today ?
|
||||
rgs.setClearingDate(LocalDate.now());
|
||||
//fixme rgs.setRefundDate();
|
||||
//fixme rgs.setValueDate();
|
||||
rgs.setContract(statement.getContract());
|
||||
//создается на базе stmt, companyCred, accountDeb
|
||||
rgs.setCounterPartyId(statement.getAddresseeId());
|
||||
rgs.setCreated(Instant.now());
|
||||
|
|
@ -325,9 +314,9 @@ public class Sdf01Executor extends AbstractExecutor<SDf01> {
|
|||
r.setUpdated(Instant.now());
|
||||
}
|
||||
|
||||
private Optional<Registry> findReg(Statement s, RegistryInstrumentType registryInstrumentType) {
|
||||
private Optional<Registry> findReg(Statement s) {
|
||||
RegistryTradingParams p = new RegistryTradingParams(
|
||||
RegistryDesignation.A, registryInstrumentType, RegistryCapacity.A, RegistryUnit.T
|
||||
RegistryDesignation.A, RegistryInstrumentType.M, null, RegistryUnit.T
|
||||
);
|
||||
String sql = RegistryCodeSqlBuilder.getInstance(p).build();
|
||||
ImdgPredicateBuilder pb = registryImdg.predicateBuilder();
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
@Service
|
||||
public class Sdf04Executor extends AbstractExecutor<SDf04> {
|
||||
|
|
@ -54,25 +53,21 @@ public class Sdf04Executor extends AbstractExecutor<SDf04> {
|
|||
for (SDf04 sdf04 : sdf) {
|
||||
//обычно мы ищем по группу sdf04, здесь как будто всегда только одна запись, todo нужно прочекать этот момент
|
||||
log.debug("Process sdf04 record; sdf04.id: {}", sdf04.getId());
|
||||
Collection<String> fullNames = Collections.emptyList(); //fixme что значит registry.fullName=sDf04.(sbanknam1, sbanknam2 и т.д.)
|
||||
Collection<Registry> registries = selectRegistryForSDF04(sdf04.getC_acc_cred(), fullNames);
|
||||
Collection<Registry> registries = selectRegistryForSDF04(sdf04.getC_acc_cred());
|
||||
registries.forEach(registry -> unlockRegistry(registry, new BigDecimal(sdf04.getPay_val())));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected Collection<Registry> selectRegistryForSDF04(String account, Collection<String> fullNames) {
|
||||
protected Collection<Registry> selectRegistryForSDF04(String account) {
|
||||
ImdgPredicateBuilder pb = registryImdg.predicateBuilder();
|
||||
ImdgPredicate query = pb.and(
|
||||
pb.and(
|
||||
pb.equals("registryDesignation", RegistryDesignation.A.getKey()),
|
||||
pb.equals("registryInstrumentType", RegistryInstrumentType.M.getKey()),
|
||||
pb.or(pb.equals("registryUnit", RegistryUnit.F.getKey()),
|
||||
pb.equals("registryUnit", RegistryUnit.B.getKey()))
|
||||
pb.equals("registryUnit", RegistryUnit.B.getKey())
|
||||
),
|
||||
pb.equals("account", account)
|
||||
// ,
|
||||
// pb.in("fullName", fullNames.toArray(new String[fullNames.size()]))
|
||||
);
|
||||
|
||||
Collection<Registry> result = registryImdg.getCollectionObjectsByPredicate(query);
|
||||
|
|
@ -81,18 +76,8 @@ public class Sdf04Executor extends AbstractExecutor<SDf04> {
|
|||
}
|
||||
|
||||
boolean unlockRegistry(Registry registry, BigDecimal value) {
|
||||
if (RegistryUnit.F.equalsByKey(registry.getRegistryUnit())) {
|
||||
if (registry.getBalance() == null) registry.setBalance(BigDecimal.ZERO);
|
||||
registry.setBalance(registry.getBalance().add(value));
|
||||
return true;
|
||||
} else if (RegistryUnit.B.equalsByKey(registry.getRegistryUnit())) {
|
||||
if (registry.getBalance() == null) registry.setBalance(BigDecimal.ZERO);
|
||||
registry.setBalance(registry.getBalance().subtract(value));
|
||||
return true;
|
||||
} else {
|
||||
log.warn("For registry {} registryUnit={} unlock operation not implemented.",
|
||||
registry.getId(), registry.getRegistryUnit());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class Sdf13Executor extends AbstractExecutor<SDf13> {
|
||||
|
|
@ -64,8 +65,7 @@ public class Sdf13Executor extends AbstractExecutor<SDf13> {
|
|||
}
|
||||
|
||||
protected SDf12 selectSdf12bySdf13(SDf13 sDf13) {
|
||||
SDf12 sdf12 = sdf12Imdg.getSingleObjectByID(sDf13.getId());
|
||||
log.trace("Selected sdf12 by sdf13");
|
||||
SDf12 sdf12 = sdf12Imdg.getSingleObjectByFieldValues(Map.of("outDocument", sDf13.getInDocument()));
|
||||
return sdf12;
|
||||
}
|
||||
|
||||
|
|
@ -74,9 +74,8 @@ public class Sdf13Executor extends AbstractExecutor<SDf13> {
|
|||
ImdgPredicate query = pb.and(
|
||||
pb.and(
|
||||
pb.equals("registryDesignation", RegistryDesignation.A.getKey()),
|
||||
pb.equals("registryInstrumentType", RegistryInstrumentType.M.getKey()),
|
||||
pb.or(pb.equals("registryUnit", RegistryUnit.F.getKey()),
|
||||
pb.equals("registryUnit", RegistryUnit.B.getKey()))
|
||||
pb.equals("registryInstrumentType", RegistryInstrumentType.S.getKey()),
|
||||
pb.equals("registryUnit", RegistryUnit.B.getKey())
|
||||
),
|
||||
pb.equals("account", account),
|
||||
pb.equals("securityCode", securityCode)
|
||||
|
|
@ -88,18 +87,8 @@ public class Sdf13Executor extends AbstractExecutor<SDf13> {
|
|||
}
|
||||
|
||||
boolean unlockRegistry(Registry registry, BigDecimal value) {
|
||||
if (RegistryUnit.F.equalsByKey(registry.getRegistryUnit())) {
|
||||
if (registry.getBalance() == null) registry.setBalance(BigDecimal.ZERO);
|
||||
registry.setBalance(registry.getBalance().add(value));
|
||||
return true;
|
||||
} else if (RegistryUnit.B.equalsByKey(registry.getRegistryUnit())) {
|
||||
if (registry.getBalance() == null) registry.setBalance(BigDecimal.ZERO);
|
||||
registry.setBalance(registry.getBalance().subtract(value));
|
||||
return true;
|
||||
} else {
|
||||
log.warn("For registry {} registryUnit={} unlock operation not implemented.",
|
||||
registry.getId(), registry.getRegistryUnit());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -169,14 +169,20 @@ public class Sdf57Executor extends AbstractExecutor<SDf57> {
|
|||
};
|
||||
Consumer<RegistryDesignation> create = (dsgn) -> {
|
||||
Registry registry = createRegistryByStatement(stmt, company, account, dsgn);
|
||||
Registry registryF = registry.clone();
|
||||
registryF.setRegistryUnit(RegistryUnit.F.getKey());
|
||||
registryF.setRegistryCode(RegistryUtil.clearingCode(registryF));
|
||||
registryF.setId(imdgProvider.getImdgIdGenerator().nextId());
|
||||
|
||||
Registry registryB = registry.clone();
|
||||
registryB.setRegistryUnit(RegistryUnit.B.getKey());
|
||||
registryB.setRegistryCode(RegistryUtil.clearingCode(registryB));
|
||||
registryB.setId(imdgProvider.getImdgIdGenerator().nextId());
|
||||
registryB.setBalance(BigDecimal.ZERO);
|
||||
registryB.setDebit(BigDecimal.ZERO);
|
||||
|
||||
Registry registryF = registry.clone();
|
||||
registryF.setRegistryUnit(RegistryUnit.F.getKey());
|
||||
registryF.setRegistryCode(RegistryUtil.clearingCode(registryF));
|
||||
registryF.setBalance(registry.getBalance().subtract(registryB.getBalance()));
|
||||
registryF.setId(imdgProvider.getImdgIdGenerator().nextId());
|
||||
|
||||
registryImdg.insert(registry);
|
||||
registryImdg.insert(registryF);
|
||||
registryImdg.insert(registryB);
|
||||
|
|
@ -283,7 +289,10 @@ public class Sdf57Executor extends AbstractExecutor<SDf57> {
|
|||
//= текущее значение registry.balance - statement.amount
|
||||
switch (inOutDirection) {
|
||||
case in -> rgs.setBalance(statement.getAmount());
|
||||
case out -> rgs.setBalance(statement.getAmount().negate());
|
||||
case out -> {
|
||||
rgs.setBalance(statement.getAmount().negate());
|
||||
rgs.setDebit(statement.getAmount());
|
||||
}
|
||||
}
|
||||
rgs.setBalanceDimension(BalanceDimension.MONY.getKey()); //fixme ! смотри описание и ссылка на начало html'ки
|
||||
//fixme !rgs.setSettlementCode();
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
<module>cleaning-builders</module>
|
||||
<module>trade-importer</module>
|
||||
<module>lim-exporter</module>
|
||||
<module>swt-exporter</module>
|
||||
<module>gateway-api</module>
|
||||
</modules>
|
||||
|
||||
|
|
|
|||
112
clearing-parent/swt-exporter/pom.xml
Normal file
112
clearing-parent/swt-exporter/pom.xml
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>swt-exporter</artifactId>
|
||||
<name>Swt exporter</name>
|
||||
<version>SPCEX-1.0.0.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>clearing-parent</artifactId>
|
||||
<version>SPCEX-1.0.0.0</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-sftp</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>classes</artifactId>
|
||||
<version>SPCEX-1.0.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.platform</groupId>
|
||||
<artifactId>platform-messaging</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.platform</groupId>
|
||||
<artifactId>platform-imdg-api-hazelcast-impl</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.platform</groupId>
|
||||
<artifactId>platform-enum</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- TEST -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>test-clearing</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<excludes>
|
||||
<exclude>application.properties</exclude>
|
||||
</excludes>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.21.0</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.platform</groupId>
|
||||
<artifactId>junit-platform-surefire-provider</artifactId>
|
||||
<version>1.2.0-M1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>5.2.0-M1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package ru.spcex.clearing.swt.exporter;
|
||||
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SwtExportApplication {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
SpringApplicationBuilder builder = new SpringApplicationBuilder(SwtExportApplication.class);
|
||||
builder.run(args);
|
||||
} catch (Throwable e) {
|
||||
LoggerFactory.getLogger(SwtExportApplication.class).error("Swt-exporter start failed: {} -> {}", e.getClass().getSimpleName(), e.getMessage());
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package ru.spcex.clearing.swt.exporter.config;
|
||||
|
||||
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.swt.exporter.config.settings.ExportSwtServiceSettings;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
||||
|
||||
@Configuration
|
||||
public class ImdgConfig {
|
||||
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);
|
||||
}
|
||||
|
||||
@Bean("imdgProvider")
|
||||
public ImdgProvider imdgProvider(
|
||||
@Qualifier("taskExecutorHazelcastClientInitializer") ThreadPoolTaskExecutor taskExecutorHazelcastClientInitializer,
|
||||
@Qualifier("taskExecutorIdGeneratorAwaiter") ThreadPoolTaskExecutor taskExecutorIdGeneratorAwaiter,
|
||||
ExportSwtServiceSettings settings) {
|
||||
return new HazelcastService(taskExecutorHazelcastClientInitializer,
|
||||
taskExecutorIdGeneratorAwaiter,
|
||||
settings.getHazelcast());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package ru.spcex.clearing.swt.exporter.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 org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.kafka.core.ProducerFactory;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.swt.exporter.config.settings.ExportSwtServiceSettings;
|
||||
import ru.spcex.clearing.platform.messaging.config.KafkaConsumerFactory;
|
||||
import ru.spcex.clearing.platform.messaging.config.KafkaProducerFactory;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfo;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgId;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
@Configuration
|
||||
public class KafkaConfig {
|
||||
@Autowired
|
||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
@Bean
|
||||
public Consumer<String, Object> createConsumer(ExportSwtServiceSettings settings) {
|
||||
return KafkaConsumerFactory.consumer(settings.getKafkaConsumer());
|
||||
}
|
||||
|
||||
@Autowired
|
||||
@Bean
|
||||
public Producer<String, Object> createProducer(ExportSwtServiceSettings settings) {
|
||||
return KafkaProducerFactory.producer(settings.getKafkaProducer());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public KafkaTemplate<String, Object> kafkaTemplate(ProducerFactory<String, Object> pf) {
|
||||
return new KafkaTemplate<>(pf);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
@Bean
|
||||
public KafkaSender kafkaSender(KafkaTemplate<String, Object> kafkaTemplate, ImdgProvider imdgProvider) {
|
||||
ImdgId imdgIdGenerator = imdgProvider.getImdgIdGenerator();
|
||||
return KafkaSender
|
||||
.setup()
|
||||
.setKafkaTemplate(kafkaTemplate)
|
||||
.idGenerator(imdgIdGenerator::nextId)
|
||||
.imdgProvider(s -> {
|
||||
Imdg<RequestInfo> imdg = imdgProvider.getImdg(IMDGDistributedNames.Map_RequestInfo, RequestInfo.class);
|
||||
return imdg::insert;
|
||||
})
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package ru.spcex.clearing.swt.exporter.config;
|
||||
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties
|
||||
@ComponentScan(basePackages = {"ru.spcex.clearing.swt.exporter"})
|
||||
public class SwtExporterConfig {
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
package ru.spcex.clearing.swt.exporter.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("export-swt-service")
|
||||
public class ExportSwtServiceSettings {
|
||||
private HazelcastClientParams hazelcast;
|
||||
private KafkaConsumerSettings kafkaConsumer;
|
||||
private KafkaProducerSettings kafkaProducer;
|
||||
|
||||
private String docOut;
|
||||
//todo ??? private Long interval
|
||||
|
||||
|
||||
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 String getDocOut() {
|
||||
return docOut;
|
||||
}
|
||||
|
||||
public void setDocOut(String docOut) {
|
||||
this.docOut = docOut;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,156 @@
|
|||
package ru.spcex.clearing.swt.exporter.services;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.utilities.JournalEventExportedRequest;
|
||||
import ru.spcex.clearing.platform.messaging.serialization.LogFormatter;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.enumeration.ResultStatuses;
|
||||
import ru.spcex.platform.enumeration.SwtTable;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import java.io.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
import static ru.spcex.clearing.platform.messaging.domain.Consts.JOURNAL_SERVICE;
|
||||
|
||||
public abstract class AbstractExporterService<T extends SpcexObjectBase> {
|
||||
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||
protected final SwtTable type;
|
||||
protected final Imdg<T> sdfImdg;
|
||||
private final DateTimeFormatter dtFileNameFormatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
|
||||
private final DateTimeFormatter dtInFileHeaderFormatter = DateTimeFormatter.ofPattern("yyyyMMdd'/'HHmm");
|
||||
private final KafkaSender kafkaSender;
|
||||
protected final FileStorage fileStorage;
|
||||
|
||||
protected AbstractExporterService(FileStorage fileStorage,
|
||||
KafkaSender kafkaSender, ImdgProvider imdgProvider,
|
||||
SwtTable type,
|
||||
String mapName, Class<T> mapClass) {
|
||||
this.fileStorage = fileStorage;
|
||||
this.kafkaSender = kafkaSender;
|
||||
this.type = type;
|
||||
Objects.requireNonNull(type, "SWT table type not set");
|
||||
this.sdfImdg = imdgProvider.getImdg(mapName, mapClass);
|
||||
}
|
||||
|
||||
public SwtTable getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
protected abstract String typeForFileName();
|
||||
|
||||
protected abstract String sectionForFileName();
|
||||
|
||||
protected abstract String typeForHeader();
|
||||
|
||||
public void process() {
|
||||
LocalDateTime exportAt = LocalDateTime.now();
|
||||
|
||||
String fileName = formatFileName(typeForFileName(), sectionForFileName(), exportAt);
|
||||
log.debug("Start export {} Lim file", fileName);
|
||||
|
||||
try {
|
||||
byte[] data;
|
||||
{
|
||||
ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();
|
||||
Collection<T> records = selectItems();
|
||||
log.debug("Prepared {} record from {} to file {}",
|
||||
records.size(), sdfImdg.getMapName(), fileName);
|
||||
makeSWTData(typeForHeader(), exportAt, records, outBuffer);
|
||||
data = outBuffer.toByteArray();
|
||||
}
|
||||
fileStorage.saveFile(fileName, data);
|
||||
} catch (Exception e) { // IOException, ...
|
||||
log.error("Failed export {} file", fileName);
|
||||
sendSwtExportedNotification(exportAt, null, ResultStatuses.notSuccess);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
log.debug("Successfully exported {} file", fileName);
|
||||
|
||||
sendSwtExportedNotification(exportAt, null, ResultStatuses.success);
|
||||
}
|
||||
|
||||
protected abstract String getDocumentNameForJournal();
|
||||
|
||||
void sendSwtExportedNotification(LocalDateTime registrationAt, Long registrationNumber, ResultStatuses resultStatus) {
|
||||
JournalEventExportedRequest exportedRequest = new JournalEventExportedRequest();
|
||||
exportedRequest.setRegistratoinDate(registrationAt.toLocalDate());
|
||||
exportedRequest.setRegistrationTime(registrationAt.toLocalTime());
|
||||
exportedRequest.setRegistrationNumber(registrationNumber);
|
||||
exportedRequest.setDocumentName(getDocumentNameForJournal());
|
||||
exportedRequest.setResultStatus(resultStatus.getKey());
|
||||
log.debug("Send message to kafka \"{}\": {}", JOURNAL_SERVICE, LogFormatter.toStringWrapper(exportedRequest));
|
||||
kafkaSender.sendRequestToQueue(JOURNAL_SERVICE, exportedRequest);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param type DF-09
|
||||
* @param section bond/fund/""
|
||||
* @param atTime LocalDateTime.now(), если null - текущее время
|
||||
* @return пример "KS_RDC_DF-12_bond_220907151804503.txt"
|
||||
*/
|
||||
protected String formatFileName(String type, String section, LocalDateTime atTime) {
|
||||
Objects.requireNonNull(type);
|
||||
if (section == null) section = "";
|
||||
if (section.length() > 0) section += "_";
|
||||
if (atTime == null) atTime = LocalDateTime.now();
|
||||
String dt = dtFileNameFormatter.format(atTime);
|
||||
return String.format("KS_RDC_%s_%s%s.txt", type, section, dt);
|
||||
}
|
||||
|
||||
// Выборка
|
||||
protected Collection<T> selectItems() {
|
||||
return sdfImdg.getAllValues();
|
||||
}
|
||||
|
||||
// Конвертация (поля см. meta.xml)
|
||||
protected abstract LinkedHashMap<String, Object> convertRecord(T record);
|
||||
|
||||
// protected abstract String[] swtHeader();
|
||||
|
||||
protected void makeSWTData(String type, LocalDateTime time, Collection<T> records, OutputStream outStream) {
|
||||
PrintWriter out = new PrintWriter(outStream);
|
||||
// todo SWT txt не понял формат. Надо уточнить формат файла. Должен соответствовать мете.
|
||||
out.println("To:CSO");
|
||||
out.println("From:SPCE");
|
||||
if (type != null)
|
||||
out.println("Type:" + type);// Type:009
|
||||
if (time != null) {
|
||||
String timeS = dtInFileHeaderFormatter.format(time);
|
||||
out.println("Date/Time:" + timeS);// Date/Time:20230227/0932
|
||||
}
|
||||
/*
|
||||
To:CSO
|
||||
From:SPCE
|
||||
Type:009
|
||||
Date/Time:20230227/0932
|
||||
:20:0ef63e17-83ac-4e22-a76b-fd8a4df10de3
|
||||
:21:SDC230227084839
|
||||
:18A:46
|
||||
*/
|
||||
StringBuilder line = new StringBuilder();
|
||||
for (T row : records) {
|
||||
LinkedHashMap<String, Object> rowData = convertRecord(row);
|
||||
line.setLength(0);
|
||||
for (Map.Entry<String, Object> r : rowData.entrySet()) {
|
||||
String value = convertItem(r.getValue());
|
||||
line.append(value).append(':');
|
||||
}
|
||||
if (line.length() > 0) // remove :
|
||||
line.setLength(line.length() - 1);
|
||||
out.println(line);
|
||||
}
|
||||
//out.println("2"); // todo что значит 2?
|
||||
}
|
||||
|
||||
protected String convertItem(Object o) {
|
||||
//todo date/time/etc.
|
||||
return String.valueOf(o);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package ru.spcex.clearing.swt.exporter.services;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.spcex.clearing.swt.exporter.config.settings.ExportSwtServiceSettings;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@Service
|
||||
public class FileStorage {
|
||||
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||
protected File outPath;
|
||||
|
||||
@Autowired
|
||||
public FileStorage(ExportSwtServiceSettings config) {
|
||||
if (config.getDocOut() == null || config.getDocOut().isBlank()) {
|
||||
throw new IllegalArgumentException("Out directory settings is empty.");
|
||||
}
|
||||
this.outPath = new File(config.getDocOut());
|
||||
if (!outPath.isDirectory()) {
|
||||
log.info("Path not exist. mkdir \"{}\"", outPath.getAbsolutePath());
|
||||
if (!outPath.mkdir()) {
|
||||
log.error("Can not make output directory \"{}\"", outPath);
|
||||
}
|
||||
}
|
||||
log.info("Output directory \"{}\"", outPath);
|
||||
}
|
||||
|
||||
public void saveFile(String fileName, byte[] data) throws IOException {
|
||||
File toFile = new File(outPath, fileName);
|
||||
FileUtils.writeByteArrayToFile(toFile, data);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
package ru.spcex.clearing.swt.exporter.services;
|
||||
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.importexport.SwtExporterRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.schedule.LauncherCommandRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.platform.utils.log.ExceptionUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class LauncherCommandReceiver extends QueueConsumer implements InitializingBean {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
protected final List<AbstractExporterService> exporterServices;
|
||||
|
||||
public LauncherCommandReceiver(Consumer<String, Object> kafkaQueue,
|
||||
List<AbstractExporterService> exporterServices
|
||||
) {
|
||||
super(kafkaQueue);
|
||||
this.exporterServices = exporterServices;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
// callback(LauncherCommandRequest.class)
|
||||
// .setConsumer(this::exportAll)
|
||||
// .forDestination(Task.unloadingSession_LIMM.topic(), callbacks::put); // todo task name?
|
||||
callback(SwtExporterRequest.class)
|
||||
.setConsumer(this::exportSpecial)
|
||||
.forDestination(Consts.SWT_EXPORTER, callbacks::put);
|
||||
init();
|
||||
}
|
||||
|
||||
protected void exportAll(BaseRequest<LauncherCommandRequest> request) {
|
||||
log.info("LauncherCommandRequest request received: {}", request);
|
||||
for (AbstractExporterService exporter : exporterServices) {
|
||||
log.debug("Export {}", exporter);
|
||||
try {
|
||||
exporter.process();
|
||||
} catch (Exception e) {
|
||||
log.error("One of exporter has error: {}", ExceptionUtils.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
log.info("All SWT export has finished.");
|
||||
}
|
||||
|
||||
protected void exportSpecial(BaseRequest<SwtExporterRequest> request) {
|
||||
log.info("SwtExporterRequest request received: {}", request);
|
||||
SwtExporterRequest req = request.getRequestPayload();
|
||||
for (AbstractExporterService exporter : exporterServices) {
|
||||
if (exporter.getType()==req.getType()) {
|
||||
log.debug("Export {}", exporter);
|
||||
try {
|
||||
exporter.process();
|
||||
} catch (Exception e) {
|
||||
log.error("Exporter has error: {}", ExceptionUtils.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
log.error("SWT export not execute for type \"{}\" - unknown command", req.getType());
|
||||
//todo return error?
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package ru.spcex.clearing.swt.exporter.services.exportimpl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.sdf.SDf09;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.clearing.swt.exporter.services.AbstractExporterService;
|
||||
import ru.spcex.clearing.swt.exporter.services.FileStorage;
|
||||
import ru.spcex.platform.enumeration.SwtTable;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
@Service
|
||||
public class DF09Exporter extends AbstractExporterService<SDf09> {
|
||||
|
||||
public DF09Exporter(FileStorage fileStorage,
|
||||
KafkaSender kafkaSender,
|
||||
ImdgProvider imdgProvider) {
|
||||
super(fileStorage, kafkaSender, imdgProvider,
|
||||
SwtTable.SDF_09,
|
||||
IMDGDistributedNames.Map_SDf09, SDf09.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String typeForFileName() {
|
||||
return "DF-09";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String sectionForFileName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String typeForHeader() {
|
||||
return "009";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDocumentNameForJournal() {
|
||||
return "Уведомление об исполнении операции загрузки ценных бумаг или уведомление об ошибке";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LinkedHashMap<String, Object> convertRecord(SDf09 record) {
|
||||
LinkedHashMap<String, Object> row = new LinkedHashMap<>();
|
||||
row.put("id", record.getId());
|
||||
|
||||
row.put("outDocument", record.getOutDocument());
|
||||
row.put("inDocument", record.getInDocument());
|
||||
row.put("depoCode", record.getDepoCode());
|
||||
row.put("quantity", record.getQuantity());
|
||||
row.put("securityCode", record.getSecurityCode());
|
||||
row.put("clientName", record.getClientName());
|
||||
row.put("result", record.getResult());
|
||||
row.put("generationTime", record.getGenerationTime());
|
||||
row.put("generationId", record.getGenerationId());
|
||||
return row;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
package ru.spcex.clearing.swt.exporter.services.exportimpl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.sdf.SDf11;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.clearing.swt.exporter.services.AbstractExporterService;
|
||||
import ru.spcex.clearing.swt.exporter.services.FileStorage;
|
||||
import ru.spcex.platform.enumeration.SwtTable;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
|
||||
@Service
|
||||
public class DF11Exporter extends AbstractExporterService<SDf11> {
|
||||
|
||||
public DF11Exporter(FileStorage fileStorage,
|
||||
KafkaSender kafkaSender,
|
||||
ImdgProvider imdgProvider) {
|
||||
super(fileStorage, kafkaSender, imdgProvider,
|
||||
SwtTable.SDF_11,
|
||||
IMDGDistributedNames.Map_SDf11, SDf11.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String typeForFileName() {
|
||||
return "DF-11";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String sectionForFileName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String typeForHeader() {
|
||||
return "011";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDocumentNameForJournal() {
|
||||
return "Ответ на Запрос на Зачисление или списание ценных бумаг";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LinkedHashMap<String, Object> convertRecord(SDf11 record) {
|
||||
LinkedHashMap<String, Object> row = new LinkedHashMap<>();
|
||||
row.put("id", record.getId());
|
||||
|
||||
row.put("outDocument", record.getOutDocument());
|
||||
row.put("inDocument", record.getInDocument());
|
||||
row.put("depoCode", record.getDepoCode());
|
||||
row.put("quantity", record.getQuantity());
|
||||
row.put("securityCode", record.getSecurityCode());
|
||||
row.put("clientName", record.getClientName());
|
||||
row.put("result", record.getResult());
|
||||
row.put("generationTime", record.getGenerationTime());
|
||||
row.put("generationId", record.getGenerationId());
|
||||
return row;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
package ru.spcex.clearing.swt.exporter.services.exportimpl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.sdf.SDf12;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.clearing.swt.exporter.services.AbstractExporterService;
|
||||
import ru.spcex.clearing.swt.exporter.services.FileStorage;
|
||||
import ru.spcex.platform.enumeration.SwtTable;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
|
||||
@Service
|
||||
public class DF12Exporter extends AbstractExporterService<SDf12> {
|
||||
|
||||
public DF12Exporter(FileStorage fileStorage,
|
||||
KafkaSender kafkaSender,
|
||||
ImdgProvider imdgProvider) {
|
||||
super(fileStorage, kafkaSender, imdgProvider,
|
||||
SwtTable.SDF_12,
|
||||
IMDGDistributedNames.Map_SDf12, SDf12.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String typeForFileName() {
|
||||
return "DF-12";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String sectionForFileName() {
|
||||
return "bond"; // todo bond / fund
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String typeForHeader() {
|
||||
return "012";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDocumentNameForJournal() {
|
||||
//todo Выбор:
|
||||
// Распоряжение на проведение операций по итогам клиринга (Фондовая секция)
|
||||
//или
|
||||
// Распоряжение на проведение операций по итогам клиринга (ОФЗ, ОБР)
|
||||
return "Распоряжение на проведение операций по итогам клиринга (Фондовая секция / ОФЗ, ОБР)";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LinkedHashMap<String, Object> convertRecord(SDf12 record) {
|
||||
LinkedHashMap<String, Object> row = new LinkedHashMap<>();
|
||||
row.put("id", record.getId());
|
||||
|
||||
row.put("outDocument", record.getOutDocument());
|
||||
row.put("quantity", record.getQuantity());
|
||||
row.put("securityCode", record.getSecurityCode());
|
||||
row.put("depoCodeSender", record.getDepoCodeSender());
|
||||
row.put("depoCodeAdressee", record.getDepoCodeAdressee());
|
||||
row.put("result", record.getResult());
|
||||
row.put("generationTime", record.getGenerationTime());
|
||||
row.put("generationId", record.getGenerationId());
|
||||
return row;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package ru.spcex.clearing.swt.exporter.services.exportimpl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.sdf.SDf14;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.clearing.swt.exporter.services.AbstractExporterService;
|
||||
import ru.spcex.clearing.swt.exporter.services.FileStorage;
|
||||
import ru.spcex.platform.enumeration.SwtTable;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
|
||||
@Service
|
||||
public class DF14Exporter extends AbstractExporterService<SDf14> {
|
||||
|
||||
public DF14Exporter(FileStorage fileStorage,
|
||||
KafkaSender kafkaSender,
|
||||
ImdgProvider imdgProvider) {
|
||||
super(fileStorage, kafkaSender, imdgProvider,
|
||||
SwtTable.SDF_14,
|
||||
IMDGDistributedNames.Map_SDf14, SDf14.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String typeForFileName() {
|
||||
return "DF-14";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String sectionForFileName() {
|
||||
return "bond"; // todo bond / fund
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String typeForHeader() {
|
||||
return "014";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDocumentNameForJournal() {
|
||||
//todo Выбор:
|
||||
// Уведомление о завершении расчетов (ОФЗ, ОБР)
|
||||
//или
|
||||
// Уведомление о завершении расчетов (ОФЗ, ОБР)
|
||||
return "Уведомление о завершении расчетов (ОФЗ, ОБР)";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LinkedHashMap<String, Object> convertRecord(SDf14 record) {
|
||||
LinkedHashMap<String, Object> row = new LinkedHashMap<>();
|
||||
row.put("id", record.getId());
|
||||
|
||||
row.put("outDocument", record.getOutDocument());
|
||||
row.put("result", record.getResult());
|
||||
row.put("generationTime", record.getGenerationTime());
|
||||
row.put("generationId", record.getGenerationId());
|
||||
return row;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
spring.main.web-application-type=none
|
||||
|
||||
export-swt-service.hazelcast.cluster-members=10.200.200.181:5701
|
||||
export-swt-service.hazelcast.login=dev
|
||||
export-swt-service.hazelcast.password=dev-pass
|
||||
|
||||
export-swt-service.common.encoding=cp866
|
||||
export-swt-service.common.threads-count=10
|
||||
|
||||
export-swt-service.docOut=/opt/spcex/clearing/files/swt/SettlementHouse_DocOut
|
||||
|
||||
export-swt-service.kafka-consumer.bootstrap-servers=localhost:9092
|
||||
export-swt-service.kafka-consumer.group-id=dev-group-balance-service
|
||||
export-swt-service.kafka-consumer.enable-auto-commit=false
|
||||
export-swt-service.kafka-consumer.session-timeout-ms=30000
|
||||
export-swt-service.kafka-consumer.auto-offset-reset=latest
|
||||
export-swt-service.kafka-consumer.linger-ms=1
|
||||
export-swt-service.kafka-consumer.buffer-memory=33554432
|
||||
|
||||
export-swt-service.kafka-producer.bootstrap-servers=localhost:9092
|
||||
export-swt-service.kafka-producer.acks=all
|
||||
export-swt-service.kafka-producer.retries=0
|
||||
export-swt-service.kafka-producer.batch-size=16384
|
||||
export-swt-service.kafka-producer.linger-ms=1
|
||||
export-swt-service.kafka-producer.buffer-memory=33554432
|
||||
37
clearing-parent/swt-exporter/src/main/resources/logback.xml
Normal file
37
clearing-parent/swt-exporter/src/main/resources/logback.xml
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<configuration>
|
||||
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<charset>UTF-8</charset>
|
||||
<pattern>%date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>./logs/swt-exporter.log</file>
|
||||
<encoder>
|
||||
<charset>UTF-8</charset>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
</encoder>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
|
||||
<fileNamePattern>
|
||||
../logs/swt-exporter.%i.log
|
||||
</fileNamePattern>
|
||||
<minIndex>1</minIndex>
|
||||
<maxIndex>10</maxIndex>
|
||||
</rollingPolicy>
|
||||
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
|
||||
<maxFileSize>500MB</maxFileSize>
|
||||
</triggeringPolicy>
|
||||
</appender>
|
||||
|
||||
<root level="warn">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="FILE"/>
|
||||
</root>
|
||||
|
||||
<logger name="ru.spcex" level="debug" additivity="false">
|
||||
<appender-ref ref="FILE"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
</configuration>
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
package ru.spcex.clearing.swt.exporter;
|
||||
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import ru.clearing.classes.statics.data.registry.Registry;
|
||||
import ru.clearing.classes.statics.data.registry.TradingClearingRegistry;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.clearing.test.config.ImdgTestConfig;
|
||||
import ru.spcex.clearing.test.config.KafkaTestConfig;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import static ru.spcex.clearing.test.config.ImdgTestConfig.currentID;
|
||||
import static ru.spcex.clearing.test.config.ImdgTestConfig.waitAvailableImdgProviderAndAddAdminWithDefaultId;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {
|
||||
ImdgTestConfig.class,
|
||||
KafkaTestConfig.class})
|
||||
public abstract class AbstractServiceTest {
|
||||
protected static final long id = currentID.getAndIncrement();
|
||||
protected Imdg<Registry> registryImdg;
|
||||
protected Imdg<TradingClearingRegistry> tradingClearingRegistryImdg;
|
||||
protected LocalDate currentDate = LocalDate.now();
|
||||
protected String tcrA = "1324A234";
|
||||
protected String tcrD = "124324A234";
|
||||
protected Long securityIdFirst = 12L;
|
||||
protected Long securityIdSecond = 23L;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("mockProducer")
|
||||
protected Producer<String, Object> mockProducer;
|
||||
|
||||
@Autowired
|
||||
protected KafkaSender kafkaSender;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("hazelcastServiceTest")
|
||||
protected ImdgProvider imdgProvider;
|
||||
|
||||
protected void init() {
|
||||
waitAvailableImdgProviderAndAddAdminWithDefaultId();
|
||||
this.registryImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Registry, Registry.class);
|
||||
this.tradingClearingRegistryImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_TradingClearingRegistry, TradingClearingRegistry.class);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package ru.spcex.clearing.swt.exporter.services;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import ru.spcex.clearing.swt.exporter.AbstractServiceTest;
|
||||
import ru.spcex.clearing.swt.exporter.services.exportimpl.DF09Exporter;
|
||||
import ru.spcex.platform.enumeration.ResultStatuses;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
class AbstractExporterServiceTest extends AbstractServiceTest {
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
super.init();
|
||||
}
|
||||
|
||||
@Test
|
||||
void sendSwtExportedNotification() {
|
||||
AbstractExporterService moneyExporterService = new DF09Exporter(null, kafkaSender, imdgProvider);
|
||||
|
||||
String fileName = "KS_RDC_DF-14_bond_221005134616035.txt";
|
||||
moneyExporterService.sendSwtExportedNotification(LocalDateTime.now(), 1L, ResultStatuses.notSuccess);
|
||||
//TestUtils.waitingSendAndCheckRecord(null, mockProducer);
|
||||
}
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
|||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
import ru.clearing.classes.statics.data.misc.Market;
|
||||
import ru.clearing.classes.statics.data.misc.STrades;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.utilities.STradesImportedRequest;
|
||||
|
|
@ -16,6 +17,7 @@ import ru.spcex.platform.imdg.api.Imdg;
|
|||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.platform.utils.log.ExceptionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Date;
|
||||
|
|
@ -26,6 +28,7 @@ import java.time.Instant;
|
|||
import java.time.LocalDate;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static ru.spcex.clearing.platform.messaging.domain.Consts.S_TRADES_IMPORTED;
|
||||
|
|
@ -36,6 +39,7 @@ import static ru.spcex.clearing.trade.importer.error.TradeImporterError.sTradesN
|
|||
public class TradeImporterService {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final Imdg<STrades> sTradesImdg;
|
||||
private final Imdg<Market> marketImdg;
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
private final Supplier<KafkaSender> kafka;
|
||||
private final IMessageResolver messageResolver;
|
||||
|
|
@ -47,6 +51,7 @@ public class TradeImporterService {
|
|||
public TradeImporterService(ImdgProvider imdgProvider, JdbcTemplate jdbcTemplate, Supplier<KafkaSender> kafka, IMessageResolver messageResolver) {
|
||||
imdgProvider.waitAvailable();
|
||||
this.sTradesImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_STrades, STrades.class);
|
||||
this.marketImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Market, Market.class);
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
this.kafka = kafka;
|
||||
this.messageResolver = messageResolver;
|
||||
|
|
@ -66,7 +71,7 @@ public class TradeImporterService {
|
|||
int created = 0;
|
||||
int updated = 0;
|
||||
for (STrades tradesDb : tradesFromDB) {
|
||||
if (isValidTrades(tradesDb)) {
|
||||
if (isValidTrades(tradesDb) && fillNessessaryFields(tradesDb)) {
|
||||
STrades sTrades = getSTradesFromImdg(tradesDb, sTradesImdg);
|
||||
if (sTrades != null) {
|
||||
// Обновление всех полей объекта из БД
|
||||
|
|
@ -97,6 +102,25 @@ public class TradeImporterService {
|
|||
kafka.get().sendRequestToQueue(S_TRADES_IMPORTED, sTradesImportedRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns OK - everything is kk
|
||||
*/
|
||||
private boolean fillNessessaryFields(STrades tradesDb) {
|
||||
Consumer<String> logErr = (st) -> log.error("strades {} {} {}", tradesDb.getTradeDate(), tradesDb.getTradeNum(), st);
|
||||
try {
|
||||
Market market = marketImdg.getSingleObjectBySQL("code = '%s'".formatted(tradesDb.getClassCode()));
|
||||
if (market == null) {
|
||||
logErr.accept("couldn't find market.section for classCode " + tradesDb.getClassCode());
|
||||
return false;
|
||||
}
|
||||
tradesDb.setSection(market.getSection());
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
logErr.accept(ExceptionUtils.getStackTrace(e));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public STrades getSTradesFromImdg(STrades tradesDb, Imdg<STrades> sTradesImdg) {
|
||||
return sTradesImdg.getSingleObjectByFieldValues(Map.of("tradeDate", tradesDb.getTradeDate(),
|
||||
"tradeNum", tradesDb.getTradeNum(),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
package ru.spcex.platform.enumeration;
|
||||
|
||||
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||
|
||||
public enum SwtTable implements IEnumKey {
|
||||
SDF_09("SDF_09"), SDF_11("SDF_11"),
|
||||
SDF_12("SDF_12"), SDF_14("SDF_14");
|
||||
|
||||
SwtTable(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
private final String key;
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsByKey(String key) {
|
||||
return IEnumKey.super.equalsByKey(key);
|
||||
}
|
||||
}
|
||||
|
|
@ -123,11 +123,13 @@ public interface Consts {
|
|||
String SDF56_PROCESS = "sdf56-process";
|
||||
String CONTINUE_SESSION_BN_FIRST_PART = "sdf57-process";
|
||||
String CONTINUE_SESSION_BN_SECOND_PART = "sdf13-process";
|
||||
String SWT_EXPORTER = "swt-exporter";
|
||||
String REVISE_PROCESS = "revise-process";
|
||||
String EXPORT_PROCESS = "export-process";
|
||||
String EXPORT_COMPLETED = "export_completed";
|
||||
String S_TRADES_IMPORTED = "s_trades-imported";
|
||||
String LIM_EXPORTED = "lim_exported";
|
||||
String JOURNAL_SERVICE = "journal-service-exported";
|
||||
String ACCOUNT_TERMINATION = "account-termination";
|
||||
String BALANCE_ACCOUNT_NEW = "balance-account-new";
|
||||
String BALANCE_ACCOUNT_UPDATE = "balance-account-update";
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
package ru.spcex.clearing.platform.messaging.domain.cud.importexport;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import ru.spcex.platform.enumeration.SwtTable;
|
||||
|
||||
public class SwtExporterRequest {
|
||||
@JsonProperty
|
||||
public SwtTable type;
|
||||
|
||||
public SwtTable getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(SwtTable type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
package ru.spcex.clearing.platform.messaging.domain.cud.utilities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import ru.spcex.clearing.platform.messaging.domain.json.deserialize.LocalDateDeserializer;
|
||||
import ru.spcex.clearing.platform.messaging.domain.json.deserialize.LocalTimeDeserializer;
|
||||
import ru.spcex.clearing.platform.messaging.domain.json.serialize.LocalDateSerializer;
|
||||
import ru.spcex.clearing.platform.messaging.domain.json.serialize.LocalTimeSerializer;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
|
||||
public class JournalEventExportedRequest {
|
||||
@JsonSerialize(using = LocalDateSerializer.class)
|
||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||
@JsonProperty
|
||||
private LocalDate registratoinDate;
|
||||
@JsonSerialize(using = LocalTimeSerializer.class)
|
||||
@JsonDeserialize(using = LocalTimeDeserializer.class)
|
||||
@JsonProperty
|
||||
private LocalTime registrationTime;
|
||||
@JsonProperty
|
||||
private Long registrationNumber;
|
||||
@JsonProperty
|
||||
private String documentName;
|
||||
@JsonProperty
|
||||
private String dossierNumber;
|
||||
/**
|
||||
* ACK при успешной загрузке
|
||||
* NACK при ошибке загрузки
|
||||
*/
|
||||
@JsonProperty
|
||||
private String resultStatus;
|
||||
|
||||
public LocalDate getRegistratoinDate() {
|
||||
return registratoinDate;
|
||||
}
|
||||
|
||||
public void setRegistratoinDate(LocalDate registratoinDate) {
|
||||
this.registratoinDate = registratoinDate;
|
||||
}
|
||||
|
||||
public LocalTime getRegistrationTime() {
|
||||
return registrationTime;
|
||||
}
|
||||
|
||||
public void setRegistrationTime(LocalTime registrationTime) {
|
||||
this.registrationTime = registrationTime;
|
||||
}
|
||||
|
||||
public Long getRegistrationNumber() {
|
||||
return registrationNumber;
|
||||
}
|
||||
|
||||
public void setRegistrationNumber(Long registrationNumber) {
|
||||
this.registrationNumber = registrationNumber;
|
||||
}
|
||||
|
||||
public String getDocumentName() {
|
||||
return documentName;
|
||||
}
|
||||
|
||||
public void setDocumentName(String documentName) {
|
||||
this.documentName = documentName;
|
||||
}
|
||||
|
||||
public String getDossierNumber() {
|
||||
return dossierNumber;
|
||||
}
|
||||
|
||||
public void setDossierNumber(String dossierNumber) {
|
||||
this.dossierNumber = dossierNumber;
|
||||
}
|
||||
|
||||
public String getResultStatus() {
|
||||
return resultStatus;
|
||||
}
|
||||
|
||||
public void setResultStatus(String resultStatus) {
|
||||
this.resultStatus = resultStatus;
|
||||
}
|
||||
}
|
||||
2
pom.xml
2
pom.xml
|
|
@ -37,6 +37,8 @@
|
|||
<folder_root_clearing_imdg>${folder_root_clearing}/clearing-parent/imdg</folder_root_clearing_imdg>
|
||||
<folder_root_dbf-exporter>${folder_root_clearing}/clearing-parent/dbf-exporter</folder_root_dbf-exporter>
|
||||
<folder_root_dbf-importer>${folder_root_clearing}/clearing-parent/dbf-importer</folder_root_dbf-importer>
|
||||
<folder_root_lim-exporter>${folder_root_clearing}/clearing-parent/lim-exporter</folder_root_lim-exporter>
|
||||
<folder_root_swt-exporter>${folder_root_clearing}/clearing-parent/swt-exporter</folder_root_swt-exporter>
|
||||
<folder_root_trade-importer>${folder_root_clearing}/clearing-parent/trade-importer</folder_root_trade-importer>
|
||||
<folder_root_account-service>${folder_root_clearing}/clearing-parent/account-service</folder_root_account-service>
|
||||
<folder_root_balance-service>${folder_root_clearing}/clearing-parent/balance-service</folder_root_balance-service>
|
||||
|
|
|
|||
|
|
@ -191,6 +191,45 @@
|
|||
</fileSets>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>copy-lim-exporter-bin</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<sourceFile>${folder_root_lim-exporter}/target/lim-exporter.jar</sourceFile>
|
||||
<destinationFile>${folder.clearing.distr.modules}/lim-exporter/lim-exporter.jar</destinationFile>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
<sourceFile>${folder_root_lim-exporter}/src/main/resources/application.properties</sourceFile>
|
||||
<destinationFile>${folder.clearing.distr.modules}/lim-exporter/application.properties</destinationFile>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>copy-swt-exporter-bin</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<sourceFile>${folder_root_swt-exporter}/target/swt-exporter.jar</sourceFile>
|
||||
<destinationFile>${folder.clearing.distr.modules}/swt-exporter/swt-exporter.jar</destinationFile>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
<sourceFile>${folder_root_swt-exporter}/src/main/resources/application.properties</sourceFile>
|
||||
<destinationFile>${folder.clearing.distr.modules}/swt-exporter/application.properties</destinationFile>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>copy-trade-importer-bin</id>
|
||||
<phase>prepare-package</phase>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ kill -9 $(ps -ef | grep java | grep company-service.jar | awk '{print $2}')
|
|||
kill -9 $(ps -ef | grep java | grep clearing-service.jar | awk '{print $2}')
|
||||
kill -9 $(ps -ef | grep java | grep dbf-exporter.jar | awk '{print $2}')
|
||||
kill -9 $(ps -ef | grep java | grep lim-exporter.jar | awk '{print $2}')
|
||||
kill -9 $(ps -ef | grep java | grep swt-exporter.jar | awk '{print $2}')
|
||||
kill -9 $(ps -ef | grep java | grep dbf-importer.jar | awk '{print $2}')
|
||||
kill -9 $(ps -ef | grep java | grep trade-importer.jar | awk '{print $2}')
|
||||
kill -9 $(ps -ef | grep java | grep imdg.jar | awk '{print $2}')
|
||||
|
|
|
|||
9
z-distr/src/main/resources/distr/bin/swt-exporter.sh
Normal file
9
z-distr/src/main/resources/distr/bin/swt-exporter.sh
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
CLEARING_HOME=/opt/mfd/clearing/
|
||||
cd $CLEARING_HOME/bin
|
||||
|
||||
CMD="java -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=7120 -jar swt-exporter.jar --spring.config.location=$CLEARING_HOME/settings/swt-exporter/"
|
||||
|
||||
$CMD >/dev/null 2>&1 &
|
||||
|
||||
Loading…
Add table
Reference in a new issue