-- 创建 sys_user 表 CREATE TABLE IF NOT EXISTS sys_user ( id INTEGER PRIMARY KEY AUTOINCREMENT, username TEXT NOT NULL, nickname TEXT, password TEXT NOT NULL, avatar TEXT, role INTEGER, is_deleted INTEGER DEFAULT 0, create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); -- 插入测试数据 INSERT INTO sys_user (username, nickname, password, avatar, role, is_deleted) VALUES ('admin', 'Admin', '12345', 'admin.png', 0, 0), ('john_doe', 'John Doe', 'password123', 'avatar1.png', 1, 0), ('jane_smith', 'Jane Smith', 'password456', 'avatar2.png', 2, 0); -- 创建 sys_role 表 CREATE TABLE IF NOT EXISTS sys_role ( id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, code TEXT NOT NULL, create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); -- 插入角色数据 INSERT INTO sys_role (name, code) VALUES ('管理员', 'ADMIN'), ('普通用户', 'USER'); -- 创建 系统配置 表 CREATE TABLE IF NOT EXISTS sys_settings ( id INTEGER PRIMARY KEY AUTOINCREMENT, parent_id INTEGER NOT NULL, name TEXT NOT NULL, code TEXT, value1 TEXT, value2 TEXT, value3 TEXT, value4 TEXT ); INSERT INTO sys_settings (id, parent_id, name, code, value1, value2, value3, value4) VALUES (1, -1, '加热区域配置', 'heat_area', '坐标', '硬件代号', '温度', '工艺id' ), (2, 1, 'A1', 'heat_area_A1', '1,1,1', 'hardware_1', '1', ''), (3, 1, 'A2', 'heat_area_A2', '2,2,2', 'hardware_2', '2',''), (4, 1, 'A3', 'heat_area_A3', '3,3,3', 'hardware_3', '3',''), (5, 1, 'A4', 'heat_area_A4', '4,4,4', 'hardware_4', '4',''), (6, 1, 'A5', 'heat_area_A5', '5,5,5', 'hardware_5', '5',''), (7, 1, 'A6', 'heat_area_A6', '6,6,6', 'hardware_6', '6',''), (8, -1, '加液区域配置', 'solution_area', '坐标', '硬件代号', '','' ), (9, 8, '加液区', 'solution_area_A7', '7,7,7', '77', '','' ), (10, -1, '拍子区域配置', 'lid_area', '坐标', '硬件代号', '' ,''), (11, 10, '拍子存放区', 'lid_area_A8', '8,8,8', '88', '','' ), (12, -1, '其他系统配置', 'sys_setting', '系统配置的值', '', '' ,''), (13, 12, '溶液量低提示', 'sys_setting_volume', '300', '', '',''), (14, 12, '异常处理区', 'sys_setting_abnormal_area', '7' , '', '',''), (15, 12, '设备信息', 'sys_setting_info', '12345' , '', '',''), (16, -1, '偏移量', 'sys_offset', '毫米' , '', '',''), (17, 16, '试管半径', 'sys_offset_tube_radius', '100' , '', '',''), (18, 16, '试管圆心间距', 'sys_offset_tube_distance', '100' , '', '',''), (19, 16, '试管高度', 'sys_offset_tube_height', '300' , '', '',''), (20, 16, '试管架高度', 'sys_offset_tube_rack_height', '280' , '', '',''), (21, 16, '拍子高度', 'sys_offset_lid_height', '350' , '', '',''), (22, 16, '试管夹取高度', 'sys_offset_tube_take_height', '10' , '', '',''), (23, 16, '拍子夹取高度', 'sys_offset_lid_take_height', '10' , '', '',''), (24, 16, '试管架夹取高度', 'sys_offset_tube_rack_take_height', '10' , '', '',''); -- 创建 solutions 溶液 表 CREATE TABLE IF NOT EXISTS solutions ( id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR NOT NULL, create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); INSERT INTO "solutions" ("id", "name", "create_time", "update_time") VALUES (1, '硫酸', '2025-02-18 02:44:07', '2025-02-18 02:44:07'); INSERT INTO "solutions" ("id", "name", "create_time", "update_time") VALUES (2, '盐酸', '2025-02-18 02:44:07', '2025-02-18 02:44:07'); INSERT INTO "solutions" ("id", "name", "create_time", "update_time") VALUES (3, '硝酸', '2025-02-18 02:44:07', '2025-02-18 02:44:07'); INSERT INTO "solutions" ("id", "name", "create_time", "update_time") VALUES (4, '氢氟酸', '2025-02-18 02:46:23', '2025-02-18 02:46:23'); INSERT INTO "solutions" ("id", "name", "create_time", "update_time") VALUES (5, '过氧酸', '2025-02-18 02:46:35', '2025-02-18 02:46:35'); INSERT INTO "solutions" ("id", "name", "create_time", "update_time") VALUES (6, '磷酸', '2025-02-18 02:46:43', '2025-02-18 02:46:43'); INSERT INTO "solutions" ("id", "name", "create_time", "update_time") VALUES (7, '纯水', '2025-02-18 02:46:50', '2025-02-18 02:46:50'); -- 创建 ores 矿石 表 CREATE TABLE IF NOT EXISTS ores ( id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR NOT NULL, create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); INSERT INTO "ores" ("id", "name", "create_time", "update_time") VALUES (1, '金矿石', '2025-02-18 02:47:35', '2025-02-18 02:47:35'); INSERT INTO "ores" ("id", "name", "create_time", "update_time") VALUES (2, '银矿石', '2025-02-18 02:47:41', '2025-02-18 02:47:41'); -- 创建 crafts 工艺 表 CREATE TABLE IF NOT EXISTS crafts ( id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR NOT NULL, steps TEXT, ores_id INTEGER, create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); INSERT INTO "crafts" ("name", "steps", "ores_id") VALUES ('测试工艺1', '[{"method":"upTray"},{"method":"downTray"},{"method":"addLiquid","params":{"tubeSolList":[{"tubeNum":15,"addLiquidList":[{"solId":15,"volume":20}]}]}},{"method":"moveToSol"},{"method":"moveToHeater"},{"method":"shaking","params":{"second":6}},{"method":"startHeating","params":{"temperature":200}},{"method":"stopHeating"},{"method":"takePhoto"},{"method":"delay","params":{"second":2}}]', 1); INSERT INTO "crafts" ("name", "steps", "ores_id") VALUES ('测试工艺2', '[{"method":"upTray"},{"method":"downTray"},{"method":"addLiquid","params":{"tubeSolList":[{"tubeNum":15,"addLiquidList":[{"solId":15,"volume":20}]}]}},{"method":"moveToSol"},{"method":"moveToHeater"},{"method":"shaking","params":{"second":6}},{"method":"startHeating","params":{"temperature":200}},{"method":"stopHeating"},{"method":"takePhoto"},{"method":"delay","params":{"second":2}}]', 1); INSERT INTO "crafts" ("name", "steps", "ores_id") VALUES ('测试工艺3', '[{"method":"upTray"},{"method":"downTray"},{"method":"addLiquid","params":{"tubeSolList":[{"tubeNum":15,"addLiquidList":[{"solId":15,"volume":20}]}]}},{"method":"moveToSol"},{"method":"moveToHeater"},{"method":"shaking","params":{"second":6}},{"method":"startHeating","params":{"temperature":200}},{"method":"stopHeating"},{"method":"takePhoto"},{"method":"delay","params":{"second":2}}]', 1); -- 创建 tasks 实验 CREATE TABLE IF NOT EXISTS tasks ( id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR NOT NULL, start_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, end_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, status INTEGER, create_user INTEGER, create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, is_deleted INTEGER ); -- 创建 container 容器 CREATE TABLE IF NOT EXISTS container ( id INTEGER PRIMARY KEY AUTOINCREMENT, type INTEGER, solution_id INTEGER, pump_id TEXT, capacity_total INTEGER, capacity_used INTEGER ); INSERT INTO container (id, type, solution_id, pump_id, capacity_total, capacity_used) VALUES (1, 0, 1, 'P001', 100, 0), (2, 0, 2, 'P002', 100, 0), (3, 0, 3, 'P003', 100, 0), (4, 0, 4, 'P004', 100, 0), (5, 0, 5, 'P005', 100, 0), (6, 0, 6, 'P006', 100, 0), (7, 0, 7, 'P007', 100, 0), (8, 0, 3, 'P008', 100, 0), (9, 1, null, 'P009', 100, 0); -- 创建 logs 日志 CREATE TABLE IF NOT EXISTS logs ( id INTEGER PRIMARY KEY AUTOINCREMENT, text TEXT, create_user INTEGER, create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); -- 创建 task_steps 步骤记录 CREATE TABLE IF NOT EXISTS task_steps ( id INTEGER PRIMARY KEY AUTOINCREMENT, task_id INTEGER, step_description TEXT );