feat: 代码变更内容为空,无法生成提交信息

This commit is contained in:
SunYF
2026-11-16 19:49:18 +08:00
parent a998a0d0f7
commit 3b0fb2ea46
+105
View File
@@ -0,0 +1,105 @@
// 海康 RCS-Lite 两点路径下发测试脚本(验证 positionCodePath 传 XW→XT 两点是否还报 1006)。
// 用法:进入 D:\hardman\bj_power\test 目录,执行 go run test_agv_two_points.go
// 只依赖 Go 标准库,单文件即可运行。
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"time"
)
func main() {
url := "http://192.168.22.13:8182/rcms/services/rest/hikRpcService/genAgvSchedulingTask"
// 时间戳生成唯一值,防止 reqCode 重复(RCS 对重复 reqCode 报 1025)。
ts := time.Now().Format("20060102150405") + fmt.Sprintf("%03d", time.Now().UnixMilli()%1000)
reqCode := "TEST" + ts
taskCode := "TEST-XW-XT-" + ts
// positionCodePath 写死两点:线头 XW → 线尾 XT,均为位置编号(type=00)。
payload := map[string]any{
"reqCode": reqCode,
"reqTime": time.Now().Format("2006-01-02 15:04:05"),
"taskTyp": "B02",
"priority": "50",
"podCode": "TESTPOD001",
"taskCode": taskCode,
"positionCodePath": []map[string]any{
{"positionCode": "XW", "type": "00"},
{"positionCode": "XT", "type": "00"},
},
}
body, err := json.Marshal(payload)
if err != nil {
fmt.Println("【错误】请求体 JSON 序列化失败:", err)
return
}
// 发送前打印完整请求体(格式化后便于核对点位数量与内容)。
pretty, _ := json.MarshalIndent(payload, "", " ")
fmt.Println("========== 发送请求 ==========")
fmt.Println("URL :", url)
fmt.Println("Method: POST")
fmt.Println("Header: Content-Type: application/json;charset=UTF-8")
fmt.Println("Body :")
fmt.Println(string(pretty))
fmt.Println("==============================")
req, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(body))
if err != nil {
fmt.Println("【错误】构造 HTTP 请求失败:", err)
return
}
req.Header.Set("Content-Type", "application/json;charset=UTF-8")
client := &http.Client{Timeout: 15 * time.Second}
resp, err := client.Do(req)
if err != nil {
fmt.Println("【错误】请求失败(网络不通 / 超时 / RCS 未启动):")
fmt.Println(" ", err)
fmt.Println(" 请确认:1) 已连内网 2) RCS 192.168.22.13:8182 可访问 3) 本机 IP 已在 RCS 白名单")
return
}
defer resp.Body.Close()
raw, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Println("【错误】读取响应体失败:", err)
return
}
fmt.Println()
fmt.Println("========== 收到响应 ==========")
fmt.Printf("HTTP 状态码: %d %s\n", resp.StatusCode, resp.Status)
fmt.Println("响应 Body :")
fmt.Println(string(raw))
fmt.Println("==============================")
// 简单结果判读:把 code 解析出来(兼容数字/字符串两种类型),给出人话结论。
var env struct {
Code json.RawMessage `json:"code"`
Message string `json:"message"`
}
if e := json.Unmarshal(raw, &env); e == nil {
code := string(env.Code)
var num json.Number
if json.Unmarshal(env.Code, &num) == nil {
code = num.String()
}
fmt.Printf("\n【判读】code=%s message=%s\n", code, env.Message)
switch code {
case "0":
fmt.Println(" → 成功:两点路径被 RCS 接受,1006 已消失。")
case "1006":
fmt.Println(" → 仍是 1006:RCS 模板要求的位置点数量与两点不匹配,需继续和海康确认模板配置。")
default:
fmt.Println(" → 其他结果:见上方原始响应体,按 code 对照文档错误码表。")
}
} else {
fmt.Println("\n【判读】响应不是 JSON(可能是纯文本拒绝提示,如 IP 白名单未加),见上方原始 Body。")
}
}