вводы/выводы - gateway

This commit is contained in:
etreschenkov 2023-06-22 16:04:53 +03:00
parent 4ac51b04ef
commit d759e54f6d

View file

@ -152,16 +152,17 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
Collection<AssetOperationRequest> assetOperations = request.getRequestPayload().getAssetOperationRequests();
List<SentAsset> assets = new ArrayList<>();
for (AssetOperationRequest assetOperation : assetOperations) {
Map<String, Object> content = Map.of("direction", assetOperation.getDirection(),
"amount", assetOperation.getAmount(),
"code", assetOperation.getCode(),
"asset", assetOperation.getSecuritySymbol(),
"firm_id", assetOperation.getTradingCode());
// if (assetOperationRequest.getAmount() != null) {
// content.put("amount", assetOperationRequest.getAmount());
// } else {
// content.put("quantity", assetOperationRequest.getQuantity());
// }
Map<String, Object> content = new HashMap<>() {{
put("direction", assetOperation.getDirection());
put("code", assetOperation.getCode());
put("asset", assetOperation.getSecuritySymbol());
put("firm_id", assetOperation.getTradingCode());
}};
if (assetOperation.getAmount() != null) {
content.put("amount", assetOperation.getAmount().toString());
} else {
content.put("quantity", assetOperation.getQuantity().toString());
}
OutboundRequest outboundRequest = OutboundRequestBuilder.builder()
.section(Section.MKR.getKey())
@ -174,7 +175,7 @@ public class GatewayService extends QueueConsumer implements InitializingBean {
ResponseEntity<Map> response = restTemplate.exchange(url, HttpMethod.POST, r, Map.class);
Map bodyResponse = response.getBody();
log.debug("Response from service: {}", bodyResponse != null ? bodyResponse : "empty");
} catch (Throwable err){
} catch (Throwable err) {
log.error("Exchange error: {}", ExceptionUtils.getStackTrace(err));
} finally {
SentAsset sentAsset = new SentAsset();