| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- package parking
- import (
- "strconv"
- "time"
- "github.com/gin-gonic/gin"
- "wails-app/internal/global"
- "wails-app/internal/model/common/response"
- "wails-app/internal/service/uhf"
- )
- func GetChannelEvents(c *gin.Context) {
- after, _ := strconv.ParseInt(c.Query("after"), 10, 64)
- events := uhf.GetChannelEvents(after)
- response.OkWithData(events, c)
- }
- // SimulateEvent 模拟RFID/车牌识别(测试用)
- func SimulateEvent(c *gin.Context) {
- rfid := c.Query("rfid")
- plate := c.Query("plate")
- direction := c.Query("direction") // in / out
- 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 == "" {
- channelName = "测试通道"
- }
- uhf.PushChannelEvent(uhf.ChannelEvent{
- DeviceCode: "SIM-001",
- RFIDTag: rfid,
- PlateNumber: plate,
- Direction: direction,
- ChannelName: channelName,
- Timestamp: time.Now().Unix(),
- })
- response.OkWithMessage("事件已推送", c)
- }
|