vehicle_management.sql 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. /*
  2. Navicat Premium Dump SQL
  3. Source Server : 47.99.164.66 hn02le.34lkdLKD
  4. Source Server Type : MySQL
  5. Source Server Version : 50736 (5.7.36)
  6. Source Host : 47.99.164.66:3306
  7. Source Schema : vehicle_management
  8. Target Server Type : MySQL
  9. Target Server Version : 50736 (5.7.36)
  10. File Encoding : 65001
  11. Date: 05/05/2026 10:14:43
  12. */
  13. SET NAMES utf8mb4;
  14. SET FOREIGN_KEY_CHECKS = 0;
  15. -- ----------------------------
  16. -- Table structure for certificates
  17. -- ----------------------------
  18. DROP TABLE IF EXISTS `certificates`;
  19. CREATE TABLE `certificates` (
  20. `id` int(11) NOT NULL AUTO_INCREMENT,
  21. `user_id` int(11) NOT NULL COMMENT '用户ID',
  22. `certificate_type` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '证件类型: driving_license(驾驶证), escort_license(押运证)等',
  23. `file_url` varchar(500) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '文件URL',
  24. `file_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '原文件名',
  25. `expiry_date` date DEFAULT NULL COMMENT '证件过期日期',
  26. `uploaded_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '上传时间',
  27. `is_deleted` tinyint(1) DEFAULT '0' COMMENT '是否删除: 0-正常, 1-删除',
  28. PRIMARY KEY (`id`),
  29. KEY `idx_user_id` (`user_id`),
  30. KEY `idx_certificates_expiry` (`expiry_date`),
  31. CONSTRAINT `certificates_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
  32. ) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='证件表';
  33. -- ----------------------------
  34. -- Records of certificates
  35. -- ----------------------------
  36. BEGIN;
  37. INSERT INTO `certificates` (`id`, `user_id`, `certificate_type`, `file_url`, `file_name`, `expiry_date`, `uploaded_at`, `is_deleted`) VALUES (5, 11, 'driving_license', 'http://localhost:8000/files/uploads/general/2026/01/15/7cbec2b6-6bef-4b57-90fc-b85460f99fd8.png', 'Snipaste_2025-12-27_16-03-25.png', '2026-01-21', '2026-01-15 16:50:44', 0);
  38. INSERT INTO `certificates` (`id`, `user_id`, `certificate_type`, `file_url`, `file_name`, `expiry_date`, `uploaded_at`, `is_deleted`) VALUES (6, 12, 'driving_license', 'http://121.43.228.102:9000/clgl/ed678c29-239d-46d4-a03b-75d1bbca6d1c.png', 'Snipaste_2025-12-27_16-03-21.png', '2026-02-04', '2026-01-15 17:05:56', 0);
  39. INSERT INTO `certificates` (`id`, `user_id`, `certificate_type`, `file_url`, `file_name`, `expiry_date`, `uploaded_at`, `is_deleted`) VALUES (7, 12, 'id_card', 'http://121.43.228.102:9000/clgl/4dbae2be-ab0b-43ca-b7f1-d9f1cdf9bbc1.png', 'Snipaste_2025-12-27_16-03-11.png', '2025-12-30', '2026-01-15 17:06:14', 1);
  40. INSERT INTO `certificates` (`id`, `user_id`, `certificate_type`, `file_url`, `file_name`, `expiry_date`, `uploaded_at`, `is_deleted`) VALUES (8, 12, 'escort_license', 'http://121.43.228.102:9000/clgl/6f20a27a-7399-47f3-aa23-5e30d74f507b.png', 'Snipaste_2025-12-27_16-03-06.png', '2026-01-14', '2026-01-15 17:10:05', 1);
  41. INSERT INTO `certificates` (`id`, `user_id`, `certificate_type`, `file_url`, `file_name`, `expiry_date`, `uploaded_at`, `is_deleted`) VALUES (9, 12, 'id_card', 'http://121.43.228.102:9000/clgl/736349d7-9443-4677-aacf-8ced1396c14c.png', 'Snipaste_2025-12-27_16-03-33.png', '2026-01-21', '2026-01-15 17:10:13', 0);
  42. INSERT INTO `certificates` (`id`, `user_id`, `certificate_type`, `file_url`, `file_name`, `expiry_date`, `uploaded_at`, `is_deleted`) VALUES (10, 12, 'id_card', 'http://121.43.228.102:9000/clgl/5e3203df-b0c3-45d5-a6b2-0a83c6ea7cda.png', 'Snipaste_2025-12-27_16-03-21.png', '2025-12-30', '2026-01-15 17:10:40', 0);
  43. INSERT INTO `certificates` (`id`, `user_id`, `certificate_type`, `file_url`, `file_name`, `expiry_date`, `uploaded_at`, `is_deleted`) VALUES (11, 12, 'qualification_certificate', 'http://121.43.228.102:9000/clgl/3b3bf250-62ab-42b9-920e-79401538ead2.png', 'Snipaste_2025-12-27_16-03-17.png', '2025-12-30', '2026-01-15 17:10:47', 0);
  44. INSERT INTO `certificates` (`id`, `user_id`, `certificate_type`, `file_url`, `file_name`, `expiry_date`, `uploaded_at`, `is_deleted`) VALUES (12, 12, 'escort_license', 'http://121.43.228.102:9000/clgl/bb416d90-8ce1-43bb-841d-ff86bb192190.png', 'Snipaste_2025-12-27_16-03-21.png', '2026-01-14', '2026-01-15 17:10:56', 0);
  45. INSERT INTO `certificates` (`id`, `user_id`, `certificate_type`, `file_url`, `file_name`, `expiry_date`, `uploaded_at`, `is_deleted`) VALUES (13, 9, 'driving_license', 'http://121.43.228.102:9000/clgl/ac003234-a437-4a18-92cf-5260ac71ec07.png', 'Snipaste_2025-12-27_16-03-33.png', '2026-01-14', '2026-01-15 22:53:09', 0);
  46. INSERT INTO `certificates` (`id`, `user_id`, `certificate_type`, `file_url`, `file_name`, `expiry_date`, `uploaded_at`, `is_deleted`) VALUES (14, 10, 'escort_license', 'http://121.43.228.102:9000/clgl/4907c641-d10e-4016-a517-65d1824df918.png', 'Snipaste_2025-12-27_16-03-21.png', '2025-12-31', '2026-01-15 22:53:21', 0);
  47. COMMIT;
  48. -- ----------------------------
  49. -- Table structure for manufacturers
  50. -- ----------------------------
  51. DROP TABLE IF EXISTS `manufacturers`;
  52. CREATE TABLE `manufacturers` (
  53. `id` int(11) NOT NULL AUTO_INCREMENT,
  54. `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '厂商名称',
  55. `safety_notice` text COLLATE utf8mb4_unicode_ci COMMENT '厂商安全须知',
  56. `address` varchar(500) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '厂商地址',
  57. `is_active` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否启用',
  58. `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  59. `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  60. `is_deleted` tinyint(1) DEFAULT '0' COMMENT '是否删除: 0-正常, 1-删除',
  61. PRIMARY KEY (`id`),
  62. UNIQUE KEY `name` (`name`),
  63. KEY `idx_name` (`name`),
  64. KEY `idx_is_active` (`is_active`)
  65. ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='厂商表';
  66. -- ----------------------------
  67. -- Records of manufacturers
  68. -- ----------------------------
  69. BEGIN;
  70. INSERT INTO `manufacturers` (`id`, `name`, `safety_notice`, `address`, `is_active`, `created_at`, `updated_at`, `is_deleted`) VALUES (1, '山峡水泥厂', '注意安全,戴好安全帽,禁止在装卸区吸烟', '山峡市工业区A区', 1, '2026-01-13 07:14:49', '2026-01-13 07:14:49', 0);
  71. INSERT INTO `manufacturers` (`id`, `name`, `safety_notice`, `address`, `is_active`, `created_at`, `updated_at`, `is_deleted`) VALUES (2, '山峡钢材厂', '注意防火,禁止明火,穿戴好防护装备', '山峡市工业区B区', 1, '2026-01-13 07:14:49', '2026-01-13 07:14:49', 0);
  72. INSERT INTO `manufacturers` (`id`, `name`, `safety_notice`, `address`, `is_active`, `created_at`, `updated_at`, `is_deleted`) VALUES (3, '山峡物流中心', '注意交通安全,服从指挥', '山峡市物流园区', 1, '2026-01-13 07:14:49', '2026-01-13 07:14:49', 0);
  73. INSERT INTO `manufacturers` (`id`, `name`, `safety_notice`, `address`, `is_active`, `created_at`, `updated_at`, `is_deleted`) VALUES (4, 'a s d f da s', '<h1><span style=\"color: rgb(225, 60, 57);\">123123123123123123213</span></h1><p><br></p><p>1额啊范德萨范德萨</p>', '啊是否撒点发三顿饭撒的范德萨发撒点饭撒的饭都是法师123123123123', 1, '2026-01-16 00:20:08', '2026-01-16 00:20:24', 1);
  74. COMMIT;
  75. -- ----------------------------
  76. -- Table structure for plan_photos
  77. -- ----------------------------
  78. DROP TABLE IF EXISTS `plan_photos`;
  79. CREATE TABLE `plan_photos` (
  80. `id` int(11) NOT NULL AUTO_INCREMENT,
  81. `plan_id` int(11) NOT NULL COMMENT '计划ID',
  82. `photo_type` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '照片类型: loading_arrival(装货到场), loading_departure(装货离场), unloading_arrival(卸货到场), unloading_departure(卸货离场), waybill(运单)',
  83. `file_url` varchar(500) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '文件URL',
  84. `file_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '原文件名',
  85. `uploaded_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '上传时间',
  86. `is_deleted` tinyint(1) DEFAULT '0' COMMENT '是否删除: 0-正常, 1-删除',
  87. PRIMARY KEY (`id`),
  88. KEY `idx_plan_id` (`plan_id`),
  89. CONSTRAINT `plan_photos_ibfk_1` FOREIGN KEY (`plan_id`) REFERENCES `vehicle_plans` (`id`) ON DELETE CASCADE
  90. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='计划照片表';
  91. -- ----------------------------
  92. -- Records of plan_photos
  93. -- ----------------------------
  94. BEGIN;
  95. COMMIT;
  96. -- ----------------------------
  97. -- Table structure for products
  98. -- ----------------------------
  99. DROP TABLE IF EXISTS `products`;
  100. CREATE TABLE `products` (
  101. `id` int(11) NOT NULL AUTO_INCREMENT,
  102. `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商品名称',
  103. `specification` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商品规格',
  104. `is_active` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否启用',
  105. `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  106. `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  107. `is_deleted` tinyint(1) DEFAULT '0' COMMENT '是否删除: 0-正常, 1-删除',
  108. PRIMARY KEY (`id`),
  109. KEY `idx_name` (`name`),
  110. KEY `idx_is_active` (`is_active`)
  111. ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='商品表';
  112. -- ----------------------------
  113. -- Records of products
  114. -- ----------------------------
  115. BEGIN;
  116. INSERT INTO `products` (`id`, `name`, `specification`, `is_active`, `created_at`, `updated_at`, `is_deleted`) VALUES (1, '水泥', '425号普通硅酸盐水泥', 1, '2026-01-13 07:14:49', '2026-01-13 07:14:49', 0);
  117. INSERT INTO `products` (`id`, `name`, `specification`, `is_active`, `created_at`, `updated_at`, `is_deleted`) VALUES (2, '钢筋', '直径12mm HRB400钢筋', 1, '2026-01-13 07:14:49', '2026-01-13 07:14:49', 0);
  118. INSERT INTO `products` (`id`, `name`, `specification`, `is_active`, `created_at`, `updated_at`, `is_deleted`) VALUES (3, '砂石', '中砂(细度模数2.3-1.6)', 1, '2026-01-13 07:14:49', '2026-01-13 07:14:49', 0);
  119. INSERT INTO `products` (`id`, `name`, `specification`, `is_active`, `created_at`, `updated_at`, `is_deleted`) VALUES (4, '混凝土', 'C30商品混凝土', 1, '2026-01-13 07:14:49', '2026-01-16 00:33:18', 1);
  120. INSERT INTO `products` (`id`, `name`, `specification`, `is_active`, `created_at`, `updated_at`, `is_deleted`) VALUES (5, '12344', '12344', 0, '2026-01-16 00:36:27', '2026-01-16 00:36:34', 1);
  121. COMMIT;
  122. -- ----------------------------
  123. -- Table structure for schema_version
  124. -- ----------------------------
  125. DROP TABLE IF EXISTS `schema_version`;
  126. CREATE TABLE `schema_version` (
  127. `version` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '数据库版本',
  128. `description` text COLLATE utf8mb4_unicode_ci COMMENT '版本描述',
  129. `applied_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '应用时间',
  130. PRIMARY KEY (`version`)
  131. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  132. -- ----------------------------
  133. -- Records of schema_version
  134. -- ----------------------------
  135. BEGIN;
  136. INSERT INTO `schema_version` (`version`, `description`, `applied_at`) VALUES ('2.0.0', '添加证件过期时间管理功能,完善车辆证件分类系统', '2026-01-13 07:14:49');
  137. COMMIT;
  138. -- ----------------------------
  139. -- Table structure for users
  140. -- ----------------------------
  141. DROP TABLE IF EXISTS `users`;
  142. CREATE TABLE `users` (
  143. `id` int(11) NOT NULL AUTO_INCREMENT,
  144. `username` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '登录工号',
  145. `password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '密码',
  146. `role` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'operator' COMMENT '角色: operator(操作员), admin(管理员), driver(司机), escort(押运员)',
  147. `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '姓名',
  148. `phone` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '手机号码(司机、押运员必填)',
  149. `id_card` varchar(18) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '身份证号(司机、押运员必填)',
  150. `is_active` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否启用',
  151. `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  152. `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  153. `is_deleted` tinyint(1) DEFAULT '0' COMMENT '是否删除: 0-正常, 1-删除',
  154. PRIMARY KEY (`id`),
  155. UNIQUE KEY `username` (`username`),
  156. KEY `idx_username` (`username`),
  157. KEY `idx_role` (`role`),
  158. KEY `idx_is_active` (`is_active`)
  159. ) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户表';
  160. -- ----------------------------
  161. -- Records of users
  162. -- ----------------------------
  163. BEGIN;
  164. INSERT INTO `users` (`id`, `username`, `password`, `role`, `name`, `phone`, `id_card`, `is_active`, `created_at`, `updated_at`, `is_deleted`) VALUES (1, 'admin', 'admin123', 'admin', '系统管理员', NULL, NULL, 1, '2026-01-13 07:14:49', '2026-01-13 07:14:49', 0);
  165. INSERT INTO `users` (`id`, `username`, `password`, `role`, `name`, `phone`, `id_card`, `is_active`, `created_at`, `updated_at`, `is_deleted`) VALUES (2, 'testuser1768458386083', '123456', 'operator', '测试用户', NULL, NULL, 1, '2026-01-15 14:26:26', '2026-01-15 14:26:26', 0);
  166. INSERT INTO `users` (`id`, `username`, `password`, `role`, `name`, `phone`, `id_card`, `is_active`, `created_at`, `updated_at`, `is_deleted`) VALUES (3, 'testuser1768458429763', '123456', 'operator', '测试用户', NULL, NULL, 1, '2026-01-15 14:27:09', '2026-01-15 14:27:09', 0);
  167. INSERT INTO `users` (`id`, `username`, `password`, `role`, `name`, `phone`, `id_card`, `is_active`, `created_at`, `updated_at`, `is_deleted`) VALUES (7, 'test422', '123456', 'operator', '测试422', '13877711221', NULL, 1, '2026-01-15 14:37:18', '2026-01-15 14:37:18', 0);
  168. INSERT INTO `users` (`id`, `username`, `password`, `role`, `name`, `phone`, `id_card`, `is_active`, `created_at`, `updated_at`, `is_deleted`) VALUES (8, 'czy03', '123456', 'operator', '操作员03', '13899001122', NULL, 1, '2026-01-15 14:39:18', '2026-01-15 14:39:18', 0);
  169. INSERT INTO `users` (`id`, `username`, `password`, `role`, `name`, `phone`, `id_card`, `is_active`, `created_at`, `updated_at`, `is_deleted`) VALUES (9, '1231', '123456', 'escort', '王五', '13899112232', '340822198111221122', 1, '2026-01-15 14:43:18', '2026-01-15 19:01:50', 0);
  170. INSERT INTO `users` (`id`, `username`, `password`, `role`, `name`, `phone`, `id_card`, `is_active`, `created_at`, `updated_at`, `is_deleted`) VALUES (10, '3', '123456', 'driver', 'lisan', '13877112211', '340822198811223344', 1, '2026-01-15 14:43:41', '2026-01-15 15:09:56', 0);
  171. INSERT INTO `users` (`id`, `username`, `password`, `role`, `name`, `phone`, `id_card`, `is_active`, `created_at`, `updated_at`, `is_deleted`) VALUES (11, '4', '123456', 'operator', '4', '13511223311', NULL, 1, '2026-01-15 14:49:14', '2026-01-15 14:49:14', 0);
  172. INSERT INTO `users` (`id`, `username`, `password`, `role`, `name`, `phone`, `id_card`, `is_active`, `created_at`, `updated_at`, `is_deleted`) VALUES (12, '5', '123456', 'operator', '5', '13611332211', NULL, 0, '2026-01-15 14:49:23', '2026-01-15 17:19:18', 0);
  173. COMMIT;
  174. -- ----------------------------
  175. -- Table structure for vehicle_certificates
  176. -- ----------------------------
  177. DROP TABLE IF EXISTS `vehicle_certificates`;
  178. CREATE TABLE `vehicle_certificates` (
  179. `id` int(11) NOT NULL AUTO_INCREMENT,
  180. `vehicle_id` int(11) NOT NULL COMMENT '车辆ID',
  181. `certificate_category` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '证件类别: license(车牌), registration(行驶证), transport(运输证), insurance(保险), inspection(罐检)',
  182. `vehicle_part` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '车辆部位: head(车头), tail(车尾), tank(罐体)',
  183. `file_url` varchar(500) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '文件URL',
  184. `file_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '原文件名',
  185. `expiry_date` date DEFAULT NULL COMMENT '证件过期日期',
  186. `uploaded_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '上传时间',
  187. `is_deleted` tinyint(1) DEFAULT '0' COMMENT '是否删除: 0-正常, 1-删除',
  188. PRIMARY KEY (`id`),
  189. KEY `idx_vehicle_id` (`vehicle_id`),
  190. KEY `idx_vehicle_certificates_expiry` (`expiry_date`),
  191. KEY `idx_vehicle_certificates_part_category` (`vehicle_part`,`certificate_category`),
  192. CONSTRAINT `vehicle_certificates_ibfk_1` FOREIGN KEY (`vehicle_id`) REFERENCES `vehicles` (`id`) ON DELETE CASCADE
  193. ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='车辆证件表';
  194. -- ----------------------------
  195. -- Records of vehicle_certificates
  196. -- ----------------------------
  197. BEGIN;
  198. INSERT INTO `vehicle_certificates` (`id`, `vehicle_id`, `certificate_category`, `vehicle_part`, `file_url`, `file_name`, `expiry_date`, `uploaded_at`, `is_deleted`) VALUES (1, 1, 'license', 'head', 'http://121.43.228.102:9000/clgl/77ccdee8-1e0e-47fc-a34f-d9d06574a335.png', 'Snipaste_2025-12-27_16-03-25.png', '2026-01-13', '2026-01-15 20:00:52', 1);
  199. INSERT INTO `vehicle_certificates` (`id`, `vehicle_id`, `certificate_category`, `vehicle_part`, `file_url`, `file_name`, `expiry_date`, `uploaded_at`, `is_deleted`) VALUES (2, 1, 'registration', 'head', 'http://example.com/test.pdf', 'test.pdf', '2025-12-31', '2026-01-15 20:01:02', 1);
  200. INSERT INTO `vehicle_certificates` (`id`, `vehicle_id`, `certificate_category`, `vehicle_part`, `file_url`, `file_name`, `expiry_date`, `uploaded_at`, `is_deleted`) VALUES (3, 1, 'registration', 'head', 'http://121.43.228.102:9000/clgl/40194dc8-62f9-49eb-9e13-b5a7fefb9ed0.png', 'Snipaste_2025-12-27_16-03-25.png', '2026-01-21', '2026-01-15 20:28:36', 0);
  201. INSERT INTO `vehicle_certificates` (`id`, `vehicle_id`, `certificate_category`, `vehicle_part`, `file_url`, `file_name`, `expiry_date`, `uploaded_at`, `is_deleted`) VALUES (4, 1, 'inspection', 'head', 'http://121.43.228.102:9000/clgl/56f3c3a2-355f-4ffb-b59a-63db99d82ad3.png', 'Snipaste_2025-12-27_16-03-21.png', '2026-01-06', '2026-01-15 20:32:47', 1);
  202. INSERT INTO `vehicle_certificates` (`id`, `vehicle_id`, `certificate_category`, `vehicle_part`, `file_url`, `file_name`, `expiry_date`, `uploaded_at`, `is_deleted`) VALUES (5, 1, 'insurance', 'head', 'http://121.43.228.102:9000/clgl/350bad8b-ce21-42f4-913c-b279a0347f92.png', 'Snipaste_2025-12-27_16-03-33.png', '2025-12-30', '2026-01-15 20:33:01', 1);
  203. INSERT INTO `vehicle_certificates` (`id`, `vehicle_id`, `certificate_category`, `vehicle_part`, `file_url`, `file_name`, `expiry_date`, `uploaded_at`, `is_deleted`) VALUES (6, 1, 'registration', 'head', 'http://121.43.228.102:9000/clgl/b799d8e6-8b94-439a-8402-1fc11016b90e.png', 'Snipaste_2025-12-27_16-03-25.png', '2025-12-30', '2026-01-15 20:52:21', 1);
  204. INSERT INTO `vehicle_certificates` (`id`, `vehicle_id`, `certificate_category`, `vehicle_part`, `file_url`, `file_name`, `expiry_date`, `uploaded_at`, `is_deleted`) VALUES (7, 1, 'transport', 'tail', 'http://121.43.228.102:9000/clgl/86b2b5f4-938f-4bac-9621-eebcc5522b08.png', 'Snipaste_2025-12-27_16-03-25.png', '2026-01-28', '2026-01-15 21:28:56', 0);
  205. INSERT INTO `vehicle_certificates` (`id`, `vehicle_id`, `certificate_category`, `vehicle_part`, `file_url`, `file_name`, `expiry_date`, `uploaded_at`, `is_deleted`) VALUES (8, 1, 'registration', 'tail', 'http://121.43.228.102:9000/clgl/9468380e-9f5d-44a3-ba22-b5805570e8bc.png', 'Snipaste_2025-12-27_16-03-17.png', '2026-01-07', '2026-01-15 21:29:10', 0);
  206. INSERT INTO `vehicle_certificates` (`id`, `vehicle_id`, `certificate_category`, `vehicle_part`, `file_url`, `file_name`, `expiry_date`, `uploaded_at`, `is_deleted`) VALUES (9, 1, 'license', 'tail', 'http://121.43.228.102:9000/clgl/b17330dc-1c32-4408-8f2d-bbcae00a3046.jpg', 'avatar.jpg', '2026-01-22', '2026-01-15 21:29:21', 0);
  207. COMMIT;
  208. -- ----------------------------
  209. -- Table structure for vehicle_heads
  210. -- ----------------------------
  211. DROP TABLE IF EXISTS `vehicle_heads`;
  212. CREATE TABLE `vehicle_heads` (
  213. `id` int(11) NOT NULL AUTO_INCREMENT,
  214. `plate_number` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  215. `is_active` tinyint(1) DEFAULT '1',
  216. `is_deleted` tinyint(1) DEFAULT '0',
  217. `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  218. `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  219. `category` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT 'owned' COMMENT '车辆分类: owned(自有车辆), other(其他车辆)',
  220. PRIMARY KEY (`id`),
  221. UNIQUE KEY `plate_number` (`plate_number`),
  222. KEY `idx_plate_number` (`plate_number`),
  223. KEY `idx_is_active` (`is_active`)
  224. ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='车头表';
  225. -- ----------------------------
  226. -- Records of vehicle_heads
  227. -- ----------------------------
  228. BEGIN;
  229. INSERT INTO `vehicle_heads` (`id`, `plate_number`, `is_active`, `is_deleted`, `created_at`, `updated_at`, `category`) VALUES (1, '皖P13231', 1, 0, '2026-01-15 19:18:40', '2026-01-15 19:18:40', 'owned');
  230. INSERT INTO `vehicle_heads` (`id`, `plate_number`, `is_active`, `is_deleted`, `created_at`, `updated_at`, `category`) VALUES (2, '皖D13223', 1, 1, '2026-01-15 21:16:13', '2026-01-15 21:30:24', 'owned');
  231. INSERT INTO `vehicle_heads` (`id`, `plate_number`, `is_active`, `is_deleted`, `created_at`, `updated_at`, `category`) VALUES (3, '皖S12222', 1, 0, '2026-01-15 22:28:32', '2026-01-15 22:28:32', 'owned');
  232. COMMIT;
  233. -- ----------------------------
  234. -- Table structure for vehicle_plans
  235. -- ----------------------------
  236. DROP TABLE IF EXISTS `vehicle_plans`;
  237. CREATE TABLE `vehicle_plans` (
  238. `id` int(11) NOT NULL AUTO_INCREMENT,
  239. `plan_date` date NOT NULL COMMENT '计划日期',
  240. `start_time` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '开始时间 (HH:MM格式)',
  241. `end_time` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '结束时间 (HH:MM格式)',
  242. `customer_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '客户名称',
  243. `product_id` int(11) NOT NULL COMMENT '商品ID',
  244. `quantity` float NOT NULL COMMENT '数量',
  245. `unit` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '单位',
  246. `loading_manufacturer_id` int(11) NOT NULL COMMENT '装货厂商ID',
  247. `unloading_manufacturer_id` int(11) NOT NULL COMMENT '卸货厂商ID',
  248. `vehicle_id` int(11) NOT NULL COMMENT '车辆ID',
  249. `driver_id` int(11) NOT NULL COMMENT '司机ID',
  250. `escort_id` int(11) NOT NULL COMMENT '押运员ID',
  251. `loading_arrival_time` datetime DEFAULT NULL COMMENT '装货到场时间',
  252. `loading_departure_time` datetime DEFAULT NULL COMMENT '装货离场时间',
  253. `unloading_arrival_time` datetime DEFAULT NULL COMMENT '卸货到场时间',
  254. `unloading_departure_time` datetime DEFAULT NULL COMMENT '卸货离场时间',
  255. `status` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending' COMMENT '状态: pending(待开始), loading(装货中), unloading(卸货中), completed(已完成)',
  256. `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  257. `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  258. `is_deleted` tinyint(1) DEFAULT '0' COMMENT '是否删除: 0-正常, 1-删除',
  259. PRIMARY KEY (`id`),
  260. KEY `idx_plan_date` (`plan_date`),
  261. KEY `idx_status` (`status`),
  262. KEY `idx_driver_id` (`driver_id`),
  263. KEY `idx_escort_id` (`escort_id`),
  264. KEY `product_id` (`product_id`),
  265. KEY `loading_manufacturer_id` (`loading_manufacturer_id`),
  266. KEY `unloading_manufacturer_id` (`unloading_manufacturer_id`),
  267. KEY `vehicle_id` (`vehicle_id`),
  268. KEY `idx_vehicle_plans_date_status` (`plan_date`,`status`),
  269. KEY `idx_vehicle_plans_driver_escort` (`driver_id`,`escort_id`),
  270. CONSTRAINT `vehicle_plans_ibfk_1` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`),
  271. CONSTRAINT `vehicle_plans_ibfk_2` FOREIGN KEY (`loading_manufacturer_id`) REFERENCES `manufacturers` (`id`),
  272. CONSTRAINT `vehicle_plans_ibfk_3` FOREIGN KEY (`unloading_manufacturer_id`) REFERENCES `manufacturers` (`id`),
  273. CONSTRAINT `vehicle_plans_ibfk_4` FOREIGN KEY (`vehicle_id`) REFERENCES `vehicles` (`id`),
  274. CONSTRAINT `vehicle_plans_ibfk_5` FOREIGN KEY (`driver_id`) REFERENCES `users` (`id`),
  275. CONSTRAINT `vehicle_plans_ibfk_6` FOREIGN KEY (`escort_id`) REFERENCES `users` (`id`)
  276. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='车辆计划表';
  277. -- ----------------------------
  278. -- Records of vehicle_plans
  279. -- ----------------------------
  280. BEGIN;
  281. COMMIT;
  282. -- ----------------------------
  283. -- Table structure for vehicle_tails
  284. -- ----------------------------
  285. DROP TABLE IF EXISTS `vehicle_tails`;
  286. CREATE TABLE `vehicle_tails` (
  287. `id` int(11) NOT NULL AUTO_INCREMENT,
  288. `plate_number` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  289. `is_active` tinyint(1) DEFAULT '1',
  290. `is_deleted` tinyint(1) DEFAULT '0',
  291. `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  292. `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  293. `category` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT 'owned' COMMENT '车辆分类: owned(自有车辆), other(其他车辆)',
  294. PRIMARY KEY (`id`),
  295. UNIQUE KEY `plate_number` (`plate_number`),
  296. KEY `idx_plate_number` (`plate_number`),
  297. KEY `idx_is_active` (`is_active`)
  298. ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='车尾表';
  299. -- ----------------------------
  300. -- Records of vehicle_tails
  301. -- ----------------------------
  302. BEGIN;
  303. INSERT INTO `vehicle_tails` (`id`, `plate_number`, `is_active`, `is_deleted`, `created_at`, `updated_at`, `category`) VALUES (1, '皖A09871', 0, 0, '2026-01-15 19:18:41', '2026-01-15 21:29:50', 'owned');
  304. INSERT INTO `vehicle_tails` (`id`, `plate_number`, `is_active`, `is_deleted`, `created_at`, `updated_at`, `category`) VALUES (2, '皖A12333', 1, 0, '2026-01-15 22:28:39', '2026-01-15 22:28:39', 'owned');
  305. COMMIT;
  306. -- ----------------------------
  307. -- Table structure for vehicles
  308. -- ----------------------------
  309. DROP TABLE IF EXISTS `vehicles`;
  310. CREATE TABLE `vehicles` (
  311. `id` int(11) NOT NULL AUTO_INCREMENT,
  312. `category` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '分类: owned(自有车辆), other(其他车辆)',
  313. `head_id` int(11) DEFAULT NULL,
  314. `tail_id` int(11) DEFAULT NULL,
  315. `default_driver_id` int(11) DEFAULT NULL COMMENT '默认司机ID',
  316. `default_escort_id` int(11) DEFAULT NULL COMMENT '默认押运员ID',
  317. `is_active` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否启用',
  318. `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  319. `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  320. `is_deleted` tinyint(1) DEFAULT '0' COMMENT '是否删除: 0-正常, 1-删除',
  321. PRIMARY KEY (`id`),
  322. KEY `idx_category` (`category`),
  323. KEY `idx_is_active` (`is_active`),
  324. KEY `default_driver_id` (`default_driver_id`),
  325. KEY `default_escort_id` (`default_escort_id`),
  326. KEY `fk_vehicle_head` (`head_id`),
  327. KEY `fk_vehicle_tail` (`tail_id`),
  328. CONSTRAINT `fk_vehicle_head` FOREIGN KEY (`head_id`) REFERENCES `vehicle_heads` (`id`),
  329. CONSTRAINT `fk_vehicle_tail` FOREIGN KEY (`tail_id`) REFERENCES `vehicle_tails` (`id`) ON DELETE SET NULL,
  330. CONSTRAINT `vehicles_ibfk_1` FOREIGN KEY (`default_driver_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  331. CONSTRAINT `vehicles_ibfk_2` FOREIGN KEY (`default_escort_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
  332. ) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='车辆表';
  333. -- ----------------------------
  334. -- Records of vehicles
  335. -- ----------------------------
  336. BEGIN;
  337. INSERT INTO `vehicles` (`id`, `category`, `head_id`, `tail_id`, `default_driver_id`, `default_escort_id`, `is_active`, `created_at`, `updated_at`, `is_deleted`) VALUES (1, 'owned', 1, 1, 10, 9, 1, '2026-01-15 19:02:06', '2026-01-15 22:35:59', 1);
  338. INSERT INTO `vehicles` (`id`, `category`, `head_id`, `tail_id`, `default_driver_id`, `default_escort_id`, `is_active`, `created_at`, `updated_at`, `is_deleted`) VALUES (2, 'other', 1, 1, 10, 9, 1, '2026-01-15 22:28:10', '2026-01-15 22:43:35', 0);
  339. INSERT INTO `vehicles` (`id`, `category`, `head_id`, `tail_id`, `default_driver_id`, `default_escort_id`, `is_active`, `created_at`, `updated_at`, `is_deleted`) VALUES (3, 'owned', 3, 2, 10, 9, 0, '2026-01-15 22:29:18', '2026-01-15 23:45:59', 0);
  340. INSERT INTO `vehicles` (`id`, `category`, `head_id`, `tail_id`, `default_driver_id`, `default_escort_id`, `is_active`, `created_at`, `updated_at`, `is_deleted`) VALUES (4, 'owned', 1, 2, 10, 9, 1, '2026-01-15 22:33:46', '2026-01-15 22:33:46', 0);
  341. INSERT INTO `vehicles` (`id`, `category`, `head_id`, `tail_id`, `default_driver_id`, `default_escort_id`, `is_active`, `created_at`, `updated_at`, `is_deleted`) VALUES (5, 'owned', 1, 2, 10, 9, 1, '2026-01-15 22:33:58', '2026-01-15 22:33:58', 0);
  342. INSERT INTO `vehicles` (`id`, `category`, `head_id`, `tail_id`, `default_driver_id`, `default_escort_id`, `is_active`, `created_at`, `updated_at`, `is_deleted`) VALUES (6, 'owned', 1, 2, 10, 9, 1, '2026-01-15 22:35:36', '2026-01-15 22:35:36', 0);
  343. INSERT INTO `vehicles` (`id`, `category`, `head_id`, `tail_id`, `default_driver_id`, `default_escort_id`, `is_active`, `created_at`, `updated_at`, `is_deleted`) VALUES (7, 'owned', 1, 2, 10, 9, 1, '2026-01-15 22:35:54', '2026-01-15 22:35:54', 0);
  344. COMMIT;
  345. -- ----------------------------
  346. -- Triggers structure for table manufacturers
  347. -- ----------------------------
  348. DROP TRIGGER IF EXISTS `update_manufacturers_timestamp`;
  349. delimiter ;;
  350. CREATE TRIGGER `vehicle_management`.`update_manufacturers_timestamp` BEFORE UPDATE ON `manufacturers` FOR EACH ROW BEGIN
  351. SET NEW.updated_at = CURRENT_TIMESTAMP;
  352. END
  353. ;;
  354. delimiter ;
  355. -- ----------------------------
  356. -- Triggers structure for table products
  357. -- ----------------------------
  358. DROP TRIGGER IF EXISTS `update_products_timestamp`;
  359. delimiter ;;
  360. CREATE TRIGGER `vehicle_management`.`update_products_timestamp` BEFORE UPDATE ON `products` FOR EACH ROW BEGIN
  361. SET NEW.updated_at = CURRENT_TIMESTAMP;
  362. END
  363. ;;
  364. delimiter ;
  365. -- ----------------------------
  366. -- Triggers structure for table users
  367. -- ----------------------------
  368. DROP TRIGGER IF EXISTS `update_users_timestamp`;
  369. delimiter ;;
  370. CREATE TRIGGER `vehicle_management`.`update_users_timestamp` BEFORE UPDATE ON `users` FOR EACH ROW BEGIN
  371. SET NEW.updated_at = CURRENT_TIMESTAMP;
  372. END
  373. ;;
  374. delimiter ;
  375. -- ----------------------------
  376. -- Triggers structure for table vehicle_heads
  377. -- ----------------------------
  378. DROP TRIGGER IF EXISTS `update_vehicle_heads_timestamp`;
  379. delimiter ;;
  380. CREATE TRIGGER `vehicle_management`.`update_vehicle_heads_timestamp` BEFORE UPDATE ON `vehicle_heads` FOR EACH ROW SET NEW.updated_at = CURRENT_TIMESTAMP
  381. ;;
  382. delimiter ;
  383. -- ----------------------------
  384. -- Triggers structure for table vehicle_plans
  385. -- ----------------------------
  386. DROP TRIGGER IF EXISTS `update_vehicle_plans_timestamp`;
  387. delimiter ;;
  388. CREATE TRIGGER `vehicle_management`.`update_vehicle_plans_timestamp` BEFORE UPDATE ON `vehicle_plans` FOR EACH ROW BEGIN
  389. SET NEW.updated_at = CURRENT_TIMESTAMP;
  390. END
  391. ;;
  392. delimiter ;
  393. -- ----------------------------
  394. -- Triggers structure for table vehicle_tails
  395. -- ----------------------------
  396. DROP TRIGGER IF EXISTS `update_vehicle_tails_timestamp`;
  397. delimiter ;;
  398. CREATE TRIGGER `vehicle_management`.`update_vehicle_tails_timestamp` BEFORE UPDATE ON `vehicle_tails` FOR EACH ROW SET NEW.updated_at = CURRENT_TIMESTAMP
  399. ;;
  400. delimiter ;
  401. -- ----------------------------
  402. -- Triggers structure for table vehicles
  403. -- ----------------------------
  404. DROP TRIGGER IF EXISTS `update_vehicles_timestamp`;
  405. delimiter ;;
  406. CREATE TRIGGER `vehicle_management`.`update_vehicles_timestamp` BEFORE UPDATE ON `vehicles` FOR EACH ROW BEGIN
  407. SET NEW.updated_at = CURRENT_TIMESTAMP;
  408. END
  409. ;;
  410. delimiter ;
  411. SET FOREIGN_KEY_CHECKS = 1;