diff --git a/README.md b/README.md
index 982cab3..2fee012 100644
--- a/README.md
+++ b/README.md
@@ -157,14 +157,14 @@ ftp-sync:
ftp-port: 9979
ftp-username: ftpuser
ftp-password: ftppass
- ftp-source-dir: /340100/record/ # txt目录
- ftp-record-dir: /340100/recordfile/ # mp3目录
- ftp-archive-dir: /340100/processed/ # 归档目录
+ ftp-source-dir: /record/ # txt目录
+ ftp-record-dir: /recordfile/ # mp3目录
+ ftp-archive-dir: /processed/ # 归档目录
vaa-sync:
oss:
base-url: http://你的OSS地址:9090
- upload-url: http://你的OSS地址:9090/apiOss/oss/fileUpload
+ upload-url: http://你的OSS地址:9090/apiOss/oss/noAuthFileUploadSingle
appcode: dataservice-yy
appid: 你的appid
appsecret: 你的appsecret
diff --git a/config/application-external.yml b/config/application-external.yml
index 713549b..1dc06a9 100644
--- a/config/application-external.yml
+++ b/config/application-external.yml
@@ -14,29 +14,7 @@ spring:
driver-class-name: com.kingbase8.Driver
url: jdbc:kingbase8://127.0.0.1:54321/kingbase?currentSchema=mid_voice&clientEncoding=utf8
username: dcms_dev
- password: your_password_here
-
-# ==================== 语音同步配置 ====================
-vaa-sync:
- # 本地录音文件存储路径
- download-path: ./vaa-recordings
-
- # 本地文件保留天数
- retain-days: 10
-
- # 同步定时任务 Cron 表达式
- # 每2小时: 0 0 0/2 * * ?
- # 每30分钟: 0 0/30 * * * ?
- # 每分钟(测试): 0 0/1 * * * ?
- sync-interval-cron: "0 0 0/2 * * ?"
-
- # OSS 文件上传配置
- oss:
- base-url: http://127.0.0.1:9090
- upload-url: http://127.0.0.1:9090/apiOss/oss/fileUpload
- appcode: dataservice-yy
- appid: your_appid_here
- appsecret: your_appsecret_here
+ password: your_password_hereq
# ==================== FTP同步配置(单地市部署) ====================
# 【说明】每个地市单独部署本服务,配置只需要写一个地市
@@ -56,6 +34,17 @@ ftp-sync:
# 字段分隔符(老系统用※)
field-separator: "※"
+ # OSS 文件上传配置
+ oss:
+ base-url: http://127.0.0.1:9090
+ upload-url: http://127.0.0.1:9090/apiOss/oss/noAuthFileUploadSingle
+ # 应用编码可以不写
+ appcode: dataservice-yy
+ # 应用ID(部署时改为真实值)
+ appid: your_appid_here
+ # 应用密钥(部署时改为真实值)
+ appsecret: your_appsecret_here
+
# 当前部署的地市FTP配置(每个地市独立部署一份)
cities:
- city-code: "340100"
diff --git a/pom.xml b/pom.xml
index 4ac48ba..6014e24 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
com.threecloud
dataservice-yy
0.0.1-SNAPSHOT
- dataservice-ftp
+ dataservice-yy
数据同步服务
diff --git a/src/main/java/com/threecloud/dataserviceyy/service/FtpSyncService.java b/src/main/java/com/threecloud/dataserviceyy/service/FtpSyncService.java
index 782977a..b171700 100644
--- a/src/main/java/com/threecloud/dataserviceyy/service/FtpSyncService.java
+++ b/src/main/java/com/threecloud/dataserviceyy/service/FtpSyncService.java
@@ -165,7 +165,7 @@ public class FtpSyncService {
private boolean processTxtFile(FTPClient ftp, FTPFile file, FtpCityConfig city,
Set existingIds) throws Exception {
String fileName = file.getName();
- String sourcePath = city.getFtpSourceDir() + "/" + fileName;
+ String sourcePath = joinPath(city.getFtpSourceDir(), fileName);
logger.info("【FTP文件】开始处理: {}", fileName);
byte[] txtBytes = FtpUtil.downloadFile(ftp, sourcePath);
@@ -200,7 +200,7 @@ public class FtpSyncService {
// 移动到归档目录
try {
- String archivePath = city.getFtpArchiveDir() + "/" + fileName;
+ String archivePath = joinPath(city.getFtpArchiveDir(), fileName);
FtpUtil.ensureDir(ftp, city.getFtpArchiveDir());
FtpUtil.rename(ftp, sourcePath, archivePath);
logger.info("【FTP文件】已归档: {} -> {}", sourcePath, archivePath);
@@ -275,7 +275,7 @@ public class FtpSyncService {
String ossPath = FilePathUtil.buildOssPath(city.getCityCode(), callStartTime, recordFileName);
// 下载录音文件(FTP路径:{ftp-record-dir}/{yyyyMMdd}/{filename})
- String remoteRecordPath = city.getFtpRecordDir() + "/" + dateStr + "/" + recordFileName;
+ String remoteRecordPath = joinPath(city.getFtpRecordDir(), dateStr, recordFileName);
byte[] recordBytes = FtpUtil.downloadFile(ftp, remoteRecordPath);
logger.info("【FTP行】下载录音: {} ({} 字节)", recordFileName, recordBytes.length);
@@ -373,4 +373,36 @@ public class FtpSyncService {
return defaultValue;
}
}
+
+ /**
+ * 拼接FTP路径,自动处理末尾斜杠,避免双斜杠
+ *
+ * @param parts 路径片段
+ * @return 拼接后的路径,使用正斜杠(FTP标准路径分隔符)
+ */
+ private String joinPath(String... parts) {
+ if (parts == null || parts.length == 0) {
+ return "";
+ }
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < parts.length; i++) {
+ String part = parts[i];
+ if (part == null || part.isEmpty()) {
+ continue;
+ }
+ // 去掉末尾的斜杠(除了最后一个片段且本身就是斜杠的情况)
+ if (part.endsWith("/") && i < parts.length - 1) {
+ part = part.substring(0, part.length() - 1);
+ }
+ // 去掉开头的斜杠(除了第一个片段)
+ if (i > 0 && part.startsWith("/")) {
+ part = part.substring(1);
+ }
+ if (sb.length() > 0) {
+ sb.append("/");
+ }
+ sb.append(part);
+ }
+ return sb.toString();
+ }
}