##新增租户
INSERT INTO `custody_tenant_info`(`tenant_name`, `account_name`, `account_level`, `contact_person`, `account_key`, `permissions`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES ('H0000001', 'H0000001', 0, 'H0000001', 'a146f69Eb7B84b5fA36e', '[\"all\"]', NULL, NULL, now(), now(), 0);
##新增授权
INSERT INTO `custody_tenant_escrow_authorization_info`(`tenant_name`, `contact_person`, `trust_no`, `app_key`, `app_secret`, `company_id`, `file_path`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES ('H0000001', 'H0000001', '99', '2c0b9acefab9440b9107f9e2428940b7', NULL, NULL, NULL, NULL, NULL, now(), now(), 0);

#新增数据字典表名称
INSERT INTO `custody_data_dictionary_directory`(`id`, `dic_type`, `dic_description`, `service_name`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (40, 'exchangeCode', '交易所', 'dataDictionaryExchangeCodeService', NULL, NULL, '2022-08-15 17:51:56', '2022-08-15 17:51:56', 0);
INSERT INTO `custody_data_dictionary_directory`(`id`, `dic_type`, `dic_description`, `service_name`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (41, 'marketFlag', '市场标识', 'dataDictionaryMarketFlagServiceImpl', NULL, NULL, '2022-08-15 17:51:56', '2022-08-15 17:51:56', 0);

##新建数据字典交易所表 以及数据
DROP TABLE IF EXISTS `custody_data_dictionary_exchange_code`;
CREATE TABLE `custody_data_dictionary_exchange_code`  (
  `id` int(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `key_str` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '字典key',
  `value` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'value',
  `version` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '版本',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `is_deleted` int(1) NULL DEFAULT NULL COMMENT '是否删除(有效|0,无效|1)',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '数据字典：交易所' ROW_FORMAT = Dynamic;
##新增数据字典交易所表数据
INSERT INTO `custody_data_dictionary_exchange_code` VALUES (1, '101', '上海证券交易所', NULL, NULL, '2022-08-15 21:28:43', '2022-08-15 21:28:43', 0);
INSERT INTO `custody_data_dictionary_exchange_code` VALUES (2, '105', '深圳证券交易所', NULL, NULL, '2022-08-15 21:28:43', '2022-08-15 21:28:43', 0);
INSERT INTO `custody_data_dictionary_exchange_code` VALUES (3, '161', '香港联合交易所', NULL, NULL, '2022-08-15 21:28:43', '2022-08-15 21:28:43', 0);
INSERT INTO `custody_data_dictionary_exchange_code` VALUES (4, '999', '其他', NULL, NULL, '2022-08-15 21:28:43', '2022-08-15 21:28:43', 0);

##币种字典新增
INSERT INTO `custody_data_dictionary_duration_currency`(`id`, `key_str`, `value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (10, '410', '韩元', NULL, NULL, '2022-08-16 15:17:02', '2022-08-16 15:17:02', 0);
INSERT INTO `custody_data_dictionary_duration_currency`(`id`, `key_str`, `value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (11, '901', '台币', NULL, NULL, '2022-08-16 15:17:02', '2022-08-16 15:17:02', 0);

##资讯平台新增币种字典
INSERT INTO `custody_data_dictionary_duration_currency_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (1, '99', '142', NULL, NULL, '2022-08-16 15:14:43', '2022-08-16 15:14:43', 0);
INSERT INTO `custody_data_dictionary_duration_currency_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (2, '99', '110', NULL, NULL, '2022-08-16 15:14:43', '2022-08-16 15:14:43', 0);
INSERT INTO `custody_data_dictionary_duration_currency_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (3, '99', '116', NULL, NULL, '2022-08-16 15:14:43', '2022-08-16 15:14:43', 0);
INSERT INTO `custody_data_dictionary_duration_currency_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (10, '99', '133', NULL, NULL, '2022-08-16 15:14:43', '2022-08-16 15:14:43', 0);
INSERT INTO `custody_data_dictionary_duration_currency_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (6, '99', '303', NULL, NULL, '2022-08-16 15:14:43', '2022-08-16 15:14:43', 0);
INSERT INTO `custody_data_dictionary_duration_currency_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (7, '99', '502', NULL, NULL, '2022-08-16 15:14:43', '2022-08-16 15:14:43', 0);
INSERT INTO `custody_data_dictionary_duration_currency_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (11, '99', '143', NULL, NULL, '2022-08-16 15:14:43', '2022-08-16 15:14:43', 0);
INSERT INTO `custody_data_dictionary_duration_currency_details`(`dic_id`, `trust_no`, `origin_value`, `version`, `remark`, `create_time`, `update_time`, `is_deleted`) VALUES (8, '99', '300', NULL, NULL, '2022-08-16 15:14:43', '2022-08-16 15:14:43', 0);

##新增市场标识字典表
DROP TABLE IF EXISTS `custody_data_dictionary_market_flag`;
CREATE TABLE `custody_data_dictionary_market_flag`  (
  `id` int(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `key_str` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '字典key',
  `value` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'value',
  `version` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '版本',
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `is_deleted` int(1) NULL DEFAULT NULL COMMENT '是否删除(有效|0,无效|1)',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '数据字典：市场标识' ROW_FORMAT = Dynamic;
##新增市场标识字典数据
INSERT INTO `custody_data_dictionary_market_flag` VALUES (1, '0', '其他', NULL, NULL, '2022-08-16 15:55:02', '2022-08-16 15:55:02', 0);
INSERT INTO `custody_data_dictionary_market_flag` VALUES (2, '1', 'A股', NULL, NULL, '2022-08-16 15:55:02', '2022-08-16 15:55:02', 0);
INSERT INTO `custody_data_dictionary_market_flag` VALUES (3, '2', '港股', NULL, NULL, '2022-08-16 15:55:02', '2022-08-16 15:55:02', 0);


##新建fund_index_daily_quote_info表
DROP TABLE IF EXISTS `custody_fund_index_daily_quote_info`;
CREATE TABLE `custody_fund_index_daily_quote_info`  (
  `id` int(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `wind_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'WIND代码',
  `secu_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '证券编码\r\n',
  `trading_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '交易代码',
  `secu_abbr` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '证券简称',
  `exchange_code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '交易所代码（数据字典：交易所）',
  `trading_day` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '交易日期  固定格式yyyyMMdd',
  `currency` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '货币代码 （数据字典：币种）\r\n',
  `prev_closing_price` decimal(20, 4) NULL DEFAULT NULL COMMENT '昨收盘',
  `opening_price` decimal(20, 4) NULL DEFAULT NULL COMMENT '开盘价(点)',
  `highest_price` decimal(20, 4) NULL DEFAULT NULL COMMENT '最高价(点)',
  `lowest_price` decimal(20, 4) NULL DEFAULT NULL COMMENT '最低价(点)',
  `closing_price` decimal(20, 4) NULL DEFAULT NULL COMMENT '收盘价(点)',
  `turnover_vol` decimal(20, 4) NULL DEFAULT NULL COMMENT '成交量',
  `turnover_val` decimal(20, 4) NULL DEFAULT NULL COMMENT '成交额',
  `day_change` decimal(20, 4) NULL DEFAULT NULL COMMENT '日涨跌',
  `day_change_rate` decimal(20, 4) NULL DEFAULT NULL COMMENT '日涨跌幅（%）',
  `pe` decimal(20, 4) NULL DEFAULT NULL COMMENT '指数市盈率(PE/PB/AFMARKETVAL/TMARKETVAL仅适用于申万指数行情)',
  `pb` decimal(20, 4) NULL DEFAULT NULL COMMENT '指数市净率',
  `af_market_val` decimal(20, 4) NULL DEFAULT NULL COMMENT 'A股流通市值(万元)',
  `t_market_val` decimal(20, 4) NULL DEFAULT NULL COMMENT '总市值(万元)',
  `market_flag` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '市场标识 (数据字典：市场标识)',
  `trust_no` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '托管人编码 （数据字典：托管人）',
  `admin` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '租户名',
  `unique_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '唯一索引：用于插入',
  `version` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '版本',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `is_deleted` int(1) NULL DEFAULT NULL COMMENT '是否删除(有效|0,无效|1)',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `unique_key`(`unique_key`) USING BTREE,
  INDEX `query_key`(`trading_code`, `trading_day`, `trust_no`, `admin`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '基金行情数据表（custody_fund_index_daily_quote_info）' ROW_FORMAT = Dynamic;


##新增公用数据名称表 及其数据
DROP TABLE IF EXISTS `custody_public_data_directory`;
CREATE TABLE `custody_public_data_directory`  (
  `id` int(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `type` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '公用数据类型',
  `public_data_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '公用数据名称',
  `service_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '服务名称',
  `version` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '版本',
  `remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `is_deleted` int(1) NULL DEFAULT 0 COMMENT '是否删除(有效|0,无效|1)',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `unique_type`(`type`) USING BTREE COMMENT '保证公用数据类型唯一'
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '公用数据目录表（custody_public_data_directory）' ROW_FORMAT = Dynamic;

INSERT INTO `custody_public_data_directory` VALUES (1, 'fundIndexDailyQuoteData', '基金行情指数', 'fundIndexDailyQuoteInfoService', NULL, NULL, '2022-08-16 22:13:48', '2022-08-16 22:13:48', 0);
