chore(backend,frontend): 移除设备位置管理全链路功能与相关代码
- 删除后端所有机器位置相关的API接口、缓存逻辑与后台同步任务 - 移除前端的机器位置导航入口、地图页面与管理代码 - 将原机器地图页面重构为车票查询页面 - 调整Lua程序的默认版本号 - 删除无用的.gitignore文件 - 优化前端页面的代码格式与导航结构
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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({
|
||||
|
||||
+3
-20
@@ -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); }
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user