/*
 change.sql 说明
 1.数据库相关修改添加到对应的 change.sql 文件，无需调整其他 sql  文件
 2.sql 语句验证正确后再提交
*/

-- wanghb 2020-12-02 新增短链接管理表
DROP TABLE IF EXISTS `portal_shorturl_manage`;
CREATE TABLE `portal_shorturl_manage`  (
  `ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `URL_` varchar(2000) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '原链接',
  `url_desc_` varchar(2000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '原链接描述',
  `SHORT_URL_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '短链接',
  `create_by_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time_` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `lose_time_` datetime(0) NULL DEFAULT NULL COMMENT '失效时间',
  `create_org_id_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人组织id',
  `update_by_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time_` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `ENABLED_` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '1' COMMENT '是否启用.1:启用，2：禁用',
  `tenant_id_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '短连接管理表' ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;

-- zjq 2020-12-04 修改流程附件上传配置表的ALIYUN_OSS_ENDPOINT_字段注释
ALTER TABLE `portal_flow_upload_properties`
MODIFY COLUMN `ALIYUN_OSS_ENDPOINT_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '访问域名 endpoint' AFTER `TENANT_ID_`;

-- wanghb 2020-12-08 用户组织岗位关系表新增维度id字段
ALTER TABLE `uc_org_user` ADD COLUMN `DEM_ID_` varchar(64) NULL COMMENT '维度id' AFTER `TENANT_ID_`;
UPDATE uc_org_user SET dem_id_ = ( SELECT dem_id_ FROM uc_org WHERE uc_org.ID_ = uc_org_user.ORG_ID_ ) WHERE ORG_ID_ != ''  OR ORG_ID_ IS NOT NULL;

-- zengst 2020-12-21 数据报表增加所属表单列
alter table form_data_template
	add FORM_NAME_ VARCHAR(64) null comment '表单名称';

-- zengst 2020-12-21 替换消息模板的前端路径
update portal_sys_msg_tpl set html_ = replace(html_,'${baseUrl}/fvue','${baseUrl}/${frontBaseUrl}') where html_ like '%${baseUrl}/fvue%';

-- zengst 2020-12-21 增加用于模板解析的系统属性
insert into portal_sys_properties (ID, NAME, ALIAS, GROUP_, VALUE, ENCRYPT, DESCRIPTION, UPDATE_TIME_, CREATE_BY_, CREATE_TIME_, CREATE_ORG_ID_, UPDATE_BY_, TENANT_ID_) values ('21', '管理端基础路径', 'manageBaseUrl', null, 'mvue', 0, '管理端IP和端口号后面基础路径', null, 1, null, null, 1, null);
insert into portal_sys_properties (ID, NAME, ALIAS, GROUP_, VALUE, ENCRYPT, DESCRIPTION, UPDATE_TIME_, CREATE_BY_, CREATE_TIME_, CREATE_ORG_ID_, UPDATE_BY_, TENANT_ID_) values ('22', '应用端基础路径', 'frontBaseUrl', null, 'fvue', 0, '应用端IP和端口号后面基础路径', null, 1, null, null, 1, null);
insert into portal_sys_properties (ID, NAME, ALIAS, GROUP_, VALUE, ENCRYPT, DESCRIPTION, UPDATE_TIME_, CREATE_BY_, CREATE_TIME_, CREATE_ORG_ID_, UPDATE_BY_, TENANT_ID_) values ('23', '移动端基础路径', 'mobileBaseUrl', null, 'mobilevue', 0, '移动端IP和端口号后面基础路径', null, 1, null, null, 1, null);

-- zengst 2020-12-22 部分人员脚本描述
update bpm_multi_script set METHOD_DESC_  = '找这个组织底下拥有这个角色的人员' where METHOD_NAME_ = 'getByCompanyRole';
update bpm_multi_script set METHOD_DESC_  = '根据是否有用户参数以及组织参数获取审批人' where METHOD_NAME_ = 'getFgUsers';

-- zhangxw 2020-12-17 表单套打扩展字段
ALTER TABLE form_print_template
ADD COLUMN MAIN_SQL_LIST text NULL COMMENT 'sql集合' AFTER SCRIPT_STR_,
ADD COLUMN DATASOURCE_ varchar(64) NULL COMMENT '数据源别名' AFTER MAIN_SQL_LIST,
ADD COLUMN LABEL_CONFIG_ text NULL COMMENT '标签配置' AFTER DATASOURCE_,
ADD COLUMN DATASOURCE_FORM_ varchar(10) NULL COMMENT '数据来源 form-表单 db-数据库' AFTER LABEL_CONFIG_,
ADD COLUMN TYPE_ID_ varchar(64) NULL COMMENT '分类id' AFTER DATASOURCE_FORM_,
ADD COLUMN TYPE_NAME_ varchar(64) NULL COMMENT '分类名称' AFTER TYPE_ID_,
ADD COLUMN NAME_ varchar(128) NULL COMMENT '模板名称' AFTER TYPE_ID_,
ADD COLUMN ALIAS_ varchar(64) NULL COMMENT '模板别名' AFTER NAME_,
ADD COLUMN DESC_ varchar(600) NULL COMMENT '模板描述' AFTER ALIAS_,
ADD COLUMN FILE_JSON_ text NULL COMMENT '模板文件json' AFTER DESC_,
ADD COLUMN BO_DEF_IDS_ varchar(2000) NULL COMMENT 'BO建模id数据（多个用逗号分隔）' AFTER FILE_JSON_;

-- zhangxw 2020-12-17 添加套打分类数据
INSERT INTO PORTAL_SYS_TYPE_GROUP(ID_, GROUP_KEY_, NAME_, FLAG_, SN_, TYPE_, CREATE_BY_, CREATE_TIME_, CREATE_ORG_ID_, UPDATE_BY_, UPDATE_TIME_) VALUES ('13', 'PRINT_TEMPLATE', '套打分类', '1', '13', '1', null, null, null, '1', null);
INSERT INTO PORTAL_SYS_TYPE(ID_, TYPE_GROUP_KEY_, NAME_, TYPE_KEY_, STRU_TYPE_, PARENT_ID_, DEPTH_, PATH_, IS_LEAF_, OWNER_ID_, SN_, CREATE_BY_, CREATE_TIME_, CREATE_ORG_ID_, UPDATE_BY_, UPDATE_TIME_, ICON_, TENANT_ID_) VALUES ('31123', 'PRINT_TEMPLATE', '默认分类', 'default', '1', '13', '1', '13.31123.', 'Y', '0', '0', '1', null, null, null, null, '{}', '-1');

-- zhangxw 2020-12-25 添加印章管理模块sql
CREATE TABLE `portal_sys_signet`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `ALIAS_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '别名',
  `NAME_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '印章名称',
  `FILE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '印章附件id',
  `DESC_` varchar(600) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '印章描述',
  `CREATE_BY_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人id',
  `CREATE_ORG_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人所属组织id',
  `CREATE_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `UPDATE_BY_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新人',
  `UPDATE_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户id',
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;


-- wanghb 知会任务表新增OPINION_ID_字段
ALTER TABLE `bpm_task_notice` ADD COLUMN `OPINION_ID_` varchar(64) NULL COMMENT '传阅时审批意见id,不为空时根据此id查找审批意见里的数据' AFTER `TENANT_ID_`;

-- zjq 矩阵表uc_matrix添加enable_字段, 添加矩阵和流程的关系表uc_matrix_proc_relation
ALTER TABLE uc_matrix ADD COLUMN ENABLED_ int NULL DEFAULT 1 COMMENT '是否启用: 0禁用 1启用';

CREATE TABLE `uc_matrix_proc_relation` (
  `ID_` varchar(64) NOT NULL COMMENT 'id',
  `MATRIX_CODE_` varchar(255) DEFAULT NULL COMMENT '矩阵编码',
  `PROC_DEF_KEY_` varchar(64) DEFAULT NULL COMMENT '流程定义Key',
  `PROC_DEF_NAME_` varchar(64) DEFAULT NULL COMMENT '流程定义名称',
  `TENANT_ID_` varchar(64) DEFAULT NULL COMMENT '租户id',
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='矩阵流程关系表';



-- 2020-01-22 zengst 常用联系人迁移
create table UC_GROUP
(
  ID_ VARCHAR(64) not null comment '主键',
  GROUP_NAME VARCHAR(255) null comment '群组名称',
  CODE_ VARCHAR(64) null comment '群组编码',
  CREATE_BY_ VARCHAR(64) null comment '创建人ID',
  CREATOR_NAME_ VARCHAR(255) null comment '创建人名称',
  CREATE_ORG_ID_ VARCHAR(64) null comment '创建人组织ID',
  UPDATE_BY_ VARCHAR(64) null comment '更新人ID',
  CREATE_TIME_ DATETIME null comment '创建时间',
  UPDATE_TIME_ DATE null comment '更新时间',
  TENANT_ID_ VARCHAR(64) null comment '租户ID',
  constraint UC_GROUP_pk
    primary key (ID_)
)
comment '群组管理';

create table UC_GROUP_USER
(
  ID_ VARCHAR(64) not null comment '主键',
  GROUP_ID_ VARCHAR(64) null comment '外键',
  USER_ID VARCHAR(64) null comment '用户ID',
  TENANT_ID_ VARCHAR(64) null comment '租户ID',
  constraint UC_GROUP_USER_pk
    primary key (ID_)
)
comment '群组和用户关系表';

INSERT INTO PORTAL_SYS_MENU (ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_, HREF_, TENANT_ID_) VALUES ('1349913657512955904', '59217', '常用联系人', 'groupManager', null, null, 1, 5, null, '-1.3.59217.1349913657512955904.', null, '-1');


-- 庞泉 2021-04-09 微信小程序集成
ALTER TABLE `uc_user_unite`
ADD COLUMN `MP_OPEN_ID_` varchar(255) NULL COMMENT '微信小程序openid' AFTER `TENANT_ID_`;


-- 刘江 2021-04-12 #9513 iframeUrl配置已无用，可以去掉
DELETE FROM portal_sys_properties WHERE ALIAS = 'iframeUrl';

-- 2021-04-12 pangq 应用端添加扫码功能
ALTER TABLE portal_sys_external_unite
ADD COLUMN SCAN_APP_ID_ varchar(255) NULL COMMENT '扫码登录的appId' AFTER `TENANT_ID_`,
ADD COLUMN SCAN_APP_SECRET_ varchar(255) NULL COMMENT '扫码登录的appSecret' AFTER `SCAN_APP_ID_`;



-- zhangxw 2021-1-13 门户表添加级别字段
ALTER TABLE `portal_sys_layout_manage`
ADD COLUMN `ALIAS` varchar(64) NULL COMMENT '别名' AFTER `ENABLE`,
ADD COLUMN `RANK` smallint NULL COMMENT '优先级（数字递增优先级递减）' AFTER `ALIAS`;

-- zhangxw 2021-1-21 应用端添加我的布局菜单
INSERT INTO portal_sys_menu(ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_, HREF_, TENANT_ID_) VALUES ('1352205235262722048', '59217', '我的布局', 'v-myLayout', '', '', NULL, 101, '', '-1.3.59217.1352205235262722048.', '', '-1');

-- zhangxw 2021-2-1 布局表扩展字段
ALTER TABLE portal_sys_layout_manage
ADD COLUMN TYPE_ varchar(20) NULL COMMENT '布局类型：column（栏目），datav（大屏）' AFTER IS_DEF,
ADD COLUMN AS_TEMPLATE_ smallint(6) NULL COMMENT '是否发布为模板(1=是，0=否)' AFTER LAYOUT_TYPE;


-- zhangxw 2021-2-24 布局管理菜单调整
UPDATE `portal_sys_menu` SET `PARENT_ID_` = '3711006', `NAME_` = '门户管理', `ALIAS_` = 'layoutManager', `ACTIVE_TAB_` = '', `MENU_ICON_` = '', `OPENED_` = NULL, `SN_` = 2, `TABS_STYLE_` = '', `PATH_` = '-1.1.3441002.3711006.6907875.', `HREF_` = NULL, `TENANT_ID_` = '-1' WHERE `ID_` = '6907875';


-- zhangxw 2021-3-1 布局管理添加属性
ALTER TABLE portal_sys_layout_manage
ADD COLUMN CREATE_TIME_ datetime(0) NULL DEFAULT NULL COMMENT '创建时间' AFTER TENANT_ID_,
ADD COLUMN UPDATE_TIME_ datetime(0) NULL DEFAULT NULL COMMENT '更新时间' AFTER CREATE_TIME_,
ADD COLUMN CREATE_BY_ varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人id' AFTER UPDATE_TIME_,
ADD COLUMN UPDATE_BY_ varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新人id' AFTER CREATE_BY_,
ADD COLUMN CREATE_ORG_ID_ varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人所属组织id' AFTER UPDATE_BY_,
ADD COLUMN SCREEN_CAPTURE_ID_ varchar(64) NULL COMMENT '截图文件id' AFTER CREATE_ORG_ID_;

-- zhangxw 2021-4-22 调整初始化布局数据
update `portal_sys_layout_manage` set `TYPE_`='column' WHERE `TYPE_` IS NULL;
update `portal_sys_layout_manage` set `ALIAS`='default_manage',`RANK`=1 WHERE `ID`='0';
update `portal_sys_layout_manage` set `ALIAS`='default_front',`RANK`=1 WHERE `ID`='2';
update `portal_sys_layout_manage` set `ALIAS`='default_mobile',`RANK`=1 WHERE `ID`='1';

-- zhangxw 2021-4-22 调整门户相关管理菜单
INSERT INTO portal_sys_menu(ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_, HREF_, TENANT_ID_) VALUES ('1366228495574896640', '3711006', '大屏管理', 'datavManager', '', '', NULL, 3, '', '-1.1.3441002.3711006.1366228495574896640.', '', '-1');
DELETE from portal_sys_menu where ALIAS_='layoutDistribution';

-- zhangxw 2021-4-25 添加套打模板菜单
INSERT INTO portal_sys_menu(ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_, HREF_, TENANT_ID_) VALUES ('1386144820958990336', '3391046', '套打模板', 'formPrintTemplateListManager', '', '', NULL, 6, '', '-1.1.3441002.3391046.1386144820958990336.', '', '-1');

-- zengst 2021-05-06 弹窗提醒表
create table portal_sys_popup
(
    ID_                varchar(64)   not null comment '主键'
        primary key,
    SUBJECT_           varchar(255)  null comment '主题',
    DATA_SOURCE_ALIAS_ varchar(64)   null comment '数据源',
    ORDER_             int           null comment '排序',
    IS_ENABLE_         int           null comment '是否启用',
    URL_               varchar(2000) null comment '跳转地址',
    POPUP_TYPE_        varchar(64)   null comment '弹窗类型',
    DIALOG_WIDTH_      int           null comment '对话框宽度',
    DIALOG_HEIGHT_     int           null comment '对话框高度',
    SQL_               varchar(2000) null comment 'SQL语句',
    DESC_              text          null comment '描述',
    CREATE_TIME_       datetime      null comment '创建时间',
    STYLE_CONTENT_     text          null,
    DATA_TYPE_         varchar(64)   null comment '数据获取方式',
    SCRIPT_            text          null comment 'groovy脚本',
    VALIDITY_START_    datetime      null comment '有效期起',
    VALIDITY_END_      datetime      null comment '有效期止',
    TENANT_ID_         varchar(64)   null comment '租户ID'
);
-- 弹窗管理菜单
insert into portal_sys_menu (ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_,
                             HREF_, TENANT_ID_)
values (1388014971052494848, 3711006, '弹窗管理', 'popupManager', 'popupManager', '', null, 4, '',
        '-1.1.3441002.3711006.1388014971052494848.', '', -1);
-- 消息提醒栏目
insert into portal_sys_column (ID, NAME, ALIAS, CATALOG, COL_TYPE, DATA_MODE, DATA_FROM, DS_ALIAS, DS_NAME, COL_HEIGHT,
                               COL_URL, TEMPLATE_HTML, IS_PUBLIC, SUPPORT_REFESH, REFESH_TIME, SHOW_EFFECT, MEMO,
                               DATA_PARAM, NEEDPAGE, ORG_ID, CREATOR, CREATE_BY_, UPDATE_BY_, CREATE_TIME_,
                               UPDATE_TIME_, REQUEST_TYPE, CATALOG_NAME, CREATE_ORG_ID_, TENANT_ID_)
values (1390133228840554496, '消息提醒', 'xxtx', 31081, 0, null, '', '', null, 0, '', 'PHBvcHVwQ29sdW1uIC8+', 2, null, null,
        null, '', '', 0, null, null, 1, 1, null, null, '', '默认分类', '', -1);

-- zengst 2021-05-07 弹窗提醒添加名字和别名
alter table portal_sys_popup
    add ALIAS_ VARCHAR(255) null comment '别名';
alter table portal_sys_popup
    add NAME_ VARCHAR(255) null comment '名称';


 -- zhangxw 2021-06-11 mysql8关键字RANK问题
ALTER TABLE`portal_sys_layout_manage`
CHANGE COLUMN `RANK` `RANK_` smallint(0) NULL DEFAULT NULL COMMENT '优先级（数字递增优先级递减）' AFTER `ALIAS`;


-- zengst 2021-07-02 后端菜单收藏功能相关表
create table portal_menu_bookmark
(
    ID_             varchar(64)   not null comment '主键'
        primary key,
    ALIAS_          varchar(128)  null comment '菜单别名',
    MENU_ID_        varchar(64)   null comment '菜单ID',
    PARENT_MENU_ID_ varchar(64)   null comment '父菜单ID',
    HREF_           varchar(2000) null comment '菜单链接',
    NAME_           varchar(128)  null comment '菜单名称',
    TENANT_ID_      varchar(64)   null comment '租户ID',
    USER_ID_        varchar(64)   null comment '用户ID'
)
    comment '菜单收藏';

create table BPM_MOBILE_CATEGORY
(
    ID_ varchar(64) not null comment '主键',
    DEF_KEY_ varchar(64) null comment '流程定义key',
    TYPE_ID_ varchar(64) null comment '分类ID',
    TYPE_KEY_ varchar(64) null comment '分类key',
    DEF_NAME_ varchar(255) null comment '流程定义名称',
    CREATOR_ varchar(64) null comment '创建人',
    CREATE_TIME_ DATETIME null comment '创建时间',
    UPDATE_TIME_ DATETIME null comment '更新时间',
    TENANT_ID_ varchar(64) null comment '租户ID',
    constraint BPM_MOBILE_CATEGORY_pk
        primary key (ID_)
)
    comment '移动端流程分类表';

-- 管理端流程分类配置页面
INSERT INTO PORTAL_SYS_MENU (ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_,
                             HREF_, TENANT_ID_)
VALUES ('1372088887966568448', '3761202', '移动端流程分类', 'mobileFlowType', 'mobileFlowType', null, 1, 4, null,
        '-1.1.3641025.3761202.1372088887966568448.', null, '-1');

-- 应用端添加常用流程设置菜单
insert into PORTAL_SYS_MENU(id_, parent_id_, name_, alias_, active_tab_, menu_icon_, opened_, sn_, tabs_style_, path_,
                            href_, tenant_id_)
values ('1349913657512955905', '59217', '常用流程', 'commonFlow', null, null, 1, 6, null, '-1.3.59217.1349913657512955905.',
        null, '-1');

INSERT INTO PORTAL_SYS_TYPE_GROUP (ID_, GROUP_KEY_, NAME_, FLAG_, SN_, TYPE_, CREATE_BY_, CREATE_TIME_, CREATE_ORG_ID_,
                                   UPDATE_BY_, UPDATE_TIME_)
VALUES ('14', 'MOBILE_FLOW_TYPE', '移动端流程分类', 1, 5, 1, null, null, null, null, null);

-- 添加常用流程类型
INSERT INTO PORTAL_SYS_TYPE (ID_, TYPE_GROUP_KEY_, NAME_, TYPE_KEY_, STRU_TYPE_, PARENT_ID_, DEPTH_, PATH_, IS_LEAF_,
                             OWNER_ID_, SN_, CREATE_BY_, CREATE_TIME_, CREATE_ORG_ID_, UPDATE_BY_, UPDATE_TIME_, ICON_,
                             TENANT_ID_)
VALUES ('15', 'MOBILE_FLOW_TYPE', '常用流程', 'default', '1', '14', 1, '14.15.', 'Y', '0', -1, '1', null, null, null,
        null, '{}', '-1');

-- 给一般用户角色授予权限常用流程菜单的权限（ybyh是初始化sql里添加的）
INSERT INTO portal_sys_role_auth (id_, role_alias_, menu_alias_, tenant_id_)
VALUES ('1371745528324427777', 'ybyh', 'commonFlow', '-1');


-- 表单元数据添加流水号配置信息字段
alter table form_meta
    add IDENTITY_CONFIG_ text null comment '流水号配置';


-- yujl 外部系统管理表
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for portal_biz_system
-- ----------------------------
DROP TABLE IF EXISTS `portal_biz_system`;
CREATE TABLE `portal_biz_system`  (
                                      `ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
                                      `SYS_CODE_` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '系统编码',
                                      `SYS_NAME_` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '系统名称',
                                      `ENABLED_` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '是否启用，可用 0：禁用，1：启用',
                                      `SECRET_KEY_` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '系统密匙，用于鉴权',
                                      `MANAGER_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '管理员ID',
                                      `MANAGER_NAME_` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '管理员名称',
                                      `ROOT_ADDRESS_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用于其他地方拼接地址',
                                      `HOME_ADDRESS_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '系统首页地址',
                                      `BPM_MSG_QUEUE_` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '流程消息队列',
                                      `DESCRIPTION_` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '系统描述',
                                      `ROBOT_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '机器人ID',
                                      `CREATE_TIME_` datetime(0) NULL DEFAULT NULL,
                                      `CREATE_BY_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
                                      `CREATE_ORG_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人组织ID',
                                      `IS_DELE_` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '是否删除，0未删，1已删',
                                      `UPDATE_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
                                      `UPDATE_BY_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新人',
                                      `TENANT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;

-- chenzm 修改数据模板字段HTML_数据类型，之前用text新增了内容之后长度不够了
ALTER TABLE form_template MODIFY HTML_ longtext;


-- chenzm 流程按钮初始化表结构和数据 Date: 27/08/2021 19:14:38
DROP TABLE IF EXISTS `bpm_flow_default_button`;
CREATE TABLE `bpm_flow_default_button`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `NAME_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '按钮名称',
  `ALIAS_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '按钮别名',
  `BEFORESCRIPT_` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '前置脚本',
  `AFTERSCRIPT_` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '后置脚本',
  `GROOVYSCRIPT_` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '后台java脚本',
  `COMPLETEEVENTGROOVYSCRIPT_` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '后台完成任务后执行的java脚本',
  `REJECTMODE_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '驳回模式 reject 驳回指定节点  rejectPre 驳回上一步   backToStart 驳回发起人',
  `REJECTNODE_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '指定驳回的节点',
  `ISLOCK_` int NULL DEFAULT NULL,
  `SUPPORTSCRIPT_` int NULL DEFAULT NULL COMMENT '是否支持脚本',
  `MSGCONFIG_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '按钮消息配置',
  `TYPE_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '按钮节点类型',
  `DISABLED_` int NULL DEFAULT NULL COMMENT '启用或者禁用',
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '流程各个节点的按钮初始化' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of bpm_flow_default_button
-- ----------------------------
INSERT INTO `bpm_flow_default_button` VALUES ('1', '启动', 'startFlow', '', '', '', '', 'backToStart,rejectPre,reject', '', 0, 1, '', 'start', 0);
INSERT INTO `bpm_flow_default_button` VALUES ('10', '签收', 'lockUnlock', '', '', '', '', 'backToStart,rejectPre,reject', '', 0, 0, '', 'userTask', 0);
INSERT INTO `bpm_flow_default_button` VALUES ('11', '保存', 'saveDraft', '', '', '', '', 'backToStart,rejectPre,reject', '', 0, 1, '', 'userTask', 0);
INSERT INTO `bpm_flow_default_button` VALUES ('12', '挂起', 'hangUp', '', '', '', '', 'backToStart,rejectPre,reject', '', 0, 0, '', 'userTask', 0);
INSERT INTO `bpm_flow_default_button` VALUES ('13', '取消挂起', 'cancelHangUp', '', '', '', '', 'backToStart,rejectPre,reject', '', 0, 0, '', 'userTask', 0);
INSERT INTO `bpm_flow_default_button` VALUES ('14', '反对', 'oppose', '', '', '', '', 'backToStart,rejectPre,reject', '', 0, 1, '', 'userTask', 0);
INSERT INTO `bpm_flow_default_button` VALUES ('15', '流转', 'startTrans', '', '', '', '', 'backToStart,rejectPre,reject', '', 0, 0, '', 'userTask', 0);
INSERT INTO `bpm_flow_default_button` VALUES ('16', '加签', 'addSign', '', '', '', '', 'backToStart,rejectPre,reject', '', 0, 0, '', 'userTask', 0);
INSERT INTO `bpm_flow_default_button` VALUES ('17', '终止', 'endProcess', '', '', '', '', 'backToStart,rejectPre,reject', '', 0, 1, '', 'userTask', 0);
INSERT INTO `bpm_flow_default_button` VALUES ('18', '传阅', 'instanceTrans', '', '', '', '', 'backToStart,rejectPre,reject', '', 0, 0, '', 'userTask', 1);
INSERT INTO `bpm_flow_default_button` VALUES ('19', '驳回发起人', 'backToStart', '', '', '', '', 'backToStart,rejectPre,reject', '', 0, 1, '', 'userTask', 1);
INSERT INTO `bpm_flow_default_button` VALUES ('2', '保存', 'saveDraft', NULL, NULL, NULL, NULL, 'backToStart,rejectPre,reject', NULL, 0, 1, NULL, 'start', 0);
INSERT INTO `bpm_flow_default_button` VALUES ('20', '同意', 'agree', NULL, NULL, NULL, NULL, 'backToStart,rejectPre,reject', NULL, 0, 1, NULL, 'signTask', 0);
INSERT INTO `bpm_flow_default_button` VALUES ('21', '沟通反馈', 'commu', '', '', '', '', 'backToStart,rejectPre,reject', '', 0, 1, '', 'signTask', 1);
INSERT INTO `bpm_flow_default_button` VALUES ('22', '驳回', 'reject', NULL, NULL, NULL, NULL, 'backToStart,rejectPre,reject', NULL, 0, 1, NULL, 'signTask', 0);
INSERT INTO `bpm_flow_default_button` VALUES ('23', '征询', 'inqu', NULL, NULL, NULL, NULL, 'backToStart,rejectPre,reject', NULL, 0, 0, NULL, 'signTask', 0);
INSERT INTO `bpm_flow_default_button` VALUES ('24', '转办', 'delegate', NULL, NULL, NULL, NULL, 'backToStart,rejectPre,reject', NULL, 0, 0, NULL, 'signTask', 0);
INSERT INTO `bpm_flow_default_button` VALUES ('25', '保存', 'saveDraft', NULL, NULL, NULL, NULL, 'backToStart,rejectPre,reject', NULL, 0, 1, NULL, 'signTask', 0);
INSERT INTO `bpm_flow_default_button` VALUES ('26', '反对', 'oppose', NULL, NULL, NULL, NULL, 'backToStart,rejectPre,reject', NULL, 0, 1, NULL, 'signTask', 0);
INSERT INTO `bpm_flow_default_button` VALUES ('27', '驳回发起人', 'backToStart', '', '', '', '', 'backToStart,rejectPre,reject', '', 0, 1, '', 'signTask', 1);
INSERT INTO `bpm_flow_default_button` VALUES ('28', '传阅', 'instanceTrans', '', '', '', '', 'backToStart,rejectPre,reject', '', 0, 0, '', 'signTask', 1);
INSERT INTO `bpm_flow_default_button` VALUES ('29', '加签', 'addSign', NULL, NULL, NULL, NULL, 'backToStart,rejectPre,reject', NULL, 0, 0, NULL, 'signTask', 0);
INSERT INTO `bpm_flow_default_button` VALUES ('3', '同意', 'agree', '', '', '', '', 'backToStart,rejectPre,reject', '', 0, 1, '', 'userTask', 0);
INSERT INTO `bpm_flow_default_button` VALUES ('4', '同意（流转）', 'agreeTrans', NULL, NULL, NULL, NULL, 'backToStart,rejectPre,reject', NULL, 0, 1, NULL, 'userTask', 0);
INSERT INTO `bpm_flow_default_button` VALUES ('5', '反对（流转）', 'opposeTrans', NULL, NULL, NULL, NULL, 'backToStart,rejectPre,reject', NULL, 0, 1, NULL, 'userTask', 0);
INSERT INTO `bpm_flow_default_button` VALUES ('6', '沟通反馈', 'commu', '', '', '', '', 'backToStart,rejectPre,reject', '', 0, 1, '', 'userTask', 1);
INSERT INTO `bpm_flow_default_button` VALUES ('7', '驳回', 'reject', NULL, NULL, NULL, NULL, 'backToStart,rejectPre,reject', NULL, 0, 1, NULL, 'userTask', 0);
INSERT INTO `bpm_flow_default_button` VALUES ('8', '征询', 'inqu', NULL, NULL, NULL, NULL, 'backToStart,rejectPre,reject', NULL, 0, 0, NULL, 'userTask', 0);
INSERT INTO `bpm_flow_default_button` VALUES ('9', '转办', 'delegate', NULL, NULL, NULL, NULL, 'backToStart,rejectPre,reject', NULL, 0, 0, NULL, 'userTask', 0);

-- zengst 2021-08-30 分级组织权限添加可选角色配置
alter table uc_org_auth
    add ROLE_PERMS_ varchar(255) null comment '角色管理权限';

alter table uc_org_auth
    add ROLE_CONFIG_ text null comment '角色配置';

-- yujl 2021-08-30 外部接口授权记录表
CREATE TABLE `portal_url_permission` (
                                         `ID` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
                                         `SYS_ID_` varchar(64) DEFAULT NULL COMMENT '授权系统ID',
                                         `MODULE_` varchar(255) DEFAULT NULL COMMENT '所属模块',
                                         `FUNCTION_` varchar(50) DEFAULT NULL COMMENT '所属功能',
                                         `AUTH_URL_` varchar(100) DEFAULT NULL COMMENT '接口授权路径',
                                         `CREATE_TIME_` datetime DEFAULT NULL,
                                         `CREATE_BY_` varchar(255) DEFAULT NULL,
                                         `CREATE_ORG_ID_` varchar(255) DEFAULT NULL COMMENT '创建人组织ID',
                                         `TENANT_ID_` varchar(255) DEFAULT NULL,
                                         `DESCRIPTION_` varchar(255) DEFAULT NULL COMMENT '接口描述',
                                         UNIQUE KEY `uniqueIndex` (`SYS_ID_`,`AUTH_URL_`) USING BTREE COMMENT '联合索引，保证数据唯一性'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


-- yujl 2021-08-31 记录外部系统的消息发送日志记录表
CREATE TABLE `portal_msg_send_log` (
                                       `ID_` varchar(64) DEFAULT NULL,
                                       `SYS_CODE_` varchar(50) DEFAULT NULL COMMENT '发往系统',
                                       `FLOW_KEY_` varchar(50) DEFAULT NULL COMMENT '触发流程KEY',
                                       `ACTION_TYPE_` varchar(20) DEFAULT NULL COMMENT '流程动作类型',
                                       `TRIG_NODE_ID_` varchar(50) DEFAULT NULL COMMENT '触发节点',
                                       `TRIG_USER_ID_` varchar(64) DEFAULT NULL COMMENT '触发用户',
                                       `SEND_TIME` datetime DEFAULT NULL COMMENT '发送时间',
                                       `TITLE_` varchar(200) DEFAULT NULL COMMENT '消息标题',
                                       `CONTENT_` text COMMENT 'MQ文本内容',
                                       `STATUS_` varchar(1) DEFAULT NULL COMMENT '0失败，1成功',
                                       `tenant_id_` varchar(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- zhangxw 2021-09-06 mysql数据库修改表单模板html字段长度
ALTER TABLE `form_template`
MODIFY COLUMN `HTML_` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '模板内容' AFTER `MACROTEMPLATE_ALIAS_`;

-- jason 2021-09-11 调整索引 优化性能
ALTER TABLE `act_ru_identitylink` DROP FOREIGN KEY `ACT_FK_IDL_PROCINST`;

ALTER TABLE `act_ru_identitylink`
DROP INDEX `ACT_IDX_IDENT_LNK_USER`,
DROP INDEX `ACT_FK_IDL_PROCINST`,
ADD INDEX `ACT_IDX_IDENT_LNK_TASK_ID`(`TASK_ID_`) USING BTREE;

-- tangxin 2021-09-14 添加url表单管理表
DROP TABLE IF EXISTS `form_url_form`;
CREATE TABLE `form_url_form`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `FORM_NAME_` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '表单名称',
  `FORM_KEY_` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '表单key',
  `FORM_DESC_` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '表单描述',
  `SYS_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '所属系统ID',
  `SYS_NAME_` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '所属系统名称',
  `FORM_URL_` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '表单地址',
  `START_URL_` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '启动表单地址',
  `TASK_URL_` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '待办表单地址',
  `INST_URL_` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '实例表单地址',
  `TOKEN_AUTH_` smallint(0) NULL DEFAULT NULL COMMENT '是否token认证，0：否，1：是',
  `IS_EMBED_` smallint(0) NULL DEFAULT NULL COMMENT '是否嵌入表单，0：否，1：是',
  `STATUS_` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '表单状态，draft：草稿，deploy：已发布',
  `FORM_TYPE_` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '表单类型，pc电脑端，mobile移动端',
  `TYPE_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '分类ID',
  `TYPE_NAME_` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '分类名称',
  `IS_MAIN_` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '是否主表单，N：否，Y：是',
  `VERSION_` int(0) NULL DEFAULT NULL COMMENT '版本号',
  `CREATE_BY_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `CREATE_ORG_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人组织ID',
  `CREATE_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `IS_DELE_` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '是否删除，0未删，1已删',
  `UPDATE_BY_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新人',
  `UPDATE_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户ID',
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = 'URL表单管理' ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;

-- tangxin 2021-09-14 审批相关表添加表单地址字段
ALTER TABLE `bpm_definition`
ADD COLUMN `PC_START_URL_` varchar(200) NULL COMMENT 'pc端启动地址' AFTER `TENANT_ID_`,
ADD COLUMN `MOBILE_START_URL_` varchar(200) NULL COMMENT '手机端启动地址' AFTER `TENANT_ID_`;

ALTER TABLE `bpm_pro_inst`
ADD COLUMN `PC_INST_URL_` varchar(200) NULL COMMENT 'pc端实例地址' AFTER `TENANT_ID_`,
ADD COLUMN `MOBILE_INST_URL_` varchar(200) NULL COMMENT '手机端实例地址' AFTER `TENANT_ID_`;

ALTER TABLE `bpm_pro_inst_hi`
ADD COLUMN `PC_INST_URL_` varchar(200) NULL COMMENT 'pc端实例地址' AFTER `TENANT_ID_`,
ADD COLUMN `MOBILE_INST_URL_` varchar(200) NULL COMMENT '手机端实例地址' AFTER `TENANT_ID_`;

ALTER TABLE `bpm_task`
ADD COLUMN `PC_TASK_URL_` varchar(200) NULL COMMENT 'pc端任务地址' AFTER `TENANT_ID_`,
ADD COLUMN `MOBILE_TASK_URL_` varchar(200) NULL COMMENT '手机端任务地址' AFTER `TENANT_ID_`;

-- tangxin 2020-09-14 添加URL表单管理菜单
INSERT INTO `portal_sys_menu`(`ID_`, `PARENT_ID_`, `NAME_`, `ALIAS_`, `ACTIVE_TAB_`, `MENU_ICON_`, `OPENED_`, `SN_`, `TABS_STYLE_`, `PATH_`, `HREF_`, `TENANT_ID_`) VALUES ('1437731738720321536', '3391046', 'URL表单管理', 'formUrlFormManager', '', '', NULL, 4, '', '-1.1.3441002.3391046.1437731738720321536.', '', '-1');
UPDATE `portal_sys_menu` SET `SN_`= 5 WHERE `ID_`='1287699251299749888';
UPDATE `portal_sys_menu` SET `SN_`= 6 WHERE `ID_`='1386144820958990336';
UPDATE `portal_sys_menu` SET `SN_`= 7 WHERE `ID_`='4151743';

-- zengst 2021-09-23 同步bpm_task到bpm_task_notice
ALTER TABLE `bpm_task_notice`
ADD COLUMN `PC_TASK_URL_` varchar(200) NULL COMMENT 'pc端任务地址' AFTER `TENANT_ID_`,
ADD COLUMN `MOBILE_TASK_URL_` varchar(200) NULL COMMENT '手机端任务地址' AFTER `TENANT_ID_`;


-- 2021-09-22 zhangxw 扩展新闻公告标签表
CREATE TABLE `portal_news_tag`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `NAME_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '标签名称',
  `ALIAS_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '标签别名',
  `STYLE_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '标签风格',
  `TENANT_ID_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户ID',
  `CREATE_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `CREATE_BY_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `UPDATE_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `UPDATE_BY_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新人',
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;


-- 2021-09-22 zhangxw 新闻公告表扩展字段
ALTER TABLE `portal_news_notice_`
ADD COLUMN `ICON_COLOR_` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '图标颜色' AFTER `TYPE_`,
ADD COLUMN `TAG_` varchar(64) NULL COMMENT '标签' AFTER `ICON_COLOR_`;


-- 2021-09-22 zhangxw 栏目表扩展字段
ALTER TABLE `portal_sys_column`
ADD COLUMN `SHOW_TITLE_` smallint(6) NULL COMMENT '是否 显示栏目名称' AFTER `TENANT_ID_`,
ADD COLUMN `CONTAIN_COL_` varchar(2000) NULL COMMENT '组合栏目包含子栏目别名（逗号分隔）' AFTER `SHOW_TITLE_`;

-- 2021-09-22 zhangxw 添加会议室管理表结构
DROP TABLE IF EXISTS `portal_meeting_room`;
CREATE TABLE `portal_meeting_room`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `NAME_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '会议室名称',
  `ALIAS_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '会议室别名',
  `TYPE_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '会议室类型',
  `CAPACITY_` int(10) NULL DEFAULT NULL COMMENT '会议室容量',
  `ADDRESS_` varchar(600) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '会议室地址',
  `FLOOR_ROOM_NUMBER_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '楼层房间号',
  `EQUIPMENT_` varchar(2000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '包含设备',
  `STATUS_` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '会议室状态（可用、不可用）',
  `DESC_` varchar(2000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '会议室说明描述',
  `CREATE_BY_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人id',
  `UPDATE_BY_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新人id',
  `CREATE_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `UPDATE_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `CREATE_ORG_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人所属部门id',
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户id',
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '会议室管理' ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;

-- 2021-09-22 zhangxw 添加会议室申请表结构
CREATE TABLE `portal_meeting_apply`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `SUBJECT_` varchar(300) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '会议主题',
  `MEETING_NAME_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '会议室名称',
  `MEETING_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '会议室id',
  `MEETING_OWNER_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '会议申请人',
  `OWNER_OWNER_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '会议申请人id',
  `MEETING_DEP_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '所属部门',
  `MEETING_DEP_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '所属部门id',
  `PARTICIPANTS_` varchar(1500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '参会人员',
  `PARTICIPANTS_ID_` varchar(1500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '参会人员id',
  `DEPARTMENT_` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '参会部门',
  `DEPARTMENT_ID_` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '参会部门id',
  `OUTSIDERS_` varchar(600) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '外部人员',
  `ATTENDANCE_` int(10) NULL DEFAULT NULL COMMENT '参会人数',
  `MEETING_NOTES_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '会议说明',
  `FILES_` varchar(2000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '相关附件',
  `APPLY_DESC_` varchar(2000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '申请说明',
  `START_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '开始时间',
  `END_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '结束时间',
  `BIND_FLOW_` smallint(6) NULL DEFAULT NULL COMMENT '是否绑定流程',
  `FLOW_KEY_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程key',
  `FLOW_NAME_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程名称',
  `PUBLISH_SCHEDULE_` smallint(6) NULL DEFAULT NULL COMMENT '发布到日程',
  `STATUS_` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '申请状态',
  `CREATE_BY_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人id',
  `UPDATE_BY_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新人id',
  `CREATE_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `UPDATE_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `CREATE_ORG_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人所属部门id',
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户id',
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '会议室申请' ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;

-- 2021-09-22 zhangxw 添加会议室管理菜单
update `portal_sys_menu` set PARENT_ID_='1408998837493829632' where id_='1278989818835111936';
INSERT INTO `portal_sys_menu`(`ID_`, `PARENT_ID_`, `NAME_`, `ALIAS_`, `ACTIVE_TAB_`, `MENU_ICON_`, `OPENED_`, `SN_`, `TABS_STYLE_`, `PATH_`, `HREF_`, `TENANT_ID_`) VALUES ('1408998837493829632', '3441002', '协同办公', 'synergy', '', '', NULL, 4, '', '-1.1.3441002.1408998837493829632.', '', '-1');

-- 2021-09-22 zhangxw 添加会议室配置表
CREATE TABLE `portal_meeting_config`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `BIND_FLOW_` smallint(6) NULL DEFAULT NULL COMMENT '是否绑定流程',
  `FLOW_KEY_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程key',
  `FLOW_NAME_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程名称',
  `PUBLISH_SCHEDULE_` smallint(6) NULL DEFAULT NULL COMMENT '发布到日程',
  `FIELD_MAPPING_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '流程实例ID',
  `CREATE_BY_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人id',
  `UPDATE_BY_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新人id',
  `CREATE_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `UPDATE_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `CREATE_ORG_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人所属部门id',
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户id',
  `DIC_CODE_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '会议室设备字典编码',
  `DIC_NAME_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '会议室设备字典名称',
  `COLUMN_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'lan',
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '会议室配置' ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;


INSERT INTO `portal_meeting_config`(`ID_`, `BIND_FLOW_`, `FLOW_KEY_`, `FLOW_NAME_`, `PUBLISH_SCHEDULE_`, `FIELD_MAPPING_`, `CREATE_BY_`, `UPDATE_BY_`, `CREATE_TIME_`, `UPDATE_TIME_`, `CREATE_ORG_ID_`, `TENANT_ID_`, `DIC_CODE_`, `DIC_NAME_`, `COLUMN_ID_`) VALUES ('1', 1, NULL, NULL, 1, NULL, '1', '1', NULL, NULL, NULL, '-1', NULL, NULL, NULL);




-- 2021-09-22 zhangxw 栏目中扩展微信公众号图文拉取
ALTER TABLE `portal_sys_column`
ADD COLUMN `APPID_` varchar(255) NULL COMMENT '公众号appid' AFTER `CONTAIN_COL_`,
ADD COLUMN `SECRET_` varchar(255) NULL COMMENT '公众号secret' AFTER `APPID_`;


-- 2021-09-22 zhangxw 微信公众号图文拉取信息存储
CREATE TABLE `portal_weixin_material`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `appid` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户凭证',
  `title` varchar(600) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '标题',
  `author` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '作者',
  `digest` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '摘要',
  `content` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '内容',
  `content_source_url` varchar(600) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '图文消息的原文地址，即点击“阅读原文”后的URL',
  `thumb_media_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '图文消息的封面图片素材id（必须是永久mediaID）',
  `show_cover_pic` int(10) NULL DEFAULT NULL COMMENT '是否显示封面，0为false，即不显示，1为true，即显示',
  `url` varchar(600) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '图文页的URL',
  `need_open_comment` int(10) NULL DEFAULT NULL COMMENT '是否打开评论，0不打开，1打开',
  `thumb_url` varchar(600) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '素材图片地址',
  `only_fans_can_comment` int(10) NULL DEFAULT NULL COMMENT '是否粉丝才可评论，0所有人可评论，1粉丝才可评论',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `pull_time` datetime(0) NULL DEFAULT NULL COMMENT '拉取时间',
  PRIMARY KEY (`ID_`) USING BTREE,
  INDEX `IDX_APPID`(`appid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '微信永久素材列表' ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;


-- 2021-09-22 新闻公告添加拟稿部门和发布时间
alter table portal_news_notice_
    add DEPARTMENT_ varchar(255) null comment '拟稿部门';

alter table portal_news_notice_
    add PUBLISH_TIME_ datetime null comment '发布时间';

-- 2021-09-22 zhangxw 会议配申请表扩展流程实例字段
ALTER TABLE `portal_meeting_apply`
ADD COLUMN `PRO_INST_ID_` varchar(64) NULL COMMENT '流程实例id' AFTER `STATUS_`;

-- 2021-09-22 zhangxw 会议配申请表扩展流程实例字段
ALTER TABLE `portal_meeting_apply`
ADD COLUMN `SERVICE_` varchar(600) NULL COMMENT '所需服务' AFTER `STATUS_`;

-- 2021-09-22 zhangxw 添加日程管理表
CREATE TABLE `portal_agenda_day`  (
  `ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `CREATOR_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `SUBJECT_` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '日程标题',
  `START_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '开始时间',
  `END_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '结束时间',
  `CONTENT_` varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '日程内容',
  `SHARE_ID_` varchar(2000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '日程共享人id',
  `SHARE_NAME_` varchar(2000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '日程共享人姓名',
  `CREATE_BY_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人id',
  `UPDATE_BY_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新人id',
  `CREATE_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `UPDATE_TIME_` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `CREATE_ORG_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人所属部门id',
  `TENANT_ID_` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户id',
  PRIMARY KEY (`ID_`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '日程管理' ROW_FORMAT = Dynamic;

-- 2021-09-24 zengst 流程收藏表
create table bpm_flow_collect
(
    ID_          varchar(64) not null comment '主键',
    DEF_KEY_     varchar(64) null comment '流程定义key',
    CREATOR_     varchar(64) null comment '创建人ID',
    CREATE_TIME_ datetime    null comment '创建时间',
    TENANT_ID_   varchar(64) null comment '租户ID',
    constraint BPM_FLOW_COLLECT_ID__uindex
        unique (ID_)
)
    comment '流程收藏记录';

alter table bpm_flow_collect
    add primary key (ID_);

-- 2021-09-24 菜单路由信息扩展列
alter table portal_sys_menu
    add ROUTE_EXTEND_ TEXT null comment '路由信息扩展';

-- 2021-09-26 zengst 前端菜单初始化sql
insert into portal_sys_menu (ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_, HREF_, ROUTE_EXTEND_, TENANT_ID_) values (1441339605377536000, 3, '流程中心', 'matter', '', '', null, 6, '', '-1.3.1441339605377536000.', '', '{"path":"/matter","component":"Layout","redirect":"noRedirect","name":"matter","alwaysShow":true,"meta":{"title":"流程中心","icon":"matterCenter"}}', -1);
insert into portal_sys_menu (ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_, HREF_, ROUTE_EXTEND_, TENANT_ID_) values (1441341228585766912, 3, '个人中心', 'personal', '', 'icon-account', null, 7, '', '-1.3.1441341228585766912.', '', '{"path":"/personal","component":"Layout","redirect":"noRedirect","name":"personal","alwaysShow":true,"meta":{"title":"个人中心","icon":"user"}}', -1);
insert into portal_sys_menu (ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_, HREF_, ROUTE_EXTEND_, TENANT_ID_) values (1441341831483412480, 3, '应用中心', 'appCenter1', '', 'icon-guanli', null, 8, '', '-1.3.1441341831483412480.', '', '{"meta":{"title":"应用中心","icon":"matterCenter"},"path":"/appCenter","component":"Layout","redirect":"noRedirect","alwaysShow":true}', -1);
insert into portal_sys_menu (ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_, HREF_, ROUTE_EXTEND_, TENANT_ID_) values (1441342209381814272, 1441339605377536000, '新建流程', 'new', '', '', null, 1, '', '-1.3.1441339605377536000.1441342209381814272.', '', '{"meta":{"title":"新建流程","isChildren":true},"component":"@/views/matter/newMatter/index","path":"new","hidden":false}', -1);
insert into portal_sys_menu (ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_, HREF_, ROUTE_EXTEND_, TENANT_ID_) values (1441342342999756800, 1441339605377536000, '流程启动', 'startProcess', '', '', null, 2, '', '-1.3.1441339605377536000.1441342342999756800.', '', '{"meta":{"title":"流程启动","isChildren":true},"component":"@/views/matter/StartProcess","path":"startProcess","hidden":true}', -1);
insert into portal_sys_menu (ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_, HREF_, ROUTE_EXTEND_, TENANT_ID_) values (1441342471236407296, 1441339605377536000, '我的任务', 'myTask', '', '', null, 3, '', '-1.3.1441339605377536000.1441342471236407296.', '', '{"meta":{"title":"我的任务","isChildren":true},"path":"myTask","component":"@/views/matter/myTask/index"}', -1);
insert into portal_sys_menu (ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_, HREF_, ROUTE_EXTEND_, TENANT_ID_) values (1441342583597617152, 1441339605377536000, '我的申请', 'apply', '', '', null, 4, '', '-1.3.1441339605377536000.1441342583597617152.', '', '{"meta":{"title":"我的申请","isChildren":true},"path":"apply","component":"@/views/matter/myRequest/index"}', -1);
insert into portal_sys_menu (ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_, HREF_, ROUTE_EXTEND_, TENANT_ID_) values (1441359555827781632, 3, '首页', 'homePage', '', '', null, 5, '', '-1.3.1441359555827781632.', '', '{"meta":{},"component":"Layout","redirect":"index","path":"/"}', -1);
insert into portal_sys_menu (ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_, HREF_, ROUTE_EXTEND_, TENANT_ID_) values (1441359958220918784, 1441359555827781632, '首页', 'Index', '', '', null, 1, '', '-1.3.1441359555827781632.1441359958220918784.', '', '{"path":"index","name":"Index","component":"@/views/home/index","meta":{"title":"首页","icon":"home","affix":true,"isChildren":true}}', -1);
insert into portal_sys_menu (ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_, HREF_, ROUTE_EXTEND_, TENANT_ID_) values (1441938397294415872, 1441341228585766912, '个人设置', 'setting', '', '', null, 1, '', '-1.3.1441341228585766912.1441938397294415872.', '', '{"path":"setting","name":"setting","component":"@/views/personal/setting","meta":{"title":"个人设置","isChildren":true}}', -1);
insert into portal_sys_menu (ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_, HREF_, ROUTE_EXTEND_, TENANT_ID_) values (1441938698676129792, 1441341228585766912, '邮件中心', 'mail', '', '', null, 2, '', '-1.3.1441341228585766912.1441938698676129792.', '', '{"path":"mail","name":"mail","component":"@/views/personal/mail","meta":{"title":"邮件中心","isChildren":true}}', -1);
-- insert into portal_sys_menu (ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_, HREF_, ROUTE_EXTEND_, TENANT_ID_) values (1441938904301883392, 1441341228585766912, '内部消息', 'message', '', '', null, 3, '', '-1.3.1441341228585766912.1441938904301883392.', '', '{"path":"message","name":"message","component":"@/views/personal/message","meta":{"title":"内部消息","isChildren":true}}', -1);
insert into portal_sys_menu (ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_, HREF_, ROUTE_EXTEND_, TENANT_ID_) values (1441941148611039232, 1441341831483412480, '应用中心', 'appCenter2', '', '', null, 1, '', '-1.3.1441341831483412480.1441941148611039232.', '', '{"path":"index","component":"@/views/appCenter/index","name":"AppCenter","meta":{"title":"首页","isChildren":true}}', -1);
insert into portal_sys_menu (ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_, HREF_, ROUTE_EXTEND_, TENANT_ID_) values (1441946969948475392, 1441359555827781632, '个人中心', 'personalCenter', '', '', null, 2, '', '-1.3.1441359555827781632.1441946969948475392.', '', '{"path":"personalCenter","name":"personalCenter","component":"@/views/personalCenter/index","meta":{"title":"个人中心","icon":"laptop","isChildren":true},"hidden":true}', -1);
insert into portal_sys_menu (ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_, HREF_, ROUTE_EXTEND_, TENANT_ID_) values (1441966593469501440, 1441339605377536000, '审批表单', 'approvalForm', '', '', null, 5, '', '-1.3.1441339605377536000.1441966593469501440.', '', '{"path":"approvalForm","name":"approvalForm","component":"@/views/matter/ApprovalForm","meta":{"title":"审批表单"},"hidden":true}', -1);


-- 2021-09-27 chenzm 流程初始化按钮菜单
INSERT INTO  portal_sys_menu ( ID_ ,  PARENT_ID_ ,  NAME_ ,  ALIAS_ ,  ACTIVE_TAB_ ,  MENU_ICON_ ,  OPENED_ ,  SN_ ,  TABS_STYLE_ ,  PATH_ ,  HREF_ ,  TENANT_ID_ ,  ROUTE_EXTEND_ ) VALUES ('1430769509001445376', '3641025', '流程按钮', 'flowButtonManager', 'startTaskButtons', '', NULL, 6, '', '-1.1.3641025.1430769509001445376.', '', '-1', NULL);
INSERT INTO  portal_sys_menu  ( ID_ ,  PARENT_ID_ ,  NAME_ ,  ALIAS_ ,  ACTIVE_TAB_ ,  MENU_ICON_ ,  OPENED_ ,  SN_ ,  TABS_STYLE_ ,  PATH_ ,  HREF_ ,  TENANT_ID_ ,  ROUTE_EXTEND_ ) VALUES ('1430788426285563904', '1430769509001445376', '用户任务节点', 'userTaskButtons', '', '', NULL, 2, '', '-1.1.3641025.1430769509001445376.1430788426285563904.', '', '-1', NULL);
INSERT INTO  portal_sys_menu  ( ID_ ,  PARENT_ID_ ,  NAME_ ,  ALIAS_ ,  ACTIVE_TAB_ ,  MENU_ICON_ ,  OPENED_ ,  SN_ ,  TABS_STYLE_ ,  PATH_ ,  HREF_ ,  TENANT_ID_ ,  ROUTE_EXTEND_ ) VALUES ('1430788606049239040', '1430769509001445376', '会签任务节点', 'signTaskButtons', '', '', NULL, 3, '', '-1.1.3641025.1430769509001445376.1430788606049239040.', '', '-1', NULL);
INSERT INTO  portal_sys_menu  ( ID_ ,  PARENT_ID_ ,  NAME_ ,  ALIAS_ ,  ACTIVE_TAB_ ,  MENU_ICON_ ,  OPENED_ ,  SN_ ,  TABS_STYLE_ ,  PATH_ ,  HREF_ ,  TENANT_ID_ ,  ROUTE_EXTEND_ ) VALUES ('1430789609448390656', '1430769509001445376', '开始任务节点', 'startTaskButtons', '', '', NULL, 1, '', '-1.1.3641025.1430769509001445376.1430789609448390656.', '', '-1', NULL);

-- 2021-09-27 chenzm 权限调整菜单
INSERT INTO  portal_sys_menu  ( ID_ ,  PARENT_ID_ ,  NAME_ ,  ALIAS_ ,  ACTIVE_TAB_ ,  MENU_ICON_ ,  OPENED_ ,  SN_ ,  TABS_STYLE_ ,  PATH_ ,  HREF_ ,  TENANT_ID_ ,  ROUTE_EXTEND_ ) VALUES ('1432175565783007232', '4073629', '权限调整', 'permissionAdjustmentManage', '', '', NULL, 4, '', '-1.1.3641025.4073629.1432175565783007232.', '', '-1', NULL);

-- 2021-09-28 pangq 表单列表漏字段
ALTER TABLE `FORM_DATA_TEMPLATE`
ADD COLUMN `TABLE_CONFIGURE_` varchar(200) NULL COMMENT '按钮操作列配置';


-- 2021-09-28 常用联系人 排序字段
alter table uc_group_user
    add SN_ int null comment '排序值';


-- 2021-09-30 zengst 用户布局配置表
-- auto-generated definition
create table portal_user_layout_config
(
    ID_             varchar(64) not null comment '主键'
        primary key,
    LAYOUT_ID_      varchar(64) null comment '布局ID',
    CONFIG_CONTENT_ text        null comment '布局配置信息',
    CREATOR_        varchar(64) null comment '创建者ID'
)
    comment '用户布局配置';

-- tangxin 2021-09-30 添加服务编排相关表
DROP TABLE IF EXISTS portal_connection_manager;
CREATE TABLE portal_connection_manager(
    id_ VARCHAR(64) NOT NULL   COMMENT '主键' ,
    ref_id_ VARCHAR(64)    COMMENT '外键' ,
    name_ VARCHAR(60)    COMMENT '连接名称' ,
    alias_ VARCHAR(60)    COMMENT '连接别名' ,
    desc_ VARCHAR(200)    COMMENT '连接描述' ,
    type_id_ VARCHAR(60)    COMMENT '所属分类' ,
    type_name_ VARCHAR(200)    COMMENT '所属分类名称' ,
    type_id_path_ VARCHAR(500)    COMMENT '所属分类路径' ,
    status_ VARCHAR(1)    COMMENT '启用状态1启用 0禁用' ,
    connection_type_ VARCHAR(60)    COMMENT '连接类型' ,
    connect_param_ VARCHAR(200)    COMMENT '属性参数' ,
    create_by_ VARCHAR(64)    COMMENT '创建人' ,
    create_org_id_ VARCHAR(64)    COMMENT '创建人组织ID' ,
    create_time_ DATETIME    COMMENT '创建时间' ,
    update_by_ VARCHAR(64)    COMMENT '更新人' ,
    update_time_ DATETIME    COMMENT '更新时间' ,
    revision_ VARCHAR(32)    COMMENT '乐观锁' ,
    is_dele_ VARCHAR(1)    COMMENT '是否删除，0未删，1已删' ,
    tenant_id_ VARCHAR(64)    COMMENT '租户ID' ,
    PRIMARY KEY (id_)
)  COMMENT = '连接管理';

DROP TABLE IF EXISTS portal_interface_manager;
CREATE TABLE portal_interface_manager(
    id_ VARCHAR(64) NOT NULL   COMMENT '主键' ,
    ref_id_ VARCHAR(64)    COMMENT '外键（连接管理ID）' ,
    name_ VARCHAR(60)    COMMENT '接口名称' ,
    alias_ VARCHAR(64)    COMMENT '接口别名' ,
    desc_ VARCHAR(200)    COMMENT '接口描述' ,
    input_params_ TEXT    COMMENT '输入参数' ,
    pre_processors_ VARCHAR(60)    COMMENT '前置处理器;用于对输入参数转换为map 或者自定义扩展输入参数' ,
    output_params_ TEXT    COMMENT '输出参数' ,
    post_processors_ VARCHAR(60)    COMMENT '后置处理器;对返回结果进行处理' ,
    status_ VARCHAR(1)    COMMENT '启用状态1启用 0禁用' ,
    create_by_ VARCHAR(64)    COMMENT '创建人' ,
    create_org_id_ VARCHAR(64)    COMMENT '创建人组织ID' ,
    create_time_ DATETIME    COMMENT '创建时间' ,
    update_by_ VARCHAR(64)    COMMENT '更新人' ,
    update_time_ DATETIME    COMMENT '更新时间' ,
    revision_ VARCHAR(32)    COMMENT '乐观锁' ,
    is_dele_ VARCHAR(1)    COMMENT '是否删除，0未删，1已删' ,
    tenant_id_ VARCHAR(64)    COMMENT '租户ID' ,
    PRIMARY KEY (id_)
)  COMMENT = '接口管理';

DROP TABLE IF EXISTS portal_db_interface;
CREATE TABLE portal_db_interface(
    id_ VARCHAR(64) NOT NULL   COMMENT '主键' ,
    ref_id_ VARCHAR(64)    COMMENT '外键' ,
    type_ VARCHAR(60)    COMMENT '类型' ,
    dsalias_ VARCHAR(60)    COMMENT '数据源的别名' ,
    need_page_ INT    COMMENT '是否需要分页' ,
    page_size_ INT    COMMENT '分页大小' ,
    obj_name_ VARCHAR(200)    COMMENT '表名或者视图名' ,
    displayfield_ TEXT    COMMENT '显示字段' ,
    resultfield_ TEXT    COMMENT '返回字段' ,
    conditionfield_ TEXT    COMMENT '条件字段' ,
    sortfield_ TEXT    COMMENT '排序字段' ,
    is_table_ VARCHAR(1)    COMMENT '是否数据库表 0视图1数据库表' ,
    diy_sql_ TEXT    COMMENT '自定义sql' ,
    sql_build_type_ VARCHAR(1)    COMMENT 'SQL构建类型' ,
    create_by_ VARCHAR(64)    COMMENT '创建人' ,
    create_org_id_ VARCHAR(64)    COMMENT '创建人组织ID' ,
    create_time_ DATETIME    COMMENT '创建时间' ,
    update_by_ VARCHAR(64)    COMMENT '更新人' ,
    update_time_ DATETIME    COMMENT '更新时间' ,
    revision_ VARCHAR(32)    COMMENT '乐观锁' ,
    is_dele_ VARCHAR(1)    COMMENT '是否删除，0未删，1已删' ,
    tenant_id_ VARCHAR(64)    COMMENT '租户ID' ,
    PRIMARY KEY (id_)
)  COMMENT = '数据库接口';

DROP TABLE IF EXISTS portal_restful_interface;
CREATE TABLE portal_restful_interface(
    id_ VARCHAR(64) NOT NULL   COMMENT '主键' ,
    ref_id_ VARCHAR(64)    COMMENT '外键' ,
    url_ VARCHAR(200)    COMMENT '接口地址' ,
    header_ VARCHAR(500)    COMMENT '接口头部' ,
    token_auth_ VARCHAR(1)    COMMENT '是否token认证，0：否，1：是' ,
    request_type_ VARCHAR(60)    COMMENT '请求方式' ,
    content_type_ VARCHAR(60)    COMMENT '请求头的Content-type类型' ,
    request_params_ VARCHAR(900)    COMMENT '请求参数 可以根据输入参数替换' ,
    list_key_ VARCHAR(50)    COMMENT '列表(key)' ,
    resultfield_ TEXT    COMMENT '返回字段' ,
    conditionfield_ TEXT    COMMENT '条件字段' ,
    data_param_ VARCHAR(2000)    COMMENT '接口参数' ,
    create_by_ VARCHAR(64)    COMMENT '创建人' ,
    create_org_id_ VARCHAR(64)    COMMENT '创建人组织ID' ,
    create_time_ DATETIME    COMMENT '创建时间' ,
    update_by_ VARCHAR(64)    COMMENT '更新人' ,
    update_time_ DATETIME    COMMENT '更新时间' ,
    revision_ VARCHAR(32)    COMMENT '乐观锁' ,
    is_dele_ VARCHAR(1)    COMMENT '是否删除，0未删，1已删' ,
    tenant_id_ VARCHAR(64)    COMMENT '租户ID' ,
    PRIMARY KEY (id_)
)  COMMENT = 'restful接口';

DROP TABLE IF EXISTS portal_service_choreography;
CREATE TABLE portal_service_choreography(
    id_ VARCHAR(64) NOT NULL   COMMENT '主键' ,
    ref_id_ VARCHAR(64)    COMMENT '外键' ,
    name_ VARCHAR(60)    COMMENT '名称' ,
    alias_ VARCHAR(60)    COMMENT '别名' ,
    desc_ VARCHAR(200)    COMMENT '描述' ,
    flow_data_json_ TEXT    COMMENT '流程数据信息' ,
    status_ VARCHAR(1)    COMMENT '启用状态1启用 0禁用' ,
    create_by_ VARCHAR(64)    COMMENT '创建人' ,
    create_org_id_ VARCHAR(64)    COMMENT '创建人组织ID' ,
    create_time_ DATETIME    COMMENT '创建时间' ,
    update_by_ VARCHAR(64)    COMMENT '更新人' ,
    update_time_ DATETIME    COMMENT '更新时间' ,
    revision_ VARCHAR(64)    COMMENT '乐观锁' ,
    is_dele_ VARCHAR(1)    COMMENT '是否删除，0未删，1已删' ,
    tenant_id_ VARCHAR(64)    COMMENT '租户ID' ,
    PRIMARY KEY (id_)
)  COMMENT = '服务编排';

DROP TABLE IF EXISTS portal_restful_manage;
CREATE TABLE portal_restful_manage(
    id_ VARCHAR(64) NOT NULL   COMMENT '主键' ,
    base_url VARCHAR(200)    COMMENT '基础地址' ,
    create_by_ VARCHAR(64)    COMMENT '创建人' ,
    create_org_id_ VARCHAR(64)    COMMENT '创建人组织ID' ,
    create_time_ DATETIME    COMMENT '创建时间' ,
    update_by_ VARCHAR(64)    COMMENT '更新人' ,
    update_time_ DATETIME    COMMENT '更新时间' ,
    status_ VARCHAR(1)    COMMENT '启用状态1启用 0禁用' ,
    revision_ VARCHAR(32)    COMMENT '乐观锁' ,
    is_dele_ VARCHAR(1)    COMMENT '是否删除，0未删，1已删' ,
    tenant_id_ VARCHAR(64)    COMMENT '租户号' ,
    PRIMARY KEY (id_)
)  COMMENT = 'restful管理';

DROP TABLE IF EXISTS portal_service_log;
CREATE TABLE portal_service_log(
    id_ VARCHAR(64) NOT NULL   COMMENT '主键' ,
    alias_ VARCHAR(60)    COMMENT '别名' ,
    proc_def_id_ VARCHAR(64)    COMMENT '流程定义ID' ,
    proc_def_key_ VARCHAR(128)    COMMENT '流程定义Key' ,
    proc_def_name_ VARCHAR(200)    COMMENT '流程名称' ,
    subject_ VARCHAR(600)    COMMENT '流程标题' ,
    sup_inst_id_ VARCHAR(64)    COMMENT '父流程实例ID' ,
    proc_inst_id_ VARCHAR(64)    COMMENT '流程实例ID' ,
    task_id_ VARCHAR(64)    COMMENT '任务ID' ,
    node_id_ VARCHAR(64)    COMMENT '节点ID' ,
    node_name_ VARCHAR(200)    COMMENT '节点名称' ,
    user_id_ VARCHAR(64)    COMMENT '用户ID' ,
    user_account_ VARCHAR(60)    COMMENT '用户账号' ,
    user_name_ VARCHAR(200)    COMMENT '用户名称' ,
    type_ VARCHAR(10)    COMMENT '类型（interface：接口，service：服务）' ,
    is_success_ VARCHAR(1)    COMMENT '是否调用成功' ,
    response_ TEXT    COMMENT '调用结果' ,
    call_time_ DATETIME    COMMENT '调用时间' ,
    revision_ VARCHAR(64)    COMMENT '乐观锁' ,
    tenant_id_ VARCHAR(64)    COMMENT '租户号' ,
    PRIMARY KEY (id_)
)  COMMENT = '服务调用日志';

-- tangxin 2021-09-30 添加服务编排初始化数据
INSERT INTO PORTAL_SYS_TYPE_GROUP(ID_, GROUP_KEY_, NAME_, FLAG_, SN_, TYPE_, CREATE_BY_, CREATE_TIME_, CREATE_ORG_ID_, UPDATE_BY_, UPDATE_TIME_) VALUES ('15', 'CONNECT_TYPE', '连接分类', 1, 0, 1, NULL, NULL, NULL, NULL, NULL);
INSERT INTO PORTAL_SYS_TYPE(ID_, TYPE_GROUP_KEY_, NAME_, TYPE_KEY_, STRU_TYPE_, PARENT_ID_, DEPTH_, PATH_, IS_LEAF_, OWNER_ID_, SN_, CREATE_BY_, CREATE_TIME_, CREATE_ORG_ID_, UPDATE_BY_, UPDATE_TIME_, ICON_, TENANT_ID_) VALUES ('31130', 'CONNECT_TYPE', '默认分类', 'default', '1', '15', 1, '15.31130.', 'Y', '0', 0, '1', NULL, '', NULL, NULL, NULL, '-1');

-- tangxin 2021-09-30 去掉数据源菜单，调整企微钉钉菜单位置
DELETE FROM PORTAL_SYS_MENU WHERE ALIAS_ = 'sysExternalUniteList';
DELETE FROM PORTAL_SYS_MENU WHERE ALIAS_ = 'dataSourceManager';

-- tangxin 2021-09-30 添加集成中心菜单
INSERT INTO PORTAL_SYS_MENU(ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_, HREF_, ROUTE_EXTEND_, TENANT_ID_) VALUES ('1437982148582154240', '1', '集成中心', 'IntegratedCenter', '', '', NULL, 4, '', '-1.1.1437982148582154240.', '', NULL, '-1');
INSERT INTO PORTAL_SYS_MENU(ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_, HREF_, ROUTE_EXTEND_, TENANT_ID_) VALUES ('1437975457390284800', '1437982148582154240', '集成管理', 'integratorManage', 'connectionManager', '', NULL, 1, '', '-1.1.1437982148582154240.1437975457390284800.', '', NULL, '-1');
INSERT INTO PORTAL_SYS_MENU(ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_, HREF_, ROUTE_EXTEND_, TENANT_ID_) VALUES ('1442676643885162496', '1437975457390284800', '连接管理', 'connectionManager', '', '', NULL, 1, '', '-1.1.1437982148582154240.1437975457390284800.1442676643885162496.', '', NULL, '-1');
INSERT INTO PORTAL_SYS_MENU(ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_, HREF_, ROUTE_EXTEND_, TENANT_ID_) VALUES ('1442676693583470592', '1437975457390284800', '接口管理', 'interfaceManage', '', '', NULL, 2, '', '-1.1.1437982148582154240.1437975457390284800.1442676693583470592.', '', NULL, '-1');
INSERT INTO PORTAL_SYS_MENU(ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_, HREF_, ROUTE_EXTEND_, TENANT_ID_) VALUES ('1442676731843911680', '1437975457390284800', '服务编排', 'serviceChoreography', '', '', NULL, 3, '', '-1.1.1437982148582154240.1437975457390284800.1442676731843911680.', '', NULL, '-1');
INSERT INTO PORTAL_SYS_MENU(ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_, HREF_, ROUTE_EXTEND_, TENANT_ID_) VALUES ('1285866673655648256', '1437982148582154240', '企微钉钉', 'sysExternalUniteList', '', '', NULL, 2, '', '-1.1.1437982148582154240.1285866673655648256.', '', NULL, '-1');
INSERT INTO PORTAL_SYS_MENU(ID_, PARENT_ID_, NAME_, ALIAS_, ACTIVE_TAB_, MENU_ICON_, OPENED_, SN_, TABS_STYLE_, PATH_, HREF_, ROUTE_EXTEND_, TENANT_ID_) VALUES ('1437738312683724800', '1437982148582154240', '外部系统管理', 'externalSystem', '', '', NULL, 3, '', '-1.1.1437982148582154240.1437738312683724800.', '', NULL, '-1');
