feat: 新增设备位置追踪与网页管理页面

- 更新服务端默认Lua版本与客户端程序版本至 v1.5.16
- 新增后端API接口用于提交和查询设备位置数据
- 为售票机和检票机添加后台GPS位置同步任务,定期上报设备坐标
- 服务端新增设备位置缓存,并自动清理超过5分钟未更新的过期数据
- 新增网页端设备位置地图页面,支持实时展示、点击查看详情与每分钟自动刷新
This commit is contained in:
2026-07-11 14:58:30 +08:00
parent 2eddb8b84c
commit efc061e471
6 changed files with 211 additions and 19 deletions
+40 -12
View File
@@ -1,7 +1,7 @@
local DEFAULT_SERVER_BASE = "http://ticket.fse-media.group"
local DEFAULT_SERVER_PATH = "/api/tickets/check"
local GATE_OPEN_SECONDS = 2
local VERSION = "v1.5.15"
local VERSION = "v1.5.16"
local VERSION_CHECK_INTERVAL = 5
local CONFIG_PATH = "gate_config.json"
@@ -1498,21 +1498,49 @@ local function processInspectionEvent(eventName, ev)
end
end
local versionTimer = os.startTimer(VERSION_CHECK_INTERVAL)
local function mainLoop()
while true do
local ev = pack(os.pullEvent())
if ev[1] == "ticket_scanned" or ev[1] == "ic_card_scanned" then
processInspectionEvent(ev[1], ev)
os.sleep(0.35)
drawReadyScreen()
end
end
end
while true do
local ev = pack(os.pullEvent())
if ev[1] == "ticket_scanned" or ev[1] == "ic_card_scanned" then
processInspectionEvent(ev[1], ev)
os.sleep(0.35)
drawReadyScreen()
elseif ev[1] == "timer" and ev[2] == versionTimer then
local function backgroundSyncTask()
while true do
sleep(VERSION_CHECK_INTERVAL)
pcall(function()
refreshRemoteLuaVersion(guessBaseFromStatusURL(serverURL))
end)
pcall(checkAndApplyUpdate)
versionTimer = os.startTimer(VERSION_CHECK_INTERVAL)
end
end
local function backgroundLocationSyncTask()
while true do
if gps and type(gps.locate) == "function" then
local x, y, z = gps.locate(2)
if x and y and z then
local label = os.getComputerLabel()
if not label or label == "" then label = "#" .. tostring(os.getComputerID()) end
local payload = {
device_id = label,
type = "Gate",
gate_mode = modeBySide and "bidirectional" or mode,
station_code = stationCodeForSide(nil) or "",
x = x,
y = y,
z = z
}
local serverBase = guessBaseFromStatusURL(serverURL)
pcall(postCheck, serverBase .. '/api/machine-location', payload)
end
end
sleep(60)
end
end
parallel.waitForAny(mainLoop, backgroundSyncTask, backgroundLocationSyncTask)