feat: add inspection object resource workflow
This commit is contained in:
33
drizzle/0017_inspection_objects.sql
Normal file
33
drizzle/0017_inspection_objects.sql
Normal file
@@ -0,0 +1,33 @@
|
||||
CREATE TABLE IF NOT EXISTS `inspection_objects` (
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`modelId` INT NOT NULL,
|
||||
`name` VARCHAR(100) NOT NULL,
|
||||
`description` TEXT NULL,
|
||||
`status` ENUM('draft','active') NOT NULL DEFAULT 'draft',
|
||||
`defaultModelPointcloudId` INT NULL,
|
||||
`defaultModelCadFileId` INT NULL,
|
||||
`createdAt` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`updatedAt` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
UNIQUE KEY `uk_inspection_objects_model_name` (`modelId`,`name`),
|
||||
KEY `idx_inspection_objects_model` (`modelId`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
ALTER TABLE `model_pointcloud_files`
|
||||
ADD COLUMN `inspectionObjectId` INT NULL AFTER `filePath`,
|
||||
ADD COLUMN `status` ENUM('available','disabled') NOT NULL DEFAULT 'available' AFTER `inspectionObjectId`,
|
||||
ADD KEY `idx_model_pointcloud_object` (`inspectionObjectId`);
|
||||
|
||||
ALTER TABLE `model_cad_files`
|
||||
ADD COLUMN `contentScope` ENUM('whole_vehicle') NOT NULL DEFAULT 'whole_vehicle' AFTER `filePath`,
|
||||
ADD COLUMN `status` ENUM('available','disabled') NOT NULL DEFAULT 'available' AFTER `contentScope`;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `model_cad_inspection_objects` (
|
||||
`cadFileId` INT NOT NULL,
|
||||
`inspectionObjectId` INT NOT NULL,
|
||||
UNIQUE KEY `uk_model_cad_inspection_object` (`cadFileId`,`inspectionObjectId`),
|
||||
KEY `idx_model_cad_object` (`inspectionObjectId`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
ALTER TABLE `inspection_tasks`
|
||||
ADD COLUMN `inspectionObjectId` INT NULL AFTER `modelId`,
|
||||
ADD KEY `idx_inspection_tasks_object` (`inspectionObjectId`);
|
||||
@@ -50,6 +50,25 @@ export const vehicleModels = mysqlTable("vehicle_models", {
|
||||
export type VehicleModel = typeof vehicleModels.$inferSelect;
|
||||
export type InsertVehicleModel = typeof vehicleModels.$inferInsert;
|
||||
|
||||
// ─── 检测对象 ────────────────────────────────────────────────────────────────
|
||||
// 车型下真正执行检测的对象,例如头车、中间车。默认资源只影响新建任务。
|
||||
export const inspectionObjects = mysqlTable("inspection_objects", {
|
||||
id: int("id").autoincrement().primaryKey(),
|
||||
modelId: int("modelId").notNull(),
|
||||
name: varchar("name", { length: 100 }).notNull(),
|
||||
description: text("description"),
|
||||
status: mysqlEnum("status", ["draft", "active"]).default("draft").notNull(),
|
||||
defaultModelPointcloudId: int("defaultModelPointcloudId"),
|
||||
defaultModelCadFileId: int("defaultModelCadFileId"),
|
||||
createdAt: timestamp("createdAt").defaultNow().notNull(),
|
||||
updatedAt: timestamp("updatedAt").defaultNow().onUpdateNow().notNull(),
|
||||
}, (table) => ({
|
||||
modelNameUnique: uniqueIndex("uk_inspection_objects_model_name").on(table.modelId, table.name),
|
||||
}));
|
||||
|
||||
export type InspectionObject = typeof inspectionObjects.$inferSelect;
|
||||
export type InsertInspectionObject = typeof inspectionObjects.$inferInsert;
|
||||
|
||||
// ─── 车型 CAD 文件 ─────────────────────────────────────────────────────────────
|
||||
// 一个车型可关联多个 CAD 文件(车头、车身、转向架等),低频变更
|
||||
|
||||
@@ -60,12 +79,21 @@ export const modelCadFiles = mysqlTable("model_cad_files", {
|
||||
format: varchar("format", { length: 32 }).notNull(),
|
||||
fileSize: bigint("fileSize", { mode: "number" }).notNull(),
|
||||
filePath: varchar("filePath", { length: 512 }).notNull(),
|
||||
contentScope: mysqlEnum("contentScope", ["whole_vehicle"]).default("whole_vehicle").notNull(),
|
||||
status: mysqlEnum("status", ["available", "disabled"]).default("available").notNull(),
|
||||
createdAt: timestamp("createdAt").defaultNow().notNull(),
|
||||
});
|
||||
|
||||
export type ModelCadFile = typeof modelCadFiles.$inferSelect;
|
||||
export type InsertModelCadFile = typeof modelCadFiles.$inferInsert;
|
||||
|
||||
export const modelCadInspectionObjects = mysqlTable("model_cad_inspection_objects", {
|
||||
cadFileId: int("cadFileId").notNull(),
|
||||
inspectionObjectId: int("inspectionObjectId").notNull(),
|
||||
}, (table) => ({
|
||||
cadObjectUnique: uniqueIndex("uk_model_cad_inspection_object").on(table.cadFileId, table.inspectionObjectId),
|
||||
}));
|
||||
|
||||
// ─── 车型点云文件 ─────────────────────────────────────────────────────────────
|
||||
// 一个车型可维护多个通用点云文件,供任务按需关联复用
|
||||
|
||||
@@ -75,6 +103,8 @@ export const modelPointcloudFiles = mysqlTable("model_pointcloud_files", {
|
||||
name: varchar("name", { length: 255 }).notNull(),
|
||||
fileSize: bigint("fileSize", { mode: "number" }).notNull(),
|
||||
filePath: varchar("filePath", { length: 512 }).notNull(),
|
||||
inspectionObjectId: int("inspectionObjectId"),
|
||||
status: mysqlEnum("status", ["available", "disabled"]).default("available").notNull(),
|
||||
metadataStatus: mysqlEnum("metadataStatus", ["pending", "ready", "unsupported", "error"]).default("pending").notNull(),
|
||||
pointCount: bigint("pointCount", { mode: "number" }),
|
||||
pointAttributes: json("pointAttributes").$type<PointAttribute[]>(),
|
||||
@@ -113,6 +143,7 @@ export type InsertTaskCadFile = typeof taskCadFiles.$inferInsert;
|
||||
export const inspectionTasks = mysqlTable("inspection_tasks", {
|
||||
id: int("id").autoincrement().primaryKey(),
|
||||
modelId: int("modelId").notNull(),
|
||||
inspectionObjectId: int("inspectionObjectId"),
|
||||
name: varchar("name", { length: 255 }).notNull(),
|
||||
inspector: varchar("inspector", { length: 100 }),
|
||||
notes: text("notes"),
|
||||
|
||||
Reference in New Issue
Block a user