Selaa lähdekoodia

feat: 通道事件支持车牌推送——plate_number字段,模拟接口同时支持rfid+plate

lq 1 kuukausi sitten
vanhempi
commit
dfb9bb2448

+ 2 - 1
frontend/src/view/parking/entryExit.vue

@@ -139,7 +139,8 @@ async function pollEvents() {
     if (r.code === 0 && r.data && r.data.length > 0) {
       const latest = r.data[r.data.length - 1]
       lastEventTs.value = latest.timestamp
-      queryForm.rfid_tag = latest.rfid_tag
+      if (latest.rfid_tag) queryForm.rfid_tag = latest.rfid_tag
+      if (latest.plate_number) queryForm.plate_number = latest.plate_number
       activeTab.value = latest.direction === 'out' ? 'exit' : 'entry'
       queryVehicle()
     }

+ 5 - 4
internal/api/v1/parking/channel_event.go

@@ -16,19 +16,19 @@ func GetChannelEvents(c *gin.Context) {
 	response.OkWithData(events, c)
 }
 
-// SimulateEvent 模拟RFID扫描(测试用)
+// SimulateEvent 模拟RFID/车牌识别(测试用)
 func SimulateEvent(c *gin.Context) {
 	rfid := c.Query("rfid")
+	plate := c.Query("plate")
 	direction := c.Query("direction") // in / out
-	if rfid == "" {
-		response.FailWithMessage("rfid参数不能为空", c)
+	if rfid == "" && plate == "" {
+		response.FailWithMessage("rfid或plate参数不能同时为空", c)
 		return
 	}
 	if direction == "" {
 		direction = "in"
 	}
 
-	// 获取第一个通道名
 	var channelName string
 	global.GVA_DB.Raw("SELECT channel_name FROM channel LIMIT 1").Scan(&channelName)
 	if channelName == "" {
@@ -38,6 +38,7 @@ func SimulateEvent(c *gin.Context) {
 	uhf.PushChannelEvent(uhf.ChannelEvent{
 		DeviceCode:  "SIM-001",
 		RFIDTag:     rfid,
+		PlateNumber: plate,
 		Direction:   direction,
 		ChannelName: channelName,
 		Timestamp:   time.Now().Unix(),

+ 2 - 1
internal/service/uhf/reader.go

@@ -30,10 +30,11 @@ type Reader interface {
 	ReleaseRelay2() error
 }
 
-// ChannelEvent 通道事件(RFID 识别到标签后推送给前端)
+// ChannelEvent 通道事件(RFID/车牌识别后推送给前端)
 type ChannelEvent struct {
 	DeviceCode  string `json:"device_code"`
 	RFIDTag     string `json:"rfid_tag"`
+	PlateNumber string `json:"plate_number"`
 	Direction   string `json:"direction"`
 	ChannelName string `json:"channel_name"`
 	Timestamp   int64  `json:"timestamp"`