车辆档案管理

用到的原来的表:

vsp_vehicle_brand 车辆品牌

vsp_vehicle_model_parent 车辆型号

vsp_vehicle_model 派生

CREATE TABLE `vsp_vehicle_brand` (
  `id` bigint(8) NOT NULL AUTO_INCREMENT,
  `brand_code` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '品牌编码',
  `brand_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  `create_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP,
  `update_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP,
  `is_deleted` tinyint(1) unsigned DEFAULT '0' COMMENT '1表示删除, 0表示未删除',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=44 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
CREATE TABLE `vsp_vehicle_model` (
  `id` bigint(8) unsigned NOT NULL AUTO_INCREMENT,
  `vehicle_model` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '车辆型号',
  `model_code` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '编码',
  `model_parent_id` bigint(8) DEFAULT NULL COMMENT '车辆型号',
  `create_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP,
  `update_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP,
  `is_deleted` tinyint(1) unsigned DEFAULT '0' COMMENT '1表示删除, 0表示未删除',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=98 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;


CREATE TABLE `vsp_vehicle_model_parent` (
  `id` bigint(8) NOT NULL AUTO_INCREMENT,
  `brand_id` bigint(8) DEFAULT NULL COMMENT '车辆品牌',
  `model_code` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '车型编码',
  `model_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '杞﹁締鍨嬪彿',
  `create_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP,
  `update_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP,
  `is_deleted` tinyint(1) unsigned DEFAULT '0' COMMENT '1表示删除, 0表示未删除',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=75 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

车辆表:

CREATE TABLE `vsp_vehicle_information` (
  `id` bigint(8) unsigned NOT NULL AUTO_INCREMENT,
  `vin` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '车架号VIN',
  `plate` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '车牌号',
  `tcu_sn` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'TCU_设备号',
  `tsu_sn` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'TSU_设备号',
  `model_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '车型',
  `factory_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '车厂',
  `create_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP,
  `update_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP,
  `is_deleted` tinyint(1) unsigned DEFAULT '0' COMMENT '1表示删除, 0表示未删除',
  `sae_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '车上的SAE编码',
  `version_id` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `area_id` bigint(8) DEFAULT NULL COMMENT '区域id',
  `owner_phone` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '车主手机号',
  `owner_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '车主姓名',
  `device_id` bigint(8) DEFAULT NULL COMMENT '设备id',
  `dealer_id` bigint(8) DEFAULT NULL COMMENT '经销商id',
  PRIMARY KEY (`id`),
  UNIQUE KEY `vin` (`vin`),
  UNIQUE KEY `vin_2` (`vin`)
) ENGINE=InnoDB AUTO_INCREMENT=259 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

服务器部署数据库:

vsp  测试环境
vsp_pre:集成环境
阿里云地址:rm-2zedohhc71x76y1ti12509

dbname: vsp
    username: vsp
    password: NsrVsp2019

新增表:

车辆基础信息表:archives_car_baseinfo

alibaba java开发手册在线版:

https://kangroo.gitee.io/ajcg/#/?id=%e5%89%8d%e8%a8%80

mysql创建表为表增加必备字段语句(更新时xxx替换为自己的表):

ALTER TABLE xxx ADD COLUMN `creater` VARCHAR(255) DEFAULT NULL COMMENT '创建人';
ALTER TABLE xxx ADD COLUMN `create_time` datetime DEFAULT NULL COMMENT '创建时间';
ALTER TABLE xxx ADD COLUMN `updater` VARCHAR(255) DEFAULT NULL COMMENT '更新人';
ALTER TABLE xxx ADD COLUMN `update_time` datetime DEFAULT NULL COMMENT '更新时间';
ALTER TABLE xxx ADD COLUMN `is_deleted` datetime DEFAULT NULL COMMENT '1表示删除,0表示未删除';

车辆扩展信息表:archives_car_extendinfo

车辆信息导入中间表:archives_car_extendinfo_import

CREATE TABLE `archives_car_extendinfo_import` (
  `id` bigint(8) NOT NULL AUTO_INCREMENT,
  `derive_code` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `vin` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `color` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `tsu_device_model` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `tsu_part_model` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `tsu_serial_number` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `iccid` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `sim` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `tsu_hard_version` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `tsu_soft_version` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `da_device_model` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `da_part_model` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `da_serial_model` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `da_hard_version` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `da_soft_version` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
     `batch_number` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
     `import_fail_reason` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `creater` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '鍒涘缓鏃堕棿',
  `updater` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `is_deleted` datetime DEFAULT NULL COMMENT '1表示删除,0表示未删除',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

销售信息表:archives_sale_info

CREATE TABLE `archives_sale_info` (
  `id` bigint(8) NOT NULL,
  `vin` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `city_code` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `sell_code` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `sell_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `sell_address` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `sell_phone` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `sell_fax` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `salesperson_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `salesperson_phone` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `user_type` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `user_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `user_phone` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `user_id_card_no` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `plate` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `service_start_time` datetime DEFAULT NULL,
  `service_end_time` datetime DEFAULT NULL,
  `creater` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `updater` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `is_deleted` tinyint(4) DEFAULT NULL COMMENT '1琛ㄧず鍒犻櫎锛?琛ㄧず鏈垹闄?',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

销售信息中间表:archives_sale_info_import

CREATE TABLE `archives_sale_info_import` (
  `id` bigint(8) NOT NULL,
  `vin` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `city_code` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `sell_code` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `sell_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `sell_address` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `sell_phone` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `sell_fax` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `salesperson_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `salesperson_phone` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `user_type` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `user_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `user_phone` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `user_id_card_no` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `plate` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `service_start_time` datetime DEFAULT NULL,
  `service_end_time` datetime DEFAULT NULL,
    `batch_number` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
     `import_fail_reason` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `creater` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `updater` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `is_deleted` tinyint(4) DEFAULT NULL COMMENT '1琛ㄧず鍒犻櫎锛?琛ㄧず鏈垹闄?',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

城市表:archives_city

全国地区代码表:

http://www.ccb.com/cn/OtherResource/bankroll/html/code_help.html

CREATE TABLE `archives_city` (
  `id` bigint(8) NOT NULL,
  `city_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `city_code` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `creater` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `updater` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `is_deleted` tinyint(4) DEFAULT NULL COMMENT '1琛ㄧず鍒犻櫎锛?琛ㄧず鏈垹闄?',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

insert语句:

e x c e l 转 i n s e r t , 在 数 据 中 间 插 入 列 写 入 特 殊 字 符 , 直 接 替 换 特 殊 字 符 , 这 样 就 不 用 读 取 e x c e l 了 。 \color{#FF0000}{excel转insert,在数据中间插入列写入特殊字符,直接替换特殊字符,这样就不用读取excel了。} excelinsert,excel

INSERT INTO t1(field1,field2) VALUE(v001,v002);

INSERT INTO archives_city(city_name,city_code,creater,create_time,updater,update_time,is_deleted) VALUES (‘1’, ‘1’, ‘1’, ‘2020-08-03 14:39:51’, ‘1’, ‘2020-08-03 14:39:54’, ‘0’);

截取部分数据:

INSERT INTO `archives_city`(city_name,city_code,creater,create_time,updater,update_time,is_deleted)  VALUES ('天津市', '', '1', '2020-08-03 14:39:51', '1', '2020-08-03 14:39:54', '0');
INSERT INTO `archives_city`(city_name,city_code,creater,create_time,updater,update_time,is_deleted)  VALUES ('地区代码', '地区名称', '1', '2020-08-03 14:39:51', '1', '2020-08-03 14:39:54', '0');

查询省份:

select * from archives_city where city_code = ‘’;

用户操作记录表:archives_user

CREATE TABLE `archives_user` (
  `id` bigint(8) NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `phone` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `id_card_no` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `status` tinyint(4) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '1正常 0失效',
  `creater` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `updater` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `is_deleted` tinyint(4) DEFAULT NULL COMMENT '1琛ㄧず鍒犻櫎锛?琛ㄧず鏈垹闄?',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

20200804 ( 城 市 编 码 表 ) \color{#FF0000}{20200804(城市编码表)} 20200804()

CREATE TABLE `archives_city` (
  `id` bigint(8) NOT NULL,
  `city_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `district_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `city_code` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `creater` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `updater` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `is_deleted` tinyint(4) DEFAULT NULL COMMENT '1琛ㄧず鍒犻櫎锛?琛ㄧず鏈垹闄?',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

20200804 ( 为 表 设 置 自 动 递 增 ) \color{#FF0000}{20200804(为表设置自动递增)} 20200804()

ALTER TABLE `archives_city`
MODIFY COLUMN `id`  bigint(8) NOT NULL AUTO_INCREMENT FIRST ;
INSERT INTO `archives_city`(`city_name`,`district_name`,`city_code`,`creater`,`create_time`, `updater`, `update_time`, `is_deleted`) VALUES ('北京市', '朝阳区', '城市编码', '1', '2020-08-04 09:46:25', '1', '2020-08-04 09:46:28', '0');
select * from archives_city where district_name = '' and city_name = '';
update archives_city set city_name = '北京' where city_code = '110000' and city_name = '' and district_name = '';
update archives_city set city_name = '北京' where city_code = '110000';
update archives_city set city_name = '天津' where city_code = '120000';
update archives_city set city_name = '河北省' where city_code = '130000';
update archives_city set city_name = '山西省' where city_code = '140000';
update archives_city set city_name = '内蒙古自治区' where city_code = '150000';
update archives_city set city_name = '辽宁省' where city_code = '210000';
update archives_city set city_name = '吉林省' where city_code = '220000';
update archives_city set city_name = '黑龙江省' where city_code = '230000';
update archives_city set city_name = '上海' where city_code = '310000';
update archives_city set city_name = '江苏省' where city_code = '320000';
update archives_city set city_name = '浙江省' where city_code = '330000';
update archives_city set city_name = '安徽省' where city_code = '340000';
update archives_city set city_name = '福建省' where city_code = '350000';
update archives_city set city_name = '江西省' where city_code = '360000';
update archives_city set city_name = '山东省' where city_code = '370000';
update archives_city set city_name = '河南省' where city_code = '410000';
update archives_city set city_name = '湖北省' where city_code = '420000';
update archives_city set city_name = '湖南省' where city_code = '430000';
update archives_city set city_name = '广东省' where city_code = '440000';
update archives_city set city_name = '广西壮族自治区' where city_code = '450000';
update archives_city set city_name = '海南省' where city_code = '460000';
update archives_city set city_name = '重庆' where city_code = '500000';
update archives_city set city_name = '四川省' where city_code = '510000';
update archives_city set city_name = '贵州省' where city_code = '520000';
update archives_city set city_name = '云南省' where city_code = '530000';
update archives_city set city_name = '西藏自治区' where city_code = '540000';
update archives_city set city_name = '陕西省' where city_code = '610000';
update archives_city set city_name = '甘肃省' where city_code = '620000';
update archives_city set city_name = '青海省' where city_code = '630000';
update archives_city set city_name = '宁夏回族自治区' where city_code = '640000';
update archives_city set city_name = '新疆维吾尔自治区' where city_code = '650000';
update archives_city set city_name = '台湾' where city_code = '710000';
update archives_city set city_name = '香港特别行政区' where city_code = '810000';
update archives_city set city_name = '澳门特别行政区' where city_code = '820000';

你可能感兴趣的:(mysql)