123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- 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"
- )
- type PersonInfo struct {
- CustomId string `json:"customId"`
- Name string `json:"name"`
- PersonType int `json:"personType"`
- TempCardType int `json:"tempCardType"`
- PicURI string `json:"picURI"`
- }
- type EditPersonsNew struct {
- Operator string `json:"operator"`
- MessageId string `json:"messageId"`
- DataBegin string `json:"DataBegin"`
- DataEnd string `json:"DataEnd"`
- PersonNum int `json:"PersonNum"`
- Info []PersonInfo `json:"info"`
- }
- type SucInfo struct {
- CustomId string `json:"customId"`
- }
- type ErrInfo struct {
- CustomId string `json:"customId"`
- ErrCode int `json:"errcode"`
- }
- type EditPersonsNewResInfo struct {
- FaceId string `json:"facesluiceId"`
- AddErrNum int `json:"AddErrNum"`
- AddSucNum int `json:"AddSucNum"`
- AddErrInfo []ErrInfo `json:"AddErrInfo"`
- AddSucInfo []SucInfo `json:"AddSucInfo"`
- Result string `json:"result"`
- Detail string `json:"detail"`
- }
- type EditPersonsNewRes struct {
- Operator string `json:"operator"`
- MessageId string `json:"messageId"`
- Info EditPersonsNewResInfo `json:"info"`
- }
- // 获取到下发白名单响应后
- func DownPersonCommandHandle(command string, res string) {
- fmt.Printf("下发白名单响应处理:command:%s\n res:%s\n", command, res)
- cmdRes := EditPersonsNewRes{}
- DelWait(cmdRes.Info.FaceId)
- json.Unmarshal([]byte(res), &cmdRes)
- mreq := pb_v1.GateCommandResultRequest{Sn: cmdRes.Info.FaceId, CmdCode: DownCommand, Content: res, Protocol: GateProtocolSaiboMqttV1}
- mreq.ResultStatus = 1
- if cmdRes.Info.AddErrNum > 0 {
- mreq.ResultStatus = 2
- mreq.ResultDesc = "添加失败"
- s, _ := json.Marshal(cmdRes.Info.AddErrInfo)
- logger.Error("mqtt_face_set_white",
- zap.String("error", string(s)))
- }
- if cmdRes.Info.Result != "ok" {
- s, _ := json.Marshal(cmdRes)
- logger.Error("mqtt_face_set_white err",
- zap.String("error", string(s)))
- mreq.ResultStatus = 2
- 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()))
- }
- }
|