feat: add inspection task lifecycle controls
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { int, mysqlEnum, mysqlTable, text, timestamp, varchar, bigint, json } from "drizzle-orm/mysql-core";
|
||||
import { int, mysqlEnum, mysqlTable, text, timestamp, varchar, bigint, json, uniqueIndex } from "drizzle-orm/mysql-core";
|
||||
|
||||
// ─── 用户表(保持不变) ────────────────────────────────────────────────────────
|
||||
|
||||
@@ -106,10 +106,14 @@ export const inspectionTasks = mysqlTable("inspection_tasks", {
|
||||
name: varchar("name", { length: 255 }).notNull(),
|
||||
inspector: varchar("inspector", { length: 100 }),
|
||||
notes: text("notes"),
|
||||
status: mysqlEnum("status", ["pending", "processing", "completed", "error"]).default("pending").notNull(),
|
||||
status: mysqlEnum("status", ["created", "pending", "processing", "completed", "error"]).default("created").notNull(),
|
||||
createdAt: timestamp("createdAt").defaultNow().notNull(),
|
||||
updatedAt: timestamp("updatedAt").defaultNow().onUpdateNow().notNull(),
|
||||
completedAt: timestamp("completedAt"),
|
||||
}, (table) => {
|
||||
return {
|
||||
modelNameUnique: uniqueIndex("uk_inspection_tasks_model_name").on(table.modelId, table.name),
|
||||
};
|
||||
});
|
||||
|
||||
export type InspectionTask = typeof inspectionTasks.$inferSelect;
|
||||
@@ -158,7 +162,7 @@ export const taskAnalysisResults = mysqlTable("task_analysis_results", {
|
||||
pluginId: varchar("pluginId", { length: 64 }),
|
||||
/** 算法 result.json 的 schema 版本,便于回放时严格校验 */
|
||||
schemaVersion: int("schemaVersion"),
|
||||
status: mysqlEnum("status", ["pending", "processing", "completed", "error"]).default("pending").notNull(),
|
||||
status: mysqlEnum("status", ["pending", "processing", "completed", "error", "cancelled"]).default("pending").notNull(),
|
||||
errorStats: json("errorStats"), // { min, max, mean, stdDev, totalPoints, withinTolerance, outOfTolerance }
|
||||
measurements: json("measurements"), // [{ name, value, unit, tolerance, status }]
|
||||
resultData: json("resultData"), // 其他分析数据(如压缩比等)
|
||||
|
||||
Reference in New Issue
Block a user