XDEP time interval
RequirementsAndObligationCreation execution match bugfix
This commit is contained in:
parent
1be10820a3
commit
c93e59c814
5 changed files with 38 additions and 14 deletions
|
|
@ -34,6 +34,7 @@ public enum ClearingError implements IErrorEnumId {
|
||||||
RgsWrongCode(5430L),
|
RgsWrongCode(5430L),
|
||||||
RefundDateCannotBeChanged(5431L),
|
RefundDateCannotBeChanged(5431L),
|
||||||
PlanBalanceReviseError(5432L),
|
PlanBalanceReviseError(5432L),
|
||||||
|
XdepTimeIntervalNotMatch(5433L),
|
||||||
//ошибки "перенесенные" из balance-service,
|
//ошибки "перенесенные" из balance-service,
|
||||||
CompanyNotFoundB(5211L),
|
CompanyNotFoundB(5211L),
|
||||||
CurrencyNotFound(5213L),
|
CurrencyNotFound(5213L),
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ public class TradingTimeService {
|
||||||
this.plannerAllTodayImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_PlannerAllToday, PlannerAllToday.class);
|
this.plannerAllTodayImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_PlannerAllToday, PlannerAllToday.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTradingTime() {
|
private boolean isTradingTime(Task startTime, Task endTime) {
|
||||||
ImdgPredicateBuilder pb = plannerAllTodayImdg.predicateBuilder();
|
ImdgPredicateBuilder pb = plannerAllTodayImdg.predicateBuilder();
|
||||||
Function<Task, Optional<PlannerAllToday>> plannerByTask = task -> {
|
Function<Task, Optional<PlannerAllToday>> plannerByTask = task -> {
|
||||||
ImdgPredicate plannerPrdct = pb.and(
|
ImdgPredicate plannerPrdct = pb.and(
|
||||||
|
|
@ -34,19 +34,28 @@ public class TradingTimeService {
|
||||||
);
|
);
|
||||||
return Optional.ofNullable(plannerAllTodayImdg.getFirstObjectByPredicate(plannerPrdct));
|
return Optional.ofNullable(plannerAllTodayImdg.getFirstObjectByPredicate(plannerPrdct));
|
||||||
};
|
};
|
||||||
LocalTime startTradingTime = plannerByTask.apply(Task.createRegistry_STRS)
|
LocalTime startTradingTime = plannerByTask.apply(startTime)
|
||||||
.map(PlannerAllToday::getTaskTime)
|
.map(PlannerAllToday::getTaskTime)
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
LocalTime endTradingTime = plannerByTask.apply(Task.createRegistry_ETRS)
|
LocalTime endTradingTime = plannerByTask.apply(endTime)
|
||||||
.map(PlannerAllToday::getTaskTime)
|
.map(PlannerAllToday::getTaskTime)
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
if (startTradingTime == null || endTradingTime == null) {
|
if (startTradingTime == null || endTradingTime == null) {
|
||||||
log.warn("startTradingTime or endTradingTime is null");
|
log.warn("{} or {} not found in planner all today", startTime.getKey(), endTime.getKey());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LocalTime now = LocalTime.now();
|
LocalTime now = LocalTime.now();
|
||||||
boolean isTradingTime = !now.isBefore(startTradingTime) && !now.isAfter(endTradingTime);
|
boolean isTradingTime = !now.isBefore(startTradingTime) && !now.isAfter(endTradingTime);
|
||||||
log.debug("now: {}, startTradingTime: {}, endTradingTime: {}. trading time: {}", now, startTradingTime, endTradingTime, isTradingTime);
|
log.debug("now: {}, {}: {}, {}: {}. period check in: {}",
|
||||||
|
now, startTime.getKey(), startTradingTime, endTime.getKey(), endTradingTime, isTradingTime);
|
||||||
return isTradingTime;
|
return isTradingTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isTradingTime() {
|
||||||
|
return isTradingTime(Task.createRegistry_STRS, Task.createRegistry_ETRS);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean timeForXdep() {
|
||||||
|
return isTradingTime(Task.startTime_SDEP, Task.endTime_EDEP);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||||
import ru.spcex.clearing.notification.NotificationSender;
|
import ru.spcex.clearing.notification.NotificationSender;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.schedule.LauncherCommandRequest;
|
import ru.spcex.clearing.platform.messaging.domain.cud.schedule.LauncherCommandRequest;
|
||||||
|
import ru.spcex.clearing.service.schedule.TradingTimeService;
|
||||||
import ru.spcex.platform.enumeration.*;
|
import ru.spcex.platform.enumeration.*;
|
||||||
import ru.spcex.platform.imdg.api.Imdg;
|
import ru.spcex.platform.imdg.api.Imdg;
|
||||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||||
|
|
@ -33,13 +34,14 @@ public class SessionManager {
|
||||||
private final IntermediateMkrSession intermediateMkrSession;
|
private final IntermediateMkrSession intermediateMkrSession;
|
||||||
private final FinalMkrSession finalMkrSession;
|
private final FinalMkrSession finalMkrSession;
|
||||||
private final ReturnDepositSession returnDepositSession;
|
private final ReturnDepositSession returnDepositSession;
|
||||||
|
private final TradingTimeService time;
|
||||||
|
|
||||||
public SessionManager(ImdgProvider imdgProvider,
|
public SessionManager(ImdgProvider imdgProvider,
|
||||||
NotificationSender notification, IMessageResolver msgs, PrimaryAuctionT0Session primaryAuctionT0Session,
|
NotificationSender notification, IMessageResolver msgs, PrimaryAuctionT0Session primaryAuctionT0Session,
|
||||||
PrimaryAuctionBnSession primaryAuctionBnSession,
|
PrimaryAuctionBnSession primaryAuctionBnSession,
|
||||||
PrimaryAuctionB0Session primaryAuctionB0Session,
|
PrimaryAuctionB0Session primaryAuctionB0Session,
|
||||||
SecondaryAuctionT0Session secondaryAuctionT0Session,
|
SecondaryAuctionT0Session secondaryAuctionT0Session,
|
||||||
IntermediateMkrSession intermediateMkrSession, FinalMkrSession finalMkrSession, ReturnDepositSession returnDepositSession) {
|
IntermediateMkrSession intermediateMkrSession, FinalMkrSession finalMkrSession, ReturnDepositSession returnDepositSession, TradingTimeService time) {
|
||||||
this.notification = notification;
|
this.notification = notification;
|
||||||
this.msgs = msgs;
|
this.msgs = msgs;
|
||||||
this.primaryAuctionT0Session = primaryAuctionT0Session;
|
this.primaryAuctionT0Session = primaryAuctionT0Session;
|
||||||
|
|
@ -51,6 +53,7 @@ public class SessionManager {
|
||||||
this.returnDepositSession = returnDepositSession;
|
this.returnDepositSession = returnDepositSession;
|
||||||
|
|
||||||
sessionImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Session, Session.class);
|
sessionImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Session, Session.class);
|
||||||
|
this.time = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void defineAndStartSession(BaseRequest<LauncherCommandRequest> r) throws ValidationException { //task sclr section fond sessiontype trdt
|
public void defineAndStartSession(BaseRequest<LauncherCommandRequest> r) throws ValidationException { //task sclr section fond sessiontype trdt
|
||||||
|
|
@ -76,19 +79,27 @@ public class SessionManager {
|
||||||
|
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
//checkActive
|
//checkActive
|
||||||
checkActiveSession();
|
checkAllowSessionStart(sessionType);
|
||||||
|
|
||||||
session.runSession(baseRequest);
|
session.runSession(baseRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkActiveSession() throws ValidationException {
|
protected void checkAllowSessionStart(SessionType sessionType) throws ValidationException {
|
||||||
Session existActiveSession = sessionImdg.getFirstObjectByFieldValues(Map.of(
|
EnumMessage err = null;
|
||||||
"workflowStatus", SessionStatus.ACTV.getKey()
|
if (sessionType.equals(SessionType.XDEP) && !time.timeForXdep()) {
|
||||||
));
|
log.warn("cannot launch {} reason: time interval not matched", sessionType);
|
||||||
if (existActiveSession != null) {
|
err = new EnumMessage(ClearingError.XdepTimeIntervalNotMatch);
|
||||||
log.warn("Can not start new session, cause exist active session.id={}", existActiveSession.getId());
|
} else {
|
||||||
EnumMessage err = new EnumMessage(ClearingError.ActiveSessionIsPresent, String.valueOf(existActiveSession.getId()));
|
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());
|
||||||
|
err = new EnumMessage(ClearingError.ActiveSessionIsPresent, String.valueOf(existActiveSession.getId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (err != null) {
|
||||||
notification.sendNotification(ObjectType.session, msgs.resolve(err), Priority.HIGH);
|
notification.sendNotification(ObjectType.session, msgs.resolve(err), Priority.HIGH);
|
||||||
throw new ValidationException(err);
|
throw new ValidationException(err);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -230,6 +230,7 @@ public class RequirementsAndObligationCreation implements ISessionStage {
|
||||||
}
|
}
|
||||||
if (invalid != null) {
|
if (invalid != null) {
|
||||||
log.error("FATAL couldn't match Execution#id({}) with Execution#id({}) error: {}", exec1.getId(), exec2.getId(), invalid);
|
log.error("FATAL couldn't match Execution#id({}) with Execution#id({}) error: {}", exec1.getId(), exec2.getId(), invalid);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return new Pair<>(exec1, exec2);
|
return new Pair<>(exec1, exec2);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ public enum Task implements IEnumKey {
|
||||||
liquidationSession_LIQU("LIQU"),//Ликвидационная сессия по обязательтсвам участника
|
liquidationSession_LIQU("LIQU"),//Ликвидационная сессия по обязательтсвам участника
|
||||||
startSession_STRM("STRM"),//Начало торговой сессии секции МКР
|
startSession_STRM("STRM"),//Начало торговой сессии секции МКР
|
||||||
terminationSession_ETRM("ETRM"),//Завершение торговой сессии секции МКР
|
terminationSession_ETRM("ETRM"),//Завершение торговой сессии секции МКР
|
||||||
|
startTime_SDEP("SDEP"),
|
||||||
|
endTime_EDEP("EDEP"),
|
||||||
startSession_SIPO("SIPO"),//Начало торговой сессии по первичным торгам
|
startSession_SIPO("SIPO"),//Начало торговой сессии по первичным торгам
|
||||||
terminationSession_EIPO("EIPO"),//Завершение торговой сессии по первичным торгам
|
terminationSession_EIPO("EIPO"),//Завершение торговой сессии по первичным торгам
|
||||||
startSession_STRF("STRF"),//Начало торговой сессии по вторичным торгам
|
startSession_STRF("STRF"),//Начало торговой сессии по вторичным торгам
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue