file name, generation time and id added to object tags
This commit is contained in:
parent
00c87829a3
commit
300e4c96c6
11 changed files with 75 additions and 17 deletions
|
|
@ -28,8 +28,8 @@ import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
|||
import ru.spcex.clearing.xml.importer.config.settings.ImportXMLServiceSettings;
|
||||
import ru.spcex.clearing.xml.importer.logic.data.enums.ETable;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.adapter.ImdgHazelcast;
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties
|
||||
|
|
@ -62,14 +62,14 @@ public class XMLImporterConfig {
|
|||
}
|
||||
|
||||
@Bean("mapOfTable")
|
||||
public Map<ETable, Imdg<? extends SpcexObjectBase>> getMapOfTables() {
|
||||
Map<ETable, Imdg<? extends SpcexObjectBase>> map = new HashMap<>();
|
||||
map.put(ETable.DF_01, hazelcastService.getImdg(IMDGDistributedNames.Map_SDf01, SDf01.class));
|
||||
map.put(ETable.DF_04, hazelcastService.getImdg(IMDGDistributedNames.Map_SDf04, SDf04.class));
|
||||
map.put(ETable.DF_06, hazelcastService.getImdg(IMDGDistributedNames.Map_SDf06, SDf06.class));
|
||||
map.put(ETable.DF_52, hazelcastService.getImdg(IMDGDistributedNames.Map_SDf52, SDf52.class));
|
||||
map.put(ETable.DF_55, hazelcastService.getImdg(IMDGDistributedNames.Map_SDf55, SDf55.class));
|
||||
map.put(ETable.DF_57, hazelcastService.getImdg(IMDGDistributedNames.Map_SDf57, SDf57.class));
|
||||
public Map<ETable, ImdgHazelcast<? extends SpcexObjectBase>> getMapOfTables() {
|
||||
Map<ETable, ImdgHazelcast<? extends SpcexObjectBase>> map = new HashMap<>();
|
||||
map.put(ETable.DF_01, (ImdgHazelcast<? extends SpcexObjectBase>) hazelcastService.getImdg(IMDGDistributedNames.Map_SDf01, SDf01.class));
|
||||
map.put(ETable.DF_04, (ImdgHazelcast<? extends SpcexObjectBase>) hazelcastService.getImdg(IMDGDistributedNames.Map_SDf04, SDf04.class));
|
||||
map.put(ETable.DF_06, (ImdgHazelcast<? extends SpcexObjectBase>) hazelcastService.getImdg(IMDGDistributedNames.Map_SDf06, SDf06.class));
|
||||
map.put(ETable.DF_52, (ImdgHazelcast<? extends SpcexObjectBase>) hazelcastService.getImdg(IMDGDistributedNames.Map_SDf52, SDf52.class));
|
||||
map.put(ETable.DF_55, (ImdgHazelcast<? extends SpcexObjectBase>) hazelcastService.getImdg(IMDGDistributedNames.Map_SDf55, SDf55.class));
|
||||
map.put(ETable.DF_57, (ImdgHazelcast<? extends SpcexObjectBase>) hazelcastService.getImdg(IMDGDistributedNames.Map_SDf57, SDf57.class));
|
||||
return map;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package ru.spcex.clearing.xml.importer.logic.data.tags.objects;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Objects;
|
||||
|
|
@ -69,6 +70,9 @@ public class DF01ObjectTag extends ObjectTag<SDf01> {
|
|||
result.setSumengage(this.getSumengage());
|
||||
result.setSumunblock(this.getSumunblock());
|
||||
result.setFile_type(this.getFileType());
|
||||
result.setFileName(this.getFileName());
|
||||
result.setGenerationTime(Instant.now());
|
||||
result.setGenerationId(this.getGenerationId());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package ru.spcex.clearing.xml.importer.logic.data.tags.objects;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Objects;
|
||||
|
|
@ -89,6 +90,9 @@ public class DF04ObjectTag extends ObjectTag<SDf04> {
|
|||
result.setSum_deb(this.getSumDeb());
|
||||
result.setSpecif_1(this.getSpecif1());
|
||||
result.setImp_result(this.getImpResult());
|
||||
result.setFile_name(this.getFileName());
|
||||
result.setGenerationTime(Instant.now());
|
||||
result.setGenerationId(this.getGenerationId());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package ru.spcex.clearing.xml.importer.logic.data.tags.objects;
|
|||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Objects;
|
||||
|
|
@ -74,6 +75,9 @@ public class DF06ObjectTag extends ObjectTag<SDf06> {
|
|||
result.setDoc_Num(this.getDocNum());
|
||||
result.setDoc_Date(this.getDocDate().format(formatter));
|
||||
result.setPay_val(this.getPayVal());
|
||||
result.setFileName(this.getFileName());
|
||||
result.setGenerationTime(Instant.now());
|
||||
result.setGenerationId(this.getGenerationId());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package ru.spcex.clearing.xml.importer.logic.data.tags.objects;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Objects;
|
||||
|
|
@ -45,6 +46,9 @@ public class DF52ObjectTag extends ObjectTag<SDf52> {
|
|||
result.setDate(this.getDate().format(formatter));
|
||||
result.setAcc_type(this.getAccType());
|
||||
result.setStatus(this.getStatus());
|
||||
result.setFileName(this.getFileName());
|
||||
result.setGenerationTime(Instant.now());
|
||||
result.setGenerationId(this.getGenerationId());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package ru.spcex.clearing.xml.importer.logic.data.tags.objects;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Objects;
|
||||
|
|
@ -175,6 +176,9 @@ public class DF55ObjectTag extends ObjectTag<SDf55> {
|
|||
result.setValue_date(this.getValueDate().format(formatter));
|
||||
result.setSwift_ben(this.getSwiftBen());
|
||||
result.setSwift_int(this.getSwiftInt());
|
||||
result.setFileName(this.getFileName());
|
||||
result.setGenerationTime(Instant.now());
|
||||
result.setGenerationId(this.getGenerationId());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package ru.spcex.clearing.xml.importer.logic.data.tags.objects;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Objects;
|
||||
|
|
@ -166,6 +167,9 @@ public class DF57ObjectTag extends ObjectTag<SDf57> {
|
|||
result.setKt_in(this.getKtIn());
|
||||
result.setDt_out(this.getDtOut());
|
||||
result.setKt_out(this.getKtOut());
|
||||
result.setFileName(this.getFileName());
|
||||
result.setGenerationTime(Instant.now());
|
||||
result.setGenerationId(this.getGenerationId());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
package ru.spcex.clearing.xml.importer.logic.data.tags.objects;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import ru.spcex.clearing.xml.importer.logic.data.enums.ETable;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.adapter.ImdgHazelcast;
|
||||
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION)
|
||||
@JsonSubTypes({
|
||||
|
|
@ -18,6 +19,11 @@ import ru.spcex.platform.imdg.api.Imdg;
|
|||
public abstract class ObjectTag<T1 extends SpcexObjectBase> {
|
||||
private final ETable prefix;
|
||||
|
||||
@JsonIgnore
|
||||
protected String fileName;
|
||||
@JsonIgnore
|
||||
protected Long generationId;
|
||||
|
||||
public ObjectTag(ETable prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
|
@ -28,7 +34,23 @@ public abstract class ObjectTag<T1 extends SpcexObjectBase> {
|
|||
return prefix;
|
||||
}
|
||||
|
||||
public void insertEntity(Imdg<T1> map) {
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public Long getGenerationId() {
|
||||
return generationId;
|
||||
}
|
||||
|
||||
public void setGenerationId(Long generationId) {
|
||||
this.generationId = generationId;
|
||||
}
|
||||
|
||||
public void insertEntity(ImdgHazelcast<T1> map) {
|
||||
T1 obj = getSDfEntity();
|
||||
if (checkOnExisting(obj)) {
|
||||
map.insert(obj);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import ru.spcex.clearing.xml.importer.logic.data.enums.StageResult;
|
|||
import ru.spcex.clearing.xml.importer.logic.data.tags.DocumentTag;
|
||||
import ru.spcex.clearing.xml.importer.logic.data.tags.objects.ObjectTag;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.adapter.ImdgHazelcast;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
||||
|
||||
@Component
|
||||
|
|
@ -21,12 +21,12 @@ public class ImportToDB {
|
|||
private final XmlMapper xmlMapper;
|
||||
private final HazelcastService hazelcastService;
|
||||
private final XmlImportKafkaMessenger kafkaMessenger;
|
||||
private final Map<ETable, Imdg<?>> mapOfTable;
|
||||
private final Map<ETable, ImdgHazelcast<?>> mapOfTable;
|
||||
|
||||
public ImportToDB(@Qualifier("xmlMapper") XmlMapper xmlMapper,
|
||||
HazelcastService hazelcastService,
|
||||
XmlImportKafkaMessenger kafkaMessenger,
|
||||
@Qualifier("mapOfTable") Map<ETable, Imdg<?>> mapOfTable) {
|
||||
@Qualifier("mapOfTable") Map<ETable, ImdgHazelcast<?>> mapOfTable) {
|
||||
this.xmlMapper = xmlMapper;
|
||||
this.hazelcastService = hazelcastService;
|
||||
this.kafkaMessenger = kafkaMessenger;
|
||||
|
|
@ -41,7 +41,9 @@ public class ImportToDB {
|
|||
String fileName = resultContainer.getXmlFile().getName();
|
||||
Long fileId = hazelcastService.getImdgIdGenerator().nextId();
|
||||
for (ObjectTag o : documentTag.getObjects()) {
|
||||
Imdg<? extends SpcexObjectBase> imdgMap = mapOfTable.get(o.getPrefix());
|
||||
ImdgHazelcast<? extends SpcexObjectBase> imdgMap = mapOfTable.get(o.getPrefix());
|
||||
o.setFileName(fileName);
|
||||
o.setGenerationId(fileId);
|
||||
o.insertEntity(imdgMap);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -140,6 +140,8 @@ class ImportToDBTest {
|
|||
Assertions.assertThat(actualSDf01.getSumengage()).isEqualTo(expectedObjectTag.getSumengage());
|
||||
Assertions.assertThat(actualSDf01.getSumunblock()).isEqualTo(expectedObjectTag.getSumunblock());
|
||||
Assertions.assertThat(actualSDf01.getFile_type()).isEqualTo(expectedObjectTag.getFileType());
|
||||
Assertions.assertThat(actualSDf01.getFileName()).isEqualTo(expectedObjectTag.getFileName());
|
||||
Assertions.assertThat(actualSDf01.getGenerationId()).isEqualTo(expectedObjectTag.getGenerationId());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -198,6 +200,8 @@ class ImportToDBTest {
|
|||
Assertions.assertThat(actualSDf04.getSum_deb()).isEqualTo(expectedObjectTag.getSumDeb());
|
||||
Assertions.assertThat(actualSDf04.getSpecif_1()).isEqualTo(expectedObjectTag.getSpecif1());
|
||||
Assertions.assertThat(actualSDf04.getImp_result()).isEqualTo(expectedObjectTag.getImpResult());
|
||||
Assertions.assertThat(actualSDf04.getFile_name()).isEqualTo(expectedObjectTag.getFileName());
|
||||
Assertions.assertThat(actualSDf04.getGenerationId()).isEqualTo(expectedObjectTag.getGenerationId());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -256,6 +260,8 @@ class ImportToDBTest {
|
|||
Assertions.assertThat(actualSDf06.getDoc_Num()).isEqualTo(expectedObjectTag.getDocNum());
|
||||
Assertions.assertThat(actualSDf06.getDoc_Date()).isEqualTo(expectedObjectTag.getDocDate().format(formatter));
|
||||
Assertions.assertThat(actualSDf06.getPay_val()).isEqualTo(expectedObjectTag.getPayVal());
|
||||
Assertions.assertThat(actualSDf06.getFileName()).isEqualTo(expectedObjectTag.getFileName());
|
||||
Assertions.assertThat(actualSDf06.getGenerationId()).isEqualTo(expectedObjectTag.getGenerationId());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -300,6 +306,8 @@ class ImportToDBTest {
|
|||
Assertions.assertThat(actualSDf52.getDate()).isEqualTo(expectedObjectTag.getDate().format(formatter));
|
||||
Assertions.assertThat(actualSDf52.getAcc_type()).isEqualTo(expectedObjectTag.getAccType());
|
||||
Assertions.assertThat(actualSDf52.getStatus()).isEqualTo(expectedObjectTag.getStatus());
|
||||
Assertions.assertThat(actualSDf52.getFileName()).isEqualTo(expectedObjectTag.getFileName());
|
||||
Assertions.assertThat(actualSDf52.getGenerationId()).isEqualTo(expectedObjectTag.getGenerationId());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -394,6 +402,8 @@ class ImportToDBTest {
|
|||
Assertions.assertThat(actualSDf55.getValue_date()).isEqualTo(expectedObjectTag.getValueDate().format(formatter));
|
||||
Assertions.assertThat(actualSDf55.getSwift_ben()).isEqualTo(expectedObjectTag.getSwiftBen());
|
||||
Assertions.assertThat(actualSDf55.getSwift_int()).isEqualTo(expectedObjectTag.getSwiftInt());
|
||||
Assertions.assertThat(actualSDf55.getFileName()).isEqualTo(expectedObjectTag.getFileName());
|
||||
Assertions.assertThat(actualSDf55.getGenerationId()).isEqualTo(expectedObjectTag.getGenerationId());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -484,5 +494,7 @@ class ImportToDBTest {
|
|||
Assertions.assertThat(actualSDf57.getKt_in()).isEqualTo(expectedObjectTag.getKtIn());
|
||||
Assertions.assertThat(actualSDf57.getDt_out()).isEqualTo(expectedObjectTag.getDtOut());
|
||||
Assertions.assertThat(actualSDf57.getKt_out()).isEqualTo(expectedObjectTag.getKtOut());
|
||||
Assertions.assertThat(actualSDf57.getFileName()).isEqualTo(expectedObjectTag.getFileName());
|
||||
Assertions.assertThat(actualSDf57.getGenerationId()).isEqualTo(expectedObjectTag.getGenerationId());
|
||||
}
|
||||
}
|
||||
|
|
@ -5,7 +5,6 @@ import java.math.BigDecimal;
|
|||
import java.math.BigInteger;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
@ -22,7 +21,6 @@ import ru.spcex.clearing.xml.importer.logic.data.ResultContainer;
|
|||
import ru.spcex.clearing.xml.importer.logic.data.enums.ETable;
|
||||
import ru.spcex.clearing.xml.importer.logic.data.enums.StageResult;
|
||||
import ru.spcex.clearing.xml.importer.logic.data.tags.DocumentTag;
|
||||
import ru.spcex.clearing.xml.importer.logic.data.tags.ParentDocTag;
|
||||
import ru.spcex.clearing.xml.importer.logic.data.tags.objects.DF01ObjectTag;
|
||||
import ru.spcex.clearing.xml.importer.logic.data.tags.objects.DF04ObjectTag;
|
||||
import ru.spcex.clearing.xml.importer.logic.data.tags.objects.DF06ObjectTag;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue