Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
e3f5236aee
1 changed files with 34 additions and 25 deletions
|
|
@ -77,7 +77,7 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
AccountHelper accountHelper,
|
||||
RequestHelper requestHelper,
|
||||
@Qualifier("informationAccountNewRequestValidator")
|
||||
Function<InformationAccountNewRequest, IValidator> infoAccountNewRequestValidator) {
|
||||
Function<InformationAccountNewRequest, IValidator> infoAccountNewRequestValidator) {
|
||||
super(kafkaQueue, kafkaResponseQueue);
|
||||
this.kafkaSender = kafkaSender;
|
||||
this.messageResolver = messageResolver;
|
||||
|
|
@ -88,21 +88,21 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
this.requestHelper = requestHelper;
|
||||
this.infoAccountNewRequestValidator = infoAccountNewRequestValidator;
|
||||
this.informationAccountImdg = imdgProvider.getImdg(
|
||||
IMDGDistributedNames.Map_InformationAccount, InformationAccount.class
|
||||
IMDGDistributedNames.Map_InformationAccount, InformationAccount.class
|
||||
);
|
||||
this.accountImdg = imdgProvider.getImdg(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
callback(InformationAccountNewRequest.class)
|
||||
.setFunction(this::informationAccountNew)
|
||||
.forDestination(Consts.DESTINATION_INFORMATION_ACCOUNT_NEW, callbacks::put);
|
||||
.setFunction(this::informationAccountNew)
|
||||
.forDestination(Consts.DESTINATION_INFORMATION_ACCOUNT_NEW, callbacks::put);
|
||||
callback(InformationAccountNewRequest.class)
|
||||
.setFunction(this::informationAccountSystemNew)
|
||||
.forDestination(Consts.INFORMATION_ACCOUNT_SYSTEM_NEW, callbacks::put);
|
||||
.setFunction(this::informationAccountSystemNew)
|
||||
.forDestination(Consts.INFORMATION_ACCOUNT_SYSTEM_NEW, callbacks::put);
|
||||
init();
|
||||
}
|
||||
|
||||
|
|
@ -126,7 +126,7 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
ImdgPredicateBuilder accountPredicateBuilder = accountImdg.predicateBuilder();
|
||||
ImdgPredicate companyIdPredicate = accountPredicateBuilder.equals("companyId", 1L);
|
||||
ImdgPredicate accountTypePredicate = accountPredicateBuilder.and(accountPredicateBuilder.equals("accountType", AccountType.Anlt.getKey()),
|
||||
accountPredicateBuilder.equals("currency", currency));
|
||||
accountPredicateBuilder.equals("currency", currency));
|
||||
ImdgPredicate andPredicate = accountPredicateBuilder.and(companyIdPredicate, accountTypePredicate);
|
||||
Collection<Account> accountsAnlt = accountImdg.getCollectionObjectsByPredicate(andPredicate);
|
||||
if (accountsAnlt.isEmpty()) {
|
||||
|
|
@ -176,12 +176,12 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
if (txOk) {
|
||||
imdgTransaction.commitTransaction();
|
||||
log.debug("successfully processed, new information account id {}, new account id {}",
|
||||
informationAccountId,
|
||||
accountId);
|
||||
informationAccountId,
|
||||
accountId);
|
||||
} else {
|
||||
log.debug("failed insert, new information account id {}, new account id {} (if id = -1 then insert is failed)",
|
||||
informationAccountId,
|
||||
accountId);
|
||||
informationAccountId,
|
||||
accountId);
|
||||
imdgTransaction.rollbackTransaction();
|
||||
}
|
||||
}
|
||||
|
|
@ -201,8 +201,8 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
ImdgPredicateBuilder pb = accountImdg.predicateBuilder();
|
||||
{ // Проверка существования счёта
|
||||
Collection<Account> accountsAnlt = accountImdg.getCollectionObjectsByFieldValues(Map.of(
|
||||
"companyId", forCompanyId,
|
||||
"accountType", AccountType.Info.getKey()
|
||||
"companyId", forCompanyId,
|
||||
"accountType", AccountType.Info.getKey()
|
||||
));
|
||||
if (!accountsAnlt.isEmpty()) {
|
||||
String trueMessage = messageResolver.resolve(new EnumMessage(AccountError.InfoAccountAlreadyExist, forCompanyId));
|
||||
|
|
@ -223,9 +223,9 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
Long anltAccountId = null;
|
||||
{
|
||||
ImdgPredicate andPredicate = pb.and(
|
||||
pb.equals("companyId", 1L),
|
||||
pb.equals("accountType", AccountType.Anlt.getKey()),
|
||||
pb.equals("currency", currency)
|
||||
pb.equals("companyId", 1L),
|
||||
pb.equals("accountType", AccountType.Anlt.getKey()),
|
||||
pb.equals("currency", currency)
|
||||
);
|
||||
Collection<Account> accountsAnlt = accountImdg.getCollectionObjectsByPredicate(andPredicate);
|
||||
if (accountsAnlt.isEmpty()) {
|
||||
|
|
@ -274,12 +274,12 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
if (txOk) {
|
||||
imdgTransaction.commitTransaction();
|
||||
log.debug("successfully processed, new information account id {}, new account id {}",
|
||||
informationAccountId,
|
||||
accountId);
|
||||
informationAccountId,
|
||||
accountId);
|
||||
} else {
|
||||
log.debug("failed insert, new information account id {}, new account id {} (if id = -1 then insert is failed)",
|
||||
informationAccountId,
|
||||
accountId);
|
||||
informationAccountId,
|
||||
accountId);
|
||||
imdgTransaction.rollbackTransaction();
|
||||
}
|
||||
}
|
||||
|
|
@ -308,6 +308,7 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
public synchronized Long accountNextId(String currency) {
|
||||
return accountNextId(currency, 810L);
|
||||
}
|
||||
|
||||
/**
|
||||
* Сквозной номер инфо-счетов
|
||||
*
|
||||
|
|
@ -321,9 +322,17 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
if (infoCounter == null) synchronized (this) {
|
||||
if (infoCounter == null) {
|
||||
log.debug("Init account-information counter.");
|
||||
Collection<Account> allInfoAcc = accountImdg.getCollectionObjectsByFieldValues(Map.of(
|
||||
"accountType", AccountType.Info.getKey(),
|
||||
"currency", currency
|
||||
ImdgPredicateBuilder predicateBuilder = accountImdg.predicateBuilder();
|
||||
ImdgPredicate currencyPredicate = predicateBuilder.equals("currency", currency);
|
||||
if (CurrencyCode.RUB.equalsByKey(currency)) {
|
||||
currencyPredicate = predicateBuilder.or(
|
||||
currencyPredicate,
|
||||
predicateBuilder.isNull("currency")
|
||||
);
|
||||
}
|
||||
Collection<Account> allInfoAcc = accountImdg.getCollectionObjectsByPredicate(predicateBuilder.and(
|
||||
predicateBuilder.equals("accountType", AccountType.Info.getKey()),
|
||||
currencyPredicate
|
||||
));
|
||||
if (allInfoAcc.isEmpty()) {
|
||||
infoCounter = new AtomicLong(1);
|
||||
|
|
@ -353,7 +362,7 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
}
|
||||
infoCounter = new AtomicLong(maxN);
|
||||
log.debug("Parsed {} information accounts ({} pattern match) in map. n={}",
|
||||
allInfoAcc.size(), parsedCount, infoCounter.get());
|
||||
allInfoAcc.size(), parsedCount, infoCounter.get());
|
||||
if (parsedCount == 0 && lastAccount != null)
|
||||
log.debug("Last unparseable account: {}", lastAccount);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue