SDF10 статусы
This commit is contained in:
parent
af70ae6392
commit
0e2adf5807
1 changed files with 35 additions and 14 deletions
|
|
@ -33,6 +33,7 @@ import ru.spcex.platform.imdg.api.ImdgId;
|
|||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.enumeration.IEnumId;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.platform.utils.number.BigDecimalUtil;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
|
@ -65,14 +66,16 @@ public class Sdf10Executor {
|
|||
private final Function<SDf10, IValidator> sDf10Validator;
|
||||
private final KafkaSender kafkaSender;
|
||||
|
||||
private final static BigDecimal successResult = BigDecimal.ZERO;
|
||||
//ошибка проверок
|
||||
private final static BigDecimal errorResult2 = new BigDecimal("3");
|
||||
//ошибка проверок баланса или наличия сессии - в этом сценарии session создается
|
||||
private final static BigDecimal errorResult1 = new BigDecimal("1");
|
||||
//отказ от gateway
|
||||
private final static BigDecimal errorResult3 = new BigDecimal("3");
|
||||
private final static String DEFAULT_11_RES = "result";
|
||||
private final static String OK = "OK!";
|
||||
private final static String SYNTAX_ERROR = "Синтаксическая ошибка (файл сформирован неверно)";
|
||||
private final static String GATEWAY_REJECTED = "Отрицательный ответ от Торговой Системы";
|
||||
private final static String NOT_FOUND_ACCOUNT = "Не найден код раздела субсчета/счета депо";
|
||||
private final static String NOT_FOUND_COMPANY = "Не найдена компания";
|
||||
private final static String NOT_FOUND_TCR = "Не найден ТКР";
|
||||
private final static String NOT_FOUND_SECURITY = "Не найден код ценной бумаги";
|
||||
private final static String INVALID_SUM = "Недопустимая сумма списания";
|
||||
private final static String PREVIOUS_REQUEST_NOT_PROCESSED = "Процесс обработки предыдущего SDF10 не завершен";
|
||||
private final static String GENERAL_ERROR = "Общая ошибка обработки SDF10";
|
||||
|
||||
private Long sdf10GroupId;
|
||||
private Long sdf11GroupId;
|
||||
|
|
@ -110,7 +113,7 @@ public class Sdf10Executor {
|
|||
if (sdf10GroupId != null) {
|
||||
log.warn("currently awaiting gateway response for groupId: {}. skipping groupId {}", sdf10GroupId, groupId);
|
||||
sdfs.forEach(sdf10 -> {
|
||||
SDf11 errorSdf11 = createSdf11(sdf10, now, DEFAULT_11_RES);
|
||||
SDf11 errorSdf11 = createSdf11(sdf10, now, PREVIOUS_REQUEST_NOT_PROCESSED);
|
||||
errorSdf11.setGenerationId(sdf11GroupId);
|
||||
this.sdf11Imdg.insert(errorSdf11);
|
||||
});
|
||||
|
|
@ -127,13 +130,11 @@ public class Sdf10Executor {
|
|||
SDf11 errorSdf11;
|
||||
String errorResult;
|
||||
Statement stmt = null;
|
||||
errorResult = errorById(err.get().getSubject());
|
||||
if (needToCreateStatement(err.get())) {
|
||||
errorResult = DEFAULT_11_RES;
|
||||
stmt = createStatementBySdf10(sDf10,
|
||||
((Company) validator.getStored(ValidationStored.CompanyByTradingCode)).getId(),
|
||||
validator.getStored(ValidationStored.Sdf10Account));
|
||||
} else {
|
||||
errorResult = DEFAULT_11_RES;
|
||||
}
|
||||
errorSdf11 = createSdf11(sDf10, now, errorResult);
|
||||
errorSdf11.setGenerationId(sdf11GroupId);
|
||||
|
|
@ -179,7 +180,7 @@ public class Sdf10Executor {
|
|||
stmt.getId(),
|
||||
sDf10.getGenerationId(),
|
||||
sDf10.getId());
|
||||
SDf11 sdf11 = createSdf11(sDf10, time, DEFAULT_11_RES);
|
||||
SDf11 sdf11 = createSdf11(sDf10, time, OK);
|
||||
sdf11.setGenerationId(sdf11GenerationId);
|
||||
sdf11Imdg.insert(sdf11);
|
||||
stmt.setOperationStatus(OperationStatus.Executed.getKey());
|
||||
|
|
@ -233,7 +234,7 @@ public class Sdf10Executor {
|
|||
statementId,
|
||||
sdf10.getGenerationId(),
|
||||
sdf10.getId());
|
||||
SDf11 sdf11 = createSdf11(sdf10, now, DEFAULT_11_RES);
|
||||
SDf11 sdf11 = createSdf11(sdf10, now, GATEWAY_REJECTED);
|
||||
sdf11.setGenerationId(sdf11GroupId);
|
||||
sdf11Imdg.insert(sdf11);
|
||||
stmt.setOperationStatus(OperationStatus.Rejected.getKey());
|
||||
|
|
@ -315,4 +316,24 @@ public class Sdf10Executor {
|
|||
return ClearingError.ActiveSessionIsPresent.equals(err.getSubject()) || ClearingError.BalanceInsufficient.equals(err.getSubject())
|
||||
|| ClearingError.TCRegistryNotFound.equals(err.getSubject());
|
||||
}
|
||||
|
||||
private static String errorById(IEnumId err) {
|
||||
if (err == null || err.getId() == null) return "unknown Error";
|
||||
if (ClearingError.DepoAccNotFound.equals(err)) {
|
||||
return NOT_FOUND_ACCOUNT;
|
||||
}
|
||||
if (ClearingError.CompanyNotFoundB.equals(err) || ClearingError.CompanyNotActive.equals(err)) {
|
||||
return NOT_FOUND_COMPANY;
|
||||
}
|
||||
if (ClearingError.TCRegistryNotFound.equals(err)) {
|
||||
return NOT_FOUND_TCR;
|
||||
}
|
||||
if (ClearingError.SecurityNotFound.equals(err)) {
|
||||
return NOT_FOUND_SECURITY;
|
||||
}
|
||||
if (ClearingError.BalanceInsufficient.equals(err)) {
|
||||
return INVALID_SUM;
|
||||
}
|
||||
return GENERAL_ERROR;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue