402 lines
15 KiB
SQL
402 lines
15 KiB
SQL
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-完整模式',
|
||
`iccid` VARCHAR(36) DEFAULT NULL COMMENT 'ICCID号,唯一',
|
||
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,
|
||
`gnss_sample_s` smallint DEFAULT 1,
|
||
`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,
|
||
`stabled` bit(1) 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,
|
||
`chargewatt` float 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,电压低;2,RSSI低;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,
|
||
`unitname` varchar(32) 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,
|
||
`sort` int DEFAULT 0,
|
||
PRIMARY KEY (`id`),
|
||
KEY `idx_devicecmd_sort` (`sort`)
|
||
) 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;
|
||
|
||
/***
|
||
GNSS 单次解记录表
|
||
*/
|
||
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 `traffic_cards` (
|
||
`id` INT NOT NULL AUTO_INCREMENT COMMENT '主键,自增,唯一',
|
||
`iccid` VARCHAR(20) NOT NULL COMMENT 'ICCID号,唯一标识SIM卡',
|
||
`msisdn` VARCHAR(20) NOT NULL COMMENT '物联卡号码',
|
||
`status` INT DEFAULT -1 COMMENT 'SIM卡状态(-1:未知, 1:待激活, 2:已激活, 3:停机, 4:注销, 5:库存, 6:可测试, 7:失效, 99:号码不存在)',
|
||
`remaining` INT DEFAULT 0 COMMENT '剩余流量,单位MB,为避免小数,存储值为实际值的1000倍',
|
||
`total` INT DEFAULT 0 COMMENT '总流量,单位MB,同上',
|
||
`used` INT DEFAULT 0 COMMENT '已用流量,单位MB,同上',
|
||
`updatetime` DATETIME DEFAULT NULL COMMENT '最后更新时间',
|
||
`querystatus` TINYINT DEFAULT 0 COMMENT 'SIM卡查询状态:0=正常,1=非当前卡商,2=其他错误',
|
||
PRIMARY KEY (`id`),
|
||
UNIQUE KEY `uk_iccid` (`iccid`),
|
||
INDEX `idx_status` (`status`),
|
||
INDEX `idx_querystatus` (`querystatus`)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='流量卡信息表';
|
||
|
||
/***
|
||
设备-SIM卡映射表
|
||
*/
|
||
CREATE TABLE IF NOT EXISTS `traffic_device_mappings` (
|
||
`id` INT NOT NULL AUTO_INCREMENT COMMENT '主键,自增,唯一',
|
||
`deviceid` VARCHAR(20) NOT NULL COMMENT '设备ID',
|
||
`iccid` VARCHAR(20) NOT NULL COMMENT 'SIM卡ICCID',
|
||
`starttime` DATETIME NOT NULL COMMENT '开始使用时间',
|
||
`endtime` DATETIME DEFAULT NULL COMMENT '结束使用时间,NULL表示当前正在使用',
|
||
PRIMARY KEY (`id`),
|
||
KEY `idx_deviceid` (`deviceid`),
|
||
KEY `idx_iccid` (`iccid`),
|
||
KEY `idx_starttime` (`starttime`)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='设备-SIM卡映射表';
|
||
|
||
/***
|
||
流量使用记录表
|
||
*/
|
||
CREATE TABLE IF NOT EXISTS `traffic_records` (
|
||
`id` INT NOT NULL AUTO_INCREMENT COMMENT '主键,自增,唯一',
|
||
`iccid` VARCHAR(20) NOT NULL COMMENT 'SIM卡ICCID',
|
||
`recordtime` DATETIME NOT NULL COMMENT '记录时间',
|
||
`remaining` INT DEFAULT NULL COMMENT '剩余流量,单位MB,为避免小数,存储值为实际值的1000倍',
|
||
`used` INT DEFAULT NULL COMMENT '已用流量MB',
|
||
`total` INT DEFAULT NULL COMMENT '总流量MB',
|
||
PRIMARY KEY (`id`),
|
||
KEY `idx_iccid` (`iccid`),
|
||
KEY `idx_recordtime` (`recordtime`)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='流量使用记录表';
|