etreschenkov 2026-04-02 13:07:05 +03:00
parent 7c45242687
commit b4a3bb9910
2 changed files with 27 additions and 15 deletions

View file

@ -69,6 +69,7 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
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; private final String clearingSystemValue;
private final GatewayApiSettings gatewayApiSettings;
public GatewayService(Consumer<String, Object> kafkaQueue, public GatewayService(Consumer<String, Object> kafkaQueue,
Producer<String, Object> kafkaProducer, Producer<String, Object> kafkaProducer,
@ -81,6 +82,7 @@ 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()) ? this.clearingSystemValue = StringUtils.isNotEmpty(gatewayApiSettings.getClearingSystem()) ?
gatewayApiSettings.getClearingSystem() : "SPVB"; gatewayApiSettings.getClearingSystem() : "SPVB";
this.inboundServerSettings = gatewayApiSettings.getInboundServer(); this.inboundServerSettings = gatewayApiSettings.getInboundServer();
@ -99,7 +101,7 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
.setConsumer(this::requestOnDemandSecurity) .setConsumer(this::requestOnDemandSecurity)
.forDestination(Task.loadIssue_LOSC.topic(), callbacks::put); .forDestination(Task.loadIssue_LOSC.topic(), callbacks::put);
callback(GatewayTaskRequest.class) callback(GatewayTaskRequest.class)
.setConsumer(this::requestOn) .setConsumer(this::requestOnRates)
.forDestination(Task.LORT.topic(), callbacks::put); .forDestination(Task.LORT.topic(), callbacks::put);
callback(LimExportedRequest.class) callback(LimExportedRequest.class)
.setConsumer(this::requestOnLimit) .setConsumer(this::requestOnLimit)
@ -195,16 +197,20 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
log.debug("LOSC task 4/4 complete (CURR section)"); log.debug("LOSC task 4/4 complete (CURR section)");
} }
public void requestOn(BaseRequest<GatewayTaskRequest> userRequest) { public void requestOnRates(BaseRequest<GatewayTaskRequest> userRequest) {
OutboundRequest settleRateReq = OutboundRequestBuilder.builder() OutboundRequest settleRateReq = OutboundRequestBuilder.builder()
.type(OutboundRequestType.CURRENCY_RATE.getKey()) .type(OutboundRequestType.CURRENCY_RATE.getKey())
.content(ContentBuilder.builder().settleRateBuild()) .content(ContentBuilder.builder()
.withSettings(gatewayApiSettings)
.settleRateBuild())
.clearingSystem(clearingSystemValue) .clearingSystem(clearingSystemValue)
.build(); .build();
OutboundRequest cbRateReq = OutboundRequestBuilder.builder() OutboundRequest cbRateReq = OutboundRequestBuilder.builder()
.type(OutboundRequestType.CURRENCY_RATE.getKey()) .type(OutboundRequestType.CURRENCY_RATE.getKey())
.content(ContentBuilder.builder().cbRateBuild()) .content(ContentBuilder.builder()
.withSettings(gatewayApiSettings)
.cbRateBuild())
.clearingSystem(clearingSystemValue) .clearingSystem(clearingSystemValue)
.build(); .build();

View file

@ -2,32 +2,38 @@ package ru.spcex.clearing.gatewayapi.service.builders;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import ru.spcex.clearing.gatewayapi.config.GatewayApiSettings;
public class ContentBuilder { public class ContentBuilder {
private GatewayApiSettings settings;
private ContentBuilder(){} private ContentBuilder(){}
public static ContentBuilder builder(){ public static ContentBuilder builder(){
return new ContentBuilder(); return new ContentBuilder();
} }
public ContentBuilder withSettings(final GatewayApiSettings settings) {
this.settings = settings;
return this;
}
public Map<String, Object> settleRateBuild() { public Map<String, Object> settleRateBuild() {
return new HashMap<>() {{ return new HashMap<>() {{
put("sender_organization_code", "SPVB"); put("sender_organization_code", settings.getSenderOrganizationCode());
put("sender_subsystem_code", "KS"); put("sender_subsystem_code", settings.getSenderSubsystemCode());
put("recipient_organization_code", "SPVB"); put("recipient_organization_code", settings.getRecipientOrganizationCode());
put("sender_rate_type_code", "SETTLE_RATE"); put("sender_rate_type_code", settings.getSenderSettleRateTypeCode());
put("recipient_rate_type_code", "NCC_RATE"); put("recipient_rate_type_code", settings.getRecipientSettleRateTypeCode());
}}; }};
} }
public Map<String, Object> cbRateBuild() { public Map<String, Object> cbRateBuild() {
return new HashMap<>() {{ return new HashMap<>() {{
put("sender_organization_code", "SPVB"); put("sender_organization_code", settings.getSenderOrganizationCode());
put("sender_subsystem_code", "KS"); put("sender_subsystem_code", settings.getSenderSubsystemCode());
put("recipient_organization_code", "SPVB"); put("recipient_organization_code", settings.getRecipientOrganizationCode());
put("sender_rate_type_code", "CB_RATE"); put("sender_rate_type_code", settings.getSenderCbRateTypeCode());
put("recipient_rate_type_code", "CBR_RATE"); put("recipient_rate_type_code", settings.getRecipientCbRateTypeCode());
}}; }};
} }
} }