clearing-service http://jira.mfd.msk:8088/browse/CLS-504
This commit is contained in:
parent
9564202df6
commit
ede6699a56
2 changed files with 30 additions and 1 deletions
|
|
@ -32,6 +32,7 @@ import java.time.LocalDate;
|
|||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Configuration("sessionStateMachineFactory")
|
||||
|
|
@ -134,6 +135,10 @@ public class StateBnConfig extends EnumStateMachineConfigurerAdapter<TaskType, S
|
|||
states
|
||||
.withStates()
|
||||
.initial(TaskType.StartRevise, context -> {
|
||||
Session existActiveSession = sessionImdg.getFirstObjectByFieldValues(Map.of("workflowStatus", SessionStatus.ACTV.getKey()));
|
||||
if (existActiveSession != null) {
|
||||
throw new RuntimeException("ActiveSessionIsPresent " + existActiveSession);
|
||||
}
|
||||
Session newSession = new Session();
|
||||
newSession.setSection(Section.FOND.getKey());
|
||||
newSession.setSessionType(SessionType.IPOB.getKey());
|
||||
|
|
|
|||
|
|
@ -3,15 +3,24 @@ package ru.spcex.clearing.session.stage;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.misc.Session;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.schedule.LauncherCommandRequest;
|
||||
import ru.spcex.platform.enumeration.Section;
|
||||
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 java.util.Map;
|
||||
|
||||
@Service
|
||||
public class SessionManager {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final Imdg<Session> sessionImdg;
|
||||
|
||||
private final PrimaryAuctionT0Session primaryAuctionT0Session;
|
||||
private final PrimaryAuctionBnSession primaryAuctionBnSession;
|
||||
private final PrimaryAuctionB0Session primaryAuctionB0Session;
|
||||
|
|
@ -20,7 +29,8 @@ public class SessionManager {
|
|||
private final FinalMkrSession finalMkrSession;
|
||||
private final ReturnDepositSession returnDepositSession;
|
||||
|
||||
public SessionManager(PrimaryAuctionT0Session primaryAuctionT0Session,
|
||||
public SessionManager(ImdgProvider imdgProvider,
|
||||
PrimaryAuctionT0Session primaryAuctionT0Session,
|
||||
PrimaryAuctionBnSession primaryAuctionBnSession,
|
||||
PrimaryAuctionB0Session primaryAuctionB0Session,
|
||||
SecondaryAuctionT0Session secondaryAuctionT0Session,
|
||||
|
|
@ -32,6 +42,8 @@ public class SessionManager {
|
|||
this.intermediateMkrSession = intermediateMkrSession;
|
||||
this.finalMkrSession = finalMkrSession;
|
||||
this.returnDepositSession = returnDepositSession;
|
||||
|
||||
sessionImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Session, Session.class);
|
||||
}
|
||||
|
||||
public void defineAndStartSession(BaseRequest<LauncherCommandRequest> r) { //task sclr section fond sessiontype trdt
|
||||
|
|
@ -57,7 +69,19 @@ public class SessionManager {
|
|||
|
||||
if (session != null) {
|
||||
//checkActive
|
||||
checkActiveSession();
|
||||
|
||||
session.runSession(baseRequest);
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkActiveSession() {
|
||||
Session existActiveSession = sessionImdg.getFirstObjectByFieldValues(Map.of(
|
||||
"workflowStatus", SessionStatus.ACTV.getKey()
|
||||
));
|
||||
if (existActiveSession != null) {
|
||||
log.warn("Can not start new session, cause exist active session.id={}", existActiveSession.getId());
|
||||
throw new RuntimeException("ActiveSessionIsPresent " + existActiveSession);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue