some exporter refactoring
This commit is contained in:
parent
2d446f5239
commit
ee92e11986
13 changed files with 16 additions and 63 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
spring.main.web-application-type=none
|
spring.main.web-application-type=none
|
||||||
account-service.hazelcast.cluster-members=127.0.0.1
|
account-service.hazelcast.cluster-members=127.0.0.1:5071
|
||||||
account-service.hazelcast.login=dev
|
account-service.hazelcast.login=dev
|
||||||
account-service.hazelcast.password=dev-pass
|
account-service.hazelcast.password=dev-pass
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
spring.main.web-application-type=none
|
spring.main.web-application-type=none
|
||||||
balance-service.hazelcast.cluster-members=127.0.0.1
|
balance-service.hazelcast.cluster-members=127.0.0.1:5071
|
||||||
balance-service.hazelcast.login=dev
|
balance-service.hazelcast.login=dev
|
||||||
balance-service.hazelcast.password=dev-pass
|
balance-service.hazelcast.password=dev-pass
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
spring.main.web-application-type=none
|
spring.main.web-application-type=none
|
||||||
company-service.hazelcast.cluster-members=127.0.0.1
|
company-service.hazelcast.cluster-members=127.0.0.1:5071
|
||||||
company-service.hazelcast.login=dev
|
company-service.hazelcast.login=dev
|
||||||
company-service.hazelcast.password=dev-pass
|
company-service.hazelcast.password=dev-pass
|
||||||
company-service.kafka.bootstrap-servers=localhost:9092
|
company-service.kafka.bootstrap-servers=localhost:9092
|
||||||
|
|
|
||||||
|
|
@ -10,37 +10,23 @@ import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import ru.spcex.clearing.dbf.exporter.logic.data.IFilter;
|
|
||||||
import ru.spcex.clearing.dbf.exporter.logic.data.enums.Table;
|
|
||||||
import ru.spcex.clearing.dbf.exporter.services.DBFExportService;
|
import ru.spcex.clearing.dbf.exporter.services.DBFExportService;
|
||||||
|
|
||||||
import java.util.EnumMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Controller("/")
|
@Controller("/")
|
||||||
public class DefaultController implements InitializingBean {
|
public class ExporterController implements InitializingBean {
|
||||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
private final DBFExportService dbfExportService;
|
private final DBFExportService dbfExportService;
|
||||||
|
|
||||||
public DefaultController(@Qualifier("dbfExportService") DBFExportService dbfExportService) {
|
public ExporterController(@Qualifier("dbfExportService") DBFExportService dbfExportService) {
|
||||||
this.dbfExportService = dbfExportService;
|
this.dbfExportService = dbfExportService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, path = "/test", produces = MediaType.TEXT_PLAIN_VALUE)
|
|
||||||
@ResponseBody
|
|
||||||
public String processGet() {
|
|
||||||
log.info("Call test method for exporter controller");
|
|
||||||
return "exporter controller test method";
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, path = "/export", produces = MediaType.TEXT_PLAIN_VALUE)
|
@RequestMapping(method = RequestMethod.GET, path = "/export", produces = MediaType.TEXT_PLAIN_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String exportTables() {
|
public String exportTables() {
|
||||||
log.info("Call export method for exporter controller");
|
log.info("Call export method for exporter controller");
|
||||||
Map<Table, IFilter> tablesForExport = new EnumMap<>(Table.class);
|
dbfExportService.run();
|
||||||
for (Table table : Table.values()) tablesForExport.put(table, null);
|
return "export done";
|
||||||
dbfExportService.run(tablesForExport);
|
|
||||||
return "export done, see log";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
package ru.spcex.clearing.dbf.exporter.logic.data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Фильтр записей для экспорта
|
|
||||||
*/
|
|
||||||
public interface IFilter {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -11,15 +11,13 @@ import java.util.UUID;
|
||||||
public class ResultContainer {
|
public class ResultContainer {
|
||||||
private UUID uuid;
|
private UUID uuid;
|
||||||
private Table tableForExport;
|
private Table tableForExport;
|
||||||
private IFilter filter;
|
|
||||||
private File fileForExport;
|
private File fileForExport;
|
||||||
|
|
||||||
protected ResultContainer() {}
|
protected ResultContainer() {}
|
||||||
|
|
||||||
public static ResultContainer createNewTask(Table tableForExport, IFilter filter) {
|
public static ResultContainer createNewTask(Table tableForExport) {
|
||||||
ResultContainer container = new ResultContainer();
|
ResultContainer container = new ResultContainer();
|
||||||
container.tableForExport = tableForExport;
|
container.tableForExport = tableForExport;
|
||||||
container.filter = filter;
|
|
||||||
container.uuid = UUID.randomUUID();
|
container.uuid = UUID.randomUUID();
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
@ -32,14 +30,6 @@ public class ResultContainer {
|
||||||
this.tableForExport = tableForExport;
|
this.tableForExport = tableForExport;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IFilter getFilter() {
|
|
||||||
return filter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFilter(IFilter filter) {
|
|
||||||
this.filter = filter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public File getFileForExport() {
|
public File getFileForExport() {
|
||||||
return fileForExport;
|
return fileForExport;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import ru.clearing.classes.statics.data.sdf.*;
|
import ru.clearing.classes.statics.data.sdf.*;
|
||||||
import ru.spcex.clearing.dbf.exporter.exceptions.ConfigException;
|
import ru.spcex.clearing.dbf.exporter.exceptions.ConfigException;
|
||||||
import ru.spcex.clearing.dbf.exporter.logic.data.IFilter;
|
|
||||||
import ru.spcex.clearing.dbf.exporter.logic.data.ResultContainer;
|
import ru.spcex.clearing.dbf.exporter.logic.data.ResultContainer;
|
||||||
import ru.spcex.clearing.dbf.exporter.logic.data.enums.StageResult;
|
import ru.spcex.clearing.dbf.exporter.logic.data.enums.StageResult;
|
||||||
import ru.spcex.clearing.dbf.exporter.logic.data.enums.Table;
|
import ru.spcex.clearing.dbf.exporter.logic.data.enums.Table;
|
||||||
|
|
@ -63,8 +62,6 @@ public class ExportFromHazelcast extends Stage implements InitializingBean {
|
||||||
Objects.requireNonNull(resultContainer.getFileForExport());
|
Objects.requireNonNull(resultContainer.getFileForExport());
|
||||||
|
|
||||||
Table table = resultContainer.getTableForExport();
|
Table table = resultContainer.getTableForExport();
|
||||||
IFilter filter = resultContainer.getFilter();
|
|
||||||
|
|
||||||
Imdg<? extends SpcexObjectBase> map = imdgProvider.getImdg(table.getHazelcastMapName(), table.getEntityClass());
|
Imdg<? extends SpcexObjectBase> map = imdgProvider.getImdg(table.getHazelcastMapName(), table.getEntityClass());
|
||||||
File dbfFile = resultContainer.getFileForExport();
|
File dbfFile = resultContainer.getFileForExport();
|
||||||
boolean writeOk = false;
|
boolean writeOk = false;
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@ import java.util.Objects;
|
||||||
public class PrepareDBFFile extends Stage implements InitializingBean {
|
public class PrepareDBFFile extends Stage implements InitializingBean {
|
||||||
private static final String SECTION = "U";
|
private static final String SECTION = "U";
|
||||||
private static final String CODE_OF_MEMBER = null;
|
private static final String CODE_OF_MEMBER = null;
|
||||||
private static DateTimeFormatter tsFormatter = DateTimeFormatter.ofPattern("yyMMddHHmm");
|
private static final DateTimeFormatter tsFormatter = DateTimeFormatter.ofPattern("yyMMddHHmm");
|
||||||
private static DateTimeFormatter utilFormatter = DateTimeFormatter.ofPattern("yyMMdd");
|
private static final DateTimeFormatter utilFormatter = DateTimeFormatter.ofPattern("yyMMdd");
|
||||||
private final AProperties properties;
|
private final AProperties properties;
|
||||||
private String outDir;
|
private String outDir;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,10 @@ package ru.spcex.clearing.dbf.exporter.services;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import ru.spcex.clearing.dbf.exporter.logic.data.IFilter;
|
|
||||||
import ru.spcex.clearing.dbf.exporter.logic.data.ResultContainer;
|
import ru.spcex.clearing.dbf.exporter.logic.data.ResultContainer;
|
||||||
import ru.spcex.clearing.dbf.exporter.logic.data.enums.Table;
|
import ru.spcex.clearing.dbf.exporter.logic.data.enums.Table;
|
||||||
import ru.spcex.clearing.dbf.exporter.logic.stages.Processor;
|
import ru.spcex.clearing.dbf.exporter.logic.stages.Processor;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Service("dbfExportService")
|
@Service("dbfExportService")
|
||||||
public class DBFExportService {
|
public class DBFExportService {
|
||||||
private final ThreadPoolTaskExecutor executor;
|
private final ThreadPoolTaskExecutor executor;
|
||||||
|
|
@ -21,11 +18,9 @@ public class DBFExportService {
|
||||||
this.processor = processor;
|
this.processor = processor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(Map<Table, IFilter> tablesForExport) {
|
public void run() {
|
||||||
for (Map.Entry<Table, IFilter> tableForExport : tablesForExport.entrySet()) {
|
for (Table tableForExport : Table.values()) {
|
||||||
Table table = tableForExport.getKey();
|
executor.submit(() -> processor.process(ResultContainer.createNewTask(tableForExport)));
|
||||||
IFilter filter = tableForExport.getValue();
|
|
||||||
executor.submit(() -> processor.process(ResultContainer.createNewTask(table, filter)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ server.port=8080
|
||||||
server.servlet.context-path=/exporter
|
server.servlet.context-path=/exporter
|
||||||
spring.main.web-application-type=servlet
|
spring.main.web-application-type=servlet
|
||||||
|
|
||||||
hazelcast.cluster-members=127.0.0.1:5701
|
hazelcast.cluster-members=127.0.0.1:5071
|
||||||
hazelcast.login=dev
|
hazelcast.login=dev
|
||||||
hazelcast.password=dev-pass
|
hazelcast.password=dev-pass
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,6 @@ public class ImporterController implements InitializingBean {
|
||||||
this.importerService = importerService;
|
this.importerService = importerService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, path = "/test", produces = MediaType.TEXT_PLAIN_VALUE)
|
|
||||||
@ResponseBody
|
|
||||||
public String processGet() {
|
|
||||||
log.info("Call test method for importer controller");
|
|
||||||
return "importer controller test method";
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, path = "/import", produces = MediaType.TEXT_PLAIN_VALUE)
|
@RequestMapping(method = RequestMethod.GET, path = "/import", produces = MediaType.TEXT_PLAIN_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String checkFolder() {
|
public String checkFolder() {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
spring.main.web-application-type=none
|
spring.main.web-application-type=none
|
||||||
|
|
||||||
securities-service.hazelcast.cluster-members=127.0.0.1
|
securities-service.hazelcast.cluster-members=127.0.0.1:5071
|
||||||
securities-service.hazelcast.login=dev
|
securities-service.hazelcast.login=dev
|
||||||
securities-service.hazelcast.password=dev-pass
|
securities-service.hazelcast.password=dev-pass
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
spring.main.web-application-type=none
|
spring.main.web-application-type=none
|
||||||
|
|
||||||
utility-service.hazelcast.cluster-members=127.0.0.1
|
utility-service.hazelcast.cluster-members=127.0.0.1:5071
|
||||||
utility-service.hazelcast.login=dev
|
utility-service.hazelcast.login=dev
|
||||||
utility-service.hazelcast.password=dev-pass
|
utility-service.hazelcast.password=dev-pass
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue