delperson_command.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package mqtt_utils
  2. import (
  3. "context"
  4. "encoding/json"
  5. "fmt"
  6. "git.getensh.com/common/gopkgs/logger"
  7. "go.uber.org/zap"
  8. "property-mqtt/pb"
  9. pb_v1 "property-mqtt/pb/v1"
  10. )
  11. type DeletePersonsInfo struct {
  12. CustomId []string `json:"customId"`
  13. }
  14. type DeletePersonsCmd struct {
  15. Operator string `json:"operator"`
  16. MessageId string `json:"messageId"`
  17. DataBegin string `json:"DataBegin"`
  18. DataEnd string `json:"DataEnd"`
  19. PersonNum int `json:"PersonNum"`
  20. Info DeletePersonsInfo `json:"info"`
  21. }
  22. type DelSucInfo struct {
  23. CustomId string `json:"customId"`
  24. }
  25. type DelErrInfo struct {
  26. CustomId string `json:"customId"`
  27. }
  28. type DeletePersonsCmdResInfo struct {
  29. FaceId string `json:"facesluiceId"`
  30. DelErrNum int `json:"DelErrNum"`
  31. DelSucNum int `json:"DelSucNum"`
  32. DelErrInfo []DelErrInfo `json:"DelErrInfo"`
  33. DelSucInfo []DelSucInfo `json:"DelSucInfo"`
  34. Result string `json:"result"`
  35. Detail string `json:"detail"`
  36. }
  37. type DeletePersonsCmdRes struct {
  38. Operator string `json:"operator"`
  39. MessageId string `json:"messageId"`
  40. Info DeletePersonsCmdResInfo `json:"info"`
  41. }
  42. func DelPersonCommandHandle(command string, res string) {
  43. fmt.Printf("删除人员响应处理:command:%s\n res:%s\n", command, res)
  44. cmdRes := DeletePersonsCmdRes{}
  45. json.Unmarshal([]byte(res), &cmdRes)
  46. DelWait(cmdRes.Info.FaceId)
  47. mreq := pb_v1.GateCommandResultRequest{Sn: cmdRes.Info.FaceId, CmdCode: DelCommand, Content: res, Protocol: GateProtocolSaiboMqttV1}
  48. if cmdRes.Info.DelErrNum > 0 {
  49. s, _ := json.Marshal(cmdRes.Info.DelErrInfo)
  50. logger.Error("mqtt_face_del_white",
  51. zap.String("error", string(s)))
  52. mreq.ResultStatus = 2
  53. mreq.ResultDesc = "删除失败"
  54. }
  55. if cmdRes.Info.Result != "ok" {
  56. s, _ := json.Marshal(cmdRes)
  57. logger.Error("mqtt_face_del_white err",
  58. zap.String("error", string(s)))
  59. mreq.ResultStatus = 2
  60. mreq.ResultDesc = cmdRes.Info.Detail
  61. }
  62. _, err := pb.Device.GateCommandResult(context.Background(), &mreq)
  63. if err != nil {
  64. logger.Error("func",
  65. zap.String("call", "pb.Device.GateCommandResult"),
  66. zap.String("error", err.Error()))
  67. }
  68. }