http://jira.mfd.msk:8088/browse/CLS-585 todo уточнить задание
This commit is contained in:
parent
9e9a801bde
commit
943ec5f762
3 changed files with 84 additions and 8 deletions
|
|
@ -70,6 +70,7 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
|||
private final Function<ClearingAccountUpdateRequest, IValidator> clearingAccountUpdateRequestValidator;
|
||||
|
||||
private final Imdg<Account> accountImdg;
|
||||
private final Imdg<ClearingAccount> clearingAccountImdg;
|
||||
private final Imdg<Company> companyImdg;
|
||||
private final Imdg<Relation> relationImdg;
|
||||
private final Imdg<ClearingMemberCategory> clearingMemberCategoryImdg;
|
||||
|
|
@ -103,6 +104,7 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
|||
this.clearingAccountUpdateRequestValidator = clearingAccountUpdateRequestValidator;
|
||||
|
||||
this.accountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
this.clearingAccountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_ClearingAccount, ClearingAccount.class);
|
||||
this.companyImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Company, Company.class);
|
||||
this.relationImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Relation, Relation.class);
|
||||
this.clearingMemberCategoryImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class);
|
||||
|
|
@ -320,6 +322,48 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Логика похожа на SDF01
|
||||
* @param accountValue account
|
||||
* @param companyId
|
||||
* @param userRequestId для лога
|
||||
* @return
|
||||
*/
|
||||
private Account createSdf52Account(String accountValue, Long companyId, Long userRequestId) {
|
||||
Instant now = Instant.now();
|
||||
Account account = new Account();
|
||||
account.setAccount(accountValue);
|
||||
account.setAccountType(AccountType.Clrn.getKey());
|
||||
account.setStatus(ServiceStatus.Active.getKey());
|
||||
account.setCompanyId(companyId);
|
||||
account.setCreated(now);
|
||||
account.setUpdated(now);
|
||||
RequestInfoUpdate requestInfoUpdate = accountService.fillAccountFromRelation(account, userRequestId, true);
|
||||
if (requestInfoUpdate != null) {
|
||||
log.warn("Error fill new account from relation. {}", /*account.getId(),*/ requestInfoUpdate.getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
if (accountImdg.getFirstObjectBySQL("account = '%s'".formatted(accountValue)) != null) {
|
||||
log.debug("Account {} already exists", accountValue);
|
||||
return null;
|
||||
}
|
||||
|
||||
Long clearingAccountId = -1L;
|
||||
Long accountId = -1L;
|
||||
ClearingAccount clearingAccount = null;
|
||||
accountId = accountImdg.insert(account);
|
||||
|
||||
clearingAccount = new ClearingAccount();
|
||||
clearingAccount.setCompanyId(companyId);
|
||||
clearingAccount.setAccountId(accountId);
|
||||
// !!!! clearingAccount.setClearingAccountType(ClearingAccountType.?);//todo на уточнении ТЗ...
|
||||
clearingAccountId = clearingAccountImdg.insert(clearingAccount);
|
||||
log.debug("New account {}, clearingAccount {} was created.", accountId, clearingAccountId);
|
||||
|
||||
return account;
|
||||
}
|
||||
|
||||
public RequestInfoUpdate accountUpdateSdf52(BaseRequest<StatementRequest> systemRequest) {
|
||||
log.debug("accountUpdateSdf52 StatementRequest received, id={}", systemRequest.getId());
|
||||
|
||||
|
|
@ -362,11 +406,20 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
|||
);
|
||||
Account account = sDf52.getAccount() == null ? null : accountImdg.getFirstObjectByFieldValues(accountQuery);
|
||||
if (account == null) {
|
||||
String msg = messageResolver.resolve(new EnumMessage(AccountError.AccountNotFound, sDf52.getAccount()));
|
||||
log.warn("By generationId={} s_df52[{}] (query: {}) error: {}", groupId, sDf52.getId(), accountQuery, msg);
|
||||
toProcessSDF53.add(new MutableTriple<>(sDf52, null,
|
||||
makeSdfErrorText(AccountError.AccountNotFound, SDFProcessService.SDF_STATUS_ERROR_COMPANY_NOT_FOUND)));
|
||||
continue;
|
||||
if (SDFProcessService.SDF52_STATUS_3Open.equals(sDf52.getStatus())) {
|
||||
account = createSdf52Account(sDf52.getAccount(), company.getId(), systemRequest.getId());
|
||||
if (account == null) {
|
||||
log.trace("Can not create account: \"{}\", companyId={}. Ignore SDF52.id={}",
|
||||
sDf52.getAccount(), company.getId(), sDf52.getId());
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
String msg = messageResolver.resolve(new EnumMessage(AccountError.AccountNotFound, sDf52.getAccount()));
|
||||
log.warn("By generationId={} s_df52[{}] (query: {}) error: {}", groupId, sDf52.getId(), accountQuery, msg);
|
||||
toProcessSDF53.add(new MutableTriple<>(sDf52, null,
|
||||
makeSdfErrorText(AccountError.AccountNotFound, SDFProcessService.SDF_STATUS_ERROR_COMPANY_NOT_FOUND)));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
toProcessSDF53.add(new MutableTriple<>(sDf52, account, SDFProcessService.SDF_STATUS_OK));
|
||||
toUpdate.add(new Pair<>(sDf52, account));
|
||||
|
|
|
|||
|
|
@ -38,6 +38,11 @@ public class SDFProcessService {
|
|||
public static final String SDF_STATUS_ERROR_NO_TRADE = "4"; // (Ошибка. Торги не идут)
|
||||
public static final String SDF_STATUS_ERROR = "9"; // (Другие ошибки, выявленные в КС) - если получены другие ошибки (т.е. account НЕ обновлена по sDf52).
|
||||
|
||||
protected static final Long SDF52_STATUS_0Blocked = 0L;
|
||||
protected static final Long SDF52_STATUS_1Unblocked = 1L;
|
||||
protected static final Long SDF52_STATUS_2Closed = 2L;
|
||||
protected static final Long SDF52_STATUS_3Open = 3L;
|
||||
|
||||
final protected Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
protected final Producer<String, Object> kafkaResponseQueue;
|
||||
|
|
@ -129,12 +134,12 @@ public class SDFProcessService {
|
|||
* @return AccountStatus или null
|
||||
*/
|
||||
public AccountStatus parseSdf52Status(Long status) {
|
||||
if (Long.valueOf(1L).equals(status) || Long.valueOf(3L).equals(status)) {
|
||||
if (SDF52_STATUS_1Unblocked.equals(status) || SDF52_STATUS_3Open.equals(status)) {
|
||||
return AccountStatus.ACTIVE;
|
||||
} else if (Long.valueOf(0L).equals(status)) {
|
||||
} else if (SDF52_STATUS_0Blocked.equals(status)) {
|
||||
return AccountStatus.BLOCKED;
|
||||
}
|
||||
if (Long.valueOf(2L).equals(status)) {
|
||||
if (SDF52_STATUS_2Closed.equals(status)) {
|
||||
return AccountStatus.CLOSE;
|
||||
}
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package ru.spcex.platform.enumeration;
|
||||
|
||||
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||
|
||||
public enum ClearingAccountType implements IEnumKey {
|
||||
A("A"), B("B");
|
||||
|
||||
private final String key;
|
||||
|
||||
ClearingAccountType(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue