| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- 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) {
- afterID, _ := strconv.ParseUint(c.Query("after_id"), 10, 64)
- if afterID == 0 {
- afterID, _ = strconv.ParseUint(c.Query("after"), 10, 64)
- }
- events := uhf.GetChannelEvents(afterID)
- 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(),
- Status: "completed",
- Message: "模拟通道事件",
- })
- response.OkWithMessage("事件已推送", c)
- }
|