This commit is contained in:
parent
e31453e293
commit
87f10edc26
16 changed files with 591 additions and 232 deletions
|
|
@ -18,6 +18,13 @@ public class GatewayApiSettings {
|
|||
private InboundServerSettings inboundServer;
|
||||
private InboundExternalServerSettings inboundExternalServer;
|
||||
private String clearingSystem;
|
||||
private String senderOrganizationCode;
|
||||
private String senderSubsystemCode;
|
||||
private String recipientOrganizationCode;
|
||||
private String senderCbRateTypeCode;
|
||||
private String senderSettleRateTypeCode;
|
||||
private String recipientCbRateTypeCode;
|
||||
private String recipientSettleRateTypeCode;
|
||||
private CurrencySpecificationFormat loadCurrencySpecificationFormat = CurrencySpecificationFormat.Massive;
|
||||
|
||||
public HazelcastClientParams getHazelcast() {
|
||||
|
|
@ -68,6 +75,62 @@ public class GatewayApiSettings {
|
|||
this.clearingSystem = clearingSystem;
|
||||
}
|
||||
|
||||
public String getSenderOrganizationCode() {
|
||||
return senderOrganizationCode;
|
||||
}
|
||||
|
||||
public void setSenderOrganizationCode(String senderOrganizationCode) {
|
||||
this.senderOrganizationCode = senderOrganizationCode;
|
||||
}
|
||||
|
||||
public String getSenderSubsystemCode() {
|
||||
return senderSubsystemCode;
|
||||
}
|
||||
|
||||
public void setSenderSubsystemCode(String senderSubsystemCode) {
|
||||
this.senderSubsystemCode = senderSubsystemCode;
|
||||
}
|
||||
|
||||
public String getRecipientOrganizationCode() {
|
||||
return recipientOrganizationCode;
|
||||
}
|
||||
|
||||
public void setRecipientOrganizationCode(String recipientOrganizationCode) {
|
||||
this.recipientOrganizationCode = recipientOrganizationCode;
|
||||
}
|
||||
|
||||
public String getSenderCbRateTypeCode() {
|
||||
return senderCbRateTypeCode;
|
||||
}
|
||||
|
||||
public void setSenderCbRateTypeCode(String senderCbRateTypeCode) {
|
||||
this.senderCbRateTypeCode = senderCbRateTypeCode;
|
||||
}
|
||||
|
||||
public String getSenderSettleRateTypeCode() {
|
||||
return senderSettleRateTypeCode;
|
||||
}
|
||||
|
||||
public void setSenderSettleRateTypeCode(String senderSettleRateTypeCode) {
|
||||
this.senderSettleRateTypeCode = senderSettleRateTypeCode;
|
||||
}
|
||||
|
||||
public String getRecipientCbRateTypeCode() {
|
||||
return recipientCbRateTypeCode;
|
||||
}
|
||||
|
||||
public void setRecipientCbRateTypeCode(String recipientCbRateTypeCode) {
|
||||
this.recipientCbRateTypeCode = recipientCbRateTypeCode;
|
||||
}
|
||||
|
||||
public String getRecipientSettleRateTypeCode() {
|
||||
return recipientSettleRateTypeCode;
|
||||
}
|
||||
|
||||
public void setRecipientSettleRateTypeCode(String recipientSettleRateTypeCode) {
|
||||
this.recipientSettleRateTypeCode = recipientSettleRateTypeCode;
|
||||
}
|
||||
|
||||
public CurrencySpecificationFormat getLoadCurrencySpecificationFormat() {
|
||||
return loadCurrencySpecificationFormat;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,12 +33,14 @@ import ru.spcex.clearing.gatewayapi.controller.inbound.request.listing.fond.Fond
|
|||
import ru.spcex.clearing.gatewayapi.controller.inbound.request.listing.fond.FondListingsRequest;
|
||||
import ru.spcex.clearing.gatewayapi.controller.inbound.request.listing.mkr.MMListingsRequest;
|
||||
import ru.spcex.clearing.gatewayapi.controller.inbound.request.operations.OperationsRequest;
|
||||
import ru.spcex.clearing.gatewayapi.controller.inbound.request.security.CurrencyRatesResponse;
|
||||
import ru.spcex.clearing.gatewayapi.controller.inbound.request.tkr.request.TkrRequest;
|
||||
import ru.spcex.clearing.gatewayapi.controller.inbound.response.CommonResponse;
|
||||
import ru.spcex.clearing.gatewayapi.enums.CurrencySpecificationFormat;
|
||||
import ru.spcex.clearing.gatewayapi.exception.GatewayException;
|
||||
import ru.spcex.clearing.gatewayapi.service.NotificationService;
|
||||
import ru.spcex.clearing.gatewayapi.service.OperationService;
|
||||
import ru.spcex.clearing.gatewayapi.service.RateService;
|
||||
import ru.spcex.clearing.gatewayapi.service.TkrService;
|
||||
import ru.spcex.clearing.gatewayapi.service.processor.CompanyProcessor;
|
||||
import ru.spcex.clearing.gatewayapi.service.processor.ListingCurrMassiveProcessor;
|
||||
|
|
@ -66,6 +68,7 @@ public class GatewayController {
|
|||
private final OperationService operationService;
|
||||
private final NotificationService notificationService;
|
||||
private final TkrService tkrService;
|
||||
private final RateService rateService;
|
||||
private final GatewayApiSettings gatewayApiSettings;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
|
|
@ -82,6 +85,7 @@ public class GatewayController {
|
|||
OperationService operationService,
|
||||
NotificationService notificationService,
|
||||
TkrService tkrService,
|
||||
RateService rateService,
|
||||
GatewayApiSettings gatewayApiSettings,
|
||||
ObjectMapper objectMapper) {
|
||||
this.messageResolver = messageResolver;
|
||||
|
|
@ -95,6 +99,7 @@ public class GatewayController {
|
|||
this.operationService = operationService;
|
||||
this.notificationService = notificationService;
|
||||
this.tkrService = tkrService;
|
||||
this.rateService = rateService;
|
||||
this.gatewayApiSettings = gatewayApiSettings;
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
|
@ -301,6 +306,29 @@ public class GatewayController {
|
|||
return createCommonResponse(request.getId());
|
||||
}
|
||||
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK", response = CommonResponse.class),
|
||||
@ApiResponse(code = 400, message = "Ошибка валидации", response = CommonResponse.class)
|
||||
})
|
||||
@RequestMapping(
|
||||
path = "/load_rate",
|
||||
method = RequestMethod.POST,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE
|
||||
)
|
||||
@ResponseBody
|
||||
public CommonResponse requestSecurity(@RequestBody CurrencyRatesResponse request) {
|
||||
log.debug("Received message: {}", request);
|
||||
executor.submit(() -> {
|
||||
try {
|
||||
rateService.processedRate(request);
|
||||
} catch (Throwable e) {
|
||||
log.error("At process /load_rate has error: {}", ExceptionUtils.getStackTrace(e));
|
||||
}
|
||||
});
|
||||
return createCommonResponse(request.getId());
|
||||
}
|
||||
|
||||
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
|
||||
@ResponseBody
|
||||
@ExceptionHandler(GatewayException.class)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,122 @@
|
|||
package ru.spcex.clearing.gatewayapi.controller.inbound.request.security;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import ru.spcex.clearing.gatewayapi.config.deserializers.LocalDateDeserializer;
|
||||
import ru.spcex.clearing.gatewayapi.config.deserializers.LocalDateTimeDeserializer;
|
||||
|
||||
public class CurrencyRate {
|
||||
|
||||
@JsonProperty
|
||||
private String type;
|
||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||
@JsonProperty("date")
|
||||
private LocalDate date;
|
||||
|
||||
@JsonProperty("base_currency_letter_code")
|
||||
private String baseCurrencyLetterCode;
|
||||
|
||||
@JsonProperty("associated_currency_letter_code")
|
||||
private String associatedCurrencyLetterCode;
|
||||
|
||||
private BigDecimal rate;
|
||||
|
||||
@JsonProperty("price_accuracy")
|
||||
private Integer priceAccuracy;
|
||||
|
||||
@JsonProperty("base_currency_unit")
|
||||
private Integer baseCurrencyUnit;
|
||||
|
||||
private BigDecimal price;
|
||||
|
||||
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
|
||||
@JsonProperty("update_date_time")
|
||||
private LocalDateTime updateDateTime;
|
||||
|
||||
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
|
||||
@JsonProperty("source_date_time")
|
||||
private LocalDateTime sourceDateTime;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public LocalDate getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(LocalDate date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public String getBaseCurrencyLetterCode() {
|
||||
return baseCurrencyLetterCode;
|
||||
}
|
||||
|
||||
public void setBaseCurrencyLetterCode(String baseCurrencyLetterCode) {
|
||||
this.baseCurrencyLetterCode = baseCurrencyLetterCode;
|
||||
}
|
||||
|
||||
public String getAssociatedCurrencyLetterCode() {
|
||||
return associatedCurrencyLetterCode;
|
||||
}
|
||||
|
||||
public void setAssociatedCurrencyLetterCode(String associatedCurrencyLetterCode) {
|
||||
this.associatedCurrencyLetterCode = associatedCurrencyLetterCode;
|
||||
}
|
||||
|
||||
public BigDecimal getRate() {
|
||||
return rate;
|
||||
}
|
||||
|
||||
public void setRate(BigDecimal rate) {
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
public Integer getPriceAccuracy() {
|
||||
return priceAccuracy;
|
||||
}
|
||||
|
||||
public void setPriceAccuracy(Integer priceAccuracy) {
|
||||
this.priceAccuracy = priceAccuracy;
|
||||
}
|
||||
|
||||
public Integer getBaseCurrencyUnit() {
|
||||
return baseCurrencyUnit;
|
||||
}
|
||||
|
||||
public void setBaseCurrencyUnit(Integer baseCurrencyUnit) {
|
||||
this.baseCurrencyUnit = baseCurrencyUnit;
|
||||
}
|
||||
|
||||
public BigDecimal getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(BigDecimal price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdateDateTime() {
|
||||
return updateDateTime;
|
||||
}
|
||||
|
||||
public void setUpdateDateTime(LocalDateTime updateDateTime) {
|
||||
this.updateDateTime = updateDateTime;
|
||||
}
|
||||
|
||||
public LocalDateTime getSourceDateTime() {
|
||||
return sourceDateTime;
|
||||
}
|
||||
|
||||
public void setSourceDateTime(LocalDateTime sourceDateTime) {
|
||||
this.sourceDateTime = sourceDateTime;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package ru.spcex.clearing.gatewayapi.controller.inbound.request.security;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CurrencyRatesResponse {
|
||||
private UUID id;
|
||||
|
||||
@JsonProperty("request_content")
|
||||
private RequestContent requestContent;
|
||||
|
||||
@JsonProperty("response_content")
|
||||
private ResponseContent responseContent;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public RequestContent getRequestContent() {
|
||||
return requestContent;
|
||||
}
|
||||
|
||||
public void setRequestContent(RequestContent requestContent) {
|
||||
this.requestContent = requestContent;
|
||||
}
|
||||
|
||||
public ResponseContent getResponseContent() {
|
||||
return responseContent;
|
||||
}
|
||||
|
||||
public void setResponseContent(ResponseContent responseContent) {
|
||||
this.responseContent = responseContent;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
package ru.spcex.clearing.gatewayapi.controller.inbound.request.security;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class RequestContent {
|
||||
@JsonProperty("sender_organization_code")
|
||||
private String senderOrganizationCode;
|
||||
|
||||
@JsonProperty("sender_subsystem_code")
|
||||
private String senderSubsystemCode;
|
||||
|
||||
@JsonProperty("recipient_organization_code")
|
||||
private String recipientOrganizationCode;
|
||||
|
||||
@JsonProperty("sender_rate_type_code")
|
||||
private String senderRateTypeCode;
|
||||
|
||||
@JsonProperty("recipient_rate_type_code")
|
||||
private String recipientRateTypeCode;
|
||||
|
||||
public String getSenderOrganizationCode() {
|
||||
return senderOrganizationCode;
|
||||
}
|
||||
|
||||
public void setSenderOrganizationCode(String senderOrganizationCode) {
|
||||
this.senderOrganizationCode = senderOrganizationCode;
|
||||
}
|
||||
|
||||
public String getSenderSubsystemCode() {
|
||||
return senderSubsystemCode;
|
||||
}
|
||||
|
||||
public void setSenderSubsystemCode(String senderSubsystemCode) {
|
||||
this.senderSubsystemCode = senderSubsystemCode;
|
||||
}
|
||||
|
||||
public String getRecipientOrganizationCode() {
|
||||
return recipientOrganizationCode;
|
||||
}
|
||||
|
||||
public void setRecipientOrganizationCode(String recipientOrganizationCode) {
|
||||
this.recipientOrganizationCode = recipientOrganizationCode;
|
||||
}
|
||||
|
||||
public String getSenderRateTypeCode() {
|
||||
return senderRateTypeCode;
|
||||
}
|
||||
|
||||
public void setSenderRateTypeCode(String senderRateTypeCode) {
|
||||
this.senderRateTypeCode = senderRateTypeCode;
|
||||
}
|
||||
|
||||
public String getRecipientRateTypeCode() {
|
||||
return recipientRateTypeCode;
|
||||
}
|
||||
|
||||
public void setRecipientRateTypeCode(String recipientRateTypeCode) {
|
||||
this.recipientRateTypeCode = recipientRateTypeCode;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package ru.spcex.clearing.gatewayapi.controller.inbound.request.security;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.util.List;
|
||||
|
||||
public class ResponseContent {
|
||||
@JsonProperty("currency_rates")
|
||||
private List<CurrencyRate> currencyRates;
|
||||
|
||||
public List<CurrencyRate> getCurrencyRates() {
|
||||
return currencyRates;
|
||||
}
|
||||
|
||||
public void setCurrencyRates(List<CurrencyRate> currencyRates) {
|
||||
this.currencyRates = currencyRates;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package ru.spcex.clearing.gatewayapi.service;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.spcex.clearing.gatewayapi.config.GatewayApiSettings;
|
||||
import ru.spcex.clearing.gatewayapi.controller.inbound.request.security.CurrencyRatesResponse;
|
||||
import ru.spcex.clearing.gatewayapi.controller.inbound.request.security.ResponseContent;
|
||||
import ru.spcex.clearing.gatewayapi.service.adapter.RateAdapter;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.gateway.rate.CurrencyRateGatewayElem;
|
||||
import ru.spcex.clearing.platform.messaging.domain.gateway.rate.SCrossRateGatewayRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.gateway.rate.RatesGatewayRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
|
||||
@Service
|
||||
public class RateService {
|
||||
private final KafkaSender kafkaSender;
|
||||
private final RateAdapter rateAdapter;
|
||||
private final GatewayApiSettings gatewayApiSettings;
|
||||
public RateService(KafkaSender kafkaSender,
|
||||
RateAdapter rateAdapter,
|
||||
GatewayApiSettings gatewayApiSettings) {
|
||||
this.kafkaSender = kafkaSender;
|
||||
this.rateAdapter = rateAdapter;
|
||||
this.gatewayApiSettings = gatewayApiSettings;
|
||||
}
|
||||
|
||||
public void processedRate(CurrencyRatesResponse currencyRatesResponse) {
|
||||
String recipientRateTypeCode = currencyRatesResponse.getRequestContent().getRecipientRateTypeCode();
|
||||
if (recipientRateTypeCode.equals(gatewayApiSettings.getRecipientCbRateTypeCode())) {
|
||||
sendSCrossRateReq(currencyRatesResponse.getResponseContent());
|
||||
} else if (recipientRateTypeCode.equals(gatewayApiSettings.getRecipientSettleRateTypeCode())) {
|
||||
sendRateReq(currencyRatesResponse.getResponseContent());
|
||||
}
|
||||
}
|
||||
|
||||
private void sendSCrossRateReq(ResponseContent responseContent) {
|
||||
List<CurrencyRateGatewayElem> sCrossReqs = responseContent.getCurrencyRates().stream()
|
||||
.filter(currencyRate -> currencyRate.getAssociatedCurrencyLetterCode().equals("RUB"))
|
||||
.map(rateAdapter::toRateGatewayElem)
|
||||
.toList();
|
||||
SCrossRateGatewayRequest sCrossRateGatewayRequest = new SCrossRateGatewayRequest();
|
||||
sCrossRateGatewayRequest.setCrossRateElems(sCrossReqs);
|
||||
kafkaSender.sendRequestToQueue(Consts.DESTINATION_S_CROSS_RATES_GATEWAY, sCrossRateGatewayRequest);
|
||||
}
|
||||
|
||||
private void sendRateReq(ResponseContent responseContent) {
|
||||
List<CurrencyRateGatewayElem> sCrossReqs = responseContent.getCurrencyRates().stream()
|
||||
.filter(currencyRate -> currencyRate.getAssociatedCurrencyLetterCode().equals("RUB"))
|
||||
.map(rateAdapter::toRateGatewayElem)
|
||||
.toList();
|
||||
RatesGatewayRequest ratesGatewayRequest = new RatesGatewayRequest();
|
||||
ratesGatewayRequest.setCurrencyRate(sCrossReqs);
|
||||
kafkaSender.sendRequestToQueue(Consts.DESTINATION_RATES_GATEWAY, ratesGatewayRequest);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package ru.spcex.clearing.gatewayapi.service.adapter;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.spcex.clearing.gatewayapi.controller.inbound.request.security.CurrencyRate;
|
||||
import ru.spcex.clearing.platform.messaging.domain.gateway.rate.CurrencyRateGatewayElem;
|
||||
|
||||
@Service
|
||||
public class RateAdapter {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
public CurrencyRateGatewayElem toRateGatewayElem(CurrencyRate currencyRate) {
|
||||
CurrencyRateGatewayElem request = new CurrencyRateGatewayElem();
|
||||
|
||||
request.setType(currencyRate.getType());
|
||||
request.setDate(currencyRate.getDate());
|
||||
request.setBaseCurrencyLetterCode(currencyRate.getBaseCurrencyLetterCode());
|
||||
request.setAssociatedCurrencyLetterCode(currencyRate.getAssociatedCurrencyLetterCode());
|
||||
request.setRate(currencyRate.getRate());
|
||||
request.setPriceAccuracy(currencyRate.getPriceAccuracy());
|
||||
request.setBaseCurrencyUnit(currencyRate.getBaseCurrencyUnit());
|
||||
request.setPrice(currencyRate.getPrice());
|
||||
request.setUpdateDateTime(currencyRate.getUpdateDateTime());
|
||||
request.setSourceDateTime(currencyRate.getSourceDateTime());
|
||||
return request;
|
||||
}
|
||||
}
|
||||
|
|
@ -27,6 +27,13 @@ gateway-api.kafka-consumer.buffer-memory=33554432
|
|||
|
||||
gateway-api.clearing-system=LCC
|
||||
gateway-api.load-currency-specification-format=Massive
|
||||
gateway-api.sender-organization-code=SPVB
|
||||
gateway-api.sender-subsystem-code=KS
|
||||
gateway-api.recipient-organization-code=SPVB
|
||||
gateway-api.sender-cb-rate-type-code=CB_RATE
|
||||
gateway-api.sender-settle-rate-type-code=SETTLE_RATE
|
||||
gateway-api.recipient-cb-rate-type-code=CBR_RATE
|
||||
gateway-api.recipient-settle-rate-type-code=NCC_RATE
|
||||
|
||||
gateway-api.inbound-server.enable-ssl=false
|
||||
gateway-api.inbound-server.host=10.200.200.183
|
||||
|
|
|
|||
|
|
@ -14,9 +14,10 @@ import ru.clearing.platform.dictionary.CurrencyCodeDictionary;
|
|||
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.security.RatesGatewayRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.security.RatesNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.security.RatesUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.gateway.rate.CurrencyRateGatewayElem;
|
||||
import ru.spcex.clearing.platform.messaging.domain.gateway.rate.RatesGatewayRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
||||
import ru.spcex.clearing.securities.service.facade.RatesFacade;
|
||||
|
|
@ -116,7 +117,7 @@ public class RatesMessageListener extends QueueConsumer implements InitializingB
|
|||
private void gatewayRatesRequest(BaseRequest<RatesGatewayRequest> ratesGatewayRequest) {
|
||||
RatesGatewayRequest payload = ratesGatewayRequest.getRequestPayload();
|
||||
|
||||
for (RatesGatewayRequest.RateElem elem : payload.getRateElems()) {
|
||||
for (CurrencyRateGatewayElem elem : payload.getCurrencyRate()) {
|
||||
ImdgPredicateBuilder predicateBuilder = ratesImdg.predicateBuilder();
|
||||
Collection<Long> rateIds = ratesImdg.getCollectionIdsByPredicate(
|
||||
predicateBuilder.and(
|
||||
|
|
@ -134,7 +135,7 @@ public class RatesMessageListener extends QueueConsumer implements InitializingB
|
|||
}
|
||||
}
|
||||
|
||||
private Optional<RatesNewRequest> toNewRequest(RatesGatewayRequest.RateElem sRateElem) {
|
||||
private Optional<RatesNewRequest> toNewRequest(CurrencyRateGatewayElem sRateElem) {
|
||||
RatesNewRequest newRequest = new RatesNewRequest();
|
||||
|
||||
CurrencyCodeDictionary currencyCodeDictionary = currencyByCode(sRateElem.getBaseCurrencyLetterCode());
|
||||
|
|
@ -148,7 +149,7 @@ public class RatesMessageListener extends QueueConsumer implements InitializingB
|
|||
return Optional.of(newRequest);
|
||||
}
|
||||
|
||||
private Optional<RatesUpdateRequest> toUpdateRequest(RatesGatewayRequest.RateElem sRateElem) {
|
||||
private Optional<RatesUpdateRequest> toUpdateRequest(CurrencyRateGatewayElem sRateElem) {
|
||||
RatesUpdateRequest updateRequest = new RatesUpdateRequest();
|
||||
|
||||
CurrencyCodeDictionary currencyCodeDictionary = currencyByCode(sRateElem.getBaseCurrencyLetterCode());
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
package ru.spcex.clearing.securities.service.listeners;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.util.Collection;
|
||||
import java.util.function.Function;
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -14,9 +12,10 @@ import ru.clearing.classes.statics.data.misc.SCrossRate;
|
|||
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.securitites.SCrossRateGatewayRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.securitites.SCrossRateNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.securitites.SCrossRateUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.gateway.rate.CurrencyRateGatewayElem;
|
||||
import ru.spcex.clearing.platform.messaging.domain.gateway.rate.SCrossRateGatewayRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.clearing.securities.service.facade.SCrossRateFacade;
|
||||
import ru.spcex.clearing.util.security.UserRoleVerification;
|
||||
|
|
@ -61,7 +60,7 @@ public class SCrossRatesMessageListener extends QueueConsumer implements Initial
|
|||
private void sCrossRatesProcess(BaseRequest<SCrossRateGatewayRequest> sCrossRatesReq) {
|
||||
SCrossRateGatewayRequest payload = sCrossRatesReq.getRequestPayload();
|
||||
|
||||
for (SCrossRateGatewayRequest.SCrossRateElem elem : payload.getCrossRateElems()) {
|
||||
for (CurrencyRateGatewayElem elem : payload.getCrossRateElems()) {
|
||||
ImdgPredicateBuilder predicateBuilder = sCrossRateImdg.predicateBuilder();
|
||||
Collection<Long> sCrossRateIds = sCrossRateImdg.getCollectionIdsByPredicate(
|
||||
predicateBuilder.and(
|
||||
|
|
@ -79,7 +78,7 @@ public class SCrossRatesMessageListener extends QueueConsumer implements Initial
|
|||
}
|
||||
}
|
||||
|
||||
private SCrossRateNewRequest toNewRequest(SCrossRateGatewayRequest.SCrossRateElem sCrossRateElem) {
|
||||
private SCrossRateNewRequest toNewRequest(CurrencyRateGatewayElem sCrossRateElem) {
|
||||
SCrossRateNewRequest newRequest = new SCrossRateNewRequest();
|
||||
newRequest.setDate(sCrossRateElem.getDate());
|
||||
newRequest.setCurrency(sCrossRateElem.getBaseCurrencyLetterCode());
|
||||
|
|
@ -89,39 +88,11 @@ public class SCrossRatesMessageListener extends QueueConsumer implements Initial
|
|||
return newRequest;
|
||||
}
|
||||
|
||||
private SCrossRateUpdateRequest toUpdateRequest(SCrossRateGatewayRequest.SCrossRateElem sCrossRateElem) {
|
||||
private SCrossRateUpdateRequest toUpdateRequest(CurrencyRateGatewayElem sCrossRateElem) {
|
||||
SCrossRateUpdateRequest updateRequest = new SCrossRateUpdateRequest();
|
||||
updateRequest.setUnitRate(sCrossRateElem.getRate());
|
||||
updateRequest.setFaceValue(BigDecimal.valueOf(sCrossRateElem.getBaseCurrencyUnit()));
|
||||
updateRequest.setRate(sCrossRateElem.getPrice());
|
||||
return updateRequest;
|
||||
}
|
||||
|
||||
private Function<SCrossRateGatewayRequest.SCrossRateElem, SCrossRate> findSCrossRate() {
|
||||
return req -> {
|
||||
ImdgPredicateBuilder predicateBuilder = sCrossRateImdg.predicateBuilder();
|
||||
Collection<Long> sCrossRateIds = sCrossRateImdg.getCollectionIdsByPredicate(
|
||||
predicateBuilder.and(
|
||||
predicateBuilder.equals("date", req.getDate()),
|
||||
predicateBuilder.equals("currency", req.getBaseCurrencyLetterCode())
|
||||
));
|
||||
SCrossRate sCrossRate;
|
||||
if (sCrossRateIds.isEmpty()) {
|
||||
log.debug("Not found any cross rate for date: {}, currency: {}",
|
||||
req.getDate(),
|
||||
req.getBaseCurrencyLetterCode());
|
||||
sCrossRate = new SCrossRate();
|
||||
sCrossRate.setCreated(Instant.now());
|
||||
} else {
|
||||
Long id = sCrossRateIds.iterator().next();
|
||||
log.debug("Found cross rate for date: {}, currency: {} with id: {}",
|
||||
req.getDate(),
|
||||
req.getBaseCurrencyLetterCode(),
|
||||
id);
|
||||
sCrossRate = sCrossRateImdg.getSingleObjectByID(sCrossRateIds.iterator().next());
|
||||
sCrossRate.setUpdated(Instant.now());
|
||||
}
|
||||
return sCrossRate;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,135 +0,0 @@
|
|||
package ru.spcex.clearing.platform.messaging.domain.cud.securitites;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import ru.spcex.clearing.platform.messaging.domain.json.deserialize.LocalDateDeserializer;
|
||||
import ru.spcex.clearing.platform.messaging.domain.json.serialize.LocalDateSerializer;
|
||||
|
||||
public class SCrossRateGatewayRequest {
|
||||
@JsonProperty
|
||||
private List<SCrossRateElem> crossRateElems;
|
||||
|
||||
public List<SCrossRateElem> getCrossRateElems() {
|
||||
return crossRateElems;
|
||||
}
|
||||
|
||||
public void setCrossRateElems(List<SCrossRateElem> crossRateElems) {
|
||||
this.crossRateElems = crossRateElems;
|
||||
}
|
||||
|
||||
public static class SCrossRateElem {
|
||||
@JsonProperty
|
||||
private String type;
|
||||
@JsonSerialize(using = LocalDateSerializer.class)
|
||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||
@JsonProperty
|
||||
private LocalDate date;
|
||||
@JsonProperty
|
||||
private String baseCurrencyLetterCode;
|
||||
@JsonProperty
|
||||
private String associatedCurrencyLetterCode;
|
||||
@JsonProperty
|
||||
private BigDecimal rate;
|
||||
@JsonProperty
|
||||
private Integer priceAccuracy;
|
||||
@JsonProperty
|
||||
private Integer baseCurrencyUnit;
|
||||
@JsonProperty
|
||||
private BigDecimal price;
|
||||
@JsonSerialize(using = LocalDateTimeSerializer.class)
|
||||
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
|
||||
@JsonProperty
|
||||
private LocalDateTime updateDateTime;
|
||||
@JsonSerialize(using = LocalDateTimeSerializer.class)
|
||||
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
|
||||
@JsonProperty
|
||||
private LocalDateTime sourceDateTime;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public LocalDate getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(LocalDate date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public String getBaseCurrencyLetterCode() {
|
||||
return baseCurrencyLetterCode;
|
||||
}
|
||||
|
||||
public void setBaseCurrencyLetterCode(String baseCurrencyLetterCode) {
|
||||
this.baseCurrencyLetterCode = baseCurrencyLetterCode;
|
||||
}
|
||||
|
||||
public String getAssociatedCurrencyLetterCode() {
|
||||
return associatedCurrencyLetterCode;
|
||||
}
|
||||
|
||||
public void setAssociatedCurrencyLetterCode(String associatedCurrencyLetterCode) {
|
||||
this.associatedCurrencyLetterCode = associatedCurrencyLetterCode;
|
||||
}
|
||||
|
||||
public BigDecimal getRate() {
|
||||
return rate;
|
||||
}
|
||||
|
||||
public void setRate(BigDecimal rate) {
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
public Integer getPriceAccuracy() {
|
||||
return priceAccuracy;
|
||||
}
|
||||
|
||||
public void setPriceAccuracy(Integer priceAccuracy) {
|
||||
this.priceAccuracy = priceAccuracy;
|
||||
}
|
||||
|
||||
public Integer getBaseCurrencyUnit() {
|
||||
return baseCurrencyUnit;
|
||||
}
|
||||
|
||||
public void setBaseCurrencyUnit(Integer baseCurrencyUnit) {
|
||||
this.baseCurrencyUnit = baseCurrencyUnit;
|
||||
}
|
||||
|
||||
public BigDecimal getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(BigDecimal price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdateDateTime() {
|
||||
return updateDateTime;
|
||||
}
|
||||
|
||||
public void setUpdateDateTime(LocalDateTime updateDateTime) {
|
||||
this.updateDateTime = updateDateTime;
|
||||
}
|
||||
|
||||
public LocalDateTime getSourceDateTime() {
|
||||
return sourceDateTime;
|
||||
}
|
||||
|
||||
public void setSourceDateTime(LocalDateTime sourceDateTime) {
|
||||
this.sourceDateTime = sourceDateTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
package ru.spcex.clearing.platform.messaging.domain.cud.security;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import ru.spcex.clearing.platform.messaging.domain.json.deserialize.LocalDateDeserializer;
|
||||
import ru.spcex.clearing.platform.messaging.domain.json.serialize.LocalDateSerializer;
|
||||
|
||||
public class RatesGatewayRequest {
|
||||
|
||||
@JsonProperty
|
||||
private List<RateElem> rateElems;
|
||||
|
||||
public List<RateElem> getRateElems() {
|
||||
return rateElems;
|
||||
}
|
||||
|
||||
public void setRateElems(List<RateElem> rateElems) {
|
||||
this.rateElems = rateElems;
|
||||
}
|
||||
|
||||
public static class RateElem {
|
||||
@JsonSerialize(using = LocalDateSerializer.class)
|
||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||
@JsonProperty
|
||||
private LocalDate date;
|
||||
@JsonProperty
|
||||
private String baseCurrencyLetterCode;
|
||||
@JsonProperty
|
||||
private BigDecimal price;
|
||||
|
||||
public LocalDate getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(LocalDate date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public String getBaseCurrencyLetterCode() {
|
||||
return baseCurrencyLetterCode;
|
||||
}
|
||||
|
||||
public void setBaseCurrencyLetterCode(String baseCurrencyLetterCode) {
|
||||
this.baseCurrencyLetterCode = baseCurrencyLetterCode;
|
||||
}
|
||||
|
||||
public BigDecimal getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(BigDecimal price) {
|
||||
this.price = price;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
package ru.spcex.clearing.platform.messaging.domain.gateway.rate;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import ru.spcex.clearing.platform.messaging.domain.json.deserialize.LocalDateDeserializer;
|
||||
import ru.spcex.clearing.platform.messaging.domain.json.serialize.LocalDateSerializer;
|
||||
|
||||
public class CurrencyRateGatewayElem {
|
||||
@JsonProperty
|
||||
private String type;
|
||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||
@JsonSerialize(using = LocalDateSerializer.class)
|
||||
@JsonProperty("date")
|
||||
private LocalDate date;
|
||||
|
||||
@JsonProperty("base_currency_letter_code")
|
||||
private String baseCurrencyLetterCode;
|
||||
|
||||
@JsonProperty("associated_currency_letter_code")
|
||||
private String associatedCurrencyLetterCode;
|
||||
|
||||
private BigDecimal rate;
|
||||
|
||||
@JsonProperty("price_accuracy")
|
||||
private Integer priceAccuracy;
|
||||
|
||||
@JsonProperty("base_currency_unit")
|
||||
private Integer baseCurrencyUnit;
|
||||
|
||||
private BigDecimal price;
|
||||
|
||||
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
|
||||
@JsonSerialize(using = LocalDateTimeSerializer.class)
|
||||
@JsonProperty("update_date_time")
|
||||
private LocalDateTime updateDateTime;
|
||||
|
||||
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
|
||||
@JsonSerialize(using = LocalDateTimeSerializer.class)
|
||||
@JsonProperty("source_date_time")
|
||||
private LocalDateTime sourceDateTime;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public LocalDate getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(LocalDate date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public String getBaseCurrencyLetterCode() {
|
||||
return baseCurrencyLetterCode;
|
||||
}
|
||||
|
||||
public void setBaseCurrencyLetterCode(String baseCurrencyLetterCode) {
|
||||
this.baseCurrencyLetterCode = baseCurrencyLetterCode;
|
||||
}
|
||||
|
||||
public String getAssociatedCurrencyLetterCode() {
|
||||
return associatedCurrencyLetterCode;
|
||||
}
|
||||
|
||||
public void setAssociatedCurrencyLetterCode(String associatedCurrencyLetterCode) {
|
||||
this.associatedCurrencyLetterCode = associatedCurrencyLetterCode;
|
||||
}
|
||||
|
||||
public BigDecimal getRate() {
|
||||
return rate;
|
||||
}
|
||||
|
||||
public void setRate(BigDecimal rate) {
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
public Integer getPriceAccuracy() {
|
||||
return priceAccuracy;
|
||||
}
|
||||
|
||||
public void setPriceAccuracy(Integer priceAccuracy) {
|
||||
this.priceAccuracy = priceAccuracy;
|
||||
}
|
||||
|
||||
public Integer getBaseCurrencyUnit() {
|
||||
return baseCurrencyUnit;
|
||||
}
|
||||
|
||||
public void setBaseCurrencyUnit(Integer baseCurrencyUnit) {
|
||||
this.baseCurrencyUnit = baseCurrencyUnit;
|
||||
}
|
||||
|
||||
public BigDecimal getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(BigDecimal price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdateDateTime() {
|
||||
return updateDateTime;
|
||||
}
|
||||
|
||||
public void setUpdateDateTime(LocalDateTime updateDateTime) {
|
||||
this.updateDateTime = updateDateTime;
|
||||
}
|
||||
|
||||
public LocalDateTime getSourceDateTime() {
|
||||
return sourceDateTime;
|
||||
}
|
||||
|
||||
public void setSourceDateTime(LocalDateTime sourceDateTime) {
|
||||
this.sourceDateTime = sourceDateTime;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package ru.spcex.clearing.platform.messaging.domain.gateway.rate;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.util.List;
|
||||
|
||||
public class RatesGatewayRequest {
|
||||
|
||||
@JsonProperty
|
||||
private List<CurrencyRateGatewayElem> currencyRate;
|
||||
|
||||
public List<CurrencyRateGatewayElem> getCurrencyRate() {
|
||||
return currencyRate;
|
||||
}
|
||||
|
||||
public void setCurrencyRate(List<CurrencyRateGatewayElem> currencyRate) {
|
||||
this.currencyRate = currencyRate;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package ru.spcex.clearing.platform.messaging.domain.gateway.rate;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.util.List;
|
||||
|
||||
public class SCrossRateGatewayRequest {
|
||||
@JsonProperty
|
||||
private List<CurrencyRateGatewayElem> crossRateElems;
|
||||
|
||||
public List<CurrencyRateGatewayElem> getCrossRateElems() {
|
||||
return crossRateElems;
|
||||
}
|
||||
|
||||
public void setCrossRateElems(List<CurrencyRateGatewayElem> crossRateElems) {
|
||||
this.crossRateElems = crossRateElems;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue