结果列表
+ Search Results +请输入关键词开始查询。
+diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 1ff3991..0000000 --- a/.gitignore +++ /dev/null @@ -1,27 +0,0 @@ -# Node.js -node_modules/ -npm-debug.log -yarn-error.log - -# IDE / Editor -.vscode/ -.idea/ -*.swp -*.swo -.DS_Store - -# Project Specific (Logs & Cache) -logs/ -.dbg/ -.last_update_ts -.last_update_version -config.json -gate_config.json -web/data/ - -# Environment Variables -.env -.env.local - -# Trae AI -.trae/ diff --git a/gate.lua b/gate.lua index bbee6ea..36a731a 100644 --- a/gate.lua +++ b/gate.lua @@ -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.18" +local VERSION = "v1.5.15" local VERSION_CHECK_INTERVAL = 5 local CONFIG_PATH = "gate_config.json" @@ -192,7 +192,6 @@ local function checkAndApplyUpdate() print("OTA Update Error: " .. tostring(res)) term.setTextColor(colors.white) end - sleep(3) end else lastUpdateError = "loadfile failed: " .. tostring(err) @@ -201,7 +200,6 @@ local function checkAndApplyUpdate() print("OTA Update Error: " .. tostring(err)) term.setTextColor(colors.white) end - sleep(3) end isUpdating = false @@ -1500,49 +1498,21 @@ local function processInspectionEvent(eventName, ev) end end -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 +local versionTimer = os.startTimer(VERSION_CHECK_INTERVAL) -local function backgroundSyncTask() - while true do - sleep(VERSION_CHECK_INTERVAL) + + +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 pcall(function() refreshRemoteLuaVersion(guessBaseFromStatusURL(serverURL)) end) pcall(checkAndApplyUpdate) + versionTimer = os.startTimer(VERSION_CHECK_INTERVAL) end end - -local function backgroundLocationSyncTask() - sleep(5) - local x, y, z - if gps and type(gps.locate) == "function" then - x, y, z = gps.locate(2) - end - 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) - while true do - sleep(86400) - end -end - -parallel.waitForAny(mainLoop, backgroundSyncTask, backgroundLocationSyncTask) diff --git a/server/routes/api.js b/server/routes/api.js index 93773d2..01389fb 100644 --- a/server/routes/api.js +++ b/server/routes/api.js @@ -163,33 +163,6 @@ router.get('/check-update', (req, res) => { res.json({ update_counter: globalUpdateCounter }); }); -router.post('/machine-location', async (req, res) => { - const data = req.body || {}; - if (!data.device_id) return res.status(400).json({ ok: false, error: 'device_id required' }); - if (!data.station && data.station_code) { - data.station = resolveStationName(data.station_code); - } - await DataService.updateMachineLocation(data.device_id, data); - res.json({ ok: true }); -}); - -router.get('/machine-locations', (req, res) => { - const locs = DataService.getMachineLocations() || {}; - res.json({ ok: true, data: locs }); -}); - -router.put('/machine-location/:id', async (req, res) => { - const id = req.params.id; - const data = req.body || {}; - const current = DataService.getMachineLocations()[id]; - if (!current) return res.status(404).json({ ok: false, error: 'machine not found' }); - if (!data.station && data.station_code) { - data.station = resolveStationName(data.station_code); - } - await DataService.updateMachineLocation(id, data); - res.json({ ok: true }); -}); - // Config router.get('/config', (req, res) => { const cfg = DataService.getConfig(); diff --git a/server/routes/public.js b/server/routes/public.js index 2d1a13a..311c0ae 100644 --- a/server/routes/public.js +++ b/server/routes/public.js @@ -224,11 +224,6 @@ router.get('/fares/query', (req, res) => { } }); -router.get('/machine-locations', (req, res) => { - const locs = DataService.getMachineLocations() || {}; - res.json({ ok: true, data: locs }); -}); - router.get('/config', (req, res) => { const cfg = DataService.getConfig(); res.json({ diff --git a/server/services/data.js b/server/services/data.js index 3b3dbf8..78ac335 100644 --- a/server/services/data.js +++ b/server/services/data.js @@ -22,8 +22,8 @@ const pool = mysql.createPool({ }); const DEFAULT_LUA_VERSIONS = { - ticketmachine: 'v1.5.18', - gate: 'v1.5.18' + ticketmachine: 'v1.5.8', + gate: 'v1.5.8' }; function normalizeLuaVersions(input) { @@ -64,8 +64,7 @@ const cache = { icCardIndex: {}, icCardEvents: [], statsTicket: [], - statsGate: [], - machineLocations: {} + statsGate: [] }; const DataService = { @@ -95,9 +94,6 @@ const DataService = { if (configs.length > 0) cache.config = normalizeConfig(configs[0].v); else await conn.query('INSERT INTO kv_store (k, v) VALUES (?, ?)', ['config', JSON.stringify(cache.config)]); - const [machLocs] = await conn.query('SELECT v FROM kv_store WHERE k = ?', ['machine_locations']); - if (machLocs.length > 0) cache.machineLocations = machLocs[0].v || {}; - const [stations] = await conn.query('SELECT data FROM stations'); cache.stations = stations.map(r => r.data); @@ -526,19 +522,6 @@ const DataService = { }), saveExport: () => { try { fs.writeFileSync(paths.export, JSON.stringify(DataService.buildExportPayload(), null, 2)); } catch(e){} - }, - - getMachineLocations: () => cache.machineLocations, - updateMachineLocation: async (deviceId, data) => { - cache.machineLocations[deviceId] = { - ...cache.machineLocations[deviceId], - ...data, - last_update_ts: Date.now() - }; - try { - await pool.query('INSERT INTO kv_store (k, v) VALUES (?, ?) ON DUPLICATE KEY UPDATE v = VALUES(v)', - ['machine_locations', JSON.stringify(cache.machineLocations)]); - } catch(e) { console.error('updateMachineLocation error', e); } } }; diff --git a/ticketmachine.lua b/ticketmachine.lua index 410f57d..5ca5564 100644 --- a/ticketmachine.lua +++ b/ticketmachine.lua @@ -1,6 +1,6 @@ local CURRENT_STATION_CODE = 'Ticket-Machine' local API_BASE = 'http://ticket.fse-media.group/api' -local VERSION = 'v1.5.18' +local VERSION = 'v1.5.15' local UPDATE_CHECK_INTERVAL = 5 -- ########################### @@ -722,7 +722,6 @@ local function checkAndApplyUpdate() print("OTA Update Error: " .. tostring(res)) term.setTextColor(colors.white) end - sleep(3) end else lastUpdateError = "loadfile failed: " .. tostring(err) @@ -731,7 +730,6 @@ local function checkAndApplyUpdate() print("OTA Update Error: " .. tostring(err)) term.setTextColor(colors.white) end - sleep(3) end isUpdating = false @@ -777,26 +775,7 @@ local function backgroundTicketUploadTask() end end -local function backgroundLocationSyncTask() - sleep(5) - local x, y, z - if gps and type(gps.locate) == "function" then - x, y, z = gps.locate(2) - end - local payload = { - device_id = currentDeviceId(), - type = "TicketMachine", - station = (CFG.current_station and (CFG.current_station.en_name or CFG.current_station.name)) or state.stationName, - station_code = state.stationCode or CURRENT_STATION_CODE, - x = x, - y = y, - z = z - } - postJSONResult(API_BASE .. '/machine-location', payload) - while true do - sleep(86400) - end -end + -- ########################### -- Data logic & Config @@ -2549,4 +2528,4 @@ local function mainPageLoop() end end -parallel.waitForAny(mainPageLoop, backgroundSyncTask, backgroundTicketUploadTask, backgroundPeripheralTask, backgroundLocationSyncTask) +parallel.waitForAny(mainPageLoop, backgroundSyncTask, backgroundTicketUploadTask, backgroundPeripheralTask) diff --git a/web/home.html b/web/home.html index bea0eea..8e6be64 100644 --- a/web/home.html +++ b/web/home.html @@ -39,7 +39,6 @@ 车票查询 IC 卡查询 线上购卡 - 机器位置 diff --git a/web/ic-card-order.html b/web/ic-card-order.html index 299b47b..937c815 100644 --- a/web/ic-card-order.html +++ b/web/ic-card-order.html @@ -40,7 +40,6 @@ 车票查询 IC 卡查询 线上购卡 - 机器位置 diff --git a/web/ic-card-search.html b/web/ic-card-search.html index ec4258b..296b4ad 100644 --- a/web/ic-card-search.html +++ b/web/ic-card-search.html @@ -40,7 +40,6 @@ 车票查询 IC 卡查询 线上购卡 - 机器位置 diff --git a/web/index.html b/web/index.html index f965989..4c5b4fe 100644 --- a/web/index.html +++ b/web/index.html @@ -64,9 +64,6 @@
- @@ -644,99 +641,6 @@ - -机器位置与状态 (每 60 秒自动更新)
- -实时查看所有售票机和检票机的位置及状态。
+ TICKET SEARCH +输入完整票号、起终点、日期或关键词,左侧浏览结果,右侧查看票据详情与最近流转记录。
可直接输入完整票号,也可输入起点、终点或日期关键字进行模糊检索。
+ +请输入关键词开始查询。
+从左侧选择一张车票以查看详情。
+