CREATE TABLE IF NOT EXISTS `safe_facility_inspection_task` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '任务ID', `inspection_name` varchar(100) DEFAULT NULL COMMENT '巡检任务名称', `facility_id` int DEFAULT NULL COMMENT '设施ID', `facility_code` varchar(100) DEFAULT NULL COMMENT '设施编号', `facility_name` varchar(100) DEFAULT NULL COMMENT '设施名称', `inspection_project` varchar(1000) DEFAULT NULL COMMENT '巡检项目', `inspector_id` int DEFAULT NULL COMMENT '巡检人ID', `frequency_type` varchar(20) DEFAULT NULL COMMENT '频率类型 DAILY/WEEKLY/MONTHLY', `frequency_detail` varchar(50) DEFAULT NULL COMMENT '频率详情:每日HH:mm;每周MON,HH:mm;每月DD,HH:mm', `next_execution_time` datetime DEFAULT NULL COMMENT '下次执行时间', `last_execution_time` datetime DEFAULT NULL COMMENT '最后执行时间', `is_enabled` tinyint DEFAULT '1' COMMENT '是否启用 0否 1是', `remark` varchar(500) DEFAULT NULL COMMENT '备注', `create_time` datetime DEFAULT NULL COMMENT '创建时间', `create_user` int DEFAULT NULL COMMENT '创建人ID', `update_time` datetime DEFAULT NULL COMMENT '更新时间', `update_user` int DEFAULT NULL COMMENT '更新人ID', `tenant_id` int DEFAULT NULL COMMENT '租户ID', `dept_id` bigint DEFAULT NULL COMMENT '部门ID', PRIMARY KEY (`id`) USING BTREE, KEY `idx_safe_facility_inspection_task_facility` (`facility_id`) USING BTREE, KEY `idx_safe_facility_inspection_task_enabled` (`is_enabled`, `next_execution_time`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='安全生产-安全设施定时巡检任务'; ALTER TABLE `safe_facility_inspection` ADD COLUMN `schedule_task_id` bigint DEFAULT NULL COMMENT '定时巡检任务ID' AFTER `id`, ADD COLUMN `inspection_project` varchar(1000) DEFAULT NULL COMMENT '巡检项目' AFTER `inspection_type`, ADD KEY `idx_safe_facility_inspection_schedule_task` (`schedule_task_id`) USING BTREE;