dbf-importer SDf57Table unixtime Ext_date
This commit is contained in:
parent
ca05eb96c0
commit
ef187881b2
4 changed files with 86 additions and 1 deletions
|
|
@ -70,6 +70,27 @@
|
||||||
<groupId>ru.spcex.platform</groupId>
|
<groupId>ru.spcex.platform</groupId>
|
||||||
<artifactId>platform-enum</artifactId>
|
<artifactId>platform-enum</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- TEST -->
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>org.springframework</groupId>-->
|
||||||
|
<!-- <artifactId>spring-test</artifactId>-->
|
||||||
|
<!-- <scope>test</scope>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mockito</groupId>
|
||||||
|
<artifactId>mockito-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.assertj</groupId>
|
||||||
|
<artifactId>assertj-core</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,10 @@ public class SDf57Table extends AbstractTable<SDf57> {
|
||||||
result.setRbanknam5((String) entity[16]);
|
result.setRbanknam5((String) entity[16]);
|
||||||
result.setOp_type((String) entity[17]);
|
result.setOp_type((String) entity[17]);
|
||||||
result.setPay_date((String) entity[18]);
|
result.setPay_date((String) entity[18]);
|
||||||
result.setExt_date((String) entity[19]);
|
BigDecimal unixTime19 = (BigDecimal) entity[19];
|
||||||
|
if (unixTime19 != null) {
|
||||||
|
result.setExt_date(unixTime19.toString()); // unix time
|
||||||
|
}
|
||||||
result.setPay_val((String) entity[20]);
|
result.setPay_val((String) entity[20]);
|
||||||
result.setSum_deb((String) entity[21]);
|
result.setSum_deb((String) entity[21]);
|
||||||
result.setSclientn1((String) entity[22]);
|
result.setSclientn1((String) entity[22]);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
package ru.spcex.clearing.dbf.importer.logic.data.tables;
|
||||||
|
|
||||||
|
import com.linuxense.javadbf.DBFReader;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||||
|
import ru.spcex.clearing.dbf.importer.logic.data.enums.StageResult;
|
||||||
|
import ru.spcex.platform.imdg.iml.hazelcast.config.HazelcastClientParams;
|
||||||
|
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
||||||
|
import ru.spcex.platform.utils.log.ExceptionUtils;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
|
||||||
|
class SDf57TableTest {
|
||||||
|
|
||||||
|
// @Test
|
||||||
|
void getEntity() throws IOException {
|
||||||
|
SDf57Table tableReader = new SDf57Table();
|
||||||
|
|
||||||
|
ThreadPoolTaskExecutor taskExecutorHazelcastClientInitializer = null;
|
||||||
|
ThreadPoolTaskExecutor taskExecutorIdGeneratorAwaiter = null;
|
||||||
|
HazelcastClientParams hazelcastClientParams = Mockito.mock(HazelcastClientParams.class);
|
||||||
|
HazelcastService hcSvs = new HazelcastService(taskExecutorHazelcastClientInitializer, taskExecutorIdGeneratorAwaiter,hazelcastClientParams );
|
||||||
|
tableReader.setHazelcastService(hcSvs);
|
||||||
|
|
||||||
|
//tableReader.bootMap();
|
||||||
|
|
||||||
|
// ImportToDB
|
||||||
|
|
||||||
|
byte[] fileData = Files.readAllBytes(Path.of("src/test/resources/sdf/DF-57_S_PRC2306141135_1.dbf"));
|
||||||
|
|
||||||
|
tableReader.setFilename("DF-57_S_PRC2306141135_1.dbf");
|
||||||
|
tableReader.setFileId(123L);
|
||||||
|
tableReader.bootMap(); // IMDGDistributedNames.Map_SDf57
|
||||||
|
reader(fileData, tableReader);
|
||||||
|
}
|
||||||
|
|
||||||
|
void reader(byte[] source, AbstractTable table) throws IOException {
|
||||||
|
// byte[] source = resultContainer.getDbfSource();
|
||||||
|
Charset sourceCharset = Charset.forName("cp866"); //settings.getCommon().getEncodingSource());
|
||||||
|
|
||||||
|
try (InputStream is = new ByteArrayInputStream(source);
|
||||||
|
DBFReader dbfReader = new DBFReader(is, sourceCharset)) {
|
||||||
|
for (int i = 0; i < dbfReader.getRecordCount(); i++) {
|
||||||
|
Object[] entity = dbfReader.nextRecord();
|
||||||
|
if (entity == null) {
|
||||||
|
// log.warn("record index {} null", i);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
table.injectEntity(table.getEntity(entity));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
Loading…
Add table
Reference in a new issue