This commit is contained in:
parent
5c7218e7f0
commit
dde7c8eef2
2 changed files with 24 additions and 33 deletions
|
|
@ -216,29 +216,27 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ReportPart reportPart : reportRequest.getReports()) {
|
Map<String, Object> content = new HashMap<>();
|
||||||
Map<String, Object> content = makeContentByReportRequest(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);
|
||||||
ResponseEntity<SuccessResponse> response = restTemplate.exchange(url, HttpMethod.POST, r, SuccessResponse.class);
|
ResponseEntity<SuccessResponse> response = restTemplate.exchange(url, HttpMethod.POST, r, SuccessResponse.class);
|
||||||
SuccessResponse bodyResponse = response.getBody();
|
SuccessResponse bodyResponse = response.getBody();
|
||||||
if (bodyResponse != null) {
|
if (bodyResponse != null) {
|
||||||
log.debug("Response from service: {}", bodyResponse);
|
log.debug("Response from service: {}", bodyResponse);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Map<String, Object> makeContentByReportRequest(ReportPart reportPart) {
|
protected void makeContentByReportRequest(Map<String, Object> content, ReportPart reportPart) {
|
||||||
Map<String, Object> content = new HashMap<>();
|
|
||||||
ReportKeys reportKey = IEnumKey.getEnumByKey(ReportKeys.class, reportPart.getReportType());
|
ReportKeys reportKey = IEnumKey.getEnumByKey(ReportKeys.class, reportPart.getReportType());
|
||||||
if (reportKey == null) {
|
if (reportKey == null) {
|
||||||
log.warn("Mismatched filename pattern : {}; {}", reportPart.getFileName(), REPORT_FILE_NAME_PATTERN);
|
log.warn("Mismatched filename pattern : {}; {}", reportPart.getFileName(), REPORT_FILE_NAME_PATTERN);
|
||||||
return content;
|
return;
|
||||||
}
|
}
|
||||||
String paramName = null;
|
String paramName = null;
|
||||||
switch (reportKey) {
|
switch (reportKey) {
|
||||||
|
|
@ -258,7 +256,6 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
|
||||||
if (paramName != null) {
|
if (paramName != null) {
|
||||||
content.put(paramName, reportPart.getFileName());
|
content.put(paramName, reportPart.getFileName());
|
||||||
}
|
}
|
||||||
return content;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formingInboundUrl(String path) {
|
private String formingInboundUrl(String path) {
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,15 @@
|
||||||
package ru.spcex.clearing.gatewayapi.service;
|
package ru.spcex.clearing.gatewayapi.service;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.gateway.ReportPart;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class GatewayServiceTest {
|
public class GatewayServiceTest {
|
||||||
|
|
||||||
@Test
|
// @Test
|
||||||
public void makeContentByReportRequestTest() {
|
// public void makeContentByReportRequestTest() {
|
||||||
GatewayService gatewayService = new GatewayService(null, null, null,
|
// GatewayService gatewayService = new GatewayService(null, null, null,
|
||||||
null, null, null, null);
|
// null, null, null, null);
|
||||||
ReportPart reportPart = new ReportPart();
|
// ReportPart reportPart = new ReportPart();
|
||||||
reportPart.setFileName("KS_BR_PFX64_INFTYPE_1_111111111111111.csv");
|
// reportPart.setFileName("KS_BR_PFX64_INFTYPE_1_111111111111111.csv");
|
||||||
Map<String, Object> content = gatewayService.makeContentByReportRequest(reportPart);
|
// Map<String, Object> content = gatewayService.makeContentByReportRequest(content, reportPart);
|
||||||
Assertions.assertTrue(content.containsKey("inftype_1"));
|
// Assertions.assertTrue(content.containsKey("inftype_1"));
|
||||||
Assertions.assertEquals("KS_BR_PFX64_INFTYPE_1_111111111111111.csv", content.get("inftype_1"));
|
// Assertions.assertEquals("KS_BR_PFX64_INFTYPE_1_111111111111111.csv", content.get("inftype_1"));
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue