Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
5a0842249b
4 changed files with 68 additions and 25 deletions
|
|
@ -18,6 +18,7 @@ preflight:
|
|||
script:
|
||||
- pwd
|
||||
- git clone "http://gitlab-ci-token:$ACCESS_TOKEN@git.mfd.msk/mfd/clearing_test.git"
|
||||
- find /builds/mfd/clearing/clearing_test -name ".gitkeep" -type f -delete
|
||||
artifacts:
|
||||
name: "$CI_COMMIT_REF_NAME"
|
||||
expire_in: 1 day
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package ru.spcex.clearing.service.execution;
|
||||
|
||||
import static java.lang.String.format;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.Instant;
|
||||
|
|
@ -13,6 +14,7 @@ import java.util.Optional;
|
|||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.event.Level;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
|
@ -31,6 +33,7 @@ import ru.clearing.classes.statics.data.security.Security;
|
|||
import ru.spcex.clearing.error.ClearingError;
|
||||
import ru.spcex.clearing.error.ClearingException;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.notification.NotificationSender;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.registry.DealRegisterNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.registry.ExecutionType;
|
||||
|
|
@ -39,6 +42,8 @@ import ru.spcex.clearing.service.validation.ValidationStored;
|
|||
import ru.spcex.clearing.service.validation.strades.CompanyByTradingCodeCashingValidationRule;
|
||||
import ru.spcex.clearing.service.validation.strades.STradesSecurityPresentValidationRule;
|
||||
import ru.spcex.clearing.service.validation.strades.TcrByCodeAndCmpIsActiveCashingValidationRule;
|
||||
import ru.spcex.platform.enumeration.ObjectType;
|
||||
import ru.spcex.platform.enumeration.Priority;
|
||||
import ru.spcex.platform.enumeration.Section;
|
||||
import ru.spcex.platform.enumeration.Side;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
|
|
@ -88,13 +93,14 @@ public class ExecutionCurrencyComponent implements IExecutionUploadComponent {
|
|||
private final KafkaSender kafkaSender;
|
||||
private static final DateTimeFormatter contractFormatter = DateTimeFormatter.ofPattern("ddMMyy");
|
||||
private final Map<ExecUploadKey, ExecUploadCashInfo> cash = new HashMap<>();
|
||||
|
||||
private final NotificationSender notifications;
|
||||
|
||||
|
||||
@Autowired
|
||||
public ExecutionCurrencyComponent(ImdgProvider imdgProvider, Producer<String, Object> kafka,
|
||||
@Qualifier("kafkaSenderWithoutRequestInfo") KafkaSender kafkaSender,
|
||||
IMessageResolver msgResolver) {
|
||||
IMessageResolver msgResolver,
|
||||
NotificationSender notifications) {
|
||||
this.sTradeImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_STrades, STrades.class);
|
||||
this.executionCurrencyImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_ExecutionCurrency, ExecutionCurrency.class);
|
||||
this.listingImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Listing, Listing.class);
|
||||
|
|
@ -110,6 +116,7 @@ public class ExecutionCurrencyComponent implements IExecutionUploadComponent {
|
|||
|
||||
// resetTradingDay();
|
||||
this.idGen = imdgProvider.getImdgIdGenerator();
|
||||
this.notifications = notifications;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -170,7 +177,10 @@ public class ExecutionCurrencyComponent implements IExecutionUploadComponent {
|
|||
sTrades.removeIf(sTrd -> {
|
||||
Side sTrdSide = IEnumKey.getEnumByKey(Side.class, sTrd.getOperation());
|
||||
if (sTrdSide == null || !(sTrdSide.equals(Side.BUY) || sTrdSide.equals(Side.SELL))) {
|
||||
log.warn("cannot parse strade.tradeNum={} strade.operation {}", sTrd.getTradeNum(), sTrd.getOperation());
|
||||
log.warn(format(
|
||||
"cannot parse strade.tradeNum=%d strade.operation %s",
|
||||
sTrd.getTradeNum(),
|
||||
sTrd.getOperation()));
|
||||
return true;
|
||||
}
|
||||
// MoneyFlowSide excDepSide = sTrdSide == Side.BUY ? MoneyFlowSide.BUY : MoneyFlowSide.SELL;
|
||||
|
|
@ -191,7 +201,8 @@ public class ExecutionCurrencyComponent implements IExecutionUploadComponent {
|
|||
IValidator validator = valFor(sTrd);
|
||||
Optional<EnumMessage> error = validator.tillFirstError();
|
||||
if (error.isPresent()) {
|
||||
logError(sTrd.getId(), error.get());
|
||||
String err = format("Сделка № %d не смогла быть обработана. %s", sTrd.getTradeNum(), msgResolver.resolve(error.get()));
|
||||
logNotifyE(err);
|
||||
continue;
|
||||
}
|
||||
ExecutionCurrency newEC;
|
||||
|
|
@ -217,7 +228,10 @@ public class ExecutionCurrencyComponent implements IExecutionUploadComponent {
|
|||
} catch (ClearingException ce) {
|
||||
auditMessage(ce);
|
||||
} catch (Exception e) {
|
||||
log.error("When create new ExecutionCurrency by STrade[{}] error: {}", sTrd.getId(), ExceptionUtils.getStackTrace(e));
|
||||
String err = String.format("When create new ExecutionCurrency by STrade[%d] error: %s",
|
||||
sTrd.getId(),
|
||||
ExceptionUtils.getStackTrace(e));
|
||||
log.error(err);
|
||||
}
|
||||
}
|
||||
log.info("batch putAll {} ExecutionCurrency", execsToInsert.size());
|
||||
|
|
@ -230,7 +244,8 @@ public class ExecutionCurrencyComponent implements IExecutionUploadComponent {
|
|||
|
||||
|
||||
protected void auditMessage(ClearingException ce) {
|
||||
log.error("AUDIT error code {}: {}", ce.getEnumMsg(), ce.getMessage());
|
||||
String err = String.format("AUDIT error code %s: %s", ce.getEnumMsg(), ce.getMessage());
|
||||
logNotifyE(err);
|
||||
}
|
||||
|
||||
protected void sendNotification(ExecutionCurrency forED) throws ClearingException {
|
||||
|
|
@ -348,11 +363,32 @@ public class ExecutionCurrencyComponent implements IExecutionUploadComponent {
|
|||
}
|
||||
|
||||
private void logError(IEnumId subject, Object... args) {
|
||||
log.info("{}", msgResolver.resolve(new EnumMessage(subject, args)));
|
||||
String err = msgResolver.resolve(new EnumMessage(subject, args));
|
||||
log.info("{}", err);
|
||||
// notifications.sendNotification(ObjectType.vfrs, err, Priority.HIGH);
|
||||
}
|
||||
|
||||
private void logError(Long sTradeId, EnumMessage msg) {
|
||||
log.warn("sTrade id={} {}", sTradeId, msgResolver.resolve(msg));
|
||||
private void logError(Long sTradeNum, EnumMessage msg) {
|
||||
String err = format("Сделка № %d не смогла быть обработана. %s", sTradeNum, msgResolver.resolve(msg));
|
||||
log.warn(err);
|
||||
notifications.sendNotification(ObjectType.vfrs, err, Priority.HIGH);
|
||||
}
|
||||
|
||||
private void logNotifyW(String msg) {
|
||||
logNotify(msg, Level.WARN);
|
||||
}
|
||||
|
||||
private void logNotifyE(String msg) {
|
||||
logNotify(msg, Level.ERROR);
|
||||
}
|
||||
|
||||
private void logNotify(String msg, Level lvl) {
|
||||
switch (lvl) {
|
||||
case WARN -> log.warn(msg);
|
||||
case ERROR -> log.error(msg);
|
||||
default -> log.error("lvl not supported {}. {}", lvl, msg);
|
||||
}
|
||||
notifications.sendNotification(ObjectType.vfrs, msg, Priority.HIGH);
|
||||
}
|
||||
|
||||
private Optional<TradingClearingRegistry> searchTcrByStrades(STrades sTrades) {
|
||||
|
|
|
|||
|
|
@ -92,7 +92,9 @@ public class ExecutionDepositComponent implements IExecutionUploadComponent {
|
|||
|
||||
|
||||
@Autowired
|
||||
public ExecutionDepositComponent(ImdgProvider imdgProvider, Producer<String, Object> kafka, NotificationSender notifications,
|
||||
public ExecutionDepositComponent(ImdgProvider imdgProvider,
|
||||
Producer<String, Object> kafka,
|
||||
NotificationSender notifications,
|
||||
@Qualifier("kafkaSenderWithoutRequestInfo") KafkaSender kafkaSender,
|
||||
IMessageResolver msgResolver) {
|
||||
this.sTradeImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_STrades, STrades.class);
|
||||
|
|
@ -161,7 +163,7 @@ public class ExecutionDepositComponent implements IExecutionUploadComponent {
|
|||
sTrades.removeIf(sTrd -> {
|
||||
Side sTrdSide = IEnumKey.getEnumByKey(Side.class, sTrd.getOperation());
|
||||
if (sTrdSide == null || !(sTrdSide.equals(Side.BUY) || sTrdSide.equals(Side.SELL))) {
|
||||
logNotifyW(format(
|
||||
log.warn(format(
|
||||
"cannot parse strade.tradeNum=%d strade.operation %s",
|
||||
sTrd.getTradeNum(),
|
||||
sTrd.getOperation())
|
||||
|
|
@ -186,7 +188,8 @@ public class ExecutionDepositComponent implements IExecutionUploadComponent {
|
|||
IValidator validator = valFor(sTrd);
|
||||
Optional<EnumMessage> error = validator.tillFirstError();
|
||||
if (error.isPresent()) {
|
||||
logError(sTrd.getId(), error.get());
|
||||
String err = format("Сделка № %d не смогла быть обработана. %s", sTrd.getTradeNum(), msgResolver.resolve(error.get()));
|
||||
logNotifyE(err);
|
||||
continue;
|
||||
}
|
||||
ExecutionDeposit newED;
|
||||
|
|
@ -215,7 +218,7 @@ public class ExecutionDepositComponent implements IExecutionUploadComponent {
|
|||
String err = String.format("When create new ExecutionDeposit by STrade[%d] error: %s",
|
||||
sTrd.getId(),
|
||||
ExceptionUtils.getStackTrace(e));
|
||||
logNotifyE(err);
|
||||
log.error(err);
|
||||
}
|
||||
}
|
||||
log.info("batch putAll {} ExecutionDeposit", execsToInsert.size());
|
||||
|
|
@ -351,12 +354,12 @@ public class ExecutionDepositComponent implements IExecutionUploadComponent {
|
|||
private void logError(IEnumId subject, Object... args) {
|
||||
String err = msgResolver.resolve(new EnumMessage(subject, args));
|
||||
log.info("{}", err);
|
||||
notifications.sendNotification(ObjectType.vfrs, err, Priority.HIGH);
|
||||
// notifications.sendNotification(ObjectType.vfrs, err, Priority.HIGH);
|
||||
}
|
||||
|
||||
|
||||
private void logError(Long sTradeId, EnumMessage msg) {
|
||||
String err = format("sTrade id=%d %s", sTradeId, msgResolver.resolve(msg));
|
||||
private void logError(Long sTradeNum, EnumMessage msg) {
|
||||
String err = format("Сделка № %d не смогла быть обработана. %s", sTradeNum, msgResolver.resolve(msg));
|
||||
log.warn(err);
|
||||
notifications.sendNotification(ObjectType.vfrs, err, Priority.HIGH);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package ru.spcex.clearing.service.execution;
|
||||
|
||||
import static java.lang.String.format;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.Instant;
|
||||
|
|
@ -9,7 +10,6 @@ import java.util.Collection;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import static java.lang.String.format;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.event.Level;
|
||||
|
|
@ -66,7 +66,6 @@ import ru.spcex.platform.utils.enumeration.EnumMessage;
|
|||
import ru.spcex.platform.utils.enumeration.IEnumId;
|
||||
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.platform.utils.enumeration.SimpleMessageResolver;
|
||||
import ru.spcex.platform.utils.log.ExceptionUtils;
|
||||
import static ru.spcex.platform.utils.number.BigDecimalUtil.safeBD;
|
||||
import ru.spcex.platform.utils.text.TextUtil;
|
||||
|
|
@ -98,7 +97,7 @@ public class ExecutionFondComponent implements IExecutionUploadComponent {
|
|||
//fixme ждать ТЗ
|
||||
Long tradeNum;
|
||||
Instant tradingDay;
|
||||
private final IMessageResolver msgResolver = new SimpleMessageResolver();
|
||||
private final IMessageResolver msgResolver;
|
||||
private final KafkaSender kafkaSender;
|
||||
private final NotificationSender notifications;
|
||||
private final boolean valuation;
|
||||
|
|
@ -109,7 +108,9 @@ public class ExecutionFondComponent implements IExecutionUploadComponent {
|
|||
@Autowired
|
||||
public ExecutionFondComponent(ImdgProvider imdgProvider,
|
||||
ClearingServiceSettings settings,
|
||||
@Qualifier("kafkaSenderWithoutRequestInfo") KafkaSender kafkaSender, NotificationSender notifications) {
|
||||
@Qualifier("kafkaSenderWithoutRequestInfo") KafkaSender kafkaSender,
|
||||
NotificationSender notifications,
|
||||
IMessageResolver msgResolver) {
|
||||
this.sTradeImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_STrades, STrades.class);
|
||||
this.executionFondImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_ExecutionFond, ExecutionFond.class);
|
||||
this.listingImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Listing, Listing.class);
|
||||
|
|
@ -129,6 +130,7 @@ public class ExecutionFondComponent implements IExecutionUploadComponent {
|
|||
this.valuation = settings.getTrade().getValuation(); //fixme
|
||||
this.kafkaSender = kafkaSender;
|
||||
this.notifications = notifications;
|
||||
this.msgResolver = msgResolver;
|
||||
|
||||
resetTradingDay();
|
||||
}
|
||||
|
|
@ -185,7 +187,7 @@ public class ExecutionFondComponent implements IExecutionUploadComponent {
|
|||
sTrades.removeIf(sTrd -> {
|
||||
Side sTrdSide = IEnumKey.getEnumByKey(Side.class, sTrd.getOperation());
|
||||
if (sTrdSide == null || !(sTrdSide.equals(Side.BUY) || sTrdSide.equals(Side.SELL))) {
|
||||
logNotifyW(format(
|
||||
log.warn(format(
|
||||
"cannot parse strade.tradeNum=%d strade.operation %s",
|
||||
sTrd.getTradeNum(),
|
||||
sTrd.getOperation())
|
||||
|
|
@ -210,7 +212,8 @@ public class ExecutionFondComponent implements IExecutionUploadComponent {
|
|||
IValidator validator = valFor(sTrd);
|
||||
Optional<EnumMessage> error = validator.tillFirstError();
|
||||
if (error.isPresent()) {
|
||||
logError(sTrd.getId(), error.get());
|
||||
String err = format("Сделка № %d не смогла быть обработана. %s", sTrd.getTradeNum(), msgResolver.resolve(error.get()));
|
||||
logNotifyE(err);
|
||||
continue;
|
||||
}
|
||||
ExecutionFond newED;
|
||||
|
|
@ -239,7 +242,7 @@ public class ExecutionFondComponent implements IExecutionUploadComponent {
|
|||
String err = String.format("When create new ExecutionFond by STrade[%d] error: %s",
|
||||
sTrd.getId(),
|
||||
ExceptionUtils.getStackTrace(e));
|
||||
logNotifyE(err);
|
||||
log.error(err);
|
||||
}
|
||||
}
|
||||
log.info("batch putAll {} ExecutionFond", execsToInsert.size());
|
||||
|
|
@ -405,11 +408,11 @@ public class ExecutionFondComponent implements IExecutionUploadComponent {
|
|||
private void logError(IEnumId subject, Object... args) {
|
||||
String err = msgResolver.resolve(new EnumMessage(subject, args));
|
||||
log.info("{}", err);
|
||||
notifications.sendNotification(ObjectType.vfrs, err, Priority.HIGH);
|
||||
// notifications.sendNotification(ObjectType.vfrs, err, Priority.HIGH);
|
||||
}
|
||||
|
||||
private void logError(Long sTradeId, EnumMessage msg) {
|
||||
String err = format("sTrade id=%d %s", sTradeId, msgResolver.resolve(msg));
|
||||
String err = format("Сделка № %d не смогла быть обработана. %s", sTradeId, msgResolver.resolve(msg));
|
||||
log.warn(err);
|
||||
notifications.sendNotification(ObjectType.vfrs, err, Priority.HIGH);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue