-- =============================================
-- 任务清单表
-- =============================================
CREATE TABLE `safety_accountability_task_list` (
    `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
    `task_list_id` varchar(64) NOT NULL COMMENT '清单UUID（业务主键）',
    `task_list_name` varchar(255) NOT NULL COMMENT '清单名称',
    `task_level` tinyint NOT NULL COMMENT '任务级别：1-企业级 2-部门级 3-班组级',
    `responsibility_post` varchar(255) NOT NULL COMMENT '责任岗位',
    `switch_flag` tinyint(1) NOT NULL DEFAULT '1' COMMENT '开启/关闭：0-关 1-开',
    `create_corp_id` bigint DEFAULT NULL COMMENT '创建公司ID',
    `create_department_id` bigint DEFAULT NULL COMMENT '创建部门ID',
    `create_user_id` bigint DEFAULT NULL COMMENT '创建人ID',
    `status` tinyint NOT NULL DEFAULT '1' COMMENT '状态：1-进行中 2-已完成 3-已关闭',
    `delete_enum` varchar(32) DEFAULT 'FALSE' COMMENT '删除标识：TRUE/FALSE',
    `remarks` varchar(500) DEFAULT NULL COMMENT '备注',
    `create_name` varchar(50) DEFAULT NULL COMMENT '创建人姓名',
    `update_name` varchar(50) DEFAULT NULL COMMENT '更新人姓名',
    `tenant_id` bigint DEFAULT NULL COMMENT '租户ID',
    `org_id` bigint DEFAULT NULL COMMENT '单位ID',
    `version` int DEFAULT '0' COMMENT '版本',
    `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
    `create_id` bigint DEFAULT NULL COMMENT '创建人ID',
    `update_id` bigint DEFAULT NULL COMMENT '修改人ID',
    `env` varchar(50) DEFAULT NULL COMMENT '环境标识',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_task_list_id` (`task_list_id`),
    KEY `idx_create_corp_id` (`create_corp_id`),
    KEY `idx_status_task_list_id` (`task_list_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='任务清单表';

-- =============================================
-- 任务清单详细表
-- =============================================
CREATE TABLE `safety_accountability_task_detail` (
    `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
    `task_detail_id` varchar(64) NOT NULL COMMENT '任务详情UUID（业务主键）',
    `task_list_id` varchar(64) NOT NULL COMMENT '任务清单主键（关联任务清单表）',
    `execute_content` text COMMENT '执行内容',
    `feedback_cycle_type` tinyint NOT NULL COMMENT '反馈周期类型：1-每月 2-季度 3-半年 4-年',
    `task_score` decimal(5,2) DEFAULT NULL COMMENT '任务分值',
    `task_status` tinyint NOT NULL DEFAULT '1' COMMENT '任务状态：1-进行中 2-已完成 3-已关闭',
    `delete_enum` varchar(32) DEFAULT 'FALSE' COMMENT '删除标识：TRUE/FALSE',
    `remarks` varchar(500) DEFAULT NULL COMMENT '备注',
    `create_name` varchar(50) DEFAULT NULL COMMENT '创建人姓名',
    `update_name` varchar(50) DEFAULT NULL COMMENT '更新人姓名',
    `tenant_id` bigint DEFAULT NULL COMMENT '租户ID',
    `org_id` bigint DEFAULT NULL COMMENT '单位ID',
    `version` int DEFAULT '0' COMMENT '版本',
    `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
    `create_id` bigint DEFAULT NULL COMMENT '创建人ID',
    `update_id` bigint DEFAULT NULL COMMENT '修改人ID',
    `env` varchar(50) DEFAULT NULL COMMENT '环境标识',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_task_detail_id` (`task_detail_id`),
    KEY `idx_task_list_id` (`task_list_id`),
    KEY `idx_task_list_status` (`task_list_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='任务清单详细表';

-- =============================================
-- 任务下发记录表
-- =============================================
CREATE TABLE `safety_accountability_task_list_issue` (
    `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
    `task_issue_id` varchar(64) NOT NULL COMMENT '下发记录UUID（业务主键）',
    `task_list_id` varchar(64) NOT NULL COMMENT '清单UUID（关联清单模板表）',
    `execute_corp_id` bigint DEFAULT NULL COMMENT '执行公司ID',
    `execute_department_id` bigint DEFAULT NULL COMMENT '执行部门ID',
    `execute_user_id` bigint DEFAULT NULL COMMENT '执行人员ID',
    `issue_status` tinyint DEFAULT '0' COMMENT '下发状态：0-未下发 1-已下发',
    `issue_time` datetime DEFAULT NULL COMMENT '下发时间',
    `issue_corp_id` bigint DEFAULT NULL COMMENT '下发公司ID',
    `issue_department_id` bigint DEFAULT NULL COMMENT '下发部门ID',
    `issue_user_id` bigint DEFAULT NULL COMMENT '下发人员ID',
    `period_start_time` datetime DEFAULT NULL COMMENT '执行周期开始时间',
    `period_end_time` datetime DEFAULT NULL COMMENT '执行周期结束时间',
    `status` tinyint NOT NULL DEFAULT '1' COMMENT '状态：1-进行中 2-已完成 3-已关闭',
    `close_time` datetime DEFAULT NULL COMMENT '关闭时间',
    `rating_score` decimal(5,2) DEFAULT NULL COMMENT '评分数（汇总所有任务执行评分）',
    `rating_user_id` bigint DEFAULT NULL COMMENT '评分人ID',
    `rating_department_id` bigint DEFAULT NULL COMMENT '评分部门ID',
    `delete_enum` varchar(32) DEFAULT 'FALSE' COMMENT '删除标识：TRUE/FALSE',
    `remarks` varchar(500) DEFAULT NULL COMMENT '备注',
    `create_name` varchar(50) DEFAULT NULL COMMENT '创建人姓名',
    `update_name` varchar(50) DEFAULT NULL COMMENT '更新人姓名',
    `tenant_id` bigint DEFAULT NULL COMMENT '租户ID',
    `org_id` bigint DEFAULT NULL COMMENT '单位ID',
    `version` int DEFAULT '0' COMMENT '版本',
    `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
    `create_id` bigint DEFAULT NULL COMMENT '创建人ID',
    `update_id` bigint DEFAULT NULL COMMENT '修改人ID',
    `env` varchar(50) DEFAULT NULL COMMENT '环境标识',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_task_issue_id` (`task_issue_id`),
    KEY `idx_tenant_org_status` (`tenant_id`,`org_id`,`status`),
    KEY `idx_task_list_id` (`task_list_id`),
    KEY `idx_execute_corp_dept_user` (`execute_corp_id`, `execute_department_id`, `execute_user_id`),
    KEY `idx_period_start` (`period_start_time`),
    KEY `idx_issue_time` (`issue_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='清单下发记录表';

-- =============================================
-- 任务执行表
-- =============================================
CREATE TABLE `safety_accountability_task_execution` (
    `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
    `task_execution_id` varchar(64) NOT NULL COMMENT '任务执行UUID（业务主键）',
    `task_issue_id` varchar(64) NOT NULL COMMENT '清单下发记录UUID（关联下发记录表）',
    `task_detail_id` varchar(64) NOT NULL COMMENT '任务模板UUID（关联任务详情模板表）',
    `task_list_id` varchar(64) NOT NULL COMMENT '清单UUID（冗余，便于查询）',
    `task_status` tinyint NOT NULL DEFAULT '1' COMMENT '任务状态：1-进行中 2-已完成 3-已关闭',
    `feedback_status` tinyint DEFAULT '1' COMMENT '反馈状态：1-正常 2-异常',
    `task_rating` decimal(5,2) DEFAULT NULL COMMENT '任务评分',
    `rating_time` datetime DEFAULT NULL COMMENT '评分时间',
    `rating_department_id` bigint DEFAULT NULL COMMENT '评分部门ID',
    `rating_user_id` bigint DEFAULT NULL COMMENT '评分人ID',
    `delete_enum` varchar(32) DEFAULT 'FALSE' COMMENT '删除标识：TRUE/FALSE',
    `remarks` varchar(500) DEFAULT NULL COMMENT '备注',
    `create_name` varchar(50) DEFAULT NULL COMMENT '创建人姓名',
    `update_name` varchar(50) DEFAULT NULL COMMENT '更新人姓名',
    `tenant_id` bigint DEFAULT NULL COMMENT '租户ID',
    `org_id` bigint DEFAULT NULL COMMENT '单位ID',
    `version` int DEFAULT '0' COMMENT '版本',
    `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
    `create_id` bigint DEFAULT NULL COMMENT '创建人ID',
    `update_id` bigint DEFAULT NULL COMMENT '修改人ID',
    `env` varchar(50) DEFAULT NULL COMMENT '环境标识',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_task_execution_id` (`task_execution_id`),
    KEY `idx_tenant_org_task` (`tenant_id`,`org_id`,`task_status`),
    KEY `idx_task_issue_id` (`task_issue_id`),
    KEY `idx_task_detail_id` (`task_detail_id`),
    KEY `idx_task_list_id` (`task_list_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='任务执行记录表';

-- =============================================
-- 执行反馈表
-- =============================================
CREATE TABLE `safety_accountability_feedback` (
    `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
    `feedback_id` varchar(64) NOT NULL COMMENT '反馈UUID（业务主键）',
    `task_detail_id` varchar(64) NOT NULL COMMENT '任务详情UUID（关联任务清单详细表）',
    `task_execution_id` varchar(64) DEFAULT NULL COMMENT '任务执行UUID（关联任务执行表）',
    `task_list_id` varchar(64) NOT NULL COMMENT '任务清单UUID（冗余字段，便于查询）',
    `task_issue_id` varchar(64) DEFAULT NULL COMMENT '清单下发记录UUID（冗余）',
    `feedback_time` datetime NOT NULL COMMENT '反馈时间',
    `feedback_period_start_time` datetime NOT NULL COMMENT '反馈周期开始时间（用于回显）',
    `feedback_period_end_time` datetime NOT NULL COMMENT '反馈周期结束时间（用于回显）',
    `feedback_period_flag` varchar(20) NOT NULL COMMENT '反馈周期标识（格式：2026-05表示月，2026-Q1表示季度，2026-H1表示半年，2026表示年）',
    `feedback_content` text COMMENT '反馈内容',
    `feedback_corp_id` bigint DEFAULT NULL COMMENT '反馈人公司ID',
    `feedback_department_id` bigint DEFAULT NULL COMMENT '反馈人部门ID',
    `feedback_user_id` bigint DEFAULT NULL COMMENT '反馈人ID',
    `delete_enum` varchar(32) DEFAULT 'FALSE' COMMENT '删除标识：TRUE/FALSE',
    `remarks` varchar(500) DEFAULT NULL COMMENT '备注',
    `create_name` varchar(50) DEFAULT NULL COMMENT '创建人姓名',
    `update_name` varchar(50) DEFAULT NULL COMMENT '更新人姓名',
    `tenant_id` bigint DEFAULT NULL COMMENT '租户ID',
    `org_id` bigint DEFAULT NULL COMMENT '单位ID',
    `version` int DEFAULT '0' COMMENT '版本',
    `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
    `create_id` bigint DEFAULT NULL COMMENT '创建人ID',
    `update_id` bigint DEFAULT NULL COMMENT '修改人ID',
    `env` varchar(50) DEFAULT NULL COMMENT '环境标识',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_feedback_id` (`feedback_id`),
    KEY `idx_task_detail_id` (`task_detail_id`),
    KEY `idx_task_list_id` (`task_list_id`),
    KEY `idx_feedback_time` (`feedback_time`),
    KEY `idx_feedback_user_id` (`feedback_user_id`),
    KEY `idx_taskdetail_period` (`task_detail_id`,`feedback_period_flag`),
    KEY `idx_task_execution_id` (`task_execution_id`),
    KEY `idx_task_issue_id` (`task_issue_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='执行反馈表';

-- =============================================
-- 反馈异常信息表
-- =============================================
CREATE TABLE `safety_accountability_feedback_exception` (
    `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
    `feedback_exception_id` varchar(64) NOT NULL COMMENT '反馈异常UUID（业务主键）',
    `task_detail_id` varchar(64) NOT NULL COMMENT '任务详情主键（关联任务清单详细表）',
    `task_execution_id` varchar(64) DEFAULT NULL COMMENT '任务执行UUID（关联任务执行表）',
    `task_list_id` varchar(64) DEFAULT NULL COMMENT '任务清单主键（冗余字段）',
    `task_issue_id` varchar(64) DEFAULT NULL COMMENT '清单下发记录UUID（冗余）',
    `exception_period_flag` varchar(20) NOT NULL COMMENT '异常周期标识',
    `exception_period_start_time` datetime DEFAULT NULL COMMENT '反馈周期开始时间（用于回显）',
    `exception_period_end_time` datetime DEFAULT NULL COMMENT '反馈周期结束时间（用于回显）',
    `exception_type` tinyint DEFAULT '1' COMMENT '异常类型：1-未按时反馈 2-反馈内容异常 3-其他',
    `exception_content` text COMMENT '反馈异常信息',
    `exception_time` datetime DEFAULT NULL COMMENT '异常时间',
    `delete_enum` varchar(32) DEFAULT 'FALSE' COMMENT '删除标识：TRUE/FALSE',
    `remarks` varchar(500) DEFAULT NULL COMMENT '备注',
    `create_name` varchar(50) DEFAULT NULL COMMENT '创建人姓名',
    `update_name` varchar(50) DEFAULT NULL COMMENT '更新人姓名',
    `tenant_id` bigint DEFAULT NULL COMMENT '租户ID',
    `org_id` bigint DEFAULT NULL COMMENT '单位ID',
    `version` int DEFAULT '0' COMMENT '版本',
    `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
    `create_id` bigint DEFAULT NULL COMMENT '创建人ID',
    `update_id` bigint DEFAULT NULL COMMENT '修改人ID',
    `env` varchar(50) DEFAULT NULL COMMENT '环境标识',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_feedback_exception_id` (`feedback_exception_id`),
    KEY `idx_task_detail_id` (`task_detail_id`),
    KEY `idx_task_list_id` (`task_list_id`),
    KEY `idx_taskdetail_ex_period` (`task_detail_id`,`exception_period_flag`),
    KEY `idx_taskdetail_ex_type` (`task_detail_id`,`exception_type`),
    KEY `idx_task_execution_id` (`task_execution_id`),
    KEY `idx_task_issue_id` (`task_issue_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='反馈异常信息表';

-- =============================================
-- 公司信息视图
-- =============================================
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `corp_info` AS select `jjb-saas-zcloud-basic-info`.`corp_info`.`id` AS `id`,`jjb-saas-zcloud-basic-info`.`corp_info`.`corpinfo_id` AS `corpinfo_id`,`jjb-saas-zcloud-basic-info`.`corp_info`.`corp_name` AS `corp_name`,`jjb-saas-zcloud-basic-info`.`corp_info`.`type` AS `type`,`jjb-saas-zcloud-basic-info`.`corp_info`.`xgf_level` AS `xgf_level`,`jjb-saas-zcloud-basic-info`.`corp_info`.`corp_order` AS `corp_order`,`jjb-saas-zcloud-basic-info`.`corp_info`.`use_flag` AS `use_flag`,`jjb-saas-zcloud-basic-info`.`corp_info`.`code` AS `code`,`jjb-saas-zcloud-basic-info`.`corp_info`.`address` AS `address`,`jjb-saas-zcloud-basic-info`.`corp_info`.`postal_code` AS `postal_code`,`jjb-saas-zcloud-basic-info`.`corp_info`.`company_area` AS `company_area`,`jjb-saas-zcloud-basic-info`.`corp_info`.`scale` AS `scale`,`jjb-saas-zcloud-basic-info`.`corp_info`.`scale_name` AS `scale_name`,`jjb-saas-zcloud-basic-info`.`corp_info`.`scale_type` AS `scale_type`,`jjb-saas-zcloud-basic-info`.`corp_info`.`create_date` AS `create_date`,`jjb-saas-zcloud-basic-info`.`corp_info`.`corp_state` AS `corp_state`,`jjb-saas-zcloud-basic-info`.`corp_info`.`corp_state_name` AS `corp_state_name`,`jjb-saas-zcloud-basic-info`.`corp_info`.`total_assets` AS `total_assets`,`jjb-saas-zcloud-basic-info`.`corp_info`.`regcapital` AS `regcapital`,`jjb-saas-zcloud-basic-info`.`corp_info`.`address_business` AS `address_business`,`jjb-saas-zcloud-basic-info`.`corp_info`.`address_office` AS `address_office`,`jjb-saas-zcloud-basic-info`.`corp_info`.`eco_type` AS `eco_type`,`jjb-saas-zcloud-basic-info`.`corp_info`.`eco_type_name` AS `eco_type_name`,`jjb-saas-zcloud-basic-info`.`corp_info`.`contacts` AS `contacts`,`jjb-saas-zcloud-basic-info`.`corp_info`.`contacts_phone` AS `contacts_phone`,`jjb-saas-zcloud-basic-info`.`corp_info`.`safety_name` AS `safety_name`,`jjb-saas-zcloud-basic-info`.`corp_info`.`safety_phone` AS `safety_phone`,`jjb-saas-zcloud-basic-info`.`corp_info`.`area_covered` AS `area_covered`,`jjb-saas-zcloud-basic-info`.`corp_info`.`employees` AS `employees`,`jjb-saas-zcloud-basic-info`.`corp_info`.`longitude` AS `longitude`,`jjb-saas-zcloud-basic-info`.`corp_info`.`latitude` AS `latitude`,`jjb-saas-zcloud-basic-info`.`corp_info`.`area_name` AS `area_name`,`jjb-saas-zcloud-basic-info`.`corp_info`.`area_code` AS `area_code`,`jjb-saas-zcloud-basic-info`.`corp_info`.`lr_name` AS `lr_name`,`jjb-saas-zcloud-basic-info`.`corp_info`.`lr_mobile` AS `lr_mobile`,`jjb-saas-zcloud-basic-info`.`corp_info`.`corp_type` AS `corp_type`,`jjb-saas-zcloud-basic-info`.`corp_info`.`corp_type_name` AS `corp_type_name`,`jjb-saas-zcloud-basic-info`.`corp_info`.`corp_type2` AS `corp_type2`,`jjb-saas-zcloud-basic-info`.`corp_info`.`corp_type2_name` AS `corp_type2_name`,`jjb-saas-zcloud-basic-info`.`corp_info`.`corp_type3` AS `corp_type3`,`jjb-saas-zcloud-basic-info`.`corp_info`.`corp_type3_name` AS `corp_type3_name`,`jjb-saas-zcloud-basic-info`.`corp_info`.`corp_type4` AS `corp_type4`,`jjb-saas-zcloud-basic-info`.`corp_info`.`corp_type4_name` AS `corp_type4_name`,`jjb-saas-zcloud-basic-info`.`corp_info`.`province_name` AS `province_name`,`jjb-saas-zcloud-basic-info`.`corp_info`.`province` AS `province`,`jjb-saas-zcloud-basic-info`.`corp_info`.`city_name` AS `city_name`,`jjb-saas-zcloud-basic-info`.`corp_info`.`city` AS `city`,`jjb-saas-zcloud-basic-info`.`corp_info`.`country_name` AS `country_name`,`jjb-saas-zcloud-basic-info`.`corp_info`.`country` AS `country`,`jjb-saas-zcloud-basic-info`.`corp_info`.`village_name` AS `village_name`,`jjb-saas-zcloud-basic-info`.`corp_info`.`village` AS `village`,`jjb-saas-zcloud-basic-info`.`corp_info`.`street_name` AS `street_name`,`jjb-saas-zcloud-basic-info`.`corp_info`.`street` AS `street`,`jjb-saas-zcloud-basic-info`.`corp_info`.`license_start` AS `license_start`,`jjb-saas-zcloud-basic-info`.`corp_info`.`license_end` AS `license_end`,`jjb-saas-zcloud-basic-info`.`corp_info`.`whether_hygiene_flag` AS `whether_hygiene_flag`,`jjb-saas-zcloud-basic-info`.`corp_info`.`whether_hazards_flag` AS `whether_hazards_flag`,`jjb-saas-zcloud-basic-info`.`corp_info`.`whether_scarce_flag` AS `whether_scarce_flag`,`jjb-saas-zcloud-basic-info`.`corp_info`.`whether_chemicals_flag` AS `whether_chemicals_flag`,`jjb-saas-zcloud-basic-info`.`corp_info`.`whether_specialequipment_flag` AS `whether_specialequipment_flag`,`jjb-saas-zcloud-basic-info`.`corp_info`.`whether_specialpeople_flag` AS `whether_specialpeople_flag`,`jjb-saas-zcloud-basic-info`.`corp_info`.`whether_coalgas_flag` AS `whether_coalgas_flag`,`jjb-saas-zcloud-basic-info`.`corp_info`.`whether_fire_flag` AS `whether_fire_flag`,`jjb-saas-zcloud-basic-info`.`corp_info`.`whether_confined_flag` AS `whether_confined_flag`,`jjb-saas-zcloud-basic-info`.`corp_info`.`whether_powder_flag` AS `whether_powder_flag`,`jjb-saas-zcloud-basic-info`.`corp_info`.`whether_lightning_flag` AS `whether_lightning_flag`,`jjb-saas-zcloud-basic-info`.`corp_info`.`whether_pipeline_flag` AS `whether_pipeline_flag`,`jjb-saas-zcloud-basic-info`.`corp_info`.`whether_actinogen_flag` AS `whether_actinogen_flag`,`jjb-saas-zcloud-basic-info`.`corp_info`.`whether_liquidammonia_flag` AS `whether_liquidammonia_flag`,`jjb-saas-zcloud-basic-info`.`corp_info`.`version` AS `version`,`jjb-saas-zcloud-basic-info`.`corp_info`.`create_id` AS `create_id`,`jjb-saas-zcloud-basic-info`.`corp_info`.`create_name` AS `create_name`,`jjb-saas-zcloud-basic-info`.`corp_info`.`create_time` AS `create_time`,`jjb-saas-zcloud-basic-info`.`corp_info`.`update_id` AS `update_id`,`jjb-saas-zcloud-basic-info`.`corp_info`.`update_name` AS `update_name`,`jjb-saas-zcloud-basic-info`.`corp_info`.`update_time` AS `update_time`,`jjb-saas-zcloud-basic-info`.`corp_info`.`remarks` AS `remarks`,`jjb-saas-zcloud-basic-info`.`corp_info`.`delete_enum` AS `delete_enum`,`jjb-saas-zcloud-basic-info`.`corp_info`.`tenant_id` AS `tenant_id`,`jjb-saas-zcloud-basic-info`.`corp_info`.`org_id` AS `org_id`,`jjb-saas-zcloud-basic-info`.`corp_info`.`env` AS `env` from `jjb-saas-zcloud-basic-info`.`corp_info` where (`jjb-saas-zcloud-basic-info`.`corp_info`.`delete_enum` = 'FALSE')

-- =============================================
-- 部门信息视图
-- =============================================
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `department` AS select `jjb-saas-zcloud-basic-info`.`department`.`id` AS `id`,`jjb-saas-zcloud-basic-info`.`department`.`department_id` AS `department_id`,`jjb-saas-zcloud-basic-info`.`department`.`name` AS `name`,`jjb-saas-zcloud-basic-info`.`department`.`parent_id` AS `parent_id`,`jjb-saas-zcloud-basic-info`.`department`.`corpinfo_id` AS `corpinfo_id`,`jjb-saas-zcloud-basic-info`.`department`.`level` AS `level`,`jjb-saas-zcloud-basic-info`.`department`.`level_name` AS `level_name`,`jjb-saas-zcloud-basic-info`.`department`.`dep_order` AS `dep_order`,`jjb-saas-zcloud-basic-info`.`department`.`supervise_flag` AS `supervise_flag`,`jjb-saas-zcloud-basic-info`.`department`.`security_flag` AS `security_flag`,`jjb-saas-zcloud-basic-info`.`department`.`department_function` AS `department_function`,`jjb-saas-zcloud-basic-info`.`department`.`version` AS `version`,`jjb-saas-zcloud-basic-info`.`department`.`create_id` AS `create_id`,`jjb-saas-zcloud-basic-info`.`department`.`create_name` AS `create_name`,`jjb-saas-zcloud-basic-info`.`department`.`create_time` AS `create_time`,`jjb-saas-zcloud-basic-info`.`department`.`update_id` AS `update_id`,`jjb-saas-zcloud-basic-info`.`department`.`update_name` AS `update_name`,`jjb-saas-zcloud-basic-info`.`department`.`update_time` AS `update_time`,`jjb-saas-zcloud-basic-info`.`department`.`remarks` AS `remarks`,`jjb-saas-zcloud-basic-info`.`department`.`delete_enum` AS `delete_enum`,`jjb-saas-zcloud-basic-info`.`department`.`tenant_id` AS `tenant_id`,`jjb-saas-zcloud-basic-info`.`department`.`org_id` AS `org_id`,`jjb-saas-zcloud-basic-info`.`department`.`env` AS `env` from `jjb-saas-zcloud-basic-info`.`department` where (`jjb-saas-zcloud-basic-info`.`department`.`delete_enum` = 'FALSE')

-- =============================================
-- 用户信息视图
-- =============================================
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `user` AS select `jjb-saas-zcloud-basic-info`.`user`.`id` AS `id`,`jjb-saas-zcloud-basic-info`.`user`.`user_id` AS `user_id`,`jjb-saas-zcloud-basic-info`.`user`.`username` AS `username`,`jjb-saas-zcloud-basic-info`.`user`.`name` AS `name`,`jjb-saas-zcloud-basic-info`.`user`.`corpinfo_id` AS `corpinfo_id`,`jjb-saas-zcloud-basic-info`.`user`.`main_corp_flag` AS `main_corp_flag`,`jjb-saas-zcloud-basic-info`.`user`.`user_type` AS `user_type`,`jjb-saas-zcloud-basic-info`.`user`.`department_id` AS `department_id`,`jjb-saas-zcloud-basic-info`.`user`.`post_id` AS `post_id`,`jjb-saas-zcloud-basic-info`.`user`.`role_id` AS `role_id`,`jjb-saas-zcloud-basic-info`.`user`.`email` AS `email`,`jjb-saas-zcloud-basic-info`.`user`.`phone` AS `phone`,`jjb-saas-zcloud-basic-info`.`user`.`personnel_type` AS `personnel_type`,`jjb-saas-zcloud-basic-info`.`user`.`personnel_type_name` AS `personnel_type_name`,`jjb-saas-zcloud-basic-info`.`user`.`nation` AS `nation`,`jjb-saas-zcloud-basic-info`.`user`.`nation_name` AS `nation_name`,`jjb-saas-zcloud-basic-info`.`user`.`user_id_card` AS `user_id_card`,`jjb-saas-zcloud-basic-info`.`user`.`user_avatar_url` AS `user_avatar_url`,`jjb-saas-zcloud-basic-info`.`user`.`current_address` AS `current_address`,`jjb-saas-zcloud-basic-info`.`user`.`location_address` AS `location_address`,`jjb-saas-zcloud-basic-info`.`user`.`rank_level` AS `rank_level`,`jjb-saas-zcloud-basic-info`.`user`.`rank_level_name` AS `rank_level_name`,`jjb-saas-zcloud-basic-info`.`user`.`sort` AS `sort`,`jjb-saas-zcloud-basic-info`.`user`.`version` AS `version`,`jjb-saas-zcloud-basic-info`.`user`.`create_id` AS `create_id`,`jjb-saas-zcloud-basic-info`.`user`.`create_name` AS `create_name`,`jjb-saas-zcloud-basic-info`.`user`.`create_time` AS `create_time`,`jjb-saas-zcloud-basic-info`.`user`.`update_id` AS `update_id`,`jjb-saas-zcloud-basic-info`.`user`.`update_name` AS `update_name`,`jjb-saas-zcloud-basic-info`.`user`.`update_time` AS `update_time`,`jjb-saas-zcloud-basic-info`.`user`.`remarks` AS `remarks`,`jjb-saas-zcloud-basic-info`.`user`.`delete_enum` AS `delete_enum`,`jjb-saas-zcloud-basic-info`.`user`.`tenant_id` AS `tenant_id`,`jjb-saas-zcloud-basic-info`.`user`.`org_id` AS `org_id`,`jjb-saas-zcloud-basic-info`.`user`.`env` AS `env`,`jjb-saas-zcloud-basic-info`.`user`.`department_leader_flag` AS `department_leader_flag`,`jjb-saas-zcloud-basic-info`.`user`.`deputy_leader_flag` AS `deputy_leader_flag`,`jjb-saas-zcloud-basic-info`.`user`.`cultural_level` AS `cultural_level`,`jjb-saas-zcloud-basic-info`.`user`.`cultural_level_name` AS `cultural_level_name`,`jjb-saas-zcloud-basic-info`.`user`.`marital_status` AS `marital_status`,`jjb-saas-zcloud-basic-info`.`user`.`marital_status_name` AS `marital_status_name`,`jjb-saas-zcloud-basic-info`.`user`.`political_affiliation` AS `political_affiliation`,`jjb-saas-zcloud-basic-info`.`user`.`political_affiliation_name` AS `political_affiliation_name`,`jjb-saas-zcloud-basic-info`.`user`.`employment_flag` AS `employment_flag`,`jjb-saas-zcloud-basic-info`.`user`.`rz_flag` AS `rz_flag` from `jjb-saas-zcloud-basic-info`.`user` where (`jjb-saas-zcloud-basic-info`.`user`.`delete_enum` = 'FALSE')