reports-service: fixes

This commit is contained in:
akulikov 2024-05-20 14:41:40 +03:00
parent c5cad4d27c
commit 09e47209aa
2 changed files with 32 additions and 18 deletions

View file

@ -48,6 +48,10 @@ public class KSRepCashRegisterSumsReport {
@CsvBindByPosition(position = 8) @CsvBindByPosition(position = 8)
private String operType; private String operType;
@CsvBindByName(column = "CURRENCY")
@CsvBindByPosition(position = 9)
private String currency;
public String getFirmId() { public String getFirmId() {
return firmId; return firmId;
@ -120,4 +124,12 @@ public class KSRepCashRegisterSumsReport {
public void setOperType(String operType) { public void setOperType(String operType) {
this.operType = operType; this.operType = operType;
} }
public String getCurrency() {
return currency;
}
public void setCurrency(String currency) {
this.currency = currency;
}
} }

View file

@ -78,11 +78,11 @@ public class KSRepCashRegisterSumsReportBuilder extends CSVReportBuilder<EmptyPa
ImdgPredicate registryPredicate = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.DM_I).buildPredicate(pb); ImdgPredicate registryPredicate = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.DM_I).buildPredicate(pb);
ImdgPredicate finalPredicate = pb.and( ImdgPredicate finalPredicate = pb.and(
pb.greatEqual("updated", instantNow.truncatedTo(ChronoUnit.DAYS)), pb.greatEqual("updated", instantNow.truncatedTo(ChronoUnit.DAYS)),
pb.less("updated", instantNow.plus(1, ChronoUnit.DAYS).truncatedTo(ChronoUnit.DAYS)), pb.less("updated", instantNow.plus(1, ChronoUnit.DAYS).truncatedTo(ChronoUnit.DAYS)),
pb.equals("registryStatus", RegistryStatus.OK.getKey()), pb.equals("registryStatus", RegistryStatus.OK.getKey()),
pb.notNull("tradingClearingRegistry"), pb.notNull("tradingClearingRegistry"),
registryPredicate registryPredicate
); );
Collection<Registry> registries = registryImdg.getCollectionObjectsByPredicate(finalPredicate); Collection<Registry> registries = registryImdg.getCollectionObjectsByPredicate(finalPredicate);
@ -92,8 +92,8 @@ public class KSRepCashRegisterSumsReportBuilder extends CSVReportBuilder<EmptyPa
Company company = companyImdg.getSingleObjectByID(registry.getCompanyId()); Company company = companyImdg.getSingleObjectByID(registry.getCompanyId());
if (company == null) { if (company == null) {
log.warn("For registry id = {} company with id = {} not found, registry was skipped", log.warn("For registry id = {} company with id = {} not found, registry was skipped",
registry.getId(), registry.getId(),
registry.getCompanyId()); registry.getCompanyId());
continue; continue;
} }
if (!WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus())) continue; if (!WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus())) continue;
@ -101,18 +101,19 @@ public class KSRepCashRegisterSumsReportBuilder extends CSVReportBuilder<EmptyPa
Registry pairRegistry = null; Registry pairRegistry = null;
ImdgPredicate pairRegistryPredicate = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.AM_T).buildPredicate(pb); ImdgPredicate pairRegistryPredicate = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.AM_T).buildPredicate(pb);
Collection<Registry> pairRegistries = registryImdg.getCollectionObjectsByPredicate( Collection<Registry> pairRegistries = registryImdg.getCollectionObjectsByPredicate(
pb.and( pb.and(
pb.equals("tradingCode", registry.getTradingCode()), pb.equals("tradingCode", registry.getTradingCode()),
pb.equals("account", registry.getAccount()), pb.equals("account", registry.getAccount()),
pairRegistryPredicate pairRegistryPredicate
) )
); );
if (pairRegistries.isEmpty()) log.warn("Pair AM_T registry for registry (id = {}) not found", registry.getId()); if (pairRegistries.isEmpty())
log.warn("Pair AM_T registry for registry (id = {}) not found", registry.getId());
pairRegistry = pairRegistries.iterator().next(); pairRegistry = pairRegistries.iterator().next();
if (pairRegistries.size() > 1) { if (pairRegistries.size() > 1) {
log.warn("For registry (id = {}) found > 1 AM_T registry, use first (id = {})", log.warn("For registry (id = {}) found > 1 AM_T registry, use first (id = {})",
registry.getId(), registry.getId(),
pairRegistry.getId()); pairRegistry.getId());
} }
String account = null; String account = null;
@ -121,8 +122,8 @@ public class KSRepCashRegisterSumsReportBuilder extends CSVReportBuilder<EmptyPa
account = registry.getAccount(); account = registry.getAccount();
} else if (accountType == AccountType.Info) { } else if (accountType == AccountType.Info) {
Account accountFromIMDG = accountImdg.getFirstObjectByFieldValues(Map.of( Account accountFromIMDG = accountImdg.getFirstObjectByFieldValues(Map.of(
"companyId", 1L, "companyId", 1L,
"accountType", AccountType.Anlt.getKey() "accountType", AccountType.Anlt.getKey()
)); ));
if (accountFromIMDG != null) account = accountFromIMDG.getAccount(); if (accountFromIMDG != null) account = accountFromIMDG.getAccount();
} }
@ -131,7 +132,7 @@ public class KSRepCashRegisterSumsReportBuilder extends CSVReportBuilder<EmptyPa
String tkr = registry.getTradingClearingRegistry(); String tkr = registry.getTradingClearingRegistry();
String tradeNum = null; String tradeNum = null;
String registerCode = pairRegistry != null ? pairRegistry.getRegistryCode() : ""; String registerCode = pairRegistry != null ? pairRegistry.getRegistryCode() : "";
BigDecimal addSum = registry.getBalance() != null ? registry.getBalance() :BigDecimal.ZERO; BigDecimal addSum = registry.getBalance() != null ? registry.getBalance() : BigDecimal.ZERO;
Instant addTime = registry.getUpdated(); Instant addTime = registry.getUpdated();
LocalDate addDate = LocalDate.now(); LocalDate addDate = LocalDate.now();
OperationType operType = OperationType.forBigDecimal(registry.getBalance()); OperationType operType = OperationType.forBigDecimal(registry.getBalance());
@ -146,6 +147,7 @@ public class KSRepCashRegisterSumsReportBuilder extends CSVReportBuilder<EmptyPa
ksRepCashRegisterSumsReport.setAddTime(LocalTime.ofInstant(addTime, getReportZoneId())); ksRepCashRegisterSumsReport.setAddTime(LocalTime.ofInstant(addTime, getReportZoneId()));
ksRepCashRegisterSumsReport.setAddDate(addDate); ksRepCashRegisterSumsReport.setAddDate(addDate);
ksRepCashRegisterSumsReport.setOperType(operType.getCode()); ksRepCashRegisterSumsReport.setOperType(operType.getCode());
ksRepCashRegisterSumsReport.setCurrency(registry.getSecuritySymbol());
rows.add(ksRepCashRegisterSumsReport); rows.add(ksRepCashRegisterSumsReport);
} }
} }