/*
 Navicat Premium Data Transfer

 Source Server         : 47.116.173.119
 Source Server Type    : MySQL
 Source Server Version : 80401
 Source Host           : 47.116.173.119:3306
 Source Schema         : saas_operation

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

 Date: 30/09/2024 10:21:52
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for sys_car
-- ----------------------------
DROP TABLE IF EXISTS `sys_car`;
CREATE TABLE `sys_car`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '自增主键',
  `car_vin` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '车辆VIN码',
  `car_plate` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '车辆车牌号',
  `car_brand` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '车辆品牌',
  `car_model` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '车辆型号',
  `car_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '车辆车型(如客车,卡车,公交车等)',
  `car_last_join_time` datetime NULL DEFAULT NULL COMMENT '最后一次连线时间',
  `car_last_offline_time` datetime NULL DEFAULT NULL COMMENT '最后一次离线时间',
  `state` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '2' COMMENT '启用状态(1.在线 2.离线 3.已断开 4.待连接 5.维修中',
  `create_by` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` int NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '车辆基础信息表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for sys_car_details
-- ----------------------------
DROP TABLE IF EXISTS `sys_car_details`;
CREATE TABLE `sys_car_details`  (
  `id` int NOT NULL COMMENT '车辆ID',
  `car_vin` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '车辆VIN码',
  `car_motor_manufacturer` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '车辆电机厂商',
  `car_motor_model` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '电机型号',
  `car_battery_manufacturer` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '车辆电池厂商',
  `car_battery_model` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '电池型号',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '车辆详细信息表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for sys_car_fault
-- ----------------------------
DROP TABLE IF EXISTS `sys_car_fault`;
CREATE TABLE `sys_car_fault`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '自增主键',
  `fault_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '车辆故障编码',
  `fault_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '车辆故障类型',
  `fault_label` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '车辆故障标签',
  `fault_bit` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '车辆故障位',
  `fault_value` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '车辆故障值',
  `fault_warn` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '故障等级',
  `fault_status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '报警状态（Y.是，N.否）',
  `create_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '车辆故障表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for sys_car_message
-- ----------------------------
DROP TABLE IF EXISTS `sys_car_message`;
CREATE TABLE `sys_car_message`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '自增主键',
  `model_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '车辆型号编码',
  `message_type_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '车辆报文类型编码',
  `message_start_index` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '开始位下标',
  `message_end_index` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '结束位下标',
  `message_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '报文分类',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 61 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '车辆报文记录表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for sys_corpuscle_fence
-- ----------------------------
DROP TABLE IF EXISTS `sys_corpuscle_fence`;
CREATE TABLE `sys_corpuscle_fence`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '自增主键',
  `fence_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '围栏编码',
  `fence_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '围栏名称',
  `fence_type` int NOT NULL DEFAULT 1 COMMENT '围栏类型(1.驶入 2.驶出)',
  `fence_position` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '围栏位置',
  `state` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '1' COMMENT '启用状态(1.启用 2.停用)',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '电子围栏表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for sys_ent
-- ----------------------------
DROP TABLE IF EXISTS `sys_ent`;
CREATE TABLE `sys_ent`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `ent_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '企业编码',
  `ip` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '企业数据库IP',
  `port` int NULL DEFAULT NULL COMMENT '数据库端口',
  `db_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '连接数据库名称',
  `user_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '用户名',
  `password` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '密码',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '企业数据库信息记录表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for sys_fence_group
-- ----------------------------
DROP TABLE IF EXISTS `sys_fence_group`;
CREATE TABLE `sys_fence_group`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '自增主键',
  `group_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '围栏组编码',
  `group_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '围栏组名称',
  `group_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '围栏组类型',
  `state` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '启用状态',
  `create_by` int NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` int NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '围栏组表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for sys_fence_group_mid
-- ----------------------------
DROP TABLE IF EXISTS `sys_fence_group_mid`;
CREATE TABLE `sys_fence_group_mid`  (
  `group_id` int NOT NULL COMMENT '围栏组id',
  `fence_id` int NOT NULL COMMENT '围栏id',
  `new_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`group_id`, `fence_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '围栏组连接表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for sys_firm
-- ----------------------------
DROP TABLE IF EXISTS `sys_firm`;
CREATE TABLE `sys_firm`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '自增主键',
  `firm_credit_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '统一社会信用代码',
  `firm_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '企业编码',
  `firm_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '企业名称',
  `firm_logs` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '企业logs',
  `state` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '1' COMMENT '启用状态(1.开业 2.停业 3.休业)',
  `create_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '企业基础信息表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for sys_message_type
-- ----------------------------
DROP TABLE IF EXISTS `sys_message_type`;
CREATE TABLE `sys_message_type`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '自增主键',
  `message_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '报文编码',
  `message_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '报文名称',
  `message_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '报文分类',
  `message_class` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '报文字段类型',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 47 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '车辆报文类型表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for warn_logs
-- ----------------------------
DROP TABLE IF EXISTS `warn_logs`;
CREATE TABLE `warn_logs`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '预警日志id',
  `vin` varchar(58) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '车辆vin码',
  `warn_rule_id` int NULL DEFAULT NULL COMMENT '规则id',
  `start_time` datetime NULL DEFAULT NULL COMMENT '开始时间',
  `end_time` datetime NULL DEFAULT NULL COMMENT '结束时间',
  `max_value` int NULL DEFAULT NULL COMMENT '最大值',
  `min_value` int NULL DEFAULT NULL COMMENT '最小值',
  `avg_value` int NULL DEFAULT NULL COMMENT '平均值',
  `median_value` int NULL DEFAULT NULL COMMENT '中位数',
  `status` int NULL DEFAULT NULL COMMENT '是否发送预警',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for warn_rule
-- ----------------------------
DROP TABLE IF EXISTS `warn_rule`;
CREATE TABLE `warn_rule`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '规则id',
  `rule_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规则名称',
  `strategy_id` int NULL DEFAULT NULL COMMENT '策略id',
  `msg_type_id` int NULL DEFAULT NULL COMMENT '报文数据类型id',
  `slide_time` int NULL DEFAULT NULL COMMENT '滑窗时间',
  `slide_frequency` int NULL DEFAULT NULL COMMENT '滑窗频率',
  `max_value` int NULL DEFAULT NULL COMMENT '最大值',
  `min_value` int NULL DEFAULT NULL COMMENT '最小值',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for warn_slide_config
-- ----------------------------
DROP TABLE IF EXISTS `warn_slide_config`;
CREATE TABLE `warn_slide_config`  (
  `id` int NOT NULL COMMENT '滑窗id',
  `vin` varchar(38) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '车辆vin码',
  `slide_time` int NULL DEFAULT NULL COMMENT '滑动时间',
  `created_by` int NULL DEFAULT NULL COMMENT '创建人',
  `created_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
  `updated_by` int NULL DEFAULT NULL COMMENT '更新人',
  `updated_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for warn_strategy
-- ----------------------------
DROP TABLE IF EXISTS `warn_strategy`;
CREATE TABLE `warn_strategy`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '策略id',
  `car_type_id` int NULL DEFAULT NULL COMMENT '车辆类型id',
  `strategy_name` varchar(38) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '策略名称',
  `msg_id` int NULL DEFAULT NULL COMMENT '报文模版id',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

SET FOREIGN_KEY_CHECKS = 1;
