feat(assistant): unify confirmed memory capture
This commit is contained in:
@@ -78,6 +78,39 @@ CREATE TABLE IF NOT EXISTS `aihr_service_memory_version` (
|
||||
KEY `idx_aihr_service_memory_version_scope` (`tenant_id`, `project_code`, `memory_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='项目服务记忆版本快照';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `aihr_assistant_capture` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '统一采集记录ID',
|
||||
`tenant_id` varchar(20) NOT NULL COMMENT '租户编号',
|
||||
`owner_user_id` bigint NOT NULL COMMENT '记录员工',
|
||||
`project_code` varchar(100) DEFAULT NULL COMMENT '经当前身份确认的项目编码',
|
||||
`save_scope` varchar(20) NOT NULL COMMENT 'PRIVATE/COMPANY',
|
||||
`suggested_type` varchar(30) NOT NULL COMMENT 'SERVICE_LEAD/RESIDENT_PROFILE/CASE/PERSONAL_NOTE/FOLLOW_UP/PROJECT_NOTE',
|
||||
`building_name` varchar(100) DEFAULT NULL COMMENT '可选楼栋',
|
||||
`unit_name` varchar(100) DEFAULT NULL COMMENT '可选单元',
|
||||
`room_no` varchar(100) DEFAULT NULL COMMENT '可选房号',
|
||||
`category` varchar(50) NOT NULL COMMENT '系统建议分类',
|
||||
`summary` varchar(1000) NOT NULL COMMENT '用户确认后的最小必要摘要',
|
||||
`detail` text COMMENT '用户确认后的必要补充',
|
||||
`occurred_at` datetime NOT NULL COMMENT '发生或获知时间',
|
||||
`follow_up_at` datetime DEFAULT NULL COMMENT '用户确认的跟进时间',
|
||||
`source_conversation_id` varchar(64) NOT NULL DEFAULT '' COMMENT '来源会话ID',
|
||||
`source_request_id` varchar(64) NOT NULL COMMENT '来源问答请求ID',
|
||||
`delivery_status` varchar(20) NOT NULL COMMENT 'NOT_REQUIRED/PENDING/DELIVERED/FAILED',
|
||||
`delivery_attempts` int NOT NULL DEFAULT 0 COMMENT '企业流转尝试次数',
|
||||
`next_delivery_at` datetime DEFAULT NULL COMMENT '下次流转时间',
|
||||
`external_record_id` varchar(100) DEFAULT NULL COMMENT '外部系统记录ID',
|
||||
`last_error` varchar(500) DEFAULT NULL COMMENT '最近一次公开错误',
|
||||
`confirm_idempotency_key` varchar(100) NOT NULL COMMENT '确认幂等键',
|
||||
`confirm_request_hash` char(64) NOT NULL COMMENT '确认请求规范化哈希',
|
||||
`version` int NOT NULL DEFAULT 1 COMMENT '记录版本',
|
||||
`create_time` datetime NOT NULL COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_aihr_assistant_capture_confirm` (`tenant_id`, `owner_user_id`, `confirm_idempotency_key`),
|
||||
KEY `idx_aihr_assistant_capture_owner` (`tenant_id`, `owner_user_id`, `save_scope`, `create_time`),
|
||||
KEY `idx_aihr_assistant_capture_delivery` (`delivery_status`, `next_delivery_at`, `id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='工作助手确认式统一采集记录';
|
||||
|
||||
-- 生产旧库与 MySQL 8 新库的排序规则可能不同;以现有租户主表为事实源动态对齐。
|
||||
SET @aihr_memory_collation := (
|
||||
SELECT collation_name
|
||||
@@ -95,6 +128,8 @@ SET @aihr_memory_ddl := CONCAT('ALTER TABLE `aihr_service_memory` CONVERT TO CHA
|
||||
PREPARE aihr_memory_stmt FROM @aihr_memory_ddl; EXECUTE aihr_memory_stmt; DEALLOCATE PREPARE aihr_memory_stmt;
|
||||
SET @aihr_memory_ddl := CONCAT('ALTER TABLE `aihr_service_memory_version` CONVERT TO CHARACTER SET utf8mb4 COLLATE ', @aihr_memory_collation);
|
||||
PREPARE aihr_memory_stmt FROM @aihr_memory_ddl; EXECUTE aihr_memory_stmt; DEALLOCATE PREPARE aihr_memory_stmt;
|
||||
SET @aihr_memory_ddl := CONCAT('ALTER TABLE `aihr_assistant_capture` CONVERT TO CHARACTER SET utf8mb4 COLLATE ', @aihr_memory_collation);
|
||||
PREPARE aihr_memory_stmt FROM @aihr_memory_ddl; EXECUTE aihr_memory_stmt; DEALLOCATE PREPARE aihr_memory_stmt;
|
||||
|
||||
SET @aihr_memory_ddl := NULL;
|
||||
SET @aihr_memory_collation := NULL;
|
||||
|
||||
@@ -78,6 +78,50 @@ CREATE TABLE IF NOT EXISTS `aihr_service_memory_version` (
|
||||
KEY `idx_aihr_service_memory_version_scope` (`tenant_id`, `project_code`, `memory_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='项目服务记忆版本快照';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `aihr_assistant_capture` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '统一采集记录ID',
|
||||
`tenant_id` varchar(20) NOT NULL COMMENT '租户编号',
|
||||
`owner_user_id` bigint NOT NULL COMMENT '记录员工',
|
||||
`project_code` varchar(100) DEFAULT NULL COMMENT '经当前身份确认的项目编码',
|
||||
`save_scope` varchar(20) NOT NULL COMMENT 'PRIVATE/COMPANY',
|
||||
`suggested_type` varchar(30) NOT NULL COMMENT '系统建议类型',
|
||||
`building_name` varchar(100) DEFAULT NULL COMMENT '可选楼栋',
|
||||
`unit_name` varchar(100) DEFAULT NULL COMMENT '可选单元',
|
||||
`room_no` varchar(100) DEFAULT NULL COMMENT '可选房号',
|
||||
`category` varchar(50) NOT NULL COMMENT '系统建议分类',
|
||||
`summary` varchar(1000) NOT NULL COMMENT '用户确认后的最小必要摘要',
|
||||
`detail` text COMMENT '用户确认后的必要补充',
|
||||
`occurred_at` datetime NOT NULL COMMENT '发生或获知时间',
|
||||
`follow_up_at` datetime DEFAULT NULL COMMENT '用户确认的跟进时间',
|
||||
`source_conversation_id` varchar(64) NOT NULL DEFAULT '' COMMENT '来源会话ID',
|
||||
`source_request_id` varchar(64) NOT NULL COMMENT '来源问答请求ID',
|
||||
`delivery_status` varchar(20) NOT NULL COMMENT 'NOT_REQUIRED/PENDING/DELIVERED/FAILED',
|
||||
`delivery_attempts` int NOT NULL DEFAULT 0 COMMENT '企业流转尝试次数',
|
||||
`next_delivery_at` datetime DEFAULT NULL COMMENT '下次流转时间',
|
||||
`external_record_id` varchar(100) DEFAULT NULL COMMENT '外部系统记录ID',
|
||||
`last_error` varchar(500) DEFAULT NULL COMMENT '最近一次公开错误',
|
||||
`confirm_idempotency_key` varchar(100) NOT NULL COMMENT '确认幂等键',
|
||||
`confirm_request_hash` char(64) NOT NULL COMMENT '确认请求规范化哈希',
|
||||
`version` int NOT NULL DEFAULT 1 COMMENT '记录版本',
|
||||
`create_time` datetime NOT NULL COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_aihr_assistant_capture_confirm` (`tenant_id`, `owner_user_id`, `confirm_idempotency_key`),
|
||||
KEY `idx_aihr_assistant_capture_owner` (`tenant_id`, `owner_user_id`, `save_scope`, `create_time`),
|
||||
KEY `idx_aihr_assistant_capture_delivery` (`delivery_status`, `next_delivery_at`, `id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='工作助手确认式统一采集记录';
|
||||
|
||||
SET @aihr_memory_ddl := IF(
|
||||
EXISTS(
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = DATABASE() AND table_name = 'aihr_assistant_capture'
|
||||
AND column_name = 'follow_up_at'
|
||||
),
|
||||
'SELECT 1',
|
||||
'ALTER TABLE `aihr_assistant_capture` ADD COLUMN `follow_up_at` datetime DEFAULT NULL COMMENT ''用户确认的跟进时间'' AFTER `occurred_at`'
|
||||
);
|
||||
PREPARE aihr_memory_stmt FROM @aihr_memory_ddl; EXECUTE aihr_memory_stmt; DEALLOCATE PREPARE aihr_memory_stmt;
|
||||
|
||||
SET @aihr_memory_ddl := IF(
|
||||
EXISTS(
|
||||
SELECT 1 FROM information_schema.statistics
|
||||
@@ -123,6 +167,8 @@ SET @aihr_memory_ddl := CONCAT('ALTER TABLE `aihr_service_memory` CONVERT TO CHA
|
||||
PREPARE aihr_memory_stmt FROM @aihr_memory_ddl; EXECUTE aihr_memory_stmt; DEALLOCATE PREPARE aihr_memory_stmt;
|
||||
SET @aihr_memory_ddl := CONCAT('ALTER TABLE `aihr_service_memory_version` CONVERT TO CHARACTER SET utf8mb4 COLLATE ', @aihr_memory_collation);
|
||||
PREPARE aihr_memory_stmt FROM @aihr_memory_ddl; EXECUTE aihr_memory_stmt; DEALLOCATE PREPARE aihr_memory_stmt;
|
||||
SET @aihr_memory_ddl := CONCAT('ALTER TABLE `aihr_assistant_capture` CONVERT TO CHARACTER SET utf8mb4 COLLATE ', @aihr_memory_collation);
|
||||
PREPARE aihr_memory_stmt FROM @aihr_memory_ddl; EXECUTE aihr_memory_stmt; DEALLOCATE PREPARE aihr_memory_stmt;
|
||||
|
||||
SET @aihr_memory_ddl := NULL;
|
||||
SET @aihr_memory_collation := NULL;
|
||||
|
||||
Reference in New Issue
Block a user