This commit is contained in:
parent
b9e0ba49e6
commit
f861eb731e
3 changed files with 26 additions and 4 deletions
|
|
@ -18,6 +18,7 @@ public class ResultContainer {
|
|||
private String memberCode;
|
||||
private DocumentTag documentTag;
|
||||
private String section;
|
||||
private boolean exportOnly = false;
|
||||
|
||||
public ResultContainer(Table tableForExport, String section) {
|
||||
this.tableForExport = tableForExport;
|
||||
|
|
@ -104,4 +105,13 @@ public class ResultContainer {
|
|||
public void setSection(String section) {
|
||||
this.section = section;
|
||||
}
|
||||
|
||||
|
||||
public boolean isExportOnly() {
|
||||
return exportOnly;
|
||||
}
|
||||
|
||||
public void setExportOnly(boolean exportOnly) {
|
||||
this.exportOnly = exportOnly;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ public class ExportFromHazelcast {
|
|||
resultContainer.getUuid(), table, table.getHazelcastMapName(), xmlFile), e);
|
||||
return StageResult.ERROR;
|
||||
}
|
||||
gateway.sendToSftp(xmlFile, path);
|
||||
if (!resultContainer.isExportOnly()) gateway.sendToSftp(xmlFile, path);
|
||||
return StageResult.OK;
|
||||
} else {
|
||||
log.debug("uuid {}. Selected {} records from map {}, generationId {}", resultContainer.getUuid(),
|
||||
|
|
@ -183,7 +183,7 @@ public class ExportFromHazelcast {
|
|||
}
|
||||
|
||||
log.debug("uuid {}, send to SFTP path \"{}\"", resultContainer.getUuid(), path);
|
||||
gateway.sendToSftp(xmlFile, path);
|
||||
if (!resultContainer.isExportOnly()) gateway.sendToSftp(xmlFile, path);
|
||||
if (Table.S_DF02.equals(resultContainer.getTableForExport())) {
|
||||
sendPairSdfRequest(resultContainer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import ru.spcex.clearing.xml.exporter.logic.data.ResultContainer;
|
|||
import ru.spcex.clearing.xml.exporter.logic.data.enums.FilenameTemplate;
|
||||
import ru.spcex.clearing.xml.exporter.logic.data.enums.StageResult;
|
||||
import ru.spcex.clearing.xml.exporter.logic.data.enums.Table;
|
||||
import ru.spcex.platform.utils.log.ExceptionUtils;
|
||||
|
||||
@Component
|
||||
public class PrepareXMLFile implements InitializingBean {
|
||||
|
|
@ -42,17 +43,27 @@ public class PrepareXMLFile implements InitializingBean {
|
|||
log.error("No SFTP scanning directories, need will be adding settings like 'export-xml-service.store.out-pay-val-dir.RUB=/RUB' and restart app");
|
||||
return StageResult.ERROR;
|
||||
}
|
||||
boolean sftpConnectionError = false;
|
||||
List<SftpFileInfo> files = new ArrayList<>();
|
||||
log.trace("Get files from SFTP paths: {}", settings.getStore().getOutPayValDir().values());
|
||||
for (String path : settings.getStore().getOutPayValDir().values()) {
|
||||
if (!path.endsWith("/")) path += "/";
|
||||
files.addAll(gateway.listFiles(path));
|
||||
try {
|
||||
files.addAll(gateway.listFiles(path));
|
||||
} catch (Exception e) {
|
||||
log.error("SFTP connection error: {}", ExceptionUtils.getStackTrace(e));
|
||||
sftpConnectionError = true;
|
||||
files = new ArrayList<>();
|
||||
break;
|
||||
}
|
||||
}
|
||||
log.info("There are {} files on the sFTP server in the search directories.", files.size());
|
||||
Table table = resultContainer.getTableForExport();
|
||||
LocalDateTime currentDateTime = LocalDateTime.now();
|
||||
resultContainer.setRegistrationDateTime(currentDateTime);
|
||||
File xmlFile = new File(nameTemplates.get(table).getFileName(resultContainer, files));
|
||||
String fileName = nameTemplates.get(table).getFileName(resultContainer, files);
|
||||
if (sftpConnectionError) fileName = "error_%s_%s".formatted(LocalDateTime.now(), fileName);
|
||||
File xmlFile = new File(fileName);
|
||||
log.info("XML FILE = {}", xmlFile.toPath());
|
||||
try {
|
||||
Path xmlFilePath = xmlFile.toPath();
|
||||
|
|
@ -65,6 +76,7 @@ public class PrepareXMLFile implements InitializingBean {
|
|||
resultContainer.setFileForExport(xmlFile);
|
||||
log.info("uuid {}. Rows from {} with generationId {} will be export to temp file \"{}\"", resultContainer.getUuid(),
|
||||
resultContainer.getTableForExport().getFilePrefix(), resultContainer.getGroupId(), xmlFile);
|
||||
resultContainer.setExportOnly(sftpConnectionError);
|
||||
return StageResult.OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue