2025-02-16 09:49:55 +08:00

370 lines
14 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

CREATE TABLE IF NOT EXISTS `UserCfg` (
`id` bigint(20) AUTO_INCREMENT,
`tenantid` int DEFAULT 0,
`tenantname` varchar(100) NOT NULL,
`name` varchar(20) NOT NULL,
`pwd` varchar(64) NOT NULL,
`role` varchar(24) NOT NULL,
`locked` boolean DEFAULT false,
`nickname` varchar(20) DEFAULT NULL,
`init_pwd` boolean DEFAULT true,
`mobile` varchar(20) DEFAULT NULL,
`avatar_url` varchar(255) DEFAULT NULL,
`openid` varchar(64) DEFAULT NULL,
`warning_enabled` bit(1) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `TenantCfg` (
`id` int NOT NULL,
`name` varchar(128) NOT NULL,
`create_time` timestamp(3) DEFAULT CURRENT_TIMESTAMP(3),
`update_time` timestamp(3) DEFAULT CURRENT_TIMESTAMP(3),
`contact` varchar(64) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/***
以下是北斗数据库表:
1、设备配置表
2、基本参数组、解算参数组、转发参数组
3、设备状态表
4、GNSS数据原始数据、解算结果
5、GNSS消息消息概要、状态消息、收发统计消息
6、告警告警门限告警消息
以上配置除2外均和租户相关。SAAS提供商可看所有的数据租户只能看到自己的设备的数据以及基本参数组、解算参数组
*/
CREATE TABLE IF NOT EXISTS `gnssdevices` (
`id` bigint AUTO_INCREMENT,
`tenantid` int NOT NULL,
`opmode` smallint DEFAULT 0,
`createtime` datetime DEFAULT NULL,
`createuser` varchar(50) DEFAULT NULL,
`updatetime` datetime DEFAULT NULL,
`updateuser` varchar(50) DEFAULT NULL,
`deviceid` varchar(20) NOT NULL,
`fwddeviceid` varchar(40) NOT NULL,
`name` varchar(50) NOT NULL,
`parentid` varchar(20) DEFAULT NULL,
`devicetype` smallint DEFAULT 0,
`tenantname` varchar(100) NOT NULL,
`project_id` varchar(64) DEFAULT NULL COMMENT '项目id',
`project2_id` varchar(64) DEFAULT NULL COMMENT '项目2id',
`group_id` int DEFAULT 1,
`calc_group_id` int DEFAULT 1,
`fwd_group_id` varchar(64) DEFAULT NULL,
`fwd_group_id2` varchar(64) DEFAULT NULL,
`syn` bit(1) DEFAULT 0 COMMENT '是否已同步',
`pictures` varchar(100) DEFAULT NULL,
`ipose` double DEFAULT NULL COMMENT '初始位置东E',
`iposn` double DEFAULT NULL COMMENT '初始位置北N',
`iposd` double DEFAULT NULL COMMENT '初始位置天D',
`ecefx` double DEFAULT NULL COMMENT '初始位置X',
`ecefy` double DEFAULT NULL COMMENT '初始位置Y',
`ecefz` double DEFAULT NULL COMMENT '初始位置Z',
`sector` varchar(64) DEFAULT NULL COMMENT '桩号',
`appver` varchar(16) DEFAULT NULL COMMENT '固件版本',
`imei` varchar(16) DEFAULT NULL,
`model` smallint DEFAULT 0,
`loggingmode` smallint DEFAULT 0 COMMENT '日志模式: 0-精简模式(仅D3F0和D3F2), 1-完整模式',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `gnssgroup` (
`id` int NOT NULL,
`name` varchar(64) DEFAULT NULL,
`work_cycle` int DEFAULT 30,
`active_time` int DEFAULT 6,
`active_offset` int DEFAULT 0,
`rs_adv` smallint DEFAULT 0,
`power_mode` smallint DEFAULT 0,
`device_num` int DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `gnssgroupcalc` (
`id` int NOT NULL,
`name` varchar(64) DEFAULT NULL,
`filter_hour` int DEFAULT NULL COMMENT '水平平滑窗口',
`zfilter_hour` int DEFAULT NULL COMMENT '高程平滑窗口',
`xy_threshold` float DEFAULT NULL COMMENT '坏点水平门限',
`z_threshold` float DEFAULT NULL COMMENT '坏点垂直门限',
`adv_filter` bit(1) DEFAULT 0 COMMENT '增强坏点剔除',
`auto_filter` bit(1) DEFAULT 0,
`filter_min_hour` int DEFAULT NULL COMMENT '最小平滑窗口',
`auto_threshold` float DEFAULT NULL,
`ver` smallint DEFAULT 1 COMMENT '算法版本',
`device_num` int DEFAULT 0,
`auto_upload` bit(1) DEFAULT 0,
`remove_rate` smallint DEFAULT NULL COMMENT '固定解剔除比例',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `gnssgroupfwd` (
`id` int AUTO_INCREMENT,
`name` varchar(64) DEFAULT NULL,
`description` varchar(256) DEFAULT NULL,
`updatetime` datetime DEFAULT NULL,
`device_num` int DEFAULT 0,
`fwd_device_num` int DEFAULT 0,
`result` bit(1) DEFAULT 0 COMMENT '推送是否成功',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `gnssstatus` (
`id` bigint AUTO_INCREMENT,
`tenantid` int NOT NULL,
`updatetime` datetime DEFAULT NULL,
`devicetime` time DEFAULT NULL,
`deviceid` varchar(20) NOT NULL,
`location` varchar(100) DEFAULT NULL,
`roll` float DEFAULT 0,
`pitch` float DEFAULT 0,
`yaw` float DEFAULT 0,
`rssi` smallint DEFAULT 0,
`voltage` int DEFAULT 0,
`temperature` float DEFAULT 0,
`humidity` float DEFAULT 0,
`satelliteinuse` int DEFAULT 0,
`txbytes` int DEFAULT 0,
`rxbytes` int DEFAULT 0,
`b562bytes` int DEFAULT 0,
`d3xxbytes` int DEFAULT 0,
`state` smallint DEFAULT 0,
`warningcode` int DEFAULT 0,
`warning` smallint DEFAULT 0,
`noreslutcount` int DEFAULT 0,
`latitude` double DEFAULT NULL,
`longitude` double DEFAULT NULL,
`altitude` double DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `gnssdevicelocationrecords` (
`id` bigint AUTO_INCREMENT,
`tenantid` int NOT NULL,
`enabled` bit(1) DEFAULT NULL,
`createtime` datetime DEFAULT NULL,
`createuser` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
`updatetime` datetime DEFAULT NULL,
`updateuser` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
`deviceid` varchar(20) CHARACTER SET utf8 NOT NULL,
`b562e` double DEFAULT NULL COMMENT '原始北斗位置东E',
`b562n` double DEFAULT NULL COMMENT '原始北斗位置北N',
`b562d` double DEFAULT NULL COMMENT '原始北斗位置天D',
`r9250e` double DEFAULT NULL,
`r9250n` double DEFAULT NULL,
`r9250d` double DEFAULT NULL,
/*`m9250e` double DEFAULT NULL,
`m9250n` double DEFAULT NULL,
`m9250d` double DEFAULT NULL,*/
`rpose` double DEFAULT NULL COMMENT '相对位置东E',
`rposn` double DEFAULT NULL COMMENT '相对位置北N',
`rposd` double DEFAULT NULL COMMENT '相对位置天D',
`auxe` double DEFAULT NULL COMMENT '中间过程东E',
`auxn` double DEFAULT NULL COMMENT '中间过程北N',
`auxd` double DEFAULT NULL COMMENT '中间过程天D',
`pps` int DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `idx_deviceid_time` (`createtime` desc,`deviceid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
CREATE TABLE IF NOT EXISTS `gnssmsg` (
`id` bigint AUTO_INCREMENT,
`tenantid` int NOT NULL,
`createtime` datetime DEFAULT NULL,
`deviceid` varchar(20) NOT NULL,
`msgtype` int default 0,
`msglen` int default 0,
`tx` bit(1) DEFAULT 0,
`content` varchar(128) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `gnssstatusmsg` (
`id` bigint AUTO_INCREMENT,
`tenantid` int NOT NULL,
`createtime` datetime DEFAULT NULL,
`devicetime` time DEFAULT NULL,
`deviceid` varchar(20) NOT NULL,
`roll` float DEFAULT NULL,
`pitch` float DEFAULT NULL,
`yaw` float DEFAULT NULL,
`dtustate` smallint DEFAULT NULL,
`rssi` smallint DEFAULT NULL,
`voltage` int DEFAULT NULL,
`solarvoltage` int DEFAULT NULL,
`chargecurrency` int DEFAULT NULL,
`temperature` float DEFAULT NULL,
`humidity` float DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `gnsstrxmsg` (
`id` bigint AUTO_INCREMENT,
`tenantid` int NOT NULL,
`createtime` datetime DEFAULT NULL,
`devicetime` time DEFAULT NULL,
`deviceid` varchar(20) NOT NULL,
`uart1txbytes` int DEFAULT NULL,
`uart1rxbytes` int DEFAULT NULL,
`uart1unknown` int DEFAULT NULL,
`uart2txbytes` int DEFAULT NULL,
`uart2rxbytes` int DEFAULT NULL,
`uart2unknown` int DEFAULT NULL,
`b562bytes` int DEFAULT NULL,
`d3xxbytes` int DEFAULT NULL,
`b562count` int DEFAULT NULL,
`satelliteinuse` int DEFAULT 0,
`fixnum` int DEFAULT NULL,
`floatnum` int DEFAULT NULL,
`jumpcount` int DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `warninginfo` (
`id` bigint AUTO_INCREMENT,
`tenantid` int NOT NULL,
`createtime` datetime DEFAULT NULL,
`cleartime` datetime DEFAULT NULL,
`deviceid` varchar(20) NOT NULL,
`devicetype` smallint DEFAULT NULL,
`level` smallint DEFAULT NULL,
`code` int NOT NULL,
`info` varchar(128) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/***
北斗告警类型1电压低2RSSI低4掉线
0x10、终端收到未知报文多0x20,使用卫星数少0x40,基站d331少于d341; 0x80、测站b562比例少
*/
CREATE TABLE IF NOT EXISTS `warningcfg` (
`id` bigint AUTO_INCREMENT,
`devicetype` smallint NOT NULL,
`type` int NOT NULL,
`level` smallint DEFAULT 0,
`typename` varchar(50) NOT NULL,
`value` int NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/***
推送记录表根据补传指令填写补传数据的设备id、数据时间段
state状态值1准备传送2传送中3传送结束待推送0已推送
*/
CREATE TABLE IF NOT EXISTS `fwdrecords` (
`id` bigint AUTO_INCREMENT,
`tenantid` int NOT NULL,
`projectid` varchar(64) DEFAULT NULL COMMENT '项目id',
`devicenum` smallint NOT NULL,
`deviceid` varchar(20) DEFAULT NULL,
`createtime` datetime DEFAULT NULL,
`recordtime` datetime DEFAULT NULL,
`result` smallint DEFAULT 0,
`fwd_group_id` varchar(64) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `resendrecords` (
`id` bigint AUTO_INCREMENT,
`tenantid` int NOT NULL,
`projectid` varchar(64) DEFAULT NULL COMMENT '项目id',
`deviceid` varchar(20) DEFAULT NULL,
`createtime` datetime DEFAULT NULL,
`starttime` datetime DEFAULT NULL,
`endtime` datetime DEFAULT NULL,
`fwd_group_id` varchar(64) DEFAULT NULL,
`state` smallint DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/***
常用指令
*/
CREATE TABLE IF NOT EXISTS `devicecmd` (
`id` bigint AUTO_INCREMENT,
`name` varchar(80) NOT NULL,
`type` smallint NOT NULL,
`content` varchar(800) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/***
常用指令
*/
CREATE TABLE IF NOT EXISTS `cachecmd` (
`id` bigint AUTO_INCREMENT,
`updatetime` datetime DEFAULT NULL,
`deviceid` varchar(20) NOT NULL,
`syn` bit(1) DEFAULT 0 COMMENT '是否已同步',
`type` smallint NOT NULL,
`msgtype` int default 0,
`cmd` varchar(350) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/***
操作日志
*/
CREATE TABLE IF NOT EXISTS `OperationLog` (
`id` bigint AUTO_INCREMENT,
`user_name` varchar(20) NOT NULL,
`tenantid` int NOT NULL,
`op_time` timestamp(3) DEFAULT CURRENT_TIMESTAMP(3),
`op_type` smallint DEFAULT NULL,
`op_object` smallint DEFAULT NULL,
`content` varchar(256) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `ApiKey` (
`id` bigint(20) AUTO_INCREMENT,
`tenantid` int DEFAULT 0,
`apikey` varchar(64) NOT NULL,
`secret` varchar(256) NOT NULL,
`tenantname` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `gnssdevicesinglerecords` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`deviceid` varchar(64) NOT NULL COMMENT '设备ID',
`createtime` datetime(3) NOT NULL COMMENT '创建时间',
`model` smallint NOT NULL COMMENT '设备型号: 0-F9P(G505), 1-博通(G510)',
`x` double NOT NULL COMMENT 'GGA时是latitude, ECEF时是x',
`y` double NOT NULL COMMENT 'GGA时是longitude, ECEF时是y',
`z` double NOT NULL COMMENT 'GGA时是altitude, ECEF时是z',
`status` int NOT NULL DEFAULT '0' COMMENT 'GGA: 0初始化,1单点定位,2码差分,3无效PPS,4固定解,5浮点解,6估算,7人工固定,8模拟,9WAAS差分; ECEF: 0无B562,1浮点解,2固定解',
PRIMARY KEY (`id`),
KEY `idx_deviceid_createtime` (`deviceid`,`createtime`),
KEY `idx_createtime` (`createtime`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COMMENT='GNSS单次解算记录表';
CREATE TABLE IF NOT EXISTS `ehm` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`tenantid` int DEFAULT 0,
`deviceid` varchar(64) NOT NULL COMMENT '设备ID',
`createtime` datetime(3) NOT NULL COMMENT '创建时间',
`offlinestatdays` smallint DEFAULT NULL COMMENT '离线统计周期',
`offlinecount` int DEFAULT NULL COMMENT '离线统计周期内的离线次数',
`offlineminutes` int DEFAULT NULL COMMENT '离线统计周期内的离线时长',
`calcstathours` int DEFAULT NULL COMMENT '数据分析周期',
`stdeve` float DEFAULT NULL COMMENT '标准差',
`stdevn` float DEFAULT NULL COMMENT '标准差',
`stdevu` float DEFAULT NULL COMMENT '标准差',
`fixrate` float DEFAULT NULL COMMENT '固定率',
`validrate` float DEFAULT NULL COMMENT '有效解比例',
`jumpcount` int DEFAULT NULL COMMENT '周跳次数',
PRIMARY KEY (`id`),
KEY `idx_deviceid_createtime` (`deviceid`,`createtime`),
KEY `idx_createtime` (`createtime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `ehmconfig` (
`updatetime` datetime(3) NOT NULL COMMENT '更新时间',
`offlinestatdays` smallint DEFAULT NULL COMMENT '离线统计周期',
`calcstathours` int DEFAULT NULL COMMENT '数据分析周期',
PRIMARY KEY (`updatetime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;