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)
private String operType;
@CsvBindByName(column = "CURRENCY")
@CsvBindByPosition(position = 9)
private String currency;
public String getFirmId() {
return firmId;
@ -120,4 +124,12 @@ public class KSRepCashRegisterSumsReport {
public void setOperType(String 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 finalPredicate = pb.and(
pb.greatEqual("updated", instantNow.truncatedTo(ChronoUnit.DAYS)),
pb.less("updated", instantNow.plus(1, ChronoUnit.DAYS).truncatedTo(ChronoUnit.DAYS)),
pb.equals("registryStatus", RegistryStatus.OK.getKey()),
pb.notNull("tradingClearingRegistry"),
registryPredicate
pb.greatEqual("updated", instantNow.truncatedTo(ChronoUnit.DAYS)),
pb.less("updated", instantNow.plus(1, ChronoUnit.DAYS).truncatedTo(ChronoUnit.DAYS)),
pb.equals("registryStatus", RegistryStatus.OK.getKey()),
pb.notNull("tradingClearingRegistry"),
registryPredicate
);
Collection<Registry> registries = registryImdg.getCollectionObjectsByPredicate(finalPredicate);
@ -92,8 +92,8 @@ public class KSRepCashRegisterSumsReportBuilder extends CSVReportBuilder<EmptyPa
Company company = companyImdg.getSingleObjectByID(registry.getCompanyId());
if (company == null) {
log.warn("For registry id = {} company with id = {} not found, registry was skipped",
registry.getId(),
registry.getCompanyId());
registry.getId(),
registry.getCompanyId());
continue;
}
if (!WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus())) continue;
@ -101,18 +101,19 @@ public class KSRepCashRegisterSumsReportBuilder extends CSVReportBuilder<EmptyPa
Registry pairRegistry = null;
ImdgPredicate pairRegistryPredicate = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.AM_T).buildPredicate(pb);
Collection<Registry> pairRegistries = registryImdg.getCollectionObjectsByPredicate(
pb.and(
pb.equals("tradingCode", registry.getTradingCode()),
pb.equals("account", registry.getAccount()),
pairRegistryPredicate
)
pb.and(
pb.equals("tradingCode", registry.getTradingCode()),
pb.equals("account", registry.getAccount()),
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();
if (pairRegistries.size() > 1) {
log.warn("For registry (id = {}) found > 1 AM_T registry, use first (id = {})",
registry.getId(),
pairRegistry.getId());
registry.getId(),
pairRegistry.getId());
}
String account = null;
@ -121,8 +122,8 @@ public class KSRepCashRegisterSumsReportBuilder extends CSVReportBuilder<EmptyPa
account = registry.getAccount();
} else if (accountType == AccountType.Info) {
Account accountFromIMDG = accountImdg.getFirstObjectByFieldValues(Map.of(
"companyId", 1L,
"accountType", AccountType.Anlt.getKey()
"companyId", 1L,
"accountType", AccountType.Anlt.getKey()
));
if (accountFromIMDG != null) account = accountFromIMDG.getAccount();
}
@ -131,7 +132,7 @@ public class KSRepCashRegisterSumsReportBuilder extends CSVReportBuilder<EmptyPa
String tkr = registry.getTradingClearingRegistry();
String tradeNum = null;
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();
LocalDate addDate = LocalDate.now();
OperationType operType = OperationType.forBigDecimal(registry.getBalance());
@ -146,6 +147,7 @@ public class KSRepCashRegisterSumsReportBuilder extends CSVReportBuilder<EmptyPa
ksRepCashRegisterSumsReport.setAddTime(LocalTime.ofInstant(addTime, getReportZoneId()));
ksRepCashRegisterSumsReport.setAddDate(addDate);
ksRepCashRegisterSumsReport.setOperType(operType.getCode());
ksRepCashRegisterSumsReport.setCurrency(registry.getSecuritySymbol());
rows.add(ksRepCashRegisterSumsReport);
}
}