etreschenkov 2024-10-15 13:43:10 +03:00
parent b1ce26ed89
commit 1bf0faf8d4
2 changed files with 18 additions and 7 deletions

View file

@ -63,11 +63,11 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
private final RestTemplate restTemplate;
private final InboundServerSettings inboundServerSettings;
private final InboundExternalServerSettings inboundExternalServerSettings;
private final GatewayApiSettings gatewayApiSettings;
private final Map<Long, List<SentAsset>> sentAssets;
private final Map<UUID, OutboundRequest> outboundRequestByUuid;
protected final Imdg<GatewayResult> gatewayResultImdg;
private final static Pattern REPORT_FILE_NAME_PATTERN = Pattern.compile("(\\S*)_(\\d{15}).csv");
private final String clearingSystemValue;
public GatewayService(Consumer<String, Object> kafkaQueue,
Producer<String, Object> kafkaProducer,
@ -80,7 +80,8 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
super(kafkaQueue, kafkaProducer);
this.restTemplate = restTemplate;
this.userRoleVerification = userRoleVerification;
this.gatewayApiSettings = gatewayApiSettings;
this.clearingSystemValue = StringUtils.isNotEmpty(gatewayApiSettings.getClearingSystem()) ?
gatewayApiSettings.getClearingSystem() : "SPVB";
this.inboundServerSettings = gatewayApiSettings.getInboundServer();
this.inboundExternalServerSettings = gatewayApiSettings.getInboundExternalServer();
this.sentAssets = sentAssets;
@ -120,6 +121,7 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
logUnknownProperties(userRequest);
OutboundRequest outboundFondRequest = OutboundRequestBuilder.builder()
.type(OutboundRequestType.MEMBER_ON_DEMAND.getKey())
.clearingSystem(clearingSystemValue)
.build();
outboundRequestByUuid.put(outboundFondRequest.getId(), outboundFondRequest);
@ -133,6 +135,7 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
OutboundRequest outboundFondRequest = OutboundRequestBuilder.builder()
.section(exportedRequest.getSection())
.type(OutboundRequestType.FILL_LIMITS.getKey())
.clearingSystem(clearingSystemValue)
.content(content)
.build();
@ -152,16 +155,19 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
OutboundRequest outboundFondRequest = OutboundRequestBuilder.builder()
.section(Section.FOND.getKey())
.type(OutboundRequestType.ON_DEMAND.getKey())
.clearingSystem(clearingSystemValue)
.build();
OutboundRequest outboundMkrRequest = OutboundRequestBuilder.builder()
.section(Section.MKR.getKey())
.type(OutboundRequestType.ON_DEMAND.getKey())
.clearingSystem(clearingSystemValue)
.build();
OutboundRequest outboundCurrRequest = OutboundRequestBuilder.builder()
.section(Section.CURR.getKey())
.type(OutboundRequestType.ON_DEMAND.getKey())
.clearingSystem(clearingSystemValue)
.build();
outboundRequestByUuid.put(outboundFondRequest.getId(), outboundFondRequest);
@ -198,6 +204,7 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
OutboundRequest outboundRequest = OutboundRequestBuilder.builder()
.section(assetOperation.getAmount() != null ? Section.MKR.getKey() : Section.FOND.getKey())
.type(OutboundRequestType.ASSET_OPERATION.getKey())
.clearingSystem(clearingSystemValue)
.content(content).build();
gatewayBuilder.outboundRequest(outboundRequest);
@ -231,6 +238,7 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
OutboundRequest outboundRequest = OutboundRequestBuilder.builder()
.section(Section.FOND.getKey())
.type(reportType.getKey())
.clearingSystem(clearingSystemValue)
.content(content).build();
sendRequest(outboundRequest);
@ -243,6 +251,7 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
OutboundRequest outboundRequest = OutboundRequestBuilder.builder()
.type(OutboundRequestType.MEMBER_RESPONSE_TKR.getKey())
.content(content)
.clearingSystem(clearingSystemValue)
.build();
if (reportRequest.getRequestId() != null) {
outboundRequest.setId(reportRequest.getRequestId());
@ -286,9 +295,6 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
}
private void sendRequest(OutboundRequest request) {
String clearingSystem = StringUtils.isNotEmpty(gatewayApiSettings.getClearingSystem()) ?
gatewayApiSettings.getClearingSystem() : "SPVB";
request.setClearingSystem(clearingSystem);
if (inboundServerSettings != null &&
(inboundServerSettings.getAllowedTypes().isEmpty() ||
inboundServerSettings.getAllowedTypes().contains(request.getType()))) {

View file

@ -1,15 +1,15 @@
package ru.spcex.clearing.gatewayapi.service.builders;
import ru.spcex.clearing.gatewayapi.controller.outbound.request.OutboundRequest;
import java.time.Instant;
import java.util.Map;
import java.util.UUID;
import ru.spcex.clearing.gatewayapi.controller.outbound.request.OutboundRequest;
public class OutboundRequestBuilder {
private String section;
private String requestType;
private String clearingSystem;
private Map<String, Object> content;
private OutboundRequestBuilder() {
@ -34,11 +34,16 @@ public class OutboundRequestBuilder {
this.content = content;
return this;
}
public OutboundRequestBuilder clearingSystem(String val) {
this.clearingSystem = val;
return this;
}
public OutboundRequest build() {
OutboundRequest outboundRequest = new OutboundRequest();
outboundRequest.setId(UUID.randomUUID());
outboundRequest.setDatetime(Instant.now());
outboundRequest.setClearingSystem(clearingSystem);
if (section != null) {
outboundRequest.setSection(section);
}