account-service backend-api http://jira.mfd.msk:8088/browse/CLS-548 information-account-new теперь не нужен, вместо него используется account-new

This commit is contained in:
AKurakin 2023-09-25 16:16:07 +03:00
parent 80fcb32abe
commit 155b899e5d
6 changed files with 56 additions and 99 deletions

View file

@ -49,9 +49,6 @@ public class AccountService extends QueueConsumer implements InitializingBean {
private final Logger log = LoggerFactory.getLogger(getClass());
private final ImdgProvider imdgProvider;
private final Imdg<Account> accountMap;
private final Imdg<InformationAccount> informationAccountMap;
private final Imdg<DepoAccount> depoAccountMap;
private final Imdg<ClearingAccount> clearingAccountMap;
private final Imdg<ClearingMemberCategory> clearingMemberCategoryMap;
private final Imdg<Relation> relationMap;
private final KafkaSender kafkaSender;
@ -87,9 +84,6 @@ public class AccountService extends QueueConsumer implements InitializingBean {
this.relationMap = imdgProvider.getImdg(
IMDGDistributedNames.Map_Relation, Relation.class
);
this.informationAccountMap = imdgProvider.getImdg(IMDGDistributedNames.Map_InformationAccount, InformationAccount.class);
this.depoAccountMap = imdgProvider.getImdg(IMDGDistributedNames.Map_DepoAccount, DepoAccount.class);
this.clearingAccountMap = imdgProvider.getImdg(IMDGDistributedNames.Map_ClearingAccount, ClearingAccount.class);
this.kafkaSender = kafkaSender;
this.messageResolver = messageResolver;
this.userRoleVerification = userRoleVerification;
@ -147,25 +141,47 @@ public class AccountService extends QueueConsumer implements InitializingBean {
requestInfoUpdate = fillAccountFromRelation(account, userRequest.getId(), false);
if (requestInfoUpdate != null) return requestInfoUpdate;
Long newId = accountMap.insert(account);
Long newId = null;
if (AccountType.Corr.equalsByKey(account.getAccountType())) {
// default, дополнительные таблицы не требуются
} else if (AccountType.Info.equalsByKey(account.getAccountType()))
makeInfoPart(account);
else if (AccountType.Depo.equalsByKey(account.getAccountType()))
makeDepoPart(account);
else if (AccountType.Clrn.equalsByKey(account.getAccountType()))
makeClrnPart(account);
else {
log.warn("Unexpected AccountType={}. Do not create additional record to other table's", account.getAccountType());
newId = accountMap.insert(account);
} else {
// Транзакцией
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
imdgTransaction.beginTransaction();
boolean txOk = false;
try {
Imdg<Account> accountMap = imdgTransaction.getImdg(IMDGDistributedNames.Map_Account, Account.class);
newId = accountMap.insert(account);
if (AccountType.Corr.equalsByKey(account.getAccountType())) {
// default, дополнительные таблицы не требуются
} else if (AccountType.Info.equalsByKey(account.getAccountType()))
makeInfoPart(imdgTransaction, account);
else if (AccountType.Depo.equalsByKey(account.getAccountType()))
makeDepoPart(imdgTransaction, account);
else if (AccountType.Clrn.equalsByKey(account.getAccountType()))
makeClrnPart(imdgTransaction, account);
else {
log.warn("Unexpected AccountType={}. Do not create additional record to other table's", account.getAccountType());
}
txOk = true;
} finally {
if (txOk) {
imdgTransaction.commitTransaction();
} else {
log.debug("failed insert, new account id {} rollback", newId);
imdgTransaction.rollbackTransaction();
}
}
}
log.debug("successfully processed, new account id {}", newId);
return null;
}
protected void makeInfoPart(Account account) {
protected void makeInfoPart(ImdgTransaction imdgTransaction, Account account) {
Imdg<InformationAccount> informationAccountMap = imdgTransaction.getImdg(IMDGDistributedNames.Map_InformationAccount, InformationAccount.class);
InformationAccount infoAcc = new InformationAccount();
infoAcc.setAccountId(account.getId());
Account firstAccountAntl = accountMap.getFirstObjectByFieldValues(Map.of(
@ -182,20 +198,22 @@ public class AccountService extends QueueConsumer implements InitializingBean {
log.debug("For account id={} make InformationAccount id={}", account.getId(), infoId);
}
protected void makeDepoPart(Account account) {
protected void makeDepoPart(ImdgTransaction imdgTransaction, Account account) {
Imdg<DepoAccount> depoAccountMap = imdgTransaction.getImdg(IMDGDistributedNames.Map_DepoAccount, DepoAccount.class);;
DepoAccount depoAcc = new DepoAccount();
depoAcc.setAccountId(account.getId());
depoAcc.setCompanyId(account.getCompanyId());
Long infoId = depoAccountMap.insert(depoAcc);
log.debug("For account id={} make DepoAccount id={}", account.getId(), infoId);
Long depoId = depoAccountMap.insert(depoAcc);
log.debug("For account id={} make DepoAccount id={}", account.getId(), depoId);
}
protected void makeClrnPart(Account account) {
protected void makeClrnPart(ImdgTransaction imdgTransaction, Account account) {
Imdg<ClearingAccount> clearingAccountMap = imdgTransaction.getImdg(IMDGDistributedNames.Map_ClearingAccount, ClearingAccount.class);;
ClearingAccount clnrAcc = new ClearingAccount();
clnrAcc.setAccountId(account.getId());
clnrAcc.setCompanyId(account.getCompanyId());
Long infoId = clearingAccountMap.insert(clnrAcc);
log.debug("For account id={} make ClearingAccount id={}", account.getId(), infoId);
Long clrnId = clearingAccountMap.insert(clnrAcc);
log.debug("For account id={} make ClearingAccount id={}", account.getId(), clrnId);
}
public RequestInfoUpdate correspondentAccountUpdate(BaseRequest<CorrespondentAccountUpdateRequest> userRequest) {

View file

@ -105,6 +105,7 @@ public class InformationAccountService extends QueueConsumer implements Initiali
init();
}
@Deprecated
public RequestInfoUpdate informationAccountNew(BaseRequest<InformationAccountNewRequest> userRequest) {
log.debug("InformationAccountNewRequest received");

View file

@ -51,13 +51,13 @@ public class InformationAccountController extends AbstractQueueController {
}
@ApiOperation(value = "Добавление информационного счета.")
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public CudResponse add(
@ApiParam(value = "Параметры команды в JSON формате.", required = true)
@RequestBody AccountInformationNewAction accountNewInformationAction) throws ExecutionException, InterruptedException {
return processRequest(Consts.DESTINATION_INFORMATION_ACCOUNT_NEW, accountNewInformationAction);
}
// @ApiOperation(value = "Добавление информационного счета.")
// @ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
// @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
// @ResponseBody
// public CudResponse add(
// @ApiParam(value = "Параметры команды в JSON формате.", required = true)
// @RequestBody AccountInformationNewAction accountNewInformationAction) throws ExecutionException, InterruptedException {
// return processRequest(Consts.DESTINATION_INFORMATION_ACCOUNT_NEW, accountNewInformationAction);
// }
}

View file

@ -1,6 +1,6 @@
{
"version": "3.8.0.54",
"version": "3.8.0.55",
"enums": {
@ -4627,34 +4627,7 @@
"type": 1,"name": "Идентификатор записи","shortname": "ID","searchable": true,"sortable": true
}
]
,"actions":[
{"method":"post",
"name": "Добавление информационного счета",
"confirmation": "companyId,account,status",
"class": "ru.spcex.clearing.backendapi.controller.request.cud.account.AccountInformationNewAction",
"fields": [
{"code": "companyId",
"type": 1,"name": "Наименование компании","shortname": "Компания","link": "company","linkCode": "shortName","required": true
}
,
{"code": "account",
"type": 2,"length": 50,"name": "Номер счета","shortname": "Счет","required": true
}
,
{"code": "status",
"type": 12,"name": "Наименование статуса","shortname": "Статус","link": "serviceStatus"
}
,
{"code": "accountType",
"type": 12,"name": "Наименование типа счета","shortname": "Тип","link": "accountType","required": true,"visible": false
}
]
}
]
}
,
"depoAccount": {

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--?xml-stylesheet type="text/xsl" href="\..\corp-reports\src\data\meta\meta.server.xslt"?-->
<meta version="3.8.0.54">
<meta version="3.8.0.55">
<!-- _xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" _xsi:noNamespaceSchemaLocation="file:///E:/d/projects/meta/from/meta.xsd" -->
<!--Здесь словари-->
<enums>
@ -1075,14 +1075,6 @@
<companyId type="1" dbname="Идентификатор компании" name="Наименование компании" shortname="Компания" searchable="true" sortable="true" visible="true" link="company" linkCode="shortName"/>
<serviceStatus field="accountId" type="12" dbname="Код статуса" name="Наименование статуса" shortname="Статус" searchable="true" sortable="true" visible="true" linkKeyCode="id" linkCode="status" link="account" extends="account" />
<id type="1" name="Идентификатор записи" shortname="ID" searchable="true" sortable="true"/>
<actions>
<post name="Добавление информационного счета" confirmation="companyId,account,status" class="ru.spcex.clearing.backendapi.controller.request.cud.account.AccountInformationNewAction">
<companyId type="1" name="Наименование компании" shortname="Компания" link="company" linkCode="shortName" required="true"/>
<account type="2" length="50" name="Номер счета" shortname="Счет" required="true"/>
<status type="12" name="Наименование статуса" shortname="Статус" link="serviceStatus"/>
<accountType type="12" name="Наименование типа счета" shortname="Тип" link="accountType" required="true" visible="false"/>
</post>
</actions>
</informationAccount>
<depoAccount name="Депозитарные счета" destination="accounting/depo-accounts" class="ru.clearing.classes.statics.data.account.DepoAccount" logUpdates="true" table="depo_account">
<accountId type="1" dbname="Идентификатор счета" name="Номер счета" shortname="Счет" searchable="true" sortable="true" visible="true" link="account" linkCode="account"/>

View file

@ -1,6 +1,6 @@
{
"version": "3.8.0.54",
"version": "3.8.0.55",
"enums": {
@ -4627,34 +4627,7 @@
"type": 1,"name": "Идентификатор записи","shortname": "ID","searchable": true,"sortable": true
}
]
,"actions":[
{"method":"post",
"name": "Добавление информационного счета",
"confirmation": "companyId,account,status",
"class": "ru.spcex.clearing.backendapi.controller.request.cud.account.AccountInformationNewAction",
"fields": [
{"code": "companyId",
"type": 1,"name": "Наименование компании","shortname": "Компания","link": "company","linkCode": "shortName","required": true
}
,
{"code": "account",
"type": 2,"length": 50,"name": "Номер счета","shortname": "Счет","required": true
}
,
{"code": "status",
"type": 12,"name": "Наименование статуса","shortname": "Статус","link": "serviceStatus"
}
,
{"code": "accountType",
"type": 12,"name": "Наименование типа счета","shortname": "Тип","link": "accountType","required": true,"visible": false
}
]
}
]
}
,
"depoAccount": {