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