etreshenkov 2023-06-08 12:43:22 +03:00
parent 420bfca7d1
commit 14c4dc58f2
3 changed files with 46 additions and 10 deletions

View file

@ -3,7 +3,7 @@ package ru.spcex.clearing.session.stage.util;
import org.junit.jupiter.api.Test;
import ru.clearing.classes.statics.data.registry.Registry;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
class RegistryUtilTest {

View file

@ -8,6 +8,7 @@ import ru.spcex.clearing.gatewayapi.config.deserializers.InstantDeserializer;
import ru.spcex.clearing.gatewayapi.config.serializers.InstantSerializer;
import java.time.Instant;
import java.util.Map;
import java.util.UUID;
public class InboundRequest {
@ -52,7 +53,7 @@ public class InboundRequest {
@ApiModelProperty(
value = "Контент", example = "null"
)
private String content = null;
private Map<String, Object> content = null;
public UUID getId() {
@ -86,4 +87,12 @@ public class InboundRequest {
public void setSection(String section) {
this.section = section;
}
public Map<String, Object> getContent() {
return content;
}
public void setContent(Map<String, Object> content) {
this.content = content;
}
}

View file

@ -14,7 +14,9 @@ import ru.spcex.clearing.gatewayapi.config.GatewayApiSettings;
import ru.spcex.clearing.gatewayapi.config.InboundServerSettings;
import ru.spcex.clearing.gatewayapi.request.InboundRequest;
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
import ru.spcex.clearing.platform.messaging.domain.Consts;
import ru.spcex.clearing.platform.messaging.domain.cud.gateway.GatewayTaskRequest;
import ru.spcex.clearing.platform.messaging.domain.cud.utilities.LimExportedRequest;
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
import ru.spcex.clearing.util.security.UserRoleVerification;
@ -23,6 +25,7 @@ import ru.spcex.platform.enumeration.Task;
import java.time.Instant;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@ -48,19 +51,22 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
@Override
public void afterPropertiesSet() throws Exception {
callback(GatewayTaskRequest.class)
.setFunction(this::requestOnDemandCompany)
.setConsumer(this::requestOnDemandCompany)
.forDestination(Task.loadParty_LOCM.topic(), callbacks::put);
callback(GatewayTaskRequest.class)
.setFunction(this::requestOnDemandSecurity)
.setConsumer(this::requestOnDemandSecurity)
.forDestination(Task.loadIssue_LOSC.topic(), callbacks::put);
callback(LimExportedRequest.class)
.setConsumer(this::requestOnLimit)
.forDestination(Consts.LIM_EXPORTED, callbacks::put);
init();
}
public RequestInfoUpdate requestOnDemandCompany(BaseRequest<GatewayTaskRequest> userRequest) {
public void requestOnDemandCompany(BaseRequest<GatewayTaskRequest> userRequest) {
log.debug("LOCM task received");
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
if (requestInfoUpdate != null) return requestInfoUpdate;
if (requestInfoUpdate != null) return;
logUnknownProperties(userRequest);
@ -77,14 +83,35 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
String response = restTemplate.postForObject(url, request, String.class);
log.debug("LOCM task complete, response: {}", response);
return null;
}
public RequestInfoUpdate requestOnDemandSecurity(BaseRequest<GatewayTaskRequest> userRequest) {
public void requestOnLimit(BaseRequest<LimExportedRequest> userRequest) {
LimExportedRequest exportedRequest = userRequest.getRequestPayload();
String url = formingInboundUrl(inboundServerSettings.getPathLOCM());
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
httpHeaders.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
InboundRequest inboundRequest = new InboundRequest();
inboundRequest.setId(UUID.randomUUID());
inboundRequest.setType("FILL_LIMITS");
inboundRequest.setSection(Section.FOND.getKey());
inboundRequest.setDatetime(Instant.now());
Map<String, Object> content = new HashMap<>();
content.put("file", exportedRequest.getLimFileName());
inboundRequest.setContent(content);
HttpEntity<InboundRequest> request = new HttpEntity<>(inboundRequest, httpHeaders);
String response = restTemplate.postForObject(url, request, String.class);
log.debug("LOCM task complete, response: {}", response);
}
public void requestOnDemandSecurity(BaseRequest<GatewayTaskRequest> userRequest) {
log.debug("LOSC task received");
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
if (requestInfoUpdate != null) return requestInfoUpdate;
if (requestInfoUpdate != null) return;
logUnknownProperties(userRequest);
@ -107,7 +134,7 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
response = restTemplate.postForObject(url, request, String.class);
log.debug("LOCM task 2/2 complete (MKR section), response: {}", response);
return null;
// return null;
}
private String formingInboundUrl(String path) {