- Deprecate elevator-side tenant_visitor_floor_policy SQL files (V2 queries only component-organization library) - Add guangfa 28F visitor floor design spec (table-driven approach A) - Add complete database ER diagram (14 DBs, 537 tables) - Add implementation plan for guangfa visitor floor policy - Code walkthrough docs for visitor floor policy analysis
37 KiB
星河湾星中星平台 — 完整数据库架构与 ER 关系文档
日期: 2026-05-09 MySQL: 192.168.3.12:3307 (root/123456) 状态: 完整梳理
目录
- 数据库总览
- 核心库 1: component-organization
- 核心库 2: cw-elevator-application
- 核心库 3: ninca_common
- 辅助库: cwos_portal
- 辅助库: cwos_manager
- 辅助库: alarm_deploy
- 其他库汇总
- 跨库关系图 (ER)
- 访客邀约+派梯完整数据流
1. 数据库总览
| # | 数据库 | 表数 | 用途 | 所属服务 |
|---|---|---|---|---|
| 1 | component-organization |
40 | 组织/人员/标签/策略 | ninca-common-component-organization |
| 2 | cw-elevator-application |
33 | 电梯规则/识别/记录 | cw-elevator-application |
| 3 | ninca_common |
38 | 区域/设备/消息/文件 | ninca-common (共享服务) |
| 4 | cwos_portal |
155 | 设备/图库/鉴权/账号 | cwos-portal, cwos-system-api |
| 5 | cwos_manager |
33 | 运维/部署/配置 | cwos-manager |
| 6 | alarm_deploy |
49 | 报警/布控/识别记录 | ninca-qk-alarm |
| 7 | person_file |
56 | 人像档案 | ninca-person-file |
| 8 | snap_deploy |
1 | 抓拍部署配置 | snap-app |
| 9 | cloudwalk_device_thirdparty |
5 | 第三方设备网关 | device-auth |
| 10 | g |
1 | (shard) | — |
| 11 | ods |
59 | 运营数据仓库 | — |
| 12 | p |
4 | (shard) | — |
| 13 | xqconfig |
59 | CRK 引擎配置 (Hash) | ninca-crk-std |
| 14 | xqfacerecog |
4 | CRK 人脸识别结果 | ninca-crk-std |
访客邀约+派梯核心链路涉及: component-organization ↔ cw-elevator-application ↔ ninca_common
2. component-organization (组织人员库)
服务: ninca-common-component-organization
连接: jdbc:mysql://192.168.3.12:3307/component-organization
2.1 表清单 (40 张)
| 表名 | 用途 | 关键外键 |
|---|---|---|
cw_is_person |
人员主表 | — |
cw_is_person_label_ref |
人员↔标签关联 | PERSON_ID → cw_is_person.ID, LABEL_ID → cw_is_label.ID |
cw_is_label |
标签主表 | — |
cw_is_organization |
组织架构主表 | PARENT_ID → cw_is_organization.ID |
cw_is_person_organization_ref |
人员↔组织关联 | PERSON_ID → cw_is_person.ID, ORG_ID → cw_is_organization.ID |
org_floor |
组织↔楼层关联 | org_id → cw_is_organization.ID |
tenant_visitor_floor_policy |
租户访客楼层策略 | org_id → cw_is_organization.ID |
cw_is_group_person_ref |
图库↔人员关联 | PERSON_ID → cw_is_person.ID, IMAGE_STORE_ID → cw_is_device_image_store.ID |
cw_is_device_image_store |
图库主表 | — |
cw_is_image_store_associated_ref |
图库↔组织/标签关联 | IMAGE_STORE_ID → cw_is_device_image_store.ID |
cw_is_device_person |
设备人员同步 | — |
cw_is_device_person_sync_log |
同步日志 | — |
cw_is_person_properties |
人员属性定义 | — |
cw_is_person_properties_switch |
属性开关 | — |
cw_is_person_audit |
人员审核记录 | — |
cw_is_person_registry |
人员注册 | — |
cw_is_person_registry_device |
注册设备 | — |
cw_is_person_registry_properties |
注册属性 | — |
cw_is_person_batch_import |
批量导入主表 | — |
cw_is_person_batch_detail |
批量导入明细 | — |
cw_is_organization_extend |
组织扩展 | — |
cw_is_organization_extend_detail |
组织扩展明细 | — |
cw_is_organization_type |
组织类型 | — |
cw_is_organization_type_properties |
组织类型属性 | — |
cw_is_organization_area_ref |
组织↔区域关联 | — |
cw_is_organization_image_store |
组织图库 | — |
cw_operation_log |
操作日志 | — |
cw_task_job_everytime_details |
定时任务 | — |
QRTZ_* (11 张) |
Quartz 调度表 | — |
2.2 核心表 DDL
cw_is_person (人员主表)
CREATE TABLE `cw_is_person` (
`ID` varchar(32) NOT NULL COMMENT '主键ID',
`BUSINESS_ID` varchar(32) NOT NULL COMMENT '企业ID (tenant)',
`PERSON_CODE` varchar(64) DEFAULT NULL COMMENT '人员CODE',
`NAME` varchar(64) DEFAULT NULL COMMENT '姓名',
`USER_NAME` varchar(255) DEFAULT NULL COMMENT '用户名',
`PHONE` varchar(64) DEFAULT NULL COMMENT '联系电话',
`EMAIL` varchar(64) DEFAULT NULL COMMENT '邮箱',
`STATUS` smallint(2) DEFAULT NULL COMMENT '人员状态(0有效 1无效)',
`EXPIRY_BEGIN_DATE` decimal(20,0) DEFAULT NULL COMMENT '有效期开始(时间戳)',
`EXPIRY_END_DATE` decimal(20,0) DEFAULT NULL COMMENT '有效期结束(时间戳)',
`SHOW_PICTURE` varchar(255) DEFAULT NULL COMMENT '展示照',
`COMPARE_PICTURE` text COMMENT '比对照',
`IMAGE_ID` varchar(255) DEFAULT NULL COMMENT '识别照',
`IS_DEL` smallint(2) DEFAULT NULL COMMENT '0未删除 1已删除',
`CREATE_TIME` decimal(20,0) DEFAULT NULL,
`CREATE_USER_ID` varchar(32) DEFAULT NULL,
`LAST_UPDATE_TIME` decimal(20,0) DEFAULT NULL,
`LAST_UPDATE_USER_ID` varchar(32) DEFAULT NULL,
-- EXT1~EXT40 (40个扩展字段)
`SOURCE` smallint(1) NOT NULL DEFAULT '1' COMMENT '1页面管理 2抓拍',
`IC_CARD_NO` varchar(255) DEFAULT NULL COMMENT 'IC卡号',
`IC_CARD_TYPE` varchar(255) DEFAULT NULL COMMENT 'IC卡类型',
`DEFAULT_FLOOR` varchar(255) DEFAULT NULL COMMENT '★默认楼层zone_id',
`CHOOSE_FLOOR` text COMMENT '★选中的楼层(被访人可访问楼层)',
PRIMARY KEY (`ID`),
KEY `IDX_IP_PAGE` (`IS_DEL`,`BUSINESS_ID`,`LAST_UPDATE_TIME`,`ID`,`SOURCE`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='人员信息表';
cw_is_label (标签主表)
CREATE TABLE `cw_is_label` (
`ID` varchar(32) NOT NULL COMMENT '唯一标识',
`NAME` varchar(64) DEFAULT NULL COMMENT '标签名(如"访客")',
`CODE` varchar(64) NOT NULL COMMENT '编码(访客标签CODE="1")',
`BUSINESS_ID` varchar(32) DEFAULT NULL,
`IS_DEL` smallint(2) DEFAULT NULL COMMENT '0未删 1已删',
`ADD_TYPE` smallint(2) DEFAULT NULL COMMENT '0手动 1应用初始 2应用创建',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
cw_is_person_label_ref (人员↔标签关联)
CREATE TABLE `cw_is_person_label_ref` (
`ID` varchar(32) NOT NULL,
`PERSON_ID` varchar(32) NOT NULL COMMENT '→ cw_is_person.ID',
`LABEL_ID` varchar(32) NOT NULL COMMENT '→ cw_is_label.ID',
PRIMARY KEY (`ID`),
KEY `IDX_PERSON` (`PERSON_ID`),
KEY `IDX_LABEL` (`LABEL_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='人员标签关联表';
cw_is_organization (组织架构主表)
CREATE TABLE `cw_is_organization` (
`ID` varchar(32) NOT NULL,
`NAME` varchar(60) DEFAULT NULL COMMENT '如"[28-38F]广发基金管理有限公司"',
`PARENT_ID` varchar(32) DEFAULT NULL COMMENT '→ 自身.ID (树形)',
`BUSINESS_ID` varchar(32) DEFAULT NULL,
`TYPE_ID` varchar(32) DEFAULT NULL,
`ORDER_BY` int(2) DEFAULT NULL,
`IS_DEL` smallint(2) DEFAULT NULL,
`IS_VALID` int(2) DEFAULT NULL COMMENT '0禁用 1启用',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
cw_is_person_organization_ref (人员↔组织关联)
CREATE TABLE `cw_is_person_organization_ref` (
`ID` varchar(32) NOT NULL,
`PERSON_ID` varchar(32) NOT NULL COMMENT '→ cw_is_person.ID',
`ORG_ID` varchar(32) NOT NULL COMMENT '→ cw_is_organization.ID',
PRIMARY KEY (`ID`),
KEY `IDX_PERSON` (`PERSON_ID`),
KEY `IDX_ORG` (`ORG_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='人员组织关联表';
org_floor (组织↔楼层映射)
CREATE TABLE `org_floor` (
`org_id` varchar(64) NOT NULL COMMENT '→ cw_is_organization.ID',
`zone_id` varchar(64) DEFAULT NULL COMMENT '楼层zone_id',
`is_all` smallint(2) NOT NULL COMMENT '0-全部 1-非全部',
`zone_name` varchar(100) DEFAULT NULL COMMENT '楼层名'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='机构楼层对应表';
tenant_visitor_floor_policy (访客楼层策略)
CREATE TABLE `tenant_visitor_floor_policy` (
`id` varchar(32) NOT NULL,
`business_id` varchar(64) DEFAULT NULL COMMENT 'DEPRECATED: 历史字段',
`org_id` varchar(32) DEFAULT NULL COMMENT '→ cw_is_organization.ID (★隔离键)',
`policy_type` varchar(32) NOT NULL DEFAULT 'INTERSECT_ALLOWLIST' COMMENT '策略类型(历史命名;语义为替代)',
`allow_zone_ids` text COMMENT '★ JSON数组 zoneId列表',
`building_id` varchar(64) DEFAULT NULL,
`enabled` tinyint(1) NOT NULL DEFAULT '1' COMMENT '1启用 0停用',
`policy_version` bigint(20) NOT NULL DEFAULT '1',
`remark` varchar(256) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_org_building` (`org_id`,`building_id`),
KEY `idx_org_enabled` (`org_id`,`enabled`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='租户访客楼层策略(组织库;detail/访客列表替代floorList)';
当前数据 (广发基金):
id=gf_vstr_policy_guangfa_fund_001xorg_id=488b8ad049bb43408a6fbcc50bcb89acallow_zone_ids=["605560545117995008"](仅 28F)enabled= 1
cw_is_group_person_ref (图库↔人员)
CREATE TABLE `cw_is_group_person_ref` (
`ID` varchar(32) NOT NULL,
`IMAGE_STORE_ID` varchar(32) DEFAULT NULL COMMENT '→ 图库',
`PERSON_ID` varchar(32) DEFAULT NULL COMMENT '→ cw_is_person.ID',
`EXPIRY_BEGIN_DATE` decimal(20,0) DEFAULT NULL,
`EXPIRY_END_DATE` decimal(20,0) DEFAULT NULL,
`STATUS` smallint(2) DEFAULT '0' COMMENT '-1删除 0正常 1失效',
`GROUP_STATUS` smallint(1) DEFAULT NULL COMMENT '0未建模 1建模中 2完成 3失败',
PRIMARY KEY (`ID`),
KEY `IDX_IGPR_PERSON` (`IMAGE_STORE_ID`,`PERSON_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2.3 组织库 ER 关系图
┌──────────────────────────────────────────────────────────────────────┐
│ component-organization │
│ │
│ ┌─────────────────┐ ┌───────────────────┐ │
│ │ cw_is_person │ │ cw_is_label │ │
│ │ ID (PK) │ │ ID (PK) │ │
│ │ BUSINESS_ID │ │ NAME ("访客") │ │
│ │ NAME │ │ CODE ("1") │ │
│ │ DEFAULT_FLOOR │ └────────┬──────────┘ │
│ │ CHOOSE_FLOOR │ │ │
│ └──┬──────┬───────┘ │ │
│ │ │ │ │
│ │ │ ┌───────────────────┴──────────┐ │
│ │ │ │ cw_is_person_label_ref │ │
│ │ │ │ PERSON_ID → cw_is_person │ │
│ │ │ │ LABEL_ID → cw_is_label │ │
│ │ │ └──────────────────────────────┘ │
│ │ │ │
│ │ └────────────────────────────┐ │
│ │ │ │
│ │ ┌─────────────────────────────────┴──────────┐ │
│ │ │ cw_is_person_organization_ref │ │
│ │ │ PERSON_ID → cw_is_person │ │
│ │ │ ORG_ID → cw_is_organization │ │
│ │ └────────────┬───────────────────────────────┘ │
│ │ │ │
│ │ ┌────────────┴────────────────┐ │
│ │ │ cw_is_organization │ │
│ │ │ ID (PK) │ │
│ │ │ NAME │ │
│ │ │ PARENT_ID → 自身 (树形) │ │
│ │ └──┬─────────────┬────────────┘ │
│ │ │ │ │
│ │ │ ┌─────────┴──────────────┐ │
│ │ │ │ org_floor │ │
│ │ │ │ org_id → organization │ │
│ │ │ │ zone_id │ │
│ │ │ └────────────────────────┘ │
│ │ │ │
│ │ │ ┌──────────────────────────────┐ │
│ │ │ │ tenant_visitor_floor_policy │ │
│ │ │ │ org_id → organization (★) │ │
│ │ │ │ allow_zone_ids (JSON) │ │
│ │ │ │ enabled (0/1) │ │
│ │ │ └──────────────────────────────┘ │
│ │ │ │
│ │ ┌──┴──────────────────────────────┐ │
│ │ │ cw_is_group_person_ref │ │
│ └──│ PERSON_ID → cw_is_person │ │
│ │ IMAGE_STORE_ID → 图库 │ │
│ └──────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────────────┘
关键关联链 (访客邀约):
PersonService.detail(personId)
→ cw_is_person + cw_is_person_organization_ref → 获取 organizationIds
→ cw_is_person_label_ref → 获取 labelIds
→ tenant_visitor_floor_policy (按 org_id) → allow_zone_ids (替代 floorList)
→ 返回 PersonResult { floorList, labelIds, organizationIds }
3. cw-elevator-application (电梯应用库)
服务: cw-elevator-application
连接: ShardingSphere → jdbc:mysql://mysql_01:3306/cw-elevator-application
特征: 识别/电梯记录表按年份分表 (2020-2030)
3.1 表清单 (33 张)
| 表名 | 用途 | 分区 |
|---|---|---|
image_rule_ref |
★通行规则(核心) — 人员/标签/组织↔楼层 | — |
code_elevator_area |
电梯区号与编码对照 | — |
it_acs_pass_rule |
通行规则主表 | — |
it_acs_recog_record |
识别记录 | 按年: _2020 ~ _2030 |
it_acs_elevator_record |
电梯乘坐记录 | 按年: _2020 ~ _2030 |
elevator_device |
电梯设备 | — |
device_image_store |
设备图库关联 | — |
it_acs_device_task |
设备任务 | — |
send_record_time |
发送记录时间 | — |
send_record_timebak |
发送记录时间备份 | — |
tenant_visitor_floor_policy |
⚠️ V1历史遗留 (V2不查询) | — |
3.2 核心表 DDL
image_rule_ref (★通行规则 — 最核心)
CREATE TABLE `image_rule_ref` (
`id` varchar(32) NOT NULL,
`zone_id` varchar(64) NOT NULL COMMENT '★楼层zone_id → code_elevator_area.zone_id',
`zone_name` varchar(64) DEFAULT NULL COMMENT '楼层名(如28F)',
`name` varchar(64) DEFAULT NULL COMMENT '规则名',
`person_id` varchar(64) DEFAULT NULL COMMENT '★人员id → cw_is_person.ID',
`include_labels` varchar(64) DEFAULT NULL COMMENT '★包含标签ID(单值) → cw_is_label.ID',
`include_organizations` varchar(64) DEFAULT NULL COMMENT '★包含组织ID(单值) → cw_is_organization.ID',
`exclude_labels` varchar(64) DEFAULT NULL COMMENT '排除标签ID',
`is_default` tinyint(1) DEFAULT '0' COMMENT '是否默认规则',
`start_time` bigint(20) DEFAULT NULL,
`end_time` bigint(20) DEFAULT NULL,
`create_time` bigint(20) DEFAULT NULL,
`last_update_time` bigint(20) DEFAULT NULL,
`business_id` varchar(64) DEFAULT NULL COMMENT '企业id',
`parent_rule` varchar(64) DEFAULT NULL COMMENT '归属规则id → it_acs_pass_rule.ID',
`person_delete` tinyint(1) DEFAULT '0' COMMENT '人员是否已删除',
PRIMARY KEY (`id`),
KEY `image_rule_ref_include_labels_IDX` (`include_labels`),
KEY `image_rule_ref_include_organizations_IDX` (`include_organizations`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='通行规则信息表(★访客权限核心)';
关键查询 (listByPersonInfo — 决定楼层访问):
SELECT DISTINCT zone_id, zone_name
FROM image_rule_ref
WHERE person_id = #{personId} AND person_delete = 0
OR include_labels IN (...)
OR include_organizations IN (...)
ORDER BY CAST(zone_name as signed) ASC
code_elevator_area (电梯区号编码)
CREATE TABLE `code_elevator_area` (
`zone_id` varchar(64) NOT NULL COMMENT '★电梯编码(如 605560545117995008)',
`code` varchar(64) NOT NULL COMMENT '地区编码(如 0x1C=28F)',
`create_time` bigint(13) DEFAULT NULL,
`last_update_time` bigint(13) DEFAULT NULL,
`is_first` tinyint(4) DEFAULT NULL COMMENT '是否首层',
`parent_id` varchar(64) DEFAULT NULL COMMENT '父级id(楼栋)',
PRIMARY KEY (`zone_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='电梯编码';
已知 zone_id:
| zone_id | zone_name | code | parent_id (楼栋) |
|---|---|---|---|
| 605560547135455232 | 40F | — | 605560539791228928 |
| 605560541473144832 | 6F | — | 605560539791228928 |
| 605560545117995008 | 28F | 0x1C | 605560539791228928 |
| 605560539791228928 | (楼栋) | — | — |
it_acs_pass_rule (通行规则主表)
CREATE TABLE `it_acs_pass_rule` (
`ID` varchar(32) NOT NULL,
`BUSINESS_ID` varchar(32) NOT NULL,
`ZONE_ID` varchar(32) NOT NULL COMMENT '楼层ID',
`ZONE_NAME` varchar(100) DEFAULT NULL,
`NAME` varchar(200) NOT NULL COMMENT '通行规则名称',
`IMAGE_STORE_ID` varchar(32) NOT NULL COMMENT '图库id',
`IS_DEFAULT` tinyint(1) DEFAULT '0',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='通行规则表';
it_acs_recog_record (识别记录 — 按年分表)
CREATE TABLE `it_acs_recog_record` (
`ID` varchar(32) NOT NULL,
`PERSON_ID` varchar(64) DEFAULT NULL,
`PERSON_NAME` varchar(64) DEFAULT NULL,
`BUSINESS_ID` varchar(32) NOT NULL,
`DEVICE_ID` varchar(64) DEFAULT NULL,
`DEVICE_CODE` varchar(64) NOT NULL,
`RECOGNITION_RESULT` tinyint(1) DEFAULT NULL COMMENT '1成功 2失败',
`RECOGNITION_TIME` bigint(255) NOT NULL,
`PERSON_LABEL_IDS` text COMMENT '★人员标签ID列表(用于MQTT访客判断)',
`SCORE` decimal(10,6) NOT NULL COMMENT '识别分数',
PRIMARY KEY (`ID`),
KEY `it_acs_recog_record_PERSON_ID_IDX` (`PERSON_ID`,`DEVICE_ID`,`RECOGNITION_TIME`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='识别记录表';
分表策略: it_acs_recog_record_2020 ~ it_acs_recog_record_2030 (11 张)
elevator_device (电梯设备)
CREATE TABLE `elevator_device` (
`ID` bigint(20) NOT NULL AUTO_INCREMENT,
`device_id` varchar(64) DEFAULT NULL,
`device_name` varchar(64) NOT NULL COMMENT '设备名称',
`current_floor_id` varchar(64) DEFAULT NULL COMMENT '当前楼层zone_id',
`current_floor` varchar(64) DEFAULT NULL COMMENT '当前楼层名',
`elevator_floor_list` varchar(255) DEFAULT NULL COMMENT '★派梯楼层(逗号分隔)',
`elevator_floor_id_list` varchar(1000) DEFAULT NULL COMMENT '★派梯楼层ID',
`business_id` varchar(32) NOT NULL COMMENT '租户id',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='派梯设备';
3.3 电梯库 ER 关系图
┌──────────────────────────────────────────────────────────────────────┐
│ cw-elevator-application │
│ │
│ ┌───────────────────────┐ ┌─────────────────────┐ │
│ │ it_acs_pass_rule │ │ code_elevator_area │ │
│ │ ID (PK) │ │ zone_id (PK) │ │
│ │ ZONE_ID │──┐ │ code │ │
│ │ ZONE_NAME │ │ │ parent_id(楼栋) │ │
│ │ IMAGE_STORE_ID │ │ └──────────┬──────────┘ │
│ └───────────┬───────────┘ │ │ │
│ │ │ │ │
│ ┌───────────┴──────────────┴───────────────┴───────┐ │
│ │ image_rule_ref (★核心) │ │
│ │ zone_id ← code_elevator_area.zone_id │ │
│ │ person_id ← cw_is_person.ID │ │
│ │ include_labels ← cw_is_label.ID (单值) │ │
│ │ include_organizations ← cw_is_organization.ID │ │
│ │ parent_rule ← it_acs_pass_rule.ID │ │
│ │ is_default (0/1) │ │
│ └───────────────────────────────────────────────────┘ │
│ │
│ ┌───────────────────────┐ ┌─────────────────────┐ │
│ │ elevator_device │ │ it_acs_recog_record │ │
│ │ device_id │ │ PERSON_LABEL_IDS │ │
│ │ elevator_floor_list │ │ RECOGNITION_TIME │ │
│ │ elevator_floor_id_list│ │ (按年分表 2020-2030)│ │
│ └───────────────────────┘ └─────────────────────┘ │
└──────────────────────────────────────────────────────────────────────┘
image_rule_ref 三种访问模式:
1. person_id 直连: WHERE person_id = X AND person_delete = 0
2. 标签关联: WHERE include_labels = X (人员标签匹配此标签)
3. 组织关联: WHERE include_organizations = X (人员组织匹配此组织)
4. ninca_common (公共组件库)
服务: ninca-common (共享服务, 通过 Feign 调用)
连接: jdbc:mysql://mysql_01:3306/ninca_common (推测)
4.1 关键表
| 表名 | 用途 |
|---|---|
cw_qz_zone |
★区域/楼层定义表 — zone_id 的主数据源 |
cw_qz_zone_unit_ref |
区域↔单元关联 |
cw_qz_zone_type |
区域类型 |
cw_qz_device_area |
设备区域 |
cw_qz_district_map |
区域地图 |
cw_qz_message_* (7 张) |
消息/通知系统 |
cw_qz_file_* (4 张) |
文件管理 |
QRTZ_* (11 张) |
Quartz 调度 |
cw_qz_zone (区域/楼层主数据)
CREATE TABLE `cw_qz_zone` (
`ID` varchar(32) DEFAULT NULL COMMENT 'zone_id',
`CODE` varchar(32) DEFAULT NULL,
`LEVEL` int(11) DEFAULT NULL,
`NAME` varchar(64) DEFAULT NULL COMMENT '区域名(如"28F")',
`PARENT_ID` varchar(32) DEFAULT NULL COMMENT '父级(楼栋)',
`BUSINESS_ID` varchar(32) DEFAULT NULL,
`TYPE_ID` varchar(32) DEFAULT NULL,
PRIMARY KEY ... (无显式PK定义)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='区域表';
Feign 接口: ZoneFeignClient.findZonelist() → POST /sysetting/zone/list (component-org 通过此接口解析 zone_id → zone_name)
5. cwos_portal (门户管理库)
155 张表 — 平台最大数据库,涵盖: 设备管理、图库管理、鉴权认证、账号系统、识别引擎配置
5.1 核心模块表
| 模块 | 关键表 | 用途 |
|---|---|---|
| 账号 | cw_ac_account, cw_ac_business |
★租户/企业账号 |
| 鉴权 | cw_auth_secret, cw_auth_secret_application |
API Key 管理 |
| 图库 | cw_ag_image_store, cw_ag_image, cw_ag_image_store_image |
人脸底库 |
| 设备 | cw_ge_device, cw_ge_device_camera, cw_ge_area |
设备/摄像头/区域 |
| 算法引擎 | cw_de_group, cw_de_service, cw_de_sub_group |
CRK 引擎分组 |
| 模型 | cw_de_model_upgrade_task |
模型升级 |
5.2 关键关联: 图库系统
cw_ag_image_store (图库)
→ cw_ag_application_image_store (应用↔图库)
→ cw_ag_device_image_store (设备↔图库)
→ cw_ag_image_store_image (图库内的图片)
→ cw_ag_image (图片)
6. cwos_manager (运维管理库)
33 张表 — 部署/运维管理: 应用、组件、节点、配置、操作日志
7. alarm_deploy (报警服务库)
49 张表 — 人脸/车辆/行为报警系统
7.1 核心表
| 表名 | 用途 |
|---|---|
cw_alarm_control_task |
布控任务 |
cw_alarm_control_task_device |
布控↔设备关联 |
cw_alarm_control_task_group |
布控↔底库关联 |
cw_alarm_blacklist_record |
★黑名单报警记录 |
cw_alarm_stranger_record |
★陌生人报警 |
cw_alarm_face_properties_record |
人脸属性报警 |
cw_alarm_plate_record |
车牌报警 |
three_level_control_record |
★三级布控记录(含 grab_floor) |
8. 其他数据库
| 数据库 | 表数 | 核心表 | 用途 |
|---|---|---|---|
person_file |
56 | 人像档案表 | 抓拍人像存档 |
snap_deploy |
1 | 抓拍配置 | snap-app 部署 |
cloudwalk_device_thirdparty |
5 | gw_thirdparty_device_* |
第三方设备网关 |
g |
1 | shard | — |
ods |
59 | 运营数据 | ODS 数据仓库 |
p |
4 | shard | — |
xqconfig |
59 | hash* (CRK 引擎配置) |
ninca-crk-std |
xqfacerecog |
4 | recogdbforface* |
CRK 识别结果分片 |
9. 跨库关系图 (ER)
9.1 平台级 ER 总图
┌─────────────────────────────────────────────────────────────────────────────┐
│ 星河湾星中星 平台 ER │
│ │
│ ┌─ component-organization ───────────────────────────────────────┐ │
│ │ │ │
│ │ cw_is_person ──┬── cw_is_person_label_ref ── cw_is_label │ │
│ │ │ │ │
│ │ ├── cw_is_person_organization_ref ── cw_is_organization ││
│ │ │ ├── org_floor │ │
│ │ │ └── tenant_visitor_floor_policy (★策略) │ │
│ │ │ │ │
│ │ └── cw_is_group_person_ref ── IMAGE_STORE_ID │ │
│ └──────────────────────┬───────────────────────────────────────────┘ │
│ │ zone_id (via Feign) │
│ ┌─ cw-elevator-application ──────────────────────────────────────┐ │
│ │ │ │
│ │ code_elevator_area (zone_id, code, parent_id) │ │
│ │ ▲ │ │
│ │ │ zone_id │ │
│ │ image_rule_ref ── person_id ──→ cw_is_person.ID │ │
│ │ ├── include_labels ──→ cw_is_label.ID │ │
│ │ ├── include_organizations ──→ cw_is_organization.ID │ │
│ │ └── parent_rule ──→ it_acs_pass_rule.ID │ │
│ │ │ │
│ │ it_acs_recog_record ── PERSON_ID ──→ cw_is_person.ID │ │
│ │ ── PERSON_LABEL_IDS (★访客判断: "1"=访客) │ │
│ └──────────────────────┬───────────────────────────────────────────┘ │
│ │ zone_id (via Feign ZoneFeignClient) │
│ ┌─ ninca_common ──────────────────────────────────────────────────┐ │
│ │ cw_qz_zone (★zone主数据: ID, NAME, PARENT_ID) │ │
│ │ cw_qz_zone_unit_ref │ │
│ │ cw_qz_device_area │ │
│ └──────────────────────────────────────────────────────────────────┘ │
│ │
│ ┌─ cwos_portal ───────────────────────────────────────────────────┐ │
│ │ cw_ac_business (★BUSINESS_ID主数据) ── cw_ac_account │ │
│ │ cw_ag_image_store (图库) ── cw_ag_image (图片) │ │
│ │ cw_ge_device (设备) ── cw_ge_device_camera (摄像头) │ │
│ └──────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘
9.2 关键跨库关联
| 关联 | 从库 | 从表.字段 | 到库 | 到表.字段 | 类型 |
|---|---|---|---|---|---|
| 人员↔楼层规则 | cw-elevator-app | image_rule_ref.person_id |
component-org | cw_is_person.ID |
逻辑外键 |
| 标签↔楼层规则 | cw-elevator-app | image_rule_ref.include_labels |
component-org | cw_is_label.ID |
逻辑外键 |
| 组织↔楼层规则 | cw-elevator-app | image_rule_ref.include_organizations |
component-org | cw_is_organization.ID |
逻辑外键 |
| 楼层编码↔主数据 | cw-elevator-app | code_elevator_area.zone_id |
ninca_common | cw_qz_zone.ID |
逻辑外键 |
| 策略↔组织 | component-org | tenant_visitor_floor_policy.org_id |
component-org | cw_is_organization.ID |
⚠️ 同库 |
| 访客标签判断 | cw-elevator-app | it_acs_recog_record.PERSON_LABEL_IDS |
component-org | cw_is_label.CODE = "1" |
业务规则 |
| 企业ID | component-org | cw_is_person.BUSINESS_ID |
cwos_portal | cw_ac_business.ID |
逻辑外键 |
10. 访客邀约+派梯完整数据流
10.1 邀约页加载
Step 1: 前端 → POST /component/person/detail
├─ component-org: cw_is_person WHERE ID = personId
├─ cw_is_person_label_ref JOIN cw_is_label → labelIds, labelNames
├─ cw_is_person_organization_ref JOIN cw_is_organization → organizationIds
│
├─ ★ 策略检查: tenant_visitor_floor_policy
│ WHERE org_id = ? AND enabled = 1
│ → allow_zone_ids = ["605560545117995008"] (28F)
│
├─ 未命中策略 → Feign: elevator-app POST /elevator/passRule/image
│ → image_rule_ref: SELECT DISTINCT zone_id, zone_name
│ WHERE person_id = X AND person_delete = 0
│ OR include_labels IN (...)
│ OR include_organizations IN (...)
│ → code_elevator_area: 获取 zone_id 对应的 code
│
└─ 返回 PersonResult { floorList: [28F_zone_id], labelIds, organizationIds }
10.2 派梯执行
Step 2: 前端 → POST /elevator/person/add/visitor
├─ elevator-app: PersonRuleServiceImpl.addVisitor()
│
├─ Feign: component-org POST /component/person/detail (回查)
│ → 返回 floorList = [28F_zone_id] (策略已替代)
│
├─ UC-02: floorIds 非空 → effective = param.floorIds = [28F_zone_id]
│ UC-01: floorIds 为空 → effective = detail.floorList = [28F_zone_id]
│
├─ ★ 无校验: floorIds 是否是 host floorList 的子集 (V2 不做交集)
│
├─ elevator-app: image_rule_ref.getDefaultByZoneId(28F_zone_id)
│ → SELECT * FROM image_rule_ref WHERE zone_id=? AND is_default=1
│
├─ elevator-app: INSERT INTO image_rule_ref
│ (person_id = visitorId, zone_id = 28F, parent_rule = defaultRule.id)
│
├─ Feign: component-org POST /component/imagestore/person/batchBind
│ → cw_is_group_person_ref: INSERT (person_id = visitorId, image_store_id = ?)
│
└─ Feign: updateGroupPersonRef → 更新组人员引用
10.3 识别派梯 (MQTT 实时)
Step 3: 人脸识别 → 电梯派梯 (实时)
├─ it_acs_recog_record: INSERT 识别记录
│ PERSON_LABEL_IDS = "1" → 判定 isVisitor = true
│
├─ MqttServiceImpl: 检查 PERSON_LABEL_IDS.contains("1")
│ → isVisitor = TRUE → 按访客逻辑派梯
│
├─ image_rule_ref: 查询访客的规则行
│ WHERE person_id = visitorId
│ → zone_id = 28F
│
└─ elevator_device: 派梯到对应楼层
elevator_floor_list / elevator_floor_id_list
10.4 关键业务规则
| 规则 | 位置 | 说明 |
|---|---|---|
| 访客标签CODE="1" | cw_is_label.CODE + it_acs_recog_record.PERSON_LABEL_IDS |
MQTT 中判断 isVisitor |
| 访客列表排除"访客"标签的人 | ImgPersonServiceImpl.listByPage L374-377 |
labelNames.contains("访客") → continue |
| 策略替代 floorList | tenant_visitor_floor_policy → ImgPersonServiceImpl.detail() L643-648 |
org_id 命中 → allow_zone_ids 替换 |
| 40F/6F 硬编码默认 | ImgPersonServiceImpl.listByPage L354-370 |
xhwId→40F, else→6F |
| addVisitor 无交集校验 | PersonRuleServiceImpl.addVisitor() |
UC-02 floorIds 任意值均可 |
| addVisitor 无 defaultRule 检查 | PersonRuleServiceImpl.addVisitor() L222 |
getDefaultByZoneId 返回 null → NPE |