| | |
| | | "gat1400Exchange/client" |
| | | "gat1400Exchange/config" |
| | | "gat1400Exchange/models" |
| | | "gat1400Exchange/nvcs" |
| | | "gat1400Exchange/pkg" |
| | | "gat1400Exchange/pkg/logger" |
| | | "gat1400Exchange/util" |
| | |
| | | } |
| | | |
| | | // 处理梯控填写的楼层信息 暂时使用otherFeature字段 |
| | | if face.OtherFeature != "" { |
| | | pd.CameraFloor = face.OtherFeature |
| | | if face.OtherFeature != "" && pd.CameraFloor == "" { |
| | | pd.Direction, pd.CameraFloor, _ = pkg.RestoreFloor(face.OtherFeature) |
| | | } |
| | | |
| | | // 尝试从faceId提取楼层 |
| | | if pd.CameraFloor == "" && config.ClientConf.AddFloorToFaceId { |
| | | pd.CameraFloor, _ = pkg.ParseFloorFromId(face.FaceID) |
| | | } |
| | | //logger.Debug("device %s, CameraFloor:%s", deviceId, pd.CameraFloor) |
| | | |
| | | payload, err := json.Marshal(pd) |
| | | if err != nil { |
| | |
| | | c.CacheData(cacheItem, "basic") |
| | | logger.Warn("The data forwarding failed, adding to local cache.") |
| | | } else { |
| | | logger.Debug("The data forwarding successful. deviceId:%s, picId:", deviceId, face.FaceID) |
| | | logger.Debug("The data forwarding successful. deviceId:%s, picId:%s", deviceId, face.FaceID) |
| | | } |
| | | } |
| | | } |
| | |
| | | pd.CameraFloor = v.BehaviorDescription |
| | | } |
| | | |
| | | // 尝试从faceId提取楼层 |
| | | if pd.CameraFloor == "" && config.ClientConf.AddFloorToFaceId { |
| | | pd.CameraFloor, _ = pkg.ParseFloorFromId(v.PersonID) |
| | | } |
| | | //// 尝试从faceId提取楼层 |
| | | //if pd.CameraFloor == "" && config.ClientConf.AddFloorToFaceId { |
| | | // pd.CameraFloor, _ = pkg.ParseFloorFromId(v.PersonID) |
| | | //} |
| | | //logger.Debug("device %s, CameraFloor:%s", deviceId, pd.CameraFloor) |
| | | |
| | | payload, err := json.Marshal(pd) |
| | |
| | | func (c CaptureRepository) PackPushDataV2(deviceId, faceId, appearTime string, bgImgBytes, faceImgBytes []byte) *vo.PushDataInfoV2 { |
| | | var pd = new(vo.PushDataInfoV2) |
| | | var floor string |
| | | var runDir string |
| | | |
| | | faceAppearTime, err := time.ParseInLocation("20060102150405", appearTime, time.Local) |
| | | if err != nil { |
| | |
| | | faceAppearTime = time.Now() |
| | | } |
| | | |
| | | if config.ServeConf.Role == "server" { |
| | | // 匹配楼层 |
| | | var devPos models.Positions |
| | | _ = devPos.FindDevicePosition(deviceId, faceAppearTime.Unix()+5) // 加5秒电梯关门的时间 |
| | | // 判断是否需要匹配楼层 |
| | | if config.NVCSConf.Model != "" { |
| | | runState := nvcs.FindPositionByTime(faceAppearTime.Unix() + 3) // 加3秒电梯关门的时间 |
| | | floor = runState.Floor |
| | | |
| | | floor = devPos.Pos |
| | | for i := 0; i < config.NVCSConf.WaitRunTime; i++ { |
| | | if runState = nvcs.FindMovePosition(faceAppearTime.Unix()+3, floor); runState.Floor != "" { |
| | | switch runState.RunState { |
| | | case nvcs.RunUp: |
| | | runDir = "in" |
| | | case nvcs.RunDown: |
| | | runDir = "out" |
| | | case nvcs.RunStop: |
| | | runDir = "" |
| | | } |
| | | |
| | | break |
| | | } |
| | | |
| | | time.Sleep(1 * time.Second) |
| | | } |
| | | } |
| | | |
| | | pd.PicMaxImages = append(pd.PicMaxImages, bgImgBytes) |
| | |
| | | pd.DataSource = "camera" |
| | | pd.CameraFloor = floor |
| | | pd.CameraId = deviceId |
| | | pd.Direction = runDir |
| | | |
| | | return pd |
| | | } |
| | |
| | | |
| | | func (c CaptureRepository) VIIDFaceMsgForward(msg *vo.RequestFaceList) { |
| | | faceInfo := msg.FaceListObject.FaceObject[0] |
| | | // 匹配楼层 |
| | | faceAppearTime, err := time.ParseInLocation("20060102150405", faceInfo.FaceAppearTime, time.Local) |
| | | if err != nil { |
| | | logger.Warn("Parse face appear time error, %s", err.Error()) |
| | | faceAppearTime = time.Now() |
| | | } |
| | | var floor, runDir string |
| | | |
| | | var devPos models.Positions |
| | | _ = devPos.FindPositionByTime(faceAppearTime.Unix() + 5) // 加5秒电梯关门的时间 |
| | | if devPos.Pos == "" { |
| | | devPos.Pos = "1F" |
| | | } |
| | | // 判断是否开启了梯控 |
| | | if config.NVCSConf.Model != "" { |
| | | // 匹配楼层 |
| | | faceAppearTime, err := time.ParseInLocation("20060102150405", faceInfo.FaceAppearTime, time.Local) |
| | | if err != nil { |
| | | logger.Warn("Parse face appear time error, %s", err.Error()) |
| | | faceAppearTime = time.Now() |
| | | } |
| | | |
| | | for idx, face := range msg.FaceListObject.FaceObject { |
| | | msg.FaceListObject.FaceObject[idx].OtherFeature = devPos.Pos |
| | | if config.ClientConf.AddFloorToFaceId { |
| | | msg.FaceListObject.FaceObject[idx].FaceID = pkg.GenerateFaceIdContainFloor(face.FaceID, devPos.Pos) |
| | | runState := nvcs.FindPositionByTime(faceAppearTime.Unix() + 3) // 加3秒电梯关门的时间 |
| | | floor = runState.Floor |
| | | |
| | | for i := 0; i < config.NVCSConf.WaitRunTime; i++ { |
| | | if runState = nvcs.FindMovePosition(faceAppearTime.Unix()+3, floor); runState.Floor != "" { |
| | | switch runState.RunState { |
| | | case nvcs.RunUp: |
| | | runDir = "in" |
| | | case nvcs.RunDown: |
| | | runDir = "out" |
| | | case nvcs.RunStop: |
| | | runDir = "" |
| | | } |
| | | |
| | | break |
| | | } |
| | | |
| | | time.Sleep(1 * time.Second) |
| | | } |
| | | |
| | | for idx, _ := range msg.FaceListObject.FaceObject { |
| | | msg.FaceListObject.FaceObject[idx].OtherFeature, _ = pkg.ParseFloor(runDir, floor) |
| | | //if config.ClientConf.AddFloorToFaceId { |
| | | // msg.FaceListObject.FaceObject[idx].FaceID = pkg.GenerateFaceIdContainFloor(face.FaceID, devPos.Pos) |
| | | //} |
| | | } |
| | | } |
| | | |
| | |
| | | appearTime = time.Now() |
| | | } |
| | | |
| | | var devPos models.Positions |
| | | _ = devPos.FindPositionByTime(appearTime.Unix() + 5) // 加5秒电梯关门的时间 |
| | | if devPos.Pos == "" { |
| | | devPos.Pos = "1F" |
| | | } |
| | | runState := nvcs.FindPositionByTime(appearTime.Unix() + 3) // 加3秒电梯关门的时间 |
| | | |
| | | for idx, v := range msg.PersonListObject.PersonObject { |
| | | msg.PersonListObject.PersonObject[idx].BehaviorDescription = devPos.Pos |
| | | if config.ClientConf.AddFloorToFaceId { |
| | | msg.PersonListObject.PersonObject[idx].PersonID = pkg.GenerateFaceIdContainFloor(v.PersonID, devPos.Pos) |
| | | } |
| | | for idx, _ := range msg.PersonListObject.PersonObject { |
| | | msg.PersonListObject.PersonObject[idx].BehaviorDescription = runState.Floor |
| | | //if config.ClientConf.AddFloorToFaceId { |
| | | // msg.PersonListObject.PersonObject[idx].PersonID = pkg.GenerateFaceIdContainFloor(v.PersonID, devPos.Pos) |
| | | //} |
| | | } |
| | | |
| | | b, _ := json.Marshal(msg) |
| | |
| | | |
| | | return |
| | | } |
| | | |
| | | func (c CaptureRepository) PubRecordMessage(deviceId, msgId string) { |
| | | var msg = vo.RecordMsg{ |
| | | CamId: deviceId, |
| | | MsgId: msgId, |
| | | } |
| | | |
| | | logger.Debug("Pub record message %s, %s", deviceId, msgId) |
| | | body, _ := json.Marshal(&msg) |
| | | |
| | | _, err := util.HttpPost(config.ForwardConf.RecordServer, nil, body) |
| | | if err != nil { |
| | | logger.Warn(err.Error()) |
| | | } |
| | | } |