fix: json文件上传重命名为txt + 扫描阶段增量路径变更修复
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -171,11 +171,24 @@ public class OssSyncService {
|
|||||||
for (Map<String, String> row : rows) {
|
for (Map<String, String> row : rows) {
|
||||||
String bizId = row.get("id");
|
String bizId = row.get("id");
|
||||||
String filePath = row.get("filePath");
|
String filePath = row.get("filePath");
|
||||||
Long exists = ossFileLogMapper.selectCount(new LambdaQueryWrapper<QhOssFileLog>()
|
QhOssFileLog existing = ossFileLogMapper.selectOne(new LambdaQueryWrapper<QhOssFileLog>()
|
||||||
.eq(QhOssFileLog::getBizTabName, mapping.getTableName())
|
.eq(QhOssFileLog::getBizTabName, mapping.getTableName())
|
||||||
.eq(QhOssFileLog::getBizTabId, bizId)
|
.eq(QhOssFileLog::getBizTabId, bizId)
|
||||||
.eq(QhOssFileLog::getBizColName, mapping.getFileCol()));
|
.eq(QhOssFileLog::getBizColName, mapping.getFileCol())
|
||||||
if (exists > 0) {
|
.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<QhOssFileLog>()
|
||||||
|
.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;
|
continue;
|
||||||
}
|
}
|
||||||
QhOssFileLog record = new QhOssFileLog();
|
QhOssFileLog record = new QhOssFileLog();
|
||||||
|
|||||||
@@ -120,6 +120,10 @@ public class OssUtil {
|
|||||||
// } else {
|
// } else {
|
||||||
// fileName += "_" + System.currentTimeMillis();
|
// 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());
|
String nowday = new SimpleDateFormat("yyyyMMdd").format(new Date());
|
||||||
final String finalFileName = DIR + bizPath + "/" + nowday + "/" + fileName;
|
final String finalFileName = DIR + bizPath + "/" + nowday + "/" + fileName;
|
||||||
return doUpload(stream, url, finalFileName);
|
return doUpload(stream, url, finalFileName);
|
||||||
|
|||||||
Reference in New Issue
Block a user