/*
 Navicat Premium Data Transfer

 Source Server         : linux_testmysql
 Source Server Type    : MySQL
 Source Server Version : 50726
 Source Host           : 192.168.2.244:3306
 Source Schema         : cneeds_server

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

 Date: 18/03/2020 15:13:38
*/


-- ----------------------------
-- Table structure for device_info
-- 设备信息表
-- ----------------------------
DROP TABLE IF EXISTS `device_info`;
CREATE TABLE `device_info`  (
  `device_id` int  AUTO_INCREMENT PRIMARY KEY,
  `dept_id` int ,
  `imei` varchar  ,
  `iccid` varchar   ,
  `status` varchar   ,
  `device_version` varchar   ,
  `product_set` varchar   ,
  `create_time` datetime  ,
  `active_time` datetime ,
  `channel_nums` varchar ,
  `channel_nums_message` varchar,
  `channel_rules` int
);

-- ----------------------------
-- Table structure for device_log
-- 设备日志表
-- ----------------------------
DROP TABLE IF EXISTS `device_log`;
CREATE TABLE `device_log`  (
  `log_id` int PRIMARY KEY  AUTO_INCREMENT,
  `log_name` varchar   ,
  `create_time` datetime  ,
  `device_id` int  ,
  `status` int  ,
  `create_username` varchar ,
  `user_id` int ,
  `repetition_steps` varchar  ,
  `logfile_url` varchar   ,
  `logfile_size` int  ,
  `logfile_status` int  ,
  `log_accept_id` varchar
) ;

-- ----------------------------
-- Table structure for device_logmedia
-- 设备日志音频文件表
-- ----------------------------
DROP TABLE IF EXISTS `device_logmedia`;
CREATE TABLE `device_logmedia`  (
  `logmedia_id` int PRIMARY KEY   AUTO_INCREMENT,
  `location_url` varchar ,
  `log_id` int ,
  `type` varchar  ,
  `file_size` int
)  ;

-- ----------------------------
-- Table structure for device_logsetting
-- 暂时用不上，设备日志设置信息表
-- ----------------------------
DROP TABLE IF EXISTS `device_logsetting`;
CREATE TABLE `device_logsetting`  (
  `logsetting_id` int PRIMARY KEY  AUTO_INCREMENT,
  `log_size` int ,
  `device_id` int
)  ;

-- ----------------------------
-- Table structure for product_series
-- 设备产品系列表
-- ----------------------------
DROP TABLE IF EXISTS `product_series`;
CREATE TABLE `product_series`  (
  `series_id` int PRIMARY KEY   AUTO_INCREMENT,
  `series_num` varchar   ,
  `remark` varchar  ,
  `create_time` datetime
) ;

-- ----------------------------
-- Table structure for sys_dept
-- 系统-部门（客户）表
-- ----------------------------
DROP TABLE IF EXISTS `sys_dept`;
CREATE TABLE `sys_dept`  (
  `dept_id` int PRIMARY KEY  AUTO_INCREMENT,
  `parent_id` int ,
  `name` varchar   ,
  `del_flag` int ,
  `distributor_num` varchar   ,
  `remark` varchar
) ;

-- ----------------------------
-- Records of sys_dept
-- ----------------------------
INSERT INTO `sys_dept` VALUES (0, NULL, '根', 0, NULL, NULL);
INSERT INTO `sys_dept` VALUES (1, 0, '美行集团', 0, NULL, NULL);
INSERT INTO `sys_dept` VALUES (2, 1, '长沙分公司', 0, NULL, NULL);
INSERT INTO `sys_dept` VALUES (3, 1, '上海分公司', 0, NULL, NULL);
INSERT INTO `sys_dept` VALUES (4, 3, '技术部', 0, NULL, NULL);
INSERT INTO `sys_dept` VALUES (5, 3, '销售部', 0, NULL, NULL);

-- ----------------------------
-- Table structure for sys_func
-- 系统 - 功能表
-- ----------------------------
DROP TABLE IF EXISTS `sys_func`;
CREATE TABLE `sys_func`  (
  `func_id` int PRIMARY KEY   AUTO_INCREMENT,
  `parent_id` int ,
  `name` varchar  ,
  `url` varchar  ,
  `perms` varchar  ,
  `type` int ,
  `order_num` int 
)  ;

-- ----------------------------
-- Records of sys_func
-- ----------------------------
INSERT INTO `sys_func` VALUES (1, 0, '系统管理', NULL, NULL, 0, 0);
INSERT INTO `sys_func` VALUES (2, 1, '用户管理', 'modules/sys/user.html', NULL, 1, 1);
INSERT INTO `sys_func` VALUES (3, 1, '角色管理', 'modules/sys/role.html', NULL, 1, 2);
INSERT INTO `sys_func` VALUES (4, 1, '菜单管理', 'modules/sys/menu.html', NULL, 1, 3);
INSERT INTO `sys_func` VALUES (15, 2, '查看', NULL, 'sys:user:list,sys:user:info', 2, 0);
INSERT INTO `sys_func` VALUES (16, 2, '新增', NULL, 'sys:user:save,sys:role:select', 2, 0);
INSERT INTO `sys_func` VALUES (17, 2, '修改', NULL, 'sys:user:update,sys:role:select', 2, 0);
INSERT INTO `sys_func` VALUES (18, 2, '删除', NULL, 'sys:user:delete', 2, 0);
INSERT INTO `sys_func` VALUES (19, 3, '查看', NULL, 'sys:role:list,sys:role:info', 2, 0);
INSERT INTO `sys_func` VALUES (20, 3, '新增', NULL, 'sys:role:save,sys:menu:perms', 2, 0);
INSERT INTO `sys_func` VALUES (21, 3, '修改', NULL, 'sys:role:update,sys:menu:perms', 2, 0);
INSERT INTO `sys_func` VALUES (22, 3, '删除', NULL, 'sys:role:delete', 2, 0);
INSERT INTO `sys_func` VALUES (23, 4, '查看', NULL, 'sys:menu:list,sys:menu:info', 2, 0);
INSERT INTO `sys_func` VALUES (24, 4, '新增', NULL, 'sys:menu:save,sys:menu:select', 2, 0);
INSERT INTO `sys_func` VALUES (25, 4, '修改', NULL, 'sys:menu:update,sys:menu:select', 2, 0);
INSERT INTO `sys_func` VALUES (26, 4, '删除', NULL, 'sys:menu:delete', 2, 0);
INSERT INTO `sys_func` VALUES (31, 1, '部门管理', 'modules/sys/dept.html', NULL, 1, 1);
INSERT INTO `sys_func` VALUES (32, 31, '查看', NULL, 'sys:dept:list,sys:dept:info', 2, 0);
INSERT INTO `sys_func` VALUES (33, 31, '新增', NULL, 'sys:dept:save,sys:dept:select', 2, 0);
INSERT INTO `sys_func` VALUES (34, 31, '修改', NULL, 'sys:dept:update,sys:dept:select', 2, 0);
INSERT INTO `sys_func` VALUES (35, 31, '删除', NULL, 'sys:dept:delete', 2, 0);
INSERT INTO `sys_func`(`func_id`, `parent_id`, `name`, `url`, `perms`, `type`, `order_num`) VALUES (36, 1, '产品系列管理', NULL, 'configManagement:productSeries:list', 1, 1);
INSERT INTO `sys_func`(`func_id`, `parent_id`, `name`, `url`, `perms`, `type`, `order_num`) VALUES (37, 36, '添加产品系列', NULL, 'configManagement:productSeries:add', 2, 0);
INSERT INTO `sys_func`(`func_id`, `parent_id`, `name`, `url`, `perms`, `type`, `order_num`) VALUES (38, 36, '修改产品系列', NULL, 'configManagement:productSeries:edit', 2, 0);
INSERT INTO `sys_func`(`func_id`, `parent_id`, `name`, `url`, `perms`, `type`, `order_num`) VALUES (39, 1, '渠道号管理', NULL, 'configManagement:deviceChannel:list', 1, 2);
INSERT INTO `sys_func`(`func_id`, `parent_id`, `name`, `url`, `perms`, `type`, `order_num`) VALUES (40, 39, '添加渠道号', NULL, 'configManagement:deviceChannel:add', 2, 0);
INSERT INTO `sys_func`(`func_id`, `parent_id`, `name`, `url`, `perms`, `type`, `order_num`) VALUES (41, 39, '修改渠道号', NULL, 'configManagement:deviceChannel:edit', 2, 0);
INSERT INTO `sys_func`(`func_id`, `parent_id`, `name`, `url`, `perms`, `type`, `order_num`) VALUES (42, 1, '设备控制,设备渠道号统计', NULL, 'deviceManagement:device:list', 1, 1);
INSERT INTO `sys_func`(`func_id`, `parent_id`, `name`, `url`, `perms`, `type`, `order_num`) VALUES (43, 42, '导入设备', NULL, 'deviceManagement:device:add', 2, 0);
INSERT INTO `sys_func`(`func_id`, `parent_id`, `name`, `url`, `perms`, `type`, `order_num`) VALUES (44, 42, '变更产品系列,适配配置,批量配置', NULL, 'deviceManagement:device:edit', 2, 0);
INSERT INTO `sys_func`(`func_id`, `parent_id`, `name`, `url`, `perms`, `type`, `order_num`) VALUES (46, 1, '日志列表', NULL, 'remotelog:logfile:list', 1, 1);
INSERT INTO `sys_func`(`func_id`, `parent_id`, `name`, `url`, `perms`, `type`, `order_num`) VALUES (47, 36, '删除产品系列', NULL, 'configManagement:productSeries:delete', 2, 0);
INSERT INTO `sys_func`(`func_id`, `parent_id`, `name`, `url`, `perms`, `type`, `order_num`) VALUES (48, 42, '删除设备', NULL, 'deviceManagement:device:delete', 2, 0);
INSERT INTO `sys_func`(`func_id`, `parent_id`, `name`, `url`, `perms`, `type`, `order_num`) VALUES (49, 39, '删除渠道号', NULL, 'configManagement:deviceChannel:delete', 2, 0);
INSERT INTO `sys_func`(`func_id`, `parent_id`, `name`, `url`, `perms`, `type`, `order_num`) VALUES (50, 46, '修改日志', NULL, 'remotelog:logfile:edit', 2, 0);
INSERT INTO `sys_func`(`func_id`, `parent_id`, `name`, `url`, `perms`, `type`, `order_num`) VALUES (51, 46, '删除日志', NULL, 'remotelog:logfile:delete', 2, 0);

-- ----------------------------
-- Table structure for sys_role
-- 系统 - 角色表
-- ----------------------------
DROP TABLE IF EXISTS `sys_role`;
CREATE TABLE `sys_role`  (
  `role_id` int PRIMARY KEY   AUTO_INCREMENT,
  `role_name` varchar   ,
  `remark` varchar  ,
  `dept_id` int ,
  `create_time` datetime
)  ;

-- ----------------------------
-- Records of sys_role
-- ----------------------------
INSERT INTO `sys_role` VALUES (1, '管理员', '描述', 1, '2020-03-10 12:06:37');
INSERT INTO `sys_role` VALUES (26, 'zzzzzzzzzz', 'zzzzzzzzzzzzzzz', 0, '2020-03-13 04:51:20');

-- ----------------------------
-- Table structure for sys_role_dept
-- 系统 - 角色部门关系表
-- ----------------------------
DROP TABLE IF EXISTS `sys_role_dept`;
CREATE TABLE `sys_role_dept`  (
  `id` int PRIMARY KEY   AUTO_INCREMENT,
  `role_id` int ,
  `dept_id` int
)  ;

-- ----------------------------
-- Records of sys_role_dept
-- ----------------------------
INSERT INTO `sys_role_dept` VALUES (463, 26, 3);
INSERT INTO `sys_role_dept` VALUES (464, 26, 4);
INSERT INTO `sys_role_dept` VALUES (465, 26, 5);

-- ----------------------------
-- Table structure for sys_role_func
-- 系统 - 角色功能表 
-- ----------------------------
DROP TABLE IF EXISTS `sys_role_func`;
CREATE TABLE `sys_role_func`  (
  `id` int PRIMARY KEY  AUTO_INCREMENT,
  `role_id` int  ,
  `func_id` int
)  ;

-- ----------------------------
-- Records of sys_role_func
-- ----------------------------
INSERT INTO `sys_role_func` VALUES (484, 26, 2);
INSERT INTO `sys_role_func` VALUES (485, 26, 15);
INSERT INTO `sys_role_func` VALUES (486, 26, 16);
INSERT INTO `sys_role_func` VALUES (487, 26, 17);
INSERT INTO `sys_role_func` VALUES (488, 26, 18);

-- ----------------------------
-- Table structure for sys_user
-- 系统 - 用户（账户）表
-- ----------------------------
DROP TABLE IF EXISTS `sys_user`;
CREATE TABLE `sys_user`  (
  `user_id` int PRIMARY KEY  AUTO_INCREMENT,
  `username` varchar  ,
  `password` varchar  ,
  `email` varchar   ,
  `remark` varchar   ,
  `mobile` varchar  ,
  `status` int  ,
  `create_time` datetime ,
  `dept_id` int
)  COMMENT = '用户信息表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of sys_user
-- ----------------------------
INSERT INTO `sys_user` VALUES (0, 'admin', '$2a$10$/uKcZ27sVZSWRRzSx9PEQ.ggLriOfc6AqILEyOYauVQQt5akh4YEm', 'YzcmCZNvbXocrsz9dm8e', 'root@cneeds.com.cn', '13612345678', 1, '2016-11-11', 0);

-- ----------------------------
-- Table structure for sys_user_role
-- 系统 - 用户角色关系表
-- ----------------------------
DROP TABLE IF EXISTS `sys_user_role`;
CREATE TABLE `sys_user_role`  (
  `id` int PRIMARY KEY  AUTO_INCREMENT,
  `user_id` int  ,
  `role_id` int
) ;

SET FOREIGN_KEY_CHECKS = 1;


-- ----------------------------
-- Table structure for sys_user_dept
-- 系统 - 用户部门关系表
-- ----------------------------
DROP TABLE IF EXISTS `sys_user_dept`;
CREATE TABLE `sys_user_dept`  (
  `id` int  AUTO_INCREMENT PRIMARY KEY,
  `user_id` int ,
  `dept_id` int
)  ;


-- ----------------------------
-- Table structure for sys_user_func
-- 系统 - 用户功能关系表
-- ----------------------------
DROP TABLE IF EXISTS `sys_user_func`;
CREATE TABLE `sys_user_func`  (
  `id` int  AUTO_INCREMENT PRIMARY KEY ,
  `user_id` int  ,
  `func_id` int
)  ;




-- 202-05-09
-- ----------------------------
-- Table structure for device_channel
-- 渠道号表
-- ----------------------------
DROP TABLE IF EXISTS `device_channel`;
CREATE TABLE `device_channel` (
  `channel_id` int PRIMARY KEY  AUTO_INCREMENT,
  `channel_num` varchar ,
  `brand` varchar ,
  `update_time` datetime
)  ;

-- ----------------------------
-- Table structure for device_info_channel
-- 设备信息 - 渠道号 映射表
-- ----------------------------
DROP TABLE IF EXISTS `device_info_channel`;
CREATE TABLE `device_info_channel` (
  `id` int PRIMARY KEY  AUTO_INCREMENT,
  `device_id` int ,
  `channel_id` int 
)  ;

-- 2020-05-13
ALTER TABLE `device_info`
DROP COLUMN `channel_nums`;

-- 2020-05-14
ALTER TABLE `device_log`
ADD COLUMN `device_version` varchar  ;


-- 2020-06-29

ALTER TABLE `device_info`
ADD COLUMN `sn` varchar ;

ALTER TABLE `device_info`
ADD COLUMN `ca_certificate_status` varchar  ;

ALTER TABLE `device_info`
CHANGE COLUMN `status` `active_status` varchar ;

-- 2020-07-14

ALTER TABLE `device_info`
MODIFY COLUMN `active_status` varchar  ;
ALTER TABLE `device_info`
MODIFY COLUMN `channel_rules` int  ;
ALTER TABLE `device_info`
MODIFY COLUMN `ca_certificate_status` varchar  ;

-- 2020-07-27
DROP TABLE IF EXISTS `device_info_export`;
CREATE TABLE `device_info_export` (
  `device_info_export_id` int PRIMARY KEY  AUTO_INCREMENT ,
  `name` varchar  ,
  `filepath` varchar  ,
  `status` int(10)  ,
  `update_time` datetime
) ;


-- 2020-07-31
ALTER TABLE `device_info`
ADD COLUMN `update_time` datetime ;