clearing-service http://jira.mfd.msk:8088/browse/CLS-504 + добавил новую ошибку
This commit is contained in:
parent
b9f924aa8d
commit
67d851b5b6
5 changed files with 35 additions and 6 deletions
|
|
@ -463,6 +463,7 @@
|
|||
<errorCode id="5425" code="CLRN" name="Запрещена идентификация средства по рассчитанным обязательствам."/>
|
||||
<errorCode id="5426" code="CLRN" name="Режим списаний и зачислений отключен в настройках модуля."/>
|
||||
<errorCode id="5427" code="CLRN" name="Найдено больше одной записи %s."/>
|
||||
<errorCode id="5428" code="CLRN" name="Активная клиринговая сессия уже существует."/>
|
||||
<!-- error code for dbf-importer -->
|
||||
<errorCode id="5600" code="DBFI" name="Общая ошибка модуля dbf-importer."/>
|
||||
<!-- error code for dbf-exporter -->
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ public enum ClearingError implements IErrorEnumId {
|
|||
NewDealsNotFound(5423L),
|
||||
IdentifiedFundsExceedObligations(5424L),
|
||||
ObligationsAlreadyCalculated(5425L),
|
||||
ActiveSessionIsPresent(5428L),
|
||||
//ошибки "перенесенные" из balance-service,
|
||||
CompanyNotFoundB(5211L),
|
||||
CurrencyNotFound(5213L),
|
||||
|
|
@ -38,8 +39,6 @@ public enum ClearingError implements IErrorEnumId {
|
|||
BalanceInsufficient(5222L),
|
||||
TCRegistryNotFound(3022L),
|
||||
WrongField(5004L),
|
||||
|
||||
ActiveSessionIsPresent(-1L),
|
||||
;
|
||||
private final Long id;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.balance.StatementRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.clearing.CreateRegistryRequest;
|
||||
|
|
@ -21,18 +22,23 @@ import ru.spcex.clearing.platform.messaging.domain.cud.registry.RegistrySplitDep
|
|||
import ru.spcex.clearing.platform.messaging.domain.cud.schedule.LauncherCommandRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.utilities.STradesImportedRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
||||
import ru.spcex.clearing.platform.messaging.service.Status;
|
||||
import ru.spcex.clearing.service.executors.Sdf06Executor;
|
||||
import ru.spcex.clearing.service.executors.Sdf10Executor;
|
||||
import ru.spcex.clearing.service.payment.PaymentInstructionOutboundService;
|
||||
import ru.spcex.clearing.session.stage.*;
|
||||
import ru.spcex.clearing.session.stage.impl.BalanceRevise;
|
||||
import ru.spcex.platform.enumeration.Task;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.platform.utils.error.ValidationException;
|
||||
|
||||
import static ru.spcex.clearing.platform.messaging.domain.Consts.S_TRADES_IMPORTED;
|
||||
|
||||
@Service
|
||||
public class EventsReceiver extends QueueConsumer implements InitializingBean {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final IMessageResolver errorResolver;
|
||||
private final ClearingService clearingService;
|
||||
private final RegistryService registryService;
|
||||
private final PrimaryAuctionBnSession primaryAuctionBnSession;
|
||||
|
|
@ -51,6 +57,7 @@ public class EventsReceiver extends QueueConsumer implements InitializingBean {
|
|||
|
||||
@Autowired
|
||||
public EventsReceiver(Consumer<String, Object> kafkaQueue, Producer<String, Object> kafkaResponseQueue,
|
||||
IMessageResolver errorResolver,
|
||||
ClearingService clearingService,
|
||||
RegistryService registryService,
|
||||
PrimaryAuctionBnSession primaryAuctionBnSession,
|
||||
|
|
@ -59,6 +66,7 @@ public class EventsReceiver extends QueueConsumer implements InitializingBean {
|
|||
Sdf06Executor sdf06Executor,
|
||||
Sdf10Executor sdf10Executor, BalanceRevise balanceRevise, Sdf05Sender sdf05Sender, PaymentInstructionOutboundService pmtOutboundService) {
|
||||
super(kafkaQueue, kafkaResponseQueue);
|
||||
this.errorResolver = errorResolver;
|
||||
this.clearingService = clearingService;
|
||||
this.registryService = registryService;
|
||||
this.primaryAuctionBnSession = primaryAuctionBnSession;
|
||||
|
|
@ -95,7 +103,14 @@ public class EventsReceiver extends QueueConsumer implements InitializingBean {
|
|||
.forDestination(Consts.CONTINUE_CLEARING, callbacks::put);
|
||||
|
||||
callback(LauncherCommandRequest.class)
|
||||
.setConsumer(sessionManager::defineAndStartSession)
|
||||
.setFunction(r -> {
|
||||
try {
|
||||
sessionManager.defineAndStartSession(r);
|
||||
} catch (ValidationException ve) {
|
||||
return makeErrorResponse(r, ve);
|
||||
}
|
||||
return null;
|
||||
})
|
||||
.forDestination(Task.startOfClearing.topic(), callbacks::put);
|
||||
|
||||
callback(PIClearingOutbondActionNewRequest.class)
|
||||
|
|
@ -160,4 +175,14 @@ public class EventsReceiver extends QueueConsumer implements InitializingBean {
|
|||
.forDestination(Task.sdf05WithCode9Final.topic(), callbacks::put);
|
||||
init();
|
||||
}
|
||||
|
||||
RequestInfoUpdate makeErrorResponse(BaseRequest<?> r, ValidationException ve) {
|
||||
String errorText = errorResolver.resolve(ve.getEnumMsg());
|
||||
log.error("Error at {}: {}", r, errorText);
|
||||
RequestInfoUpdate errorMsg = new RequestInfoUpdate();
|
||||
errorMsg.setId(r.getId());
|
||||
errorMsg.setStatus(Status.Error);
|
||||
errorMsg.setMessage(errorText);
|
||||
return errorMsg;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ 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.error.ClearingError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.schedule.LauncherCommandRequest;
|
||||
|
|
@ -13,6 +14,7 @@ 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.error.ValidationException;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -46,7 +48,7 @@ public class SessionManager {
|
|||
sessionImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Session, Session.class);
|
||||
}
|
||||
|
||||
public void defineAndStartSession(BaseRequest<LauncherCommandRequest> r) { //task sclr section fond sessiontype trdt
|
||||
public void defineAndStartSession(BaseRequest<LauncherCommandRequest> r) throws ValidationException { //task sclr section fond sessiontype trdt
|
||||
LauncherCommandRequest payload = r.getRequestPayload();
|
||||
// Long sessionId = commandRequest.getSessionId();
|
||||
SessionType sessionType = IEnumKey.getEnumByKey(SessionType.class, payload.getSessionType());
|
||||
|
|
@ -75,13 +77,13 @@ public class SessionManager {
|
|||
}
|
||||
}
|
||||
|
||||
protected void checkActiveSession() {
|
||||
protected void checkActiveSession() throws ValidationException {
|
||||
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);
|
||||
throw new ValidationException(ClearingError.ActiveSessionIsPresent, String.valueOf(existActiveSession.getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -896,6 +896,8 @@ INSERT INTO ERROR_CODE_DICTIONARY(ID, CODE, NAME) values (5426, 'CLRN', 'Реж
|
|||
|
||||
INSERT INTO ERROR_CODE_DICTIONARY(ID, CODE, NAME) values (5427, 'CLRN', 'Найдено больше одной записи %s.') ON CONFLICT (ID) DO UPDATE SET CODE = EXCLUDED.CODE, NAME = EXCLUDED.NAME;
|
||||
|
||||
INSERT INTO ERROR_CODE_DICTIONARY(ID, CODE, NAME) values (5428, 'CLRN', 'Активная клиринговая сессия уже существует.') ON CONFLICT (ID) DO UPDATE SET CODE = EXCLUDED.CODE, NAME = EXCLUDED.NAME;
|
||||
|
||||
INSERT INTO ERROR_CODE_DICTIONARY(ID, CODE, NAME) values (5600, 'DBFI', 'Общая ошибка модуля dbf-importer.') ON CONFLICT (ID) DO UPDATE SET CODE = EXCLUDED.CODE, NAME = EXCLUDED.NAME;
|
||||
|
||||
INSERT INTO ERROR_CODE_DICTIONARY(ID, CODE, NAME) values (5800, 'DBFE', 'Общая ошибка модуля dbf-exporter.') ON CONFLICT (ID) DO UPDATE SET CODE = EXCLUDED.CODE, NAME = EXCLUDED.NAME;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue