Merge branch 'main' into dyf-device

This commit is contained in:
2025-11-07 17:11:21 +08:00
8 changed files with 187 additions and 37 deletions

View File

@ -39,6 +39,7 @@ public class DeviceDebugService {
private final IAppBusinessFileService appBusinessFileService;
private final IAppOperationVideoService appOperationVideoService;
private final DeviceService deviceService;
private final FileHashUtil fileHashUtil;
/**
* 文件上传并添加文件信息哈希去重
@ -62,26 +63,12 @@ public class DeviceDebugService {
Map<String, Long> hash2OssId = new LinkedHashMap<>(files.length);
for (MultipartFile file : files) {
// 1. 计算文件哈希
String hash = FileHashUtil.hash(file);
String hash = fileHashUtil.hash(file);
// 2. 先根据 hash 查库(秒传)
SysOssVo exist = sysOssService.selectByHash(hash);
Long ossId;
if (exist != null) {
// 2.1 已存在,直接复用
ossId = exist.getOssId();
hash2OssId.putIfAbsent(hash, ossId);
} else {
// 2.2 不存在,真正上传
SysOssVo upload = sysOssService.upload(file);
if (upload == null) {
return false;
}
ossId = upload.getOssId();
hash2OssId.putIfAbsent(hash, ossId);
// 2.3 把 hash 写回记录(供下次去重)
sysOssService.updateHashById(ossId, hash);
}
SysOssVo exist = sysOssService.updateHash(file, hash);
// 2.1 已存在,直接复用
long ossId = exist.getOssId();
hash2OssId.putIfAbsent(hash, ossId);
}
// 4. 组装业务中间表
List<AppBusinessFile> bizList = new ArrayList<>(bo.getDeviceIds().length * hash2OssId.size());