account-service-v2
This commit is contained in:
parent
ccef108e13
commit
9eec24c4cf
1 changed files with 7 additions and 15 deletions
|
|
@ -121,7 +121,6 @@ public class ClientCodeMessageListener extends QueueConsumer implements Initiali
|
||||||
|
|
||||||
//unwrap запроса
|
//unwrap запроса
|
||||||
for (Map.Entry<TkrAccount, ValidationResult> entry : accountsAfterValidation.entrySet()) {
|
for (Map.Entry<TkrAccount, ValidationResult> entry : accountsAfterValidation.entrySet()) {
|
||||||
ClientCodeNewRequest clientCodeNewRequest = new ClientCodeNewRequest();
|
|
||||||
TkrAccount tkrAccount = entry.getKey();
|
TkrAccount tkrAccount = entry.getKey();
|
||||||
ValidationResult validationResult = entry.getValue();
|
ValidationResult validationResult = entry.getValue();
|
||||||
log.debug("Creating new clientCode by tkr account: {}", tkrAccount.getClientCode());
|
log.debug("Creating new clientCode by tkr account: {}", tkrAccount.getClientCode());
|
||||||
|
|
@ -132,18 +131,20 @@ public class ClientCodeMessageListener extends QueueConsumer implements Initiali
|
||||||
Long depoAccountId = depoAccount.map(Account::getId).orElse(null);
|
Long depoAccountId = depoAccount.map(Account::getId).orElse(null);
|
||||||
Map<String, Account> accountByCurrency = validator.getStored(ClientCodeStoreObjects.MAPPED_TO_CURRENCY_ACCOUNTS);
|
Map<String, Account> accountByCurrency = validator.getStored(ClientCodeStoreObjects.MAPPED_TO_CURRENCY_ACCOUNTS);
|
||||||
|
|
||||||
clientCodeNewRequest.setCompanyId(company.getId());
|
|
||||||
clientCodeNewRequest.setCode(tkrAccount.getClientCode());
|
|
||||||
clientCodeNewRequest.setDepoAccountId(depoAccountId);
|
|
||||||
Account moneyAccount = accountByCurrency.get(CurrencyCode.RUB.getKey());
|
Account moneyAccount = accountByCurrency.get(CurrencyCode.RUB.getKey());
|
||||||
clientCodeNewRequest.setMoneyAccountId(moneyAccount.getId());
|
|
||||||
|
|
||||||
List<Long> foreignCurrencyList = accountByCurrency.entrySet()
|
List<Long> foreignCurrencyList = accountByCurrency.entrySet()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(currencyCodeAccountEntry -> !CurrencyCode.RUB.equalsByKey(currencyCodeAccountEntry.getKey()))
|
.filter(currencyCodeAccountEntry -> !CurrencyCode.RUB.equalsByKey(currencyCodeAccountEntry.getKey()))
|
||||||
.map(currencyCodeAccountEntry -> currencyCodeAccountEntry.getValue().getId())
|
.map(currencyCodeAccountEntry -> currencyCodeAccountEntry.getValue().getId())
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
|
ClientCodeNewRequest clientCodeNewRequest = new ClientCodeNewRequest();
|
||||||
|
clientCodeNewRequest.setCompanyId(company.getId());
|
||||||
|
clientCodeNewRequest.setCode(tkrAccount.getClientCode());
|
||||||
|
clientCodeNewRequest.setDepoAccountId(depoAccountId);
|
||||||
|
clientCodeNewRequest.setMoneyAccountId(moneyAccount.getId());
|
||||||
clientCodeNewRequest.setCurrencyAccountList(foreignCurrencyList);
|
clientCodeNewRequest.setCurrencyAccountList(foreignCurrencyList);
|
||||||
|
|
||||||
clientCodeFacade.createClientCode(clientCodeNewRequest, validator);
|
clientCodeFacade.createClientCode(clientCodeNewRequest, validator);
|
||||||
|
|
||||||
TradingClearingRegistry tradingClearingRegistry = selectTradingClearingRegistry(company.getId(),
|
TradingClearingRegistry tradingClearingRegistry = selectTradingClearingRegistry(company.getId(),
|
||||||
|
|
@ -168,15 +169,6 @@ public class ClientCodeMessageListener extends QueueConsumer implements Initiali
|
||||||
return DefaultResponses.build(clientCodeNewRequest.getId(), DefaultResponses.SUCCESS);
|
return DefaultResponses.build(clientCodeNewRequest.getId(), DefaultResponses.SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private RequestInfoUpdate makeErrorResponse(BaseRequest<ClientCodeNewRequest> clientCodeNewRequest,
|
|
||||||
ValidationResult validationResult) {
|
|
||||||
RequestInfoUpdate requestInfoUpdate = new RequestInfoUpdate();
|
|
||||||
requestInfoUpdate.setId(clientCodeNewRequest.getId());
|
|
||||||
requestInfoUpdate.setStatus(Status.Error);
|
|
||||||
validationResult.errorMsg().ifPresent(requestInfoUpdate::setMessage);
|
|
||||||
return requestInfoUpdate;
|
|
||||||
}
|
|
||||||
|
|
||||||
private TradingClearingRegistry selectTradingClearingRegistry(Long companyId, Long moneyAccountId, Long depoAccountId) {
|
private TradingClearingRegistry selectTradingClearingRegistry(Long companyId, Long moneyAccountId, Long depoAccountId) {
|
||||||
Map<String, Comparable<?>> query = new HashMap<>();
|
Map<String, Comparable<?>> query = new HashMap<>();
|
||||||
query.put("companyId", companyId);
|
query.put("companyId", companyId);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue