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.
232 lines
9.7 KiB
232 lines
9.7 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', 1, 0),
|
|
('john_doe', 'John Doe', 'password123', 'avatar1.png', 2, 0),
|
|
('test', 'test', 'test123', 'avatar2.png', 3, 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'),
|
|
('测试用户', 'TEST');
|
|
|
|
-- 创建 系统配置 表
|
|
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":"moveToHeat"},{"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":"moveToHeat"},{"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":"moveToHeat"},{"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', 5000, 0),
|
|
(2, 0, 2, 'P002', 5000, 2500),
|
|
(3, 0, 3, 'P003', 5000, 2600),
|
|
(4, 0, 4, 'P004', 5000, 4000),
|
|
(5, 0, 5, 'P005', 5000, 2400),
|
|
(6, 0, 6, 'P006', 5000, 4500),
|
|
(7, 0, 7, 'P007', 5000, 4900),
|
|
(8, 0, 3, 'P008', 5000, 100),
|
|
(9, 1, null, 'P009', 5000, 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,
|
|
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
-- 创建 ctrl_func 设备控制方法记录表
|
|
CREATE TABLE ctrl_func
|
|
(
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
name TEXT NOT NULL,
|
|
func_cmd TEXT NOT NULL,
|
|
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
INSERT INTO ctrl_func (name, func_cmd)
|
|
VALUES ('开门', 'openDoor'),
|
|
('关门', 'closeDoor'),
|
|
('张开夹爪', 'openClaw'),
|
|
('收合夹爪', 'closeClaw'),
|
|
('移至加热区', 'moveToHeatArea'),
|
|
('移动单个试管', 'moveTube'),
|
|
('移至加液区', 'moveToActionArea'),
|
|
('拍照', 'takePhoto'),
|
|
('开始加热', 'startHeat'),
|
|
('停止加热', 'stopHeat'),
|
|
('开始摇匀', 'startShakeUp'),
|
|
('结束摇匀', 'stopShakeUp'),
|
|
('添加溶液', 'injectFluid'),
|
|
('机械臂移动至指定坐标', 'moveMachineArm'),
|
|
('抬起托盘', 'upTray'),
|
|
('降下托盘', 'downTray');
|
|
|
|
|
|
-- 创建 ctrl_func_step 设备控制方法步骤表,params为null的话会从传入参数获取
|
|
CREATE TABLE ctrl_func_step
|
|
(
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
func_cmd TEXT NOT NULL,
|
|
device_cmd TEXT NOT NULL,
|
|
params TEXT,
|
|
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
INSERT INTO ctrl_func_step (func_cmd, device_cmd, params)
|
|
VALUES ('openDoor', 'openDoor', null),
|
|
('openDoor', 'openDoor', null),
|
|
('openDoor', 'openDoor', null);
|