feat: 新增多插件 UI 支持及运行日志集中回传功能

本次提交包含多项功能更新:
1. 为多个插件(xq0002/0003/0004/0008/0010/0011/0020/0031_xq0032/0033/0035/0037/0045_xq0046/0047/0048)新增 UI 界面及配置支持
2. 新增运行日志集中回传功能,客户端自动上传运行日志到中心机集中存储
3. 新增插件分类字段支持,用于场景库分组管理
4. 优化 xq0034/0037/0048 等插件的功能及描述
5. 修复控制面响应兼容问题,支持新旧版本数据格式
6. 新增 xq0033 插件的状态存储模块,用于历史记录管理
7. 优化 CRM 登录窗口模式,支持全屏置顶
This commit is contained in:
2026-10-26 15:42:50 +08:00
parent 9fd687ada8
commit 843ff244a6
453 changed files with 243002 additions and 4493 deletions
@@ -1,5 +1,4 @@
import { Column, Entity, Index, PrimaryColumn, PrimaryGeneratedColumn } from 'typeorm';
/**
* 运行上报(现网 runtime_reports 表)
*/
@@ -143,3 +142,102 @@ export class NotificationEntity {
@Column({ name: 'active', type: 'tinyint', width: 1, default: 1, comment: '1=启用 0=停用' })
active: number;
}
/**
* 运行日志(集中留存,客户端回传,按 run_id 幂等 upsert)。
* 注意:trigger_by 列原名 trigger(MySQL 保留字),改名避免 TypeORM 自动建表/查询语法错误;
* 对外 JSON 字段仍为 trigger(SELECT ... AS trigger)。
*/
@Entity('run_logs')
export class RunLogEntity {
@PrimaryGeneratedColumn({ name: 'id', type: 'bigint', unsigned: true, comment: '记录自增ID' })
id: number;
@Index({ unique: true })
@Column({ name: 'run_id', type: 'varchar', length: 64, comment: '运行ID(客户端生成 32 位 hex,唯一)' })
runId: string;
@Index()
@Column({ name: 'account', type: 'varchar', length: 64, default: '', comment: '运行账号(工号)' })
account: string;
@Index()
@Column({ name: 'device_id', type: 'varchar', length: 64, default: '', comment: '执行机设备ID' })
deviceId: string;
@Index()
@Column({ name: 'plugin_id', type: 'varchar', length: 64, default: '', comment: '插件ID' })
pluginId: string;
@Column({ name: 'name', type: 'varchar', length: 128, default: '', comment: '插件名称' })
name: string;
@Column({ name: 'version', type: 'varchar', length: 32, default: '', comment: '插件版本号' })
version: string;
@Column({ name: 'trigger_by', type: 'varchar', length: 16, default: 'manual', comment: '触发方式:manual=手动 schedule=定时' })
triggerBy: string;
@Column({ name: 'schedule_id', type: 'varchar', length: 64, default: '', comment: '定时任务ID' })
scheduleId: string;
@Index()
@Column({ name: 'status', type: 'varchar', length: 32, default: '', comment: 'running/done/error' })
status: string;
@Column({ name: 'ok', type: 'tinyint', width: 1, default: 0, comment: '是否成功:1=是 0=否' })
ok: number;
@Column({ name: 'error', type: 'text', comment: '错误信息' })
error: string;
@Column({ name: 'summary', type: 'text', comment: '运行结论摘要' })
summary: string;
@Column({ name: 'started', type: 'bigint', unsigned: true, default: 0, comment: '开始时间(epoch 秒)' })
started: number;
@Column({ name: 'finished', type: 'bigint', unsigned: true, default: 0, comment: '结束时间(epoch 秒)' })
finished: number;
@Column({ name: 'duration_sec', type: 'int', unsigned: true, default: 0, comment: '运行时长(秒)' })
durationSec: number;
@Column({ name: 'log_count', type: 'int', unsigned: true, default: 0, comment: '日志条数' })
logCount: number;
@Column({ name: 'logs', type: 'mediumtext', comment: '运行日志全文(JSON 数组 [{t,level,msg}])' })
logs: string;
@Index()
@Column({ name: 'uploaded_at', type: 'datetime', default: () => 'CURRENT_TIMESTAMP', comment: '回传时间' })
uploadedAt: Date;
}
/**
* 客户端壳日志元数据(内容存 logs/shell/<device_id>.log,增量追加)
*/
@Entity('device_logs')
export class DeviceLogEntity {
@PrimaryColumn({ name: 'device_id', type: 'varchar', length: 64, comment: '执行机设备ID(唯一)' })
deviceId: string;
@Index()
@Column({ name: 'account', type: 'varchar', length: 64, default: '', comment: '当前登录账号' })
account: string;
@Column({ name: 'hostname', type: 'varchar', length: 128, default: '', comment: '主机名' })
hostname: string;
@Column({ name: 'client_version', type: 'varchar', length: 32, default: '', comment: '客户端(壳子)版本号' })
clientVersion: string;
@Column({ name: 'size_bytes', type: 'bigint', unsigned: true, default: 0, comment: '已回传壳日志累计字节' })
sizeBytes: number;
@Column({ name: 'last_uploaded_at', type: 'datetime', default: () => 'CURRENT_TIMESTAMP', comment: '最近一次回传时间' })
lastUploadedAt: Date;
@Column({ name: 'updated_at', type: 'datetime', default: () => 'CURRENT_TIMESTAMP', onUpdate: 'CURRENT_TIMESTAMP', comment: '更新时间' })
updatedAt: Date;
}