-- ============================================
-- 业务表结构增量导出（只增不删）
-- 来源: 127.0.0.1:3306/test_src
-- 表数: 20
-- 生成时间: 2026-08-07 15:16:41
-- 语义: 表不存在→CREATE IF NOT EXISTS；表已存在→仅补缺失列；不改已有列、不 DROP
-- ============================================

-- ############ 表: bg_partymatter ############
CREATE TABLE IF NOT EXISTS `bg_partymatter` (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建日期',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新日期',
  `sys_org_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '所属部门',
  `meeting_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '会议类型：party党委会，office所务会',
  `secret_level` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '密级',
  `year` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '年份',
  `number` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '序号',
  `matter_time` date DEFAULT NULL COMMENT '会议时间',
  `title` varchar(320) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '事项名称',
  `content` varchar(3200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '会议决议',
  `item_number` int DEFAULT NULL COMMENT '议题序号',
  `matter_code` varchar(320) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '事项目录编码',
  `respon_deptid` varchar(320) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '主办部门',
  `assist_deptid` varchar(320) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '协办部门',
  `actual_exect` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '实际执行情况',
  `bpm_status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '完成状态',
  `supervise_count` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '督办次数',
  `deadline` date DEFAULT NULL COMMENT '要求完成日期',
  `urgency_level` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '紧急程度',
  `is_need_appro` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '是否需要所办领导审批',
  `sup_deptleaderid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '所办领导',
  `is_need_suoleader` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '是否抄送所领导',
  `suoleaderid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '抄送所领导',
  `del_flag` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '删除标识',
  `is_need_interval` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '是否需要重复督办',
  `interval_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '重复类型',
  `start_count` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '重复次数',
  `interval_start_time` date DEFAULT NULL COMMENT '重复开始时间',
  `notice_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '抄告单编号',
  `is_important` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '是否为三重一大决策',
  `manage_suoleader` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '分管所领导',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `id` varchar(36) NOT NULL', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'create_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `create_by` varchar(50) COMMENT ''创建人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'create_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `create_time` datetime COMMENT ''创建日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'update_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `update_by` varchar(50) COMMENT ''更新人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'update_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `update_time` datetime COMMENT ''更新日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'sys_org_code');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `sys_org_code` varchar(64) COMMENT ''所属部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'meeting_type');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `meeting_type` varchar(255) COMMENT ''会议类型：party党委会，office所务会''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'secret_level');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `secret_level` varchar(255) COMMENT ''密级''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'year');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `year` varchar(32) COMMENT ''年份''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'number');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `number` varchar(32) COMMENT ''序号''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'matter_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `matter_time` date COMMENT ''会议时间''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'title');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `title` varchar(320) COMMENT ''事项名称''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'content');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `content` varchar(3200) COMMENT ''会议决议''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'item_number');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `item_number` int COMMENT ''议题序号''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'matter_code');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `matter_code` varchar(320) COMMENT ''事项目录编码''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'respon_deptid');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `respon_deptid` varchar(320) COMMENT ''主办部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'assist_deptid');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `assist_deptid` varchar(320) COMMENT ''协办部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'actual_exect');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `actual_exect` varchar(32) COMMENT ''实际执行情况''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'bpm_status');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `bpm_status` varchar(32) COMMENT ''完成状态''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'supervise_count');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `supervise_count` varchar(32) DEFAULT ''0'' COMMENT ''督办次数''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'deadline');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `deadline` date COMMENT ''要求完成日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'urgency_level');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `urgency_level` varchar(32) COMMENT ''紧急程度''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'is_need_appro');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `is_need_appro` varchar(32) COMMENT ''是否需要所办领导审批''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'sup_deptleaderid');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `sup_deptleaderid` varchar(255) COMMENT ''所办领导''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'is_need_suoleader');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `is_need_suoleader` varchar(32) COMMENT ''是否抄送所领导''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'suoleaderid');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `suoleaderid` varchar(32) COMMENT ''抄送所领导''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'del_flag');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `del_flag` varchar(2) DEFAULT ''0'' COMMENT ''删除标识''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'is_need_interval');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `is_need_interval` varchar(255) COMMENT ''是否需要重复督办''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'interval_type');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `interval_type` varchar(255) COMMENT ''重复类型''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'start_count');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `start_count` varchar(255) COMMENT ''重复次数''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'interval_start_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `interval_start_time` date COMMENT ''重复开始时间''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'notice_number');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `notice_number` varchar(255) COMMENT ''抄告单编号''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'is_important');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `is_important` varchar(255) COMMENT ''是否为三重一大决策''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter' AND column_name = 'manage_suoleader');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter` ADD COLUMN `manage_suoleader` varchar(255) COMMENT ''分管所领导''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;

-- ############ 表: bg_partymatter_feedback ############
CREATE TABLE IF NOT EXISTS `bg_partymatter_feedback` (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建日期',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新日期',
  `sys_org_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '所属部门',
  `respon_deptid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '责任部门id',
  `respon_deptname` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '责任部门名称',
  `respon_personid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '反馈人id',
  `respon_personname` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '反馈人姓名',
  `actual_exect` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '实际执行情况',
  `actual_time` date DEFAULT NULL COMMENT '实际完成时间',
  `bpm_status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '完成状态',
  `bpm_process_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '流程实例id',
  `del_flag` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '删除标识',
  `main_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '外键',
  `plan_exect` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '计划完成目标',
  `plan_time` date DEFAULT NULL COMMENT '计划完成日期',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter_feedback' AND column_name = 'id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter_feedback` ADD COLUMN `id` varchar(36) NOT NULL', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter_feedback' AND column_name = 'create_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter_feedback` ADD COLUMN `create_by` varchar(50) COMMENT ''创建人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter_feedback' AND column_name = 'create_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter_feedback` ADD COLUMN `create_time` datetime COMMENT ''创建日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter_feedback' AND column_name = 'update_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter_feedback` ADD COLUMN `update_by` varchar(50) COMMENT ''更新人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter_feedback' AND column_name = 'update_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter_feedback` ADD COLUMN `update_time` datetime COMMENT ''更新日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter_feedback' AND column_name = 'sys_org_code');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter_feedback` ADD COLUMN `sys_org_code` varchar(64) COMMENT ''所属部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter_feedback' AND column_name = 'respon_deptid');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter_feedback` ADD COLUMN `respon_deptid` varchar(32) COMMENT ''责任部门id''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter_feedback' AND column_name = 'respon_deptname');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter_feedback` ADD COLUMN `respon_deptname` varchar(32) COMMENT ''责任部门名称''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter_feedback' AND column_name = 'respon_personid');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter_feedback` ADD COLUMN `respon_personid` varchar(32) COMMENT ''反馈人id''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter_feedback' AND column_name = 'respon_personname');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter_feedback` ADD COLUMN `respon_personname` varchar(32) COMMENT ''反馈人姓名''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter_feedback' AND column_name = 'actual_exect');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter_feedback` ADD COLUMN `actual_exect` varchar(32) COMMENT ''实际执行情况''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter_feedback' AND column_name = 'actual_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter_feedback` ADD COLUMN `actual_time` date COMMENT ''实际完成时间''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter_feedback' AND column_name = 'bpm_status');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter_feedback` ADD COLUMN `bpm_status` varchar(32) COMMENT ''完成状态''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter_feedback' AND column_name = 'bpm_process_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter_feedback` ADD COLUMN `bpm_process_id` varchar(255) COMMENT ''流程实例id''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter_feedback' AND column_name = 'del_flag');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter_feedback` ADD COLUMN `del_flag` varchar(32) DEFAULT ''0'' COMMENT ''删除标识''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter_feedback' AND column_name = 'main_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter_feedback` ADD COLUMN `main_id` varchar(32) COMMENT ''外键''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter_feedback' AND column_name = 'plan_exect');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter_feedback` ADD COLUMN `plan_exect` varchar(255) COMMENT ''计划完成目标''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_partymatter_feedback' AND column_name = 'plan_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_partymatter_feedback` ADD COLUMN `plan_time` date COMMENT ''计划完成日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;

-- ############ 表: bg_takepulse ############
CREATE TABLE IF NOT EXISTS `bg_takepulse` (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建日期',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新日期',
  `sys_org_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '所属部门',
  `secret_level` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '密级',
  `year` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '年份',
  `number` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '序号',
  `task_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '会议类型：行政线、技术线',
  `type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '类别：党的建设等其他',
  `proposer` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '提出人',
  `title` varchar(320) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '意见主题',
  `content` varchar(3200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '具体意见',
  `suoleader` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '责任领导',
  `respon_deptid` varchar(320) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '牵头部门',
  `assist_deptid` varchar(320) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '协办部门',
  `implement_deptid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '落实部门',
  `is_adopt` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '是否采纳',
  `measure` varchar(3200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '落实措施/解释说明',
  `measure_number` int DEFAULT NULL COMMENT '措施数量',
  `achievement` varchar(3200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '成果形式',
  `deadline` date DEFAULT NULL COMMENT '要求完成日期',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
  `actual_exect` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '执行情况',
  `actual_time` datetime DEFAULT NULL COMMENT '实际完成时间',
  `proposer_confirm` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '提出人确认',
  `bpm_status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '完成状态',
  `act_st` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '调整落实措施及执行情况',
  `supervise_count` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '督办次数',
  `urgency_level` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '紧急程度',
  `is_need_appro` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '是否需要所办领导审批',
  `sup_deptleaderid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '所办领导',
  `del_flag` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '删除标识',
  `manage_suoleader` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '分管所领导',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `id` varchar(36) NOT NULL', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'create_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `create_by` varchar(50) COMMENT ''创建人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'create_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `create_time` datetime COMMENT ''创建日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'update_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `update_by` varchar(50) COMMENT ''更新人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'update_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `update_time` datetime COMMENT ''更新日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'sys_org_code');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `sys_org_code` varchar(64) COMMENT ''所属部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'secret_level');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `secret_level` varchar(255) COMMENT ''密级''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'year');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `year` varchar(32) COMMENT ''年份''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'number');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `number` varchar(32) COMMENT ''序号''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'task_type');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `task_type` varchar(255) COMMENT ''会议类型：行政线、技术线''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'type');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `type` varchar(255) COMMENT ''类别：党的建设等其他''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'proposer');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `proposer` varchar(255) COMMENT ''提出人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'title');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `title` varchar(320) COMMENT ''意见主题''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'content');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `content` varchar(3200) COMMENT ''具体意见''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'suoleader');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `suoleader` varchar(255) COMMENT ''责任领导''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'respon_deptid');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `respon_deptid` varchar(320) COMMENT ''牵头部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'assist_deptid');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `assist_deptid` varchar(320) COMMENT ''协办部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'implement_deptid');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `implement_deptid` varchar(255) COMMENT ''落实部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'is_adopt');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `is_adopt` varchar(255) COMMENT ''是否采纳''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'measure');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `measure` varchar(3200) COMMENT ''落实措施/解释说明''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'measure_number');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `measure_number` int COMMENT ''措施数量''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'achievement');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `achievement` varchar(3200) COMMENT ''成果形式''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'deadline');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `deadline` date COMMENT ''要求完成日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'remark');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `remark` varchar(255) COMMENT ''备注''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'actual_exect');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `actual_exect` text COMMENT ''执行情况''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'actual_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `actual_time` datetime COMMENT ''实际完成时间''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'proposer_confirm');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `proposer_confirm` varchar(255) COMMENT ''提出人确认''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'bpm_status');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `bpm_status` varchar(32) COMMENT ''完成状态''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'act_st');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `act_st` text COMMENT ''调整落实措施及执行情况''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'supervise_count');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `supervise_count` varchar(32) DEFAULT ''0'' COMMENT ''督办次数''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'urgency_level');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `urgency_level` varchar(32) COMMENT ''紧急程度''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'is_need_appro');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `is_need_appro` varchar(32) COMMENT ''是否需要所办领导审批''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'sup_deptleaderid');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `sup_deptleaderid` varchar(255) COMMENT ''所办领导''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'del_flag');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `del_flag` varchar(2) DEFAULT ''0'' COMMENT ''删除标识''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse' AND column_name = 'manage_suoleader');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse` ADD COLUMN `manage_suoleader` varchar(255) COMMENT ''分管所领导''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;

-- ############ 表: bg_takepulse_feedback ############
CREATE TABLE IF NOT EXISTS `bg_takepulse_feedback` (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建日期',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新日期',
  `sys_org_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '所属部门',
  `respon_deptid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '责任部门id',
  `respon_deptname` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '责任部门名称',
  `respon_personid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '反馈人id',
  `respon_personname` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '反馈人姓名',
  `actual_exect` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '实际执行情况',
  `actual_time` date DEFAULT NULL COMMENT '实际完成时间',
  `act_st` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '调整落实措施及执行情况',
  `bpm_status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '完成状态',
  `proposer_confirm` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '提出人确认',
  `bpm_process_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '流程实例id',
  `del_flag` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '删除标识',
  `main_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '外键',
  `plan_exect` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '计划完成目标',
  `plan_time` date DEFAULT NULL COMMENT '计划完成日期',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse_feedback' AND column_name = 'id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse_feedback` ADD COLUMN `id` varchar(36) NOT NULL', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse_feedback' AND column_name = 'create_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse_feedback` ADD COLUMN `create_by` varchar(50) COMMENT ''创建人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse_feedback' AND column_name = 'create_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse_feedback` ADD COLUMN `create_time` datetime COMMENT ''创建日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse_feedback' AND column_name = 'update_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse_feedback` ADD COLUMN `update_by` varchar(50) COMMENT ''更新人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse_feedback' AND column_name = 'update_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse_feedback` ADD COLUMN `update_time` datetime COMMENT ''更新日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse_feedback' AND column_name = 'sys_org_code');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse_feedback` ADD COLUMN `sys_org_code` varchar(64) COMMENT ''所属部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse_feedback' AND column_name = 'respon_deptid');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse_feedback` ADD COLUMN `respon_deptid` varchar(32) COMMENT ''责任部门id''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse_feedback' AND column_name = 'respon_deptname');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse_feedback` ADD COLUMN `respon_deptname` varchar(32) COMMENT ''责任部门名称''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse_feedback' AND column_name = 'respon_personid');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse_feedback` ADD COLUMN `respon_personid` varchar(32) COMMENT ''反馈人id''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse_feedback' AND column_name = 'respon_personname');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse_feedback` ADD COLUMN `respon_personname` varchar(32) COMMENT ''反馈人姓名''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse_feedback' AND column_name = 'actual_exect');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse_feedback` ADD COLUMN `actual_exect` varchar(32) COMMENT ''实际执行情况''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse_feedback' AND column_name = 'actual_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse_feedback` ADD COLUMN `actual_time` date COMMENT ''实际完成时间''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse_feedback' AND column_name = 'act_st');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse_feedback` ADD COLUMN `act_st` text COMMENT ''调整落实措施及执行情况''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse_feedback' AND column_name = 'bpm_status');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse_feedback` ADD COLUMN `bpm_status` varchar(32) COMMENT ''完成状态''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse_feedback' AND column_name = 'proposer_confirm');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse_feedback` ADD COLUMN `proposer_confirm` varchar(255) COMMENT ''提出人确认''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse_feedback' AND column_name = 'bpm_process_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse_feedback` ADD COLUMN `bpm_process_id` varchar(255) COMMENT ''流程实例id''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse_feedback' AND column_name = 'del_flag');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse_feedback` ADD COLUMN `del_flag` varchar(32) DEFAULT ''0'' COMMENT ''删除标识''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse_feedback' AND column_name = 'main_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse_feedback` ADD COLUMN `main_id` varchar(32) COMMENT ''外键''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse_feedback' AND column_name = 'plan_exect');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse_feedback` ADD COLUMN `plan_exect` varchar(255) COMMENT ''计划完成目标''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_takepulse_feedback' AND column_name = 'plan_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_takepulse_feedback` ADD COLUMN `plan_time` date COMMENT ''计划完成日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;

-- ############ 表: bg_xi_speak ############
CREATE TABLE IF NOT EXISTS `bg_xi_speak` (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建日期',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新日期',
  `sys_org_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '所属部门',
  `pid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '父级节点',
  `has_child` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '是否有子节点',
  `speak_status` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '习近平总书记重要讲话指示批示情况',
  `time` date DEFAULT NULL COMMENT '时间',
  `elm_comment` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '企业负责同志批示情况',
  `status` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '学习传达研究部署情况',
  `responsible_person` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '责任人',
  `impl_plan` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '落实方案',
  `lead_department` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '牵头部门',
  `impl_measures` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '贯彻落实措施',
  `number_of_resolutions` int DEFAULT NULL COMMENT '会议决策数',
  `impl_status` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '落实情况',
  `impl_count` int DEFAULT NULL COMMENT '落实条数',
  `closed_count` int DEFAULT NULL COMMENT '已闭环数量',
  `report_feedback_status` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '报告反馈情况',
  `is_completion_risk` int DEFAULT NULL COMMENT '是否存在完成风险(0不存在，1存在)',
  `delay_risk_mitigation` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '拖期风险应对措施',
  `completion_status` int DEFAULT NULL COMMENT '完成状态(0推进中，1已完成)',
  `impl_dept` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '落实部门',
  `tree_depth` int DEFAULT NULL COMMENT '层深(最顶层节点层深为0)',
  `sort_order` int DEFAULT NULL COMMENT '同级数据排序号',
  `del_flag` tinyint(1) DEFAULT '0' COMMENT '逻辑删除flag(0保留,1删除)',
  `bpm_status` tinyint(1) DEFAULT NULL COMMENT '流程引擎状态字段',
  `supervision_count` tinyint(1) DEFAULT NULL COMMENT '督办次数',
  `sdw_leader_list` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'sdw用户',
  `need_sdw_approval` tinyint(1) DEFAULT NULL COMMENT '是否需要sdw审批',
  `approve_info` json DEFAULT NULL COMMENT '业务数据对应的审批信息',
  `launch_type` tinyint DEFAULT NULL COMMENT '0收集后直接发起，1收集后按照反馈时间周期性发起',
  `interval_type` tinyint DEFAULT NULL COMMENT '周期类型 1日 2周 3两周 4月 5季',
  `deadline` date DEFAULT NULL,
  `secret_level` tinyint(1) DEFAULT NULL,
  `completed_stage` int DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `id` varchar(36) NOT NULL', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'create_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `create_by` varchar(50) COMMENT ''创建人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'create_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `create_time` datetime COMMENT ''创建日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'update_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `update_by` varchar(50) COMMENT ''更新人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'update_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `update_time` datetime COMMENT ''更新日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'sys_org_code');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `sys_org_code` varchar(64) COMMENT ''所属部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'pid');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `pid` varchar(32) COMMENT ''父级节点''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'has_child');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `has_child` varchar(3) COMMENT ''是否有子节点''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'speak_status');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `speak_status` varchar(1024) COMMENT ''习近平总书记重要讲话指示批示情况''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `time` date COMMENT ''时间''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'elm_comment');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `elm_comment` varchar(512) COMMENT ''企业负责同志批示情况''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'status');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `status` varchar(512) COMMENT ''学习传达研究部署情况''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'responsible_person');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `responsible_person` varchar(36) COMMENT ''责任人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'impl_plan');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `impl_plan` varchar(512) COMMENT ''落实方案''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'lead_department');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `lead_department` varchar(36) COMMENT ''牵头部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'impl_measures');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `impl_measures` varchar(512) COMMENT ''贯彻落实措施''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'number_of_resolutions');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `number_of_resolutions` int COMMENT ''会议决策数''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'impl_status');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `impl_status` varchar(512) COMMENT ''落实情况''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'impl_count');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `impl_count` int COMMENT ''落实条数''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'closed_count');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `closed_count` int COMMENT ''已闭环数量''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'report_feedback_status');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `report_feedback_status` varchar(512) COMMENT ''报告反馈情况''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'is_completion_risk');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `is_completion_risk` int COMMENT ''是否存在完成风险(0不存在，1存在)''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'delay_risk_mitigation');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `delay_risk_mitigation` varchar(512) COMMENT ''拖期风险应对措施''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'completion_status');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `completion_status` int COMMENT ''完成状态(0推进中，1已完成)''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'impl_dept');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `impl_dept` varchar(256) COMMENT ''落实部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'tree_depth');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `tree_depth` int COMMENT ''层深(最顶层节点层深为0)''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'sort_order');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `sort_order` int COMMENT ''同级数据排序号''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'del_flag');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `del_flag` tinyint(1) DEFAULT 0 COMMENT ''逻辑删除flag(0保留,1删除)''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'bpm_status');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `bpm_status` tinyint(1) COMMENT ''流程引擎状态字段''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'supervision_count');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `supervision_count` tinyint(1) COMMENT ''督办次数''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'sdw_leader_list');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `sdw_leader_list` varchar(255) COMMENT ''sdw用户''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'need_sdw_approval');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `need_sdw_approval` tinyint(1) COMMENT ''是否需要sdw审批''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'approve_info');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `approve_info` json COMMENT ''业务数据对应的审批信息''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'launch_type');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `launch_type` tinyint COMMENT ''0收集后直接发起，1收集后按照反馈时间周期性发起''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'interval_type');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `interval_type` tinyint COMMENT ''周期类型 1日 2周 3两周 4月 5季''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'deadline');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `deadline` date', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'secret_level');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `secret_level` tinyint(1)', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak' AND column_name = 'completed_stage');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak` ADD COLUMN `completed_stage` int', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;

-- ############ 表: bg_xi_speak_feedback ############
CREATE TABLE IF NOT EXISTS `bg_xi_speak_feedback` (
  `id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '主键',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建日期',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新日期',
  `sys_org_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '所属部门',
  `respon_deptid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '反馈部门id',
  `respon_deptname` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '反馈部门名称',
  `respon_personid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '反馈人id',
  `respon_personname` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '反馈人姓名',
  `respon_time` datetime DEFAULT NULL COMMENT '反馈时间',
  `impl_status` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '落实情况',
  `completion_status` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '完成状态',
  `main_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '外键',
  `num` int DEFAULT NULL COMMENT '序号',
  `method` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '措施内容',
  `deadline` datetime DEFAULT NULL COMMENT '完成期限',
  `outcome_form` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '成果形式',
  `progress` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '进展情况',
  `completion_plan` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '落实计划',
  `sum_method_num` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '总措施号',
  `check_status` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '检查情况',
  `inspection_advice` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '监督意见',
  `measure_num` int DEFAULT NULL COMMENT '措施数量',
  `bpm_status` int DEFAULT '1' COMMENT '流程引擎状态字段',
  `approve_info` json DEFAULT NULL COMMENT '审批信息Map',
  `is_reported_to_higher` tinyint(1) DEFAULT NULL COMMENT '是否有报送上级报告(0不存在，1存在)',
  `is_completion_risk` tinyint(1) DEFAULT NULL,
  `delay_risk_mitigation` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `report_feedback_status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_main_id` (`main_id`) USING BTREE COMMENT '外键索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='习总书记重要讲话反馈表';

SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `id` varchar(32) NOT NULL COMMENT ''主键''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'create_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `create_by` varchar(50) COMMENT ''创建人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'create_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `create_time` datetime COMMENT ''创建日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'update_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `update_by` varchar(50) COMMENT ''更新人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'update_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `update_time` datetime COMMENT ''更新日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'sys_org_code');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `sys_org_code` varchar(64) COMMENT ''所属部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'respon_deptid');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `respon_deptid` varchar(32) COMMENT ''反馈部门id''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'respon_deptname');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `respon_deptname` varchar(100) COMMENT ''反馈部门名称''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'respon_personid');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `respon_personid` varchar(32) COMMENT ''反馈人id''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'respon_personname');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `respon_personname` varchar(100) COMMENT ''反馈人姓名''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'respon_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `respon_time` datetime COMMENT ''反馈时间''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'impl_status');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `impl_status` varchar(500) COMMENT ''落实情况''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'completion_status');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `completion_status` varchar(2) COMMENT ''完成状态''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'main_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `main_id` varchar(32) COMMENT ''外键''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'num');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `num` int COMMENT ''序号''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'method');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `method` varchar(500) COMMENT ''措施内容''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'deadline');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `deadline` datetime COMMENT ''完成期限''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'outcome_form');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `outcome_form` varchar(500) COMMENT ''成果形式''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'progress');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `progress` text COMMENT ''进展情况''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'completion_plan');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `completion_plan` text COMMENT ''落实计划''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'sum_method_num');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `sum_method_num` varchar(100) COMMENT ''总措施号''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'check_status');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `check_status` text COMMENT ''检查情况''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'inspection_advice');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `inspection_advice` text COMMENT ''监督意见''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'measure_num');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `measure_num` int COMMENT ''措施数量''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'bpm_status');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `bpm_status` int DEFAULT 1 COMMENT ''流程引擎状态字段''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'approve_info');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `approve_info` json COMMENT ''审批信息Map''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'is_reported_to_higher');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `is_reported_to_higher` tinyint(1) COMMENT ''是否有报送上级报告(0不存在，1存在)''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'is_completion_risk');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `is_completion_risk` tinyint(1)', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'delay_risk_mitigation');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `delay_risk_mitigation` varchar(255)', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'bg_xi_speak_feedback' AND column_name = 'report_feedback_status');
SET @ddl = IF(@has = 0, 'ALTER TABLE `bg_xi_speak_feedback` ADD COLUMN `report_feedback_status` varchar(255)', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;

-- ############ 表: dj_officialdoc_distribute ############
CREATE TABLE IF NOT EXISTS `dj_officialdoc_distribute` (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建日期',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新日期',
  `sys_org_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '所属部门',
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '方案名',
  `username` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '用户名',
  `user_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '用户id',
  `selected` json DEFAULT NULL COMMENT '已选（包括部门，包括用户）',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dj_officialdoc_distribute' AND column_name = 'id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dj_officialdoc_distribute` ADD COLUMN `id` varchar(36) NOT NULL', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dj_officialdoc_distribute' AND column_name = 'create_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dj_officialdoc_distribute` ADD COLUMN `create_by` varchar(50) COMMENT ''创建人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dj_officialdoc_distribute' AND column_name = 'create_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dj_officialdoc_distribute` ADD COLUMN `create_time` datetime COMMENT ''创建日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dj_officialdoc_distribute' AND column_name = 'update_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dj_officialdoc_distribute` ADD COLUMN `update_by` varchar(50) COMMENT ''更新人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dj_officialdoc_distribute' AND column_name = 'update_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dj_officialdoc_distribute` ADD COLUMN `update_time` datetime COMMENT ''更新日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dj_officialdoc_distribute' AND column_name = 'sys_org_code');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dj_officialdoc_distribute` ADD COLUMN `sys_org_code` varchar(64) COMMENT ''所属部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dj_officialdoc_distribute' AND column_name = 'name');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dj_officialdoc_distribute` ADD COLUMN `name` varchar(255) COMMENT ''方案名''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dj_officialdoc_distribute' AND column_name = 'username');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dj_officialdoc_distribute` ADD COLUMN `username` varchar(255) COMMENT ''用户名''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dj_officialdoc_distribute' AND column_name = 'user_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dj_officialdoc_distribute` ADD COLUMN `user_id` varchar(255) COMMENT ''用户id''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dj_officialdoc_distribute' AND column_name = 'selected');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dj_officialdoc_distribute` ADD COLUMN `selected` json COMMENT ''已选（包括部门，包括用户）''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;

-- ############ 表: dq_inspect_problem ############
CREATE TABLE IF NOT EXISTS `dq_inspect_problem` (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建日期',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新日期',
  `sys_org_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '所属部门',
  `secret_level` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '密级',
  `year` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '年份',
  `pid` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '父节点ID',
  `has_child` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '是否有子节点',
  `node_type` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '节点类型：category/surface/specific',
  `problem_name` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '问题名称',
  `problem_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '问题编码/分类字典值',
  `sort_no` int DEFAULT '0' COMMENT '排序',
  `inspect_advice` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '巡视建议',
  `question_res_leader` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '问题责任领导',
  `question_res_dept` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '问题责任部门',
  `del_flag` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '删除标识',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='巡视问题清单';

SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_problem' AND column_name = 'id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_problem` ADD COLUMN `id` varchar(36) NOT NULL', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_problem' AND column_name = 'create_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_problem` ADD COLUMN `create_by` varchar(50) COMMENT ''创建人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_problem' AND column_name = 'create_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_problem` ADD COLUMN `create_time` datetime COMMENT ''创建日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_problem' AND column_name = 'update_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_problem` ADD COLUMN `update_by` varchar(50) COMMENT ''更新人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_problem' AND column_name = 'update_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_problem` ADD COLUMN `update_time` datetime COMMENT ''更新日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_problem' AND column_name = 'sys_org_code');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_problem` ADD COLUMN `sys_org_code` varchar(64) COMMENT ''所属部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_problem' AND column_name = 'secret_level');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_problem` ADD COLUMN `secret_level` varchar(36) COMMENT ''密级''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_problem' AND column_name = 'year');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_problem` ADD COLUMN `year` varchar(30) COMMENT ''年份''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_problem' AND column_name = 'pid');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_problem` ADD COLUMN `pid` varchar(36) DEFAULT ''0'' COMMENT ''父节点ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_problem' AND column_name = 'has_child');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_problem` ADD COLUMN `has_child` varchar(1) DEFAULT ''0'' COMMENT ''是否有子节点''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_problem' AND column_name = 'node_type');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_problem` ADD COLUMN `node_type` varchar(30) COMMENT ''节点类型：category/surface/specific''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_problem' AND column_name = 'problem_name');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_problem` ADD COLUMN `problem_name` varchar(1000) COMMENT ''问题名称''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_problem' AND column_name = 'problem_code');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_problem` ADD COLUMN `problem_code` varchar(64) COMMENT ''问题编码/分类字典值''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_problem' AND column_name = 'sort_no');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_problem` ADD COLUMN `sort_no` int DEFAULT 0 COMMENT ''排序''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_problem' AND column_name = 'inspect_advice');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_problem` ADD COLUMN `inspect_advice` varchar(1000) COMMENT ''巡视建议''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_problem' AND column_name = 'question_res_leader');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_problem` ADD COLUMN `question_res_leader` varchar(255) COMMENT ''问题责任领导''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_problem' AND column_name = 'question_res_dept');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_problem` ADD COLUMN `question_res_dept` varchar(255) COMMENT ''问题责任部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_problem' AND column_name = 'del_flag');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_problem` ADD COLUMN `del_flag` varchar(1) DEFAULT ''0'' COMMENT ''删除标识''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;

-- ############ 表: dq_inspect_progress ############
CREATE TABLE IF NOT EXISTS `dq_inspect_progress` (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建日期',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新日期',
  `sys_org_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '所属部门',
  `feedback_dept_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '反馈部门ID',
  `feedback_dept_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '反馈部门名称',
  `feedback_person_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '反馈人ID',
  `feedback_person_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '反馈人姓名',
  `actual_time` date DEFAULT NULL COMMENT '实际完成时间',
  `work_progress` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '工作进展',
  `bpm_status` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '进展状态',
  `del_flag` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '删除标识',
  `main_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '整改措施任务ID',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_progress' AND column_name = 'id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_progress` ADD COLUMN `id` varchar(36) NOT NULL', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_progress' AND column_name = 'create_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_progress` ADD COLUMN `create_by` varchar(50) COMMENT ''创建人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_progress' AND column_name = 'create_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_progress` ADD COLUMN `create_time` datetime COMMENT ''创建日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_progress' AND column_name = 'update_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_progress` ADD COLUMN `update_by` varchar(50) COMMENT ''更新人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_progress' AND column_name = 'update_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_progress` ADD COLUMN `update_time` datetime COMMENT ''更新日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_progress' AND column_name = 'sys_org_code');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_progress` ADD COLUMN `sys_org_code` varchar(64) COMMENT ''所属部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_progress' AND column_name = 'feedback_dept_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_progress` ADD COLUMN `feedback_dept_id` varchar(64) COMMENT ''反馈部门ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_progress' AND column_name = 'feedback_dept_name');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_progress` ADD COLUMN `feedback_dept_name` varchar(255) COMMENT ''反馈部门名称''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_progress' AND column_name = 'feedback_person_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_progress` ADD COLUMN `feedback_person_id` varchar(64) COMMENT ''反馈人ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_progress' AND column_name = 'feedback_person_name');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_progress` ADD COLUMN `feedback_person_name` varchar(32) COMMENT ''反馈人姓名''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_progress' AND column_name = 'actual_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_progress` ADD COLUMN `actual_time` date COMMENT ''实际完成时间''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_progress' AND column_name = 'work_progress');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_progress` ADD COLUMN `work_progress` varchar(1024) COMMENT ''工作进展''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_progress' AND column_name = 'bpm_status');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_progress` ADD COLUMN `bpm_status` varchar(36) COMMENT ''进展状态''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_progress' AND column_name = 'del_flag');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_progress` ADD COLUMN `del_flag` varchar(32) COMMENT ''删除标识''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_progress' AND column_name = 'main_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_progress` ADD COLUMN `main_id` varchar(32) COMMENT ''整改措施任务ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;

-- ############ 表: dq_inspect_task ############
CREATE TABLE IF NOT EXISTS `dq_inspect_task` (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建日期',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新日期',
  `sys_org_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '所属部门',
  `problem_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '具体问题ID',
  `secret_level` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '密级',
  `improve_measure` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '整改措施',
  `deadline` date DEFAULT NULL COMMENT '完成时限',
  `target_node` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '目标节点',
  `measure_res_leader` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '措施责任领导',
  `measure_res_dept` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '措施责任部门',
  `charge_leader_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '所领导',
  `rectification_evidence` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '整改交付成果',
  `evaluation_criterion` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '成效评价标准',
  `is_need_appro` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '是否需要党群领导审批',
  `sup_deptleaderid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '党群领导',
  `inspection_status` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '检查情况',
  `supervisory_opinion` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '监督意见',
  `measure_count` int DEFAULT NULL COMMENT '措施数量',
  `bpm_process_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '流程实例ID',
  `bpm_status` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '流程状态',
  `task_status` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '整改状态',
  `supervise_count` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '督办次数',
  `sort_no` int DEFAULT '0' COMMENT '排序',
  `del_flag` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '删除标识',
  `completed_stage` int DEFAULT NULL COMMENT '已完成阶段数',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='巡视任务清单';

SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `id` varchar(36) NOT NULL', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'create_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `create_by` varchar(50) COMMENT ''创建人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'create_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `create_time` datetime COMMENT ''创建日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'update_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `update_by` varchar(50) COMMENT ''更新人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'update_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `update_time` datetime COMMENT ''更新日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'sys_org_code');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `sys_org_code` varchar(64) COMMENT ''所属部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'problem_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `problem_id` varchar(36) COMMENT ''具体问题ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'secret_level');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `secret_level` varchar(255) COMMENT ''密级''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'improve_measure');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `improve_measure` varchar(1000) COMMENT ''整改措施''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'deadline');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `deadline` date COMMENT ''完成时限''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'target_node');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `target_node` varchar(1000) COMMENT ''目标节点''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'measure_res_leader');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `measure_res_leader` varchar(255) COMMENT ''措施责任领导''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'measure_res_dept');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `measure_res_dept` varchar(255) COMMENT ''措施责任部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'charge_leader_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `charge_leader_id` varchar(64) COMMENT ''所领导''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'rectification_evidence');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `rectification_evidence` varchar(1000) COMMENT ''整改交付成果''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'evaluation_criterion');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `evaluation_criterion` varchar(1000) COMMENT ''成效评价标准''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'is_need_appro');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `is_need_appro` varchar(32) COMMENT ''是否需要党群领导审批''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'sup_deptleaderid');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `sup_deptleaderid` varchar(255) COMMENT ''党群领导''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'inspection_status');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `inspection_status` varchar(1000) COMMENT ''检查情况''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'supervisory_opinion');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `supervisory_opinion` varchar(1000) COMMENT ''监督意见''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'measure_count');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `measure_count` int COMMENT ''措施数量''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'bpm_process_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `bpm_process_id` varchar(64) COMMENT ''流程实例ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'bpm_status');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `bpm_status` varchar(36) COMMENT ''流程状态''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'task_status');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `task_status` varchar(36) COMMENT ''整改状态''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'supervise_count');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `supervise_count` varchar(36) COMMENT ''督办次数''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'sort_no');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `sort_no` int DEFAULT 0 COMMENT ''排序''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'del_flag');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `del_flag` varchar(1) DEFAULT ''0'' COMMENT ''删除标识''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'dq_inspect_task' AND column_name = 'completed_stage');
SET @ddl = IF(@has = 0, 'ALTER TABLE `dq_inspect_task` ADD COLUMN `completed_stage` int COMMENT ''已完成阶段数''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;

-- ############ 表: fixed_contact_20260730 ############
CREATE TABLE IF NOT EXISTS `fixed_contact_20260730` (
  `id` varchar(36) NOT NULL,
  `create_by` varchar(50) DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(50) DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `sys_org_code` varchar(64) DEFAULT NULL COMMENT '所属部门',
  `seq_no` varchar(50) DEFAULT NULL COMMENT '序号',
  `form_no` varchar(100) DEFAULT NULL COMMENT '表单编号',
  `contact_leader` varchar(100) DEFAULT NULL COMMENT '定点联系所领导',
  `contact_dept` varchar(100) DEFAULT NULL COMMENT '联系单位（部门）',
  `contact_time` date DEFAULT NULL COMMENT '联系时间',
  `meeting_place` varchar(200) DEFAULT NULL COMMENT '座谈地点',
  `suggestion_summary` varchar(2000) DEFAULT NULL COMMENT '联系点建议诉求摘要',
  `leader_opinion` varchar(2000) DEFAULT NULL COMMENT '定点联系所领导审批意见',
  `related_leader_opinion` varchar(2000) DEFAULT NULL COMMENT '相关分管所领导批示意见',
  `related_leader` varchar(100) DEFAULT NULL COMMENT '相关分管所领导',
  `applicant` varchar(100) DEFAULT NULL COMMENT '申请人',
  `host_dept` varchar(100) DEFAULT NULL COMMENT '主办部门',
  `co_dept` varchar(100) DEFAULT NULL COMMENT '协办部门',
  `supervise_count` int DEFAULT NULL COMMENT '督办次数',
  `bpm_status` varchar(32) DEFAULT NULL COMMENT '流程状态：1=未开始，2=督办中，3=已完成',
  `is_need_appro` varchar(1) DEFAULT '0' COMMENT '是否所办领导审批：0=否，1=是',
  `sup_deptleaderid` varchar(255) DEFAULT NULL COMMENT '所办领导ID，多个逗号分隔',
  `approve_info` text COMMENT '部门审批信息',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_20260730' AND column_name = 'id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_20260730` ADD COLUMN `id` varchar(36) NOT NULL', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_20260730' AND column_name = 'create_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_20260730` ADD COLUMN `create_by` varchar(50) COMMENT ''创建人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_20260730' AND column_name = 'create_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_20260730` ADD COLUMN `create_time` datetime COMMENT ''创建时间''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_20260730' AND column_name = 'update_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_20260730` ADD COLUMN `update_by` varchar(50) COMMENT ''更新人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_20260730' AND column_name = 'update_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_20260730` ADD COLUMN `update_time` datetime COMMENT ''更新时间''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_20260730' AND column_name = 'sys_org_code');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_20260730` ADD COLUMN `sys_org_code` varchar(64) COMMENT ''所属部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_20260730' AND column_name = 'seq_no');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_20260730` ADD COLUMN `seq_no` varchar(50) COMMENT ''序号''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_20260730' AND column_name = 'form_no');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_20260730` ADD COLUMN `form_no` varchar(100) COMMENT ''表单编号''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_20260730' AND column_name = 'contact_leader');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_20260730` ADD COLUMN `contact_leader` varchar(100) COMMENT ''定点联系所领导''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_20260730' AND column_name = 'contact_dept');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_20260730` ADD COLUMN `contact_dept` varchar(100) COMMENT ''联系单位（部门）''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_20260730' AND column_name = 'contact_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_20260730` ADD COLUMN `contact_time` date COMMENT ''联系时间''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_20260730' AND column_name = 'meeting_place');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_20260730` ADD COLUMN `meeting_place` varchar(200) COMMENT ''座谈地点''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_20260730' AND column_name = 'suggestion_summary');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_20260730` ADD COLUMN `suggestion_summary` varchar(2000) COMMENT ''联系点建议诉求摘要''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_20260730' AND column_name = 'leader_opinion');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_20260730` ADD COLUMN `leader_opinion` varchar(2000) COMMENT ''定点联系所领导审批意见''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_20260730' AND column_name = 'related_leader_opinion');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_20260730` ADD COLUMN `related_leader_opinion` varchar(2000) COMMENT ''相关分管所领导批示意见''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_20260730' AND column_name = 'related_leader');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_20260730` ADD COLUMN `related_leader` varchar(100) COMMENT ''相关分管所领导''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_20260730' AND column_name = 'applicant');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_20260730` ADD COLUMN `applicant` varchar(100) COMMENT ''申请人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_20260730' AND column_name = 'host_dept');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_20260730` ADD COLUMN `host_dept` varchar(100) COMMENT ''主办部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_20260730' AND column_name = 'co_dept');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_20260730` ADD COLUMN `co_dept` varchar(100) COMMENT ''协办部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_20260730' AND column_name = 'supervise_count');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_20260730` ADD COLUMN `supervise_count` int COMMENT ''督办次数''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_20260730' AND column_name = 'bpm_status');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_20260730` ADD COLUMN `bpm_status` varchar(32) COMMENT ''流程状态：1=未开始，2=督办中，3=已完成''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_20260730' AND column_name = 'is_need_appro');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_20260730` ADD COLUMN `is_need_appro` varchar(1) DEFAULT ''0'' COMMENT ''是否所办领导审批：0=否，1=是''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_20260730' AND column_name = 'sup_deptleaderid');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_20260730` ADD COLUMN `sup_deptleaderid` varchar(255) COMMENT ''所办领导ID，多个逗号分隔''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_20260730' AND column_name = 'approve_info');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_20260730` ADD COLUMN `approve_info` text COMMENT ''部门审批信息''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;

-- ############ 表: fixed_contact_feedback_20260730 ############
CREATE TABLE IF NOT EXISTS `fixed_contact_feedback_20260730` (
  `id` varchar(36) NOT NULL,
  `fixed_contact_20260730_id` varchar(36) DEFAULT NULL COMMENT '主表ID',
  `create_by` varchar(50) DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(50) DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `sys_org_code` varchar(64) DEFAULT NULL COMMENT '所属部门',
  `plan_finish_time` date DEFAULT NULL COMMENT '计划完成时间',
  `plan_finish_status` varchar(500) DEFAULT NULL COMMENT '计划完成情况',
  `handle_opinion` varchar(500) DEFAULT NULL COMMENT '处理意见、承办情况',
  `finish_status` varchar(500) DEFAULT NULL COMMENT '办结情况',
  `actual_finish_time` date DEFAULT NULL COMMENT '实际完成时间',
  `actual_finish_status` varchar(500) DEFAULT NULL COMMENT '实际完成情况',
  `feedback_user` varchar(100) DEFAULT NULL COMMENT '反馈人',
  `feedback_dept` varchar(100) DEFAULT NULL COMMENT '反馈部门',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_feedback_20260730' AND column_name = 'id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_feedback_20260730` ADD COLUMN `id` varchar(36) NOT NULL', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_feedback_20260730' AND column_name = 'fixed_contact_20260730_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_feedback_20260730` ADD COLUMN `fixed_contact_20260730_id` varchar(36) COMMENT ''主表ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_feedback_20260730' AND column_name = 'create_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_feedback_20260730` ADD COLUMN `create_by` varchar(50) COMMENT ''创建人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_feedback_20260730' AND column_name = 'create_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_feedback_20260730` ADD COLUMN `create_time` datetime COMMENT ''创建时间''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_feedback_20260730' AND column_name = 'update_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_feedback_20260730` ADD COLUMN `update_by` varchar(50) COMMENT ''更新人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_feedback_20260730' AND column_name = 'update_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_feedback_20260730` ADD COLUMN `update_time` datetime COMMENT ''更新时间''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_feedback_20260730' AND column_name = 'sys_org_code');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_feedback_20260730` ADD COLUMN `sys_org_code` varchar(64) COMMENT ''所属部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_feedback_20260730' AND column_name = 'plan_finish_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_feedback_20260730` ADD COLUMN `plan_finish_time` date COMMENT ''计划完成时间''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_feedback_20260730' AND column_name = 'plan_finish_status');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_feedback_20260730` ADD COLUMN `plan_finish_status` varchar(500) COMMENT ''计划完成情况''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_feedback_20260730' AND column_name = 'handle_opinion');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_feedback_20260730` ADD COLUMN `handle_opinion` varchar(500) COMMENT ''处理意见、承办情况''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_feedback_20260730' AND column_name = 'finish_status');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_feedback_20260730` ADD COLUMN `finish_status` varchar(500) COMMENT ''办结情况''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_feedback_20260730' AND column_name = 'actual_finish_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_feedback_20260730` ADD COLUMN `actual_finish_time` date COMMENT ''实际完成时间''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_feedback_20260730' AND column_name = 'actual_finish_status');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_feedback_20260730` ADD COLUMN `actual_finish_status` varchar(500) COMMENT ''实际完成情况''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_feedback_20260730' AND column_name = 'feedback_user');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_feedback_20260730` ADD COLUMN `feedback_user` varchar(100) COMMENT ''反馈人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'fixed_contact_feedback_20260730' AND column_name = 'feedback_dept');
SET @ddl = IF(@has = 0, 'ALTER TABLE `fixed_contact_feedback_20260730` ADD COLUMN `feedback_dept` varchar(100) COMMENT ''反馈部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;

-- ############ 表: improvement_dept_score ############
CREATE TABLE IF NOT EXISTS `improvement_dept_score` (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '主键',
  `main_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '改善提案主表ID',
  `process_task_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程任务ID',
  `scorer_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '评委ID',
  `scorer_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '评委姓名',
  `score_status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'pending' COMMENT '评分状态：pending/completed',
  `safety_score` decimal(5,2) DEFAULT NULL COMMENT '安全得分',
  `quality_score` decimal(5,2) DEFAULT NULL COMMENT '质量得分',
  `efficiency_score` decimal(5,2) DEFAULT NULL COMMENT '效率得分',
  `cost_score` decimal(5,2) DEFAULT NULL COMMENT '成本得分',
  `effect_score` decimal(5,2) DEFAULT NULL COMMENT '改善效果平均得分，由安全、质量、效率、成本四项平均计算',
  `promotion_score` decimal(5,2) DEFAULT NULL COMMENT '可推广度得分',
  `originality_score` decimal(5,2) DEFAULT NULL COMMENT '独创性得分',
  `effort_score` decimal(5,2) DEFAULT NULL COMMENT '努力度得分',
  `total_score` decimal(5,2) DEFAULT NULL COMMENT '加权总分',
  `score_opinion` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '评分意见',
  `score_time` datetime DEFAULT NULL COMMENT '评分时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建日期',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新日期',
  `sys_org_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '所属部门',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除状态：0正常，1已删除',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_dept_score_main_scorer` (`main_id`,`scorer_id`) USING BTREE,
  KEY `idx_dept_score_scorer` (`scorer_id`) USING BTREE,
  KEY `idx_dept_score_org` (`sys_org_code`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;

SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_dept_score' AND column_name = 'id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_dept_score` ADD COLUMN `id` varchar(36) NOT NULL COMMENT ''主键''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_dept_score' AND column_name = 'main_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_dept_score` ADD COLUMN `main_id` varchar(36) NOT NULL COMMENT ''改善提案主表ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_dept_score' AND column_name = 'process_task_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_dept_score` ADD COLUMN `process_task_id` varchar(64) COMMENT ''流程任务ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_dept_score' AND column_name = 'scorer_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_dept_score` ADD COLUMN `scorer_id` varchar(36) NOT NULL COMMENT ''评委ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_dept_score' AND column_name = 'scorer_name');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_dept_score` ADD COLUMN `scorer_name` varchar(100) NOT NULL COMMENT ''评委姓名''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_dept_score' AND column_name = 'score_status');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_dept_score` ADD COLUMN `score_status` varchar(20) NOT NULL DEFAULT ''pending'' COMMENT ''评分状态：pending/completed''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_dept_score' AND column_name = 'safety_score');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_dept_score` ADD COLUMN `safety_score` decimal(5,2) COMMENT ''安全得分''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_dept_score' AND column_name = 'quality_score');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_dept_score` ADD COLUMN `quality_score` decimal(5,2) COMMENT ''质量得分''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_dept_score' AND column_name = 'efficiency_score');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_dept_score` ADD COLUMN `efficiency_score` decimal(5,2) COMMENT ''效率得分''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_dept_score' AND column_name = 'cost_score');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_dept_score` ADD COLUMN `cost_score` decimal(5,2) COMMENT ''成本得分''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_dept_score' AND column_name = 'effect_score');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_dept_score` ADD COLUMN `effect_score` decimal(5,2) COMMENT ''改善效果平均得分，由安全、质量、效率、成本四项平均计算''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_dept_score' AND column_name = 'promotion_score');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_dept_score` ADD COLUMN `promotion_score` decimal(5,2) COMMENT ''可推广度得分''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_dept_score' AND column_name = 'originality_score');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_dept_score` ADD COLUMN `originality_score` decimal(5,2) COMMENT ''独创性得分''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_dept_score' AND column_name = 'effort_score');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_dept_score` ADD COLUMN `effort_score` decimal(5,2) COMMENT ''努力度得分''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_dept_score' AND column_name = 'total_score');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_dept_score` ADD COLUMN `total_score` decimal(5,2) COMMENT ''加权总分''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_dept_score' AND column_name = 'score_opinion');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_dept_score` ADD COLUMN `score_opinion` text COMMENT ''评分意见''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_dept_score' AND column_name = 'score_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_dept_score` ADD COLUMN `score_time` datetime COMMENT ''评分时间''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_dept_score' AND column_name = 'create_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_dept_score` ADD COLUMN `create_by` varchar(50) COMMENT ''创建人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_dept_score' AND column_name = 'create_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_dept_score` ADD COLUMN `create_time` datetime COMMENT ''创建日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_dept_score' AND column_name = 'update_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_dept_score` ADD COLUMN `update_by` varchar(50) COMMENT ''更新人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_dept_score' AND column_name = 'update_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_dept_score` ADD COLUMN `update_time` datetime COMMENT ''更新日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_dept_score' AND column_name = 'sys_org_code');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_dept_score` ADD COLUMN `sys_org_code` varchar(64) COMMENT ''所属部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_dept_score' AND column_name = 'del_flag');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_dept_score` ADD COLUMN `del_flag` char(1) NOT NULL DEFAULT ''0'' COMMENT ''删除状态：0正常，1已删除''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;

-- ############ 表: improvement_institute_vote ############
CREATE TABLE IF NOT EXISTS `improvement_institute_vote` (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '主键',
  `main_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '改善提案主表ID',
  `process_task_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程任务ID',
  `voter_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '投票人ID',
  `voter_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '投票人姓名',
  `vote_status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'pending' COMMENT '投票状态：pending/voted',
  `vote_result` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '投票结果：agree/disagree',
  `vote_opinion` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '投票意见',
  `vote_time` datetime DEFAULT NULL COMMENT '投票时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建日期',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新日期',
  `sys_org_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '所属部门',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除状态：0正常，1已删除',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_vote_main_voter` (`main_id`,`voter_id`) USING BTREE,
  KEY `idx_institute_vote_voter` (`voter_id`) USING BTREE,
  KEY `idx_institute_vote_org` (`sys_org_code`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;

SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_institute_vote' AND column_name = 'id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_institute_vote` ADD COLUMN `id` varchar(36) NOT NULL COMMENT ''主键''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_institute_vote' AND column_name = 'main_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_institute_vote` ADD COLUMN `main_id` varchar(36) NOT NULL COMMENT ''改善提案主表ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_institute_vote' AND column_name = 'process_task_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_institute_vote` ADD COLUMN `process_task_id` varchar(64) COMMENT ''流程任务ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_institute_vote' AND column_name = 'voter_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_institute_vote` ADD COLUMN `voter_id` varchar(36) NOT NULL COMMENT ''投票人ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_institute_vote' AND column_name = 'voter_name');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_institute_vote` ADD COLUMN `voter_name` varchar(100) NOT NULL COMMENT ''投票人姓名''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_institute_vote' AND column_name = 'vote_status');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_institute_vote` ADD COLUMN `vote_status` varchar(20) NOT NULL DEFAULT ''pending'' COMMENT ''投票状态：pending/voted''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_institute_vote' AND column_name = 'vote_result');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_institute_vote` ADD COLUMN `vote_result` varchar(20) COMMENT ''投票结果：agree/disagree''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_institute_vote' AND column_name = 'vote_opinion');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_institute_vote` ADD COLUMN `vote_opinion` text COMMENT ''投票意见''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_institute_vote' AND column_name = 'vote_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_institute_vote` ADD COLUMN `vote_time` datetime COMMENT ''投票时间''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_institute_vote' AND column_name = 'create_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_institute_vote` ADD COLUMN `create_by` varchar(50) COMMENT ''创建人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_institute_vote' AND column_name = 'create_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_institute_vote` ADD COLUMN `create_time` datetime COMMENT ''创建日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_institute_vote' AND column_name = 'update_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_institute_vote` ADD COLUMN `update_by` varchar(50) COMMENT ''更新人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_institute_vote' AND column_name = 'update_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_institute_vote` ADD COLUMN `update_time` datetime COMMENT ''更新日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_institute_vote' AND column_name = 'sys_org_code');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_institute_vote` ADD COLUMN `sys_org_code` varchar(64) COMMENT ''所属部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_institute_vote' AND column_name = 'del_flag');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_institute_vote` ADD COLUMN `del_flag` char(1) NOT NULL DEFAULT ''0'' COMMENT ''删除状态：0正常，1已删除''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;

-- ############ 表: improvement_proposal ############
CREATE TABLE IF NOT EXISTS `improvement_proposal` (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '主键',
  `process_instance_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程实例ID',
  `proposal_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '提案编号',
  `proposal_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '提案名称',
  `proposal_date` date NOT NULL COMMENT '提出日期',
  `proposal_dept_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '提案部门ID',
  `proposal_dept_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '提案部门名称',
  `applicant_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '申请人ID',
  `applicant_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '申请人姓名',
  `team_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '团队名称',
  `proposal_category` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '提案类别',
  `problem_desc` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '问题描述',
  `improvement_method` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '改善方法及措施',
  `before_desc` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '改善前情况描述',
  `after_desc` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '改善后情况描述',
  `improvement_effect` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '改善效果',
  `initial_award` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '部门精益专员初步评定奖项',
  `need_dept_score` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '是否需要部门评议打分：1/0',
  `isneedvote` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '是否需要所级评议小组投票：1/0',
  `dept_avg_score` decimal(5,2) DEFAULT NULL COMMENT '部门评议平均分',
  `suggested_award` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '系统建议奖项',
  `leader_final_award` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '部门负责人确认奖项',
  `final_award` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '最终奖项',
  `institute_voters` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '所级评议领导名单',
  `institute_total_voters` int DEFAULT NULL COMMENT '所级评议应投票人数',
  `institute_agree_count` int DEFAULT NULL COMMENT '所级评议同意票数',
  `institute_disagree_count` int DEFAULT NULL COMMENT '所级评议不同意票数',
  `institute_vote_result` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '所级评议结果：passed/failed',
  `manual_confirm_result` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '金奖未通过后的经办人手动确认结果',
  `bpm_status` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程状态',
  `archive_by` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '归档人ID',
  `archive_time` datetime DEFAULT NULL COMMENT '归档时间',
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建日期',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新日期',
  `sys_org_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '所属部门',
  `del_flag` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '删除状态：0正常，1已删除',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_improvement_proposal_no` (`proposal_no`) USING BTREE,
  KEY `idx_improvement_proposal_process` (`process_instance_id`) USING BTREE,
  KEY `idx_improvement_proposal_applicant` (`applicant_id`) USING BTREE,
  KEY `idx_improvement_proposal_dept` (`proposal_dept_id`) USING BTREE,
  KEY `idx_improvement_proposal_org` (`sys_org_code`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;

SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `id` varchar(36) NOT NULL COMMENT ''主键''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'process_instance_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `process_instance_id` varchar(64) COMMENT ''流程实例ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'proposal_no');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `proposal_no` varchar(64) NOT NULL COMMENT ''提案编号''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'proposal_name');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `proposal_name` varchar(200) NOT NULL COMMENT ''提案名称''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'proposal_date');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `proposal_date` date NOT NULL COMMENT ''提出日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'proposal_dept_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `proposal_dept_id` varchar(36) NOT NULL COMMENT ''提案部门ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'proposal_dept_name');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `proposal_dept_name` varchar(100) NOT NULL COMMENT ''提案部门名称''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'applicant_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `applicant_id` varchar(36) NOT NULL COMMENT ''申请人ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'applicant_name');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `applicant_name` varchar(100) NOT NULL COMMENT ''申请人姓名''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'team_name');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `team_name` varchar(200) COMMENT ''团队名称''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'proposal_category');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `proposal_category` varchar(50) NOT NULL COMMENT ''提案类别''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'problem_desc');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `problem_desc` text NOT NULL COMMENT ''问题描述''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'improvement_method');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `improvement_method` text NOT NULL COMMENT ''改善方法及措施''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'before_desc');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `before_desc` text COMMENT ''改善前情况描述''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'after_desc');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `after_desc` text COMMENT ''改善后情况描述''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'improvement_effect');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `improvement_effect` text COMMENT ''改善效果''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'initial_award');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `initial_award` varchar(50) COMMENT ''部门精益专员初步评定奖项''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'need_dept_score');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `need_dept_score` varchar(1) COMMENT ''是否需要部门评议打分：1/0''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'isneedvote');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `isneedvote` varchar(2) COMMENT ''是否需要所级评议小组投票：1/0''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'dept_avg_score');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `dept_avg_score` decimal(5,2) COMMENT ''部门评议平均分''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'suggested_award');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `suggested_award` varchar(50) COMMENT ''系统建议奖项''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'leader_final_award');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `leader_final_award` varchar(50) COMMENT ''部门负责人确认奖项''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'final_award');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `final_award` varchar(50) COMMENT ''最终奖项''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'institute_voters');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `institute_voters` varchar(255) COMMENT ''所级评议领导名单''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'institute_total_voters');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `institute_total_voters` int COMMENT ''所级评议应投票人数''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'institute_agree_count');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `institute_agree_count` int COMMENT ''所级评议同意票数''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'institute_disagree_count');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `institute_disagree_count` int COMMENT ''所级评议不同意票数''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'institute_vote_result');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `institute_vote_result` varchar(20) COMMENT ''所级评议结果：passed/failed''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'manual_confirm_result');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `manual_confirm_result` varchar(50) COMMENT ''金奖未通过后的经办人手动确认结果''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'bpm_status');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `bpm_status` varchar(50) COMMENT ''流程状态''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'archive_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `archive_by` varchar(36) COMMENT ''归档人ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'archive_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `archive_time` datetime COMMENT ''归档时间''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'create_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `create_by` varchar(50) COMMENT ''创建人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'create_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `create_time` datetime COMMENT ''创建日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'update_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `update_by` varchar(50) COMMENT ''更新人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'update_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `update_time` datetime COMMENT ''更新日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'sys_org_code');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `sys_org_code` varchar(64) COMMENT ''所属部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal' AND column_name = 'del_flag');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal` ADD COLUMN `del_flag` varchar(1) NOT NULL COMMENT ''删除状态：0正常，1已删除''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;

-- ############ 表: improvement_proposal_year_sequence ############
CREATE TABLE IF NOT EXISTS `improvement_proposal_year_sequence` (
  `sequence_year` int NOT NULL COMMENT '年度',
  `current_sequence` int NOT NULL DEFAULT '0' COMMENT '当前年度最大流水号',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`sequence_year`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='改善提案年度流水号控制表';

SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal_year_sequence' AND column_name = 'sequence_year');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal_year_sequence` ADD COLUMN `sequence_year` int NOT NULL COMMENT ''年度''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal_year_sequence' AND column_name = 'current_sequence');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal_year_sequence` ADD COLUMN `current_sequence` int NOT NULL DEFAULT 0 COMMENT ''当前年度最大流水号''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'improvement_proposal_year_sequence' AND column_name = 'update_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `improvement_proposal_year_sequence` ADD COLUMN `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT ''更新时间''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;

-- ############ 表: task_list ############
CREATE TABLE IF NOT EXISTS `task_list` (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建日期',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新日期',
  `sys_org_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '所属部门',
  `tasklist_name` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '清单名称',
  `del_flag` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '删除标识',
  `secret_text` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '密级名称',
  `secret_level` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '密级',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list' AND column_name = 'id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list` ADD COLUMN `id` varchar(36) NOT NULL', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list' AND column_name = 'create_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list` ADD COLUMN `create_by` varchar(50) COMMENT ''创建人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list' AND column_name = 'create_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list` ADD COLUMN `create_time` datetime COMMENT ''创建日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list' AND column_name = 'update_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list` ADD COLUMN `update_by` varchar(50) COMMENT ''更新人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list' AND column_name = 'update_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list` ADD COLUMN `update_time` datetime COMMENT ''更新日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list' AND column_name = 'sys_org_code');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list` ADD COLUMN `sys_org_code` varchar(64) COMMENT ''所属部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list' AND column_name = 'tasklist_name');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list` ADD COLUMN `tasklist_name` varchar(300) COMMENT ''清单名称''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list' AND column_name = 'del_flag');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list` ADD COLUMN `del_flag` varchar(2) DEFAULT ''0'' COMMENT ''删除标识''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list' AND column_name = 'secret_text');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list` ADD COLUMN `secret_text` varchar(32) COMMENT ''密级名称''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list' AND column_name = 'secret_level');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list` ADD COLUMN `secret_level` varchar(32) COMMENT ''密级''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;

-- ############ 表: task_list_detial ############
CREATE TABLE IF NOT EXISTS `task_list_detial` (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建日期',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新日期',
  `sys_org_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '所属部门',
  `main_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '主表ID',
  `pid` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '父节点ID',
  `has_child` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '是否有子节点',
  `sort_order` int DEFAULT '0' COMMENT '排序号',
  `task_name` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '任务名称',
  `task_desc` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '任务描述',
  `priority` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '优先级',
  `task_status` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '完成状态',
  `assignee_id` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '负责人ID',
  `assignee_name` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '负责人',
  `followers_id` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '关注人ID',
  `followers_name` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '关注人',
  `assign_id` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '分配人ID',
  `assign_name` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '分配人',
  `start_time` datetime DEFAULT NULL COMMENT '开始时间',
  `end_time` datetime DEFAULT NULL COMMENT '结束时间',
  `complete_time` datetime DEFAULT NULL COMMENT '完成时间',
  `type` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '类型',
  `sub_task_count` int DEFAULT '0' COMMENT '子任务数',
  `completed_sub_task_count` int DEFAULT '0' COMMENT '子任务完成数',
  `del_flag` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '删除标识',
  `participant_name` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '参与人',
  `participant_id` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '参与人ID',
  `remark` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '其他事项说明',
  `is_default` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '是否是默认分组',
  `version` int NOT NULL DEFAULT '0' COMMENT '乐观锁版本号',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `id` varchar(36) NOT NULL', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'create_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `create_by` varchar(50) COMMENT ''创建人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'create_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `create_time` datetime COMMENT ''创建日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'update_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `update_by` varchar(50) COMMENT ''更新人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'update_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `update_time` datetime COMMENT ''更新日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'sys_org_code');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `sys_org_code` varchar(64) COMMENT ''所属部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'main_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `main_id` varchar(36) COMMENT ''主表ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'pid');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `pid` varchar(36) COMMENT ''父节点ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'has_child');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `has_child` varchar(3) DEFAULT ''0'' COMMENT ''是否有子节点''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'sort_order');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `sort_order` int DEFAULT 0 COMMENT ''排序号''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'task_name');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `task_name` varchar(300) COMMENT ''任务名称''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'task_desc');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `task_desc` varchar(512) COMMENT ''任务描述''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'priority');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `priority` varchar(10) COMMENT ''优先级''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'task_status');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `task_status` varchar(3) COMMENT ''完成状态''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'assignee_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `assignee_id` varchar(512) COMMENT ''负责人ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'assignee_name');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `assignee_name` varchar(512) COMMENT ''负责人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'followers_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `followers_id` varchar(512) COMMENT ''关注人ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'followers_name');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `followers_name` varchar(512) COMMENT ''关注人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'assign_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `assign_id` varchar(512) COMMENT ''分配人ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'assign_name');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `assign_name` varchar(512) COMMENT ''分配人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'start_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `start_time` datetime COMMENT ''开始时间''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'end_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `end_time` datetime COMMENT ''结束时间''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'complete_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `complete_time` datetime COMMENT ''完成时间''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'type');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `type` varchar(3) COMMENT ''类型''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'sub_task_count');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `sub_task_count` int DEFAULT 0 COMMENT ''子任务数''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'completed_sub_task_count');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `completed_sub_task_count` int DEFAULT 0 COMMENT ''子任务完成数''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'del_flag');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `del_flag` varchar(2) DEFAULT ''0'' COMMENT ''删除标识''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'participant_name');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `participant_name` varchar(512) COMMENT ''参与人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'participant_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `participant_id` varchar(512) COMMENT ''参与人ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'remark');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `remark` varchar(512) COMMENT ''其他事项说明''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'is_default');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `is_default` varchar(2) DEFAULT ''0'' COMMENT ''是否是默认分组''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_detial' AND column_name = 'version');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_detial` ADD COLUMN `version` int NOT NULL DEFAULT 0 COMMENT ''乐观锁版本号''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;

-- ############ 表: task_list_favorite ############
CREATE TABLE IF NOT EXISTS `task_list_favorite` (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建日期',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新日期',
  `sys_org_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '所属部门',
  `main_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '主表ID',
  `user_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '用户ID',
  `type` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '类型（0是分组，1是清单）',
  `pid` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '父节点ID',
  `has_child` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '是否有子节点',
  `sort_order` int DEFAULT NULL COMMENT '排序',
  `del_flag` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '删除标识',
  `tasklist_name` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '任务清单（分组）名称',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_favorite' AND column_name = 'id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_favorite` ADD COLUMN `id` varchar(36) NOT NULL', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_favorite' AND column_name = 'create_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_favorite` ADD COLUMN `create_by` varchar(50) COMMENT ''创建人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_favorite' AND column_name = 'create_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_favorite` ADD COLUMN `create_time` datetime COMMENT ''创建日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_favorite' AND column_name = 'update_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_favorite` ADD COLUMN `update_by` varchar(50) COMMENT ''更新人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_favorite' AND column_name = 'update_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_favorite` ADD COLUMN `update_time` datetime COMMENT ''更新日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_favorite' AND column_name = 'sys_org_code');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_favorite` ADD COLUMN `sys_org_code` varchar(64) COMMENT ''所属部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_favorite' AND column_name = 'main_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_favorite` ADD COLUMN `main_id` varchar(36) COMMENT ''主表ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_favorite' AND column_name = 'user_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_favorite` ADD COLUMN `user_id` varchar(36) COMMENT ''用户ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_favorite' AND column_name = 'type');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_favorite` ADD COLUMN `type` varchar(3) COMMENT ''类型（0是分组，1是清单）''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_favorite' AND column_name = 'pid');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_favorite` ADD COLUMN `pid` varchar(36) COMMENT ''父节点ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_favorite' AND column_name = 'has_child');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_favorite` ADD COLUMN `has_child` varchar(3) COMMENT ''是否有子节点''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_favorite' AND column_name = 'sort_order');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_favorite` ADD COLUMN `sort_order` int COMMENT ''排序''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_favorite' AND column_name = 'del_flag');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_favorite` ADD COLUMN `del_flag` varchar(2) DEFAULT ''0'' COMMENT ''删除标识''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_favorite' AND column_name = 'tasklist_name');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_favorite` ADD COLUMN `tasklist_name` varchar(300) COMMENT ''任务清单（分组）名称''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;

-- ############ 表: task_list_permission ############
CREATE TABLE IF NOT EXISTS `task_list_permission` (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建日期',
  `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新日期',
  `sys_org_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '所属部门',
  `main_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '主表ID',
  `user_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '用户ID',
  `permission` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '权限类型',
  `del_flag` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '删除标识',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_permission' AND column_name = 'id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_permission` ADD COLUMN `id` varchar(36) NOT NULL', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_permission' AND column_name = 'create_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_permission` ADD COLUMN `create_by` varchar(50) COMMENT ''创建人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_permission' AND column_name = 'create_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_permission` ADD COLUMN `create_time` datetime COMMENT ''创建日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_permission' AND column_name = 'update_by');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_permission` ADD COLUMN `update_by` varchar(50) COMMENT ''更新人''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_permission' AND column_name = 'update_time');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_permission` ADD COLUMN `update_time` datetime COMMENT ''更新日期''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_permission' AND column_name = 'sys_org_code');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_permission` ADD COLUMN `sys_org_code` varchar(64) COMMENT ''所属部门''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_permission' AND column_name = 'main_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_permission` ADD COLUMN `main_id` varchar(36) COMMENT ''主表ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_permission' AND column_name = 'user_id');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_permission` ADD COLUMN `user_id` varchar(36) COMMENT ''用户ID''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_permission' AND column_name = 'permission');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_permission` ADD COLUMN `permission` varchar(3) COMMENT ''权限类型''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;
SET @has = (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'task_list_permission' AND column_name = 'del_flag');
SET @ddl = IF(@has = 0, 'ALTER TABLE `task_list_permission` ADD COLUMN `del_flag` varchar(2) DEFAULT ''0'' COMMENT ''删除标识''', 'SELECT 1');
PREPARE __s FROM @ddl; EXECUTE __s; DEALLOCATE PREPARE __s;

