Добавил загрузку документа DF-21.
This commit is contained in:
parent
98335c8b2e
commit
d71a7187fa
17 changed files with 584 additions and 48 deletions
|
|
@ -8,10 +8,7 @@ import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||||
import ru.spcex.clearing.swt.importer.config.settings.ImportSWTServiceSettings;
|
import ru.spcex.clearing.swt.importer.config.settings.ImportSWTServiceSettings;
|
||||||
import ru.spcex.clearing.swt.importer.logic.data.enums.ETable;
|
import ru.spcex.clearing.swt.importer.logic.data.enums.ETable;
|
||||||
import ru.spcex.clearing.swt.importer.logic.data.tables.AbstractTable;
|
import ru.spcex.clearing.swt.importer.logic.data.tables.*;
|
||||||
import ru.spcex.clearing.swt.importer.logic.data.tables.SDf08Table;
|
|
||||||
import ru.spcex.clearing.swt.importer.logic.data.tables.SDf10Table;
|
|
||||||
import ru.spcex.clearing.swt.importer.logic.data.tables.SDf13Table;
|
|
||||||
import ru.spcex.clearing.swt.importer.logic.stages.*;
|
import ru.spcex.clearing.swt.importer.logic.stages.*;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
@ -60,6 +57,7 @@ public class SWTImporterConfig {
|
||||||
map.put(ETable.S_DF_08, new SDf08Table());
|
map.put(ETable.S_DF_08, new SDf08Table());
|
||||||
map.put(ETable.S_DF_10, new SDf10Table());
|
map.put(ETable.S_DF_10, new SDf10Table());
|
||||||
map.put(ETable.S_DF_13, new SDf13Table());
|
map.put(ETable.S_DF_13, new SDf13Table());
|
||||||
|
map.put(ETable.S_DF_21, new SDf21Table());
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,8 @@ package ru.spcex.clearing.swt.importer.logic.data.enums;
|
||||||
public enum ETable {
|
public enum ETable {
|
||||||
S_DF_08("DF-08"),
|
S_DF_08("DF-08"),
|
||||||
S_DF_10("DF-10"),
|
S_DF_10("DF-10"),
|
||||||
S_DF_13("DF-13");
|
S_DF_13("DF-13"),
|
||||||
|
S_DF_21("DF-21");
|
||||||
//S_DF20("DF-20");
|
//S_DF20("DF-20");
|
||||||
|
|
||||||
private final String prefix;
|
private final String prefix;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package ru.spcex.clearing.swt.importer.logic.data.enums;
|
package ru.spcex.clearing.swt.importer.logic.data.enums;
|
||||||
|
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import ru.spcex.clearing.swt.importer.util.SWTRecord;
|
import ru.spcex.clearing.swt.importer.readers.SWTRecord;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
|
@ -60,6 +60,15 @@ public enum ReadingPatterns {
|
||||||
record.setValFor20Tag(getValueWitoutKey(line, ":20:"));
|
record.setValFor20Tag(getValueWitoutKey(line, ":20:"));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Tag20C {
|
||||||
|
public boolean canRead(String line) {
|
||||||
|
return line.startsWith(":20C:");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reed(String line, SWTRecord record) {
|
||||||
|
record.setValFor20CTag(getValueWitoutKey(line, ":20C:"));
|
||||||
|
}
|
||||||
|
},
|
||||||
Tag21 {
|
Tag21 {
|
||||||
public boolean canRead(String line) {
|
public boolean canRead(String line) {
|
||||||
return line.startsWith(":21:");
|
return line.startsWith(":21:");
|
||||||
|
|
@ -78,13 +87,22 @@ public enum ReadingPatterns {
|
||||||
record.setValFor23Tag(getValueWitoutKey(line, ":23:"));
|
record.setValFor23Tag(getValueWitoutKey(line, ":23:"));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Tag35A {
|
Tag30 {
|
||||||
public boolean canRead(String line) {
|
public boolean canRead(String line) {
|
||||||
return line.startsWith(":35A:");
|
return line.startsWith(":30:");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reed(String line, SWTRecord record) {
|
public void reed(String line, SWTRecord record) {
|
||||||
record.setValFor35ATag(getValueWitoutKey(line, ":35A:"));
|
record.setValFor30Tag(getValueWitoutKey(line, ":30:"));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Tag35A {
|
||||||
|
public boolean canRead(String line) {
|
||||||
|
return line.startsWith(":35A:SHS");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reed(String line, SWTRecord record) {
|
||||||
|
record.setValFor35ATag(getValueWitoutKey(line, ":35A:SHS").replace(",", ""));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Tag35B {
|
Tag35B {
|
||||||
|
|
@ -93,7 +111,36 @@ public enum ReadingPatterns {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reed(String line, SWTRecord record) {
|
public void reed(String line, SWTRecord record) {
|
||||||
record.setValFor35BTag(getValueWitoutKey(line, ":35B:"));
|
String[] cells = getValueWitoutKey(line, ":35B:ISIN ").split(":");
|
||||||
|
cells = Arrays.copyOf(cells, 3);
|
||||||
|
record.setValFor35BTag(cells);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Tag60A {
|
||||||
|
public boolean canRead(String line) {
|
||||||
|
return line.startsWith(":60A:SHS");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reed(String line, SWTRecord record) {
|
||||||
|
record.setValFor60ATag(getValueWitoutKey(line, ":60A:SHS").replace(",", ""));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Tag62A {
|
||||||
|
public boolean canRead(String line) {
|
||||||
|
return line.startsWith(":62A:SHS");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reed(String line, SWTRecord record) {
|
||||||
|
record.setValFor62ATag(getValueWitoutKey(line, ":62A:SHS").replace(",", ""));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Tag66A {
|
||||||
|
public boolean canRead(String line) {
|
||||||
|
return line.startsWith(":66A:");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reed(String line, SWTRecord record) {
|
||||||
|
record.setValFor66ATag(getValueWitoutKey(line, ":66A:"));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Tag76 {
|
Tag76 {
|
||||||
|
|
@ -123,6 +170,18 @@ public enum ReadingPatterns {
|
||||||
record.setValFor82DTag(getValueWitoutKey(line, ":82D:"));
|
record.setValFor82DTag(getValueWitoutKey(line, ":82D:"));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Tag83D {
|
||||||
|
public boolean canRead(String line) {
|
||||||
|
return line.startsWith(":83D:");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reed(String line, SWTRecord record) {
|
||||||
|
String[] cells = getValueWitoutKey(line, ":83D:").split(":");
|
||||||
|
cells = Arrays.copyOf(cells, 3);
|
||||||
|
record.setValFor35BTag(cells);
|
||||||
|
record.setValFor83DTag(cells);
|
||||||
|
}
|
||||||
|
},
|
||||||
Tag87C {
|
Tag87C {
|
||||||
public boolean canRead(String line) {
|
public boolean canRead(String line) {
|
||||||
return line.startsWith(":87C:");
|
return line.startsWith(":87C:");
|
||||||
|
|
@ -132,6 +191,15 @@ public enum ReadingPatterns {
|
||||||
record.setValFor87CTag(getValueWitoutKey(line, ":87C:"));
|
record.setValFor87CTag(getValueWitoutKey(line, ":87C:"));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Tag87D {
|
||||||
|
public boolean canRead(String line) {
|
||||||
|
return line.startsWith(":87D:");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reed(String line, SWTRecord record) {
|
||||||
|
record.setValFor87DTag(getValueWitoutKey(line, ":87D:"));
|
||||||
|
}
|
||||||
|
},
|
||||||
TableRow {
|
TableRow {
|
||||||
public boolean canRead(String line) {
|
public boolean canRead(String line) {
|
||||||
String[] sepLine = line.split(":");
|
String[] sepLine = line.split(":");
|
||||||
|
|
@ -145,7 +213,8 @@ public enum ReadingPatterns {
|
||||||
cells = Arrays.copyOf(cells, 20);
|
cells = Arrays.copyOf(cells, 20);
|
||||||
record.setTableRow(cells);
|
record.setTableRow(cells);
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
EndFile;
|
||||||
|
|
||||||
public boolean canRead(String line) {
|
public boolean canRead(String line) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package ru.spcex.clearing.swt.importer.logic.data.tables;
|
package ru.spcex.clearing.swt.importer.logic.data.tables;
|
||||||
|
|
||||||
import ru.spcex.clearing.swt.importer.util.SWTRecord;
|
import ru.spcex.clearing.swt.importer.readers.SWTRecord;
|
||||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||||
import ru.spcex.platform.imdg.iml.hazelcast.adapter.ImdgHazelcast;
|
import ru.spcex.platform.imdg.iml.hazelcast.adapter.ImdgHazelcast;
|
||||||
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package ru.spcex.clearing.swt.importer.logic.data.tables;
|
||||||
import ru.clearing.classes.statics.data.sdf.SDf08;
|
import ru.clearing.classes.statics.data.sdf.SDf08;
|
||||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||||
import ru.spcex.clearing.swt.importer.logic.data.enums.ETable;
|
import ru.spcex.clearing.swt.importer.logic.data.enums.ETable;
|
||||||
import ru.spcex.clearing.swt.importer.util.SWTRecord;
|
import ru.spcex.clearing.swt.importer.readers.SWTRecord;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package ru.spcex.clearing.swt.importer.logic.data.tables;
|
||||||
import ru.clearing.classes.statics.data.sdf.SDf10;
|
import ru.clearing.classes.statics.data.sdf.SDf10;
|
||||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||||
import ru.spcex.clearing.swt.importer.logic.data.enums.ETable;
|
import ru.spcex.clearing.swt.importer.logic.data.enums.ETable;
|
||||||
import ru.spcex.clearing.swt.importer.util.SWTRecord;
|
import ru.spcex.clearing.swt.importer.readers.SWTRecord;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package ru.spcex.clearing.swt.importer.logic.data.tables;
|
||||||
import ru.clearing.classes.statics.data.sdf.SDf13;
|
import ru.clearing.classes.statics.data.sdf.SDf13;
|
||||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||||
import ru.spcex.clearing.swt.importer.logic.data.enums.ETable;
|
import ru.spcex.clearing.swt.importer.logic.data.enums.ETable;
|
||||||
import ru.spcex.clearing.swt.importer.util.SWTRecord;
|
import ru.spcex.clearing.swt.importer.readers.SWTRecord;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
package ru.spcex.clearing.swt.importer.logic.data.tables;
|
||||||
|
|
||||||
|
import ru.clearing.classes.statics.data.sdf.SDf21;
|
||||||
|
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||||
|
import ru.spcex.clearing.swt.importer.logic.data.enums.ETable;
|
||||||
|
import ru.spcex.clearing.swt.importer.readers.SWTRecord;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
|
public class SDf21Table extends AbstractTable<SDf21> {
|
||||||
|
|
||||||
|
private static final String PREFIX = ETable.S_DF_21.name();
|
||||||
|
private static final Class<SDf21> CLAZZ = SDf21.class;
|
||||||
|
private static final String NAME_OF_HZ_MAP = IMDGDistributedNames.Map_SDf21;
|
||||||
|
|
||||||
|
public SDf21Table() {
|
||||||
|
super(PREFIX, CLAZZ, NAME_OF_HZ_MAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SDf21 getEntity(SWTRecord record) {
|
||||||
|
SDf21 result = new SDf21();
|
||||||
|
result.setOutDocument(record.getValFor20Tag());
|
||||||
|
result.setInDocument(record.getValFor21Tag());
|
||||||
|
result.setSecurityCode(record.getValFor35BTag()[0]);
|
||||||
|
result.setSecurityName(record.getValFor35BTag()[1]);
|
||||||
|
result.setSecurityType(record.getValFor35BTag()[2]);
|
||||||
|
result.setOpenBalance(record.getValFor60ATag());
|
||||||
|
result.setDepoCodeCl(record.getValFor83DTag()[0]);
|
||||||
|
result.setNameCl(record.getValFor83DTag()[1]);
|
||||||
|
result.setQuantity(record.getValFor35ATag());
|
||||||
|
result.setOperationCode(record.getValFor66ATag());
|
||||||
|
result.setDepoCodeCorr(record.getValFor87DTag());
|
||||||
|
result.setOperationDate(record.getValFor30Tag());
|
||||||
|
result.setCloseBalance(record.getValFor62ATag());
|
||||||
|
result.setFileName(filename);
|
||||||
|
result.setGenerationTime(Instant.now());
|
||||||
|
result.setGenerationId(fileId);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -7,8 +7,9 @@ import ru.spcex.clearing.swt.importer.logic.data.ResultContainer;
|
||||||
import ru.spcex.clearing.swt.importer.logic.data.enums.ETable;
|
import ru.spcex.clearing.swt.importer.logic.data.enums.ETable;
|
||||||
import ru.spcex.clearing.swt.importer.logic.data.enums.StageResult;
|
import ru.spcex.clearing.swt.importer.logic.data.enums.StageResult;
|
||||||
import ru.spcex.clearing.swt.importer.logic.data.tables.AbstractTable;
|
import ru.spcex.clearing.swt.importer.logic.data.tables.AbstractTable;
|
||||||
import ru.spcex.clearing.swt.importer.util.SWTReader;
|
import ru.spcex.clearing.swt.importer.readers.SWTReader;
|
||||||
import ru.spcex.clearing.swt.importer.util.SWTRecord;
|
import ru.spcex.clearing.swt.importer.readers.SWTRecord;
|
||||||
|
import ru.spcex.clearing.swt.importer.readers.ValidationResult;
|
||||||
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
||||||
import ru.spcex.platform.utils.log.ExceptionUtils;
|
import ru.spcex.platform.utils.log.ExceptionUtils;
|
||||||
|
|
||||||
|
|
@ -16,7 +17,11 @@ import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import static ru.spcex.clearing.swt.importer.readers.ValidationResult.SUCSESS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Заливка проверенных данных в базу
|
* Заливка проверенных данных в базу
|
||||||
|
|
@ -53,14 +58,20 @@ public class ImportToDB extends Stage {
|
||||||
hazelcastService.waitAvailable();
|
hazelcastService.waitAvailable();
|
||||||
Long fileId = hazelcastService.getImdgIdGenerator().nextId();
|
Long fileId = hazelcastService.getImdgIdGenerator().nextId();
|
||||||
table.setFileId(fileId);
|
table.setFileId(fileId);
|
||||||
int counter = 0;
|
AtomicInteger counter = new AtomicInteger();
|
||||||
do {
|
do {
|
||||||
SWTRecord record = swtReader.nextRecord();
|
ValidationResult result = swtReader.readGroupRecords();
|
||||||
if (record.isNotEmpty()) {
|
if (!SUCSESS.equals(result)) {
|
||||||
table.injectEntity(table.getEntity(record));
|
log.debug("reading error: {}.", result.message());
|
||||||
counter++;
|
return StageResult.ERROR;
|
||||||
log.debug("{} entity stored.", counter);
|
}
|
||||||
} else continue;
|
List<SWTRecord> records = swtReader.getGroupRecords();
|
||||||
|
records.forEach(record -> {
|
||||||
|
if (record.isNotEmpty()) {
|
||||||
|
table.injectEntity(table.getEntity(record));
|
||||||
|
log.debug("{} entity stored.", counter.incrementAndGet());
|
||||||
|
}
|
||||||
|
});
|
||||||
} while (swtReader.hasNextRecord());
|
} while (swtReader.hasNextRecord());
|
||||||
kafkaMessenger.notifySystemIfNeeded(currTable, fileId);
|
kafkaMessenger.notifySystemIfNeeded(currTable, fileId);
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
|
|
@ -71,7 +82,6 @@ public class ImportToDB extends Stage {
|
||||||
return StageResult.ERROR;
|
return StageResult.ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return StageResult.OK;
|
return StageResult.OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
package ru.spcex.clearing.swt.importer.readers;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import ru.spcex.clearing.swt.importer.logic.data.enums.ReadingPatterns;
|
||||||
|
import ru.spcex.clearing.swt.importer.readers.template.SDf21Template;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Scanner;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import static ru.spcex.clearing.swt.importer.readers.ValidationResult.SUCSESS;
|
||||||
|
|
||||||
|
public abstract class AbstractTemplate {
|
||||||
|
protected Logger log = LoggerFactory.getLogger(getClass());
|
||||||
|
protected Scanner scanner;
|
||||||
|
protected boolean readEnded;
|
||||||
|
|
||||||
|
protected abstract List<SWTRecord> getGroupRecords();
|
||||||
|
|
||||||
|
protected abstract ValidationResult readAndValidate();
|
||||||
|
|
||||||
|
public AbstractTemplate(Scanner scanner) {
|
||||||
|
this.scanner = scanner;
|
||||||
|
this.readEnded = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ValidationResult checkNotValue(String line, String errMes) {
|
||||||
|
for (ReadingPatterns pattern : ReadingPatterns.values()) {
|
||||||
|
if (pattern.canRead(line)) {
|
||||||
|
return new ValidationResult(errMes + pattern.name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return SUCSESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ValidationResult prepareNextLine(Consumer<String> lineSetter) {
|
||||||
|
while (scanner.hasNextLine()) {
|
||||||
|
lineSetter.accept(scanner.nextLine());
|
||||||
|
return SUCSESS;
|
||||||
|
}
|
||||||
|
return new ValidationResult("Bud file format.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isReadEnded() {
|
||||||
|
return readEnded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReadEnded(boolean readEnded) {
|
||||||
|
this.readEnded = readEnded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AbstractTemplate getSDf21Template(Scanner scanner){
|
||||||
|
return new SDf21Template(scanner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package ru.spcex.clearing.swt.importer.util;
|
package ru.spcex.clearing.swt.importer.readers;
|
||||||
|
|
||||||
import ru.spcex.clearing.swt.importer.logic.data.ResultContainer;
|
import ru.spcex.clearing.swt.importer.logic.data.ResultContainer;
|
||||||
import ru.spcex.clearing.swt.importer.logic.data.enums.ETable;
|
import ru.spcex.clearing.swt.importer.logic.data.enums.ETable;
|
||||||
|
|
@ -8,9 +8,10 @@ import java.io.Closeable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.Map;
|
import java.util.function.Function;
|
||||||
import java.util.Scanner;
|
|
||||||
|
import static ru.spcex.clearing.swt.importer.readers.ValidationResult.SUCSESS;
|
||||||
|
|
||||||
public class SWTReader implements Closeable {
|
public class SWTReader implements Closeable {
|
||||||
protected InputStream inputStream;
|
protected InputStream inputStream;
|
||||||
|
|
@ -18,20 +19,26 @@ public class SWTReader implements Closeable {
|
||||||
protected ResultContainer resultContainer;
|
protected ResultContainer resultContainer;
|
||||||
private SWTRecord record;
|
private SWTRecord record;
|
||||||
private static Map<ETable, ReadingPatterns> recordEnds = new HashMap<>();
|
private static Map<ETable, ReadingPatterns> recordEnds = new HashMap<>();
|
||||||
|
private static Map<ETable, Function<Scanner, AbstractTemplate>> templates = new HashMap<>();
|
||||||
private ReadingPatterns recordEnd;
|
private ReadingPatterns recordEnd;
|
||||||
|
private AbstractTemplate template;
|
||||||
|
private List<SWTRecord> groupRecords = new ArrayList<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
recordEnds.put(ETable.S_DF_08, ReadingPatterns.TableRow);
|
recordEnds.put(ETable.S_DF_08, ReadingPatterns.TableRow);
|
||||||
recordEnds.put(ETable.S_DF_10, ReadingPatterns.TableRow);
|
recordEnds.put(ETable.S_DF_10, ReadingPatterns.TableRow);
|
||||||
recordEnds.put(ETable.S_DF_13, ReadingPatterns.Tag77A);
|
recordEnds.put(ETable.S_DF_13, ReadingPatterns.Tag77A);
|
||||||
|
templates.put(ETable.S_DF_21, AbstractTemplate::getSDf21Template);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SWTReader(InputStream inputStream, Charset charset, ResultContainer resultContainer) {
|
public SWTReader(InputStream inputStream, Charset charset, ResultContainer resultContainer) {
|
||||||
this.inputStream = inputStream;
|
this.inputStream = inputStream;
|
||||||
this.scanner = new Scanner(inputStream, charset);
|
this.scanner = new Scanner(inputStream, charset);
|
||||||
this.resultContainer = resultContainer;
|
this.resultContainer = resultContainer;
|
||||||
recordEnd = recordEnds.get(resultContainer.getSwtTable());
|
this.recordEnd = recordEnds.get(resultContainer.getSwtTable());
|
||||||
this.record = new SWTRecord();
|
this.record = new SWTRecord();
|
||||||
|
if (templates.containsKey(resultContainer.getSwtTable()))
|
||||||
|
this.template = templates.get(resultContainer.getSwtTable()).apply(scanner);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SWTRecord nextRecord() {
|
public SWTRecord nextRecord() {
|
||||||
|
|
@ -51,10 +58,29 @@ public class SWTReader implements Closeable {
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ValidationResult readGroupRecords(){
|
||||||
|
groupRecords = new ArrayList<>();
|
||||||
|
if (template != null) {
|
||||||
|
ValidationResult result = template.readAndValidate();
|
||||||
|
if (!SUCSESS.equals(result)) return result;
|
||||||
|
groupRecords.addAll(template.getGroupRecords());
|
||||||
|
} else {
|
||||||
|
groupRecords.add(nextRecord());
|
||||||
|
}
|
||||||
|
return SUCSESS;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasNextRecord() {
|
public boolean hasNextRecord() {
|
||||||
|
if (template != null){
|
||||||
|
return !template.isReadEnded();
|
||||||
|
}
|
||||||
return scanner.hasNextLine();
|
return scanner.hasNextLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<SWTRecord> getGroupRecords() {
|
||||||
|
return groupRecords;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
|
|
@ -1,24 +1,32 @@
|
||||||
package ru.spcex.clearing.swt.importer.util;
|
package ru.spcex.clearing.swt.importer.readers;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
public class SWTRecord {
|
public class SWTRecord implements Cloneable {
|
||||||
private static final DateTimeFormatter dtInFileHeaderFormatter = DateTimeFormatter.ofPattern("yyyyMMdd'/'HHmm");
|
private static final DateTimeFormatter dtInFileHeaderFormatter = DateTimeFormatter.ofPattern("yyyyMMdd'/'HHmm");
|
||||||
|
private static final DateTimeFormatter dt30Formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||||
private String to;
|
private String to;
|
||||||
private String from;
|
private String from;
|
||||||
private String type;
|
private String type;
|
||||||
private LocalDateTime dateTime;
|
private LocalDateTime dateTime;
|
||||||
private String valFor20Tag;
|
|
||||||
private String valFor18ATag;
|
private String valFor18ATag;
|
||||||
|
private String valFor20Tag;
|
||||||
|
private String valFor20CTag;
|
||||||
private String valFor21Tag;
|
private String valFor21Tag;
|
||||||
private String valFor23Tag;
|
private String valFor23Tag;
|
||||||
|
private String valFor30Tag;
|
||||||
private String valFor35ATag;
|
private String valFor35ATag;
|
||||||
private String valFor35BTag;
|
private String[] valFor35BTag;//Код ценной бумаги:наименование:тип
|
||||||
|
private String valFor60ATag;
|
||||||
|
private String valFor62ATag;
|
||||||
|
private String valFor66ATag;
|
||||||
private String valFor76Tag;
|
private String valFor76Tag;
|
||||||
private String valFor77ATag;
|
private String valFor77ATag;
|
||||||
private String valFor82DTag;
|
private String valFor82DTag;
|
||||||
|
private String[] valFor83DTag;
|
||||||
private String valFor87CTag;
|
private String valFor87CTag;
|
||||||
|
private String valFor87DTag;
|
||||||
private boolean notEmpty;
|
private boolean notEmpty;
|
||||||
private String[] tableRow;
|
private String[] tableRow;
|
||||||
|
|
||||||
|
|
@ -74,6 +82,14 @@ public class SWTRecord {
|
||||||
this.dateTime = LocalDateTime.from(dtInFileHeaderFormatter.parse(dateTime));
|
this.dateTime = LocalDateTime.from(dtInFileHeaderFormatter.parse(dateTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getValFor18ATag() {
|
||||||
|
return valFor18ATag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValFor18ATag(String valFor18ATag) {
|
||||||
|
this.valFor18ATag = valFor18ATag;
|
||||||
|
}
|
||||||
|
|
||||||
public String getValFor20Tag() {
|
public String getValFor20Tag() {
|
||||||
return valFor20Tag;
|
return valFor20Tag;
|
||||||
}
|
}
|
||||||
|
|
@ -82,12 +98,12 @@ public class SWTRecord {
|
||||||
this.valFor20Tag = valFor20Tag;
|
this.valFor20Tag = valFor20Tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValFor18ATag() {
|
public String getValFor20CTag() {
|
||||||
return valFor18ATag;
|
return valFor20CTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValFor18ATag(String valFor18ATag) {
|
public void setValFor20CTag(String valFor20CTag) {
|
||||||
this.valFor18ATag = valFor18ATag;
|
this.valFor20CTag = valFor20CTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValFor21Tag() {
|
public String getValFor21Tag() {
|
||||||
|
|
@ -106,6 +122,14 @@ public class SWTRecord {
|
||||||
this.valFor23Tag = valFor23Tag;
|
this.valFor23Tag = valFor23Tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getValFor30Tag() {
|
||||||
|
return valFor30Tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValFor30Tag(String valFor30Tag) {
|
||||||
|
this.valFor30Tag = valFor30Tag;
|
||||||
|
}
|
||||||
|
|
||||||
public String getValFor35ATag() {
|
public String getValFor35ATag() {
|
||||||
return valFor35ATag;
|
return valFor35ATag;
|
||||||
}
|
}
|
||||||
|
|
@ -114,14 +138,38 @@ public class SWTRecord {
|
||||||
this.valFor35ATag = valFor35ATag;
|
this.valFor35ATag = valFor35ATag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValFor35BTag() {
|
public String[] getValFor35BTag() {
|
||||||
return valFor35BTag;
|
return valFor35BTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValFor35BTag(String valFor35BTag) {
|
public void setValFor35BTag(String[] valFor35BTag) {
|
||||||
this.valFor35BTag = valFor35BTag;
|
this.valFor35BTag = valFor35BTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getValFor60ATag() {
|
||||||
|
return valFor60ATag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValFor60ATag(String valFor60ATag) {
|
||||||
|
this.valFor60ATag = valFor60ATag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValFor62ATag() {
|
||||||
|
return valFor62ATag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValFor62ATag(String valFor62ATag) {
|
||||||
|
this.valFor62ATag = valFor62ATag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValFor66ATag() {
|
||||||
|
return valFor66ATag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValFor66ATag(String valFor66ATag) {
|
||||||
|
this.valFor66ATag = valFor66ATag;
|
||||||
|
}
|
||||||
|
|
||||||
public String getValFor82DTag() {
|
public String getValFor82DTag() {
|
||||||
return valFor82DTag;
|
return valFor82DTag;
|
||||||
}
|
}
|
||||||
|
|
@ -130,6 +178,14 @@ public class SWTRecord {
|
||||||
this.valFor82DTag = valFor82DTag;
|
this.valFor82DTag = valFor82DTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String[] getValFor83DTag() {
|
||||||
|
return valFor83DTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValFor83DTag(String[] valFor83DTag) {
|
||||||
|
this.valFor83DTag = valFor83DTag;
|
||||||
|
}
|
||||||
|
|
||||||
public String getValFor87CTag() {
|
public String getValFor87CTag() {
|
||||||
return valFor87CTag;
|
return valFor87CTag;
|
||||||
}
|
}
|
||||||
|
|
@ -138,6 +194,14 @@ public class SWTRecord {
|
||||||
this.valFor87CTag = valFor87CTag;
|
this.valFor87CTag = valFor87CTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getValFor87DTag() {
|
||||||
|
return valFor87DTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValFor87DTag(String valFor87DTag) {
|
||||||
|
this.valFor87DTag = valFor87DTag;
|
||||||
|
}
|
||||||
|
|
||||||
public String[] getTableRow() {
|
public String[] getTableRow() {
|
||||||
return tableRow;
|
return tableRow;
|
||||||
}
|
}
|
||||||
|
|
@ -191,4 +255,9 @@ public class SWTRecord {
|
||||||
}
|
}
|
||||||
return stringBuilder.toString();
|
return stringBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SWTRecord clone() throws CloneNotSupportedException {
|
||||||
|
return (SWTRecord) super.clone();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
package ru.spcex.clearing.swt.importer.readers;
|
||||||
|
|
||||||
|
public record ValidationResult(String message) {
|
||||||
|
public static ValidationResult SUCSESS = new ValidationResult("");
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,141 @@
|
||||||
|
package ru.spcex.clearing.swt.importer.readers.template;
|
||||||
|
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
import ru.spcex.clearing.swt.importer.logic.data.enums.ReadingPatterns;
|
||||||
|
import ru.spcex.clearing.swt.importer.readers.AbstractTemplate;
|
||||||
|
import ru.spcex.clearing.swt.importer.readers.SWTRecord;
|
||||||
|
import ru.spcex.clearing.swt.importer.readers.ValidationResult;
|
||||||
|
import ru.spcex.platform.utils.log.ExceptionUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
import static ru.spcex.clearing.swt.importer.logic.data.enums.ReadingPatterns.*;
|
||||||
|
import static ru.spcex.clearing.swt.importer.readers.ValidationResult.SUCSESS;
|
||||||
|
|
||||||
|
public class SDf21Template extends AbstractTemplate {
|
||||||
|
private List<ReadingPatterns> hederPatterns = List.of(
|
||||||
|
To,
|
||||||
|
From,
|
||||||
|
Type,
|
||||||
|
DateTime,
|
||||||
|
Tag20,
|
||||||
|
Tag21,
|
||||||
|
Tag18A);
|
||||||
|
private List<ReadingPatterns> oneDimensionalPatterns = List.of(
|
||||||
|
Tag35B,
|
||||||
|
Tag60A,
|
||||||
|
Tag83D,
|
||||||
|
Tag18A,
|
||||||
|
Tag62A);
|
||||||
|
private List<ReadingPatterns> twoDimensionalPatterns = List.of(
|
||||||
|
Tag20C,
|
||||||
|
Tag35A,
|
||||||
|
Tag23,
|
||||||
|
Tag66A,
|
||||||
|
Tag87D,
|
||||||
|
Tag30);
|
||||||
|
|
||||||
|
private List<SWTRecord> groupRecords = new ArrayList<>();
|
||||||
|
|
||||||
|
private String line = "";
|
||||||
|
|
||||||
|
public SDf21Template(Scanner scanner) {
|
||||||
|
super(scanner);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<SWTRecord> getGroupRecords() {
|
||||||
|
return groupRecords;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ValidationResult readAndValidate() {
|
||||||
|
int oneDimensionalCount = 0;
|
||||||
|
SWTRecord currentRecord = new SWTRecord();
|
||||||
|
currentRecord.setNotEmpty(false);
|
||||||
|
ReadingPatterns currentPattern;
|
||||||
|
ValidationResult result = prepareNextLine(this::setLine);
|
||||||
|
List<SWTRecord> currentRecords = new ArrayList<>();
|
||||||
|
if (!SUCSESS.equals(result)) return result;
|
||||||
|
for (int i = 0; i < hederPatterns.size() && !isReadEnded(); i++) {
|
||||||
|
currentPattern = hederPatterns.get(i);
|
||||||
|
if (currentPattern.canRead(line)) {
|
||||||
|
currentPattern.reed(line, currentRecord);
|
||||||
|
result = prepareNextLine(this::setLine);
|
||||||
|
if (!SUCSESS.equals(result)) return result;
|
||||||
|
currentRecord.setNotEmpty(true);
|
||||||
|
if (Tag18A.equals(currentPattern)) {
|
||||||
|
String str18 = currentRecord.getValFor18ATag().trim();
|
||||||
|
if (StringUtils.hasText(str18)) {
|
||||||
|
int count = Integer.parseInt(str18);
|
||||||
|
oneDimensionalCount = oneDimensionalPatterns.size() * count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result = checkNotValue(line, "required teg: " + currentPattern.name() + ", but was: ");
|
||||||
|
if (!SUCSESS.equals(result)) return result;
|
||||||
|
result = prepareNextLine(this::setLine);
|
||||||
|
if (!SUCSESS.equals(result)) return result;
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
for (int j = 0; j < oneDimensionalCount; j++) {
|
||||||
|
int twoDimensionalCount = 0;
|
||||||
|
currentPattern = oneDimensionalPatterns.get(j % oneDimensionalPatterns.size());
|
||||||
|
if (currentPattern.canRead(line)) {
|
||||||
|
currentPattern.reed(line, currentRecord);
|
||||||
|
result = prepareNextLine(this::setLine);
|
||||||
|
if (!SUCSESS.equals(result)) return result;
|
||||||
|
currentRecord.setNotEmpty(true);
|
||||||
|
if (Tag18A.equals(currentPattern)) {
|
||||||
|
String str18 = currentRecord.getValFor18ATag().trim();
|
||||||
|
if (StringUtils.hasText(str18)) {
|
||||||
|
int count = Integer.parseInt(str18);
|
||||||
|
twoDimensionalCount = twoDimensionalPatterns.size() * count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Tag62A.equals(currentPattern)) {
|
||||||
|
currentRecords.forEach(r -> r.setValFor62ATag(currentRecord.getValFor62ATag()));
|
||||||
|
groupRecords.addAll(currentRecords);
|
||||||
|
currentRecords = new ArrayList<>();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result = checkNotValue(line, "required teg: " + currentPattern.name() + ", but was: ");
|
||||||
|
if (!SUCSESS.equals(result)) return result;
|
||||||
|
result = prepareNextLine(this::setLine);
|
||||||
|
if (!SUCSESS.equals(result)) return result;
|
||||||
|
j--;
|
||||||
|
}
|
||||||
|
for (int k = 0; k < twoDimensionalCount; k++) {
|
||||||
|
currentPattern = twoDimensionalPatterns.get(k % twoDimensionalPatterns.size());
|
||||||
|
if (currentPattern.canRead(line)) {
|
||||||
|
currentPattern.reed(line, currentRecord);
|
||||||
|
result = prepareNextLine(this::setLine);
|
||||||
|
if (!SUCSESS.equals(result)) return result;
|
||||||
|
currentRecord.setNotEmpty(true);
|
||||||
|
if (Tag30.equals(currentPattern)) {
|
||||||
|
try {
|
||||||
|
currentRecords.add(currentRecord.clone());
|
||||||
|
} catch (CloneNotSupportedException e) {
|
||||||
|
log.error(ExceptionUtils.getStackTrace(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result = checkNotValue(line, "required teg: " + currentPattern.name() + ", but was: ");
|
||||||
|
if (!SUCSESS.equals(result)) return result;
|
||||||
|
result = prepareNextLine(this::setLine);
|
||||||
|
if (!SUCSESS.equals(result)) return result;
|
||||||
|
k--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setReadEnded(true);
|
||||||
|
return SUCSESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLine(String line) {
|
||||||
|
this.line = line;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,10 +5,7 @@ import org.springframework.context.annotation.Configuration;
|
||||||
import ru.spcex.clearing.swt.importer.config.settings.Common;
|
import ru.spcex.clearing.swt.importer.config.settings.Common;
|
||||||
import ru.spcex.clearing.swt.importer.config.settings.ImportSWTServiceSettings;
|
import ru.spcex.clearing.swt.importer.config.settings.ImportSWTServiceSettings;
|
||||||
import ru.spcex.clearing.swt.importer.logic.data.enums.ETable;
|
import ru.spcex.clearing.swt.importer.logic.data.enums.ETable;
|
||||||
import ru.spcex.clearing.swt.importer.logic.data.tables.AbstractTable;
|
import ru.spcex.clearing.swt.importer.logic.data.tables.*;
|
||||||
import ru.spcex.clearing.swt.importer.logic.data.tables.SDf08Table;
|
|
||||||
import ru.spcex.clearing.swt.importer.logic.data.tables.SDf10Table;
|
|
||||||
import ru.spcex.clearing.swt.importer.logic.data.tables.SDf13Table;
|
|
||||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||||
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
||||||
|
|
||||||
|
|
@ -33,6 +30,7 @@ public class ImportSWTServiceTest {
|
||||||
map.put(ETable.S_DF_08, new SDf08Table());
|
map.put(ETable.S_DF_08, new SDf08Table());
|
||||||
map.put(ETable.S_DF_10, new SDf10Table());
|
map.put(ETable.S_DF_10, new SDf10Table());
|
||||||
map.put(ETable.S_DF_13, new SDf13Table());
|
map.put(ETable.S_DF_13, new SDf13Table());
|
||||||
|
map.put(ETable.S_DF_21, new SDf21Table());
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,111 @@
|
||||||
|
|
||||||
|
To:SPCE
|
||||||
|
|
||||||
|
From:CSO
|
||||||
|
Type:572
|
||||||
|
Date/Time:20230717/1640
|
||||||
|
:20:SDC230717164022
|
||||||
|
:21:NONREF
|
||||||
|
|
||||||
|
empty string
|
||||||
|
|
||||||
|
:18A:4
|
||||||
|
:35B:ISIN MFBEL-BV-08:Ðåñïóáëèêà Áåëàðóñü:îáëèãàöèè
|
||||||
|
:60A:SHS1,
|
||||||
|
:83D:747200000AT0:ÏÀÎ "Ïðîìñâÿçüáàíê":ðàçäåë îñíîâíîé äëÿ ðàñ÷åòîâ (ñîáñòâåííûå ÖÁ)
|
||||||
|
|
||||||
|
:18A:1
|
||||||
|
34
|
||||||
|
:20C:Ïîðó÷åíèå XXX202304061703 îò 2023-04-06
|
||||||
|
:35A:SHS9900000,
|
||||||
|
:23:8711
|
||||||
|
:66A:RECFREE
|
||||||
|
:87D:747288887ZT0
|
||||||
|
:30:20230406
|
||||||
|
1
|
||||||
|
1
|
||||||
|
:62A:SHS1111111,
|
||||||
|
1
|
||||||
|
4
|
||||||
|
:35B:ISIN MFBEL-BV-08:Ðåñïóáëèêà Áåëàðóñü:îáëèãàöèè
|
||||||
|
:60A:SHS2,
|
||||||
|
:83D:747288887ZT0:ÏÀÎ "Ïðîìñâÿçüáàíê":òåõíè÷åñêèé ñ÷åò
|
||||||
|
:18A:4
|
||||||
|
:20C:Ïîðó÷. SPCEX_NONREF
|
||||||
|
:35A:SHS222222,
|
||||||
|
:23:8712
|
||||||
|
:66A:RECFREE
|
||||||
|
:87D:
|
||||||
|
:30:20230406
|
||||||
|
1
|
||||||
|
4
|
||||||
|
:20C:Ïîðó÷åíèå XXX202304061703 îò 2023-04-06
|
||||||
|
:35A:SHS9900000,
|
||||||
|
:23:8713
|
||||||
|
:66A:DELFREE
|
||||||
|
:87D:747200000AT0
|
||||||
|
:30:20230406
|
||||||
|
2
|
||||||
|
4
|
||||||
|
:20C:Ïîðó÷åíèå XXX202304061703 îò 2023-04-06
|
||||||
|
:35A:SHS10000,
|
||||||
|
:23:8714
|
||||||
|
:66A:DELFREE
|
||||||
|
:87D:750000000AT0
|
||||||
|
:30:20230406
|
||||||
|
3
|
||||||
|
4
|
||||||
|
:20C:Ïîðó÷åíèå XXX202304061703 îò 2023-04-06
|
||||||
|
:35A:SHS90000,
|
||||||
|
:23:8715
|
||||||
|
:66A:DELFREE
|
||||||
|
:87D:750099999BT0
|
||||||
|
:30:20230406
|
||||||
|
4
|
||||||
|
|
||||||
|
4
|
||||||
|
:62A:SHS22222,
|
||||||
|
2
|
||||||
|
4
|
||||||
|
:35B:ISIN MFBEL-BV-08:Ðåñïóáëèêà Áåëàðóñü:îáëèãàöèè
|
||||||
|
:60A:SHS3,
|
||||||
|
:83D:750000000AT0:ÎÎÎ ÏÒÖ:ðàçäåë îñíîâíîé äëÿ ðàñ÷åòîâ (ñîáñòâåííûå ÖÁ)
|
||||||
|
:18A:1
|
||||||
|
:20C:Ïîðó÷åíèå XXX202304061703 îò 2023-04-06
|
||||||
|
:35A:SHS10000,
|
||||||
|
:23:8716
|
||||||
|
:66A:RECFREE
|
||||||
|
:87D:747288887ZT0
|
||||||
|
:30:20230406
|
||||||
|
1
|
||||||
|
1
|
||||||
|
|
||||||
|
:62A:SHS33333,
|
||||||
|
|
||||||
|
3
|
||||||
|
4
|
||||||
|
:35B:ISIN MFBEL-BV-08:Ðåñïóáëèêà Áåëàðóñü:îáëèãàöèè
|
||||||
|
:60A:SHS4,
|
||||||
|
:83D:750099999BT0:ÎÎÎ ÏÒÖ:ðàçäåë îñíîâíîé äëÿ ðàñ÷åòîâ (êëèåíòñêèå ÖÁ)
|
||||||
|
:18A:2
|
||||||
|
:20C:Ïîðó÷åíèå XXX202304061703 îò 2023-04-06
|
||||||
|
:35A:SHS90000,
|
||||||
|
:23:8717
|
||||||
|
:66A:RECFREE
|
||||||
|
:87D:747288887ZT0
|
||||||
|
:30:20230406
|
||||||
|
1
|
||||||
|
2
|
||||||
|
:20C:Ïîðó÷åíèå XXX202304061703 îò 2023-04-06
|
||||||
|
:35A:SHS90000,
|
||||||
|
:23:8718
|
||||||
|
:66A:RECFREE
|
||||||
|
:87D:747288887ZT0
|
||||||
|
:30:20230406
|
||||||
|
2
|
||||||
|
2
|
||||||
|
:62A:SHS444444,
|
||||||
|
4
|
||||||
|
4
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package ru.spcex.clearing.swt.importer.logic.stages;
|
package ru.spcex.clearing.swt.importer.logic.stages;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
|
@ -8,6 +7,7 @@ import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||||
import ru.clearing.classes.statics.data.sdf.SDf10;
|
import ru.clearing.classes.statics.data.sdf.SDf10;
|
||||||
import ru.clearing.classes.statics.data.sdf.SDf13;
|
import ru.clearing.classes.statics.data.sdf.SDf13;
|
||||||
|
import ru.clearing.classes.statics.data.sdf.SDf21;
|
||||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||||
import ru.spcex.clearing.swt.importer.config.ImportSWTServiceTest;
|
import ru.spcex.clearing.swt.importer.config.ImportSWTServiceTest;
|
||||||
import ru.spcex.clearing.swt.importer.logic.data.ResultContainer;
|
import ru.spcex.clearing.swt.importer.logic.data.ResultContainer;
|
||||||
|
|
@ -47,13 +47,22 @@ class ImportToDBTest {
|
||||||
waitAvailableImdgProviderAndAddAdminWithDefaultId();
|
waitAvailableImdgProviderAndAddAdminWithDefaultId();
|
||||||
|
|
||||||
}
|
}
|
||||||
@Test
|
// @Test
|
||||||
void process() throws IOException {
|
void process() throws IOException {
|
||||||
ETable eTable = ETable.S_DF_13;
|
ETable eTable = ETable.S_DF_21;
|
||||||
File swtFile = new File("D:\\repo\\mfd\\clearing\\clearing-parent\\swt-importer\\src\\test\\java\\ru\\spcex\\clearing\\swt\\importer\\files\\RDC_KS_DF-13_bond_221111131459718.txt");
|
File swtFile = new File("D:\\repo\\mfd\\clearing\\clearing-parent\\swt-importer\\src\\test\\java\\ru\\spcex\\clearing\\swt\\importer\\files\\RDC_KS_DF-21_230717164021676.txt");
|
||||||
ResultContainer resultContainer = createNewTask(eTable, swtFile);
|
ResultContainer resultContainer = createNewTask(eTable, swtFile);
|
||||||
resultContainer.setSwtSource(Files.readAllBytes(Paths.get(swtFile.getAbsolutePath())));
|
resultContainer.setSwtSource(Files.readAllBytes(Paths.get(swtFile.getAbsolutePath())));
|
||||||
|
|
||||||
|
importToDB.process(resultContainer);
|
||||||
|
Imdg<SDf21> df21Imdg = imdgProvider.getImdg(IMDGDistributedNames.Map_SDf21, SDf21.class);
|
||||||
|
df21Imdg.getAllValues();
|
||||||
|
|
||||||
|
eTable = ETable.S_DF_13;
|
||||||
|
swtFile = new File("D:\\repo\\mfd\\clearing\\clearing-parent\\swt-importer\\src\\test\\java\\ru\\spcex\\clearing\\swt\\importer\\files\\RDC_KS_DF-13_bond_221111131459718.txt");
|
||||||
|
resultContainer = createNewTask(eTable, swtFile);
|
||||||
|
resultContainer.setSwtSource(Files.readAllBytes(Paths.get(swtFile.getAbsolutePath())));
|
||||||
|
|
||||||
importToDB.process(resultContainer);
|
importToDB.process(resultContainer);
|
||||||
Imdg<SDf13> df13Imdg = imdgProvider.getImdg(IMDGDistributedNames.Map_SDf13, SDf13.class);
|
Imdg<SDf13> df13Imdg = imdgProvider.getImdg(IMDGDistributedNames.Map_SDf13, SDf13.class);
|
||||||
df13Imdg.getAllValues();
|
df13Imdg.getAllValues();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue