-- 创建消息模板表结构
CREATE TABLE IF NOT EXISTS `hzims_message_template`  (
   `ID` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '消息类型',
   `TYPE` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键ID',
   `BUSINESS_KEY` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '业务关键字',
   `BUSINESS_CLASSIFY` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '业务分类',
   `SUBJECT` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主题',
   `CONCENTRATED_DURATION` mediumint(9) NULL DEFAULT NULL COMMENT '集中推送时长',
   `CONCENTRATED_TIME_UNIT` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '集中推送单位',
   `ADVANCE_DURATION` mediumint(9) NULL DEFAULT NULL COMMENT '提前推送时长',
   `ADVANCE_TIME_UNIT` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '提前推送单位',
   `TENANT_ID` varchar(12) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '租户ID',
   `CREATE_DEPT` bigint(20) NULL DEFAULT NULL COMMENT '创建单位',
   `CREATE_USER` bigint(20) NOT NULL COMMENT '创建人',
   `CREATE_TIME` datetime NOT NULL COMMENT '创建时间',
   `UPDATE_USER` bigint(20) NULL DEFAULT NULL COMMENT '修改人',
   `UPDATE_TIME` datetime NULL DEFAULT NULL COMMENT '修改时间',
   `STATUS` tinyint(4) NULL DEFAULT NULL COMMENT '业务状态',
   `IS_DELETED` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否删除 0-正常 1-删除',
   PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1643920980174729219 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '消息推送模板' ROW_FORMAT = DYNAMIC;
SET FOREIGN_KEY_CHECKS = 1;

-- 创建消息记录表结构
CREATE TABLE IF NOT EXISTS `hzims_message_push_record`  (
  `ID` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `TASK_ID` bigint(20) NOT NULL COMMENT '消息类型',
  `TEMPLATE_ID` bigint(20) NOT NULL COMMENT '消息模板ID',
  `PUSHER` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '推送人',
  `PUSHER_NAME` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '推送人名称',
  `CONTENT` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '内容',
  `PLAN_TIME` datetime NULL DEFAULT NULL COMMENT '计划推送时间',
  `PUSH_TIME` datetime NULL DEFAULT NULL COMMENT '实际推送时间',
  `TYPE` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '消息类型',
  `BUSINESS_KEY` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '业务关键字',
  `BUSINESS_CLASSIFY` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '业务分类。系统通知：system,事务消息：business,日常提醒：dailyRemind,巡检消息：inspect',
  `SUBJECT` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主题',
  `CONCENTRATED_DURATION` mediumint(9) NULL DEFAULT NULL COMMENT '集中推送时长',
  `CONCENTRATED_TIME_UNIT` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '集中推送单位',
  `ADVANCE_DURATION` mediumint(9) NULL DEFAULT NULL COMMENT '提前推送时长',
  `ADVANCE_TIME_UNIT` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '提前推送单位',
  `TENANT_ID` varchar(12) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '租户ID',
  `CREATE_DEPT` bigint(20) NULL DEFAULT NULL COMMENT '创建单位',
  `CREATE_USER` bigint(20) NOT NULL COMMENT '创建人',
  `CREATE_TIME` datetime NOT NULL COMMENT '创建时间',
  `UPDATE_USER` bigint(20) NULL DEFAULT NULL COMMENT '修改人',
  `UPDATE_TIME` datetime NULL DEFAULT NULL COMMENT '修改时间',
  `STATUS` tinyint(4) NULL DEFAULT 0 COMMENT '业务状态(0 未推送,1 推送成功,2 推送失败,3 已确认)',
  `IS_DELETED` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否删除 0-正常 1-删除',
  `RESPOND_TIME` datetime NULL DEFAULT NULL COMMENT '响应时间',
  `RESPOND_REMARK` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '响应说明',
  `RESOURCE_CODE` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '资源编码',
  `ACCOUNT` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '推送账号：手机号，邮箱',
  `STATION_CODE` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '站点编码',
  `STATION_NAME` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '站点名称',
  PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1645716467911520258 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '消息推送记录' ROW_FORMAT = DYNAMIC;

SET FOREIGN_KEY_CHECKS = 1;

-- 站点编码字段 -> 机构ID
alter table hzims_message_push_record change `STATION_CODE` `DEPT_ID` bigint(20) DEFAULT NULL comment '机构ID';
-- 站点名称字段 -> 机构名称
alter table hzims_message_push_record change `STATION_NAME` `DEPT_NAME` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL comment '机构ID';

-- 消息推送类型字典
INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1645998325178130433, 0, 'pushType', '-1', '推送类型', 6, '', 0, 0, 0, -1, 'message');
INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1645998429171703809, 1645998325178130433, 'pushType', '0', '即时推送', 1, '', 0, 0, 0, -1, 'message');
INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1645998773519867906, 1645998325178130433, 'pushType', '1', '计划推送', 2, '', 0, 0, 0, -1, 'message');


