|
@@ -109,7 +109,11 @@ public class SftpFileParsing {
|
|
* @param channelElectricFields 某通道绑定的场站
|
|
* @param channelElectricFields 某通道绑定的场站
|
|
* @param sftp sftp
|
|
* @param sftp sftp
|
|
*/
|
|
*/
|
|
- private void parsingFile(List<ParsingType> parsingTypes, List<ElectricField> channelElectricFields, Sftp sftp) {
|
|
|
|
|
|
+ private void parsingFile(
|
|
|
|
+ List<ParsingType> parsingTypes,
|
|
|
|
+ List<ElectricField> channelElectricFields,
|
|
|
|
+ Sftp sftp
|
|
|
|
+ ) {
|
|
List<ParsingLog> parsingLogs = new ArrayList<>();
|
|
List<ParsingLog> parsingLogs = new ArrayList<>();
|
|
for (ParsingType parsingType : parsingTypes) {
|
|
for (ParsingType parsingType : parsingTypes) {
|
|
// executor.execute(new Runnable() {
|
|
// executor.execute(new Runnable() {
|
|
@@ -201,7 +205,9 @@ public class SftpFileParsing {
|
|
* @param sftpChannel sftp通道信息
|
|
* @param sftpChannel sftp通道信息
|
|
* @return sftp控制
|
|
* @return sftp控制
|
|
*/
|
|
*/
|
|
- public SftpConfig createSftp(SftpChannel sftpChannel) {
|
|
|
|
|
|
+ public SftpConfig createSftp(
|
|
|
|
+ SftpChannel sftpChannel
|
|
|
|
+ ) {
|
|
// SFTP方式上报
|
|
// SFTP方式上报
|
|
SftpConfig sftpConfig = new SftpConfig();
|
|
SftpConfig sftpConfig = new SftpConfig();
|
|
|
|
|
|
@@ -236,6 +242,7 @@ public class SftpFileParsing {
|
|
* 压缩前一日解析文件并上传至sftp服务器,本地不保留
|
|
* 压缩前一日解析文件并上传至sftp服务器,本地不保留
|
|
*/
|
|
*/
|
|
public void uploadZipFile() {
|
|
public void uploadZipFile() {
|
|
|
|
+ log.info("-----------------开始压缩前一日解析文件并上传至sftp服务器解析任务----------------------");
|
|
List<SftpChannel> sftpChannels = sftpChannelService.list();
|
|
List<SftpChannel> sftpChannels = sftpChannelService.list();
|
|
|
|
|
|
List<ElectricField> electricFields = electricFieldService.list();
|
|
List<ElectricField> electricFields = electricFieldService.list();
|
|
@@ -251,7 +258,7 @@ public class SftpFileParsing {
|
|
for (ElectricField channelElectricField : channelElectricFields) {
|
|
for (ElectricField channelElectricField : channelElectricFields) {
|
|
File failFileDir = new File(PARSING_FILE_FAIL_DIR.getPath() + File.separator + dirYesToday + File.separator + channelElectricField.getStationCode());
|
|
File failFileDir = new File(PARSING_FILE_FAIL_DIR.getPath() + File.separator + dirYesToday + File.separator + channelElectricField.getStationCode());
|
|
if (failFileDir.exists()) {
|
|
if (failFileDir.exists()) {
|
|
- String zipPath = ZipUtil.zip(failFileDir.getAbsolutePath(), PARSING_FILE_FAIL_DIR.getPath() + File.separator + dirYesToday + "_SUCCESS.zip");
|
|
|
|
|
|
+ String zipPath = ZipUtil.zip(failFileDir.getAbsolutePath(), PARSING_FILE_FAIL_DIR.getPath() + File.separator + dirYesToday + "_FAIL.zip");
|
|
if (zipPath != null && new File(zipPath).exists()) {
|
|
if (zipPath != null && new File(zipPath).exists()) {
|
|
upload(sftpConfig.getSftp(), channelElectricField.getSftpBackupUrl(), zipPath);
|
|
upload(sftpConfig.getSftp(), channelElectricField.getSftpBackupUrl(), zipPath);
|
|
}
|
|
}
|
|
@@ -269,6 +276,7 @@ public class SftpFileParsing {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ log.info("-----------------结束压缩前一日解析文件并上传至sftp服务器解析任务----------------------");
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -278,12 +286,18 @@ public class SftpFileParsing {
|
|
* @param destPathName 目标路径
|
|
* @param destPathName 目标路径
|
|
* @param srcName 源路径
|
|
* @param srcName 源路径
|
|
*/
|
|
*/
|
|
- private void upload(Sftp sftp, String destPathName, String srcName) {
|
|
|
|
|
|
+ private void upload(
|
|
|
|
+ Sftp sftp,
|
|
|
|
+ String destPathName,
|
|
|
|
+ String srcName
|
|
|
|
+ ) {
|
|
FileInputStream fis = null;
|
|
FileInputStream fis = null;
|
|
try {
|
|
try {
|
|
fis = new FileInputStream(srcName);
|
|
fis = new FileInputStream(srcName);
|
|
File file = new File(srcName);
|
|
File file = new File(srcName);
|
|
sftp.getClient().put(fis, destPathName + "/" + file.getName());
|
|
sftp.getClient().put(fis, destPathName + "/" + file.getName());
|
|
|
|
+ //有没删掉文件的情况,怀疑是文件没有传输完成导致的文件被占用,静止一秒后再删除试试
|
|
|
|
+ Thread.sleep(1000L);
|
|
file.delete();
|
|
file.delete();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("上传备份文件异常", e);
|
|
log.error("上传备份文件异常", e);
|