This commit is contained in:
parent
b1ce26ed89
commit
1bf0faf8d4
2 changed files with 18 additions and 7 deletions
|
|
@ -63,11 +63,11 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
|
||||||
private final RestTemplate restTemplate;
|
private final RestTemplate restTemplate;
|
||||||
private final InboundServerSettings inboundServerSettings;
|
private final InboundServerSettings inboundServerSettings;
|
||||||
private final InboundExternalServerSettings inboundExternalServerSettings;
|
private final InboundExternalServerSettings inboundExternalServerSettings;
|
||||||
private final GatewayApiSettings gatewayApiSettings;
|
|
||||||
private final Map<Long, List<SentAsset>> sentAssets;
|
private final Map<Long, List<SentAsset>> sentAssets;
|
||||||
private final Map<UUID, OutboundRequest> outboundRequestByUuid;
|
private final Map<UUID, OutboundRequest> outboundRequestByUuid;
|
||||||
protected final Imdg<GatewayResult> gatewayResultImdg;
|
protected final Imdg<GatewayResult> gatewayResultImdg;
|
||||||
private final static Pattern REPORT_FILE_NAME_PATTERN = Pattern.compile("(\\S*)_(\\d{15}).csv");
|
private final static Pattern REPORT_FILE_NAME_PATTERN = Pattern.compile("(\\S*)_(\\d{15}).csv");
|
||||||
|
private final String clearingSystemValue;
|
||||||
|
|
||||||
public GatewayService(Consumer<String, Object> kafkaQueue,
|
public GatewayService(Consumer<String, Object> kafkaQueue,
|
||||||
Producer<String, Object> kafkaProducer,
|
Producer<String, Object> kafkaProducer,
|
||||||
|
|
@ -80,7 +80,8 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
|
||||||
super(kafkaQueue, kafkaProducer);
|
super(kafkaQueue, kafkaProducer);
|
||||||
this.restTemplate = restTemplate;
|
this.restTemplate = restTemplate;
|
||||||
this.userRoleVerification = userRoleVerification;
|
this.userRoleVerification = userRoleVerification;
|
||||||
this.gatewayApiSettings = gatewayApiSettings;
|
this.clearingSystemValue = StringUtils.isNotEmpty(gatewayApiSettings.getClearingSystem()) ?
|
||||||
|
gatewayApiSettings.getClearingSystem() : "SPVB";
|
||||||
this.inboundServerSettings = gatewayApiSettings.getInboundServer();
|
this.inboundServerSettings = gatewayApiSettings.getInboundServer();
|
||||||
this.inboundExternalServerSettings = gatewayApiSettings.getInboundExternalServer();
|
this.inboundExternalServerSettings = gatewayApiSettings.getInboundExternalServer();
|
||||||
this.sentAssets = sentAssets;
|
this.sentAssets = sentAssets;
|
||||||
|
|
@ -120,6 +121,7 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
|
||||||
logUnknownProperties(userRequest);
|
logUnknownProperties(userRequest);
|
||||||
OutboundRequest outboundFondRequest = OutboundRequestBuilder.builder()
|
OutboundRequest outboundFondRequest = OutboundRequestBuilder.builder()
|
||||||
.type(OutboundRequestType.MEMBER_ON_DEMAND.getKey())
|
.type(OutboundRequestType.MEMBER_ON_DEMAND.getKey())
|
||||||
|
.clearingSystem(clearingSystemValue)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
outboundRequestByUuid.put(outboundFondRequest.getId(), outboundFondRequest);
|
outboundRequestByUuid.put(outboundFondRequest.getId(), outboundFondRequest);
|
||||||
|
|
@ -133,6 +135,7 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
|
||||||
OutboundRequest outboundFondRequest = OutboundRequestBuilder.builder()
|
OutboundRequest outboundFondRequest = OutboundRequestBuilder.builder()
|
||||||
.section(exportedRequest.getSection())
|
.section(exportedRequest.getSection())
|
||||||
.type(OutboundRequestType.FILL_LIMITS.getKey())
|
.type(OutboundRequestType.FILL_LIMITS.getKey())
|
||||||
|
.clearingSystem(clearingSystemValue)
|
||||||
.content(content)
|
.content(content)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
@ -152,16 +155,19 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
|
||||||
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())
|
||||||
|
.clearingSystem(clearingSystemValue)
|
||||||
.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())
|
||||||
|
.clearingSystem(clearingSystemValue)
|
||||||
.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())
|
||||||
|
.clearingSystem(clearingSystemValue)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
outboundRequestByUuid.put(outboundFondRequest.getId(), outboundFondRequest);
|
outboundRequestByUuid.put(outboundFondRequest.getId(), outboundFondRequest);
|
||||||
|
|
@ -198,6 +204,7 @@ 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())
|
||||||
|
.clearingSystem(clearingSystemValue)
|
||||||
.content(content).build();
|
.content(content).build();
|
||||||
|
|
||||||
gatewayBuilder.outboundRequest(outboundRequest);
|
gatewayBuilder.outboundRequest(outboundRequest);
|
||||||
|
|
@ -231,6 +238,7 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
|
||||||
OutboundRequest outboundRequest = OutboundRequestBuilder.builder()
|
OutboundRequest outboundRequest = OutboundRequestBuilder.builder()
|
||||||
.section(Section.FOND.getKey())
|
.section(Section.FOND.getKey())
|
||||||
.type(reportType.getKey())
|
.type(reportType.getKey())
|
||||||
|
.clearingSystem(clearingSystemValue)
|
||||||
.content(content).build();
|
.content(content).build();
|
||||||
|
|
||||||
sendRequest(outboundRequest);
|
sendRequest(outboundRequest);
|
||||||
|
|
@ -243,6 +251,7 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
|
||||||
OutboundRequest outboundRequest = OutboundRequestBuilder.builder()
|
OutboundRequest outboundRequest = OutboundRequestBuilder.builder()
|
||||||
.type(OutboundRequestType.MEMBER_RESPONSE_TKR.getKey())
|
.type(OutboundRequestType.MEMBER_RESPONSE_TKR.getKey())
|
||||||
.content(content)
|
.content(content)
|
||||||
|
.clearingSystem(clearingSystemValue)
|
||||||
.build();
|
.build();
|
||||||
if (reportRequest.getRequestId() != null) {
|
if (reportRequest.getRequestId() != null) {
|
||||||
outboundRequest.setId(reportRequest.getRequestId());
|
outboundRequest.setId(reportRequest.getRequestId());
|
||||||
|
|
@ -286,9 +295,6 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendRequest(OutboundRequest request) {
|
private void sendRequest(OutboundRequest request) {
|
||||||
String clearingSystem = StringUtils.isNotEmpty(gatewayApiSettings.getClearingSystem()) ?
|
|
||||||
gatewayApiSettings.getClearingSystem() : "SPVB";
|
|
||||||
request.setClearingSystem(clearingSystem);
|
|
||||||
if (inboundServerSettings != null &&
|
if (inboundServerSettings != null &&
|
||||||
(inboundServerSettings.getAllowedTypes().isEmpty() ||
|
(inboundServerSettings.getAllowedTypes().isEmpty() ||
|
||||||
inboundServerSettings.getAllowedTypes().contains(request.getType()))) {
|
inboundServerSettings.getAllowedTypes().contains(request.getType()))) {
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
package ru.spcex.clearing.gatewayapi.service.builders;
|
package ru.spcex.clearing.gatewayapi.service.builders;
|
||||||
|
|
||||||
import ru.spcex.clearing.gatewayapi.controller.outbound.request.OutboundRequest;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import ru.spcex.clearing.gatewayapi.controller.outbound.request.OutboundRequest;
|
||||||
|
|
||||||
public class OutboundRequestBuilder {
|
public class OutboundRequestBuilder {
|
||||||
|
|
||||||
private String section;
|
private String section;
|
||||||
private String requestType;
|
private String requestType;
|
||||||
|
private String clearingSystem;
|
||||||
private Map<String, Object> content;
|
private Map<String, Object> content;
|
||||||
|
|
||||||
private OutboundRequestBuilder() {
|
private OutboundRequestBuilder() {
|
||||||
|
|
@ -34,11 +34,16 @@ public class OutboundRequestBuilder {
|
||||||
this.content = content;
|
this.content = content;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
public OutboundRequestBuilder clearingSystem(String val) {
|
||||||
|
this.clearingSystem = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public OutboundRequest build() {
|
public OutboundRequest build() {
|
||||||
OutboundRequest outboundRequest = new OutboundRequest();
|
OutboundRequest outboundRequest = new OutboundRequest();
|
||||||
outboundRequest.setId(UUID.randomUUID());
|
outboundRequest.setId(UUID.randomUUID());
|
||||||
outboundRequest.setDatetime(Instant.now());
|
outboundRequest.setDatetime(Instant.now());
|
||||||
|
outboundRequest.setClearingSystem(clearingSystem);
|
||||||
if (section != null) {
|
if (section != null) {
|
||||||
outboundRequest.setSection(section);
|
outboundRequest.setSection(section);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue