|
|
@ -243,8 +243,9 @@ public class FtpSyncService { |
|
|
*/ |
|
|
*/ |
|
|
private boolean processLine(String line, FtpCityConfig city, Set<String> existingIds, |
|
|
private boolean processLine(String line, FtpCityConfig city, Set<String> existingIds, |
|
|
FTPClient ftp) throws Exception { |
|
|
FTPClient ftp) throws Exception { |
|
|
// 按分隔符拆分字段(老淮南FTP数据格式:※分隔)
|
|
|
// 按分隔符拆分字段(*分隔,需转义正则特殊字符)
|
|
|
String[] fields = line.split(properties.getFieldSeparator(), -1); |
|
|
String separator = java.util.regex.Pattern.quote(properties.getFieldSeparator()); |
|
|
|
|
|
String[] fields = line.split(separator, -1); |
|
|
if (fields.length < MIN_FIELD_COUNT) { |
|
|
if (fields.length < MIN_FIELD_COUNT) { |
|
|
logger.debug("【FTP行】字段数不足({}<{}),跳过: {}", fields.length, MIN_FIELD_COUNT, line); |
|
|
logger.debug("【FTP行】字段数不足({}<{}),跳过: {}", fields.length, MIN_FIELD_COUNT, line); |
|
|
return false; |
|
|
return false; |
|
|
@ -300,22 +301,16 @@ public class FtpSyncService { |
|
|
String ossPath = FilePathUtil.buildOssPath(city.getCityCode(), callStartTime, recordFileName); |
|
|
String ossPath = FilePathUtil.buildOssPath(city.getCityCode(), callStartTime, recordFileName); |
|
|
|
|
|
|
|
|
// 下载录音文件(FTP路径:{ftp-record-dir}/{yyyyMMdd}/{filename})
|
|
|
// 下载录音文件(FTP路径:{ftp-record-dir}/{yyyyMMdd}/{filename})
|
|
|
// 先切换到录音文件根目录,避免工作目录在别处导致下载失败
|
|
|
// 使用绝对路径下载,避免切换目录导致的问题
|
|
|
String recordDir = city.getFtpRecordDir(); |
|
|
String recordDir = city.getFtpRecordDir(); |
|
|
// 去掉末尾斜杠,避免双斜杠
|
|
|
|
|
|
if (recordDir != null && recordDir.endsWith("/")) { |
|
|
if (recordDir != null && recordDir.endsWith("/")) { |
|
|
recordDir = recordDir.substring(0, recordDir.length() - 1); |
|
|
recordDir = recordDir.substring(0, recordDir.length() - 1); |
|
|
} |
|
|
} |
|
|
logger.info("【FTP行】准备切换目录: {}", recordDir); |
|
|
String remoteRecordPath = recordDir + "/" + dateStr + "/" + recordFileName; |
|
|
FtpUtil.changeDir(ftp, recordDir); |
|
|
logger.info("【FTP行】准备下载录音: {}", remoteRecordPath); |
|
|
String remoteRecordPath = dateStr + "/" + recordFileName; |
|
|
|
|
|
logger.info("【FTP行】准备下载录音: {}/{}", recordDir, remoteRecordPath); |
|
|
|
|
|
byte[] recordBytes = FtpUtil.downloadFile(ftp, remoteRecordPath); |
|
|
byte[] recordBytes = FtpUtil.downloadFile(ftp, remoteRecordPath); |
|
|
logger.info("【FTP行】下载录音: {} ({} 字节)", recordFileName, recordBytes.length); |
|
|
logger.info("【FTP行】下载录音: {} ({} 字节)", recordFileName, recordBytes.length); |
|
|
|
|
|
|
|
|
// 下载完成后切回txt目录,继续处理下一个文件
|
|
|
|
|
|
FtpUtil.changeDir(ftp, city.getFtpSourceDir()); |
|
|
|
|
|
|
|
|
|
|
|
// 上传到OSS(获取可访问的URL)
|
|
|
// 上传到OSS(获取可访问的URL)
|
|
|
String ossUrl = fileUploadUtil.uploadWav(ossPath, recordFileName, recordBytes); |
|
|
String ossUrl = fileUploadUtil.uploadWav(ossPath, recordFileName, recordBytes); |
|
|
logger.info("【FTP行】上传OSS: {}", ossUrl); |
|
|
logger.info("【FTP行】上传OSS: {}", ossUrl); |
|
|
|