解决已知问题
This commit is contained in:
parent
0c8835f2fa
commit
e7193d3626
|
|
@ -363,16 +363,14 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
String currentUserId = UserThreadLocal.getUserId();
|
||||
String identifier = fileChunkDTO.getIdentifier();
|
||||
// 首先检查该分片有没被上传,如果有则禁止上传
|
||||
String destPath = uploadDataDir + File.separator + currentUserId + File.separator + identifier + fileChunkDTO.getChunkNumber() + UPLOAD_FILE_CHUNK_SUFFIX;
|
||||
String destPath = uploadDataDir + File.separator + currentUserId + File.separator + identifier + File.separator + fileChunkDTO.getChunkNumber() + UPLOAD_FILE_CHUNK_SUFFIX;
|
||||
boolean exist = FileUtil.exist(destPath);
|
||||
if (exist) {
|
||||
return ElectromagneticResultUtil.fail("-1", "文件已经存在,请勿重复上传");
|
||||
}
|
||||
try (
|
||||
InputStream inputStream = fileChunkDTO.getFile().getInputStream();
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(destPath);
|
||||
) {
|
||||
IoUtil.copy(inputStream, fileOutputStream);
|
||||
|
||||
try {
|
||||
FileUtil.writeFromStream(fileChunkDTO.getFile().getInputStream(), destPath);
|
||||
} catch (IOException ioException) {
|
||||
log.error("上传文件失败...", ioException);
|
||||
throw new BizException(-1, "上传文件失败");
|
||||
|
|
@ -413,7 +411,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
String uuid = IdUtil.fastSimpleUUID();
|
||||
String tmpDir = uploadDataDir + currentUserId + File.separator + uuid + File.separator;
|
||||
ZipUtil.unzip(zipDirPath, tmpDir);
|
||||
update2Database(zipDirPath);
|
||||
update2Database(tmpDir);
|
||||
fileSystemService.deleteFile(zipDirPath, destColibPath);
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
}
|
||||
|
|
@ -477,11 +475,30 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
List<EdFileInfo> deepCopyV = JSONUtil.toList(JSONUtil.toJsonStr(v), EdFileInfo.class);
|
||||
List<EdFileInfo> deepCopyDb = JSONUtil.toList(JSONUtil.toJsonStr(dbFileInfos), EdFileInfo.class);
|
||||
|
||||
EdFileInfo importEffectFile = deepCopyV.stream().filter(e -> e.getEffectFlag().equals(EffectFlagEnum.EFFECT.code)).findFirst().get();
|
||||
EdFileInfo dbEffectFile = deepCopyDb.stream().filter(e -> e.getEffectFlag().equals(EffectFlagEnum.EFFECT.code)).findFirst().get();
|
||||
// 导入的文件在线下已经被废除了
|
||||
Optional<EdFileInfo> first = deepCopyV.stream().filter(e -> e.getEffectFlag().equals(EffectFlagEnum.EFFECT.code)).findFirst();
|
||||
if (!first.isPresent()) {
|
||||
continue;
|
||||
}
|
||||
EdFileInfo importEffectFile = first.get();
|
||||
Optional<EdFileInfo> first1 = deepCopyDb.stream().filter(e -> e.getEffectFlag().equals(EffectFlagEnum.EFFECT.code)).findFirst();
|
||||
EdFileInfo dbEffectFile = null;
|
||||
if (!first1.isPresent()) {
|
||||
// 线下存在,线上不存在,被废除了,此时根据更新时间判断,如果线上的比线下的新,则以线上的为准
|
||||
EdFileInfo fileInfo = deepCopyDb.stream().max(Comparator.comparing(EdFileInfo::getUpdatedTime)).get();
|
||||
if (fileInfo.getUpdatedTime().after(importEffectFile.getUpdatedTime())) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
dbEffectFile = first1.get();
|
||||
}
|
||||
// 如果导入的时间比数据库的时间新,则将导入的置为effect
|
||||
String effectId = importEffectFile.getUpdatedTime().after(dbEffectFile.getUpdatedTime()) ? importEffectFile.getId() : dbEffectFile.getId();
|
||||
|
||||
String effectId;
|
||||
if (ObjUtil.isNull(dbEffectFile)) {
|
||||
effectId = importEffectFile.getId();
|
||||
} else {
|
||||
effectId = importEffectFile.getUpdatedTime().after(dbEffectFile.getUpdatedTime())? importEffectFile.getId() : dbEffectFile.getId();
|
||||
}
|
||||
Map<String, String> importVersionRelation = getVersionRelation(deepCopyV);
|
||||
Map<String, String> dbVersionRelation = getVersionRelation(deepCopyDb);
|
||||
|
||||
|
|
@ -661,7 +678,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
FileSystemResource fileSystemResource = new FileSystemResource(file);
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||
String fileName = Base64.encode(fileSystemResource.getFilename());
|
||||
String fileName = Base64.encode(EleCommonUtil.getNowTimeStr() + "_" + fileSystemResource.getFilename());
|
||||
headers.add("Pragma", "no-cache");
|
||||
headers.add("Expires", "0");
|
||||
response.setHeader("content-disposition", "attachment;filename=" + fileName);
|
||||
|
|
@ -1102,7 +1119,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
private String doSysFileMerge(String identifier, String fileName, Integer totalChunks) {
|
||||
String currentUserId = UserThreadLocal.getUserId();
|
||||
for (int i = 1; i <= totalChunks; i++) {
|
||||
String tmpPath = uploadDataDir + File.separator + currentUserId + identifier + File.separator + i + UPLOAD_FILE_CHUNK_SUFFIX;
|
||||
String tmpPath = uploadDataDir + File.separator + currentUserId + File.separator + identifier + File.separator + i + UPLOAD_FILE_CHUNK_SUFFIX;
|
||||
if (!FileUtil.exist(new File(tmpPath))) {
|
||||
String info = StrFormatter.format("第{}个分片没有上传完成,请上传完成后再合并。", i);
|
||||
log.error(info);
|
||||
|
|
@ -1154,6 +1171,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
public ElectromagneticResult<?> queryChildFolder(String parentId) {
|
||||
|
||||
List<EdFileInfo> edFileInfos = this.baseMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class).select(EdFileInfo::getId, EdFileInfo::getFileName)
|
||||
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FOLDER.code)
|
||||
.eq(EdFileInfo::getPrjDir, Boolean.FALSE)
|
||||
.eq(EdFileInfo::getParentId, parentId)
|
||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code));
|
||||
|
|
|
|||
Loading…
Reference in New Issue