Commit Graph

5 Commits

Author SHA1 Message Date
lzh
3a3f7b78d4 refactor(video): 预置 AI 算法改为 SQL 种子数据,移除 @PostConstruct 初始化
原 AiAlgorithmServiceImpl.initPresetAlgorithms() 在 @PostConstruct
里插入 4 条预置算法,带来两个问题:
1. 启动时无登录上下文,MP 自动填充 creator 失效 → 启动失败
2. 算法清单硬编码在 Java 代码,迭代要重编译发布

改为 video.sql 种子数据管理:
- video.sql 的预置算法 INSERT 扩展为 4 条(leave_post / intrusion /
  illegal_parking / vehicle_congestion),参数 schema 与边缘端对齐
- 使用 ON DUPLICATE KEY UPDATE 保证幂等:新库初始化 + 存量库升级
  都走同一条语句,param_schema / description 会被自动校正
- 保留用户侧可修改的字段(is_active / global_params)不被覆盖

代码层:
- 删除 initPresetAlgorithms() 方法与 PRESET_ALGORITHMS 静态 Map
- 删除 SYSTEM_USER 常量
- 删除 @PostConstruct / HashMap 相关 import
- 保留 syncFromEdge() 作为边缘端主动同步的运行时入口

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 13:54:39 +08:00
lzh
0ca1adf2a4 refactor(video): P2 应用层时间字段 varchar → datetime / String → LocalDateTime
SQL 类型优化(应用层生成的业务时间改为标准 datetime):
- video_ai_edge_device: last_heartbeat / updated_at
- video_ai_config_log: updated_at
- video_ai_config_snapshot: created_at
- video_ai_algorithm: sync_time
- video_ai_alert: received_at
- video_media_server: last_keepalive_time

DO 字段 String → LocalDateTime 对齐:AiEdgeDevice / AiConfigLog /
AiConfigSnapshot / AiAlgorithm / AiAlert / MediaServer

调用点适配:
- Service 层 new Date() 字符串格式化赋值统一改为 LocalDateTime.now()
- AiAlertController.edgeReport / MqttService.handleAlert 新增
  parseEventTime / parseTimestamp 私有方法,外部字符串防御性解析

保留 varchar(本批次暂不动,SIP 协议原生字符串,改动涉及 72+ 处
Mapper 与 SIP 处理器,单独迭代):
- video_device.register_time / keepalive_time
- video_device_channel.end_time / gps_time
- video_device_mobile_position.time
- video_stream_push.push_time

编译通过(mvn compile BUILD SUCCESS)。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-21 12:32:23 +08:00
lzh
64dcdd8d4c refactor(video): P1 类型规范化 — varchar 数值转 int / Integer 布尔转 Boolean
SQL 类型修正(数值语义列不再用 varchar):
- video_platform: device_port / expires / keep_timeout varchar(50) → int
- video_platform_channel: custom_cert_num / custom_end_time varchar(50) → int

DO 布尔语义字段 Integer → Boolean(SQL 早已是 tinyint(1),DO 对齐语义):
- AiAlgorithm.isActive
- AiRoi.enabled
- AiRoiAlgoBind.enabled
同步修复 ~20 处调用点的布尔判断,setEnabled(1) → setEnabled(true),
getEnabled() == 1 → Boolean.TRUE.equals(getEnabled())

MediaServer.hookAliveInterval Float → Integer(SQL 是 int,Float 精度丢失)
同步修复 MediaConfig、ABL/ZLM 两个 StatusManager 的 10F → 10 字面量

编译通过(mvn compile BUILD SUCCESS)。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-21 12:13:56 +08:00
lzh
1698c71d84 fix(video): P0 修复 @TableName 映射错误、字段命名、补缺列与 exist=false
@TableName 修正:
- CommonGBChannel: "video_device_channel" → "video_common_gb_channel"
- DeviceChannel: 显式加 @TableName("video_device_channel")
- PlatformChannel: 补充 @TableName("video_platform_channel")
  避免因继承 CommonGBChannel 而写入错误表

字段命名规范化(修复驼峰转 snake_case 错位):
- CommonGBChannel.recordPLan → recordPlanId(对应 record_plan_id)
- MediaServer.httpSSlPort / flvSSLPort / wsFlvSSLPort
  → httpSslPort / flvSslPort / wsFlvSslPort
  (原命名 L 大写/双大写导致转 snake 变 http_s_sl_port)
- 同步更新 Mapper SQL 中的 #{xxx} 引用和 ZLM/ABL 节点服务调用点

@TableField(exist=false) 标注(JOIN 显示字段/业务计算值/内存对象):
- DeviceChannel: parentDeviceId、parentName、ptzTypeText
- DeviceAlarm: deviceName、alarmPriorityDescription、alarmMethodDescription、
  alarmTypeDescription
- AiAlert: cameraName、roiName
- Device: sipTransactionInfo
- MobilePosition: channelDeviceId
- StreamPush: uniqueKey

补齐 SQL 缺失列(需持久化的业务状态字段):
- video_device: channel_count
- video_platform: channel_count / catalog_subscribe / alarm_subscribe
  / mobile_position_subscribe
- video_media_server: status / last_keepalive_time
- video_cloud_record: reserve
- video_device_mobile_position.channel_id: varchar(50) → bigint
  (DO 字段是 Long,作为外键引用 video_device_channel.id)

补齐 DO 缺失字段:
- AiAlgorithm: 新增 globalParams(对应 SQL global_params)
- StreamPush: 新增 status(对应 SQL status)

编译通过(mvn compile BUILD SUCCESS)。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-21 12:07:47 +08:00
lzh
43becf998c refactor(video): projectId 两级隔离适配 + SQL 融合到 video.sql
SQL 融合:
- sql/mysql/video.sql 作为最终主脚本(26 张表),整合用户改造版表前缀 video_
  与 cherry-pick 版的框架字段(tenant_id/creator/updater/deleted/datetime)
- 新增 video_ai_camera_snapshot(AI 抓拍)、video_common_gb_channel(国标通道抽象)
- 删除旧的 aiot-video.sql(被 video.sql 替代)
- 17 张业务表 + 6 张 AI 业务表加 project_id 列(项目级隔离)
- 2 张字典表(video_ai_algorithm/video_ai_algo_template)仅租户级
- video_media_server 全局共享,无多租户字段

代码改造:
- 21 个 DO 的 @TableName 从 wvp_* 改为 video_*
- 16 个业务 DO 改继承 ProjectBaseDO(StreamProxy/StreamPush 通过
  CommonGBChannel 自动获得),字典 DO 保留 TenantBaseDO,
  MediaServer 保留 BaseDO
- 28 个 Mapper/Provider 的 SQL 表名全部更新为 video_*
- application.yaml 新增 tenant.ignore-project-tables 配置,
  列出 video_media_server/video_ai_algorithm/video_ai_algo_template
  不参与项目隔离
- 编译通过(mvn compile BUILD SUCCESS)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-21 11:10:27 +08:00