http://jira.mfd.msk:8088/browse/CLS-265 auto request for TCR new
This commit is contained in:
parent
654943ec36
commit
65c235c01c
5 changed files with 39 additions and 4 deletions
|
|
@ -16,9 +16,11 @@ import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
|||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.ClearingAccountNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.ClearingAccountUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.registry.TradingClearingRegistryNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
||||
import ru.spcex.clearing.platform.messaging.service.Status;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.clearing.validation.common.ValidationHelper;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.enumeration.ServiceStatus;
|
||||
|
|
@ -38,6 +40,7 @@ import java.util.function.Function;
|
|||
@Service
|
||||
public class ClearingAccountService extends QueueConsumer implements InitializingBean {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final KafkaSender kafkaSender;
|
||||
private final AccountService accountService;
|
||||
private final ValidationHelper validationHelper;
|
||||
private final ImdgProvider imdgProvider;
|
||||
|
|
@ -50,6 +53,7 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
|||
@Autowired
|
||||
public ClearingAccountService(Consumer<String, Object> kafkaQueue,
|
||||
Producer<String, Object> kafkaResponseQueue,
|
||||
KafkaSender kafkaSender,
|
||||
AccountService accountService,
|
||||
ValidationHelper validationHelper,
|
||||
ImdgProvider imdgProvider,
|
||||
|
|
@ -59,6 +63,7 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
|||
@Qualifier("clearingAccountUpdateRequestValidator")
|
||||
Function<ClearingAccountUpdateRequest, IValidator> clearingAccountUpdateRequestValidator) {
|
||||
super(kafkaQueue, kafkaResponseQueue);
|
||||
this.kafkaSender = kafkaSender;
|
||||
this.accountService = accountService;
|
||||
this.validationHelper = validationHelper;
|
||||
this.imdgProvider = imdgProvider;
|
||||
|
|
@ -104,10 +109,11 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
|||
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
||||
boolean txOk = false;
|
||||
imdgTransaction.beginTransaction();
|
||||
ClearingAccount clearingAccount = null;
|
||||
try {
|
||||
accountId = accountImdg.insert(account);
|
||||
|
||||
ClearingAccount clearingAccount = new ClearingAccount();
|
||||
clearingAccount = new ClearingAccount();
|
||||
clearingAccount.setCompanyId(req.getCompanyId());
|
||||
clearingAccount.setAccountId(accountId);
|
||||
clearingAccount.setClearingAccountType(req.getClearingAccountType());
|
||||
|
|
@ -116,6 +122,10 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
|||
} finally {
|
||||
if (txOk) {
|
||||
imdgTransaction.commitTransaction();
|
||||
TradingClearingRegistryNewRequest request = new TradingClearingRegistryNewRequest();
|
||||
request.setMoneyAccountId(accountId);
|
||||
request.setCompanyId(clearingAccount.getCompanyId());
|
||||
kafkaSender.sendRequestToQueue(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW, request);
|
||||
log.debug("successfully processed, new clearing account id {}, account id {}", clearingAccountId, accountId);
|
||||
} else {
|
||||
// todo выяснить, что возвращать из метода в этой ситуации
|
||||
|
|
|
|||
|
|
@ -13,8 +13,10 @@ 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.account.DepoAccountNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.registry.TradingClearingRegistryNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.clearing.validation.common.ValidationHelper;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.enumeration.ServiceStatus;
|
||||
|
|
@ -30,6 +32,7 @@ import java.util.function.Function;
|
|||
public class DepoAccountService extends QueueConsumer implements InitializingBean {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private final KafkaSender kafkaSender;
|
||||
private final ValidationHelper validationHelper;
|
||||
private final ImdgProvider imdgProvider;
|
||||
private final AccountService accountService;
|
||||
|
|
@ -39,12 +42,14 @@ public class DepoAccountService extends QueueConsumer implements InitializingBea
|
|||
|
||||
public DepoAccountService(Consumer<String, Object> kafkaQueue,
|
||||
Producer<String, Object> kafkaProducer,
|
||||
KafkaSender kafkaSender,
|
||||
ValidationHelper validationHelper,
|
||||
ImdgProvider imdgProvider,
|
||||
AccountService accountService,
|
||||
@Qualifier("depoAccountNewRequestValidator")
|
||||
Function<DepoAccountNewRequest, IValidator> depoAccountNewRequestValidator) {
|
||||
super(kafkaQueue, kafkaProducer);
|
||||
this.kafkaSender = kafkaSender;
|
||||
this.validationHelper = validationHelper;
|
||||
this.imdgProvider = imdgProvider;
|
||||
this.accountService = accountService;
|
||||
|
|
@ -86,10 +91,11 @@ public class DepoAccountService extends QueueConsumer implements InitializingBea
|
|||
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
||||
boolean txOk = false;
|
||||
imdgTransaction.beginTransaction();
|
||||
DepoAccount depoAccount = null;
|
||||
try {
|
||||
accountId = accountImdg.insert(account);
|
||||
|
||||
DepoAccount depoAccount = new DepoAccount();
|
||||
depoAccount = new DepoAccount();
|
||||
depoAccount.setCompanyId(req.getCompanyId());
|
||||
depoAccount.setAccountId(accountId);
|
||||
depoAccount.setDepoAccountType(req.getDepoAccountType());
|
||||
|
|
@ -98,6 +104,10 @@ public class DepoAccountService extends QueueConsumer implements InitializingBea
|
|||
} finally {
|
||||
if (txOk) {
|
||||
imdgTransaction.commitTransaction();
|
||||
TradingClearingRegistryNewRequest request = new TradingClearingRegistryNewRequest();
|
||||
request.setDepoAccountId(accountId);
|
||||
request.setCompanyId(depoAccount.getCompanyId());
|
||||
kafkaSender.sendRequestToQueue(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW, request);
|
||||
log.debug("successfully processed, new depo account id {}, account id {}", depoAccountId, accountId);
|
||||
} else {
|
||||
// todo выяснить, что возвращать из метода в этой ситуации
|
||||
|
|
|
|||
|
|
@ -15,9 +15,11 @@ 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.account.InformationAccountNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.registry.TradingClearingRegistryNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
||||
import ru.spcex.clearing.platform.messaging.service.Status;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.clearing.validation.common.ValidationHelper;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.enumeration.ServiceStatus;
|
||||
|
|
@ -37,6 +39,7 @@ import java.util.function.Function;
|
|||
@Service
|
||||
public class InformationAccountService extends QueueConsumer implements InitializingBean {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final KafkaSender kafkaSender;
|
||||
private final IMessageResolver messageResolver;
|
||||
private final ImdgProvider imdgProvider;
|
||||
private final ValidationHelper validationHelper;
|
||||
|
|
@ -48,6 +51,7 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
@Autowired
|
||||
public InformationAccountService(Consumer<String, Object> kafkaQueue,
|
||||
Producer<String, Object> kafkaResponseQueue,
|
||||
KafkaSender kafkaSender,
|
||||
IMessageResolver messageResolver,
|
||||
ImdgProvider imdgProvider,
|
||||
ValidationHelper validationHelper,
|
||||
|
|
@ -55,6 +59,7 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
@Qualifier("informationAccountNewRequestValidator")
|
||||
Function<InformationAccountNewRequest, IValidator> infoAccountNewRequestValidator) {
|
||||
super(kafkaQueue, kafkaResponseQueue);
|
||||
this.kafkaSender = kafkaSender;
|
||||
this.messageResolver = messageResolver;
|
||||
this.imdgProvider = imdgProvider;
|
||||
this.validationHelper = validationHelper;
|
||||
|
|
@ -117,10 +122,11 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
boolean txOk = false;
|
||||
Long informationAccountId = -1L;
|
||||
Long accountId = -1L;
|
||||
InformationAccount informationAccount = null;
|
||||
try {
|
||||
accountId = accountImdg.insert(account);
|
||||
|
||||
InformationAccount informationAccount = new InformationAccount();
|
||||
informationAccount = new InformationAccount();
|
||||
informationAccount.setId(newId);
|
||||
informationAccount.setAccountId(accountId);
|
||||
informationAccount.setClearingAccountId(anltAccount.getId());
|
||||
|
|
@ -130,6 +136,10 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
} finally {
|
||||
if (txOk) {
|
||||
imdgTransaction.commitTransaction();
|
||||
TradingClearingRegistryNewRequest request = new TradingClearingRegistryNewRequest();
|
||||
request.setMoneyAccountId(informationAccountId);
|
||||
request.setCompanyId(informationAccount.getCompanyId());
|
||||
kafkaSender.sendRequestToQueue(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW, request);
|
||||
log.debug("successfully processed, new information account id {}, new account id {}",
|
||||
informationAccountId,
|
||||
accountId);
|
||||
|
|
|
|||
|
|
@ -99,6 +99,9 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
|
|||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
init();
|
||||
callback(TradingClearingRegistryNewRequest.class)
|
||||
.setConsumer(this::tradingClearingRegistryAutoNew)
|
||||
.forDestination(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW, callbacks::put);
|
||||
callback(TradingClearingRegistryNewRequest.class)
|
||||
.setConsumer(this::tradingClearingRegistryNew)
|
||||
.forDestination(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_NEW, callbacks::put);
|
||||
|
|
@ -140,7 +143,8 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
|
|||
// TODO: WELCOME TO HELL
|
||||
// Проверка выглядит очень сложно и запутанно, потому что репортеры сами не до конца понимают, какая она должна быть.
|
||||
// Пока что она соответствует ТЗ, но возможно будет правиться, поэтому расписана без выноса кода в методы и
|
||||
// прочих методов сокращения кода
|
||||
// прочих методов сокращения кода. В дальнейшем, после тестирования и окончательного выяснения вида проверки,
|
||||
// её стоит вынести на этап валидации запроса.
|
||||
Relation relation = relationImdg.getSingleObjectByFieldValues(Map.of("consumerId", req.getCompanyId()));
|
||||
if (ru.spcex.platform.enumeration.Service.MKR.equalsByKey(relation.getService())) {
|
||||
TradingClearingRegistry registry = tradingClearingRegistryImdg.getSingleObjectByFieldValues(Map.of("companyId", req.getCompanyId()));
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ public interface Consts {
|
|||
String DESTINATION_CLIENT_CODE_DELETE = "client-code-delete";
|
||||
|
||||
String DESTINATION_TRADING_CLEARING_REGISTRY_NEW = "trading-clearing-registry-new";
|
||||
String DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW = "trading-clearing-registry-auto-new";
|
||||
String DESTINATION_TRADING_CLEARING_REGISTRY_UPDATE = "trading-clearing-registry-update";
|
||||
String DESTINATION_TRADING_CLEARING_REGISTRY_BLOCK = "trading-clearing-registry-block";
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue