核对日期:2026-06-18 核对范围:
sql/目录下全部初始化脚本 +sql/migrations/2026-06-17-autofocus-data-layer.sql核对对象:各微服务 MyBatis 实体/Mapper(@TableName)、C# 控制端 SqlSugar 实体([SugarColumn]) 性质:只读核对,未改动任何 SQL/代码 结论摘要:base 脚本表名覆盖基本一致;本次对焦改造的列在“中央端 MySQL(Java tl-control)”侧完全缺失,是本次最关键的不一致。🔄 校正注(2026-06-18 体检补记):上面"中央端列完全缺失"为核对时点结论;V-047 已补全——Java tl-control 实体现已含对焦列(
TlSetting.java:289 focus_layer_spacing_pulse / :295 focus_layer_count、HouseWellSetting.java:59 move_down_layer / :82 focus_layer_spacing_pulse / :88 focus_layer_count),下发 VO/DTO/mapper 与 C# DTO 重载同步补齐,随四微服务编译通过。该项不一致已消解,运行/真机待验(V-047/V-064)。本节下文逐列核对保留为历史依据。
| sql 脚本 | 目标库 | 微服务 | 数据源(jdbc) | 脚本表数 | 代码 @TableName 覆盖 |
|---|---|---|---|---|---|
aivfo-auth.sql |
aivfo-auth |
aivfo-gateway(认证) | — | 4 (middle/permission/role/user) | 4 全覆盖 ✅ |
aivfo_services.sql |
aivfo_services |
aivfo-service | jdbc:mysql://.../aivfo_services |
2 (alarm_contacts/tdi_log) | ⚠ 见 §四-3:代码实际只用 msg_send_info,脚本里的两表无对应实体 |
aivfo-tl.sql(中划线) |
aivfo-tl |
aivfo-data-transmission | jdbc:mysql://.../aivfo-tl |
4 (video/video_pictures/video_splice/video_update) | ⚠ 见 §四-2:另有 picture/picture_identify_result DAO 指向同库但脚本无此两表 |
aivfo_tl.sql(下划线) |
aivfo_tl |
aivfo-business-manage | (加密 jdbcUrl) | 25 (病例/胚胎/字典) | ⚠ 见 §四-1:identify_key 实体/Mapper 在用,但脚本里是 mark_key,无 identify_key 表 |
aivfo_tl_setting.sql |
aivfo_tl_setting |
aivof-tl-control | (加密 jdbcUrl) | 17 (告警/区域/拍照设置) | 15 个 @TableName 全部在脚本中存在 ✅ |
log.sql |
log |
aivfo-log 框架 | — | 1 (system_log) | 框架表,未逐核 |
quartz.sql |
quartz |
aivfo-quartz 框架 | — | 11 (tqrtz*) | 框架表,未逐核 |
C# 控制端(ivf_tl_control_2.0)使用本地 SQLite(
DependFile\DB\aivfoTL.db,见AppData.cs:86),不连上述 MySQL;表通过 SqlSugar 实体映射。详见 §二、§三。
对比对象:
sql/migrations/2026-06-17-autofocus-data-layer.sql 的 CREATE TABLE house_autofocus_calibrationivf_tl_control_2.0/ivf_tl_Entity/DBEntitys/HouseAutofocusCalibrationDB.cs([SugarTable("house_autofocus_calibration")])| 迁移脚本列 | 类型(MySQL) | C# 属性 | C# 映射列名 | C# 类型 | 一致性 |
|---|---|---|---|---|---|
| id | bigint AI PK | id | id (PK,Identity) | long | ✅ |
| tl_sn | varchar(255) NOT NULL | tlSn | tl_sn | string | ✅ |
| house_sn | int NOT NULL | houseSn | house_sn | int | ✅ |
| well_sn | int NOT NULL | wellSn | well_sn | int | ✅ |
| scene | int NOT NULL | scene | scene | int | ✅ |
| focus_z | int NOT NULL | focusZ | focus_z | int | ✅ |
| exposure | int NULL | exposure | exposure | int? | ✅ |
| horizontal_pulse | int NULL | horizontalPulse | horizontal_pulse | int? | ✅ |
| peak_ratio | decimal(10,3) NULL | peakRatio | peak_ratio | decimal? | ✅ |
| circle_found | tinyint NULL | circleFound | circle_found | int? | ✅ (tinyint↔int 兼容) |
| center_offset_pct | decimal(10,3) NULL | centerOffsetPct | center_offset_pct | decimal? | ✅ |
| calib_time | datetime NOT NULL | calibTime | calib_time | DateTime | ✅ |
| source | varchar(32) NOT NULL DEFAULT 'LOCAL_JSON' | source | source | string | ✅ (默认值仅脚本侧) |
| note | varchar(255) NULL | note | note | string | ✅ |
| create_by | varchar(255) NULL | createBy | create_by | string | ✅ |
| create_time | datetime NULL | createTime | create_time | DateTime? | ✅ |
| update_by | varchar(255) NULL | updateBy | update_by | string | ✅ |
| update_time | datetime NULL | updateTime | update_time | DateTime? | ✅ |
| deleted | timestamp NULL | deleted | deleted | DateTime? | ✅ |
| platform_id | int NULL | platformId | platform_id | int? | ✅ |
结论:house_autofocus_calibration 表 20 列与 C# 实体逐列完全一致 ✅。
补充说明:
DBService.StartDbService() → Db.CodeFirst.InitTables(typeof(HouseAutofocusCalibrationDB)) 自动建表(DBService.cs:59),CREATE TABLE IF NOT EXISTS,已建则不动。这是 sql 目录里唯一一处由 C# CodeFirst 建、且不需要手工跑迁移脚本的表(本地侧)。house_autofocus_calibration(全仓 grep 0 命中)——即中央端这张表当前没有服务读写它,只是“预留镜像位”。属设计预期(真相源在机旁 calibration.json),非缺陷,但需知晓。TLSettingDB.cs| 迁移脚本新增列 | 类型 | 默认 | C# 属性(TLSettingDB) | 一致性 |
|---|---|---|---|---|
| focus_layer_spacing_pulse | int NULL | NULL | int? focusLayerSpacingPulse |
✅ |
| focus_layer_count | int NOT NULL | 5 | int? focusLayerCount |
⚠ 列名/类型对应;脚本 NOT NULL+默认5,C# 为可空(IsNullable=true)。SQLite 本地缓存可空属设计,但与 MySQL NOT NULL 语义不同 |
| focus_layer_down | int NOT NULL | 2 | int? focusLayerDown |
⚠ 同上(脚本 NOT NULL,C# 可空) |
| focus_peak_ratio_threshold | decimal(10,3) NOT NULL | 1.200 | decimal? focusPeakRatioThreshold |
⚠ 同上(脚本 NOT NULL,C# 可空) |
| local_autofocus_enabled | int NOT NULL | 0 | int localAutofocusEnabled (非空) |
✅ |
C# 端列名映射:未写 [SugarColumn(ColumnName=...)],沿用本表 camelCase 直映风格([SugarTable("TLSettingDB")],整表是 camelCase 列名,与 MySQL 蛇形不同库不同表,互不冲突)。
HouseWellSettingDB.cs| 迁移脚本新增列 | 类型 | C# 属性(HouseWellSettingDB) | 一致性 |
|---|---|---|---|
| focus_layer_spacing_pulse | int NULL | int? focusLayerSpacingPulse |
✅ |
| focus_layer_count | int NULL | int? focusLayerCount |
✅ |
C# 端同样 camelCase 直映,[SugarTable("HouseWellSettingDB")]。下移层数复用既有 moveDownLayer,未新增列,与脚本注释一致 ✅。
这是本次核对发现的最重要问题,务必关注:
| 维度 | 现状 |
|---|---|
| 迁移脚本方言 | MySQL,注释明确“库:aivfo_tl_setting(中央端 tl_setting 库)” |
| C# 控制端实际读哪个库 | 本地 SQLite(aivfoTL.db)。取数链:DBService.DBUpdateTLInfo() 用 ConvertHelper.ConvertToTLSettingDB(tLInitControllerResult.TLSetting) 把服务器下发的 init JSON 转成 TLSettingDB 写入本地 SQLite;运行时再 ConvertToTLSetting() 回填到运行态 TLSetting(ConvertHelper.cs:144-147, 223-226),喂给 HouseBin.cs 拍照层计算 |
| 本地 SQLite 的 tl_setting/house_well_setting 表结构在哪定义? | 未发现显式定义。DBService.StartDbService 只对 HouseAutofocusCalibrationDB 调了 InitTables,没有对 TLSettingDB/HouseWellSettingDB 调 InitTables。即本地 SQLite 这两张表的新列不会被自动加列——若本地 db 文件是旧结构,写入/读取新列会失败或丢列 |
| 中央端来源(关键断链) | C# 注释写“取数链同 focusLayer*:经服务器 init JSON 反序列化”(TLSetting.cs:385)。但服务器端 Java TlSetting.java 实体完全没有这 5 列(见下) |
断链证据(全仓 grep):
focus_layer* / focusLayer* / local_autofocus* / focus_peak* 命中数 = 0(aivof-tl-control、aivfo-business-manage 全模块,含 .java 与 mapper .xml)。aivof-tl-control/.../entity/dao/TlSetting.java 实体最后一列是 operable_embryo_time,无任何对焦扩列。focusLayerSpacingPulse 永远收不到值 → 按 TLSetting.cs:347 设计将为 null → §2.5 抛 FocusConfigMissingException(不兜底)。回答任务三问:
TLSettingDB/HouseWellSettingDB),值来源是服务器 init JSON 下发后缓存。sql/aivfo_tl_setting.sql 的 tl_setting 需要也加这 5 列(给中央端 MySQL)——迁移脚本正是为此而写;但仅加列还不够,必须同步给 Java 端 TlSetting.java/HouseWellSetting.java 加 @TableField,否则下发链断裂。TlSetting.java、HouseWellSetting.java(aivof-tl-control)均无 focuslayer* / local_autofocus_enabled 字段。TlSetting/HouseWellSetting 补 5+2 个 @TableField,并在下发 init JSON 的组装链路带上这些字段。PictureDAO(@TableName picture)、PictureIdentifyResultDAO(@TableName picture_identify_result) 指向 aivfo-tl 库,但 sql/aivfo-tl.sql 只有 4 张 video 表。aivfo_tl.sql(下划线,business 库)里存在。若 data-transmission 确实需要在 aivfo-tl(中划线)库读写它们,则该库缺表;若是历史遗留 DAO 不再使用,则脚本无需补。需业务确认这两个 DAO 是否仍在运行链路中。alarm_contacts / tdi_log 两表;但 aivfo-service 代码里无 AlarmContacts/TdiLog 实体,全仓 grep alarm_contacts 在 .java 中 0 命中。msg_send_info(MsgSendInfo.java,@TableName msg_send_info),而该表不在 aivfo_services.sql 中。IdentifyKey.java + IdentifyKeyMapper(BaseMapper) 映射 @TableName identify_key,被 AutoMark 处理器链使用。sql/aivfo_tl.sql 无 CREATE TABLE identify_key(只有 mark_key,且 identify_key 仅作为列名出现)。属脚本缺表(或表名与代码不一致)。需确认 identify_key 是否应有独立建表。DBService.StartDbService 仅 InitTables(HouseAutofocusCalibrationDB),未对 TLSettingDB/HouseWellSettingDB 做 CodeFirst 迁移。aivfoTL.db 为旧结构,新对焦列在本地表中不存在 → SqlSugar 写/读这些列会异常或被忽略。需确认本地 db 升级方式(重建 db / 手工 ALTER / 补 InitTables)。 该项已被项目登记为待验证 V-046/V-047。sql/aivfo_tl_setting.sql(base)当前 tl_setting/house_well_setting 不含 focuslayer* / local_autofocus_enabled 列;这些列只在 sql/migrations/2026-06-17-autofocus-data-layer.sql 中。
aivfo_tl_setting 库 执行 migration 脚本(新增 house_autofocus_calibration 表 + ALTER 两表加列)。aivfo_tl_setting(脚本头注释已写明),不要误跑到 aivfo_tl/aivfo-tl。DROP TABLE IF EXISTS house_autofocus_calibration(会清空已建镜像表),且 MySQL 8 ADD COLUMN 不支持 IF NOT EXISTS,重跑 ALTER 会报“列已存在”。重跑前需人工判断列/表是否已存在。TlSetting/HouseWellSetting 补字段(风险1)。仅跑 SQL migration 不能让 C# 端拿到对焦配置。