|
@@ -4,8 +4,10 @@ import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.io.FileUtil;
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
|
+import cn.hutool.core.lang.UUID;
|
|
import cn.hutool.core.thread.ThreadUtil;
|
|
import cn.hutool.core.thread.ThreadUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
+import cn.hutool.crypto.digest.MD5;
|
|
import cn.hutool.extra.qrcode.QrCodeUtil;
|
|
import cn.hutool.extra.qrcode.QrCodeUtil;
|
|
import cn.hutool.extra.qrcode.QrConfig;
|
|
import cn.hutool.extra.qrcode.QrConfig;
|
|
import cn.hutool.http.HttpUtil;
|
|
import cn.hutool.http.HttpUtil;
|
|
@@ -1782,9 +1784,14 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
return ResultData.ok();
|
|
return ResultData.ok();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
|
+ System.out.println(UUID.randomUUID().toString());
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public ResultData uploadFile(MultipartFile file, String params) throws Exception {
|
|
public ResultData uploadFile(MultipartFile file, String params) throws Exception {
|
|
|
|
|
|
|
|
+ String uuid = UUID.randomUUID().toString();
|
|
log.info("upload-params: "+params);
|
|
log.info("upload-params: "+params);
|
|
if (StringUtils.isEmpty(params)){
|
|
if (StringUtils.isEmpty(params)){
|
|
throw new BusinessException(ErrorCode.PARAM_REQUIRED);
|
|
throw new BusinessException(ErrorCode.PARAM_REQUIRED);
|
|
@@ -1800,7 +1807,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
|
|
|
//这里增加判断,如果是日志文件,不做任何处理,直接返回
|
|
//这里增加判断,如果是日志文件,不做任何处理,直接返回
|
|
if(restr.contains("normal")){
|
|
if(restr.contains("normal")){
|
|
- return ResultData.ok();
|
|
|
|
|
|
+ return ResultData.ok("参数带有normal,直接丢弃");
|
|
}
|
|
}
|
|
String[] strArr = restr.split(SPLICE);
|
|
String[] strArr = restr.split(SPLICE);
|
|
|
|
|
|
@@ -1862,6 +1869,16 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
.concat(filePath).concat(File.separator).concat(fileName);
|
|
.concat(filePath).concat(File.separator).concat(fileName);
|
|
log.info("yunFilePath:{}", yunFilePath);
|
|
log.info("yunFilePath:{}", yunFilePath);
|
|
|
|
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ map.put("uuid", uuid);
|
|
|
|
+ map.put("params", params);
|
|
|
|
+ map.put("yunFilePath", yunFilePath);
|
|
|
|
+ map.put("mac", mac);
|
|
|
|
+ map.put("fileId", fileId);
|
|
|
|
+ map.put("picNum", picNum);
|
|
|
|
+ map.put("md5", md5);
|
|
|
|
+ map.put("chunk", chunk);
|
|
|
|
+
|
|
boolean needUpload = false;
|
|
boolean needUpload = false;
|
|
File yunFile = new File(yunFilePath);
|
|
File yunFile = new File(yunFilePath);
|
|
if (yunFile.exists()){
|
|
if (yunFile.exists()){
|
|
@@ -1887,7 +1904,8 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
sceneFileUploadEntity.setChunk(Integer.valueOf(chunk));
|
|
sceneFileUploadEntity.setChunk(Integer.valueOf(chunk));
|
|
sceneFileUploadService.save(sceneFileUploadEntity);
|
|
sceneFileUploadService.save(sceneFileUploadEntity);
|
|
}
|
|
}
|
|
- result = ResultData.ok();
|
|
|
|
|
|
+ map.put("needUpload",false);
|
|
|
|
+ result = ResultData.ok(map);
|
|
}else if (!md5.equals(fileMD5)) {
|
|
}else if (!md5.equals(fileMD5)) {
|
|
log.info("文件已上传,上传MD5:"+md5+",服务器MD5:"+fileMD5+"。不一致。需要重新上传");
|
|
log.info("文件已上传,上传MD5:"+md5+",服务器MD5:"+fileMD5+"。不一致。需要重新上传");
|
|
FileUtils.delFile(yunFilePath.toString());
|
|
FileUtils.delFile(yunFilePath.toString());
|
|
@@ -1906,6 +1924,9 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
// 5. 如果相等,更新数据记录。如果不相等,返回上传失败结果。
|
|
// 5. 如果相等,更新数据记录。如果不相等,返回上传失败结果。
|
|
try {
|
|
try {
|
|
if (needUpload){
|
|
if (needUpload){
|
|
|
|
+
|
|
|
|
+ map.put("needUpload", true);
|
|
|
|
+
|
|
fYunFileService.uploadFile(file.getInputStream(),ConstantFilePath.OSS_PREFIX.concat(filePath).concat(File.separator).concat(fileName));
|
|
fYunFileService.uploadFile(file.getInputStream(),ConstantFilePath.OSS_PREFIX.concat(filePath).concat(File.separator).concat(fileName));
|
|
File uploadFile = new File(yunFilePath);
|
|
File uploadFile = new File(yunFilePath);
|
|
String fileMD5 = FileMd5Util.getFileMD5(uploadFile);
|
|
String fileMD5 = FileMd5Util.getFileMD5(uploadFile);
|
|
@@ -1922,7 +1943,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
log.info("文件已上传,MD5和文件大小一致。上传成功");
|
|
log.info("文件已上传,MD5和文件大小一致。上传成功");
|
|
sceneFileUploadEntity.setUploadStatus(1);
|
|
sceneFileUploadEntity.setUploadStatus(1);
|
|
sceneFileUploadService.save(sceneFileUploadEntity);
|
|
sceneFileUploadService.save(sceneFileUploadEntity);
|
|
- result = ResultData.ok(sceneFileUploadEntity.getFilePath());
|
|
|
|
|
|
+ result = ResultData.ok(map);
|
|
}else if (!md5.equals(fileMD5)) {
|
|
}else if (!md5.equals(fileMD5)) {
|
|
log.error("文件已上传,上传MD5:"+md5+",服务器MD5:"+fileMD5+"。不一致。上传失败");
|
|
log.error("文件已上传,上传MD5:"+md5+",服务器MD5:"+fileMD5+"。不一致。上传失败");
|
|
sceneFileUploadEntity.setUploadStatus(-1);
|
|
sceneFileUploadEntity.setUploadStatus(-1);
|