|
@@ -1,13 +1,11 @@
|
|
|
-package com.css.simulation.resource.scene.ctrl;
|
|
|
+package com.css.simulation.resource.system.ctrl;
|
|
|
|
|
|
import api.common.pojo.common.ResponseBodyVO;
|
|
|
import api.common.pojo.constants.DictConstants;
|
|
|
import api.common.pojo.param.MinioParameter;
|
|
|
-import api.common.pojo.param.RedisParameter;
|
|
|
-import api.common.util.ObjectUtil;
|
|
|
+import api.common.util.StringUtil;
|
|
|
import api.common.util.TimeUtil;
|
|
|
import com.css.simulation.resource.feign.FileDownService;
|
|
|
-import com.css.simulation.resource.feign.RedisService;
|
|
|
import feign.Response;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.http.MediaType;
|
|
@@ -35,10 +33,7 @@ public class FileController {
|
|
|
@Resource
|
|
|
private FileDownService fileDownService;
|
|
|
|
|
|
- @Resource
|
|
|
- private RedisService redisService;
|
|
|
-
|
|
|
- @PostMapping(value = "/uploadWj", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
|
|
+ @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
|
|
public ResponseBodyVO<Map> uploadWj(@RequestParam("file") MultipartFile multipartFile, HttpServletRequest request) {
|
|
|
//获取文件类型
|
|
|
String type = request.getParameter("type");
|
|
@@ -46,52 +41,33 @@ public class FileController {
|
|
|
if (multipartFile != null) {
|
|
|
String fileName = "";
|
|
|
Integer nowTime = TimeUtil.getRq(new Date(), 0);
|
|
|
- if (type.equals(DictConstants.SCENE_NATURAL)) {
|
|
|
- fileName = "自然驾驶场景/" + nowTime + "/" + objectPath + "/" + multipartFile.getOriginalFilename();
|
|
|
- } else if (type.equals(DictConstants.SCENE_STANDARD)) {
|
|
|
- fileName = "标准法规场景/" + nowTime + "/" + objectPath + "/" + multipartFile.getOriginalFilename();
|
|
|
- } else if (type.equals(DictConstants.SCENE_ACCIDENT)) {
|
|
|
- fileName = "交通事故场景/" + nowTime + "/" + objectPath + "/" + multipartFile.getOriginalFilename();
|
|
|
- } else if (type.equals(DictConstants.SCENE_GENERAL)) {
|
|
|
- fileName = "泛化场景/" + nowTime + "/" + objectPath + "/" + multipartFile.getOriginalFilename();
|
|
|
+ String randomCode = StringUtil.getRandomCode();
|
|
|
+ if (type.equals(DictConstants.VEHICLE_IMG_FILE)) {
|
|
|
+ fileName = DictConstants.VEHICLE_IMG_FILE + "/" + objectPath + "/" + nowTime + "/" + randomCode + "/" + multipartFile.getOriginalFilename();
|
|
|
} else {
|
|
|
- fileName = multipartFile.getOriginalFilename();
|
|
|
+ new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "文件类型错误!");
|
|
|
}
|
|
|
- ResponseBodyVO<String> respon;
|
|
|
- respon = fileDownService.upload(multipartFile, fileName);
|
|
|
- String videoPreview = respon.getMessage();
|
|
|
- Map map = new HashMap();
|
|
|
- // map.put("videoPreview", videoPreview);
|
|
|
- map.put("fileName", fileName);
|
|
|
-
|
|
|
- return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, map);
|
|
|
+ ResponseBodyVO<String> respon = fileDownService.upload(multipartFile, fileName);
|
|
|
+ if(respon.isStatus()){
|
|
|
+ String previewUrl = respon.getInfo();
|
|
|
+ Map map = new HashMap();
|
|
|
+ map.put("previewUrl", previewUrl);
|
|
|
+ map.put("fileName", fileName);
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, map);
|
|
|
+ }
|
|
|
+ new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "上传失败!");
|
|
|
}
|
|
|
return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE, "文件流file为空,请检查!");
|
|
|
}
|
|
|
|
|
|
@PostMapping(value = "/download")
|
|
|
- public void download(
|
|
|
- HttpServletResponse response, @RequestBody @Validated MinioParameter parms
|
|
|
- ) throws IOException {
|
|
|
+ public void download( HttpServletResponse response, @RequestBody @Validated MinioParameter parms ) throws IOException {
|
|
|
Response download = fileDownService.download(parms);
|
|
|
Response.Body body = download.body();
|
|
|
InputStream inputStream = body.asInputStream();
|
|
|
downloadForHttp(parms.getObjectName(), inputStream, response, 1024);
|
|
|
}
|
|
|
|
|
|
- @PostMapping(value = "/getProgress")
|
|
|
- public ResponseBodyVO getProgress(@RequestBody Map<String,String> paramMap){
|
|
|
- String objectPath = paramMap.get("objectPath");
|
|
|
- RedisParameter redisParameter = new RedisParameter();
|
|
|
- redisParameter.setKey(DictConstants.ALGORITHM_KEY + objectPath);
|
|
|
- ResponseBodyVO resp = redisService.getProgress(redisParameter);
|
|
|
- if(ObjectUtil.isNull(resp.getInfo())){
|
|
|
- resp.setInfo("0.00");
|
|
|
- }
|
|
|
- return resp;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
|
|
|
public void downloadForHttp(String fileName, InputStream in, HttpServletResponse response, int bufferSize) throws IOException {
|
|
|
int idx = fileName.lastIndexOf("/");
|
|
@@ -110,17 +86,15 @@ public class FileController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//从minio获取文件列表
|
|
|
+ //从minio获取文件列表
|
|
|
@PostMapping(value = "/queryList")
|
|
|
- public List<String> queryList(@RequestBody @Validated MinioParameter parms
|
|
|
- ) throws IOException {
|
|
|
+ public List<String> queryList(@RequestBody @Validated MinioParameter parms ) throws IOException {
|
|
|
List<String> list = fileDownService.list(parms).getInfo();
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
@PostMapping(value = "/queryList1")
|
|
|
- public List<String> queryList1(@RequestBody @Validated MinioParameter parms
|
|
|
- ) throws IOException {
|
|
|
+ public List<String> queryList1(@RequestBody @Validated MinioParameter parms ) throws IOException {
|
|
|
List<String> list = fileDownService.listDeepOne(parms).getInfo();
|
|
|
return list;
|
|
|
}
|