/*
 Navicat Premium Data Transfer

 Source Server         : 腾讯云mysql-remote
 Source Server Type    : MySQL
 Source Server Version : 50734
 Source Host           : 82.156.76.30:3306
 Source Schema         : ailink123

 Target Server Type    : MySQL
 Target Server Version : 50734
 File Encoding         : 65001

 Date: 26/08/2021 17:27:58
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for body_fat
-- ----------------------------
DROP TABLE IF EXISTS `body_fat`;
CREATE TABLE `body_fat` (
  `body_fat_id` int(11) NOT NULL AUTO_INCREMENT,
  `app_user_id` int(11) DEFAULT NULL,
  `sub_user_id` int(11) DEFAULT NULL,
  `device_id` int(11) DEFAULT NULL,
  `weight` varchar(10) DEFAULT NULL,
  `weight_unit` varchar(10) DEFAULT NULL,
  `weight_point` varchar(10) DEFAULT NULL,
  `bmi` varchar(10) DEFAULT NULL,
  `bfr` varchar(10) DEFAULT NULL,
  `sfr` varchar(10) DEFAULT NULL,
  `uvi` varchar(10) DEFAULT NULL,
  `rom` varchar(10) DEFAULT NULL,
  `bmr` varchar(10) DEFAULT NULL,
  `bm` varchar(10) DEFAULT NULL,
  `vwc` varchar(10) DEFAULT NULL,
  `body_age` varchar(10) DEFAULT NULL,
  `pp` varchar(10) DEFAULT NULL,
  `adc` varchar(10) DEFAULT NULL,
  `create_time` bigint(20) DEFAULT NULL,
  `upload_time` datetime DEFAULT NULL,
  `heart_rate` varchar(255) DEFAULT NULL COMMENT '心跳',
  `deviceAlgorithm` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '算法',
  `dataModel` int(11) DEFAULT NULL COMMENT '数据模式：0/空：普通人；1：运动员；2：孕妇',
  `standardWeight` varchar(255) DEFAULT NULL,
  `weightControl` varchar(255) DEFAULT NULL,
  `fatMass` varchar(255) DEFAULT NULL,
  `weightWithoutFat` varchar(255) DEFAULT NULL,
  `musleMass` varchar(255) DEFAULT NULL,
  `proteinMass` varchar(255) DEFAULT NULL,
  `fatLevel` varchar(255) DEFAULT NULL,
  `dataMode` varchar(255) DEFAULT NULL,
  `dataFrom` varchar(255) DEFAULT NULL,
  `remark` varchar(255) DEFAULT NULL,
  `fatMassRightTop` varchar(255) DEFAULT NULL COMMENT '右上脂肪量',
  `fatMassRightBottom` varchar(255) DEFAULT NULL COMMENT '右下脂肪量',
  `fatMassLeftTop` varchar(255) DEFAULT NULL COMMENT '左上脂肪量',
  `fatMassLeftBottom` varchar(255) DEFAULT NULL COMMENT '左下脂肪量',
  `fatMassBody` varchar(255) DEFAULT NULL COMMENT '躯干脂肪量',
  `musleMassRightTop` varchar(255) DEFAULT NULL COMMENT '右上肌肉量',
  `musleMassRightBottom` varchar(255) DEFAULT NULL COMMENT '右下肌肉量',
  `musleMassLeftTop` varchar(255) DEFAULT NULL COMMENT '左上肌肉量',
  `musleMassLeftBottom` varchar(255) DEFAULT NULL COMMENT '左下肌肉量',
  `musleMassBody` varchar(255) DEFAULT NULL COMMENT '躯干肌肉量',
  `musleMassLimbs` varchar(255) DEFAULT NULL COMMENT '四肢肌肉指数',
  `calculationTimes` int(1) DEFAULT NULL COMMENT '计算次数',
  `source` int(1) DEFAULT NULL COMMENT '数据来源；1：WIFI/4G秤',
  `height` varchar(10) DEFAULT NULL COMMENT '身高',
  `height_unit` varchar(10) DEFAULT NULL COMMENT '身高单位',
  `height_point` varchar(10) DEFAULT NULL COMMENT '身高小数点',
  `workModel` int(2) DEFAULT NULL COMMENT '工作模式',
  `bodyType` int(2) DEFAULT NULL COMMENT '身体类型',
  `bodyScore` int(3) DEFAULT NULL COMMENT '身体评分',
  `dataDisplay` int(2) DEFAULT NULL COMMENT '数据展示方式',
  PRIMARY KEY (`body_fat_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=41974 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Table structure for device
-- ----------------------------
DROP TABLE IF EXISTS `device`;
CREATE TABLE `device` (
  `device_id` int(11) NOT NULL AUTO_INCREMENT,
  `room_id` int(11) DEFAULT NULL,
  `device_name` varchar(500) DEFAULT NULL,
  `mac` varchar(500) DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  `cid` int(11) DEFAULT NULL,
  `pid` int(11) DEFAULT NULL,
  `vid` int(11) DEFAULT NULL,
  `support_unit` varchar(500) DEFAULT NULL,
  `version` varchar(50) DEFAULT NULL COMMENT '设备软件版本',
  `hardwareVersion` varchar(255) DEFAULT NULL COMMENT '设备硬件版本',
  `userAutoVersion` varchar(255) DEFAULT NULL COMMENT '用户自定义版本',
  `deviceTime` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '设备时间',
  `deviceModel` varchar(255) DEFAULT NULL COMMENT '设备型号',
  `chipId` varchar(255) DEFAULT NULL COMMENT '芯片id',
  `appUserId` int(11) DEFAULT NULL,
  `deviceSN` varchar(255) DEFAULT NULL COMMENT '设备SN号',
  `deviceUnit` varchar(255) DEFAULT NULL COMMENT '设备单位',
  `imei` varchar(255) DEFAULT NULL COMMENT '设备IMEI字段 app端维护',
  `wifi_name` varchar(255) DEFAULT NULL COMMENT 'Wifi名称字段 app端维护',
  PRIMARY KEY (`device_id`) USING BTREE,
  KEY `FK_appUserId` (`appUserId`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=20790 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Procedure structure for updBt
-- ----------------------------
DROP PROCEDURE IF EXISTS `updBt`;
delimiter ;;
CREATE PROCEDURE `updBt`()
BEGIN
	UPDATE tt_bluetooth_info SET 
	appName = appName,
	appVersion = appVersion,
	phoneType = phoneType,
	phoneVersion = phoneVersion,
	phoneLanguage = phoneLanguage,
	btVersion = btVersion,
	btName = btName,
	isCheck = isCheck,
	lastConnection = lastConnection,
	connectionCount = connectionCount+1,
	vid = vid,
	cid = cid,
	pid = pid,
	packageName = packageName,
	userId = userId,
	userName = userName
	WHERE userId = userId AND btMacAddress = btMacAddress; 
    END
;;
delimiter ;

SET FOREIGN_KEY_CHECKS = 1;
