---
DepoPaymentInstructionRegisterService refactored, but there are a lot of question that should be sorted out
This commit is contained in:
aalehin 2023-05-23 11:29:30 +03:00
parent df4cecf59e
commit 63b1babed9

View file

@ -17,9 +17,11 @@ import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
import ru.spcex.platform.imdg.api.Imdg;
import ru.spcex.platform.imdg.api.ImdgProvider;
import java.time.Instant;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static ru.spcex.platform.enumeration.Task.createRegistry_GORR;
import static ru.spcex.platform.enumeration.Task.createRegistry_GRRT;
@ -55,9 +57,9 @@ public class DepoPaymentInstructionRegisterService extends QueueConsumer impleme
public void depoPaymentInstructionRegisterNew(BaseRequest<LauncherCommandRequest> userRequest) {
log.debug("LauncherCommandRequest received from {}", createRegistry_GORR.topic());
HashMap<Long, PaymentInstruction> sessionIdByPaymentInstructions = new HashMap<>();
paymentInstructionMap.getAllValues().stream().forEach(x -> sessionIdByPaymentInstructions.put(x.getSessionId(), x));
List<Session> actualSession = sessionMap.getAllValues().stream().filter(x ->
sessionIdByPaymentInstructions.containsKey(x.getId()) && x.getSection().equalsIgnoreCase("FOND")
paymentInstructionMap.getAllValues().forEach(x -> sessionIdByPaymentInstructions.put(x.getSessionId(), x));
List<Session> actualSession = sessionMap.getCollectionObjectsByFieldValues(Map.of("section", "FOND")).stream().filter(x ->
sessionIdByPaymentInstructions.containsKey(x.getId())
).toList();
HashMap<Long, Long> sessionIdByCompanyId = new HashMap<>();
Collection<DepoPaymentInstructionRegister> collection = depoPaymentInstructionRegisterMap.getAllValues();
@ -73,17 +75,21 @@ public class DepoPaymentInstructionRegisterService extends QueueConsumer impleme
}
private void insertDepoPaymentInstructionRegister(PaymentInstruction paymentInstruction) {
log.trace("Started generating DepoPaymentInstructionRegister entity...");
DepoPaymentInstructionRegister depoPaymentInstructionRegister = new DepoPaymentInstructionRegister();
//todo fix up Optional<TradingClearingRegistry> tradingClearingRegistry = tradingClearingRegistryMap.getAllValues().stream().filter((x)-> x.getCompanyId().equals(paymentInstruction.getCompanyId())).findFirst();
//TODO CLARIFY HOW WE SHOULD FIND TRADING CLEARING REGISTRY IF IN PAYMENT INSTRUCTION THERE IS NO COMPANY ID
//TradingClearingRegistry tradingClearingRegistry = tradingClearingRegistryMap.getSingleObjectByFieldValues(Map.of("companyId", paymentInstruction.getCompanyId()));
depoPaymentInstructionRegister.setCreated(Instant.now());
depoPaymentInstructionRegister.setUpdated(Instant.now());
depoPaymentInstructionRegister.setCompanyId(paymentInstruction.getSenderId());
//todo fix up depoPaymentInstructionRegister.setTradingClearingRegistryType();
//todo fix up depoPaymentInstructionRegister.setTradingClearingRegistry();
depoPaymentInstructionRegister.setCbCode("=RNCB-BE-01");
depoPaymentInstructionRegister.setCbCode("=RNCB-BE-01"); //TODO CLARIFY THERE SHOULD BE VALUE =RNCB-BE-01 OR RNCB-BE-01
depoPaymentInstructionRegister.setQuantity(paymentInstruction.getCreditLeg_amount());
//todo fix up depoPaymentInstructionRegister.setDirection(paymentInstruction.getCreditLeg_direction());
//depoPaymentInstructionRegister.setDirection(paymentInstruction.getCreditLeg_direction()); //TODO CLARIFY HOW WE SHOULD MAP LONG IN STRING IS THERE SOME ERRORS
depoPaymentInstructionRegister.setSessionId(paymentInstruction.getSessionId());
depoPaymentInstructionRegisterMap.insert(depoPaymentInstructionRegister);
log.debug("inserted successfully DepoBalanceRegister entity with id: {}", depoPaymentInstructionRegister.getId());
}
}