From 036d7488ad471834efae6d85fc447c98249a0de7 Mon Sep 17 00:00:00 2001 From: lianlonggang Date: Mon, 20 Apr 2026 15:32:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20json=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=E4=B8=BAtxt=20+=20=E6=89=AB?= =?UTF-8?q?=E6=8F=8F=E9=98=B6=E6=AE=B5=E5=A2=9E=E9=87=8F=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E5=8F=98=E6=9B=B4=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- .../yxtech/ossyn/service/OssSyncService.java | 19 ++++++++++++++++--- .../java/com/yxtech/ossyn/util/OssUtil.java | 4 ++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/yxtech/ossyn/service/OssSyncService.java b/src/main/java/com/yxtech/ossyn/service/OssSyncService.java index 06f8fda..956632a 100644 --- a/src/main/java/com/yxtech/ossyn/service/OssSyncService.java +++ b/src/main/java/com/yxtech/ossyn/service/OssSyncService.java @@ -171,11 +171,24 @@ public class OssSyncService { for (Map row : rows) { String bizId = row.get("id"); String filePath = row.get("filePath"); - Long exists = ossFileLogMapper.selectCount(new LambdaQueryWrapper() + QhOssFileLog existing = ossFileLogMapper.selectOne(new LambdaQueryWrapper() .eq(QhOssFileLog::getBizTabName, mapping.getTableName()) .eq(QhOssFileLog::getBizTabId, bizId) - .eq(QhOssFileLog::getBizColName, mapping.getFileCol())); - if (exists > 0) { + .eq(QhOssFileLog::getBizColName, mapping.getFileCol()) + .last("LIMIT 1")); + if (existing != null) { + // 路径未变,跳过;路径已变(业务重新上传),重置为待处理 + if (filePath != null && filePath.equals(existing.getBizTabPath())) { + continue; + } + log.info("[OssSyncService] 检测到文件路径变更,重置日志 id={} 旧路径={} 新路径={}", + existing.getId(), existing.getBizTabPath(), filePath); + ossFileLogMapper.update(null, new LambdaUpdateWrapper() + .eq(QhOssFileLog::getId, existing.getId()) + .set(QhOssFileLog::getBizTabPath, filePath) + .set(QhOssFileLog::getBizHandleStatus, QhOssFileLog.STATUS_PENDING) + .set(QhOssFileLog::getOssPath, null) + .set(QhOssFileLog::getUpdateTime, LocalDateTime.now())); continue; } QhOssFileLog record = new QhOssFileLog(); diff --git a/src/main/java/com/yxtech/ossyn/util/OssUtil.java b/src/main/java/com/yxtech/ossyn/util/OssUtil.java index 5aa66f1..aa9c40d 100644 --- a/src/main/java/com/yxtech/ossyn/util/OssUtil.java +++ b/src/main/java/com/yxtech/ossyn/util/OssUtil.java @@ -120,6 +120,10 @@ public class OssUtil { // } else { // fileName += "_" + System.currentTimeMillis(); // } + // json 文件改为 txt 后缀上传(OSS 不支持 json 类型) + if (fileName.toLowerCase().endsWith(".json")) { + fileName = fileName.substring(0, fileName.length() - 5) + ".txt"; + } String nowday = new SimpleDateFormat("yyyyMMdd").format(new Date()); final String finalFileName = DIR + bizPath + "/" + nowday + "/" + fileName; return doUpload(stream, url, finalFileName);