SDF12 в swt-exporter используется sessionId для определения имени файла
This commit is contained in:
parent
51949a281a
commit
b5a3e7289e
5 changed files with 31 additions and 15 deletions
|
|
@ -295,7 +295,7 @@ public class FormingPaymentInstructionAssets implements ISessionStage {
|
|||
}
|
||||
|
||||
|
||||
Collection<SdfTable> sdfTables = sendSdfs(paymentInstructions);
|
||||
Collection<SdfTable> sdfTables = sendSdfs(paymentInstructions, sessionId);
|
||||
StageResult<PaymentInfo> stageResult = new StageResult<>(null, true);
|
||||
stageResult.setStageResult(new PaymentInfo(paymentInstructions, sdfTables));
|
||||
return stageResult;
|
||||
|
|
@ -307,7 +307,7 @@ public class FormingPaymentInstructionAssets implements ISessionStage {
|
|||
registryImdg.update(rgs);
|
||||
}
|
||||
|
||||
private Collection<SdfTable> sendSdfs(List<PaymentInstruction> formedPaymentInstructions) {
|
||||
private Collection<SdfTable> sendSdfs(List<PaymentInstruction> formedPaymentInstructions, Long sessionId) {
|
||||
Collection<SdfTable> sentSdfs = new ArrayList<>();
|
||||
List<SDf03> sDf03Created = new ArrayList<>();
|
||||
List<SDf12> sDf12Created = new ArrayList<>();
|
||||
|
|
@ -360,6 +360,7 @@ public class FormingPaymentInstructionAssets implements ISessionStage {
|
|||
SwtExporterRequest swtExporterRequest = new SwtExporterRequest();
|
||||
swtExporterRequest.setType("SDF_12");
|
||||
swtExporterRequest.setGroupId(sdf12GroupId);
|
||||
swtExporterRequest.setSessionId(sessionId);
|
||||
kafkaSender.sendRequestToQueue(Consts.SWT_EXPORTER, swtExporterRequest);
|
||||
}
|
||||
if (sdf03GroupId != null) sentSdfs.add(SdfTable.SDF_03);
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ public class FormingPaymentInstructionSecondaryT0 implements ISessionStage {
|
|||
paymentInstructionReturns.size(),
|
||||
paymentInstructionDeals.size());
|
||||
List<PaymentInstruction> returnsAndDeals = Stream.concat(paymentInstructionReturns.stream(), paymentInstructionDeals.stream()).toList();
|
||||
sendSdfs(returnsAndDeals);
|
||||
sendSdfs(returnsAndDeals, sessionId);
|
||||
StageResult<Collection<PaymentInstruction>> stageResult = new StageResult<>(null, true);
|
||||
stageResult.setStageResult(returnsAndDeals);
|
||||
return stageResult;
|
||||
|
|
@ -228,7 +228,7 @@ public class FormingPaymentInstructionSecondaryT0 implements ISessionStage {
|
|||
registryImdg.update(rgs);
|
||||
}
|
||||
|
||||
private void sendSdfs(List<PaymentInstruction> formedPaymentInstructions) {
|
||||
private void sendSdfs(List<PaymentInstruction> formedPaymentInstructions, Long sessionId) {
|
||||
List<SDf03> sDf03Created = new ArrayList<>();
|
||||
List<SDf12> sDf12Created = new ArrayList<>();
|
||||
for (PaymentInstruction paymentInstruction : formedPaymentInstructions) {
|
||||
|
|
@ -279,6 +279,7 @@ public class FormingPaymentInstructionSecondaryT0 implements ISessionStage {
|
|||
SwtExporterRequest swtExporterRequest = new SwtExporterRequest();
|
||||
swtExporterRequest.setType("SDF_12");
|
||||
swtExporterRequest.setGroupId(sdf12GroupId);
|
||||
swtExporterRequest.setSessionId(sessionId);
|
||||
kafkaSender.sendRequestToQueue(Consts.SWT_EXPORTER, swtExporterRequest);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package ru.spcex.clearing.swt.exporter.services;
|
|||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import ru.clearing.classes.statics.data.misc.Session;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.importexport.SwtExporterRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.utilities.JournalEventExportedRequest;
|
||||
import ru.spcex.clearing.platform.messaging.serialization.LogFormatter;
|
||||
|
|
@ -36,6 +38,7 @@ public abstract class AbstractExporterService<T extends SpcexObjectBase> {
|
|||
private final KafkaSender kafkaSender;
|
||||
protected final FileStorage fileStorage;
|
||||
protected final Class<T> mapClass;
|
||||
private final Imdg<Session> sessionImdg;
|
||||
|
||||
protected AbstractExporterService(FileStorage fileStorage,
|
||||
KafkaSender kafkaSender, ImdgProvider imdgProvider,
|
||||
|
|
@ -47,6 +50,7 @@ public abstract class AbstractExporterService<T extends SpcexObjectBase> {
|
|||
this.mapClass = mapClass;
|
||||
Objects.requireNonNull(type, "SWT table type not set");
|
||||
this.sdfImdg = imdgProvider.getImdg(mapName, mapClass);
|
||||
this.sessionImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Session, Session.class);
|
||||
}
|
||||
|
||||
public SwtTable getType() {
|
||||
|
|
@ -156,4 +160,11 @@ public abstract class AbstractExporterService<T extends SpcexObjectBase> {
|
|||
|
||||
protected abstract void writeFooter(PrintWriter out, Collection<T> records, int counter);
|
||||
|
||||
protected Session session(SwtExporterRequest req) {
|
||||
Long sessionId = req.getSessionId();
|
||||
Objects.requireNonNull(sessionId, "cannot process %s without session id".formatted(typeForFileName()));
|
||||
Session session = sessionImdg.getSingleObjectByID(sessionId);
|
||||
Objects.requireNonNull(session, "cannot process %s: couldn't find session.id=%d".formatted(typeForFileName(), sessionId));
|
||||
return session;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package ru.spcex.clearing.swt.exporter.services.exportimpl;
|
|||
|
||||
import com.hazelcast.aws.utility.StringUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.misc.Session;
|
||||
import ru.clearing.classes.statics.data.sdf.SDf12;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.importexport.SwtExporterRequest;
|
||||
|
|
@ -10,6 +11,8 @@ import ru.spcex.clearing.swt.exporter.services.AbstractExporterService;
|
|||
import ru.spcex.clearing.swt.exporter.services.FileStorage;
|
||||
import ru.spcex.clearing.swt.exporter.util.ConvertionContext;
|
||||
import ru.spcex.clearing.swt.exporter.util.SWTHeaderData;
|
||||
import ru.spcex.platform.enumeration.Section;
|
||||
import ru.spcex.platform.enumeration.SessionType;
|
||||
import ru.spcex.platform.enumeration.SwtTable;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
|
|
@ -37,7 +40,14 @@ public class DF12Exporter extends AbstractExporterService<SDf12> {
|
|||
|
||||
@Override
|
||||
protected String sectionForFileName(SwtExporterRequest req) {
|
||||
return "bond"; // todo bond / fund
|
||||
Session session = session(req);
|
||||
if (!Section.FOND.equalsByKey(session.getSection())) {
|
||||
throw new IllegalStateException("%s is only processed for FOND section".formatted(typeForFileName()));
|
||||
}
|
||||
if (SessionType.TRDT.equalsByKey(session.getSessionType())) {
|
||||
return "fund";
|
||||
}
|
||||
return "bond";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -15,12 +15,10 @@ import ru.spcex.platform.enumeration.SessionType;
|
|||
import ru.spcex.platform.enumeration.SwtTable;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
@Service
|
||||
|
|
@ -45,16 +43,11 @@ public class DF14Exporter extends AbstractExporterService<SDf14> {
|
|||
|
||||
@Override
|
||||
protected String sectionForFileName(SwtExporterRequest req) {
|
||||
Long sessionId = req.getSessionId();
|
||||
Objects.requireNonNull(sessionId, "cannot process DF-14 without session id");
|
||||
Session session = sessionImdg.getSingleObjectByID(sessionId);
|
||||
Objects.requireNonNull(session, "cannot process DF-14: couldn't find session.id=%d".formatted(sessionId));
|
||||
SessionType type = IEnumKey.getEnumByKey(SessionType.class, session.getSessionType());
|
||||
Objects.requireNonNull(type, "cannot process DF-14: session.id=%d couldn't determine session type %s".formatted(sessionId, session.getSessionType()));
|
||||
Session session = session(req);
|
||||
if (!Section.FOND.equalsByKey(session.getSection())) {
|
||||
throw new IllegalStateException("DF-14 is only processed for FOND section");
|
||||
throw new IllegalStateException("%s is only processed for FOND section".formatted(typeForFileName()));
|
||||
}
|
||||
if (type == SessionType.TRDT) {
|
||||
if (SessionType.TRDT.equalsByKey(session.getSessionType())) {
|
||||
return "fund";
|
||||
}
|
||||
return "bond";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue