|
@@ -2,8 +2,10 @@ package parking
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
"strconv"
|
|
"strconv"
|
|
|
|
|
+ "time"
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
+ "wails-app/internal/global"
|
|
|
"wails-app/internal/model/common/response"
|
|
"wails-app/internal/model/common/response"
|
|
|
"wails-app/internal/service/uhf"
|
|
"wails-app/internal/service/uhf"
|
|
|
)
|
|
)
|
|
@@ -13,3 +15,32 @@ func GetChannelEvents(c *gin.Context) {
|
|
|
events := uhf.GetChannelEvents(after)
|
|
events := uhf.GetChannelEvents(after)
|
|
|
response.OkWithData(events, c)
|
|
response.OkWithData(events, c)
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+// SimulateEvent 模拟RFID扫描(测试用)
|
|
|
|
|
+func SimulateEvent(c *gin.Context) {
|
|
|
|
|
+ rfid := c.Query("rfid")
|
|
|
|
|
+ direction := c.Query("direction") // in / out
|
|
|
|
|
+ if rfid == "" {
|
|
|
|
|
+ response.FailWithMessage("rfid参数不能为空", 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,
|
|
|
|
|
+ Direction: direction,
|
|
|
|
|
+ ChannelName: channelName,
|
|
|
|
|
+ Timestamp: time.Now().Unix(),
|
|
|
|
|
+ })
|
|
|
|
|
+ response.OkWithMessage("事件已推送", c)
|
|
|
|
|
+}
|