diff --git a/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FinishingSession.java b/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FinishingSession.java index 8f9a4ba56..e02476832 100644 --- a/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FinishingSession.java +++ b/clearing-parent/clearing-service/src/main/java/ru/spcex/clearing/session/stage/impl/FinishingSession.java @@ -2,7 +2,9 @@ package ru.spcex.clearing.session.stage.impl; import java.time.Instant; import java.time.LocalDate; +import java.util.ArrayList; import java.util.Collection; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; @@ -33,6 +35,7 @@ import ru.spcex.clearing.session.stage.ISessionStage; import ru.spcex.clearing.session.stage.StageResult; import ru.spcex.clearing.session.stage.Task; import ru.spcex.clearing.session.stage.task.FinishingSessionPayload; +import ru.spcex.platform.classes.base.interfaces.ExecutionType; import ru.spcex.platform.enumeration.CoverageStatus; import ru.spcex.platform.enumeration.RegistryDesignation; import ru.spcex.platform.enumeration.RegistryStatus; @@ -146,7 +149,7 @@ public class FinishingSession implements ISessionStage { int allowed = 0; int notAllowed = 0; SessionType sessionType = getEnumByKey(SessionType.class, session.getSessionType()); - if (IEnumKey.contains(sessionType, SessionType.FINL, SessionType.MEDM)) { + if (IEnumKey.contains(sessionType, SessionType.FINL, SessionType.MEDM, SessionType.UNIT)) { Collection executions = findExecutionDepositBySessionId(sessionId); log.trace("loaded {} ExecutionDeposits for sessionId {}", executions.size(), sessionId); for (ExecutionDeposit execution : executions) { @@ -171,7 +174,8 @@ public class FinishingSession implements ISessionStage { allowed, notAllowed, executions.size() - (allowed + notAllowed)); - } else if (IEnumKey.contains(sessionType, SessionType.CURR, SessionType.TRDT, SessionType.IPOB, SessionType.IPO0, SessionType.IPOT)) { + } + if (IEnumKey.contains(sessionType, SessionType.CURR, SessionType.TRDT, SessionType.IPOB, SessionType.IPO0, SessionType.IPOT, SessionType.UNIT)) { Collection executions = findExecutionFondBySessionId(sessionId, sessionType); log.trace("loaded {} Executions for sessionId {}", executions.size(), sessionId); for (ExecutionCommon execution : executions) { @@ -188,7 +192,7 @@ public class FinishingSession implements ISessionStage { } execution.setCoverageStatus(toStatus.getKey()); execution.setUpdated(Instant.now()); - if (sessionType.equals(SessionType.CURR)) { + if (execution.type().equals(ExecutionType.ExecutionCurrency)) { executionCurrencyImdg.update((ExecutionCurrency) execution); } else { executionFondImdg.update((ExecutionFond) execution); @@ -310,16 +314,29 @@ public class FinishingSession implements ISessionStage { } protected Collection findExecutionFondBySessionId(Long sessionId, SessionType sessionType) { - Imdg excImdg; - if (sessionType.equals(SessionType.CURR)) { - excImdg = executionCurrencyImdg; + if (sessionType.equals(SessionType.UNIT)) { + List res = new ArrayList<>(); + res.addAll(findExecutionFondBySessionId(sessionId, executionCurrencyImdg)); + res.addAll(findExecutionFondBySessionId(sessionId, executionFondImdg)); + return res; } else { - excImdg = executionFondImdg; + Imdg excImdg; + if (sessionType.equals(SessionType.CURR)) { + excImdg = executionCurrencyImdg; + } else { + excImdg = executionFondImdg; + } + return findExecutionFondBySessionId(sessionId, excImdg); } + } + + protected Collection findExecutionFondBySessionId( + Long sessionId, + Imdg excImdg) { ImdgPredicateBuilder pb = excImdg.predicateBuilder(); ImdgPredicate prdct = pb.or( - pb.equals("sessionId", sessionId), - pb.equals("settlementDate", LocalDate.now()) + pb.equals("sessionId", sessionId), + pb.equals("settlementDate", LocalDate.now()) ); Collection result = excImdg.getCollectionObjectsByPredicate(prdct) .stream()