1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- 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 DeletePersonsInfo struct {
- CustomId []string `json:"customId"`
- }
- type DeletePersonsCmd struct {
- Operator string `json:"operator"`
- MessageId string `json:"messageId"`
- DataBegin string `json:"DataBegin"`
- DataEnd string `json:"DataEnd"`
- PersonNum int `json:"PersonNum"`
- Info DeletePersonsInfo `json:"info"`
- }
- type DelSucInfo struct {
- CustomId string `json:"customId"`
- }
- type DelErrInfo struct {
- CustomId string `json:"customId"`
- }
- type DeletePersonsCmdResInfo struct {
- FaceId string `json:"facesluiceId"`
- DelErrNum int `json:"DelErrNum"`
- DelSucNum int `json:"DelSucNum"`
- DelErrInfo []DelErrInfo `json:"DelErrInfo"`
- DelSucInfo []DelSucInfo `json:"DelSucInfo"`
- Result string `json:"result"`
- Detail string `json:"detail"`
- }
- type DeletePersonsCmdRes struct {
- Operator string `json:"operator"`
- MessageId string `json:"messageId"`
- Info DeletePersonsCmdResInfo `json:"info"`
- }
- func DelPersonCommandHandle(command string, res string) {
- fmt.Printf("删除人员响应处理:command:%s\n res:%s\n", command, res)
- cmdRes := DeletePersonsCmdRes{}
- json.Unmarshal([]byte(res), &cmdRes)
- DelWait(cmdRes.Info.FaceId)
- mreq := pb_v1.GateCommandResultRequest{Sn: cmdRes.Info.FaceId, CmdCode: DelCommand, Content: res, Protocol: GateProtocolSaiboMqttV1}
- if cmdRes.Info.DelErrNum > 0 {
- s, _ := json.Marshal(cmdRes.Info.DelErrInfo)
- logger.Error("mqtt_face_del_white",
- zap.String("error", string(s)))
- mreq.ResultStatus = 2
- mreq.ResultDesc = "删除失败"
- }
- if cmdRes.Info.Result != "ok" {
- s, _ := json.Marshal(cmdRes)
- logger.Error("mqtt_face_del_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()))
- }
- }
|