This commit is contained in:
parent
866c063b0d
commit
1d4d831ea7
8 changed files with 31 additions and 24 deletions
|
|
@ -112,6 +112,7 @@ public class FinalMkrSession extends AbstractSession implements InitializingBean
|
||||||
inspectionObligations.setSection(section());
|
inspectionObligations.setSection(section());
|
||||||
formingPaymentInstructionDeals.setSection(section());
|
formingPaymentInstructionDeals.setSection(section());
|
||||||
formingPaymentInstructionDeals.setSessionType(sessionType());
|
formingPaymentInstructionDeals.setSessionType(sessionType());
|
||||||
|
finishingSession.setSessionType(sessionType());
|
||||||
imdgProvider.waitAvailable();
|
imdgProvider.waitAvailable();
|
||||||
initSessionIfPresent();
|
initSessionIfPresent();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,7 @@ public class IntermediateMkrSession extends AbstractSession implements Initializ
|
||||||
inspectionObligations.setSection(section());
|
inspectionObligations.setSection(section());
|
||||||
formingPaymentInstructionDeals.setSection(section());
|
formingPaymentInstructionDeals.setSection(section());
|
||||||
formingPaymentInstructionDeals.setSessionType(sessionType());
|
formingPaymentInstructionDeals.setSessionType(sessionType());
|
||||||
|
finishingSession.setSessionType(sessionType());
|
||||||
imdgProvider.waitAvailable();
|
imdgProvider.waitAvailable();
|
||||||
initSessionIfPresent();
|
initSessionIfPresent();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,7 @@ public class PrimaryAuctionB0Session extends AbstractSession implements Initiali
|
||||||
inclusionObligations.setSessionType(sessionType());
|
inclusionObligations.setSessionType(sessionType());
|
||||||
inspectionObligations.setSection(section());
|
inspectionObligations.setSection(section());
|
||||||
finishingSession.setSection(section());
|
finishingSession.setSection(section());
|
||||||
|
finishingSession.setSessionType(sessionType());
|
||||||
imdgProvider.waitAvailable();
|
imdgProvider.waitAvailable();
|
||||||
initSessionIfPresent();
|
initSessionIfPresent();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,7 @@ public class PrimaryAuctionBnSession extends AbstractSession implements Initiali
|
||||||
inclusionObligations.setSessionType(sessionType());
|
inclusionObligations.setSessionType(sessionType());
|
||||||
inspectionObligations.setSection(section());
|
inspectionObligations.setSection(section());
|
||||||
finishingSession.setSection(section());
|
finishingSession.setSection(section());
|
||||||
|
finishingSession.setSessionType(sessionType());
|
||||||
imdgProvider.waitAvailable();
|
imdgProvider.waitAvailable();
|
||||||
initSessionIfPresent();
|
initSessionIfPresent();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,7 @@ public class PrimaryAuctionT0Session extends AbstractSession implements Initiali
|
||||||
inclusionObligations.setSessionType(sessionType());
|
inclusionObligations.setSessionType(sessionType());
|
||||||
inspectionObligations.setSection(section());
|
inspectionObligations.setSection(section());
|
||||||
finishingSession.setSection(section());
|
finishingSession.setSection(section());
|
||||||
|
finishingSession.setSessionType(sessionType());
|
||||||
imdgProvider.waitAvailable();
|
imdgProvider.waitAvailable();
|
||||||
initSessionIfPresent();
|
initSessionIfPresent();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@ public class ReturnDepositSession extends AbstractSession implements Initializin
|
||||||
rgsPrctBuilder.less("valueDate", LocalDate.now())
|
rgsPrctBuilder.less("valueDate", LocalDate.now())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
finishingSession.setSessionType(sessionType());
|
||||||
imdgProvider.waitAvailable();
|
imdgProvider.waitAvailable();
|
||||||
initSessionIfPresent();
|
initSessionIfPresent();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,7 @@ public class SecondaryAuctionT0Session extends AbstractSession implements Initia
|
||||||
inclusionObligations.setSessionType(sessionType());
|
inclusionObligations.setSessionType(sessionType());
|
||||||
inspectionObligations.setSection(section());
|
inspectionObligations.setSection(section());
|
||||||
finishingSession.setSection(section());
|
finishingSession.setSection(section());
|
||||||
|
finishingSession.setSessionType(sessionType());
|
||||||
imdgProvider.waitAvailable();
|
imdgProvider.waitAvailable();
|
||||||
initSessionIfPresent();
|
initSessionIfPresent();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,10 +35,12 @@ import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.*;
|
import java.util.Collection;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import static ru.spcex.clearing.error.ClearingErrorInternal.SessionGeneralError;
|
import static ru.spcex.clearing.error.ClearingErrorInternal.SessionGeneralError;
|
||||||
import static ru.spcex.platform.utils.enumeration.IEnumKey.getEnumByKey;
|
import static ru.spcex.platform.utils.enumeration.IEnumKey.getEnumByKey;
|
||||||
|
|
@ -58,6 +60,7 @@ public class FinishingSession implements ISessionStage {
|
||||||
private final IMessageResolver msgResolver;
|
private final IMessageResolver msgResolver;
|
||||||
private final Sdf05Sender sdf05Sender;
|
private final Sdf05Sender sdf05Sender;
|
||||||
private final Sdf14Sender sdf14Sender;
|
private final Sdf14Sender sdf14Sender;
|
||||||
|
private SessionType sessionType;
|
||||||
private Section section;
|
private Section section;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
@ -77,6 +80,9 @@ public class FinishingSession implements ISessionStage {
|
||||||
public void setSection(Section section) {
|
public void setSection(Section section) {
|
||||||
this.section = section;
|
this.section = section;
|
||||||
}
|
}
|
||||||
|
public void setSessionType(SessionType sessionType) {
|
||||||
|
this.sessionType = sessionType;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StageResult<?> submit(Task<?> task) {
|
public StageResult<?> submit(Task<?> task) {
|
||||||
|
|
@ -109,7 +115,6 @@ public class FinishingSession implements ISessionStage {
|
||||||
log.error("Session id={} not found. Can not update Execution's.", sessionId);
|
log.error("Session id={} not found. Can not update Execution's.", sessionId);
|
||||||
} else {
|
} else {
|
||||||
Collection<Registry> oRegs = findORegistryBySessionId(sessionId);
|
Collection<Registry> oRegs = findORegistryBySessionId(sessionId);
|
||||||
log.trace("found {} obligation registers by sessionId {}", oRegs.size(), sessionId);
|
|
||||||
Map<Long, RegistryStatus> obligationStatusByGroupId;
|
Map<Long, RegistryStatus> obligationStatusByGroupId;
|
||||||
obligationStatusByGroupId = oRegs.stream()
|
obligationStatusByGroupId = oRegs.stream()
|
||||||
.map(rgs -> new Pair<>(rgs.getGroupId(), getEnumByKey(RegistryStatus.class, rgs.getRegistryStatus())))
|
.map(rgs -> new Pair<>(rgs.getGroupId(), getEnumByKey(RegistryStatus.class, rgs.getRegistryStatus())))
|
||||||
|
|
@ -159,10 +164,7 @@ public class FinishingSession implements ISessionStage {
|
||||||
notAllowed,
|
notAllowed,
|
||||||
executions.size() - (allowed + notAllowed));
|
executions.size() - (allowed + notAllowed));
|
||||||
} else if (IEnumKey.contains(session.getSessionType(), SessionType.TRDT, SessionType.IPOB, SessionType.IPO0, SessionType.IPOT)) {
|
} else if (IEnumKey.contains(session.getSessionType(), SessionType.TRDT, SessionType.IPOB, SessionType.IPO0, SessionType.IPOT)) {
|
||||||
List<ExecutionFond> executions = Stream.concat(
|
Collection<ExecutionFond> executions = findExecutionFondBySessionId(sessionId);
|
||||||
findExecutionFondBySessionId(sessionId).stream(),
|
|
||||||
findExecutionFondByExchangeId(exchangeExecutionIdsPreviousDay).stream())
|
|
||||||
.toList();
|
|
||||||
log.trace("loaded {} ExecutionFonds for sessionId {}", executions.size(), sessionId);
|
log.trace("loaded {} ExecutionFonds for sessionId {}", executions.size(), sessionId);
|
||||||
for (ExecutionFond execution : executions) {
|
for (ExecutionFond execution : executions) {
|
||||||
CoverageStatus toStatus = statusByExchangeId.apply(execution.getExchangeExecutionId());
|
CoverageStatus toStatus = statusByExchangeId.apply(execution.getExchangeExecutionId());
|
||||||
|
|
@ -201,7 +203,7 @@ public class FinishingSession implements ISessionStage {
|
||||||
return sResult;
|
return sResult;
|
||||||
}
|
}
|
||||||
for (Registry registryA : forRegistries) {
|
for (Registry registryA : forRegistries) {
|
||||||
if (!RegistryDesignation.A.equalsByKey(registryA.getRegistryUnit())) {
|
if (!RegistryDesignation.A.equalsByKey(registryA.getRegistryUnit())) { //fixme Unit -> Designation
|
||||||
log.warn("For registry {}.RegistryDesignation is not A.", registryA.getId());
|
log.warn("For registry {}.RegistryDesignation is not A.", registryA.getId());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -285,40 +287,38 @@ public class FinishingSession implements ISessionStage {
|
||||||
// registryStatus - любой статус
|
// registryStatus - любой статус
|
||||||
pb.equals("registryDesignation", RegistryDesignation.O.getKey()));
|
pb.equals("registryDesignation", RegistryDesignation.O.getKey()));
|
||||||
Collection<Registry> result = registryImdg.getCollectionObjectsByPredicate(prdct);
|
Collection<Registry> result = registryImdg.getCollectionObjectsByPredicate(prdct);
|
||||||
log.trace("found {} liabilities by query {} ", result.size(), prdct);
|
int size = result.size();
|
||||||
result = result.stream()
|
result = result.stream()
|
||||||
.filter(registry -> Objects.equals(registry.getSettlementDate(), LocalDate.now()))
|
.filter(registry -> Objects.equals(registry.getSettlementDate(), LocalDate.now()))
|
||||||
.filter(registry -> Objects.equals(registry.getValueDate(), registry.getSettlementDate()))
|
.filter(registry -> Objects.equals(registry.getValueDate(), registry.getSettlementDate()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
log.debug("found {} liabilities 'O' by query {} and ValueDate==SettlementDate", result.size(), prdct);
|
log.debug("found {} liabilities by query {} and {} liabilities after filtering ValueDate==SettlementDate",
|
||||||
|
size, result.size(), prdct);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Collection<ExecutionFond> findExecutionFondBySessionId(Long sessionId) {
|
protected Collection<ExecutionFond> findExecutionFondBySessionId(Long sessionId) {
|
||||||
ImdgPredicateBuilder pb = executionFondImdg.predicateBuilder();
|
ImdgPredicateBuilder pb = executionFondImdg.predicateBuilder();
|
||||||
ImdgPredicate prdct = pb.and(
|
ImdgPredicate prdct = pb.or(
|
||||||
pb.equals("sessionId", sessionId),
|
pb.equals("sessionId", sessionId),
|
||||||
pb.equals("settlementDate", LocalDate.now())
|
pb.equals("settlementDate", LocalDate.now())
|
||||||
);
|
);
|
||||||
Collection<ExecutionFond> result = executionFondImdg.getCollectionObjectsByPredicate(prdct);
|
Collection<ExecutionFond> result = executionFondImdg.getCollectionObjectsByPredicate(prdct)
|
||||||
|
.stream()
|
||||||
|
.filter(eFond -> Objects.nonNull(eFond.getSessionId()))
|
||||||
|
.filter(eFond -> {
|
||||||
|
if (sessionId.equals(eFond.getSessionId())) return true;
|
||||||
|
Session session = sessionImdg.getSingleObjectByID(eFond.getSessionId());
|
||||||
|
return sessionType.equalsByKey(session.getSessionType());
|
||||||
|
})
|
||||||
|
.toList();
|
||||||
log.trace("found {} ExecutionFond by sessionId={}", result.size(), sessionId);
|
log.trace("found {} ExecutionFond by sessionId={}", result.size(), sessionId);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Collection<ExecutionFond> findExecutionFondByExchangeId(Set<Long> exchangeIds) {
|
|
||||||
ImdgPredicateBuilder pb = executionFondImdg.predicateBuilder();
|
|
||||||
ImdgPredicate prdct = pb.and(
|
|
||||||
pb.in("exchangeExecutionId", exchangeIds.toArray(new Long[0])),
|
|
||||||
pb.not(pb.equals("settlementDate", LocalDate.now()))
|
|
||||||
);
|
|
||||||
Collection<ExecutionFond> result = executionFondImdg.getCollectionObjectsByPredicate(prdct);
|
|
||||||
log.trace("found {} ExecutionFond from first day", result.size());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Collection<ExecutionDeposit> findExecutionDepositBySessionId(Long sessionId) {
|
protected Collection<ExecutionDeposit> findExecutionDepositBySessionId(Long sessionId) {
|
||||||
ImdgPredicateBuilder pb = executionDepositImdg.predicateBuilder();
|
ImdgPredicateBuilder pb = executionDepositImdg.predicateBuilder();
|
||||||
ImdgPredicate prdct = pb.and(
|
ImdgPredicate prdct = pb.or(
|
||||||
pb.equals("sessionId", sessionId),
|
pb.equals("sessionId", sessionId),
|
||||||
pb.equals("firstLegSettlementDate", LocalDate.now())
|
pb.equals("firstLegSettlementDate", LocalDate.now())
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue