http://jira.mfd.msk:8088/browse/CLS-189 PaymentInstructionCreator мелкая правка, добавил логов trace

This commit is contained in:
AKurakin 2023-02-07 14:08:06 +03:00
parent 722b6ff385
commit 687b50d970

View file

@ -100,7 +100,7 @@ public class PaymentInstructionCreator {
// I
if (clearingCategory.contains(ClearingCategory.I)) {
log.debug("By liabilitiesClaimsAssets[{}] create for category I 1 record", liabilitiesClaimsAssets.getId());
log.debug("By liabilitiesClaimsAssets[{}] create for category I 2 PaymentInstruction record", liabilitiesClaimsAssets.getId());
PaymentInstruction payment1 = new PaymentInstruction();
PaymentInstruction payment2 = new PaymentInstruction();
@ -115,13 +115,16 @@ public class PaymentInstructionCreator {
payment2.setSenderId(SPVB_ID); // СПВБ
payment1.setAddresseeId(SPVB_ID); // СПВБ
String sqlLCA = String.format("securityId = %s and companyId != %s",
liabilitiesClaimsAssets.getSecurityId(), liabilitiesClaimsAssets.getCompanyId());
ExecutionDeposit counterExecutionDeposit = executionDepositImdg.getSingleObjectBySQL(sqlLCA);
if (counterExecutionDeposit == null) {
log.warn("Counter ExecutionDeposit not found for : {}", sqlLCA);
} else {
payment2.setAddresseeId(counterExecutionDeposit.getCompanyId());
{
String sqlLCA = String.format("securityId = %s and companyId != %s",
liabilitiesClaimsAssets.getSecurityId(), liabilitiesClaimsAssets.getCompanyId());
ExecutionDeposit counterExecutionDeposit = executionDepositImdg.getSingleObjectBySQL(sqlLCA);
if (counterExecutionDeposit == null) {
log.warn("Counter ExecutionDeposit not found for : {}", sqlLCA);
} else {
payment2.setAddresseeId(counterExecutionDeposit.getCompanyId());
log.trace("payment2.AddresseeId={} found by: {}", payment2.getAddresseeId(), sqlLCA);
}
}
String symbol1 = selectSymbolValue(payment1.getAddresseeId(), CompanySymbol.BIC);
@ -140,7 +143,7 @@ public class PaymentInstructionCreator {
Company companyPRC = companyImdg.getSingleObjectByID(PRC_ID); // 2 "НКО АО ПРЦ"
String companyPRCName = null;
if (companyPRC == null) {
log.warn("Company.id=2 not found");
log.warn("Company.id={} not found", PRC_ID);
} else {
companyPRCName = companyPRC.getShortName();
}
@ -170,13 +173,14 @@ public class PaymentInstructionCreator {
payment2.setDebitLegAmount(amount);
payment1.setCreditLegAccountId(liabilitiesClaimsAssets.getAccountId());
String accSql = String.format("companyId = %s AND accountType=TRAN AND accountStatus=ACTV AND processingSign=ALWD",
payment2.getSenderId());
Account anotherAcc = accountImdg.getSingleObjectBySQL(accSql);
if (anotherAcc == null) {
log.warn("Account not found: {}", accSql);
} else {
payment2.setCreditLegAccountId(anotherAcc.getId());
{
Account anotherAcc = selectAccount(payment2.getSenderId(), AccountType.Tran, Status.Active, Allowed.ALLOWED);
if (anotherAcc == null) {
log.warn("Account not found: companyId = {} AND accountType={} AND accountStatus={} AND processingSign={}",
payment2.getSenderId(), AccountType.Tran, Status.Active, Allowed.ALLOWED);
} else {
payment2.setCreditLegAccountId(anotherAcc.getId());
}
}
payment1.setCreditCsAccount(null);
@ -231,7 +235,7 @@ public class PaymentInstructionCreator {
} else {
// V / B
if (clearingCategory.contains(ClearingCategory.V)) {
log.debug("By liabilitiesClaimsAssets[{}] create for category V 1 record", liabilitiesClaimsAssets.getId());
log.debug("By liabilitiesClaimsAssets[{}] create for category V 1 PaymentInstruction record", liabilitiesClaimsAssets.getId());
PaymentInstruction payment1 = new PaymentInstruction();
payment1.setId(idGenerator.nextId());
payment1.setCreated(now);
@ -239,13 +243,16 @@ public class PaymentInstructionCreator {
payment1.setSenderId(SPVB_ID); // СПВБ
String sqlLCA = String.format("securityId = %s and companyId != %s",
liabilitiesClaimsAssets.getSecurityId(), liabilitiesClaimsAssets.getCompanyId());
ExecutionDeposit counterExecutionDeposit = executionDepositImdg.getSingleObjectBySQL(sqlLCA);
if (counterExecutionDeposit == null) {
log.warn("Counter ExecutionDeposit not found for : {}", sqlLCA);
} else {
payment1.setAddresseeId(counterExecutionDeposit.getCompanyId());
{
String sqlLCA = String.format("securityId = %s and companyId != %s",
liabilitiesClaimsAssets.getSecurityId(), liabilitiesClaimsAssets.getCompanyId());
ExecutionDeposit counterExecutionDeposit = executionDepositImdg.getSingleObjectBySQL(sqlLCA);
if (counterExecutionDeposit == null) {
log.warn("Counter ExecutionDeposit not found for : {}", sqlLCA);
} else {
payment1.setAddresseeId(counterExecutionDeposit.getCompanyId());
log.trace("payment1.AddresseeId={} found by: {}", payment1.getAddresseeId(), sqlLCA);
}
}
String symbol1 = selectSymbolValue(payment1.getAddresseeId(), CompanySymbol.BIC);
@ -258,7 +265,7 @@ public class PaymentInstructionCreator {
Company companyPRC = companyImdg.getSingleObjectByID(PRC_ID); // 2 "НКО АО ПРЦ"
String companyPRCName = null;
if (companyPRC == null) {
log.warn("Company.id=2 not found");
log.warn("Company.id={} not found", PRC_ID);
} else {
companyPRCName = companyPRC.getShortName();
}
@ -280,11 +287,10 @@ public class PaymentInstructionCreator {
payment1.setDebitLegAmount(amount);
{
String accSql = String.format("companyId = %s AND accountType=ANLT AND accountStatus=ACTV AND processingSign=ALWD",
payment1.getSenderId());
Account acc1 = accountImdg.getSingleObjectBySQL(accSql);
Account acc1 = selectAccount(payment1.getSenderId(), AccountType.Anlt, Status.Active, Allowed.ALLOWED);
if (acc1 == null) {
log.warn("Account not found: {}", accSql);
log.warn("Account not found: companyId = {} AND accountType={} AND accountStatus={} AND processingSign={}",
payment1.getSenderId(), AccountType.Anlt, Status.Active, Allowed.ALLOWED);
} else {
payment1.setCreditLegAccountId(acc1.getId());
payment1.setCreditLegAccount(acc1.getAccount());
@ -317,7 +323,7 @@ public class PaymentInstructionCreator {
newPaymentInstructions.add(payment1);
} else // Для V,B только 1 PaymentInstruction
if (clearingCategory.contains(ClearingCategory.B)) {
log.debug("By liabilitiesClaimsAssets[{}] create for category B 1 record", liabilitiesClaimsAssets.getId());
log.debug("By liabilitiesClaimsAssets[{}] create for category B 1 PaymentInstruction record", liabilitiesClaimsAssets.getId());
PaymentInstruction payment1 = new PaymentInstruction();
payment1.setId(idGenerator.nextId());
payment1.setCreated(now);
@ -337,7 +343,7 @@ public class PaymentInstructionCreator {
Company companyPRC = companyImdg.getSingleObjectByID(PRC_ID); // 2 "НКО АО ПРЦ"
String companyPRCName = null;
if (companyPRC == null) {
log.warn("Company.id=2 not found");
log.warn("Company.id={} not found", PRC_ID);
} else {
companyPRCName = companyPRC.getShortName();
}
@ -359,11 +365,10 @@ public class PaymentInstructionCreator {
payment1.setDebitLegAmount(amount);
{
String accSql = String.format("companyId = %s AND accountType=ANLT AND accountStatus=ACTV AND processingSign=ALWD",
payment1.getSenderId());
Account acc1 = accountImdg.getSingleObjectBySQL(accSql);
Long accountId = liabilitiesClaimsAssets.getAccountId();
Account acc1 = accountImdg.getSingleObjectByID(accountId);
if (acc1 == null) {
log.warn("Account not found: {}", accSql);
log.warn("Account not found: {}", accountId);
} else {
payment1.setCreditLegAccountId(acc1.getId());
payment1.setCreditLegAccount(acc1.getAccount());
@ -443,6 +448,15 @@ public class PaymentInstructionCreator {
"accountStatus", accountStatus.getKey(),
"processingSign", processingSign.getKey()
));
if (account == null) {
log.trace("Account not found by: companyId={} accountType={} accountStatus={} processingSign={}",
companyId, accountType.getKey(), accountStatus.getKey(), processingSign.getKey()
);
} else {
log.trace("Found Account.id={} by: companyId={} accountType={} accountStatus={} processingSign={}", account.getId(),
companyId, accountType.getKey(), accountStatus.getKey(), processingSign.getKey()
);
}
return account;
}
@ -495,7 +509,7 @@ public class PaymentInstructionCreator {
* Обновление liabilitiesClaimsMoney первой/второй ноги по liabilitiesClaimsAssets
*
* @param liabilitiesClaimsMoney обновить этот объект (firstLeg)
* @param isFirstLeg true - первая, false вторая
* @param isFirstLeg true - первая, false вторая
* @param paymentInstructions
* @param clearingCategory
* @return были внесены изменения в liabilitiesClaimsMoney