You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

150 lines
5.6 KiB

-- 创建 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
);
INSERT INTO sys_settings (id, parent_id, name, code, value1, value2, value3)
VALUES
(1, -1, '加热区域配置', 'heat_area', '坐标', '硬件代号', '' ),
(2, 1, 'A1', 'heat_area_A1', '1,1,1', '', ''),
(3, 1, 'A2', 'heat_area_A2', '2,2,2', '', ''),
(4, 1, 'A3', 'heat_area_A3', '3,3,3', '', ''),
(5, 1, 'A4', 'heat_area_A4', '4,4,4', '', ''),
(6, 1, 'A5', 'heat_area_A5', '5,5,5', '', ''),
(7, 1, 'A6', 'heat_area_A6', '6,6,6', '', ''),
(8, -1, '加液区域配置', 'solution_area', '坐标', '硬件代号', '' ),
(9, 8, '加液区', 'solution_area_A7', '7,7,7', '', '' ),
(10, -1, '拍子区域配置', 'lid_area', '坐标', '硬件代号', '' ),
(11, 10, '拍子存放区', 'lid_area_A8', '8,8,8', '', '' ),
(12, -1, '其他系统配置', 'sys_setting', '系统配置的值', '', '' ),
(13, 12, '溶液量低提示', 'sys_setting_volume', '300', '', '' ),
(14, 12, '异常处理区', 'sys_setting_abnormal_area', '7' , '', ''),
(15, 12, '设备信息', 'sys_setting_info', '12345' , '', '');
-- 创建 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 "main"."ores" ("id", "name", "create_time", "update_time") VALUES (1, '金矿石', '2025-02-18 02:47:35', '2025-02-18 02:47:35');
INSERT INTO "main"."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
);
-- 创建 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, null, '1', 100, 0),
(2, 0, null, '2', 100, 0),
(3, 0, null, '3', 100, 0),
(4, 0, null, '4', 100, 0),
(5, 0, null, '5', 100, 0),
(6, 0, null, '6', 100, 0),
(7, 0, null, '7', 100, 0),
(8, 0, null, '8', 100, 0),
(9, 1, null, '9', 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
);