12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package mqtt_utils
- import (
- "context"
- "encoding/json"
- "fmt"
- "git.getensh.com/common/gopkgs/logger"
- "go.uber.org/zap"
- "property-mqtt/pb"
- pb_v1 "property-mqtt/pb/v1"
- "strconv"
- )
- type RebootDeviceInfo struct {
- }
- type RebootDeviceCmd struct {
- Operator string `json:"operator"`
- MessageId string `json:"messageId"`
- Info RebootDeviceInfo `json:"info"`
- }
- type RebootDeviceCmdResInfo struct {
- Result string `json:"result"`
- FaceId string `json:"facesluiceId"`
- Detail string `json:"detail"`
- }
- type RebootDeviceCmdRes struct {
- Operator string `json:"operator"`
- MessageId string `json:"messageId"`
- Info RebootDeviceCmdResInfo `json:"info"`
- }
- func RebootCommandHandle(command string, res string) {
- fmt.Printf("重启响应处理:command:%s\n res:%s\n", command, res)
- cmdRes := RebootDeviceCmdRes{}
- json.Unmarshal([]byte(res), &cmdRes)
- result := 2
- if cmdRes.Info.Result == "ok" {
- result = 1
- }
- cmdId, _ := strconv.ParseInt(cmdRes.MessageId, 10, 64)
- mreq := pb_v1.GateCommandResultRequest{Sn: cmdRes.Info.FaceId, CmdCode: RebootCommand, Content: res, Protocol: GateProtocolSaiboMqttV1, Id: cmdId}
- mreq.ResultStatus = int32(result)
- mreq.ResultDesc = cmdRes.Info.Detail
- _, err := pb.Device.GateCommandResult(context.Background(), &mreq)
- if err != nil {
- logger.Error("func",
- zap.String("call", "pb.Device.GateCommandResult"),
- zap.String("error", err.Error()))
- }
- }
|