This commit is contained in:
AKurakin 2024-04-12 19:09:47 +03:00
parent 0dfd89d294
commit 89bf4fe820
3 changed files with 61 additions and 3 deletions

View file

@ -187,6 +187,10 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
imdgTransaction.rollbackTransaction();
}
}
if (txOk && account != null) {
sendNotificationAccountNewRequest(account);
}
return null;
}
@ -242,6 +246,7 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
AccountSdf01Request req = userRequest.getRequestPayload();
List<AccountSdfToStatementRequestPart> accountToStatement = new ArrayList<>();
List<Account> accountsToNotification = new ArrayList<>();
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
boolean txOk = false;
@ -289,6 +294,7 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
Long accountId = -1L;
ClearingAccount clearingAccount = null;
accountId = accountImdg.insert(account);
accountsToNotification.add(account);
clearingAccount = new ClearingAccount();
clearingAccount.setCompanyId(accountReq.getCompanyId());
@ -317,6 +323,11 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
sendStatementRequestBack(req.getGroupingSdf01Id(), req.getGroupingSdf02Id(), accountToStatement);
if (txOk) {
for (Account account : accountsToNotification)
sendNotificationAccountNewRequest(account);
}
log.debug("successfully processed, grouping id={}, processed number={}", req.getGroupingSdf01Id(), accountToStatement.size());
return null;
@ -531,6 +542,24 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
}
/**
* Формирование уведомления о добавлении счёта
*/
public Long sendNotificationAccountNewRequest(Account account) {
String message = String.format("Добавлен новый счет %s", account.getAccount());
final String destination = Consts.NOTIFICATION_NEW;
NotificationNewRequest request = new NotificationNewRequest();
//request.setObjectId(account.getId());
request.setObjectType(ObjectType.registry.getKey());
request.setPriority(Priority.HIGH.getKey());
request.setComment(message);
log.debug("Send message to kafka \"{}\": {}", destination, LogFormatter.toStringWrapper(request));
Long rKey = kafkaSender.sendRequestToQueue(destination, request);
log.trace("About account.id={} send notification request id={}", account.getId(), rKey);
return rKey;
}
// --------- notification apply system -----------
public static class SDF52WaitingData {
public BaseRequest<StatementRequest> systemRequest;

View file

@ -18,6 +18,7 @@ import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdf0
import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdfRequestPart;
import ru.spcex.clearing.platform.messaging.domain.cud.balance.AccountSdfToStatementRequestPart;
import ru.spcex.clearing.platform.messaging.domain.cud.balance.StatementRequest;
import ru.spcex.clearing.platform.messaging.domain.cud.utilities.NotificationNewRequest;
import ru.spcex.clearing.platform.messaging.serialization.LogFormatter;
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
@ -129,6 +130,9 @@ public class DepoAccountService extends QueueConsumer implements InitializingBea
imdgTransaction.rollbackTransaction();
}
}
if (txOk && depoAccount != null) {
sendNotificationAccountNewRequest(account);
}
return null;
}
@ -137,6 +141,7 @@ public class DepoAccountService extends QueueConsumer implements InitializingBea
AccountSdf01Request req = userRequest.getRequestPayload();
List<AccountSdfToStatementRequestPart> accountToStatement = new ArrayList<>();
List<Account> accountsToNotification = new ArrayList<>();
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
boolean txOk = false;
@ -184,7 +189,8 @@ public class DepoAccountService extends QueueConsumer implements InitializingBea
Long depoAccountId = -1L;
Long accountId = -1L;
accountId = accountImdg.insert(account);
accountId = accountImdg.insert(account);
accountsToNotification.add(account);
DepoAccount depoAccount = new DepoAccount();
depoAccount.setCompanyId(accountReq.getCompanyId());
@ -219,6 +225,11 @@ public class DepoAccountService extends QueueConsumer implements InitializingBea
}
sendStatementRequestBack(req.getGroupingSdf01Id(), req.getGroupingSdf02Id(), accountToStatement);
if (txOk) {
for (Account account : accountsToNotification)
sendNotificationAccountNewRequest(account);
}
log.debug("successfully processed, grouping id={}, processed number={}", req.getGroupingSdf01Id(), accountToStatement.size());
return null;
@ -228,10 +239,27 @@ public class DepoAccountService extends QueueConsumer implements InitializingBea
StatementRequest request = new StatementRequest();
request.setGroupId(groupingSdf01Id);
request.setChildGenerationId(groupingSdf02Id);
request.setContinueSdf(true); //fixme????
request.setContinueSdf(true);
request.setAccountCreationResults(results);
request.setTable(SdfTable.SDF_08); // по нему запрос получили
log.debug("Send message to kafka \"{}\": {}", Consts.STATEMENT_PROCESS, LogFormatter.toStringWrapper(request));
kafkaSender.sendRequestToQueue(Consts.STATEMENT_PROCESS, request);
}
/**
* Формирование уведомления о добавлении счёта
*/
public Long sendNotificationAccountNewRequest(Account account) {
String message = String.format("Добавлен новый счет %s", account.getAccount());
final String destination = Consts.NOTIFICATION_NEW;
NotificationNewRequest request = new NotificationNewRequest();
//request.setObjectId(account.getId());
request.setObjectType(ObjectType.registry.getKey());
request.setPriority(Priority.HIGH.getKey());
request.setComment(message);
log.debug("Send message to kafka \"{}\": {}", destination, LogFormatter.toStringWrapper(request));
Long rKey = kafkaSender.sendRequestToQueue(destination, request);
log.trace("About account.id={} send notification request id={}", account.getId(), rKey);
return rKey;
}
}

View file

@ -4,7 +4,8 @@ import ru.spcex.platform.utils.enumeration.IEnumKey;
public enum ObjectType implements IEnumKey {
statement("STMT"), vfrs("VFRS"), rgst("RGST"), gateway("GTWY"), session("SESN"),
account_block("ACCB"), account_active("ACCA"), diff("DIFF");
account_block("ACCB"), account_active("ACCA"), diff("DIFF"),
registry("RGST");
private final String key;