道闸6类核心接口规范 · 统一抽象标准
📷 接口一:车牌识别接口(Plate Recognition)
// 请求
POST /api/v1/gate/recognize
{
"gate_id": "GATE_001",
"image_base64": "base64编码的车牌图片",
"direction": "in", // in=入场, out=出场
"timestamp": 1694736000000
}
// 响应
{
"code": 0,
"plate_number": "闽A12345",
"plate_color": "blue", // blue=蓝牌, green=新能源, yellow=黄牌
"confidence": 0.985, // 识别置信度 0-1
"vehicle_type": "car", // car=小车, truck=货车, motorcycle=摩托车
"recognized_at": "2026-09-15T10:00:00+08:00"
}
核心参数:gate_id(道闸ID)、image_base64(车牌图片)、direction(方向)
返回字段:plate_number(车牌号)、plate_color(车牌颜色)、confidence(置信度)、vehicle_type(车型)
置信度处理:≥0.9自动放行;0.8-0.9二次确认;<0.8人工审核
🎛️ 接口二:道闸控制接口(Gate Control)
// 开闸
POST /api/v1/gate/{gate_id}/open
{
"reason": "plate_recognized", // 开闸原因
"plate_number": "闽A12345",
"operator": "system", // system=系统自动, manual=人工
"timeout": 3000 // 超时时间ms
}
// 关闸
POST /api/v1/gate/{gate_id}/close
// 道闸状态查询
GET /api/v1/gate/{gate_id}/status
{
"gate_id": "GATE_001",
"status": "open", // open=开, closed=关, moving=运动中, fault=故障
"current_angle": 90, // 当前角度
"last_action": "open",
"last_action_at": "2026-09-15T10:00:01+08:00",
"fault_code": null,
"online": true
}
控制指令:open(开闸)、close(关闸)、stop(停止)、reset(复位)
状态枚举:open(开)、closed(关)、moving(运动中)、fault(故障)、offline(离线)
超时控制:开闸指令3秒内未响应,自动重试1次,仍失败触发告警
📋 接口三:通行记录接口(Access Record)
// 通行记录上报(道闸→平台)
POST /api/v1/gate/records
{
"record_id": "REC_20260915_000001",
"gate_id": "GATE_001",
"plate_number": "闽A12345",
"direction": "in", // in=入场, out=出场
"pass_type": "recognized", // recognized=识别放行, manual=人工放行, free=免费放行
"entry_time": "2026-09-15T10:00:00+08:00",
"exit_time": null,
"image_url": "https://cdn.example.com/plate/xxx.jpg",
"confidence": 0.985,
"vehicle_type": "car",
"parking_lot_id": "PLOT_001"
}
// 通行记录查询
GET /api/v1/gate/records?plate_number=闽A12345&start_time=xxx&end_time=xxx&page=1&page_size=20
记录类型:入场记录、出场记录、异常记录(未识别/人工放行/冲卡)
关键字段:record_id(记录ID)、plate_number(车牌号)、direction(方向)、pass_type(放行类型)、entry/exit_time(进出时间)
数据同步:本地缓存+实时上报,断网时本地存储,网络恢复后批量同步
👥 接口四:白名单/计费接口(Whitelist & Billing)
// 白名单查询(车辆到达时查询)
GET /api/v1/gate/whitelist/check?plate_number=闽A12345&gate_id=GATE_001
{
"plate_number": "闽A12345",
"in_whitelist": true,
"whitelist_type": "monthly", // monthly=月卡, vip=VIP, employee=员工, free=免费
"expire_time": "2026-12-31T23:59:59+08:00",
"remaining_times": null, // 次卡剩余次数
"discount_rate": 1.0, // 折扣率
"free_hours": 0 // 免费时长
}
// 计费计算(出场时计算费用)
POST /api/v1/gate/billing/calculate
{
"plate_number": "闽A12345",
"entry_time": "2026-09-15T08:00:00+08:00",
"exit_time": "2026-09-15T10:30:00+08:00",
"parking_lot_id": "PLOT_001",
"vehicle_type": "car"
}
// 响应
{
"duration_minutes": 150,
"free_minutes": 30,
"billable_minutes": 120,
"original_amount": 10.00,
"discount_amount": 0.00,
"final_amount": 10.00,
"currency": "CNY",
"billing_rule_id": "RULE_001"
}
白名单类型:monthly(月卡/季卡/年卡)、vip(VIP会员)、employee(员工)、free(免费车辆)、temp(临时车)
计费规则:按时计费、按次计费、分段计费、封顶计费、免费时长、会员折扣、优惠券
本地缓存:白名单和计费规则定期同步到边缘网关,断网时本地计算
🔔 接口五:事件告警接口(Event & Alarm)
// 事件上报(道闸→平台)
POST /api/v1/gate/events
{
"event_id": "EVT_20260915_000001",
"gate_id": "GATE_001",
"event_type": "fault", // fault=故障, alarm=告警, info=信息
"event_code": "GATE_F_001", // 故障码
"event_name": "道闸电机过载",
"severity": "high", // low=低, medium=中, high=高, critical=紧急
"description": "道闸电机电流超过阈值,可能存在机械故障",
"timestamp": "2026-09-15T10:00:00+08:00",
"device_status": {
"motor_current": 15.2,
"motor_temp": 85,
"power_voltage": 220
}
}
// 告警级别定义
// critical=紧急(安全事故,立即处理):防砸失效、冲卡、设备冒烟
// high=高(影响运营,1小时内处理):道闸故障、识别失效、网络中断
// medium=中(影响体验,4小时内处理):识别率下降、计费异常、设备温度高
// low=低(不影响运营,24小时内处理):设备离线恢复、日志告警、版本更新
事件类型:fault(设备故障)、alarm(安全告警)、info(运行信息)
告警级别:critical(紧急)、high(高)、medium(中)、low(低)
通知渠道:飞书/企微Webhook推送、短信通知(紧急)、APP推送、邮件
⚙️ 接口六:设备管理接口(Device Management)
// 设备注册
POST /api/v1/gate/devices/register
{
"device_id": "GATE_001",
"device_type": "gate", // gate=道闸, camera=摄像头, loop=地感, infrared=红外
"vendor": "jieshun", // 厂商
"model": "JS-PB-001",
"firmware_version": "v2.3.1",
"ip_address": "192.168.1.100",
"port": 8080,
"protocol": "tcp_json", // 协议类型
"parking_lot_id": "PLOT_001",
"location": "入口1号车道"
}
// 设备心跳
POST /api/v1/gate/devices/heartbeat
{
"device_id": "GATE_001",
"timestamp": 1694736000000,
"status": "online",
"cpu_usage": 23.5,
"memory_usage": 45.2,
"network_latency": 15
}
// 固件升级
POST /api/v1/gate/devices/{device_id}/upgrade
{
"firmware_url": "https://cdn.example.com/firmware/v2.4.0.bin",
"firmware_version": "v2.4.0",
"md5": "abc123...",
"upgrade_mode": "auto" // auto=自动, manual=手动
}
设备类型:gate(道闸主机)、camera(识别摄像头)、loop(地感线圈)、infrared(红外对射)、radar(雷达)、screen(显示屏)
管理功能:注册、心跳、状态监控、参数配置、固件升级、远程重启、日志查询
批量管理:支持按停车场、按厂商、按设备类型批量操作