From 76a1b74c4bc97ddabb9fc5f487f1df75dc778821 Mon Sep 17 00:00:00 2001 From: aalehin Date: Fri, 6 Oct 2023 11:30:56 +0300 Subject: [PATCH] http://jira.mfd.msk:8088/browse/CLS-280 --- 1 and 2 bullet points --- .../DepoPaymentInstructionRegisterService.java | 10 ++++++---- .../MoneyPaymentInstructionRegisterService.java | 15 +++++++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/clearing-parent/registry-service/src/main/java/ru/spcex/clearing/registry/service/DepoPaymentInstructionRegisterService.java b/clearing-parent/registry-service/src/main/java/ru/spcex/clearing/registry/service/DepoPaymentInstructionRegisterService.java index b7323faef..fb09c0230 100644 --- a/clearing-parent/registry-service/src/main/java/ru/spcex/clearing/registry/service/DepoPaymentInstructionRegisterService.java +++ b/clearing-parent/registry-service/src/main/java/ru/spcex/clearing/registry/service/DepoPaymentInstructionRegisterService.java @@ -94,15 +94,17 @@ public class DepoPaymentInstructionRegisterService extends QueueConsumer impleme private void insertDepoPaymentInstructionRegister(PaymentInstruction paymentInstruction) { log.trace("Started generating DepoPaymentInstructionRegister entity..."); DepoPaymentInstructionRegister depoPaymentInstructionRegister = new DepoPaymentInstructionRegister(); - TradingClearingRegistry tradingClearingRegistry = paymentInstruction.getCreditLeg_accountId() == null ? null : - tradingClearingRegistryMap.getFirstObjectByFieldValues(Map.of("depoAccountId", paymentInstruction.getCreditLeg_accountId())); + TradingClearingRegistry tradingClearingRegistry = null; + if (paymentInstruction.getCreditLeg_accountId() != null && paymentInstruction.getSenderId() != null) { + tradingClearingRegistry = tradingClearingRegistryMap.getFirstObjectByFieldValues(Map.of("companyId", paymentInstruction.getSenderId(), "depoAccountId", paymentInstruction.getCreditLeg_accountId())); + } InOutDirectionDictionary inOutDirectionDictionary = InOutDirectionDictionaryMap.getFirstObjectByFieldValues(Map.of("code", paymentInstruction.getCreditLeg_direction())); depoPaymentInstructionRegister.setCreated(Instant.now()); depoPaymentInstructionRegister.setUpdated(Instant.now()); depoPaymentInstructionRegister.setCompanyId(paymentInstruction.getSenderId()); if (tradingClearingRegistry == null) { - log.warn("For paymentInstruction[{}].CreditLeg_accountId={} can not find TradingClearingRegistry.", - paymentInstruction.getId(), paymentInstruction.getCreditLeg_accountId()); + log.warn("For paymentInstruction[{}].CreditLeg_accountId={} or SenderId={} can not find TradingClearingRegistry.", + paymentInstruction.getId(), paymentInstruction.getCreditLeg_accountId(), paymentInstruction.getSenderId()); } else { depoPaymentInstructionRegister.setTradingClearingRegistryType(tradingClearingRegistry.getTradingClearingRegistryType()); depoPaymentInstructionRegister.setTradingClearingRegistry(tradingClearingRegistry.getCode()); diff --git a/clearing-parent/registry-service/src/main/java/ru/spcex/clearing/registry/service/MoneyPaymentInstructionRegisterService.java b/clearing-parent/registry-service/src/main/java/ru/spcex/clearing/registry/service/MoneyPaymentInstructionRegisterService.java index 73633a618..6691c2d01 100644 --- a/clearing-parent/registry-service/src/main/java/ru/spcex/clearing/registry/service/MoneyPaymentInstructionRegisterService.java +++ b/clearing-parent/registry-service/src/main/java/ru/spcex/clearing/registry/service/MoneyPaymentInstructionRegisterService.java @@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import ru.clearing.classes.statics.data.company.Company; import ru.clearing.classes.statics.data.misc.Session; import ru.clearing.classes.statics.data.payment.PaymentInstruction; import ru.clearing.classes.statics.data.register.MoneyPaymentInstructionRegister; @@ -35,6 +36,7 @@ public class MoneyPaymentInstructionRegisterService extends QueueConsumer implem private final Imdg paymentInstructionMap; private final Imdg sessionMap; private final Function, IValidator> fieldValuesValidator; + private final Imdg companyMap; private final PreClearMap preClearMap; @Autowired @@ -46,6 +48,7 @@ public class MoneyPaymentInstructionRegisterService extends QueueConsumer implem this.moneyPaymentInstructionRegisterMap = imdgProvider.getImdg(IMDGDistributedNames.Map_MoneyPaymentInstructionRegister, MoneyPaymentInstructionRegister.class); this.paymentInstructionMap = imdgProvider.getImdg(IMDGDistributedNames.Map_PaymentInstruction, PaymentInstruction.class); this.sessionMap = imdgProvider.getImdg(IMDGDistributedNames.Map_Session, Session.class); + this.companyMap = imdgProvider.getImdg(IMDGDistributedNames.Map_Company, Company.class); this.fieldValuesValidator = fieldValuesValidator; preClearMap = PreClearMap.instanceForLocalDateField(moneyPaymentInstructionRegisterMap, "clearingDate"); } @@ -85,10 +88,14 @@ public class MoneyPaymentInstructionRegisterService extends QueueConsumer implem moneyPaymentInstructionRegister.setCreditLegAmount(paymentInstruction.getCreditLeg_amount()); moneyPaymentInstructionRegister.setCreditLegCurrencyCode(paymentInstruction.getCreditLeg_currencyCode()); moneyPaymentInstructionRegister.setDebitLegAccount(paymentInstruction.getDebitLeg_account()); - if (paymentInstruction.getSenderId()!=null) - moneyPaymentInstructionRegister.setSender(paymentInstruction.getSenderId().toString()); - if (paymentInstruction.getAddresseeId()!=null) - moneyPaymentInstructionRegister.setAddressee(paymentInstruction.getAddresseeId().toString()); + if (paymentInstruction.getSenderId() != null) { + Company companyForInjectionBySenderId = companyMap.getSingleObjectByID(paymentInstruction.getSenderId()); + moneyPaymentInstructionRegister.setSender(companyForInjectionBySenderId != null ? companyForInjectionBySenderId.getShortName() : null); + } + if (paymentInstruction.getAddresseeId() != null) { + Company companyForInjectionByAddresseeId = companyMap.getSingleObjectByID(paymentInstruction.getAddresseeId()); + moneyPaymentInstructionRegister.setAddressee(companyForInjectionByAddresseeId != null ? companyForInjectionByAddresseeId.getShortName() : null); + } moneyPaymentInstructionRegister.setClearingDate(paymentInstruction.getClearingDate()); moneyPaymentInstructionRegister.setCreated(Instant.now()); moneyPaymentInstructionRegister.setUpdated(moneyPaymentInstructionRegister.getCreated());