|
@@ -1,67 +0,0 @@
|
|
|
-package h_rosbag_filter
|
|
|
-
|
|
|
-import (
|
|
|
- "cicv-data-closedloop/common/config/c_log"
|
|
|
- "cicv-data-closedloop/common/entity"
|
|
|
- "encoding/json"
|
|
|
- "fmt"
|
|
|
- "net/http"
|
|
|
-)
|
|
|
-
|
|
|
-var (
|
|
|
- deviceMap = map[string]Device{
|
|
|
- "1": {Name: "金龙车", CodePath: "/root/rosbag-handle-kinglong/", CompileCmd: "CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc GOARCH=arm64 go build --buildmode=plugin -o /root/rosbag-handle-kinglong/plugin/memoveroccupied.so /root/rosbag-handle-kinglong//plugin/sys_info/memoveroccupied/main/memoveroccupied.go"},
|
|
|
- "2": {Name: "朴津机器人", CodePath: "/root/rosbag-handle-pji/", CompileCmd: "CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc GOARCH=arm64 go build --buildmode=plugin -o /root/rosbag-handle-kinglong/plugin/memoveroccupied.so /root/rosbag-handle-kinglong//plugin/sys_info/memoveroccupied/main/memoveroccupied.go"},
|
|
|
- }
|
|
|
- vaildateCmd = "/root/vaildatePlugin.exe"
|
|
|
-)
|
|
|
-
|
|
|
-// Device 设备
|
|
|
-type Device struct {
|
|
|
- Name string
|
|
|
- CodePath string
|
|
|
- CompileCmd string
|
|
|
-}
|
|
|
-
|
|
|
-// FilterHandler implements http.Handler
|
|
|
-type FilterHandler struct{}
|
|
|
-
|
|
|
-func (h *FilterHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
|
- //
|
|
|
- // 1 校验参数
|
|
|
- queryParams := r.URL.Query()
|
|
|
- deviceType := queryParams.Get("deviceType")
|
|
|
- if deviceType == "" {
|
|
|
- result, _ := json.Marshal(entity.HttpResult{Status: false, Code: "1003", Message: "参数 deviceType 不能为空。"})
|
|
|
- _, _ = fmt.Fprintf(w, string(result))
|
|
|
- return
|
|
|
- }
|
|
|
- goObjectKey := queryParams.Get("goObjectKey")
|
|
|
- if goObjectKey == "" {
|
|
|
- result, _ := json.Marshal(entity.HttpResult{Status: false, Code: "1003", Message: "参数 goObjectKey 不能为空。"})
|
|
|
- _, _ = fmt.Fprintf(w, string(result))
|
|
|
- return
|
|
|
- }
|
|
|
- soObjectKey := queryParams.Get("soObjectKey")
|
|
|
- if soObjectKey == "" {
|
|
|
- result, _ := json.Marshal(entity.HttpResult{Status: false, Code: "1003", Message: "参数 soObjectKey 不能为空。"})
|
|
|
- _, _ = fmt.Fprintf(w, string(result))
|
|
|
- return
|
|
|
- }
|
|
|
- c_log.GlobalLogger.Infof("接收到参数【deviceType】=%v,【goObjectKey】=%v,【soObjectKey】=%v", deviceType, goObjectKey, soObjectKey)
|
|
|
-
|
|
|
- // 2 从 oss 上下载 go 文件
|
|
|
- //device := deviceMap[deviceType]
|
|
|
- //codePath := device.CodePath
|
|
|
- //
|
|
|
- //// 3 编译 go 文件
|
|
|
- //compileCmd := device.CompileCmd
|
|
|
-
|
|
|
- // 4 校验插件是否能用
|
|
|
-
|
|
|
- // 5 如果插件能用,直接上传,并删除本地插件文件
|
|
|
-
|
|
|
- // 通过fmt.Fprintf返回数据
|
|
|
- result, _ := json.Marshal(entity.HttpResult{Status: true, Code: "2000", Message: "编译成功。"})
|
|
|
- _, _ = fmt.Fprintf(w, string(result))
|
|
|
-}
|