account-service utility-service http://jira.mfd.msk:8088/browse/CLS-588
This commit is contained in:
parent
0dfd89d294
commit
89bf4fe820
3 changed files with 61 additions and 3 deletions
|
|
@ -187,6 +187,10 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
||||||
imdgTransaction.rollbackTransaction();
|
imdgTransaction.rollbackTransaction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (txOk && account != null) {
|
||||||
|
sendNotificationAccountNewRequest(account);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -242,6 +246,7 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
||||||
|
|
||||||
AccountSdf01Request req = userRequest.getRequestPayload();
|
AccountSdf01Request req = userRequest.getRequestPayload();
|
||||||
List<AccountSdfToStatementRequestPart> accountToStatement = new ArrayList<>();
|
List<AccountSdfToStatementRequestPart> accountToStatement = new ArrayList<>();
|
||||||
|
List<Account> accountsToNotification = new ArrayList<>();
|
||||||
|
|
||||||
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
||||||
boolean txOk = false;
|
boolean txOk = false;
|
||||||
|
|
@ -289,6 +294,7 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
||||||
Long accountId = -1L;
|
Long accountId = -1L;
|
||||||
ClearingAccount clearingAccount = null;
|
ClearingAccount clearingAccount = null;
|
||||||
accountId = accountImdg.insert(account);
|
accountId = accountImdg.insert(account);
|
||||||
|
accountsToNotification.add(account);
|
||||||
|
|
||||||
clearingAccount = new ClearingAccount();
|
clearingAccount = new ClearingAccount();
|
||||||
clearingAccount.setCompanyId(accountReq.getCompanyId());
|
clearingAccount.setCompanyId(accountReq.getCompanyId());
|
||||||
|
|
@ -317,6 +323,11 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
||||||
|
|
||||||
|
|
||||||
sendStatementRequestBack(req.getGroupingSdf01Id(), req.getGroupingSdf02Id(), accountToStatement);
|
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());
|
log.debug("successfully processed, grouping id={}, processed number={}", req.getGroupingSdf01Id(), accountToStatement.size());
|
||||||
|
|
||||||
return null;
|
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 -----------
|
// --------- notification apply system -----------
|
||||||
public static class SDF52WaitingData {
|
public static class SDF52WaitingData {
|
||||||
public BaseRequest<StatementRequest> systemRequest;
|
public BaseRequest<StatementRequest> systemRequest;
|
||||||
|
|
|
||||||
|
|
@ -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.account.sdf01.AccountSdfRequestPart;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.balance.AccountSdfToStatementRequestPart;
|
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.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.serialization.LogFormatter;
|
||||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||||
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
||||||
|
|
@ -129,6 +130,9 @@ public class DepoAccountService extends QueueConsumer implements InitializingBea
|
||||||
imdgTransaction.rollbackTransaction();
|
imdgTransaction.rollbackTransaction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (txOk && depoAccount != null) {
|
||||||
|
sendNotificationAccountNewRequest(account);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -137,6 +141,7 @@ public class DepoAccountService extends QueueConsumer implements InitializingBea
|
||||||
|
|
||||||
AccountSdf01Request req = userRequest.getRequestPayload();
|
AccountSdf01Request req = userRequest.getRequestPayload();
|
||||||
List<AccountSdfToStatementRequestPart> accountToStatement = new ArrayList<>();
|
List<AccountSdfToStatementRequestPart> accountToStatement = new ArrayList<>();
|
||||||
|
List<Account> accountsToNotification = new ArrayList<>();
|
||||||
|
|
||||||
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
||||||
boolean txOk = false;
|
boolean txOk = false;
|
||||||
|
|
@ -184,7 +189,8 @@ public class DepoAccountService extends QueueConsumer implements InitializingBea
|
||||||
Long depoAccountId = -1L;
|
Long depoAccountId = -1L;
|
||||||
Long accountId = -1L;
|
Long accountId = -1L;
|
||||||
|
|
||||||
accountId = accountImdg.insert(account);
|
accountId = accountImdg.insert(account);
|
||||||
|
accountsToNotification.add(account);
|
||||||
|
|
||||||
DepoAccount depoAccount = new DepoAccount();
|
DepoAccount depoAccount = new DepoAccount();
|
||||||
depoAccount.setCompanyId(accountReq.getCompanyId());
|
depoAccount.setCompanyId(accountReq.getCompanyId());
|
||||||
|
|
@ -219,6 +225,11 @@ public class DepoAccountService extends QueueConsumer implements InitializingBea
|
||||||
}
|
}
|
||||||
|
|
||||||
sendStatementRequestBack(req.getGroupingSdf01Id(), req.getGroupingSdf02Id(), accountToStatement);
|
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());
|
log.debug("successfully processed, grouping id={}, processed number={}", req.getGroupingSdf01Id(), accountToStatement.size());
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -228,10 +239,27 @@ public class DepoAccountService extends QueueConsumer implements InitializingBea
|
||||||
StatementRequest request = new StatementRequest();
|
StatementRequest request = new StatementRequest();
|
||||||
request.setGroupId(groupingSdf01Id);
|
request.setGroupId(groupingSdf01Id);
|
||||||
request.setChildGenerationId(groupingSdf02Id);
|
request.setChildGenerationId(groupingSdf02Id);
|
||||||
request.setContinueSdf(true); //fixme????
|
request.setContinueSdf(true);
|
||||||
request.setAccountCreationResults(results);
|
request.setAccountCreationResults(results);
|
||||||
request.setTable(SdfTable.SDF_08); // по нему запрос получили
|
request.setTable(SdfTable.SDF_08); // по нему запрос получили
|
||||||
log.debug("Send message to kafka \"{}\": {}", Consts.STATEMENT_PROCESS, LogFormatter.toStringWrapper(request));
|
log.debug("Send message to kafka \"{}\": {}", Consts.STATEMENT_PROCESS, LogFormatter.toStringWrapper(request));
|
||||||
kafkaSender.sendRequestToQueue(Consts.STATEMENT_PROCESS, 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,8 @@ import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||||
|
|
||||||
public enum ObjectType implements IEnumKey {
|
public enum ObjectType implements IEnumKey {
|
||||||
statement("STMT"), vfrs("VFRS"), rgst("RGST"), gateway("GTWY"), session("SESN"),
|
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;
|
private final String key;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue