-- ----------------------------
-- 企业生命周期表
-- ----------------------------
DROP TABLE IF EXISTS `mortals_ent_life_cycle`;
CREATE TABLE `mortals_ent_life_cycle`
(
    `id`             bigint(20)                                              NOT NULL AUTO_INCREMENT COMMENT '主键ID，主键，自增长',
    `life_cycle_code`   varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '生命周期编码',
    `life_cycle_name`   varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '生命周期名称',
    `sort`           int(4)                                                  NULL DEFAULT 0 COMMENT '排序字段',
    `remark`         varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '备注',
    `create_user_id` bigint(20)                                                   DEFAULT NULL COMMENT '创建用户',
    `create_user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建用户名称',
    `create_time`    datetime                                                     DEFAULT NULL COMMENT '创建时间',
    `update_time`    datetime                                                     DEFAULT NULL COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8
  COLLATE = utf8_general_ci COMMENT = '企业生命周期表';


-- ----------------------------
-- 企业周期事项主表
-- ----------------------------
DROP TABLE IF EXISTS `mortals_ent_life_matter`;
CREATE TABLE `mortals_ent_life_matter`
(
    `id`             bigint(20)                                              NOT NULL AUTO_INCREMENT COMMENT '主键ID，主键，自增长',
    `life_cycle_id`    bigint(20)                                                   DEFAULT NULL COMMENT '企业生命周期id',
    `life_cycle_name`   varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '生命周期名称',
    `matter_group_name`    varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '事项组名称',
    `dept_id` bigint(20) NULL DEFAULT NULL COMMENT '办理单位数量',
    `remark`         varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '备注',
    `create_user_id` bigint(20)                                                   DEFAULT NULL COMMENT '创建用户',
    `create_user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建用户名称',
    `create_time`    datetime                                                     DEFAULT NULL COMMENT '创建时间',
    `update_time`    datetime                                                     DEFAULT NULL COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8
  COLLATE = utf8_general_ci COMMENT = '企业周期事项主表';


-- ----------------------------
-- 企业周期事项子表
-- ----------------------------
DROP TABLE IF EXISTS `mortals_ent_life_matter_sub`;
CREATE TABLE `mortals_ent_life_matter_sub`
(
    `id`             bigint(20)                                              NOT NULL AUTO_INCREMENT COMMENT '主键ID，主键，自增长',
    `master_record_id`    bigint(20)                                                   DEFAULT NULL COMMENT '主事项id',
    `matter_id`     bigint(20)                                                   DEFAULT NULL COMMENT '事项id',
    `matter_name`    varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '事项名称',
    `matter_code`   varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '事项编码',
    `area_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '区域编码',
    `area_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '区域名称',
    `area_level` tinyint(2) NULL DEFAULT 1 COMMENT '区域等级(1.省，2.地市州，3.区县，4.街道，5.社区)',
    `dept_id` bigint(20) NULL DEFAULT NULL COMMENT '办理单位ID',
    `dept_name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '办理单位名称',
    `sort`           int(4)                                                  NULL DEFAULT 0 COMMENT '排序字段',
    `remark`         varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '备注',
    `create_user_id` bigint(20)                                                   DEFAULT NULL COMMENT '创建用户',
    `create_user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建用户名称',
    `create_time`    datetime                                                     DEFAULT NULL COMMENT '创建时间',
    `update_time`    datetime                                                     DEFAULT NULL COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8
  COLLATE = utf8_general_ci COMMENT = '企业周期事项子表';


ALTER TABLE mortals_sys_matter ADD COLUMN `areaName` varchar(255)      COMMENT '区域名称';
ALTER TABLE mortals_sys_matter ADD COLUMN `areaLevel` tinyint(2)      COMMENT '区域等级(1.省，2.地市州，3.区县，4.街道，5.社区)';



INSERT INTO `mortals_sys_area` VALUES (null, ',16ca461e2c824257a50dd0c7fab6f2de', '达州东部经开区', 'gde17ba11bbf48568547c21b174c8a32', '16ca461e2c824257a50dd0c7fab6f2de', 'True', 'True', 'false', 'false', '511715000000', 3, '达州东部经开区', 'dzsgxjscyy.sczwfw.gov.cn', 1, '2025-03-20 10:20:10', NULL, '2025-03-20 10:20:10');


ALTER TABLE mortals_ent_life_matter ADD COLUMN  `num`           int(4)   NULL DEFAULT 0 COMMENT '数量';