account-service http://jira.mfd.msk:8088/browse/CLS-271 убрано автосоздание ТКР, оставлено только для ClientCode
This commit is contained in:
parent
109240166e
commit
05a42541de
7 changed files with 73 additions and 82 deletions
|
|
@ -1,11 +1,10 @@
|
||||||
package ru.spcex.clearing.account.config.validation;
|
package ru.spcex.clearing.account.config.validation;
|
||||||
|
|
||||||
|
import com.hazelcast.query.PredicateBuilder;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import ru.clearing.classes.statics.data.account.Account;
|
import ru.clearing.classes.statics.data.account.Account;
|
||||||
import ru.clearing.classes.statics.data.account.ClearingAccount;
|
|
||||||
import ru.clearing.classes.statics.data.account.DepoAccount;
|
import ru.clearing.classes.statics.data.account.DepoAccount;
|
||||||
import ru.clearing.classes.statics.data.account.InformationAccount;
|
|
||||||
import ru.clearing.classes.statics.data.company.Company;
|
import ru.clearing.classes.statics.data.company.Company;
|
||||||
import ru.clearing.classes.statics.data.company.CompanySymbols;
|
import ru.clearing.classes.statics.data.company.CompanySymbols;
|
||||||
import ru.clearing.classes.statics.data.registry.TradingClearingRegistry;
|
import ru.clearing.classes.statics.data.registry.TradingClearingRegistry;
|
||||||
|
|
@ -23,13 +22,21 @@ import ru.spcex.platform.enumeration.AccountType;
|
||||||
import ru.spcex.platform.enumeration.CompanySymbol;
|
import ru.spcex.platform.enumeration.CompanySymbol;
|
||||||
import ru.spcex.platform.enumeration.ServiceStatus;
|
import ru.spcex.platform.enumeration.ServiceStatus;
|
||||||
import ru.spcex.platform.imdg.api.Imdg;
|
import ru.spcex.platform.imdg.api.Imdg;
|
||||||
|
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||||
|
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||||
import ru.spcex.platform.imdg.validation.ImdgValidationContext;
|
import ru.spcex.platform.imdg.validation.ImdgValidationContext;
|
||||||
|
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||||
|
import ru.spcex.platform.utils.validation.IValidationRule;
|
||||||
import ru.spcex.platform.utils.validation.IValidator;
|
import ru.spcex.platform.utils.validation.IValidator;
|
||||||
import ru.spcex.platform.utils.validation.ValidatorImpl;
|
import ru.spcex.platform.utils.validation.ValidatorImpl;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class TradingClearingRegistryValidationConfig {
|
public class TradingClearingRegistryValidationConfig {
|
||||||
|
|
@ -49,6 +56,7 @@ public class TradingClearingRegistryValidationConfig {
|
||||||
addImdg.accept(IMDGDistributedNames.Map_DepoAccount);
|
addImdg.accept(IMDGDistributedNames.Map_DepoAccount);
|
||||||
addImdg.accept(IMDGDistributedNames.Map_InformationAccount);
|
addImdg.accept(IMDGDistributedNames.Map_InformationAccount);
|
||||||
addImdg.accept(IMDGDistributedNames.Map_ServiceStatusDictionary);
|
addImdg.accept(IMDGDistributedNames.Map_ServiceStatusDictionary);
|
||||||
|
addImdg.accept(IMDGDistributedNames.Map_TradingClearingRegistry);
|
||||||
return new ValidatorImpl<>(context,
|
return new ValidatorImpl<>(context,
|
||||||
IdPresentRule.instance("companyId",
|
IdPresentRule.instance("companyId",
|
||||||
TradingClearingRegistryNewRequest::getCompanyId,
|
TradingClearingRegistryNewRequest::getCompanyId,
|
||||||
|
|
@ -108,7 +116,7 @@ public class TradingClearingRegistryValidationConfig {
|
||||||
if (depoAccountId == null) return null;
|
if (depoAccountId == null) return null;
|
||||||
Imdg<DepoAccount> depoAccountImdg = context.obtainMap(IMDGDistributedNames.Map_DepoAccount, DepoAccount.class);
|
Imdg<DepoAccount> depoAccountImdg = context.obtainMap(IMDGDistributedNames.Map_DepoAccount, DepoAccount.class);
|
||||||
DepoAccount depoAccount = depoAccountImdg.getSingleObjectByFieldValues(
|
DepoAccount depoAccount = depoAccountImdg.getSingleObjectByFieldValues(
|
||||||
Map.of("accountId",depoAccountId)
|
Map.of("accountId", depoAccountId)
|
||||||
);
|
);
|
||||||
if (depoAccount == null) return AccountError.AccountNotFound;
|
if (depoAccount == null) return AccountError.AccountNotFound;
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -124,11 +132,44 @@ public class TradingClearingRegistryValidationConfig {
|
||||||
String statusCode = statusValue.getCode();
|
String statusCode = statusValue.getCode();
|
||||||
if (ServiceStatus.Active.equalsByKey(statusCode)) return null;
|
if (ServiceStatus.Active.equalsByKey(statusCode)) return null;
|
||||||
return AccountError.WrongFieldValue;
|
return AccountError.WrongFieldValue;
|
||||||
})
|
}),
|
||||||
|
new newTCRDuplicateCheck()
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class newTCRDuplicateCheck implements IValidationRule<ImdgValidationContext<TradingClearingRegistryNewRequest>> {
|
||||||
|
@Override
|
||||||
|
public Optional<EnumMessage> validate(ImdgValidationContext<TradingClearingRegistryNewRequest> context) {
|
||||||
|
TradingClearingRegistryNewRequest validatedObject = context.getValidatedObject();
|
||||||
|
Imdg<TradingClearingRegistry> tcrMap = context.obtainMap(IMDGDistributedNames.Map_TradingClearingRegistry, TradingClearingRegistry.class);
|
||||||
|
|
||||||
|
if (validatedObject.getMoneyAccountId() != null) {
|
||||||
|
return of(AccountError.RequiredFieldEmpty, "MoneyAccountId");
|
||||||
|
}
|
||||||
|
//Map<String, Comparable<?>> query = new HashMap<>();
|
||||||
|
// query.put("moneyAccountId", validatedObject.getMoneyAccountId());
|
||||||
|
// if (validatedObject.getDepoAccountId() != null) {
|
||||||
|
// query.put("depoAccountId", validatedObject.getDepoAccountId());
|
||||||
|
// }
|
||||||
|
ImdgPredicateBuilder pb = tcrMap.predicateBuilder();
|
||||||
|
ImdgPredicate query = pb.equals("moneyAccountId", validatedObject.getMoneyAccountId());
|
||||||
|
if (validatedObject.getDepoAccountId() != null) {
|
||||||
|
query = pb.or(query, pb.equals("depoAccountId", validatedObject.getDepoAccountId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
Collection<TradingClearingRegistry> existTCR = tcrMap.getCollectionObjectsByPredicate(query);
|
||||||
|
|
||||||
|
if (existTCR.isEmpty()) {
|
||||||
|
return empty();
|
||||||
|
} else {
|
||||||
|
String tcrIds = existTCR.stream().map(tcr -> String.valueOf(tcr.getId())).collect(Collectors.joining(";"));
|
||||||
|
return of(AccountError.AccountForTradingClearingRegistryAlreadyUsed, validatedObject.getCompanyId(), tcrIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Bean("tradingClearingRegistryUpdateRequest")
|
@Bean("tradingClearingRegistryUpdateRequest")
|
||||||
public Function<TradingClearingRegistryUpdateRequest, IValidator> tradingClearingRegistryUpdateRequestValidator(
|
public Function<TradingClearingRegistryUpdateRequest, IValidator> tradingClearingRegistryUpdateRequestValidator(
|
||||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ public enum AccountError implements IErrorEnumId {
|
||||||
ClearingCategoryNotFound(5019L),
|
ClearingCategoryNotFound(5019L),
|
||||||
ClearingCompanySymbolNotFound(5022L), // Для компании %s отсутствует клиринговый код».
|
ClearingCompanySymbolNotFound(5022L), // Для компании %s отсутствует клиринговый код».
|
||||||
TradingClearingRegistryNotFound(3022L),
|
TradingClearingRegistryNotFound(3022L),
|
||||||
|
AccountForTradingClearingRegistryAlreadyUsed(3023L),
|
||||||
;
|
;
|
||||||
|
|
||||||
private final Long id;
|
private final Long id;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdf0
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdfRequestPart;
|
import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdfRequestPart;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.balance.AccountSdfToStatementRequestPart;
|
import ru.spcex.clearing.platform.messaging.domain.cud.balance.AccountSdfToStatementRequestPart;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.balance.StatementRequest;
|
import ru.spcex.clearing.platform.messaging.domain.cud.balance.StatementRequest;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.registry.TradingClearingRegistryNewRequest;
|
|
||||||
import ru.spcex.clearing.platform.messaging.serialization.LogFormatter;
|
import ru.spcex.clearing.platform.messaging.serialization.LogFormatter;
|
||||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||||
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
||||||
|
|
@ -139,12 +138,6 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
||||||
} finally {
|
} finally {
|
||||||
if (txOk) {
|
if (txOk) {
|
||||||
imdgTransaction.commitTransaction();
|
imdgTransaction.commitTransaction();
|
||||||
TradingClearingRegistryNewRequest request = new TradingClearingRegistryNewRequest();
|
|
||||||
request.setMoneyAccountId(accountId);
|
|
||||||
request.setCompanyId(clearingAccount.getCompanyId());
|
|
||||||
log.debug("Send message to kafka \"{}\": {}", Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW,
|
|
||||||
LogFormatter.toStringWrapper(request));
|
|
||||||
kafkaSender.sendRequestToQueue(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW, request);
|
|
||||||
log.debug("successfully processed, new clearing account id {}, account id {}", clearingAccountId, accountId);
|
log.debug("successfully processed, new clearing account id {}, account id {}", clearingAccountId, accountId);
|
||||||
} else {
|
} else {
|
||||||
log.debug("failed insert, new clearing account id {}, new account id {} (if id = -1 then insert is failed)",
|
log.debug("failed insert, new clearing account id {}, new account id {} (if id = -1 then insert is failed)",
|
||||||
|
|
@ -210,7 +203,6 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
||||||
List<AccountSdfToStatementRequestPart> accountToStatement = new ArrayList<>();
|
List<AccountSdfToStatementRequestPart> accountToStatement = new ArrayList<>();
|
||||||
|
|
||||||
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
||||||
List<TradingClearingRegistryNewRequest> toTCRRequests = new ArrayList<>();
|
|
||||||
boolean txOk = false;
|
boolean txOk = false;
|
||||||
imdgTransaction.beginTransaction();
|
imdgTransaction.beginTransaction();
|
||||||
try {
|
try {
|
||||||
|
|
@ -252,13 +244,6 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
||||||
clearingAccountId = clearingAccountImdg.insert(clearingAccount);
|
clearingAccountId = clearingAccountImdg.insert(clearingAccount);
|
||||||
log.debug("New account {}, clearingAccount {} was created.", accountId, clearingAccountId);
|
log.debug("New account {}, clearingAccount {} was created.", accountId, clearingAccountId);
|
||||||
|
|
||||||
{
|
|
||||||
TradingClearingRegistryNewRequest request = new TradingClearingRegistryNewRequest();
|
|
||||||
request.setMoneyAccountId(accountId);
|
|
||||||
request.setCompanyId(clearingAccount.getCompanyId());
|
|
||||||
// request.setTradingClearingRegistryType(cl);
|
|
||||||
toTCRRequests.add(request);
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
AccountSdfToStatementRequestPart responsePart = new AccountSdfToStatementRequestPart();
|
AccountSdfToStatementRequestPart responsePart = new AccountSdfToStatementRequestPart();
|
||||||
responsePart.setSdfId(accountReq.getSdfId());
|
responsePart.setSdfId(accountReq.getSdfId());
|
||||||
|
|
@ -277,16 +262,6 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (txOk) {
|
|
||||||
log.debug("Sending {} messages of TradingClearingRegistryNewRequest", toTCRRequests.size());
|
|
||||||
for (TradingClearingRegistryNewRequest tcrReq : toTCRRequests) {
|
|
||||||
log.debug("Send message to kafka \"{}\": {}", Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW,
|
|
||||||
LogFormatter.toStringWrapper(tcrReq));
|
|
||||||
Long kafkaId = kafkaSender.sendRequestToQueue(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW, tcrReq);
|
|
||||||
log.trace("successfully send request {} to kafka: new clearing account MoneyAccountId {}, DepoAccountId {}",
|
|
||||||
kafkaId, tcrReq.getMoneyAccountId(), tcrReq.getDepoAccountId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sendStatementRequestBack(req.getGroupingSdf01Id(), accountToStatement);
|
sendStatementRequestBack(req.getGroupingSdf01Id(), accountToStatement);
|
||||||
log.debug("successfully processed, grouping id={}, processed number={}", req.getGroupingSdf01Id(), accountToStatement.size());
|
log.debug("successfully processed, grouping id={}, processed number={}", req.getGroupingSdf01Id(), accountToStatement.size());
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdf0
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdfRequestPart;
|
import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdfRequestPart;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.balance.AccountSdfToStatementRequestPart;
|
import ru.spcex.clearing.platform.messaging.domain.cud.balance.AccountSdfToStatementRequestPart;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.balance.StatementRequest;
|
import ru.spcex.clearing.platform.messaging.domain.cud.balance.StatementRequest;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.registry.TradingClearingRegistryNewRequest;
|
|
||||||
import ru.spcex.clearing.platform.messaging.serialization.LogFormatter;
|
import ru.spcex.clearing.platform.messaging.serialization.LogFormatter;
|
||||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||||
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
||||||
|
|
@ -121,11 +120,6 @@ public class DepoAccountService extends QueueConsumer implements InitializingBea
|
||||||
} finally {
|
} finally {
|
||||||
if (txOk) {
|
if (txOk) {
|
||||||
imdgTransaction.commitTransaction();
|
imdgTransaction.commitTransaction();
|
||||||
TradingClearingRegistryNewRequest request = new TradingClearingRegistryNewRequest();
|
|
||||||
request.setDepoAccountId(accountId);
|
|
||||||
request.setCompanyId(depoAccount.getCompanyId());
|
|
||||||
log.debug("Send message to kafka \"{}\": {}", Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW, LogFormatter.toStringWrapper(request));
|
|
||||||
kafkaSender.sendRequestToQueue(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW, request);
|
|
||||||
log.debug("successfully processed, new depo account id {}, account id {}", depoAccountId, accountId);
|
log.debug("successfully processed, new depo account id {}, account id {}", depoAccountId, accountId);
|
||||||
} else {
|
} else {
|
||||||
log.debug("failed insert, new depo account id {}, new account id {} (if id = -1 then insert is failed)",
|
log.debug("failed insert, new depo account id {}, new account id {} (if id = -1 then insert is failed)",
|
||||||
|
|
@ -144,7 +138,6 @@ public class DepoAccountService extends QueueConsumer implements InitializingBea
|
||||||
List<AccountSdfToStatementRequestPart> accountToStatement = new ArrayList<>();
|
List<AccountSdfToStatementRequestPart> accountToStatement = new ArrayList<>();
|
||||||
|
|
||||||
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
||||||
List<TradingClearingRegistryNewRequest> toTCRRequests = new ArrayList<>();
|
|
||||||
boolean txOk = false;
|
boolean txOk = false;
|
||||||
imdgTransaction.beginTransaction();
|
imdgTransaction.beginTransaction();
|
||||||
try {
|
try {
|
||||||
|
|
@ -191,13 +184,6 @@ public class DepoAccountService extends QueueConsumer implements InitializingBea
|
||||||
|
|
||||||
log.debug("New account {}, depoAccount {} was created.", accountId, depoAccountId);
|
log.debug("New account {}, depoAccount {} was created.", accountId, depoAccountId);
|
||||||
|
|
||||||
{
|
|
||||||
TradingClearingRegistryNewRequest request = new TradingClearingRegistryNewRequest();
|
|
||||||
request.setDepoAccountId(accountId);
|
|
||||||
request.setCompanyId(depoAccount.getCompanyId());
|
|
||||||
// request.setTradingClearingRegistryType(cl);
|
|
||||||
toTCRRequests.add(request);
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
AccountSdfToStatementRequestPart responsePart = new AccountSdfToStatementRequestPart();
|
AccountSdfToStatementRequestPart responsePart = new AccountSdfToStatementRequestPart();
|
||||||
responsePart.setSdfId(accountReq.getSdfId());
|
responsePart.setSdfId(accountReq.getSdfId());
|
||||||
|
|
@ -216,17 +202,6 @@ public class DepoAccountService extends QueueConsumer implements InitializingBea
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (txOk) {
|
|
||||||
log.debug("Sending {} messages of TradingClearingRegistryNewRequest", toTCRRequests.size());
|
|
||||||
for (TradingClearingRegistryNewRequest tcrReq : toTCRRequests) {
|
|
||||||
log.debug("Send message to kafka \"{}\": {}", Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW,
|
|
||||||
LogFormatter.toStringWrapper(tcrReq));
|
|
||||||
Long kafkaId = kafkaSender.sendRequestToQueue(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW, tcrReq);
|
|
||||||
log.trace("successfully send request {} to kafka: new clearing account MoneyAccountId {}, DepoAccountId {}",
|
|
||||||
kafkaId, tcrReq.getMoneyAccountId(), tcrReq.getDepoAccountId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sendStatementRequestBack(req.getGroupingSdf01Id(), accountToStatement);
|
sendStatementRequestBack(req.getGroupingSdf01Id(), accountToStatement);
|
||||||
log.debug("successfully processed, grouping id={}, processed number={}", req.getGroupingSdf01Id(), accountToStatement.size());
|
log.debug("successfully processed, grouping id={}, processed number={}", req.getGroupingSdf01Id(), accountToStatement.size());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -164,11 +164,6 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
||||||
} finally {
|
} finally {
|
||||||
if (txOk) {
|
if (txOk) {
|
||||||
imdgTransaction.commitTransaction();
|
imdgTransaction.commitTransaction();
|
||||||
TradingClearingRegistryNewRequest request = new TradingClearingRegistryNewRequest();
|
|
||||||
request.setMoneyAccountId(accountId);
|
|
||||||
request.setCompanyId(informationAccount.getCompanyId());
|
|
||||||
log.debug("Send message to kafka \"{}\": {}", Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW, LogFormatter.toStringWrapper(request));
|
|
||||||
kafkaSender.sendRequestToQueue(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW, request);
|
|
||||||
log.debug("successfully processed, new information account id {}, new account id {}",
|
log.debug("successfully processed, new information account id {}, new account id {}",
|
||||||
informationAccountId,
|
informationAccountId,
|
||||||
accountId);
|
accountId);
|
||||||
|
|
@ -275,22 +270,11 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
||||||
}
|
}
|
||||||
|
|
||||||
// send to kafka
|
// send to kafka
|
||||||
sendNotificationToTCR(informationAccount, account);
|
|
||||||
sendNotificationToReport(informationAccount, account);
|
sendNotificationToReport(informationAccount, account);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Автоматическое добавление ТКР
|
|
||||||
*/
|
|
||||||
protected void sendNotificationToTCR(InformationAccount informationAccount, Account account) {
|
|
||||||
TradingClearingRegistryNewRequest request = new TradingClearingRegistryNewRequest();
|
|
||||||
request.setMoneyAccountId(account.getId());
|
|
||||||
request.setCompanyId(informationAccount.getCompanyId());
|
|
||||||
log.debug("Send message to kafka \"{}\": {}", Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW, LogFormatter.toStringWrapper(request));
|
|
||||||
kafkaSender.sendRequestToQueue(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW, request);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Формирование уведолмения о регистрации УК
|
* Формирование уведолмения о регистрации УК
|
||||||
|
|
|
||||||
|
|
@ -40,10 +40,7 @@ import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||||
import ru.spcex.platform.utils.validation.IValidator;
|
import ru.spcex.platform.utils.validation.IValidator;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
|
@ -110,7 +107,7 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() throws Exception {
|
||||||
imdgProvider.waitAvailable();
|
imdgProvider.waitAvailable();
|
||||||
callback(TradingClearingRegistryNewRequest.class)
|
callback(TradingClearingRegistryNewRequest.class) // todo deprecated - unused.
|
||||||
.setFunction(this::tradingClearingRegistryAutoNew)
|
.setFunction(this::tradingClearingRegistryAutoNew)
|
||||||
.forDestination(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW, callbacks::put);
|
.forDestination(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW, callbacks::put);
|
||||||
callback(TradingClearingRegistryNewRequest.class)
|
callback(TradingClearingRegistryNewRequest.class)
|
||||||
|
|
@ -125,6 +122,7 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public RequestInfoUpdate tradingClearingRegistryAutoNew(BaseRequest<TradingClearingRegistryNewRequest> userRequest) {
|
public RequestInfoUpdate tradingClearingRegistryAutoNew(BaseRequest<TradingClearingRegistryNewRequest> userRequest) {
|
||||||
log.debug("TradingClearingRegistryNewRequest received");
|
log.debug("TradingClearingRegistryNewRequest received");
|
||||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||||
|
|
@ -306,7 +304,11 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
|
||||||
DepoAccount depoAccount = req.getDepoAccountId() != null ? depoAccountImdg.getSingleObjectByFieldValues(Map.of("accountId", req.getDepoAccountId())) : null;
|
DepoAccount depoAccount = req.getDepoAccountId() != null ? depoAccountImdg.getSingleObjectByFieldValues(Map.of("accountId", req.getDepoAccountId())) : null;
|
||||||
ClearingAccount clearingAccount = req.getMoneyAccountId() != null ? clearingAccountImdg.getSingleObjectByFieldValues(Map.of("accountId", req.getMoneyAccountId())) : null;
|
ClearingAccount clearingAccount = req.getMoneyAccountId() != null ? clearingAccountImdg.getSingleObjectByFieldValues(Map.of("accountId", req.getMoneyAccountId())) : null;
|
||||||
|
|
||||||
tradingClearingRegistry.setStatus(ServiceStatus.Active.getKey());
|
if (req.getStatus() == null) {
|
||||||
|
tradingClearingRegistry.setStatus(ServiceStatus.Active.getKey());
|
||||||
|
} else {
|
||||||
|
tradingClearingRegistry.setStatus(req.getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
String tradingRegistryType;
|
String tradingRegistryType;
|
||||||
if (req.getTradingClearingRegistryType() != null) {
|
if (req.getTradingClearingRegistryType() != null) {
|
||||||
|
|
@ -405,14 +407,26 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
|
||||||
TradingClearingRegistryUpdateRequest req = userRequest.getRequestPayload();
|
TradingClearingRegistryUpdateRequest req = userRequest.getRequestPayload();
|
||||||
TradingClearingRegistry tradingClearingRegistry = tradingClearingRegistryImdg.getSingleObjectByID(req.getId());
|
TradingClearingRegistry tradingClearingRegistry = tradingClearingRegistryImdg.getSingleObjectByID(req.getId());
|
||||||
|
|
||||||
if (req.getStatus() != null) tradingClearingRegistry.setStatus(req.getStatus());
|
// кроссвалидация - нельзя менять эти поля:
|
||||||
|
if (req.getMoneyAccountId() != null && !req.getMoneyAccountId().equals(tradingClearingRegistry.getMoneyAccountId())) {
|
||||||
|
return requestHelper.makeErrorResponse(userRequest, AccountError.WrongFieldValue, "MoneyAccountId", req.getMoneyAccountId());
|
||||||
|
}
|
||||||
|
if (req.getDepoAccountId() != null && !req.getDepoAccountId().equals(tradingClearingRegistry.getDepoAccountId())) {
|
||||||
|
return requestHelper.makeErrorResponse(userRequest, AccountError.WrongFieldValue, "DepoAccountId", req.getDepoAccountId());
|
||||||
|
}
|
||||||
|
// tradingClearingRegistry.setMoneyAccountId(req.getMoneyAccountId());
|
||||||
|
// tradingClearingRegistry.setDepoAccountId(req.getDepoAccountId());
|
||||||
|
|
||||||
Instant now = Instant.now();
|
|
||||||
tradingClearingRegistry.setUpdated(now);
|
|
||||||
tradingClearingRegistry.setMoneyAccountId(req.getMoneyAccountId());
|
|
||||||
tradingClearingRegistry.setDepoAccountId(req.getDepoAccountId());
|
|
||||||
|
|
||||||
tradingClearingRegistryImdg.update(tradingClearingRegistry);
|
if (req.getStatus() != null && !Objects.equals(req.getStatus(), tradingClearingRegistry.getStatus())) {
|
||||||
|
Instant now = Instant.now();
|
||||||
|
tradingClearingRegistry.setUpdated(now);
|
||||||
|
tradingClearingRegistry.setStatus(req.getStatus());
|
||||||
|
tradingClearingRegistryImdg.update(tradingClearingRegistry);
|
||||||
|
log.debug("Update TCR.id={}.", tradingClearingRegistry.getId());
|
||||||
|
} else {
|
||||||
|
log.debug("Nothing to update TCR.id={}.", tradingClearingRegistry.getId());
|
||||||
|
}
|
||||||
|
|
||||||
log.debug("successfully processed, id {}", tradingClearingRegistry.getId());
|
log.debug("successfully processed, id {}", tradingClearingRegistry.getId());
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,7 @@ public interface Consts {
|
||||||
String DESTINATION_CLIENT_CODE_DELETE = "client-code-delete";
|
String DESTINATION_CLIENT_CODE_DELETE = "client-code-delete";
|
||||||
|
|
||||||
String DESTINATION_TRADING_CLEARING_REGISTRY_NEW = "trading-clearing-registry-new"; // не путать с REGISTRY_NEW
|
String DESTINATION_TRADING_CLEARING_REGISTRY_NEW = "trading-clearing-registry-new"; // не путать с REGISTRY_NEW
|
||||||
|
@Deprecated // сейчас в бизнес-логике автосоздание ТКР не используется
|
||||||
String DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW = "trading-clearing-registry-auto-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_UPDATE = "trading-clearing-registry-update";
|
||||||
String DESTINATION_TRADING_CLEARING_REGISTRY_BLOCK = "trading-clearing-registry-block";
|
String DESTINATION_TRADING_CLEARING_REGISTRY_BLOCK = "trading-clearing-registry-block";
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue