|
@@ -0,0 +1,65 @@
|
|
|
+package com.fdkk.sxz.webApi.controller;
|
|
|
+
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
+import com.fdkk.sxz.annotation.auth.NoAuthentication;
|
|
|
+import com.fdkk.sxz.annotation.log.AroundLog;
|
|
|
+import com.fdkk.sxz.base.Result;
|
|
|
+import com.fdkk.sxz.util.CreateObjUtil;
|
|
|
+import com.fdkk.sxz.util.SnowIdUtil;
|
|
|
+import com.fdkk.sxz.util.UploadToOssUtil;
|
|
|
+import com.fdkk.sxz.vo.request.RequestOfflineConvert;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.io.File;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author Xiewj
|
|
|
+ * @date 2021/10/19
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@RestController
|
|
|
+@RequestMapping("/change/offline")
|
|
|
+@Api(tags = "线下转换模块")
|
|
|
+public class OfflineController {
|
|
|
+ @Value("${upload.file.location}")
|
|
|
+ private String path;
|
|
|
+ @Autowired
|
|
|
+ private UploadToOssUtil uploadToOssUtil;
|
|
|
+ @Autowired
|
|
|
+ private SnowIdUtil snowIdUtil;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 转换modeldata
|
|
|
+ *
|
|
|
+ * @param dto
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation("转换modeldata")
|
|
|
+ @RequestMapping(value = "/convertToVisionmodeldata", method = RequestMethod.POST)
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "downloadUrl", value = "下载路径", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "pushUrl", value = "上传路径", dataType = "String")})
|
|
|
+ @NoAuthentication
|
|
|
+ @AroundLog(name = "转换modeldata")
|
|
|
+ public Result convertToVisionmodeldata(HttpServletRequest request, @RequestBody RequestOfflineConvert dto) throws Exception {
|
|
|
+ String basePath = path + File.separator + snowIdUtil.getNextIdStr() + File.separator;
|
|
|
+ FileUtil.mkdir(basePath);
|
|
|
+ uploadToOssUtil.download(dto.getDownloadUrl() + "vision.txt", basePath + "vision.txt");
|
|
|
+ CreateObjUtil.convertTxtToVisionmodeldata(basePath + "vision.txt", basePath + "vision.modeldata");
|
|
|
+ uploadToOssUtil.upload(basePath + "vision.modeldata", dto.getPushUrl() + "vision.modeldata");
|
|
|
+ FileUtil.del(basePath);
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|