fix continue

This commit is contained in:
etreschenkov 2023-05-27 15:41:24 +03:00
parent adc4d101f0
commit 9b8c2d3e37
2 changed files with 50 additions and 50 deletions

View file

@ -148,15 +148,14 @@ public class PrimaryAuctionBnSession extends AbstractSession implements Initiali
//stage 7
StageResult<Collection<PaymentInstruction>> paymentResult = runStage(TaskType.FormingPaymentInstruction, formingPaymentInstruction);
if (paymentResult.getStageResult().isEmpty()) {
runStage(TaskType.ContinueRevise, balanceRevise);
finishPart(req);
runStage(TaskType.FormingPaymentInstruction, balanceRevise);
// finishPart(req);
}
} catch (StageException e) {
//already logged
}
}
public void finishPart(BaseRequest<?> req) {
try {
if (!checkStage(TaskType.FormingPaymentInstruction)) {

View file

@ -57,12 +57,10 @@ public class BalanceRevise implements ISessionStage {
@Override
public StageResult<?> submit(Task<?> task) {
switch (task.getTaskType()) {
case StartRevise -> {
case StartRevise, FormingPaymentInstruction -> {
return sendSdfs();
}
case ContinueRevise -> {
//больше не используются, удалить после проверки
cashFlow(); //((SdfClearingRequest) task.getData()).getGroupId() if needed //todo убрать это отсюда
return revise();
}
default -> throw new IllegalStateException("unknown task " + task.getTaskType());
@ -91,6 +89,53 @@ public class BalanceRevise implements ISessionStage {
return new StageResult<>(null, true);
}
private StageResult<?> revise() {
String statementSQL = String.format("inOutSDfType = %s and operationStatus = %s and statementType = %s",
InOutSDfType.type1.getKey(), OperationStatus.Pending.getKey(), StatementType.full.getKey());
Collection<Statement> stmts = statementImdg.getCollectionObjectsBySQL(statementSQL);
for (Statement stmt : stmts) {
RegistryTradingParams registryAMT = new RegistryTradingParams(RegistryDesignation.A, RegistryInstrumentType.M,
null, RegistryUnit.T);
String registrySqlAMT = String.format("%s and account = '%s' and securityId = %d",
RegistryCodeSqlBuilder.getInstance(registryAMT).build(),
stmt.getAccount(),
stmt.getSecurityId()
);
Registry rgsAMT = registryImdg.getSingleObjectBySQL(registrySqlAMT);
rgsAMT.setCheckBalance(stmt.getAmount());
rgsAMT.setDiffBalance(safeBD(rgsAMT.getBalance()).subtract(safeBD(rgsAMT.getCheckBalance())));
}
return new StageResult<>(null, true);
}
private BigDecimal safeBD(BigDecimal value) {
return value != null ? value : BigDecimal.ZERO;
}
private void newSDf56(Statement statement) {
log.debug("creating sdf56");
SDf56 sDf56 = new SDf56();
sDf56.setNumber(idGenerator.nextId().toString());
Instant now = Instant.now();
String startTime = String.valueOf(statement != null ?
statement.getCreated().toEpochMilli() : now.minus(1, ChronoUnit.DAYS).toEpochMilli());
sDf56.setStart_datetime(startTime);
sDf56.setEnd_datetime(String.valueOf(now.toEpochMilli()));
sDf56.setAccount("ТБС");
sDf56.setDeal("КОДУ");
sDf56.setGenerationTime(now);
sDf56.setGenerationId(idGenerator.nextId());
sDf56Imdg.insert(sDf56);
SdfClearingRequest requestForExporter = new SdfClearingRequest();
requestForExporter.setGroupId(sDf56.getGenerationId());
kafkaSender.sendRequestToQueue(Consts.SDF56_PROCESS, requestForExporter);
log.debug("successfully processed, new id {}", sDf56.getId());
}
private StageResult<?> cashFlow() {
String statementSQL = String.format("inOutSDfType = %s and operationStatus = %s and statementType = %s",
InOutSDfType.type57.getKey(), OperationStatus.Pending.getKey(), StatementType.incr.getKey());
@ -149,48 +194,4 @@ public class BalanceRevise implements ISessionStage {
//todoSdf1
return new StageResult<>(null, true);
}
private StageResult<?> revise() {
String statementSQL = String.format("inOutSDfType = %s and operationStatus = %s and statementType = %s",
InOutSDfType.type1.getKey(), OperationStatus.Pending.getKey(), StatementType.full.getKey());
Collection<Statement> stmts = statementImdg.getCollectionObjectsBySQL(statementSQL);
for (Statement stmt : stmts) {
RegistryTradingParams registryAMT = new RegistryTradingParams(RegistryDesignation.A, RegistryInstrumentType.M,
null, RegistryUnit.T);
String registrySqlAMT = String.format("%s and account = '%s' and securityId = %d",
RegistryCodeSqlBuilder.getInstance(registryAMT).build(),
stmt.getAccount(),
stmt.getSecurityId()
);
Registry rgsAMT = registryImdg.getSingleObjectBySQL(registrySqlAMT);
rgsAMT.setCheckBalance(stmt.getAmount());
rgsAMT.setDiffBalance(safeBD(rgsAMT.getBalance()).subtract(safeBD(rgsAMT.getCheckBalance())));
}
return new StageResult<>(null, true);
}
private BigDecimal safeBD(BigDecimal value) {
return value != null ? value : BigDecimal.ZERO;
}
private void newSDf56(Statement statement) {
log.debug("creating sdf56");
SDf56 sDf56 = new SDf56();
sDf56.setNumber(idGenerator.nextId().toString());
Instant now = Instant.now();
String startTime = String.valueOf(statement != null ?
statement.getCreated().toEpochMilli() : now.minus(1, ChronoUnit.DAYS).toEpochMilli());
sDf56.setStart_datetime(startTime);
sDf56.setEnd_datetime(String.valueOf(now.toEpochMilli()));
sDf56.setAccount("ТБС");
sDf56.setDeal("КОДУ");
sDf56.setGenerationTime(now);
sDf56.setGenerationId(idGenerator.nextId());
sDf56Imdg.insert(sDf56);
SdfClearingRequest requestForExporter = new SdfClearingRequest();
requestForExporter.setGroupId(sDf56.getGenerationId());
kafkaSender.sendRequestToQueue(Consts.SDF56_PROCESS, requestForExporter);
log.debug("successfully processed, new id {}", sDf56.getId());
}
}