This commit is contained in:
parent
478b711dee
commit
b569062294
1 changed files with 48 additions and 17 deletions
|
|
@ -16,8 +16,12 @@ import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
|||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.schedule.LauncherCommandRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.platform.enumeration.RegistryTradingParams;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
import ru.spcex.platform.imdg.api.predicate.specific.RegistryCodeSqlBuilder;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Collection;
|
||||
|
|
@ -58,8 +62,12 @@ public class MoneyBalanceRegisterService extends QueueConsumer implements Initia
|
|||
|
||||
public void moneyBalanceRegisterNew(BaseRequest<LauncherCommandRequest> userRequest) {
|
||||
log.debug("LauncherCommandRequest received from {}", createRegistry_GBRR.topic());
|
||||
String sqlConditionForRegistry = getSqlForRegistries(userRequest.getRequestPayload().getCompanyId());
|
||||
Collection<Registry> registries = registryMap.getCollectionObjectsBySQL(sqlConditionForRegistry);
|
||||
if (userRequest.getRequestPayload().getCompanyId() == null) {
|
||||
log.warn("LauncherCommandRequest.id={} without companyId", userRequest.getId());
|
||||
return;
|
||||
}
|
||||
ImdgPredicate sqlConditionForRegistry = getSqlForRegistries(userRequest.getRequestPayload().getCompanyId());
|
||||
Collection<Registry> registries = registryMap.getCollectionObjectsByPredicate(sqlConditionForRegistry);
|
||||
if (registries == null) {
|
||||
log.debug("No registry with such conditions {}", sqlConditionForRegistry);
|
||||
return;
|
||||
|
|
@ -84,9 +92,9 @@ public class MoneyBalanceRegisterService extends QueueConsumer implements Initia
|
|||
private void insertMoneyBalanceRegister(Registry registry) {
|
||||
log.trace("Started generating MoneyBalanceRegister entity...");
|
||||
MoneyBalanceRegister moneyBalanceRegister = new MoneyBalanceRegister();
|
||||
Registry registryForRemainderSum = registryMap.getFirstObjectBySQL(getSqlForRemainderSum(registry.getCompanyId(), registry.getAccount()));
|
||||
Registry registryForBlockedSum = registryMap.getFirstObjectBySQL(getSqlForBlockedSum(registry.getCompanyId(), registry.getAccount()));
|
||||
Registry registryForUnblockedSum = registryMap.getFirstObjectBySQL(getSqlForUnblockedSum(registry.getCompanyId(), registry.getAccount()));
|
||||
Registry registryForRemainderSum = registryMap.getFirstObjectByPredicate(getSqlForRemainderSum(registry.getCompanyId(), registry.getAccount()));
|
||||
Registry registryForBlockedSum = registryMap.getFirstObjectByPredicate(getSqlForBlockedSum(registry.getCompanyId(), registry.getAccount()));
|
||||
Registry registryForUnblockedSum = registryMap.getFirstObjectByPredicate(getSqlForUnblockedSum(registry.getCompanyId(), registry.getAccount()));
|
||||
Company company = companyMap.getFirstObjectByFieldValues(Map.of("id", 2L));
|
||||
CompanySymbols companySymbol = companySymbolsMap.getFirstObjectByFieldValues(Map.of("companyId", registry.getCompanyId()));
|
||||
String setHouseName = company != null ? company.getShortName() : null;
|
||||
|
|
@ -119,24 +127,47 @@ public class MoneyBalanceRegisterService extends QueueConsumer implements Initia
|
|||
log.debug("inserted successfully MoneyBalanceRegister entity with id: {}", moneyBalanceRegister.getId());
|
||||
}
|
||||
|
||||
private String getSqlForRegistries(Long companyId) {
|
||||
log.trace("Started generating sql predicate for registries...");
|
||||
return String.format("companyId = '%s' and registryCode LIKE 'AM__'", companyId);
|
||||
private ImdgPredicate getSqlForRegistries(Long companyId) {
|
||||
ImdgPredicateBuilder pb = registryMap.predicateBuilder();
|
||||
ImdgPredicate prdct = pb.and(
|
||||
pb.equals("companyId", companyId),
|
||||
pb.sql(RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.AM__).build())
|
||||
);
|
||||
log.trace("sql predicate for registries {}", prdct);
|
||||
return prdct;
|
||||
}
|
||||
|
||||
private String getSqlForRemainderSum(Long companyId, String account) {
|
||||
log.trace("Started generating sql predicate for registries remainder sum...");
|
||||
return String.format("companyId = '%s' and account = '%s' and registryCode LIKE 'AM_T'", companyId, account);
|
||||
private ImdgPredicate getSqlForRemainderSum(Long companyId, String account) {
|
||||
ImdgPredicateBuilder pb = registryMap.predicateBuilder();
|
||||
ImdgPredicate prdct = pb.and(
|
||||
pb.equals("companyId", companyId),
|
||||
pb.equals("account", account),
|
||||
pb.sql(RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.AM_T).build())
|
||||
);
|
||||
log.trace("sql predicate for registries remainder sum {}", prdct);
|
||||
return prdct;
|
||||
}
|
||||
|
||||
private String getSqlForBlockedSum(Long companyId, String account) {
|
||||
log.trace("Started generating sql predicate for registries blocked sum...");
|
||||
return String.format("companyId = '%s' and account = '%s' and registryCode LIKE 'AM_B'", companyId, account);
|
||||
private ImdgPredicate getSqlForBlockedSum(Long companyId, String account) {
|
||||
ImdgPredicateBuilder pb = registryMap.predicateBuilder();
|
||||
ImdgPredicate prdct = pb.and(
|
||||
pb.equals("companyId", companyId),
|
||||
pb.equals("account", account),
|
||||
pb.sql(RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.AM_B).build())
|
||||
);
|
||||
log.trace("sql predicate for registries blocked sum {}", prdct);
|
||||
return prdct;
|
||||
}
|
||||
|
||||
private String getSqlForUnblockedSum(Long companyId, String account) {
|
||||
log.trace("Started generating sql predicate for registries unblocked sum...");
|
||||
return String.format("companyId = '%s' and account = '%s' and registryCode LIKE 'AM_F'", companyId, account);
|
||||
private ImdgPredicate getSqlForUnblockedSum(Long companyId, String account) {
|
||||
ImdgPredicateBuilder pb = registryMap.predicateBuilder();
|
||||
ImdgPredicate prdct = pb.and(
|
||||
pb.equals("companyId", companyId),
|
||||
pb.equals("account", account),
|
||||
pb.sql(RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.AM_F).build())
|
||||
);
|
||||
log.trace("sql predicate for registries unblocked sum {}", prdct);
|
||||
return prdct;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue