account-service http://jira.mfd.msk:8088/browse/CLS-679
This commit is contained in:
parent
2406152394
commit
655e8a6571
1 changed files with 23 additions and 5 deletions
|
|
@ -27,6 +27,7 @@ import ru.clearing.classes.statics.data.misc.Currency;
|
|||
import ru.clearing.classes.statics.data.misc.Notification;
|
||||
import ru.clearing.classes.statics.data.registry.TradingClearingRegistry;
|
||||
import ru.clearing.classes.statics.data.sdf.SDf52;
|
||||
import ru.clearing.platform.dictionary.ClearingAccountTypeDictionary;
|
||||
import ru.clearing.platform.dictionary.ClearingCategoryDictionary;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
|
|
@ -92,6 +93,7 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
|||
private final Imdg<ClearingCategoryDictionary> clearingCategoryImdg;
|
||||
private final Imdg<TradingClearingRegistry> tradingClearingRegistryImdg;
|
||||
private final Imdg<Notification> notificationImdg;
|
||||
private final Imdg<ClearingAccountTypeDictionary> clearingAccountTypeDictionaryImdg;
|
||||
|
||||
@Autowired
|
||||
public ClearingAccountService(Consumer<String, Object> kafkaQueue,
|
||||
|
|
@ -127,6 +129,7 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
|||
this.clearingCategoryImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_ClearingCategoryDictionary, ClearingCategoryDictionary.class);
|
||||
this.tradingClearingRegistryImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_TradingClearingRegistry, TradingClearingRegistry.class);
|
||||
this.notificationImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Notification, Notification.class);
|
||||
this.clearingAccountTypeDictionaryImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_ClearingAccountTypeDictionary, ClearingAccountTypeDictionary.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -378,6 +381,22 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
|||
* @return
|
||||
*/
|
||||
private synchronized Account createSdf52Account(String accountValue, String acctType, Long companyId, Long userRequestId) {
|
||||
{ // Валидация
|
||||
boolean existClearingAccountTypeDictionary;
|
||||
if (acctType == null) {
|
||||
existClearingAccountTypeDictionary = false;
|
||||
} else {
|
||||
ClearingAccountTypeDictionary catd = clearingAccountTypeDictionaryImdg.getFirstObjectByFieldValues(
|
||||
Map.of("code", acctType));
|
||||
existClearingAccountTypeDictionary = catd != null;
|
||||
}
|
||||
if (!existClearingAccountTypeDictionary) {
|
||||
String errMsg = messageResolver.resolve(new EnumMessage(AccountError.DictionaryNotFound, acctType, clearingAccountTypeDictionaryImdg.getMapName()));
|
||||
log.warn(errMsg);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Instant now = Instant.now();
|
||||
Account account = new Account();
|
||||
account.setAccount(accountValue);
|
||||
|
|
@ -388,7 +407,9 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
|||
Long currencyId = Long.valueOf(accountValue.substring(5, 8));
|
||||
Currency currency = currImdg.getSingleObjectByID(currencyId);
|
||||
account.setCurrency(currency.getCurrencyCode());
|
||||
} catch (Throwable e) {}
|
||||
} catch (Throwable e) {
|
||||
log.trace("When obtain currency from accountValue: {}", e.toString());
|
||||
}
|
||||
}
|
||||
if (TextUtil.isEmpty(account.getCurrency())) {
|
||||
log.warn("Sdf52: Wrong accountValue=\"{}\" - can not parse for get currency", accountValue);
|
||||
|
|
@ -477,14 +498,11 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
|||
Account account = sDf52.getAccount() == null ? null : accountImdg.getFirstObjectByFieldValues(accountQuery);
|
||||
if (account == null) {
|
||||
if (SDFProcessService.SDF52_STATUS_3Open.equals(sDf52.getStatus())) {
|
||||
//log.debug("By generationId={} s_df52[{}].status={}, but account not found (query: {}). Continue with result OK for status 3",
|
||||
// groupId, sDf52.getId(), sDf52.getStatus(), accountQuery);
|
||||
// todo http://jira.mfd.msk:8088/browse/CLS-585 добавят поле acc_type в формат дф52
|
||||
log.trace("By generationId={} s_df52[{}].status={}, account not found (query: {}). Try create new account.",
|
||||
groupId, sDf52.getId(), sDf52.getStatus(), accountQuery);
|
||||
account = createSdf52Account(sDf52.getAccount(),sDf52.getAcc_type(), company.getId(), systemRequest.getId());
|
||||
if (account == null) {
|
||||
log.warn("Can not create account: \"{}\", companyId={}. Ignore SDF52.id={}",
|
||||
log.info("Can not create account: \"{}\", companyId={}. Ignore SDF52.id={}",
|
||||
sDf52.getAccount(), company.getId(), sDf52.getId());
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue