add payload to paymentInstructionForming for every session

This commit is contained in:
etreschenkov 2023-06-02 17:57:20 +03:00
parent e5dc6d4487
commit e2a0f33012
8 changed files with 50 additions and 95 deletions

View file

@ -153,8 +153,14 @@ public class FinalMkrSession extends AbstractSession implements InitializingBean
//stage 6
runStage(TaskType.FormingRegistersOnOS, formingRegistersOnOS); //returns Collection<Registry>
//stage 7
StageResult<Collection<PaymentInstruction>> paymentResult = runStage(TaskType.FormingPaymentInstruction, formingPaymentInstruction);
if (paymentResult.getStageResult().isEmpty()) {
StageResult<Collection<PaymentInstruction>> paymentResult = null;
{
FormingPaymentInstructionPayload payload = new FormingPaymentInstructionPayload();
payload.setSessionId(currSession.getId());
//stage 7
paymentResult = runStage(TaskType.FormingPaymentInstruction, payload, formingPaymentInstruction);
}
if (paymentResult != null && paymentResult.getStageResult().isEmpty()) {
runStage(TaskType.FormingPaymentInstruction, balanceRevise);
// finishPart(req);
}

View file

@ -158,8 +158,14 @@ public class IntermediateMkrSession extends AbstractSession implements Initializ
//stage 6
runStage(TaskType.FormingRegistersOnOS, formingRegistersOnOS); //returns Collection<Registry>
//stage 7
StageResult<Collection<PaymentInstruction>> paymentResult = runStage(TaskType.FormingPaymentInstruction, formingPaymentInstruction);
if (paymentResult.getStageResult().isEmpty()) {
StageResult<Collection<PaymentInstruction>> paymentResult = null;
{
FormingPaymentInstructionPayload payload = new FormingPaymentInstructionPayload();
payload.setSessionId(currSession.getId());
//stage 7
paymentResult = runStage(TaskType.FormingPaymentInstruction, payload, formingPaymentInstruction);
}
if (paymentResult != null && paymentResult.getStageResult().isEmpty()) {
runStage(TaskType.FormingPaymentInstruction, balanceRevise);
// finishPart(req);
}

View file

@ -146,8 +146,14 @@ public class PrimaryAuctionB0Session extends AbstractSession implements Initiali
//stage 6
runStage(TaskType.FormingRegistersOnOS, formingRegistersOnOS); //returns Collection<Registry>
//stage 7
StageResult<Collection<PaymentInstruction>> paymentResult = runStage(TaskType.FormingPaymentInstruction, formingPaymentInstruction);
if (paymentResult.getStageResult().isEmpty()) {
StageResult<Collection<PaymentInstruction>> paymentResult = null;
{
FormingPaymentInstructionPayload payload = new FormingPaymentInstructionPayload();
payload.setSessionId(currSession.getId());
//stage 7
paymentResult = runStage(TaskType.FormingPaymentInstruction, payload, formingPaymentInstruction);
}
if (paymentResult != null && paymentResult.getStageResult().isEmpty()) {
runStage(TaskType.FormingPaymentInstruction, balanceRevise);
// finishPart(req);
}

View file

@ -145,8 +145,14 @@ public class PrimaryAuctionT0Session extends AbstractSession implements Initiali
//stage 6
runStage(TaskType.FormingRegistersOnOS, formingRegistersOnOS); //returns Collection<Registry>
//stage 7
StageResult<Collection<PaymentInstruction>> paymentResult = runStage(TaskType.FormingPaymentInstruction, formingPaymentInstruction);
if (paymentResult.getStageResult().isEmpty()) {
StageResult<Collection<PaymentInstruction>> paymentResult = null;
{
FormingPaymentInstructionPayload payload = new FormingPaymentInstructionPayload();
payload.setSessionId(currSession.getId());
//stage 7
paymentResult = runStage(TaskType.FormingPaymentInstruction, payload, formingPaymentInstruction);
}
if (paymentResult != null && paymentResult.getStageResult().isEmpty()) {
runStage(TaskType.FormingPaymentInstruction, balanceRevise);
// finishPart(req);
}

View file

@ -10,10 +10,7 @@ import ru.clearing.classes.statics.data.registry.Registry;
import ru.spcex.clearing.imdg.IMDGDistributedNames;
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
import ru.spcex.clearing.session.stage.impl.*;
import ru.spcex.clearing.session.stage.task.EndStageNotificationPayload;
import ru.spcex.clearing.session.stage.task.FinishingSessionPayload;
import ru.spcex.clearing.session.stage.task.InclusionToPoolPayload;
import ru.spcex.clearing.session.stage.task.InspectionPoolPayload;
import ru.spcex.clearing.session.stage.task.*;
import ru.spcex.platform.enumeration.RegistryStatus;
import ru.spcex.platform.enumeration.Section;
import ru.spcex.platform.enumeration.SessionStatus;
@ -135,9 +132,14 @@ public class ReturnDepositSession extends AbstractSession implements Initializin
}
//stage 6
runStage(TaskType.FormingRegistersOnOS, formingRegistersOnOS); //returns Collection<Registry>
//stage 7
StageResult<Collection<PaymentInstruction>> paymentResult = runStage(TaskType.FormingPaymentInstruction, formingPaymentInstruction);
if (paymentResult.getStageResult().isEmpty()) {
StageResult<Collection<PaymentInstruction>> paymentResult = null;
{
FormingPaymentInstructionPayload payload = new FormingPaymentInstructionPayload();
payload.setSessionId(currSession.getId());
//stage 7
paymentResult = runStage(TaskType.FormingPaymentInstruction, payload, formingPaymentInstruction);
}
if (paymentResult != null && paymentResult.getStageResult().isEmpty()) {
runStage(TaskType.FormingPaymentInstruction, balanceRevise);
// finishPart(req);
}

View file

@ -145,8 +145,14 @@ public class SecondaryAuctionT0Session extends AbstractSession implements Initia
//stage 6
runStage(TaskType.FormingRegistersOnOS, formingRegistersOnOS); //returns Collection<Registry>
//stage 7
StageResult<Collection<PaymentInstruction>> paymentResult = runStage(TaskType.FormingPaymentInstruction, formingPaymentInstruction);
if (paymentResult.getStageResult().isEmpty()) {
StageResult<Collection<PaymentInstruction>> paymentResult = null;
{
FormingPaymentInstructionPayload payload = new FormingPaymentInstructionPayload();
payload.setSessionId(currSession.getId());
//stage 7
paymentResult = runStage(TaskType.FormingPaymentInstruction, payload, formingPaymentInstruction);
}
if (paymentResult != null && paymentResult.getStageResult().isEmpty()) {
runStage(TaskType.FormingPaymentInstruction, balanceRevise);
// finishPart(req);
}

View file

@ -23,7 +23,6 @@ import ru.spcex.platform.imdg.api.ImdgId;
import ru.spcex.platform.imdg.api.ImdgProvider;
import ru.spcex.platform.imdg.api.predicate.specific.RegistryCodeSqlBuilder;
import ru.spcex.platform.imdg.api.predicate.specific.StatementRevisePredicate;
import ru.spcex.platform.utils.enumeration.IEnumKey;
import java.math.BigDecimal;
import java.time.Instant;
@ -72,20 +71,6 @@ public class BalanceRevise implements ISessionStage {
Collection<Long> currencies = currencyImdg.projectSingleAttribute("id");
Statement statement = statementImdg.aggregateByMax("created", StatementRevisePredicate.get(statementImdg, currencies));
newSDf56(statement);
//fixme теперь не отправляем команду в модуль dbf-export, он получит ее из другого места
// Instant now = Instant.now();
// Sdf56And51Request sdf56Request = new Sdf56And51Request();
// sdf56Request.setDf56Number(idGenerator.nextId()); //fixme day scope id generator
// sdf56Request.setsDateTime(statement != null ?
// statement.getCreated() : TimeUtil.localDateToInstant(LocalDate.of(2023, Month.JANUARY, 1))); //fixme default sDate
// sdf56Request.seteDateTime(now);
// sdf56Request.setDf51Number(idGenerator.nextId()); //fixme day scope id generator
// sdf56Request.setDateTime(now);
// Long msgKey = kafkaSender.sendRequestToQueue(Consts.REVISE_PROCESS, sdf56Request);
// if (msgKey == null) {
// log.error("failed to put SDF56 request to kafka queue");
// return new StageResult<>(new EnumMessage(SessionGeneralError), false);
// }
return new StageResult<>(null, true);
}
@ -132,66 +117,4 @@ public class BalanceRevise implements ISessionStage {
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());
Collection<Statement> stmts = statementImdg.getCollectionObjectsBySQL(statementSQL);
for (Statement stmt : stmts) {
String unformatted = "%s and account = '%s' and securityId = %d";
RegistryTradingParams registryAMT = new RegistryTradingParams(RegistryDesignation.A, RegistryInstrumentType.M,
null, RegistryUnit.T);
RegistryTradingParams registryAMF = new RegistryTradingParams(RegistryDesignation.A, RegistryInstrumentType.M,
null, RegistryUnit.F);
RegistryTradingParams registryAMB = new RegistryTradingParams(RegistryDesignation.A, RegistryInstrumentType.M,
null, RegistryUnit.B);
String registrySqlAMT = String.format(unformatted,
RegistryCodeSqlBuilder.getInstance(registryAMT).build(),
stmt.getAccount(),
stmt.getSecurityId()
);
String registrySqlAMF = String.format(unformatted,
RegistryCodeSqlBuilder.getInstance(registryAMF).build(),
stmt.getAccount(),
stmt.getSecurityId()
);
String registrySqlAMB = String.format(unformatted,
RegistryCodeSqlBuilder.getInstance(registryAMB).build(),
stmt.getAccount(),
stmt.getSecurityId()
);
Registry rgsAMT = registryImdg.getSingleObjectBySQL(registrySqlAMT);
Registry rgsAMF = registryImdg.getSingleObjectBySQL(registrySqlAMF);
Registry rgsAMB = registryImdg.getSingleObjectBySQL(registrySqlAMB);
InOutDirection direction = IEnumKey.getEnumByKey(InOutDirection.class, stmt.getInOutDirection());
if (direction == null) throw new IllegalStateException("null direction");
switch (direction) {
case out -> {
rgsAMT.setBalance(safeBD(rgsAMT.getBalance()).subtract(safeBD(stmt.getAmount())));
rgsAMT.setDebit(safeBD(rgsAMT.getDebit()).add(safeBD(stmt.getAmount())));
}
case in -> {
rgsAMT.setBalance(safeBD(rgsAMT.getBalance()).add(safeBD(stmt.getAmount())));
rgsAMT.setCredit(safeBD(rgsAMT.getCredit()).add(safeBD(stmt.getAmount())));
}
default -> {
throw new IllegalStateException("null direction");
}
}
rgsAMF.setBalance(safeBD(rgsAMT.getBalance()).subtract(safeBD(rgsAMB.getBalance())));
registryImdg.update(rgsAMT);
registryImdg.update(rgsAMF);
registryImdg.update(rgsAMB);
//todo create if needed?
}
//todoSdf1
return new StageResult<>(null, true);
}
}

View file

@ -306,7 +306,7 @@ public class FormingPaymentInstruction implements ISessionStage {
Long sdf12GroupId = null;
Long maxTxNumber = 1L;
if (!sDf12Created.isEmpty()) {
sdf12GroupId = !sDf12Created.isEmpty() ? imdgProvider.getImdgIdGenerator().nextId() : null;
sdf12GroupId = imdgProvider.getImdgIdGenerator().nextId();
ImdgPredicateBuilder predicateBuilder = sDf12Imdg.predicateBuilder();
ImdgPredicate notEmptyTransactionNum = predicateBuilder.not(predicateBuilder.equals("transaction_number", ""));
Long maxId = sDf12Imdg.aggregateLongMax("id", notEmptyTransactionNum);