feat: 优化设备标识识别与单程票检票逻辑
- 升级项目版本至v1.0.16 - 重构多文件的设备ID标准化逻辑,新增空格修剪、大小写不敏感处理,支持更多设备类型 - 基于事件类型智能区分闸机、充值机与售票机 - 新增站点线路校验工具,修复单程票检票的站点合法性校验 - 修正单程票票价计算使用实际进站站点而非初始起点 - 添加事件元数据格式化的空值安全检查
This commit is contained in:
+16
-5
@@ -191,11 +191,22 @@
|
||||
const formatIcCardEventUnified = (ev) => {
|
||||
const type = String(ev?.type || '').toLowerCase();
|
||||
const action = String(ev?.action || '').toLowerCase();
|
||||
let deviceId = ev?.device || ev?.device_id || ev?.["设备编号"] || ev?.["机器ID"] || '---';
|
||||
if (/^\d+$/.test(deviceId)) deviceId = 'ticket_machine';
|
||||
if (deviceId === 'ticket_machine') deviceId = '售票机';
|
||||
if (deviceId === 'gate') deviceId = '闸机';
|
||||
if (deviceId === 'refill_machine') deviceId = '充值机';
|
||||
let deviceId = String(ev?.device || ev?.device_id || ev?.["设备编号"] || ev?.["机器ID"] || '---').trim();
|
||||
const dStr = deviceId.toLowerCase();
|
||||
|
||||
if (dStr === 'gate') {
|
||||
deviceId = '闸机';
|
||||
} else if (dStr === 'refill_machine') {
|
||||
deviceId = '充值机';
|
||||
} else if (dStr === 'ticket_machine' || dStr === 'ticket_vending_machine' || /^\d+$/.test(dStr) || dStr.includes('computer') || dStr === 'unknown') {
|
||||
if (type === 'entry' || action === 'entry' || type === 'exit' || action === 'exit' || type === 'check') {
|
||||
deviceId = '闸机';
|
||||
} else if (type === 'topup' || type === 'refill' || action === 'topup' || type === '充值') {
|
||||
deviceId = '充值机';
|
||||
} else {
|
||||
deviceId = '售票机';
|
||||
}
|
||||
}
|
||||
const timeStr = formatTime(ev?.ts);
|
||||
const balance = ev?.balance ?? ev?.["余额"] ?? 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user