fix: 修复票据详情设备ID缺失并优化自动更新逻辑

- 为票据详情接口添加设备字段兼容映射,支持从e.device/e.device_id/e.detail?.device获取值
- 更新设备ID缺失问题的调试文档,标记已验证的假设并补充最终结论
- 优化售票机和闸机的自动更新逻辑:缩短版本检查间隔至5秒,添加更新中状态标识,改为事件触发更新
This commit is contained in:
2026-07-10 21:32:17 +08:00
parent 5f184bf184
commit f1cdfe3a84
4 changed files with 64 additions and 28 deletions
+36 -9
View File
@@ -2,7 +2,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.10"
local VERSION_CHECK_INTERVAL = 60
local VERSION_CHECK_INTERVAL = 5
local CONFIG_PATH = "gate_config.json"
@@ -93,6 +93,7 @@ local serverLastChangeTs = 0
local expectedGateVersion = nil
local versionMismatch = nil
local pendingGateUpdate = false
local isUpdating = false
local gateBusyUntilTs = 0
local function nowMs()
@@ -163,7 +164,11 @@ local function drawVersionIndicator(w)
if #s == 0 then return end
if w < #s then return end
local markerColor = colors.yellow
if versionMismatch == true then
local markerText = "*"
if isUpdating then
markerColor = colors.yellow
markerText = "^ing"
elseif versionMismatch == true then
markerColor = colors.red
elseif versionMismatch == false then
markerColor = colors.lime
@@ -172,9 +177,9 @@ local function drawVersionIndicator(w)
termDev.setTextColor(colors.gray)
termDev.setCursorPos(1, 1)
termDev.write(s)
if w >= (#s + 1) then
if w >= (#s + #markerText) then
termDev.setTextColor(markerColor)
termDev.write("*")
termDev.write(markerText)
end
termDev.setTextColor(colors.white)
end
@@ -1374,6 +1379,20 @@ end
local versionTimer = os.startTimer(VERSION_CHECK_INTERVAL)
-- 启动时不再自动触发更新检查逻辑,等待事件触发
-- if pendingGateUpdate and isGateIdleForUpdate() then
-- isUpdating = true
-- drawReadyScreen()
-- os.sleep(0.5)
-- local ok, updated = pcall(runSilentGateUpdate)
-- if ok and updated then
-- os.reboot()
-- return
-- end
-- isUpdating = false
-- drawReadyScreen()
-- end
while true do
local ev = pack(os.pullEvent())
if ev[1] == "ticket_scanned" or ev[1] == "ic_card_scanned" then
@@ -1381,21 +1400,29 @@ while true do
processInspectionEvent(ev[1], ev)
os.sleep(0.35)
drawReadyScreen()
elseif ev[1] == "trigger_update" then
pendingGateUpdate = true
elseif ev[1] == "timer" and ev[2] == versionTimer then
pcall(function()
refreshRemoteLuaVersion(guessBaseFromStatusURL(serverURL))
end)
if versionMismatch == true then
pendingGateUpdate = true
elseif versionMismatch == false then
pendingGateUpdate = false
end
-- 取消自动标记更新,仅由外部事件(例如手动控制台)触发时处理
-- if versionMismatch == true then
-- pendingGateUpdate = true
-- elseif versionMismatch == false then
-- pendingGateUpdate = false
-- end
if pendingGateUpdate and isGateIdleForUpdate() then
isUpdating = true
drawReadyScreen()
os.sleep(0.5)
local ok, updated = pcall(runSilentGateUpdate)
if ok and updated then
os.reboot()
return
end
isUpdating = false
pendingGateUpdate = false
end
drawReadyScreen()
versionTimer = os.startTimer(VERSION_CHECK_INTERVAL)