SceneFileController.java 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. package com.fdkankan.scene.controller;
  2. import com.fasterxml.jackson.databind.ObjectMapper;
  3. import com.fdkankan.common.controller.BaseController;
  4. import com.fdkankan.common.response.ResultData;
  5. import com.fdkankan.redis.util.RedisLockUtil;
  6. import com.fdkankan.scene.service.*;
  7. import com.fdkankan.scene.vo.ResponseSceneFile;
  8. import lombok.extern.log4j.Log4j2;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.beans.factory.annotation.Value;
  11. import org.springframework.transaction.annotation.Transactional;
  12. import org.springframework.web.bind.annotation.PostMapping;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import org.springframework.web.bind.annotation.RequestParam;
  15. import org.springframework.web.bind.annotation.RestController;
  16. import org.springframework.web.multipart.MultipartFile;
  17. /**
  18. * 场景文件上传模块
  19. */
  20. @Log4j2
  21. @RestController
  22. @RequestMapping("/api/scene/file")
  23. //@Transactional(rollbackFor = Exception.class)
  24. public class SceneFileController extends BaseController {
  25. @Value("${main.url}")
  26. private String mainUrl;
  27. @Value("${scene.url}")
  28. private String sceneUrl;
  29. @Value("${scene.pro.url}")
  30. private String sceneProUrl;
  31. @Value("${scene.pro.new.url}")
  32. private String sceneProNewUrl;
  33. @Value("${upload.type}")
  34. private String type;
  35. @Value("${oss.prefix.ali}")
  36. private String prefixAli;
  37. @Value("${ecs.type}")
  38. private String ecsType;
  39. @Value("${unCalculated.company.ids:#{null}}")
  40. private String[] unCalculatedCompanyIds;
  41. @Autowired
  42. private ISceneFileBuildService sceneFileBuildService;
  43. private String splice = "#";
  44. @Autowired
  45. RedisLockUtil redisLockUtil;
  46. /**
  47. * 场景文件上传之前先获取fileId
  48. * @param params
  49. * @return
  50. * @throws Exception
  51. */
  52. @PostMapping("preUpload")
  53. public ResponseSceneFile preUpload(String params) throws Exception {
  54. return sceneFileBuildService.preUpload(params);
  55. }
  56. /**
  57. * 获取文件上传的状态
  58. * @param params
  59. * @return
  60. * @throws Exception
  61. */
  62. @PostMapping("getProgress")
  63. public ResponseSceneFile getProgress(String params) throws Exception {
  64. return sceneFileBuildService.getProgress(params);
  65. }
  66. /**
  67. * 单个文件上传
  68. * @param file
  69. * @param params
  70. * @return
  71. */
  72. @PostMapping("upload")
  73. public ResultData upload(@RequestParam(value = "file",required = false) MultipartFile file,
  74. String params) throws Exception {
  75. return sceneFileBuildService.uploadFile(file, params);
  76. }
  77. /**
  78. * 上传大文件
  79. * @param file
  80. * @return
  81. * @throws
  82. */
  83. @PostMapping("uploadBigFile")
  84. public ResultData uploadBigFile(@RequestParam(value = "file",required = false) MultipartFile file,
  85. String params) throws Exception {
  86. return sceneFileBuildService.uploadFile(file, params);
  87. }
  88. /**
  89. * 更新fileid文件的上传状态 -- 作废
  90. *
  91. * @param params
  92. * @return
  93. */
  94. @PostMapping("uploadSuccess")
  95. public ResultData uploadSuccess(String params) throws Exception {
  96. return sceneFileBuildService.uploadSuccess(params);
  97. }
  98. /**
  99. * 更新fileid文件的上传状态 - 后端八目上传逻辑
  100. *
  101. * @param params
  102. * @return
  103. */
  104. @PostMapping("uploadSuccessBuild")
  105. public ResultData uploadSuccessBuild(String params) throws Exception {
  106. return sceneFileBuildService.uploadSuccessBuild(params);
  107. }
  108. /**
  109. *
  110. *
  111. * @param params
  112. * @return
  113. */
  114. @PostMapping("turntableUploadSuccess")
  115. public ResultData turntableUploadSuccess(String params) throws Exception {
  116. return sceneFileBuildService.turntableUploadSuccess(params);
  117. }
  118. /**
  119. * 获取亚马逊S3文件上传url
  120. *
  121. * @return
  122. */
  123. @PostMapping("getS3UploadUrl")
  124. public ResultData getS3UploadUrl(String params) throws Exception {
  125. return sceneFileBuildService.getS3UploadUrl(params);
  126. }
  127. /**
  128. * 计算双目场景 - 新双目相机上传 小红屋
  129. *
  130. * @return
  131. */
  132. // @ApiOperation("计算双目场景 - 新双目相机上传 小红屋")
  133. @PostMapping("buildLiteScene")
  134. // @ApiImplicitParams({
  135. // @ApiImplicitParam(name = "prefix", value = "文件下载前缀,结尾不加/", dataType = "String"),
  136. // @ApiImplicitParam(name = "dataFdage", value = "dataFdage", dataType = "String"),
  137. // @ApiImplicitParam(name = "zipName", value = "zip文件包名称", dataType = "String"),
  138. // @ApiImplicitParam(name = "password", value = "密码", dataType = "String"),
  139. // @ApiImplicitParam(name = "userName", value = "用户名", dataType = "String")})
  140. public ResultData buildLiteScene(String prefix, String dataFdage, String zipName, String userName, String password, String oldNum) throws Exception{
  141. return sceneFileBuildService.buildLiteScene(prefix, dataFdage, zipName, userName, password, oldNum);
  142. }
  143. /**
  144. * 获取亚马逊S3文件上传url
  145. * @return
  146. */
  147. @PostMapping("buildScene")
  148. // @ApiOperation("获取亚马逊S3文件上传url")
  149. // @ApiImplicitParams({
  150. // @ApiImplicitParam(name = "unicode", value = "unicode文件夹", dataType = "String"),
  151. // @ApiImplicitParam(name = "zip", value = "zip包的名称", dataType = "String"),
  152. // @ApiImplicitParam(name = "dataFdage", value = "dataFdage名称", dataType = "String")})
  153. public ResultData buildScene(String prefix, String unicode, String zip, String dataFdage) throws Exception{
  154. return sceneFileBuildService.buildScene(prefix, unicode, zip, dataFdage);
  155. }
  156. }