http://jira.mfd.msk:8088/browse/CLS-404 (bug fix CLS-313) поправил поиск по файлам
This commit is contained in:
parent
262166d470
commit
30349030dd
1 changed files with 12 additions and 4 deletions
|
|
@ -1,5 +1,7 @@
|
|||
package ru.spcex.clearing.dbf.exporter.logic.data.enums;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.integration.sftp.session.SftpFileInfo;
|
||||
import ru.spcex.clearing.dbf.exporter.logic.data.ResultContainer;
|
||||
|
||||
|
|
@ -74,20 +76,26 @@ public enum FilenameTemplate {
|
|||
}
|
||||
|
||||
protected Integer countSameFilesInDir(String prefixOfTable, List<SftpFileInfo> files) {
|
||||
final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
int res = 0;
|
||||
String timestampNow = utilFormatter.format(LocalDateTime.now());
|
||||
for (SftpFileInfo file : files) {
|
||||
if (file.isDirectory()) continue;
|
||||
String name = file.getFilename();
|
||||
String[] splitName = name.split("_");
|
||||
if (splitName.length < 3)
|
||||
throw new IllegalArgumentException("Filename did not contains 3 or 4 separator \"_\": " + name);
|
||||
if (splitName.length < 3) {
|
||||
log.info("Filename did not contains 3 or 4+ separator \"_\": " + name);
|
||||
continue;
|
||||
}
|
||||
String prefix = splitName[0];
|
||||
String timestamp = splitName[2];
|
||||
|
||||
if (prefix.equalsIgnoreCase(prefixOfTable) && timestamp.contains(timestampNow)) {
|
||||
if (splitName.length < 4)
|
||||
throw new IllegalArgumentException("Filename did not contains 4 separator \"_\": " + name);
|
||||
if (splitName.length < 4) {
|
||||
log.warn("Filename did not contains 4+ separator \"_\": " + name);
|
||||
continue;
|
||||
}
|
||||
String counter = splitName[3];
|
||||
int positionOfDot = counter.indexOf('.');
|
||||
if (positionOfDot != -1) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue