| | |
| | | // 如果开启了下级, 身份应该是消息代理, 不再转发到服务器 |
| | | face := req.FaceListObject.FaceObject[0] |
| | | if config.ClientConf.Enable && config.ServeConf.Role == "agent" { |
| | | a.Repository.VIIDMsgForward(&req) |
| | | go a.Repository.VIIDMsgForward(&req) |
| | | } else if config.ServeConf.Role == "cascade" { |
| | | logger.Debug("Receive new message, Id:%s Ip:%s faceId:%s, LeftTopX:%d, appearTime:%s", c.RemoteIP(), face.DeviceID, face.FaceID, face.LeftTopX, face.FaceAppearTime) |
| | | service.AddFaceCapture(&face) |
| | | go service.AddFaceCapture(&face) |
| | | } else { |
| | | logger.Debug("Receive new message, Id:%s Ip:%s faceId:%s, LeftTopX:%d, appearTime:%s", c.RemoteIP(), face.DeviceID, face.FaceID, face.LeftTopX, face.FaceAppearTime) |
| | | a.Repository.FaceForward(req.FaceListObject.FaceObject) |
| | | go a.Repository.FaceForward(req.FaceListObject.FaceObject) |
| | | } |
| | | |
| | | // 设备保活 |
| | |
| | | package controller |
| | | |
| | | import ( |
| | | "fmt" |
| | | "gat1400Exchange/pkg/logger" |
| | | "gat1400Exchange/repository" |
| | | "gat1400Exchange/vo" |
| | | "net/http" |
| | |
| | | |
| | | type SubscribeController struct { |
| | | Repository repository.SubscribeRepository |
| | | Srv repository.CaptureRepository |
| | | } |
| | | |
| | | // 构造函数 |
| | | func NewSubscribeController() SubscribeController { |
| | | svr := repository.NewSubscribeRepository() |
| | | controller := SubscribeController{svr} |
| | | svr1 := repository.NewCaptureRepository() |
| | | controller := SubscribeController{svr, svr1} |
| | | |
| | | return controller |
| | | } |
| | |
| | | } |
| | | |
| | | func (s SubscribeController) Notifications(c *gin.Context) { |
| | | data, err := c.GetRawData() |
| | | if err != nil { |
| | | |
| | | var rsp vo.ResponseStatusList |
| | | var req vo.RequestSubscribeNotificationBind |
| | | if err := c.BindJSON(&req); err != nil { |
| | | c.JSON(http.StatusBadRequest, gin.H{"ResponseStatusListObject": rsp}) |
| | | return |
| | | } |
| | | |
| | | fmt.Println("Notifications:", string(data)) |
| | | c.JSON(http.StatusOK, gin.H{"ResponseStatusListObject": ""}) |
| | | logger.Debug("Receive notifications: %+v", req) |
| | | |
| | | for _, msg := range req.SubscribeNotificationListObject.SubscribeNotificationObject { |
| | | rsp.ResponseStatusObject = append(rsp.ResponseStatusObject, vo.ResponseStatus{ |
| | | RequestURL: c.FullPath(), |
| | | StatusCode: vo.StatusSuccess, |
| | | StatusString: vo.StatusString[vo.StatusSuccess], |
| | | Id: msg.SubscribeID, |
| | | LocalTime: time.Now().Format("20060102150405"), |
| | | }) |
| | | |
| | | // 转发 |
| | | go s.Srv.FaceForward(msg.FaceObjectList.FaceObject) |
| | | } |
| | | |
| | | c.Header("Content-Type", "application/VIID+json;charset=UTF-8") |
| | | c.JSON(http.StatusOK, gin.H{"ResponseStatusListObject": rsp}) |
| | | } |
| | |
| | | ) |
| | | |
| | | var StatusString = [10]string{ |
| | | StatusSuccess: "正常", |
| | | StatusSuccess: "成功", |
| | | StatusOtherError: "其他未知错误", |
| | | StatusDeviceBusy: "设备忙", |
| | | StatusDeviceError: "设备错", |
| | |
| | | } `json:"SubscribeNotificationListObject"` |
| | | } |
| | | |
| | | type RequestSubscribeNotificationBind struct { |
| | | SubscribeNotificationListObject struct { |
| | | SubscribeNotificationObject []Notification `json:"SubscribeNotificationObject"` |
| | | } `json:"SubscribeNotificationListObject"` |
| | | } |
| | | |
| | | type DeviceNotification struct { |
| | | NotificationID string |
| | | SubscribeID string |
| | |
| | | ExecuteOperation int |
| | | FaceObjectList NotificationFaceList |
| | | } |
| | | |
| | | type Notification struct { |
| | | NotificationID string |
| | | SubscribeID string |
| | | Title string |
| | | TriggerTime string |
| | | InfoIDs string |
| | | ExecuteOperation int |
| | | DeviceList NotificationApeList |
| | | FaceObjectList NotificationFaceList |
| | | } |