|
@@ -1,8 +1,15 @@
|
|
|
package com.fdkankan.manage_jp.controller;
|
|
|
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
import com.fdkankan.manage_jp.common.Constant;
|
|
|
import com.fdkankan.manage_jp.common.Result;
|
|
|
+import com.fdkankan.manage_jp.common.ResultCode;
|
|
|
+import com.fdkankan.manage_jp.exception.BusinessException;
|
|
|
+import com.fdkankan.manage_jp.httpClient.client.FdKKClient;
|
|
|
+import com.fdkankan.manage_jp.httpClient.param.UploadEditSceneParam;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -12,10 +19,12 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
+import java.util.UUID;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping("/manage_jp/file")
|
|
|
-public class UploadController {
|
|
|
+@Slf4j
|
|
|
+public class UploadController extends BaseController{
|
|
|
|
|
|
@Autowired
|
|
|
FYunFileServiceInterface fYunFileServiceInterface;
|
|
@@ -33,4 +42,43 @@ public class UploadController {
|
|
|
String url = fYunFileServiceInterface.uploadFile(filePath,"img/".concat(fileName));
|
|
|
return Result.success("",url);
|
|
|
}
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ FdKKClient fdKKClient;
|
|
|
+ @PostMapping("/uploadE57")
|
|
|
+ public Result uploadE57(@RequestParam("file") MultipartFile file,Integer isObj) {
|
|
|
+ try {
|
|
|
+ String originalFilename = file.getOriginalFilename();
|
|
|
+ String suffix = originalFilename.substring(originalFilename.lastIndexOf("."));
|
|
|
+
|
|
|
+ String newFileName = UUID.randomUUID().toString().replace("-","");
|
|
|
+ String filePath = Constant.MANAGE_PATH + "e57/" + File.separator + newFileName +"."+suffix;
|
|
|
+ File targetFile = new File(filePath);
|
|
|
+ if(!targetFile.getParentFile().exists()){
|
|
|
+ targetFile.getParentFile().mkdirs();
|
|
|
+ }
|
|
|
+ file.transferTo(targetFile);
|
|
|
+
|
|
|
+ String url = fYunFileServiceInterface.uploadFile(filePath,filePath.replace(Constant.MANAGE_PATH,"manage"));
|
|
|
+
|
|
|
+ UploadEditSceneParam editSceneParam = new UploadEditSceneParam();
|
|
|
+ editSceneParam.setTitle(originalFilename.replace("."+suffix,""));
|
|
|
+ editSceneParam.setUserId(getUser().getId());
|
|
|
+ editSceneParam.setPath(url);
|
|
|
+ editSceneParam.setOtherType("E57_V4");
|
|
|
+
|
|
|
+ JSONObject jsonObject = fdKKClient.reverseScene(editSceneParam);
|
|
|
+ Integer code = jsonObject.getInteger("code");
|
|
|
+ if(code != 0){
|
|
|
+ log.info("调用失败-toFdCreateScene:{}",jsonObject);
|
|
|
+ throw new BusinessException(ResultCode.UPLOAD_ERROR);
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ log.info("调用失败-toFdCreateScene:",e);
|
|
|
+ throw new BusinessException(ResultCode.UPLOAD_ERROR);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
}
|