etreschenkov 2026-06-18 18:46:05 +03:00
parent 459fe3db6c
commit 2f94fcfe50
4 changed files with 28 additions and 38 deletions

View file

@ -174,6 +174,7 @@ public class ClientCodeValidationConfig {
addImdg.accept(IMDGDistributedNames.Map_CompanySymbols);
addImdg.accept(IMDGDistributedNames.Map_Account);
addImdg.accept(IMDGDistributedNames.Map_TradingClearingRegistry);
addImdg.accept(IMDGDistributedNames.Map_TradingClearingRegistryList);
addImdg.accept(IMDGDistributedNames.Map_AccountSymbols);
addImdg.accept(IMDGDistributedNames.Map_DepoAccount);
addImdg.accept(IMDGDistributedNames.Map_ClientCode);

View file

@ -32,8 +32,8 @@ public enum AccountError implements IErrorEnumId {
CurrencyForTradingClearingRegistryListAlreadyUsed(5031L),
BadSymbol(5032L),
TradingClearingRegistryNotFound(3022L),
ClientCodeNotLinedToTkr(3033L),
AccountRubForbiddenForAdd(3033L),
DepoAccountChangeNotAllowed(5033L),
ClientCodeNotFound(5034L),
CurrencyNotFound(1016L),
;

View file

@ -8,7 +8,6 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Stream;
import org.apache.kafka.clients.consumer.Consumer;
import org.apache.kafka.clients.producer.Producer;
import org.slf4j.Logger;
@ -221,12 +220,21 @@ public class ClientCodeMessageListener extends QueueConsumer implements Initiali
TkrAccount tkrAccount = entry.getKey();
ValidationResult validationResult = entry.getValue();
IValidator validator = validationResult.validator();
Company company = validator.getStored(ClientCodeStoreObjects.COMPANY);
List<Account> clrnAccs = validator.getStored(ClientCodeStoreObjects.CLRN_ACCS);
List<Account> anltAccs = validator.getStored(ClientCodeStoreObjects.ANLT_ACCS);
TradingClearingRegistry tradingClearingRegistry = validator.getStored(ClientCodeStoreObjects.TRADING_CLEARING_REGISTRY);
List<Long> accIds = Stream.concat(clrnAccs.stream(), anltAccs.stream())
.map(Account::getId)
.toList();
List<Long> accIds = new ArrayList<>();
for (MoneyAccountMsgRequest account : tkrAccount.getMoneyAccounts()) {
if (StringUtils.hasText(account.getEks_account())) {
log.debug("eks_account is filled, creating info account: {}", account.getEks_account());
Pair<Long, String> accId = accountFacade.createAccountInfo(account, company);
accIds.add(accId.getFirst());
}
}
clrnAccs.forEach(account -> accIds.add(account.getId()));
TradingClearingRegistryListNewRequest tcrListNew = new TradingClearingRegistryListNewRequest();
tcrListNew.setTradingClearingRegistryId(tradingClearingRegistry.getId());

View file

@ -97,10 +97,10 @@ public enum GatewayUpdateEksClientCodeValidationRule implements IValidationRule<
);
if (depoAccount == null) {
context.storeObject(ClientCodeStoreObjects.DEPO_ACCOUNT, Optional.empty());
return of(AccountError.DepoAccountNotFound, "depo_account");
return of(AccountError.AccountNotFound, "depo_account");
}
if (!tkr.getDepoAccountId().equals(depoAccount.getAccountId())) {
return of(AccountError.AccountForTradingClearingRegistryAlreadyUsed, depoAccount.getAccountId());
if (!depoAccount.getAccountId().equals(tkr.getDepoAccountId())) {
return of(AccountError.DepoAccountChangeNotAllowed, depoAccount.getAccountId());
}
}
return empty();
@ -116,7 +116,7 @@ public enum GatewayUpdateEksClientCodeValidationRule implements IValidationRule<
&& CurrencyCode.RUB.equalsByKey(moneyAccountMsgRequest.getCurrCode()))
.toList();
if (!accounts.isEmpty()) {
return of(AccountError.AccountRubForbiddenForAdd, accounts.stream().findFirst().get().getAccount());
return of(AccountError.AccountForTradingClearingRegistryAlreadyUsed, accounts.stream().findFirst().get().getAccount());
}
return empty();
}
@ -140,7 +140,7 @@ public enum GatewayUpdateEksClientCodeValidationRule implements IValidationRule<
)
);
if (existClientCode == null) {
return of(AccountError.ClientCodeNotLinedToTkr, trkCode);
return of(AccountError.ClientCodeNotFound, trkCode);
}
context.storeObject(ClientCodeStoreObjects.CLIENT_CODE, existClientCode);
return empty();
@ -155,12 +155,12 @@ public enum GatewayUpdateEksClientCodeValidationRule implements IValidationRule<
ImdgPredicateBuilder predicateBuilder = accountImdg.predicateBuilder();
List<MoneyAccountMsgRequest> accounts = validatedObject.getMoneyAccounts().stream()
.filter(moneyAccountMsgRequest ->
moneyAccountMsgRequest.getStatus().equals("NEW")
StringUtils.hasText(moneyAccountMsgRequest.getAccount()) && moneyAccountMsgRequest.getStatus().equals("NEW")
&& !CurrencyCode.RUB.equalsByKey(moneyAccountMsgRequest.getCurrCode()))
.toList();
List<MoneyAccountMsgRequest> existAccounts = validatedObject.getMoneyAccounts().stream()
.filter(moneyAccountMsgRequest ->
moneyAccountMsgRequest.getStatus().equals("NEW")
StringUtils.hasText(moneyAccountMsgRequest.getAccount()) && moneyAccountMsgRequest.getStatus().equals("NOW")
&& !CurrencyCode.RUB.equalsByKey(moneyAccountMsgRequest.getCurrCode()))
.toList();
List<Account> clrnAccounts = new ArrayList<>();
@ -171,6 +171,7 @@ public enum GatewayUpdateEksClientCodeValidationRule implements IValidationRule<
predicateBuilder.equals("accountType", AccountType.Clrn.getKey())
)
);
if (account == null) {
return of(AccountError.AccountNotFound, request.getAccount());
}
@ -194,7 +195,10 @@ public enum GatewayUpdateEksClientCodeValidationRule implements IValidationRule<
return of(AccountError.AccountNotFound, request.getAccount());
}
TradingClearingRegistryList tkrListByAccount = tkrList.getSingleObjectByPredicate(
predicateBuilder.equals("accountId", account.getId())
predicateBuilder.and(
predicateBuilder.equals("accountId", account.getId()),
predicateBuilder.equals("currency", account.getCurrency())
)
);
if (tkrListByAccount == null) {
return of(AccountError.AccountForTradingClearingRegistryAlreadyUsed, account.getId());
@ -229,7 +233,7 @@ public enum GatewayUpdateEksClientCodeValidationRule implements IValidationRule<
return of(AccountError.AccountNotFound, request.getAccount());
}
TradingClearingRegistryList tkrListByAccount = tkrList.getSingleObjectByPredicate(
predicateBuilder.equals("accountId", account.getId())
predicateBuilder.equals("currency", account.getCurrency())
);
if (tkrListByAccount != null) {
return of(AccountError.AccountForTradingClearingRegistryAlreadyUsed, account.getId());
@ -237,29 +241,6 @@ public enum GatewayUpdateEksClientCodeValidationRule implements IValidationRule<
anltAccounts.add(account);
}
List<MoneyAccountMsgRequest> existAccounts = validatedObject.getMoneyAccounts().stream()
.filter(moneyAccountMsgRequest ->
StringUtils.hasText(moneyAccountMsgRequest.getEks_account()) && moneyAccountMsgRequest.getStatus().equals("NOW")
&& !CurrencyCode.RUB.equalsByKey(moneyAccountMsgRequest.getCurrCode()))
.toList();
for (MoneyAccountMsgRequest request : existAccounts) {
Account account = accountImdg.getFirstObjectByPredicate(
predicateBuilder.and(
predicateBuilder.equals("accountType", AccountType.Anlt.getKey()),
predicateBuilder.equals("currency", request.getCurrCode()),
predicateBuilder.equals("account", request.getEks_account())
)
);
if (account == null) {
return of(AccountError.AccountNotFound, request.getAccount());
}
TradingClearingRegistryList tkrListByAccount = tkrList.getSingleObjectByPredicate(
predicateBuilder.equals("accountId", account.getId())
);
if (tkrListByAccount == null) {
return of(AccountError.AccountForTradingClearingRegistryAlreadyUsed, account.getId());
}
}
context.storeObject(ClientCodeStoreObjects.ANLT_ACCS, anltAccounts);
return empty();
}