This commit is contained in:
parent
a35b19467a
commit
e00cc21a58
7 changed files with 81 additions and 85 deletions
|
|
@ -0,0 +1,22 @@
|
||||||
|
package ru.spcex.clearing.gatewayapi.config.deserializers;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import com.fasterxml.jackson.core.JsonParser;
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||||
|
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||||
|
|
||||||
|
public class LocalDateTimeDeserializer extends JsonDeserializer<LocalDateTime> {
|
||||||
|
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm:ss:SSS");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LocalDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
|
||||||
|
String date = p.getText();
|
||||||
|
if (date == null || date.trim().length() == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return LocalDateTime.parse(date, formatter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,10 +4,13 @@ import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
|
import ru.spcex.clearing.gatewayapi.config.deserializers.LocalDateTimeDeserializer;
|
||||||
|
|
||||||
public class TkrRequest {
|
public class TkrRequest {
|
||||||
@JsonProperty("id")
|
@JsonProperty("id")
|
||||||
private UUID id;
|
private UUID id;
|
||||||
|
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
|
||||||
@JsonProperty("datetime")
|
@JsonProperty("datetime")
|
||||||
private LocalDateTime datetime;
|
private LocalDateTime datetime;
|
||||||
@JsonProperty("type")
|
@JsonProperty("type")
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ public enum OutboundRequestType implements IEnumKey {
|
||||||
PFX65("PFX65"),
|
PFX65("PFX65"),
|
||||||
REPORT_KS_TMP("REPORT_KS_TMP"),
|
REPORT_KS_TMP("REPORT_KS_TMP"),
|
||||||
REPORT_KS_FINAL("REPORT_KS_FINAL"),
|
REPORT_KS_FINAL("REPORT_KS_FINAL"),
|
||||||
|
MEMBER_RESPONSE_TKR("MEMBER_RESPONSE_TKR"),
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String key;
|
private final String key;
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ import ru.spcex.clearing.platform.messaging.domain.cud.clearing.AssetOperationRe
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.gateway.GatewayTaskRequest;
|
import ru.spcex.clearing.platform.messaging.domain.cud.gateway.GatewayTaskRequest;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.gateway.ReportPart;
|
import ru.spcex.clearing.platform.messaging.domain.cud.gateway.ReportPart;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.gateway.SendReportRequest;
|
import ru.spcex.clearing.platform.messaging.domain.cud.gateway.SendReportRequest;
|
||||||
|
import ru.spcex.clearing.platform.messaging.domain.cud.gateway.SendTkrRequest;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.utilities.LimExportedRequest;
|
import ru.spcex.clearing.platform.messaging.domain.cud.utilities.LimExportedRequest;
|
||||||
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;
|
||||||
|
|
@ -84,20 +85,23 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() throws Exception {
|
||||||
callback(GatewayTaskRequest.class)
|
callback(GatewayTaskRequest.class)
|
||||||
.setConsumer(this::requestOnDemandCompany)
|
.setConsumer(this::requestOnDemandCompany)
|
||||||
.forDestination(Task.loadParty_LOCM.topic(), callbacks::put);
|
.forDestination(Task.loadParty_LOCM.topic(), callbacks::put);
|
||||||
callback(GatewayTaskRequest.class)
|
callback(GatewayTaskRequest.class)
|
||||||
.setConsumer(this::requestOnDemandSecurity)
|
.setConsumer(this::requestOnDemandSecurity)
|
||||||
.forDestination(Task.loadIssue_LOSC.topic(), callbacks::put);
|
.forDestination(Task.loadIssue_LOSC.topic(), callbacks::put);
|
||||||
callback(LimExportedRequest.class)
|
callback(LimExportedRequest.class)
|
||||||
.setConsumer(this::requestOnLimit)
|
.setConsumer(this::requestOnLimit)
|
||||||
.forDestination(Consts.LIM_EXPORTED, callbacks::put);
|
.forDestination(Consts.LIM_EXPORTED, callbacks::put);
|
||||||
callback(AssetOperationListRequest.class)
|
callback(AssetOperationListRequest.class)
|
||||||
.setConsumer(this::requestOnAsset)
|
.setConsumer(this::requestOnAsset)
|
||||||
.forDestination(Consts.ASSET_OPERATION, callbacks::put);
|
.forDestination(Consts.ASSET_OPERATION, callbacks::put);
|
||||||
callback(SendReportRequest.class)
|
callback(SendReportRequest.class)
|
||||||
.setConsumer(this::requestOnReport)
|
.setConsumer(this::requestOnReport)
|
||||||
.forDestination(Consts.REPORTS_TO_GATEWAY, callbacks::put);
|
.forDestination(Consts.REPORTS_TO_GATEWAY, callbacks::put);
|
||||||
|
callback(SendTkrRequest.class)
|
||||||
|
.setConsumer(this::requestOnTkr)
|
||||||
|
.forDestination(Consts.ACCOUNTS_TO_GATEWAY, callbacks::put);
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -112,8 +116,8 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
|
||||||
String url = formingInboundUrl(inboundServerSettings.getPathLOCM());
|
String url = formingInboundUrl(inboundServerSettings.getPathLOCM());
|
||||||
|
|
||||||
OutboundRequest outboundFondRequest = OutboundRequestBuilder.builder()
|
OutboundRequest outboundFondRequest = OutboundRequestBuilder.builder()
|
||||||
.type(OutboundRequestType.MEMBER_ON_DEMAND.getKey())
|
.type(OutboundRequestType.MEMBER_ON_DEMAND.getKey())
|
||||||
.build();
|
.build();
|
||||||
HttpEntity<OutboundRequest> request = makeDefaultRequest(outboundFondRequest);
|
HttpEntity<OutboundRequest> request = makeDefaultRequest(outboundFondRequest);
|
||||||
|
|
||||||
outboundRequestByUuid.put(outboundFondRequest.getId(), outboundFondRequest);
|
outboundRequestByUuid.put(outboundFondRequest.getId(), outboundFondRequest);
|
||||||
|
|
@ -131,10 +135,10 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
|
||||||
Map<String, Object> content = Map.of("file", exportedRequest.getLimFileName());
|
Map<String, Object> content = Map.of("file", exportedRequest.getLimFileName());
|
||||||
|
|
||||||
OutboundRequest outboundFondRequest = OutboundRequestBuilder.builder()
|
OutboundRequest outboundFondRequest = OutboundRequestBuilder.builder()
|
||||||
.section(exportedRequest.getSection())
|
.section(exportedRequest.getSection())
|
||||||
.type(OutboundRequestType.FILL_LIMITS.getKey())
|
.type(OutboundRequestType.FILL_LIMITS.getKey())
|
||||||
.content(content)
|
.content(content)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
HttpEntity<OutboundRequest> request = makeDefaultRequest(outboundFondRequest);
|
HttpEntity<OutboundRequest> request = makeDefaultRequest(outboundFondRequest);
|
||||||
outboundRequestByUuid.put(outboundFondRequest.getId(), outboundFondRequest);
|
outboundRequestByUuid.put(outboundFondRequest.getId(), outboundFondRequest);
|
||||||
|
|
@ -157,19 +161,19 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
|
||||||
String url = formingInboundUrl(inboundServerSettings.getPathLOCM());
|
String url = formingInboundUrl(inboundServerSettings.getPathLOCM());
|
||||||
|
|
||||||
OutboundRequest outboundFondRequest = OutboundRequestBuilder.builder()
|
OutboundRequest outboundFondRequest = OutboundRequestBuilder.builder()
|
||||||
.section(Section.FOND.getKey())
|
.section(Section.FOND.getKey())
|
||||||
.type(OutboundRequestType.ON_DEMAND.getKey())
|
.type(OutboundRequestType.ON_DEMAND.getKey())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
OutboundRequest outboundMkrRequest = OutboundRequestBuilder.builder()
|
OutboundRequest outboundMkrRequest = OutboundRequestBuilder.builder()
|
||||||
.section(Section.MKR.getKey())
|
.section(Section.MKR.getKey())
|
||||||
.type(OutboundRequestType.ON_DEMAND.getKey())
|
.type(OutboundRequestType.ON_DEMAND.getKey())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
OutboundRequest outboundCurrRequest = OutboundRequestBuilder.builder()
|
OutboundRequest outboundCurrRequest = OutboundRequestBuilder.builder()
|
||||||
.section(Section.CURR.getKey())
|
.section(Section.CURR.getKey())
|
||||||
.type(OutboundRequestType.ON_DEMAND.getKey())
|
.type(OutboundRequestType.ON_DEMAND.getKey())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
HttpEntity<OutboundRequest> requestFond = makeDefaultRequest(outboundFondRequest);
|
HttpEntity<OutboundRequest> requestFond = makeDefaultRequest(outboundFondRequest);
|
||||||
HttpEntity<OutboundRequest> requestMKR = makeDefaultRequest(outboundMkrRequest);
|
HttpEntity<OutboundRequest> requestMKR = makeDefaultRequest(outboundMkrRequest);
|
||||||
|
|
@ -215,9 +219,9 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
|
||||||
}
|
}
|
||||||
|
|
||||||
OutboundRequest outboundRequest = OutboundRequestBuilder.builder()
|
OutboundRequest outboundRequest = OutboundRequestBuilder.builder()
|
||||||
.section(assetOperation.getAmount() != null ? Section.MKR.getKey() : Section.FOND.getKey())
|
.section(assetOperation.getAmount() != null ? Section.MKR.getKey() : Section.FOND.getKey())
|
||||||
.type(OutboundRequestType.ASSET_OPERATION.getKey())
|
.type(OutboundRequestType.ASSET_OPERATION.getKey())
|
||||||
.content(content).build();
|
.content(content).build();
|
||||||
|
|
||||||
gatewayBuilder.outboundRequest(outboundRequest);
|
gatewayBuilder.outboundRequest(outboundRequest);
|
||||||
String url = formingInboundUrl(inboundServerSettings.getPathLOCM());
|
String url = formingInboundUrl(inboundServerSettings.getPathLOCM());
|
||||||
|
|
@ -254,9 +258,9 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
|
||||||
Map<String, Object> content = new HashMap<>();
|
Map<String, Object> content = new HashMap<>();
|
||||||
reportRequest.getReports().forEach(reportPart -> makeContentByReportRequest(content, reportPart));
|
reportRequest.getReports().forEach(reportPart -> makeContentByReportRequest(content, reportPart));
|
||||||
OutboundRequest outboundRequest = OutboundRequestBuilder.builder()
|
OutboundRequest outboundRequest = OutboundRequestBuilder.builder()
|
||||||
.section(Section.FOND.getKey())
|
.section(Section.FOND.getKey())
|
||||||
.type(reportType.getKey())
|
.type(reportType.getKey())
|
||||||
.content(content).build();
|
.content(content).build();
|
||||||
|
|
||||||
String url = formingInboundUrl(inboundServerSettings.getPathLOCM());
|
String url = formingInboundUrl(inboundServerSettings.getPathLOCM());
|
||||||
HttpEntity<OutboundRequest> r = makeDefaultRequest(outboundRequest);
|
HttpEntity<OutboundRequest> r = makeDefaultRequest(outboundRequest);
|
||||||
|
|
@ -267,21 +271,17 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void requestOnTkr(BaseRequest<SendReportRequest> request) {
|
public void requestOnTkr(BaseRequest<SendTkrRequest> request) {
|
||||||
SendReportRequest reportRequest = request.getRequestPayload();
|
SendTkrRequest reportRequest = request.getRequestPayload();
|
||||||
ReportType reportType = IEnumKey.getEnumByKey(ReportType.class, reportRequest.getType());
|
|
||||||
if (reportType == null) {
|
|
||||||
log.warn("Undefined type of request: {}; skip", reportRequest.getType());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Object> content = new HashMap<>();
|
Map<String, Object> content = new HashMap<>();
|
||||||
reportRequest.getReports().forEach(reportPart -> makeContentByReportRequest(content, reportPart));
|
content.put("tkr_list", reportRequest.getTkrs());
|
||||||
OutboundRequest outboundRequest = OutboundRequestBuilder.builder()
|
OutboundRequest outboundRequest = OutboundRequestBuilder.builder()
|
||||||
.section(Section.FOND.getKey())
|
.type(OutboundRequestType.MEMBER_RESPONSE_TKR.getKey())
|
||||||
.type(reportType.getKey())
|
.content(content)
|
||||||
.content(content).build();
|
.build();
|
||||||
|
if (reportRequest.getRequestId() != null) {
|
||||||
|
outboundRequest.setId(reportRequest.getRequestId());
|
||||||
|
}
|
||||||
String url = formingInboundUrl(inboundServerSettings.getPathLOCM());
|
String url = formingInboundUrl(inboundServerSettings.getPathLOCM());
|
||||||
HttpEntity<OutboundRequest> r = makeDefaultRequest(outboundRequest);
|
HttpEntity<OutboundRequest> r = makeDefaultRequest(outboundRequest);
|
||||||
ResponseEntity<SuccessResponse> response = restTemplate.exchange(url, HttpMethod.POST, r, SuccessResponse.class);
|
ResponseEntity<SuccessResponse> response = restTemplate.exchange(url, HttpMethod.POST, r, SuccessResponse.class);
|
||||||
|
|
@ -322,10 +322,10 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
|
||||||
|
|
||||||
public String formingInboundUrl(String path) {
|
public String formingInboundUrl(String path) {
|
||||||
return "%s://%s:%s/%s".formatted(
|
return "%s://%s:%s/%s".formatted(
|
||||||
inboundServerSettings.getEnableSsl() ? "https" : "http",
|
inboundServerSettings.getEnableSsl() ? "https" : "http",
|
||||||
inboundServerSettings.getHost(),
|
inboundServerSettings.getHost(),
|
||||||
inboundServerSettings.getPort(),
|
inboundServerSettings.getPort(),
|
||||||
path
|
path
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ import org.springframework.stereotype.Service;
|
||||||
import ru.spcex.clearing.gatewayapi.controller.inbound.request.tkr.request.TkrRequest;
|
import ru.spcex.clearing.gatewayapi.controller.inbound.request.tkr.request.TkrRequest;
|
||||||
import ru.spcex.clearing.gatewayapi.service.adapter.TkrAdapter;
|
import ru.spcex.clearing.gatewayapi.service.adapter.TkrAdapter;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.gateway.TkrAccount;
|
import ru.spcex.clearing.platform.messaging.domain.cud.account.TkrAccount;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.gateway.TkrAccountsResponse;
|
import ru.spcex.clearing.platform.messaging.domain.cud.account.TkrAccountsCheckRequest;
|
||||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
|
@ -23,8 +23,9 @@ public class TkrService {
|
||||||
public void processedTkrRequest(TkrRequest tkrRequest) {
|
public void processedTkrRequest(TkrRequest tkrRequest) {
|
||||||
List<TkrAccount> tkrAccounts = tkrRequest.getInfoAccount().stream()
|
List<TkrAccount> tkrAccounts = tkrRequest.getInfoAccount().stream()
|
||||||
.map(tkrAdapter::toTkrResponse).toList();
|
.map(tkrAdapter::toTkrResponse).toList();
|
||||||
TkrAccountsResponse tkrAccountsResponse = new TkrAccountsResponse();
|
TkrAccountsCheckRequest tkrAccountsCheckRequest = new TkrAccountsCheckRequest();
|
||||||
tkrAccountsResponse.setAccounts(tkrAccounts);
|
tkrAccountsCheckRequest.setRequestId(tkrRequest.getId());
|
||||||
kafkaSender.sendRequestToQueue(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_CHECK, tkrAccountsResponse);
|
tkrAccountsCheckRequest.setAccounts(tkrAccounts);
|
||||||
|
kafkaSender.sendRequestToQueue(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_CHECK, tkrAccountsCheckRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import org.springframework.stereotype.Service;
|
||||||
import ru.spcex.clearing.gatewayapi.controller.inbound.request.tkr.request.InfoAccount;
|
import ru.spcex.clearing.gatewayapi.controller.inbound.request.tkr.request.InfoAccount;
|
||||||
import ru.spcex.clearing.gatewayapi.controller.inbound.request.tkr.request.MoneyAccount;
|
import ru.spcex.clearing.gatewayapi.controller.inbound.request.tkr.request.MoneyAccount;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.gateway.MoneyAccountMsg;
|
import ru.spcex.clearing.platform.messaging.domain.cud.gateway.MoneyAccountMsg;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.gateway.TkrAccount;
|
import ru.spcex.clearing.platform.messaging.domain.cud.account.TkrAccount;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class TkrAdapter {
|
public class TkrAdapter {
|
||||||
|
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
package ru.spcex.clearing.gatewayapi.service.builders;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import ru.spcex.clearing.gatewayapi.controller.inbound.request.tkr.response.TkrElemResponse;
|
|
||||||
|
|
||||||
public class TkrListResultBuilder {
|
|
||||||
private final List<TkrElemResponse> tkrElems;
|
|
||||||
|
|
||||||
private TkrListResultBuilder() {
|
|
||||||
this.tkrElems = new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TkrListResultBuilder builder() {
|
|
||||||
return new TkrListResultBuilder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public TkrListResultBuilder elemOfList() {
|
|
||||||
TkrElemResponse tkrElemResponse = new TkrElemResponse();
|
|
||||||
tkrElems.add(tkrElemResponse);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, List<TkrElemResponse>> build() {
|
|
||||||
Map<String, List<TkrElemResponse>> map = new HashMap<>();
|
|
||||||
map.put("tkr_list", this.tkrElems);
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Reference in a new issue