|
@@ -5,6 +5,7 @@ import (
|
|
|
"context"
|
|
|
"fmt"
|
|
|
"github.com/cloudwego/hertz/pkg/app"
|
|
|
+ "github.com/cloudwego/hertz/pkg/protocol/consts"
|
|
|
"io"
|
|
|
"net/http"
|
|
|
"os"
|
|
@@ -12,6 +13,7 @@ import (
|
|
|
"pji_desktop_http/biz/dal/mysql"
|
|
|
"pji_desktop_http/common/config"
|
|
|
"pji_desktop_http/common/config/c_log"
|
|
|
+ "pji_desktop_http/common/entity"
|
|
|
"pji_desktop_http/common/util"
|
|
|
)
|
|
|
|
|
@@ -86,18 +88,19 @@ func generateSimulationZipById(ctx context.Context, id string) (file string, tmp
|
|
|
}
|
|
|
c_log.GlobalLogger.Info("创建文件打包根目录:", baseDir)
|
|
|
|
|
|
- // 从oss下载data.zip文件到根目录(data.zip中的mapBuf文件夹包含map.pgm, map.yaml)
|
|
|
+ // 从oss下载data.zip, map.pgm, map.yaml文件到根目录
|
|
|
// 过滤特定后缀的文件列表
|
|
|
simulationFileList := util.FilterBySuffixes(allFileList, config.SimulationFiltersuffixes...)
|
|
|
+ fmt.Println("simulationFileList", simulationFileList)
|
|
|
// 从oss下载文件到 根目录
|
|
|
for _, file := range simulationFileList {
|
|
|
err = config.OssBucket.GetObjectToFile(file, filepath.Join(baseDir, filepath.Base(file)))
|
|
|
if err != nil {
|
|
|
- fmt.Println("Error downloading mapBuf file:", err)
|
|
|
+ fmt.Println("Error downloading file - data.zip, map.pgm, map.yaml:", err)
|
|
|
return "", "", err
|
|
|
}
|
|
|
}
|
|
|
- c_log.GlobalLogger.Info("下载data.zip文件到根目录 - 成功")
|
|
|
+ c_log.GlobalLogger.Info("下载data.zip, map.pgm, map.yaml文件到根目录 - 成功")
|
|
|
|
|
|
// 下载world文件
|
|
|
// 查询状态
|
|
@@ -115,6 +118,19 @@ func generateSimulationZipById(ctx context.Context, id string) (file string, tmp
|
|
|
c_log.GlobalLogger.Info("下载world文件到根目录 - 成功")
|
|
|
}
|
|
|
|
|
|
+ // 下载原始bag
|
|
|
+ rosField, err := util.GetRosFileById(id)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error querying origin map's bag file:", err)
|
|
|
+ return "", "", err
|
|
|
+ }
|
|
|
+ err = config.OssBucket.GetObjectToFile(rosField, filepath.Join(baseDir, "origin_map.bag"))
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error downloading origin map's bag file:", err)
|
|
|
+ return "", "", err
|
|
|
+ }
|
|
|
+ c_log.GlobalLogger.Info("下载origin_map.bag文件到根目录 - 成功")
|
|
|
+
|
|
|
// 创建压缩文件
|
|
|
zipPath := filepath.Join(tmpDir, "simulationFile-"+id+".zip")
|
|
|
zipFile, err := os.Create(zipPath)
|
|
@@ -138,3 +154,23 @@ func generateSimulationZipById(ctx context.Context, id string) (file string, tmp
|
|
|
|
|
|
return zipPath, tmpDir, nil
|
|
|
}
|
|
|
+
|
|
|
+// CheckDataFileStatus 检查data目录是否存在
|
|
|
+// @router /simulation/check/file/data/status [GET]
|
|
|
+func CheckDataFileStatus(ctx context.Context, c *app.RequestContext) {
|
|
|
+ sceneID := c.Query("id")
|
|
|
+ fmt.Println("id", sceneID)
|
|
|
+
|
|
|
+ // 根据id获取对应的oss文件列表
|
|
|
+ allFileList, err := util.GetExactedMapFileById(sceneID)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 过滤特定后缀的文件列表(data.zip)
|
|
|
+ simulationFileList := util.FilterBySuffixes(allFileList, config.DataFiltersuffixes...)
|
|
|
+ if len(simulationFileList) == 0 {
|
|
|
+ c.JSON(consts.StatusOK, entity.HttpResult{Status: false, Code: "", Message: "data目录不存在"})
|
|
|
+ return
|
|
|
+ }
|
|
|
+ c.JSON(consts.StatusOK, entity.HttpResult{Status: true, Code: "", Message: "data目录存在"})
|
|
|
+}
|