filled accountType
fix build account field
This commit is contained in:
parent
5739606f8b
commit
10fe89dd10
3 changed files with 36 additions and 26 deletions
|
|
@ -14,6 +14,7 @@ import ru.clearing.classes.statics.data.account.DepoAccount;
|
|||
import ru.clearing.classes.statics.data.account.InformationAccount;
|
||||
import ru.clearing.classes.statics.data.company.ClearingMemberCategory;
|
||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||
import ru.clearing.classes.statics.data.misc.Currency;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
|
|
@ -51,6 +52,7 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
private final Imdg<Account> accountMap;
|
||||
private final Imdg<ClearingMemberCategory> clearingMemberCategoryMap;
|
||||
private final Imdg<Relation> relationMap;
|
||||
private final Imdg<Currency> currencyMap;
|
||||
private final KafkaSender kafkaSender;
|
||||
private final IMessageResolver messageResolver;
|
||||
private final UserRoleVerification userRoleVerification;
|
||||
|
|
@ -72,22 +74,25 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
AccountHelper accountHelper,
|
||||
InformationAccountService informationAccountService,
|
||||
@Qualifier("correspondentAccountNewRequestValidator")
|
||||
Function<CorrespondentAccountNewRequest, IValidator> accountNewRequestValidator,
|
||||
Function<CorrespondentAccountNewRequest, IValidator> accountNewRequestValidator,
|
||||
@Qualifier("correspondentAccountUpdateRequestValidator")
|
||||
Function<CorrespondentAccountUpdateRequest, IValidator> accountUpdateRequestValidator,
|
||||
Function<CorrespondentAccountUpdateRequest, IValidator> accountUpdateRequestValidator,
|
||||
@Qualifier("correspondentAccountBlockRequestValidator")
|
||||
Function<CommonIdRequest, IValidator> accountBlockRequestValidator) {
|
||||
Function<CommonIdRequest, IValidator> accountBlockRequestValidator) {
|
||||
super(kafkaQueue, kafkaProducer);
|
||||
this.accountHelper = accountHelper;
|
||||
this.imdgProvider = imdgProvider;
|
||||
this.accountMap = imdgProvider.getImdg(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
this.clearingMemberCategoryMap = imdgProvider.getImdg(
|
||||
IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class
|
||||
IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class
|
||||
);
|
||||
this.relationMap = imdgProvider.getImdg(
|
||||
IMDGDistributedNames.Map_Relation, Relation.class
|
||||
IMDGDistributedNames.Map_Relation, Relation.class
|
||||
);
|
||||
this.currencyMap = imdgProvider.getImdg(
|
||||
IMDGDistributedNames.Map_Currency, Currency.class
|
||||
);
|
||||
this.kafkaSender = kafkaSender;
|
||||
this.messageResolver = messageResolver;
|
||||
|
|
@ -103,18 +108,18 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
public void afterPropertiesSet() {
|
||||
imdgProvider.waitAvailable();
|
||||
callback(CorrespondentAccountNewRequest.class)
|
||||
.setFunction(this::accountCorrespondentNew)
|
||||
.forDestination(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_NEW, callbacks::put);
|
||||
.setFunction(this::accountCorrespondentNew)
|
||||
.forDestination(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_NEW, callbacks::put);
|
||||
callback(CorrespondentAccountUpdateRequest.class)
|
||||
.setFunction(this::correspondentAccountUpdate)
|
||||
.forDestination(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_UPDATE, callbacks::put);
|
||||
.setFunction(this::correspondentAccountUpdate)
|
||||
.forDestination(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_UPDATE, callbacks::put);
|
||||
callback(CommonIdRequest.class)
|
||||
.setFunction(this::correspondentAccountBlock)
|
||||
.forDestination(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_BLOCK, callbacks::put);
|
||||
.setFunction(this::correspondentAccountBlock)
|
||||
.forDestination(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_BLOCK, callbacks::put);
|
||||
|
||||
callback(AccountTerminationRequest.class)
|
||||
.setFunction(this::accountTerminationForCompany)
|
||||
.forDestination(Consts.ACCOUNT_TERMINATION, callbacks::put);
|
||||
.setFunction(this::accountTerminationForCompany)
|
||||
.forDestination(Consts.ACCOUNT_TERMINATION, callbacks::put);
|
||||
init();
|
||||
}
|
||||
|
||||
|
|
@ -130,6 +135,10 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
|
||||
CorrespondentAccountNewRequest req = userRequest.getRequestPayload();
|
||||
String currency = req.getCurrency() == null ? CurrencyCode.RUB.getKey() : req.getCurrency();
|
||||
Currency currencyByCode = currencyMap.getFirstObjectByPredicate(
|
||||
currencyMap.predicateBuilder().equals("currencyCode", currency)
|
||||
);
|
||||
Long currencyCodeId = CurrencyCode.RUB.getKey().equals(currency) ? 810 : currencyByCode.getId();
|
||||
|
||||
Instant now = Instant.now();
|
||||
Account account = new Account();
|
||||
|
|
@ -137,7 +146,7 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
account.setAccount(req.getAccount());
|
||||
if (AccountType.Info.equalsByKey(req.getAccountType())) {
|
||||
Long infoSequenceId = informationAccountService.accountNextId(currency);
|
||||
String accountValue = informationAccountService.generateInfoAccount(infoSequenceId);
|
||||
String accountValue = informationAccountService.generateInfoAccount(currencyCodeId, infoSequenceId);
|
||||
log.trace("New info-account SequenceId={} account={}", infoSequenceId, accountValue);
|
||||
account.setAccount(accountValue);
|
||||
}
|
||||
|
|
@ -199,9 +208,9 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
InformationAccount infoAcc = new InformationAccount();
|
||||
infoAcc.setAccountId(account.getId());
|
||||
Account firstAccountAntl = accountMap.getFirstObjectByFieldValues(Map.of(
|
||||
"companyId", Sender.One.getId(),
|
||||
"accountType", AccountType.Anlt.getKey(),
|
||||
"currency", account.getCurrency()
|
||||
"companyId", Sender.One.getId(),
|
||||
"accountType", AccountType.Anlt.getKey(),
|
||||
"currency", account.getCurrency()
|
||||
));
|
||||
if (firstAccountAntl == null) {
|
||||
log.warn("Can not find 1 ANTL {} account for fill information ClearingAccountId.", account.getCurrency());
|
||||
|
|
@ -320,7 +329,7 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
|
||||
Long reqId = kafkaSender.sendRequestToQueue(Consts.ACCOUNT_TERMINATION_STEP2, req);
|
||||
log.info("On termination request id={} send to next step {} new request id={}",
|
||||
userRequest.getId(), Consts.ACCOUNT_TERMINATION_STEP2, reqId);
|
||||
userRequest.getId(), Consts.ACCOUNT_TERMINATION_STEP2, reqId);
|
||||
|
||||
log.debug("successfully processed, account termination");
|
||||
return null;
|
||||
|
|
@ -329,9 +338,9 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
private RequestInfoUpdate makeError(Long reqId, AccountError accountError, Object... args) {
|
||||
String errMsg = messageResolver.resolve(new EnumMessage(accountError, args));
|
||||
return new RequestInfoUpdate()
|
||||
.setId(reqId)
|
||||
.setStatus(Status.Error)
|
||||
.setMessage(errMsg);
|
||||
.setId(reqId)
|
||||
.setStatus(Status.Error)
|
||||
.setMessage(errMsg);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -372,6 +372,7 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
|||
Instant now = Instant.now();
|
||||
Account account = new Account();
|
||||
account.setAccount(accountValue);
|
||||
account.setAccountType(AccountType.Clrn.getKey());
|
||||
account.setStatus(ServiceStatus.Active.getKey());
|
||||
if (accountValue.length() >= 7) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
|
||||
Long newId = informationAccountImdg.nextIDSequenceFor();
|
||||
Long infoSequenceId = accountNextId(currency);
|
||||
String accountValue = generateInfoAccount(infoSequenceId);
|
||||
String accountValue = generateInfoAccount(810L, infoSequenceId);
|
||||
log.trace("New info-account id={}, sequenceId={}, account={}", newId, infoSequenceId, accountValue);
|
||||
|
||||
ImdgPredicateBuilder accountPredicateBuilder = accountImdg.predicateBuilder();
|
||||
|
|
@ -217,7 +217,7 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
currency = CurrencyCode.RUB.getKey();
|
||||
Long newId = informationAccountImdg.nextIDSequenceFor();
|
||||
Long infoSequenceId = accountNextId(currency); // требуется последовательность n+1
|
||||
String accountValue = generateInfoAccount(infoSequenceId);
|
||||
String accountValue = generateInfoAccount(810L, infoSequenceId);
|
||||
log.trace("New info-account id={}, sequenceId={}, account={}", newId, infoSequenceId, accountValue);
|
||||
|
||||
Long anltAccountId = null;
|
||||
|
|
@ -301,8 +301,8 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
kafkaSender.sendRequestToQueue(Consts.CREATE_NOTIFICATION_NCMP, request);
|
||||
}
|
||||
|
||||
public String generateInfoAccount(Long id) {
|
||||
return "%d%d%08d%d".formatted(39911, 810, id, 7000);
|
||||
public String generateInfoAccount(Long currencyCodeId, Long id) {
|
||||
return "%d%d%08d%d".formatted(39911, currencyCodeId, id, 7000);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue