人员数据采集-远程采集
This commit is contained in:
parent
5aeff6b0d3
commit
005a421d72
|
|
@ -0,0 +1,149 @@
|
||||||
|
package iot
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"myschools.me/suguo/hikvision/iot/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
capture_rule = "/api/v1/open/collectors/remote/rules"
|
||||||
|
capture_idcard = "/api/v1/open/collectors/remote/identities/actions/get"
|
||||||
|
capture_card = "/api/v1/open/collectors/remote/cards/actions/get"
|
||||||
|
capture_fingerprint = "/api/v1/open/collectors/remote/fingerprints/actions/get"
|
||||||
|
capture_face = "/api/v1/open/collectors/remote/faces/actions/get"
|
||||||
|
capture_face_process = "/api/v1/open/collectors/remote/faces/actions/getProgress"
|
||||||
|
)
|
||||||
|
|
||||||
|
// 采集规则配置
|
||||||
|
func CaptureRemoteRuleSet(deviceSerial string, cardNoAdaptive bool, cardNoBytesLen, cardTimeout int) (*model.Hikvision, error) {
|
||||||
|
req := &struct {
|
||||||
|
DeviceSerial string `json:"deviceSerial"`
|
||||||
|
CardRule model.CaptureRemoteRule `json:"cardRule"`
|
||||||
|
}{
|
||||||
|
DeviceSerial: deviceSerial,
|
||||||
|
CardRule: model.CaptureRemoteRule{
|
||||||
|
CardNoAdaptive: cardNoAdaptive,
|
||||||
|
CardNoBytesLen: cardNoBytesLen,
|
||||||
|
CardTimeout: cardTimeout,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := hikvisionRequest("POST", capture_rule+"/create", req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var result = &model.Hikvision{}
|
||||||
|
if err := json.Unmarshal(resp, &result); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取采集规则配置
|
||||||
|
func CaptureRemoteRuleGet(deviceSerial string) (*model.CaptureRemoteRuleGet, error) {
|
||||||
|
|
||||||
|
resp, err := hikvisionRequest("GET", capture_rule+"/get?deviceSerial="+deviceSerial, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var result = &model.CaptureRemoteRuleGet{}
|
||||||
|
if err := json.Unmarshal(resp, &result); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 采集并获取身份证信息
|
||||||
|
func CaptureRemoteIDCardGet(deviceSerial string) (*model.CaptureRemoteIDCardGet, error) {
|
||||||
|
req := &struct {
|
||||||
|
DeviceSerial string `json:"deviceSerial"`
|
||||||
|
}{
|
||||||
|
DeviceSerial: deviceSerial,
|
||||||
|
}
|
||||||
|
resp, err := hikvisionRequest("POST", capture_idcard, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var result = &model.CaptureRemoteIDCardGet{}
|
||||||
|
if err := json.Unmarshal(resp, &result); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 采集并获取卡信息,默认5秒左右超时,如果配置了采集规则,以规则配置接口中cardTimeout的值为准。
|
||||||
|
func CaptureRemoteCardGet(deviceSerial string) (*model.CaptureRemoteCardGet, error) {
|
||||||
|
|
||||||
|
req := &struct {
|
||||||
|
DeviceSerial string `json:"deviceSerial"`
|
||||||
|
}{
|
||||||
|
DeviceSerial: deviceSerial,
|
||||||
|
}
|
||||||
|
resp, err := hikvisionRequest("POST", capture_card, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var result = &model.CaptureRemoteCardGet{}
|
||||||
|
if err := json.Unmarshal(resp, &result); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 采集并获取指纹信息,手指需要进行3次感应,最好在10秒内完成采集。
|
||||||
|
func CaptureRemoteFingerPrintGet(deviceSerial string, fingerprintNo int) (*model.CaptureRemoteFingerPrintGet, error) {
|
||||||
|
|
||||||
|
req := &struct {
|
||||||
|
DeviceSerial string `json:"deviceSerial"`
|
||||||
|
FingerprintNo int `json:"fingerprintNo"` //指纹编号,取值范围:[1~10]
|
||||||
|
}{
|
||||||
|
DeviceSerial: deviceSerial,
|
||||||
|
FingerprintNo: fingerprintNo,
|
||||||
|
}
|
||||||
|
resp, err := hikvisionRequest("POST", capture_fingerprint, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var result = &model.CaptureRemoteFingerPrintGet{}
|
||||||
|
if err := json.Unmarshal(resp, &result); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 采集并获取人脸信息
|
||||||
|
func CaptureRemoteFaceGet(deviceSerial string, infrared bool) (*model.CaptureRemoteFaceGet, error) {
|
||||||
|
|
||||||
|
req := &struct {
|
||||||
|
DeviceSerial string `json:"deviceSerial"`
|
||||||
|
Infrared bool `json:"infrared"`
|
||||||
|
}{
|
||||||
|
DeviceSerial: deviceSerial,
|
||||||
|
Infrared: infrared,
|
||||||
|
}
|
||||||
|
resp, err := hikvisionRequest("POST", capture_face, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var result = &model.CaptureRemoteFaceGet{}
|
||||||
|
if err := json.Unmarshal(resp, &result); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果采集人脸信息接口采集进度不为100,且未返回人脸照片URL时,调用该接口查询采集进度以及获取人脸URL。
|
||||||
|
func CaptureRemoteFaceProcessGet(deviceSerial string) (*model.CaptureRemoteFaceGet, error) {
|
||||||
|
|
||||||
|
resp, err := hikvisionRequest("GET", fmt.Sprintf("%s?deviceSerial=%s", capture_face_process, deviceSerial), nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var result = &model.CaptureRemoteFaceGet{}
|
||||||
|
if err := json.Unmarshal(resp, &result); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
package model
|
||||||
|
|
||||||
|
type CaptureRemoteRule struct {
|
||||||
|
CardNoAdaptive bool `json:"cardNoAdaptive"` //卡号长度自适应
|
||||||
|
CardNoBytesLen int `json:"cardNoBytesLen"` //卡号占字节大小
|
||||||
|
CardTimeout int `json:"cardTimeout"` //设备采集卡超时时长 2000~60000
|
||||||
|
}
|
||||||
|
|
||||||
|
type CaptureRemoteRuleGet struct {
|
||||||
|
Hikvision
|
||||||
|
Data CaptureRemoteRule `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CaptureRemoteIDCardGet struct {
|
||||||
|
Hikvision
|
||||||
|
Data struct {
|
||||||
|
ChnName string `json:"chnName"`
|
||||||
|
EnName string `json:"enName"`
|
||||||
|
Gender string `json:"gender"`
|
||||||
|
Birth string `json:"birth"`
|
||||||
|
Addr string `json:"addr"`
|
||||||
|
IdcardNo string `json:"idcardNo"`
|
||||||
|
IssuingAuthority string `json:"issuingAuthority"`
|
||||||
|
StartDate string `json:"startDate"`
|
||||||
|
EndDate string `json:"endDate"`
|
||||||
|
Nation int `json:"nation"`
|
||||||
|
PassNo string `json:"passNo"`
|
||||||
|
IssueNumber string `json:"issueNumber"`
|
||||||
|
CertificateType string `json:"certificateType"`
|
||||||
|
PermanentResidenceCardNo string `json:"permanentResidenceCardNo"`
|
||||||
|
NationalityOrAreaCode string `json:"nationalityOrAreaCode"`
|
||||||
|
Version string `json:"version"`
|
||||||
|
ReceivingAuthorityCode string `json:"receivingAuthorityCode"`
|
||||||
|
FaceData string `json:"faceData"`
|
||||||
|
Fingerprints []string `json:"fingerprints"`
|
||||||
|
} `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CaptureRemoteCardGet struct {
|
||||||
|
Hikvision
|
||||||
|
Data struct {
|
||||||
|
CardNo string `json:"cardNo"`
|
||||||
|
CardType string `json:"cardType"`
|
||||||
|
} `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CaptureRemoteFingerPrintGet struct {
|
||||||
|
Hikvision
|
||||||
|
Data struct {
|
||||||
|
FingerprintNo int `json:"fingerprintNo"`
|
||||||
|
FingerprintData string `json:"fingerprintData"`
|
||||||
|
FingerprintQuality int `json:"fingerprintQuality"`
|
||||||
|
} `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CaptureRemoteFaceGet struct {
|
||||||
|
Hikvision
|
||||||
|
Data struct {
|
||||||
|
Progress int `json:"progress"`
|
||||||
|
FaceUrl string `json:"faceUrl"`
|
||||||
|
InfraredUrl string `json:"infraredUrl"`
|
||||||
|
} `json:"data"`
|
||||||
|
}
|
||||||
|
|
@ -7,26 +7,55 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestOauth(t *testing.T) {
|
func TestOauth(t *testing.T) {
|
||||||
// r0, err := VoiceTalkSet()
|
deviceserial := "AF8534579"
|
||||||
|
// r0, err := CaptureRemoteRuleSet(deviceserial, true, 0, 50000)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// log.Fatal(err)
|
// log.Fatal(err)
|
||||||
// return
|
// return
|
||||||
// }
|
// }
|
||||||
// fmt.Println(r0)
|
// fmt.Println(r0)
|
||||||
|
|
||||||
r1, err := VoiceTalkInform("2023-11-23T08:00:00+08:00", 1, 101, 2, "request", 3, "outdoor", "AF8534579", 1, 3)
|
// r1, err := CaptureRemoteRuleGet(deviceserial)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Fatal(err)
|
// log.Fatal(err)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
fmt.Println(r1)
|
// fmt.Println(r1)
|
||||||
|
|
||||||
// r2, err := VoiceTalkGet()
|
// r2, err := CaptureRemoteIDCardGet(deviceserial)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// log.Fatal(err)
|
// log.Fatal(err)
|
||||||
// return
|
// return
|
||||||
// }
|
// }
|
||||||
// fmt.Println(r2)
|
// fmt.Println(r2)
|
||||||
|
|
||||||
|
// r3, err := CaptureRemoteCardGet(deviceserial)
|
||||||
|
// if err != nil {
|
||||||
|
// log.Fatal(err)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// fmt.Println(r3)
|
||||||
|
|
||||||
|
// r4, err := CaptureRemoteFingerPrintGet(deviceserial, 1)
|
||||||
|
// if err != nil {
|
||||||
|
// log.Fatal(err)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// fmt.Println(r4)
|
||||||
|
|
||||||
|
r5, err := CaptureRemoteFaceGet(deviceserial, false)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
fmt.Println(r5)
|
||||||
|
|
||||||
|
r6, err := CaptureRemoteFaceProcessGet(deviceserial)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
fmt.Println(r6)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -121,3 +150,26 @@ func TestOauth(t *testing.T) {
|
||||||
// }
|
// }
|
||||||
// fmt.Println(r8)
|
// fmt.Println(r8)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
// r0, err := VoiceTalkSet()
|
||||||
|
// if err != nil {
|
||||||
|
// log.Fatal(err)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// fmt.Println(r0)
|
||||||
|
|
||||||
|
// r1, err := VoiceTalkInform("2023-11-23T08:00:00+08:00", 1, 101, 2, "request", 3, "outdoor", "AF8534579", 1, 3)
|
||||||
|
// if err != nil {
|
||||||
|
// log.Fatal(err)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// fmt.Println(r1)
|
||||||
|
|
||||||
|
// r2, err := VoiceTalkGet()
|
||||||
|
// if err != nil {
|
||||||
|
// log.Fatal(err)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// fmt.Println(r2)
|
||||||
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue