ALTER TABLE `hot_hidden_danger_inspection`
    ADD COLUMN `submit_version` bigint NULL DEFAULT 0 COMMENT '提交版本号' AFTER `flow_status`,
    ADD COLUMN `audit_result` varchar(16) NULL COMMENT '审核结果（PASS=通过 REJECT=驳回）' AFTER `submit_version`,
    ADD COLUMN `reject_count` bigint NULL DEFAULT 0 COMMENT '驳回次数' AFTER `audit_result`,
    ADD COLUMN `last_reject_reason` varchar(500) NULL COMMENT '最近一次驳回原因' AFTER `reject_count`,
    ADD COLUMN `last_reject_time` datetime NULL COMMENT '最近一次驳回时间' AFTER `last_reject_reason`,
    ADD COLUMN `last_reject_by_id` bigint NULL COMMENT '最近一次驳回人ID' AFTER `last_reject_time`,
    ADD COLUMN `last_reject_by_name` varchar(64) NULL COMMENT '最近一次驳回人姓名' AFTER `last_reject_by_id`;

CREATE TABLE `hot_hidden_danger_inspection_audit_history` (
    `id` bigint NOT NULL COMMENT '主键',
    `inspection_id` bigint NOT NULL COMMENT '隐患排查主单ID',
    `company_id` bigint DEFAULT NULL COMMENT '公司ID',
    `plan_id` bigint DEFAULT NULL COMMENT '计划ID',
    `project_name` varchar(255) DEFAULT NULL COMMENT '排查项目',
    `project_id` varchar(64) DEFAULT NULL COMMENT '排查项目ID',
    `project_type` bigint DEFAULT NULL COMMENT '排查类型（1=公司 2=车辆 3=人员）',
    `submit_version` bigint DEFAULT NULL COMMENT '提交版本号',
    `audit_round` bigint DEFAULT NULL COMMENT '审核轮次',
    `audit_result` varchar(16) DEFAULT NULL COMMENT '审核结果（REJECT）',
    `reject_reason` varchar(500) DEFAULT NULL COMMENT '驳回原因',
    `audit_date` datetime DEFAULT NULL COMMENT '审核日期',
    `approver_id` bigint DEFAULT NULL COMMENT '审核人ID',
    `approver_name` varchar(64) DEFAULT NULL COMMENT '审核人姓名',
    `approver_sign_img_url` varchar(500) DEFAULT NULL COMMENT '审核人签名图片',
    `audit_has_danger` bigint DEFAULT NULL COMMENT '审核时是否存在隐患',
    `submit_snapshot_json` longtext COMMENT '当次提交快照JSON',
    `check_content_json` longtext COMMENT '排查内容JSON',
    `danger_desc` varchar(500) DEFAULT NULL COMMENT '隐患描述',
    `attachment_url` varchar(2000) DEFAULT NULL COMMENT '附件URL',
    `sign_img_url` varchar(500) DEFAULT NULL COMMENT '排查人签名图片',
    `checker_id` varchar(64) DEFAULT NULL COMMENT '排查人ID',
    `checker_name` varchar(64) DEFAULT NULL COMMENT '排查人姓名',
    `check_date` datetime DEFAULT NULL COMMENT '排查日期',
    `create_dept` bigint DEFAULT NULL COMMENT '创建部门',
    `create_by` bigint DEFAULT NULL COMMENT '创建者',
    `create_by_name` varchar(64) DEFAULT NULL COMMENT '创建者名称',
    `create_time` datetime DEFAULT NULL COMMENT '创建时间',
    `update_by` bigint DEFAULT NULL COMMENT '更新者',
    `update_by_name` varchar(64) DEFAULT NULL COMMENT '更新者名称',
    `update_time` datetime DEFAULT NULL COMMENT '更新时间',
    `is_deleted` bigint DEFAULT 0 COMMENT '0=正常,1=已删除',
    `remark` varchar(500) DEFAULT NULL COMMENT '备注',
    PRIMARY KEY (`id`),
    KEY `idx_hdiah_inspection_id` (`inspection_id`),
    KEY `idx_hdiah_company_id` (`company_id`),
    KEY `idx_hdiah_audit_round` (`audit_round`),
    KEY `idx_hdiah_is_deleted` (`is_deleted`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='隐患排查审核驳回历史表';
