实现 M002 CP5 任务确认与 OPERA 模拟骨架

This commit is contained in:
andy
2026-07-07 16:24:17 +08:00
parent f7d77b45bd
commit bd7b791bee
37 changed files with 2548 additions and 57 deletions

View File

@@ -0,0 +1,15 @@
-- M002 CP5任务草稿和最终确认 payload。第一版按矩阵 field_path 保存,不直接生成 OPERA 参数。
ALTER TABLE workflow_reservation_task_card
ADD COLUMN draft_payload_json LONGTEXT NULL COMMENT '用户保存的任务卡草稿 JSON第一版按矩阵 field_path 作为 key 保存';
ALTER TABLE workflow_reservation_task_card
ADD COLUMN confirmed_payload_json LONGTEXT NULL COMMENT '用户最终确认后的任务卡 JSON第一版按矩阵 field_path 合并保存,后续 OPERA 参数组装时再转换';
ALTER TABLE workflow_reservation_task_card
ADD COLUMN confirmed_by VARCHAR(128) NULL COMMENT '确认人标识,用户身份权限接入前使用本地占位';
ALTER TABLE workflow_reservation_task_card
ADD COLUMN confirmed_at DATETIME(6) NULL COMMENT '任务卡最终确认 UTC 时间';
ALTER TABLE workflow_reservation_task
ADD COLUMN confirmed_at DATETIME(6) NULL COMMENT '任务最终确认 UTC 时间';

View File

@@ -0,0 +1,42 @@
-- M002 OPERA 模拟骨架:每个已确认任务固定生成两条模拟操作。
CREATE TABLE workflow_reservation_opera_operation (
id BIGINT NOT NULL COMMENT 'OPERA 模拟操作 ID',
hotel_id VARCHAR(64) NOT NULL COMMENT '酒店或业务上下文 ID',
order_id BIGINT NOT NULL COMMENT '关联订单 ID',
task_id BIGINT NOT NULL COMMENT '关联任务 ID',
operation_sequence INT NOT NULL COMMENT '任务内模拟操作顺序,从 1 开始',
operation_code VARCHAR(64) NOT NULL COMMENT '模拟操作代码,第一版固定两类',
operation_name VARCHAR(128) NOT NULL COMMENT '模拟操作展示名称',
operation_status VARCHAR(32) NOT NULL COMMENT '操作状态PENDING、SUCCEEDED、FAILED',
request_payload_json LONGTEXT NULL COMMENT '模拟请求 JSON来源于 confirmed_payload_json 的低耦合摘要',
attempt_count INT NOT NULL DEFAULT 0 COMMENT '已执行 attempt 次数',
last_attempt_id BIGINT NULL COMMENT '最近一次 attempt ID',
last_error_message VARCHAR(512) NULL COMMENT '最近一次失败原因摘要',
created_at DATETIME(6) NOT NULL COMMENT '记录创建 UTC 时间',
updated_at DATETIME(6) NOT NULL COMMENT '记录更新 UTC 时间',
PRIMARY KEY (id),
UNIQUE KEY uk_reservation_opera_operation_sequence (hotel_id, task_id, operation_sequence),
KEY idx_reservation_opera_operation_task_status (hotel_id, task_id, operation_status),
KEY idx_reservation_opera_operation_order (hotel_id, order_id, operation_sequence)
) COMMENT='Reservation OPERA 模拟操作表,第一版每个任务固定两条操作';
-- M002 OPERA 模拟骨架:每次执行或重试都会生成一条 attempt。
CREATE TABLE workflow_reservation_opera_operation_attempt (
id BIGINT NOT NULL COMMENT 'OPERA 模拟操作 attempt ID',
hotel_id VARCHAR(64) NOT NULL COMMENT '酒店或业务上下文 ID',
order_id BIGINT NOT NULL COMMENT '关联订单 ID',
task_id BIGINT NOT NULL COMMENT '关联任务 ID',
operation_id BIGINT NOT NULL COMMENT '关联 OPERA 模拟操作 ID',
attempt_number INT NOT NULL COMMENT '同一操作内第几次 attempt从 1 开始',
attempt_status VARCHAR(32) NOT NULL COMMENT 'attempt 状态SUCCEEDED、FAILED',
request_payload_json LONGTEXT NULL COMMENT '本次模拟请求 JSON',
response_payload_json LONGTEXT NULL COMMENT '本次模拟响应 JSON',
error_message VARCHAR(512) NULL COMMENT '失败原因摘要',
started_at DATETIME(6) NOT NULL COMMENT 'attempt 开始 UTC 时间',
finished_at DATETIME(6) NOT NULL COMMENT 'attempt 结束 UTC 时间',
created_at DATETIME(6) NOT NULL COMMENT '记录创建 UTC 时间',
PRIMARY KEY (id),
UNIQUE KEY uk_reservation_opera_attempt_number (hotel_id, operation_id, attempt_number),
KEY idx_reservation_opera_attempt_task (hotel_id, task_id, created_at),
KEY idx_reservation_opera_attempt_operation (hotel_id, operation_id, attempt_number)
) COMMENT='Reservation OPERA 模拟操作 attempt 表,记录执行和重试结果';