добавил поднятие сессии из IMDG при старте clearing-service
пофиксил тип сессии для первичных торгов B0
This commit is contained in:
parent
b1af5cc68f
commit
01db30a3bc
8 changed files with 64 additions and 23 deletions
|
|
@ -10,8 +10,10 @@ import ru.spcex.platform.enumeration.SessionStatus;
|
|||
import ru.spcex.platform.enumeration.SessionType;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
|
|
@ -22,10 +24,12 @@ public abstract class AbstractSession {
|
|||
protected final IMessageResolver messageResolver;
|
||||
protected final AtomicReference<TaskType> currStage = new AtomicReference<>();
|
||||
protected Session currSession;
|
||||
protected final ImdgProvider imdgProvider;
|
||||
|
||||
public AbstractSession(
|
||||
ImdgProvider imdgProvider,
|
||||
IMessageResolver messageResolver) {
|
||||
this.imdgProvider = imdgProvider;
|
||||
this.sessionImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Session, Session.class);
|
||||
this.messageResolver = messageResolver;
|
||||
}
|
||||
|
|
@ -55,6 +59,11 @@ public abstract class AbstractSession {
|
|||
|
||||
protected void endSession() {
|
||||
synchronized (this.currStage) {
|
||||
Session session = currSession;
|
||||
if (session != null) {
|
||||
session.setSessionStatus(SessionStatus.CLOS.getKey());
|
||||
sessionImdg.update(session);
|
||||
}
|
||||
this.currStage.set(null);
|
||||
this.currSession = null;
|
||||
}
|
||||
|
|
@ -80,16 +89,35 @@ public abstract class AbstractSession {
|
|||
}
|
||||
}
|
||||
|
||||
protected boolean checkIsActive() {
|
||||
Session activeSession = sessionImdg.getSingleObjectByFieldValues(Map.of(
|
||||
"sectionType", sectionType().getKey(),
|
||||
protected void initSessionIfPresent() {
|
||||
Session session = sessionImdg.getSingleObjectByFieldValues(Map.of(
|
||||
"sessionType", sessionType().getKey(),
|
||||
"section", section().getKey(),
|
||||
"sessionStatus", SessionStatus.ACTV.getKey())
|
||||
"workflowStatus", SessionStatus.ACTV.getKey())
|
||||
);
|
||||
return activeSession != null;
|
||||
if (session != null) {
|
||||
synchronized (this.currStage) {
|
||||
log.info("Session id={} section={} sessionType={} taskType={} found", session.getId(),
|
||||
session.getSection(),
|
||||
session.getSessionType(),
|
||||
session.getSessionStatus()
|
||||
);
|
||||
TaskType taskType = IEnumKey.getEnumByKey(TaskType.class, session.getSessionStatus());
|
||||
if (taskType == null) {
|
||||
log.warn("cannot distinguish taskType {} for session.id={}", session.getSessionStatus(), session.getId());
|
||||
session.setSessionStatus(SessionStatus.CLOS.getKey());
|
||||
session.setUpdated(Instant.now());
|
||||
sessionImdg.update(session);
|
||||
return;
|
||||
}
|
||||
log.info("Session id={} accepted to processing with current step {}.{}", session.getId(), taskType, taskType.getKey());
|
||||
this.currStage.set(taskType);
|
||||
this.currSession = session;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract Section section();
|
||||
|
||||
protected abstract SessionType sectionType();
|
||||
protected abstract SessionType sessionType();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,7 +98,9 @@ public class FinalMkrSession extends AbstractSession implements InitializingBean
|
|||
rgsPrctBuilder.lessEqual("valueDate", LocalDate.now())
|
||||
)
|
||||
);
|
||||
inspectionObligations.setSessionType(sectionType());
|
||||
inspectionObligations.setSessionType(sessionType());
|
||||
imdgProvider.waitAvailable();
|
||||
initSessionIfPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -232,7 +234,7 @@ public class FinalMkrSession extends AbstractSession implements InitializingBean
|
|||
TaskType startStatus = TaskType.StartRevise;
|
||||
Session newSession = new Session();
|
||||
newSession.setSection(section().getKey());
|
||||
newSession.setSessionType(sectionType().getKey());
|
||||
newSession.setSessionType(sessionType().getKey());
|
||||
newSession.setSessionStatus(startStatus.getKey());
|
||||
newSession.setWorkflowStatus(SessionStatus.ACTV.getKey());
|
||||
newSession.setClearingDate(LocalDate.now());
|
||||
|
|
@ -253,7 +255,7 @@ public class FinalMkrSession extends AbstractSession implements InitializingBean
|
|||
}
|
||||
|
||||
@Override
|
||||
protected SessionType sectionType() {
|
||||
protected SessionType sessionType() {
|
||||
return SessionType.FINL;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,6 +85,8 @@ public class IntermediateMkrSession extends AbstractSession implements Initializ
|
|||
ImdgPredicateBuilder execFondPb = executionDepositImdg.predicateBuilder();
|
||||
dealsPrepare.addExecutionDepositCondition(execFondPb.regex("firstLegSettlementCode", "(^T0.*$)|(B[^0]\\d*$)"));
|
||||
// dealsPrepare.addExecutionDepositCondition(execFondPb.in("market", marketCodes.get().toArray(new String[0])));
|
||||
imdgProvider.waitAvailable();
|
||||
initSessionIfPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -208,7 +210,7 @@ public class IntermediateMkrSession extends AbstractSession implements Initializ
|
|||
TaskType startStatus = TaskType.StartRevise;
|
||||
Session newSession = new Session();
|
||||
newSession.setSection(section().getKey());
|
||||
newSession.setSessionType(sectionType().getKey());
|
||||
newSession.setSessionType(sessionType().getKey());
|
||||
newSession.setSessionStatus(startStatus.getKey());
|
||||
newSession.setWorkflowStatus(SessionStatus.ACTV.getKey());
|
||||
newSession.setClearingDate(LocalDate.now());
|
||||
|
|
@ -229,7 +231,7 @@ public class IntermediateMkrSession extends AbstractSession implements Initializ
|
|||
}
|
||||
|
||||
@Override
|
||||
protected SessionType sectionType() {
|
||||
protected SessionType sessionType() {
|
||||
return SessionType.MEDM;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,6 +85,8 @@ public class PrimaryAuctionB0Session extends AbstractSession implements Initiali
|
|||
ImdgPredicateBuilder execFondPb = executionFondImdg.predicateBuilder();
|
||||
dealsPrepare.addExecutionFondCondition(execFondPb.regex("settlementCode", "^B0.*$"));
|
||||
dealsPrepare.addExecutionFondCondition(execFondPb.equals("marketType", MarketType.PRMR.getKey()));
|
||||
imdgProvider.waitAvailable();
|
||||
initSessionIfPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -196,7 +198,7 @@ public class PrimaryAuctionB0Session extends AbstractSession implements Initiali
|
|||
TaskType startStatus = TaskType.StartRevise;
|
||||
Session newSession = new Session();
|
||||
newSession.setSection(Section.FOND.getKey());
|
||||
newSession.setSessionType(SessionType.IPO0.getKey());
|
||||
newSession.setSessionType(sessionType().getKey());
|
||||
newSession.setSessionStatus(startStatus.getKey());
|
||||
newSession.setWorkflowStatus(SessionStatus.ACTV.getKey());
|
||||
newSession.setClearingDate(LocalDate.now());
|
||||
|
|
@ -216,7 +218,7 @@ public class PrimaryAuctionB0Session extends AbstractSession implements Initiali
|
|||
}
|
||||
|
||||
@Override
|
||||
protected SessionType sectionType() {
|
||||
return SessionType.IPOB;
|
||||
protected SessionType sessionType() {
|
||||
return SessionType.IPO0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,8 @@ public class PrimaryAuctionBnSession extends AbstractSession implements Initiali
|
|||
ImdgPredicateBuilder execFondPb = executionFondImdg.predicateBuilder();
|
||||
dealsPrepare.addExecutionFondCondition(execFondPb.regex("settlementCode", "^B\\d{2}$"));
|
||||
dealsPrepare.addExecutionFondCondition(execFondPb.in("market", marketCodes.get().toArray(new String[0])));
|
||||
imdgProvider.waitAvailable();
|
||||
initSessionIfPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -194,7 +196,7 @@ public class PrimaryAuctionBnSession extends AbstractSession implements Initiali
|
|||
TaskType startStatus = TaskType.StartRevise;
|
||||
Session newSession = new Session();
|
||||
newSession.setSection(Section.FOND.getKey());
|
||||
newSession.setSessionType(SessionType.IPOB.getKey());
|
||||
newSession.setSessionType(sessionType().getKey());
|
||||
newSession.setSessionStatus(startStatus.getKey());
|
||||
newSession.setWorkflowStatus(SessionStatus.ACTV.getKey());
|
||||
newSession.setClearingDate(LocalDate.now());
|
||||
|
|
@ -215,7 +217,7 @@ public class PrimaryAuctionBnSession extends AbstractSession implements Initiali
|
|||
}
|
||||
|
||||
@Override
|
||||
protected SessionType sectionType() {
|
||||
protected SessionType sessionType() {
|
||||
return SessionType.IPOB;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,8 @@ public class PrimaryAuctionT0Session extends AbstractSession implements Initiali
|
|||
ImdgPredicateBuilder execFondPb = executionFondImdg.predicateBuilder();
|
||||
dealsPrepare.addExecutionFondCondition(execFondPb.regex("settlementCode", "^T0.*$"));
|
||||
dealsPrepare.addExecutionFondCondition(execFondPb.equals("marketType", MarketType.PRMR.getKey()));
|
||||
imdgProvider.waitAvailable();
|
||||
initSessionIfPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -194,7 +196,7 @@ public class PrimaryAuctionT0Session extends AbstractSession implements Initiali
|
|||
} else {
|
||||
Session newSession = new Session();
|
||||
newSession.setSection(Section.FOND.getKey());
|
||||
newSession.setSessionType(SessionType.IPOT.getKey());
|
||||
newSession.setSessionType(sessionType().getKey());
|
||||
newSession.setSessionStatus(TaskType.StartRevise.getKey());
|
||||
newSession.setWorkflowStatus(SessionStatus.ACTV.getKey());
|
||||
newSession.setClearingDate(LocalDate.now());
|
||||
|
|
@ -214,7 +216,7 @@ public class PrimaryAuctionT0Session extends AbstractSession implements Initiali
|
|||
}
|
||||
|
||||
@Override
|
||||
protected SessionType sectionType() {
|
||||
protected SessionType sessionType() {
|
||||
return SessionType.IPOT;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,8 @@ public class ReturnDepositSession extends AbstractSession implements Initializin
|
|||
rgsPrctBuilder.less("valueDate", LocalDate.now())
|
||||
)
|
||||
);
|
||||
|
||||
imdgProvider.waitAvailable();
|
||||
initSessionIfPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -183,7 +184,7 @@ public class ReturnDepositSession extends AbstractSession implements Initializin
|
|||
TaskType startStatus = TaskType.StartRevise;
|
||||
Session newSession = new Session();
|
||||
newSession.setSection(section().getKey());
|
||||
newSession.setSessionType(sectionType().getKey());
|
||||
newSession.setSessionType(sessionType().getKey());
|
||||
newSession.setSessionStatus(startStatus.getKey());
|
||||
newSession.setWorkflowStatus(SessionStatus.ACTV.getKey());
|
||||
newSession.setClearingDate(LocalDate.now());
|
||||
|
|
@ -204,7 +205,7 @@ public class ReturnDepositSession extends AbstractSession implements Initializin
|
|||
}
|
||||
|
||||
@Override
|
||||
protected SessionType sectionType() {
|
||||
protected SessionType sessionType() {
|
||||
return SessionType.XDEP;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,8 @@ public class SecondaryAuctionT0Session extends AbstractSession implements Initia
|
|||
ImdgPredicateBuilder execFondPb = executionFondImdg.predicateBuilder();
|
||||
dealsPrepare.addExecutionFondCondition(execFondPb.regex("settlementCode", "^T0.*$"));
|
||||
dealsPrepare.addExecutionFondCondition(execFondPb.in("market", marketCodes.get().toArray(new String[0])));
|
||||
imdgProvider.waitAvailable();
|
||||
initSessionIfPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -195,7 +197,7 @@ public class SecondaryAuctionT0Session extends AbstractSession implements Initia
|
|||
TaskType startStatus = TaskType.StartRevise;
|
||||
Session newSession = new Session();
|
||||
newSession.setSection(Section.FOND.getKey());
|
||||
newSession.setSessionType(SessionType.TRDT.getKey());
|
||||
newSession.setSessionType(sessionType().getKey());
|
||||
newSession.setSessionStatus(startStatus.getKey());
|
||||
newSession.setWorkflowStatus(SessionStatus.ACTV.getKey());
|
||||
newSession.setClearingDate(LocalDate.now());
|
||||
|
|
@ -216,7 +218,7 @@ public class SecondaryAuctionT0Session extends AbstractSession implements Initia
|
|||
}
|
||||
|
||||
@Override
|
||||
protected SessionType sectionType() {
|
||||
protected SessionType sessionType() {
|
||||
return SessionType.TRDT;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue