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);