etreschenkov 2023-07-07 13:18:37 +03:00
parent db8fd60495
commit 02b870f95b
2 changed files with 20 additions and 15 deletions

View file

@ -29,6 +29,7 @@ import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
import ru.spcex.clearing.util.security.UserRoleVerification;
import ru.spcex.platform.enumeration.ReportKeys;
import ru.spcex.platform.enumeration.ReportType;
import ru.spcex.platform.enumeration.Section;
import ru.spcex.platform.enumeration.Task;
import ru.spcex.platform.utils.enumeration.IEnumKey;
@ -94,7 +95,7 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
String url = formingInboundUrl(inboundServerSettings.getPathLOCM());
OutboundRequest outboundFondRequest = OutboundRequestBuilder.builder()
.type(OutboundRequestType.MEMBER_ON_DEMAND)
.type(OutboundRequestType.MEMBER_ON_DEMAND.getKey())
.build();
HttpEntity<OutboundRequest> request = makeDefaultRequest(outboundFondRequest);
@ -114,7 +115,7 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
OutboundRequest outboundFondRequest = OutboundRequestBuilder.builder()
.section(exportedRequest.getSection())
.type(OutboundRequestType.FILL_LIMITS)
.type(OutboundRequestType.FILL_LIMITS.getKey())
.content(content)
.build();
@ -139,12 +140,12 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
OutboundRequest outboundFondRequest = OutboundRequestBuilder.builder()
.section(Section.FOND.getKey())
.type(OutboundRequestType.ON_DEMAND)
.type(OutboundRequestType.ON_DEMAND.getKey())
.build();
OutboundRequest outboundMkrRequest = OutboundRequestBuilder.builder()
.section(Section.MKR.getKey())
.type(OutboundRequestType.ON_DEMAND)
.type(OutboundRequestType.ON_DEMAND.getKey())
.build();
HttpEntity<OutboundRequest> requestFond = makeDefaultRequest(outboundFondRequest);
@ -183,7 +184,7 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
OutboundRequest outboundRequest = OutboundRequestBuilder.builder()
.section(Section.MKR.getKey())
.type(OutboundRequestType.ASSET_OPERATION)
.type(OutboundRequestType.ASSET_OPERATION.getKey())
.content(content).build();
String url = formingInboundUrl(inboundServerSettings.getPathLOCM());
@ -210,8 +211,8 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
public void requestOnReport(BaseRequest<SendReportRequest> request) {
SendReportRequest reportRequest = request.getRequestPayload();
OutboundRequestType outboundRequestType = IEnumKey.getEnumByKey(OutboundRequestType.class, reportRequest.getType());
if (outboundRequestType == null) {
ReportType reportType = IEnumKey.getEnumByKey(ReportType.class, reportRequest.getType());
if (reportType == null) {
log.warn("Undefined type of request: {}; skip", reportRequest.getType());
return;
}
@ -220,7 +221,7 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
Map<String, Object> content = makeContentByReportRequest(reportPart);
OutboundRequest outboundRequest = OutboundRequestBuilder.builder()
.section(Section.FOND.getKey())
.type(outboundRequestType)
.type(reportType.getKey())
.content(content).build();
String url = formingInboundUrl(inboundServerSettings.getPathLOCM());
@ -236,13 +237,17 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
protected Map<String, Object> makeContentByReportRequest(ReportPart reportPart) {
Map<String, Object> content = new HashMap<>();
Matcher matcher = REPORT_FILE_NAME_PATTERN.matcher(reportPart.getFileName());
ReportKeys reportKeys = null;
ReportKeys reportKey = null;
if (matcher.matches()) {
String rowKey = matcher.group(1);
reportKeys = IEnumKey.getEnumByKeyOrUndefined(ReportKeys.class, rowKey);
reportKey = IEnumKey.getEnumByKeyOrUndefined(ReportKeys.class, rowKey);
}
if (reportKey == null) {
log.warn("Mismatched filename pattern : {}; {}", reportPart.getFileName(), REPORT_FILE_NAME_PATTERN);
return content;
}
String paramName = null;
switch (reportKeys) {
switch (reportKey) {
case KS_BR_PFX64_INFTYPE_1 -> paramName = "inftype_1";
case KS_BR_PFX64_INFTYPE_2 -> paramName = "inftype_2";
case KS_BR_PFX64_INFTYPE_3 -> paramName = "inftype_3";

View file

@ -1,7 +1,6 @@
package ru.spcex.clearing.gatewayapi.service.builders;
import ru.spcex.clearing.gatewayapi.controller.outbound.request.OutboundRequest;
import ru.spcex.clearing.gatewayapi.enums.OutboundRequestType;
import java.time.Instant;
import java.util.Map;
@ -10,7 +9,7 @@ import java.util.UUID;
public class OutboundRequestBuilder {
private String section;
private OutboundRequestType requestType;
private String requestType;
private Map<String, Object> content;
private OutboundRequestBuilder() {
@ -25,11 +24,12 @@ public class OutboundRequestBuilder {
return this;
}
public OutboundRequestBuilder type(OutboundRequestType outboundRequestType) {
public OutboundRequestBuilder type(String outboundRequestType) {
this.requestType = outboundRequestType;
return this;
}
public OutboundRequestBuilder content(Map<String, Object> content) {
this.content = content;
return this;
@ -43,7 +43,7 @@ public class OutboundRequestBuilder {
outboundRequest.setSection(section);
}
if (requestType != null) {
outboundRequest.setType(requestType.getKey());
outboundRequest.setType(requestType);
}
outboundRequest.setContent(content);
return outboundRequest;