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
|
||||
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.password=dev-pass
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
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.password=dev-pass
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
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.password=dev-pass
|
||||
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.RequestMethod;
|
||||
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 java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller("/")
|
||||
public class DefaultController implements InitializingBean {
|
||||
public class ExporterController implements InitializingBean {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final DBFExportService dbfExportService;
|
||||
|
||||
public DefaultController(@Qualifier("dbfExportService") DBFExportService dbfExportService) {
|
||||
public ExporterController(@Qualifier("dbfExportService") 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)
|
||||
@ResponseBody
|
||||
public String exportTables() {
|
||||
log.info("Call export method for exporter controller");
|
||||
Map<Table, IFilter> tablesForExport = new EnumMap<>(Table.class);
|
||||
for (Table table : Table.values()) tablesForExport.put(table, null);
|
||||
dbfExportService.run(tablesForExport);
|
||||
return "export done, see log";
|
||||
dbfExportService.run();
|
||||
return "export done";
|
||||
}
|
||||
|
||||
@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 {
|
||||
private UUID uuid;
|
||||
private Table tableForExport;
|
||||
private IFilter filter;
|
||||
private File fileForExport;
|
||||
|
||||
protected ResultContainer() {}
|
||||
|
||||
public static ResultContainer createNewTask(Table tableForExport, IFilter filter) {
|
||||
public static ResultContainer createNewTask(Table tableForExport) {
|
||||
ResultContainer container = new ResultContainer();
|
||||
container.tableForExport = tableForExport;
|
||||
container.filter = filter;
|
||||
container.uuid = UUID.randomUUID();
|
||||
return container;
|
||||
}
|
||||
|
|
@ -32,14 +30,6 @@ public class ResultContainer {
|
|||
this.tableForExport = tableForExport;
|
||||
}
|
||||
|
||||
public IFilter getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
public void setFilter(IFilter filter) {
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
public File getFileForExport() {
|
||||
return fileForExport;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
|||
import org.springframework.stereotype.Component;
|
||||
import ru.clearing.classes.statics.data.sdf.*;
|
||||
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.enums.StageResult;
|
||||
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());
|
||||
|
||||
Table table = resultContainer.getTableForExport();
|
||||
IFilter filter = resultContainer.getFilter();
|
||||
|
||||
Imdg<? extends SpcexObjectBase> map = imdgProvider.getImdg(table.getHazelcastMapName(), table.getEntityClass());
|
||||
File dbfFile = resultContainer.getFileForExport();
|
||||
boolean writeOk = false;
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ import java.util.Objects;
|
|||
public class PrepareDBFFile extends Stage implements InitializingBean {
|
||||
private static final String SECTION = "U";
|
||||
private static final String CODE_OF_MEMBER = null;
|
||||
private static DateTimeFormatter tsFormatter = DateTimeFormatter.ofPattern("yyMMddHHmm");
|
||||
private static DateTimeFormatter utilFormatter = DateTimeFormatter.ofPattern("yyMMdd");
|
||||
private static final DateTimeFormatter tsFormatter = DateTimeFormatter.ofPattern("yyMMddHHmm");
|
||||
private static final DateTimeFormatter utilFormatter = DateTimeFormatter.ofPattern("yyMMdd");
|
||||
private final AProperties properties;
|
||||
private String outDir;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,13 +3,10 @@ package ru.spcex.clearing.dbf.exporter.services;
|
|||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
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.enums.Table;
|
||||
import ru.spcex.clearing.dbf.exporter.logic.stages.Processor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service("dbfExportService")
|
||||
public class DBFExportService {
|
||||
private final ThreadPoolTaskExecutor executor;
|
||||
|
|
@ -21,11 +18,9 @@ public class DBFExportService {
|
|||
this.processor = processor;
|
||||
}
|
||||
|
||||
public void run(Map<Table, IFilter> tablesForExport) {
|
||||
for (Map.Entry<Table, IFilter> tableForExport : tablesForExport.entrySet()) {
|
||||
Table table = tableForExport.getKey();
|
||||
IFilter filter = tableForExport.getValue();
|
||||
executor.submit(() -> processor.process(ResultContainer.createNewTask(table, filter)));
|
||||
public void run() {
|
||||
for (Table tableForExport : Table.values()) {
|
||||
executor.submit(() -> processor.process(ResultContainer.createNewTask(tableForExport)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ server.port=8080
|
|||
server.servlet.context-path=/exporter
|
||||
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.password=dev-pass
|
||||
|
||||
|
|
|
|||
|
|
@ -21,13 +21,6 @@ public class ImporterController implements InitializingBean {
|
|||
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)
|
||||
@ResponseBody
|
||||
public String checkFolder() {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
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.password=dev-pass
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
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.password=dev-pass
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue