reports-service http://jira.mfd.msk:8088/browse/CLS-497 правки
This commit is contained in:
parent
53b71431ea
commit
ea0b8a74dd
4 changed files with 101 additions and 11 deletions
|
|
@ -0,0 +1,66 @@
|
|||
package ru.spcex.clearing.reports.reports;
|
||||
|
||||
import ru.clearing.classes.statics.data.registry.Registry;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class PairRegistry3Id {
|
||||
private String account;
|
||||
private Long securityId;
|
||||
private Long sessionId;
|
||||
|
||||
public PairRegistry3Id() {
|
||||
}
|
||||
|
||||
public PairRegistry3Id(Registry registry) {
|
||||
this.account = registry.getAccount();
|
||||
this.sessionId = registry.getSessionId();
|
||||
this.securityId = registry.getSecurityId();
|
||||
}
|
||||
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(String account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public Long getSecurityId() {
|
||||
return securityId;
|
||||
}
|
||||
|
||||
public void setSecurityId(Long securityId) {
|
||||
this.securityId = securityId;
|
||||
}
|
||||
|
||||
public Long getSessionId() {
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
public void setSessionId(Long sessionId) {
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
PairRegistry3Id that = (PairRegistry3Id) o;
|
||||
return Objects.equals(account, that.account) && Objects.equals(securityId, that.securityId) && Objects.equals(sessionId, that.sessionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(account, securityId, sessionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{" +
|
||||
"account='" + account + '\'' +
|
||||
", securityId=" + securityId +
|
||||
", sessionId=" + sessionId +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
@ -48,4 +48,12 @@ public class PairRegistryId {
|
|||
result = 31 * result + (sessionId != null ? sessionId.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{" +
|
||||
"account='" + account + '\'' +
|
||||
", sessionId=" + sessionId +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import ru.clearing.classes.statics.data.misc.Session;
|
|||
import ru.clearing.classes.statics.data.registry.Registry;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.reports.reports.CSVReportBuilder;
|
||||
import ru.spcex.clearing.reports.reports.PairRegistryId;
|
||||
import ru.spcex.clearing.reports.reports.PairRegistry3Id;
|
||||
import ru.spcex.clearing.reports.reports.SessionIdParam;
|
||||
import ru.spcex.clearing.reports.reports.bean.KSRepDepoNettoReport;
|
||||
import ru.spcex.platform.enumeration.*;
|
||||
|
|
@ -79,16 +79,15 @@ public class KSRepDepoNettoReportBuilder extends CSVReportBuilder<SessionIdParam
|
|||
Collection<Registry> registries = registryImdg.getCollectionObjectsByPredicate(finalPredicate);
|
||||
log.debug("Found {} Registry by query: {}", registries.size(), finalPredicate);
|
||||
|
||||
Map<PairRegistryId, List<Registry>> registryMap = registries.stream().collect(Collectors.groupingBy(PairRegistryId::new));
|
||||
Map<PairRegistry3Id, List<Registry>> registryMap = registries.stream().collect(Collectors.groupingBy(PairRegistry3Id::new));
|
||||
rows = new ArrayList<>(registries.size());
|
||||
for (Map.Entry<PairRegistryId, List<Registry>> entry : registryMap.entrySet()) {
|
||||
PairRegistryId pairRegistryId = entry.getKey();
|
||||
for (Map.Entry<PairRegistry3Id, List<Registry>> entry : registryMap.entrySet()) {
|
||||
PairRegistry3Id pairRegistryId = entry.getKey();
|
||||
List<Registry> groupedRegistry = entry.getValue();
|
||||
try {
|
||||
if (groupedRegistry.isEmpty()) {
|
||||
log.warn("Empty OS_T and TS_T registries for account = {} and sessionId = {}. Registries with id = [{}] was skipped",
|
||||
pairRegistryId.getAccount(),
|
||||
pairRegistryId.getSessionId(),
|
||||
log.warn("Empty OS_T and TS_T registries for {}. Registries with id = [{}] was skipped",
|
||||
pairRegistryId,
|
||||
groupedRegistry.stream().map(r -> String.valueOf(r.getId())).collect(Collectors.joining(", "))
|
||||
);
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import java.math.BigDecimal;
|
|||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -129,15 +130,31 @@ public class KSRepTradesReportBuilder extends CSVReportBuilder<EmptyParams, KSRe
|
|||
|
||||
if (execution instanceof ExecutionDeposit executionDeposit) {
|
||||
BigDecimal firstLegAmount = executionDeposit.getFirstLegAmount() != null ? executionDeposit.getFirstLegAmount() : BigDecimal.ZERO;
|
||||
if (Side.SELL.equalsByKey(executionDeposit.getSide())) firstLegAmount = firstLegAmount.negate();
|
||||
if (Arrays.asList(Side.BUY.getKey(), "B","BUY").contains(executionDeposit.getSide())) {
|
||||
ksRepTradesReport.setCashLiability(firstLegAmount);
|
||||
} else if (Arrays.asList(Side.SELL.getKey(), "S","SELL").contains((executionDeposit.getSide()))) {
|
||||
firstLegAmount = firstLegAmount.negate();
|
||||
ksRepTradesReport.setCashLiability(firstLegAmount);
|
||||
} else {
|
||||
log.warn("Execution id={} has unknown side={}", executionDeposit.getId(), executionDeposit.getSide());
|
||||
continue;
|
||||
}
|
||||
ksRepTradesReport.setCashLiability(firstLegAmount);
|
||||
ksRepTradesReport.setDepoLiability(BigDecimal.ZERO);
|
||||
} else if (execution instanceof ExecutionFond executionFond) {
|
||||
BigDecimal settlementAmount = executionFond.getSettlementAmount() != null ? executionFond.getSettlementAmount() : BigDecimal.ZERO;
|
||||
if (Side.BUY.equalsByKey(executionFond.getSide())) settlementAmount = settlementAmount.negate();
|
||||
if (Arrays.asList(Side.BUY.getKey(), "B","BUY").contains(executionFond.getSide())) {
|
||||
settlementAmount = settlementAmount.negate();
|
||||
ksRepTradesReport.setCashLiability(settlementAmount);
|
||||
} else if (Arrays.asList(Side.SELL.getKey(), "S","SELL").contains(executionFond.getSide())) {
|
||||
ksRepTradesReport.setCashLiability(settlementAmount);
|
||||
} else {
|
||||
log.warn("Execution id={} has unknown side={}", executionFond.getId(), executionFond.getSide());
|
||||
continue;
|
||||
}
|
||||
BigDecimal quantity = executionFond.getQuantity() != null ? executionFond.getQuantity() : BigDecimal.ZERO;
|
||||
if (Side.SELL.equalsByKey(executionFond.getSide())) quantity = quantity.negate();
|
||||
ksRepTradesReport.setCashLiability(settlementAmount);
|
||||
if (Arrays.asList(Side.SELL.getKey(), "S", "SELL").contains((executionFond.getSide())))
|
||||
quantity = quantity.negate();
|
||||
ksRepTradesReport.setDepoLiability(quantity);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue