From 997118ceb8ecf192059cffe011e8aeff9bc0a46a Mon Sep 17 00:00:00 2001 From: etreschenkov Date: Wed, 12 Jul 2023 19:29:20 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D0=B1=D0=B0=D0=B3=D0=B8=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B8=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D0=B8=20?= =?UTF-8?q?=D0=B8=D0=BD=D1=81=D1=82=D1=80=D1=83=D0=BC=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/IssueCompanyService.java | 41 +++++++----- .../gatewayapi/service/SecurityService.java | 31 +++++---- .../service/processor/CompanyProcessor.java | 65 ++++++++++--------- .../service/processor/ListingMMProcessor.java | 22 ++++--- 4 files changed, 86 insertions(+), 73 deletions(-) diff --git a/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/service/IssueCompanyService.java b/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/service/IssueCompanyService.java index 91e4070d8..dedc8c53e 100644 --- a/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/service/IssueCompanyService.java +++ b/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/service/IssueCompanyService.java @@ -13,6 +13,7 @@ import ru.spcex.clearing.platform.messaging.domain.cud.company.CompanySymbolNewR import ru.spcex.clearing.platform.messaging.domain.cud.company.ContactNewRequest; import ru.spcex.clearing.platform.messaging.domain.cud.company.SecurityMkrGatewayRequest; import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender; +import ru.spcex.platform.utils.log.ExceptionUtils; import java.util.List; import java.util.UUID; @@ -34,28 +35,32 @@ public class IssueCompanyService { public void sendRequest(FondListingsRequest request) { List issuerCompanyList = request.getIssuerCompanyList(); for (IssuerCompany issuerCompany : issuerCompanyList) { - UUID companyId = issuerCompany.getId(); - log.debug("Grouping by companyId: {}", companyId); - List issuerCompanySymbolsList = groupByCompanyId(request.getIssuerCompanySymbolsList(), companyId); - List issuerContactList = groupByCompanyId(request.getIssuerContactList(), companyId); + try { + UUID companyId = issuerCompany.getId(); + log.debug("Grouping by companyId: {}", companyId); + List issuerCompanySymbolsList = groupByCompanyId(request.getIssuerCompanySymbolsList(), companyId); + List issuerContactList = groupByCompanyId(request.getIssuerContactList(), companyId); - List companySymbolNewRequests = issuerCompanySymbolsList.stream(). - map(issuerCompanyRequestAdapter::toCompanySymbolRequest).toList(); - List contactNewRequests = issuerContactList.stream(). - map(issuerCompanyRequestAdapter::toContactRequest).toList(); + List companySymbolNewRequests = issuerCompanySymbolsList.stream(). + map(issuerCompanyRequestAdapter::toCompanySymbolRequest).toList(); + List contactNewRequests = issuerContactList.stream(). + map(issuerCompanyRequestAdapter::toContactRequest).toList(); - SecurityMkrGatewayRequest securityMkrGatewayRequest = new SecurityMkrGatewayRequest(); - securityMkrGatewayRequest.setCompanyNewRequest(issuerCompanyRequestAdapter.toCompanyRequest(issuerCompany)); - securityMkrGatewayRequest.setCompanySymbolNewRequests(companySymbolNewRequests); - securityMkrGatewayRequest.setContactNewRequests(contactNewRequests); - request.getIssuerCompanyInfoList() - .stream() - .filter(info -> info.getCompanyId().equals(companyId)).findFirst() - .map(issuerCompanyRequestAdapter::toCompanyInfoRequest) - .ifPresent(securityMkrGatewayRequest::setCompanyInfoUpdateRequest); + SecurityMkrGatewayRequest securityMkrGatewayRequest = new SecurityMkrGatewayRequest(); + securityMkrGatewayRequest.setCompanyNewRequest(issuerCompanyRequestAdapter.toCompanyRequest(issuerCompany)); + securityMkrGatewayRequest.setCompanySymbolNewRequests(companySymbolNewRequests); + securityMkrGatewayRequest.setContactNewRequests(contactNewRequests); + request.getIssuerCompanyInfoList() + .stream() + .filter(info -> info.getCompanyId().equals(companyId)).findFirst() + .map(issuerCompanyRequestAdapter::toCompanyInfoRequest) + .ifPresent(securityMkrGatewayRequest::setCompanyInfoUpdateRequest); - //todo реализовать на стороне security-service обработку и правильную группировку + //todo реализовать на стороне security-service обработку и правильную группировку // kafkaSender.sendRequestToQueue(Consts.DESTINATION_ISSUER_COMPANY_GATEWAY_REQUEST, securityMkrGatewayRequest); + } catch (Throwable e) { + log.error("{}", ExceptionUtils.getStackTrace(e)); + } } } diff --git a/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/service/SecurityService.java b/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/service/SecurityService.java index 3685c037d..104937996 100644 --- a/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/service/SecurityService.java +++ b/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/service/SecurityService.java @@ -35,22 +35,22 @@ public class SecurityService { public void sendRequest(FondListingsRequest request) { List securityList = request.getSecurities(); for (FondSecurity security : securityList) { - log.debug("process security uuid: {}", security.getId()); - UUID securityId = security.getId(); - log.debug("Grouping by securityId: {}", securityId); - List incomeListings = groupByCompanyId(request.getListingList(), securityId); - List couponSchedules = groupByCompanyId(request.getCouponSchedules(), securityId); - List nominals = groupByCompanyId(request.getNominalList(), securityId); - - List listingRequests = incomeListings.stream(). - map(securityRequestAdapter::toIncomeListing).toList(); - List couponPeriodRequests = couponSchedules.stream(). - map(securityRequestAdapter::toCouponPeriodRequest).toList(); - List cashFlowRequests = nominals.stream(). - map(securityRequestAdapter::toFixedIncomeCashFlowRequest).toList(); - - SecurityFondGatewayRequest securityGatewayRequest; try { + log.debug("process security uuid: {}", security.getId()); + UUID securityId = security.getId(); + log.debug("Grouping by securityId: {}", securityId); + List incomeListings = groupByCompanyId(request.getListingList(), securityId); + List couponSchedules = groupByCompanyId(request.getCouponSchedules(), securityId); + List nominals = groupByCompanyId(request.getNominalList(), securityId); + + List listingRequests = incomeListings.stream(). + map(securityRequestAdapter::toIncomeListing).toList(); + List couponPeriodRequests = couponSchedules.stream(). + map(securityRequestAdapter::toCouponPeriodRequest).toList(); + List cashFlowRequests = nominals.stream(). + map(securityRequestAdapter::toFixedIncomeCashFlowRequest).toList(); + + SecurityFondGatewayRequest securityGatewayRequest; if (InstrumentType.BOND.equalsByKey(security.getInstrumentType())) { FixedIncomeSecurityNewRequest fixedIncomeSecurityNewRequest = securityRequestAdapter.toFixedIncomeSecurityRequest(security); securityGatewayRequest = new FixedIncomeGatewayRequest(fixedIncomeSecurityNewRequest); @@ -67,7 +67,6 @@ public class SecurityService { } catch (Throwable e) { log.error("{}", ExceptionUtils.getStackTrace(e)); } - } } diff --git a/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/service/processor/CompanyProcessor.java b/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/service/processor/CompanyProcessor.java index eead7f7ec..2635f1704 100644 --- a/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/service/processor/CompanyProcessor.java +++ b/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/service/processor/CompanyProcessor.java @@ -10,6 +10,7 @@ import ru.spcex.clearing.platform.messaging.domain.Consts; import ru.spcex.clearing.platform.messaging.domain.cud.account.ClientCodeNewRequest; import ru.spcex.clearing.platform.messaging.domain.cud.company.*; import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender; +import ru.spcex.platform.utils.log.ExceptionUtils; import java.util.List; import java.util.UUID; @@ -31,39 +32,43 @@ public class CompanyProcessor { public void process(CompaniesRequest request) { List companyList = request.getCompanyList(); for (Company memberCompany : companyList) { - UUID companyId = memberCompany.getId(); - log.debug("Grouping by companyId: {}", companyId); - List companyClearingCategories = groupByCompanyId(request.getCompanyClearingCategoryList(), companyId); - List companySymbols = groupByCompanyId(request.getMemberCompanySymbolsList(), companyId); - List contacts = groupByCompanyId(request.getContactList(), companyId); - List profileDocuments = groupByCompanyId(request.getProfileDocumentList(), companyId); - List clients = groupByCompanyId(request.getClientList(), companyId); + try { + UUID companyId = memberCompany.getId(); + log.debug("Grouping by companyId: {}", companyId); + List companyClearingCategories = groupByCompanyId(request.getCompanyClearingCategoryList(), companyId); + List companySymbols = groupByCompanyId(request.getMemberCompanySymbolsList(), companyId); + List contacts = groupByCompanyId(request.getContactList(), companyId); + List profileDocuments = groupByCompanyId(request.getProfileDocumentList(), companyId); + List clients = groupByCompanyId(request.getClientList(), companyId); - List companySymbolNewRequests = companySymbols.stream(). - map(companyRequestAdapter::toCompanySymbolsRequest).toList(); - List contactNewRequests = contacts.stream(). - map(companyRequestAdapter::toContactRequest).toList(); - List profileDocumentNewRequests = profileDocuments.stream(). - map(companyRequestAdapter::toProfileDocumentRequest).toList(); - List clientCodeNewRequests = clients.stream(). - map(companyRequestAdapter::toClientRequest).toList(); - List categories = companyClearingCategories.stream(). - map(companyRequestAdapter::toCategoryRequest).toList(); + List companySymbolNewRequests = companySymbols.stream(). + map(companyRequestAdapter::toCompanySymbolsRequest).toList(); + List contactNewRequests = contacts.stream(). + map(companyRequestAdapter::toContactRequest).toList(); + List profileDocumentNewRequests = profileDocuments.stream(). + map(companyRequestAdapter::toProfileDocumentRequest).toList(); + List clientCodeNewRequests = clients.stream(). + map(companyRequestAdapter::toClientRequest).toList(); + List categories = companyClearingCategories.stream(). + map(companyRequestAdapter::toCategoryRequest).toList(); - CompanyGatewayRequest companyGatewayRequest = new CompanyGatewayRequest(); - companyGatewayRequest.setCompany(companyRequestAdapter.toCompanyRequest(memberCompany)); - request.getCompanyInfoList() - .stream() - .filter(info -> info.getCompanyId().equals(companyId)).findFirst() - .map(companyRequestAdapter::toCompanyInfoRequest) - .ifPresent(companyGatewayRequest::setCompanyInfo); - companyGatewayRequest.setCompanySymbols(companySymbolNewRequests); - companyGatewayRequest.setContacts(contactNewRequests); - companyGatewayRequest.setProfileDocuments(profileDocumentNewRequests); - companyGatewayRequest.setClientCodes(clientCodeNewRequests); - companyGatewayRequest.setCategories(categories); + CompanyGatewayRequest companyGatewayRequest = new CompanyGatewayRequest(); + companyGatewayRequest.setCompany(companyRequestAdapter.toCompanyRequest(memberCompany)); + request.getCompanyInfoList() + .stream() + .filter(info -> info.getCompanyId().equals(companyId)).findFirst() + .map(companyRequestAdapter::toCompanyInfoRequest) + .ifPresent(companyGatewayRequest::setCompanyInfo); + companyGatewayRequest.setCompanySymbols(companySymbolNewRequests); + companyGatewayRequest.setContacts(contactNewRequests); + companyGatewayRequest.setProfileDocuments(profileDocumentNewRequests); + companyGatewayRequest.setClientCodes(clientCodeNewRequests); + companyGatewayRequest.setCategories(categories); - kafkaSender.sendRequestToQueue(Consts.DESTINATION_COMPANY_GATEWAY_REQUEST, companyGatewayRequest); + kafkaSender.sendRequestToQueue(Consts.DESTINATION_COMPANY_GATEWAY_REQUEST, companyGatewayRequest); + } catch (Throwable e) { + log.error("{}", ExceptionUtils.getStackTrace(e)); + } } } diff --git a/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/service/processor/ListingMMProcessor.java b/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/service/processor/ListingMMProcessor.java index 9220e4a4d..db61f6561 100644 --- a/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/service/processor/ListingMMProcessor.java +++ b/clearing-parent/gateway-api/src/main/java/ru/spcex/clearing/gatewayapi/service/processor/ListingMMProcessor.java @@ -10,6 +10,7 @@ import ru.spcex.clearing.gatewayapi.service.adapter.MoneyMarketSecurityRequestAd import ru.spcex.clearing.platform.messaging.domain.Consts; import ru.spcex.clearing.platform.messaging.domain.cud.securitites.MoneyMarketSecurityNewRequest; import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender; +import ru.spcex.platform.utils.log.ExceptionUtils; import java.util.List; import java.util.UUID; @@ -30,16 +31,19 @@ public class ListingMMProcessor { public void process(MMListingsRequest request) { List exchangeInstrumentList = request.getExchangeInstrumentList(); for (ExchangeInstrument exchangeInstrument : exchangeInstrumentList) { - UUID exchangeInstrumentId = exchangeInstrument.getId(); - log.debug("Process exchangeInstrumentId : {}", exchangeInstrumentId); - if (StringUtils.isEmpty(exchangeInstrument.getCode()) || exchangeInstrument.getCode().length() < 6) { - log.warn("Incorrect code : {}, skip record", exchangeInstrument.getCode()); + try { + UUID exchangeInstrumentId = exchangeInstrument.getId(); + log.debug("Process exchangeInstrumentId : {}", exchangeInstrumentId); + if (StringUtils.isEmpty(exchangeInstrument.getCode()) || exchangeInstrument.getCode().length() < 6) { + log.warn("Incorrect code : {}, skip record", exchangeInstrument.getCode()); + continue; + } + MoneyMarketSecurityNewRequest moneyMarketSecurityNewRequest = moneyMarketSecurityRequestAdapter + .toMoneyMarketSecurityNewRequest(exchangeInstrument); + kafkaSender.sendRequestToQueue(Consts.DESTINATION_GATEWAY_MONEY_MARKET_SECURITY, moneyMarketSecurityNewRequest); + } catch (Throwable e) { + log.error("{}", ExceptionUtils.getStackTrace(e)); } - - MoneyMarketSecurityNewRequest moneyMarketSecurityNewRequest = moneyMarketSecurityRequestAdapter - .toMoneyMarketSecurityNewRequest(exchangeInstrument); - - kafkaSender.sendRequestToQueue(Consts.DESTINATION_GATEWAY_MONEY_MARKET_SECURITY, moneyMarketSecurityNewRequest); } } }