|
@@ -1,20 +1,26 @@
|
|
package com.fdkankan.fusion.controller;
|
|
package com.fdkankan.fusion.controller;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.fdkankan.fusion.common.FilePath;
|
|
import com.fdkankan.fusion.common.FilePath;
|
|
import com.fdkankan.fusion.common.ResultCode;
|
|
import com.fdkankan.fusion.common.ResultCode;
|
|
|
|
+import com.fdkankan.fusion.entity.CommonUpload;
|
|
import com.fdkankan.fusion.exception.BusinessException;
|
|
import com.fdkankan.fusion.exception.BusinessException;
|
|
import com.fdkankan.fusion.common.ResultData;
|
|
import com.fdkankan.fusion.common.ResultData;
|
|
import com.fdkankan.fusion.common.ResultCode;
|
|
import com.fdkankan.fusion.common.ResultCode;
|
|
|
|
+import com.fdkankan.fusion.response.UploadProcessVo;
|
|
import com.fdkankan.fusion.service.ICommonUploadService;
|
|
import com.fdkankan.fusion.service.ICommonUploadService;
|
|
import com.fdkankan.fusion.service.impl.UploadService;
|
|
import com.fdkankan.fusion.service.impl.UploadService;
|
|
|
|
+import com.fdkankan.redis.util.RedisUtil;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
+import scala.Int;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.UUID;
|
|
import java.util.UUID;
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@@ -44,4 +50,35 @@ public class UploadController {
|
|
|
|
|
|
return commonUploadService.uploadFileNew(dictId,file);
|
|
return commonUploadService.uploadFileNew(dictId,file);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ RedisUtil redisUtil;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @GetMapping(value = "/uploadProcess/{uploadId}")
|
|
|
|
+ public ResultData uploadProcess(@PathVariable Integer uploadId) {
|
|
|
|
+ String redisKey = "fusion:upload:process:"+ uploadId;
|
|
|
|
+ String redisKey2 = "fusion:upload:process:num:"+ uploadId;
|
|
|
|
+ if(redisUtil.hasKey(redisKey)){
|
|
|
|
+ return ResultData.ok(JSONObject.parseObject(redisUtil.get(redisKey)));
|
|
|
|
+ }
|
|
|
|
+ if(redisUtil.hasKey(redisKey2)){
|
|
|
|
+ redisUtil.set(redisKey2,String.valueOf(Integer.parseInt(redisUtil.get(redisKey2)) + 1),60*60);
|
|
|
|
+ }else {
|
|
|
|
+ redisUtil.set(redisKey2,"1",60*60);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ UploadProcessVo uploadProcessVo = new UploadProcessVo();
|
|
|
|
+ CommonUpload commonUpload = commonUploadService.getById(uploadId);
|
|
|
|
+ uploadProcessVo.setStatus(commonUpload.getStatus());
|
|
|
|
+ if(commonUpload.getStatus() == 1){
|
|
|
|
+ uploadProcessVo.setPercent(100);
|
|
|
|
+ }else{
|
|
|
|
+ Integer percent = Integer.parseInt(redisUtil.get(redisKey2)) <100 ? Integer.parseInt(redisUtil.get(redisKey2)) : 99;
|
|
|
|
+ uploadProcessVo.setPercent(percent);
|
|
|
|
+ }
|
|
|
|
+ redisUtil.set(redisKey,JSONObject.toJSONString(commonUpload),60);
|
|
|
|
+
|
|
|
|
+ return ResultData.ok(uploadProcessVo);
|
|
|
|
+ }
|
|
}
|
|
}
|