правка 7 шага для МКР и промежуточной сессии
This commit is contained in:
parent
7174024333
commit
c8fa6e052e
4 changed files with 111 additions and 76 deletions
|
|
@ -43,7 +43,7 @@ public class FinalMkrSession extends AbstractSession implements InitializingBean
|
||||||
private final InspectionObligations inspectionObligations;
|
private final InspectionObligations inspectionObligations;
|
||||||
private final FormingRegistersOnOS formingRegistersOnOS;
|
private final FormingRegistersOnOS formingRegistersOnOS;
|
||||||
private final FormingPaymentInstructionReturnMkr formingPaymentInstructionReturn;
|
private final FormingPaymentInstructionReturnMkr formingPaymentInstructionReturn;
|
||||||
private final FormingPaymentInstructionDealsFinalMkr formingPaymentInstructionDeals;
|
private final FormingPaymentInstructionAssets formingPaymentInstructionDeals;
|
||||||
private final UnlockResources unlockResources;
|
private final UnlockResources unlockResources;
|
||||||
private final FinishingSession finishingSession;
|
private final FinishingSession finishingSession;
|
||||||
private final EndStageNotification endStageNotification;
|
private final EndStageNotification endStageNotification;
|
||||||
|
|
@ -61,7 +61,7 @@ public class FinalMkrSession extends AbstractSession implements InitializingBean
|
||||||
ObligationAdmission obligationsAdmission,
|
ObligationAdmission obligationsAdmission,
|
||||||
InclusionObligations inclusionObligations,
|
InclusionObligations inclusionObligations,
|
||||||
InspectionObligations inspectionObligations, FormingRegistersOnOS formingRegistersOnOS,
|
InspectionObligations inspectionObligations, FormingRegistersOnOS formingRegistersOnOS,
|
||||||
FormingPaymentInstructionReturnMkr formingPaymentInstructionReturn, FormingPaymentInstructionDealsFinalMkr formingPaymentInstructionDeals,
|
FormingPaymentInstructionReturnMkr formingPaymentInstructionReturn, FormingPaymentInstructionAssets formingPaymentInstructionDeals,
|
||||||
UnlockResources unlockResources,
|
UnlockResources unlockResources,
|
||||||
FinishingSession finishingSession,
|
FinishingSession finishingSession,
|
||||||
EndStageNotification endStageNotification,
|
EndStageNotification endStageNotification,
|
||||||
|
|
@ -104,6 +104,7 @@ public class FinalMkrSession extends AbstractSession implements InitializingBean
|
||||||
inclusionObligations.setSessionType(sessionType());
|
inclusionObligations.setSessionType(sessionType());
|
||||||
inspectionObligationsReturn.setSessionType(sessionType());
|
inspectionObligationsReturn.setSessionType(sessionType());
|
||||||
inspectionObligations.setSessionType(sessionType());
|
inspectionObligations.setSessionType(sessionType());
|
||||||
|
formingPaymentInstructionDeals.setSection(section());
|
||||||
imdgProvider.waitAvailable();
|
imdgProvider.waitAvailable();
|
||||||
initSessionIfPresent();
|
initSessionIfPresent();
|
||||||
}
|
}
|
||||||
|
|
@ -197,7 +198,7 @@ public class FinalMkrSession extends AbstractSession implements InitializingBean
|
||||||
|
|
||||||
StageResult<Collection<PaymentInstruction>> paymentResult = null;
|
StageResult<Collection<PaymentInstruction>> paymentResult = null;
|
||||||
{
|
{
|
||||||
FormingPaymentInstructionDealsMkrPayload payload = new FormingPaymentInstructionDealsMkrPayload();
|
FormingPaymentInstructionPayload payload = new FormingPaymentInstructionPayload();
|
||||||
payload.setSessionId(currSession.getId());
|
payload.setSessionId(currSession.getId());
|
||||||
payload.setPaymentInstructionReturns(returnsPayment.getStageResult());
|
payload.setPaymentInstructionReturns(returnsPayment.getStageResult());
|
||||||
//stage 7
|
//stage 7
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ public class IntermediateMkrSession extends AbstractSession implements Initializ
|
||||||
private final InspectionObligations inspectionObligations;
|
private final InspectionObligations inspectionObligations;
|
||||||
private final FormingRegistersOnOS formingRegistersOnOS;
|
private final FormingRegistersOnOS formingRegistersOnOS;
|
||||||
private final FormingPaymentInstructionReturnMkr formingPaymentInstructionReturn;
|
private final FormingPaymentInstructionReturnMkr formingPaymentInstructionReturn;
|
||||||
private final FormingPaymentInstructionDealsFinalMkr formingPaymentInstructionDeals;
|
private final FormingPaymentInstructionAssets formingPaymentInstructionDeals;
|
||||||
private final UnlockResources unlockResources;
|
private final UnlockResources unlockResources;
|
||||||
private final FinishingSession finishingSession;
|
private final FinishingSession finishingSession;
|
||||||
private final EndStageNotification endStageNotification;
|
private final EndStageNotification endStageNotification;
|
||||||
|
|
@ -61,7 +61,7 @@ public class IntermediateMkrSession extends AbstractSession implements Initializ
|
||||||
ObligationAdmission obligationsAdmission,
|
ObligationAdmission obligationsAdmission,
|
||||||
InclusionObligations inclusionObligations,
|
InclusionObligations inclusionObligations,
|
||||||
InspectionObligations inspectionObligations, FormingRegistersOnOS formingRegistersOnOS,
|
InspectionObligations inspectionObligations, FormingRegistersOnOS formingRegistersOnOS,
|
||||||
FormingPaymentInstructionReturnMkr formingPaymentInstructionReturn, FormingPaymentInstructionDealsFinalMkr formingPaymentInstructionDeals,
|
FormingPaymentInstructionReturnMkr formingPaymentInstructionReturn, FormingPaymentInstructionAssets formingPaymentInstructionDeals,
|
||||||
UnlockResources unlockResources,
|
UnlockResources unlockResources,
|
||||||
FinishingSession finishingSession,
|
FinishingSession finishingSession,
|
||||||
EndStageNotification endStageNotification,
|
EndStageNotification endStageNotification,
|
||||||
|
|
@ -104,6 +104,7 @@ public class IntermediateMkrSession extends AbstractSession implements Initializ
|
||||||
inclusionObligations.setSessionType(sessionType());
|
inclusionObligations.setSessionType(sessionType());
|
||||||
inspectionObligationsReturn.setSessionType(sessionType());
|
inspectionObligationsReturn.setSessionType(sessionType());
|
||||||
inspectionObligations.setSessionType(sessionType());
|
inspectionObligations.setSessionType(sessionType());
|
||||||
|
formingPaymentInstructionDeals.setSection(section());
|
||||||
imdgProvider.waitAvailable();
|
imdgProvider.waitAvailable();
|
||||||
initSessionIfPresent();
|
initSessionIfPresent();
|
||||||
}
|
}
|
||||||
|
|
@ -184,7 +185,7 @@ public class IntermediateMkrSession extends AbstractSession implements Initializ
|
||||||
|
|
||||||
StageResult<Collection<PaymentInstruction>> paymentResult = null;
|
StageResult<Collection<PaymentInstruction>> paymentResult = null;
|
||||||
{
|
{
|
||||||
FormingPaymentInstructionDealsMkrPayload payload = new FormingPaymentInstructionDealsMkrPayload();
|
FormingPaymentInstructionPayload payload = new FormingPaymentInstructionPayload();
|
||||||
payload.setSessionId(currSession.getId());
|
payload.setSessionId(currSession.getId());
|
||||||
payload.setPaymentInstructionReturns(returnsPayment.getStageResult());
|
payload.setPaymentInstructionReturns(returnsPayment.getStageResult());
|
||||||
//stage 7
|
//stage 7
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ import ru.spcex.platform.utils.number.BigDecimalUtil;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static ru.spcex.platform.enumeration.RegistryTradingParams.*;
|
import static ru.spcex.platform.enumeration.RegistryTradingParams.*;
|
||||||
import static ru.spcex.platform.utils.number.BigDecimalUtil.safeBD;
|
import static ru.spcex.platform.utils.number.BigDecimalUtil.safeBD;
|
||||||
|
|
@ -66,6 +67,7 @@ public class FormingPaymentInstructionAssets implements ISessionStage {
|
||||||
private final IMessageResolver msgResolver = new SimpleMessageResolver();
|
private final IMessageResolver msgResolver = new SimpleMessageResolver();
|
||||||
private final SecuritySelector<Security> securitySelector;
|
private final SecuritySelector<Security> securitySelector;
|
||||||
private final RegistryManager rgsMng;
|
private final RegistryManager rgsMng;
|
||||||
|
private Section section;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public FormingPaymentInstructionAssets(ImdgProvider imdgProvider,
|
public FormingPaymentInstructionAssets(ImdgProvider imdgProvider,
|
||||||
|
|
@ -90,7 +92,7 @@ public class FormingPaymentInstructionAssets implements ISessionStage {
|
||||||
FormingPaymentInstructionPayload payload = (FormingPaymentInstructionPayload) task.getData();
|
FormingPaymentInstructionPayload payload = (FormingPaymentInstructionPayload) task.getData();
|
||||||
switch (task.getTaskType()) {
|
switch (task.getTaskType()) {
|
||||||
case FormingPaymentInstruction -> {
|
case FormingPaymentInstruction -> {
|
||||||
return formingPaymentInstructions(payload.getSessionId());
|
return formingPaymentInstructions(payload);
|
||||||
}
|
}
|
||||||
default -> {
|
default -> {
|
||||||
throw new IllegalStateException("Unknown task type: " + task.getTaskType());
|
throw new IllegalStateException("Unknown task type: " + task.getTaskType());
|
||||||
|
|
@ -98,12 +100,15 @@ public class FormingPaymentInstructionAssets implements ISessionStage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Collection<Registry> selectAMBRegistries() {
|
private Collection<Registry> selectAMBRegistries(Long sessionId) {
|
||||||
ImdgPredicateBuilder rgsPb = registryImdg.predicateBuilder();
|
ImdgPredicateBuilder rgsPb = registryImdg.predicateBuilder();
|
||||||
RegistryCodeSqlBuilder registryCodeSqlBuilder = RegistryCodeSqlBuilder.getInstance(
|
RegistryCodeSqlBuilder registryCodeSqlBuilder = RegistryCodeSqlBuilder.getInstance(
|
||||||
AM_B
|
AM_B
|
||||||
);
|
);
|
||||||
ImdgPredicate rgsCodePrdct = rgsPb.sql(registryCodeSqlBuilder.build());
|
ImdgPredicate rgsCodePrdct = rgsPb.and(
|
||||||
|
rgsPb.sql(registryCodeSqlBuilder.build()),
|
||||||
|
rgsPb.equals("sessionId", sessionId)
|
||||||
|
);
|
||||||
return registryImdg.getCollectionObjectsByPredicate(rgsCodePrdct);
|
return registryImdg.getCollectionObjectsByPredicate(rgsCodePrdct);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -116,8 +121,9 @@ public class FormingPaymentInstructionAssets implements ISessionStage {
|
||||||
return registryImdg.getCollectionObjectsByPredicate(rgsCodePrdct);
|
return registryImdg.getCollectionObjectsByPredicate(rgsCodePrdct);
|
||||||
}
|
}
|
||||||
|
|
||||||
private StageResult<?> formingPaymentInstructions(Long sessionId) {
|
private StageResult<?> formingPaymentInstructions(FormingPaymentInstructionPayload payload) {
|
||||||
Collection<Registry> AMBregistries = selectAMBRegistries();
|
Long sessionId = payload.getSessionId();
|
||||||
|
Collection<Registry> AMBregistries = selectAMBRegistries(sessionId);
|
||||||
log.debug("found AMB registries.size() = {}", AMBregistries.size());
|
log.debug("found AMB registries.size() = {}", AMBregistries.size());
|
||||||
Instant now = Instant.now();
|
Instant now = Instant.now();
|
||||||
Account tranAcc = accountImdg.getFirstObjectBySQL("accountType = '%s' and status = '%s' and processingSign = '%s'"
|
Account tranAcc = accountImdg.getFirstObjectBySQL("accountType = '%s' and status = '%s' and processingSign = '%s'"
|
||||||
|
|
@ -210,7 +216,7 @@ public class FormingPaymentInstructionAssets implements ISessionStage {
|
||||||
registryImdg.update(registry);
|
registryImdg.update(registry);
|
||||||
paymentInstructions.add(paymentInstruction);
|
paymentInstructions.add(paymentInstruction);
|
||||||
}
|
}
|
||||||
|
if (section == null || !section.equals(Section.MKR)) {
|
||||||
Collection<Registry> ASBregistries = selectASBRegistries();
|
Collection<Registry> ASBregistries = selectASBRegistries();
|
||||||
log.debug("found ASB registries.size() = {}", ASBregistries.size());
|
log.debug("found ASB registries.size() = {}", ASBregistries.size());
|
||||||
|
|
||||||
|
|
@ -279,6 +285,15 @@ public class FormingPaymentInstructionAssets implements ISessionStage {
|
||||||
registryImdg.update(registry);
|
registryImdg.update(registry);
|
||||||
paymentInstructions.add(paymentInstruction);
|
paymentInstructions.add(paymentInstruction);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (payload.getPaymentInstructionReturns().size() > 0) {
|
||||||
|
log.debug("PaymentInstructions return size {}, PaymentInstructions deals size {}. sending SDF03",
|
||||||
|
payload.getPaymentInstructionReturns().size(),
|
||||||
|
paymentInstructions.size());
|
||||||
|
paymentInstructions = Stream.concat(payload.getPaymentInstructionReturns().stream(),
|
||||||
|
paymentInstructions.stream()).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sendSdfs(paymentInstructions);
|
sendSdfs(paymentInstructions);
|
||||||
StageResult<Collection<PaymentInstruction>> stageResult = new StageResult<>(null, true);
|
StageResult<Collection<PaymentInstruction>> stageResult = new StageResult<>(null, true);
|
||||||
|
|
@ -364,4 +379,8 @@ public class FormingPaymentInstructionAssets implements ISessionStage {
|
||||||
sDf12.setGenerationTime(Instant.now());
|
sDf12.setGenerationTime(Instant.now());
|
||||||
return sDf12;
|
return sDf12;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSection(Section section) {
|
||||||
|
this.section = section;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,13 @@
|
||||||
package ru.spcex.clearing.session.stage.task;
|
package ru.spcex.clearing.session.stage.task;
|
||||||
|
|
||||||
|
import ru.clearing.classes.statics.data.payment.PaymentInstruction;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
public class FormingPaymentInstructionPayload {
|
public class FormingPaymentInstructionPayload {
|
||||||
private Long sessionId;
|
private Long sessionId;
|
||||||
|
private Collection<PaymentInstruction> paymentInstructionReturns;
|
||||||
|
|
||||||
public Long getSessionId() {
|
public Long getSessionId() {
|
||||||
return sessionId;
|
return sessionId;
|
||||||
|
|
@ -10,4 +16,12 @@ public class FormingPaymentInstructionPayload {
|
||||||
public void setSessionId(Long sessionId) {
|
public void setSessionId(Long sessionId) {
|
||||||
this.sessionId = sessionId;
|
this.sessionId = sessionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Collection<PaymentInstruction> getPaymentInstructionReturns() {
|
||||||
|
return paymentInstructionReturns != null ? paymentInstructionReturns : Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPaymentInstructionReturns(Collection<PaymentInstruction> paymentInstructionReturns) {
|
||||||
|
this.paymentInstructionReturns = paymentInstructionReturns;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue