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.

233 lines
9.8 KiB

6 months ago
6 months ago
  1. -- 创建 sys_user 表
  2. CREATE TABLE IF NOT EXISTS sys_user
  3. (
  4. id INTEGER PRIMARY KEY AUTOINCREMENT,
  5. username TEXT NOT NULL,
  6. nickname TEXT,
  7. password TEXT NOT NULL,
  8. avatar TEXT,
  9. role INTEGER,
  10. is_deleted INTEGER DEFAULT 0,
  11. create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  12. update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
  13. );
  14. -- 插入测试数据
  15. INSERT INTO sys_user (username, nickname, password, avatar, role, is_deleted)
  16. VALUES ('admin', 'Admin', '12345', 'admin.png', 1, 0),
  17. ('john_doe', 'John Doe', 'password123', 'avatar1.png', 2, 0),
  18. ('test', 'test', 'test123', 'avatar2.png', 3, 0);
  19. -- 创建 sys_role 表
  20. CREATE TABLE IF NOT EXISTS sys_role
  21. (
  22. id INTEGER PRIMARY KEY AUTOINCREMENT,
  23. name TEXT NOT NULL,
  24. code TEXT NOT NULL,
  25. create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  26. update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
  27. );
  28. -- 插入角色数据
  29. INSERT INTO sys_role (name, code)
  30. VALUES ('管理员', 'ADMIN'),
  31. ('普通用户', 'USER'),
  32. ('测试用户', 'TEST');
  33. -- 创建 系统配置 表
  34. CREATE TABLE IF NOT EXISTS sys_settings
  35. (
  36. id INTEGER PRIMARY KEY AUTOINCREMENT,
  37. parent_id INTEGER NOT NULL,
  38. name TEXT NOT NULL,
  39. code TEXT,
  40. value1 TEXT,
  41. value2 TEXT,
  42. value3 TEXT,
  43. value4 TEXT
  44. );
  45. INSERT INTO sys_settings (id, parent_id, name, code, value1, value2, value3, value4)
  46. VALUES (1, -1, '加热区域配置', 'heat_area', '坐标', '硬件代号', '温度', '工艺id'),
  47. (2, 1, 'A1', 'heat_area_A1', '1,1,1', 'hardware_1', '1', ''),
  48. (3, 1, 'A2', 'heat_area_A2', '2,2,2', 'hardware_2', '2', ''),
  49. (4, 1, 'A3', 'heat_area_A3', '3,3,3', 'hardware_3', '3', ''),
  50. (5, 1, 'A4', 'heat_area_A4', '4,4,4', 'hardware_4', '4', ''),
  51. (6, 1, 'A5', 'heat_area_A5', '5,5,5', 'hardware_5', '5', ''),
  52. (7, 1, 'A6', 'heat_area_A6', '6,6,6', 'hardware_6', '6', ''),
  53. (8, -1, '加液区域配置', 'solution_area', '坐标', '硬件代号', '', ''),
  54. (9, 8, '加液区', 'solution_area_A7', '7,7,7', '77', '', ''),
  55. (10, -1, '拍子区域配置', 'lid_area', '坐标', '硬件代号', '', ''),
  56. (11, 10, '拍子存放区', 'lid_area_A8', '8,8,8', '88', '', ''),
  57. (12, -1, '其他系统配置', 'sys_setting', '系统配置的值', '', '', ''),
  58. (13, 12, '溶液量低提示', 'sys_setting_volume', '300', '', '', ''),
  59. (14, 12, '异常处理区', 'sys_setting_abnormal_area', '7', '', '', ''),
  60. (15, 12, '设备信息', 'sys_setting_info', '12345', '', '', ''),
  61. (16, -1, '偏移量', 'sys_offset', '毫米', '', '', ''),
  62. (17, 16, '试管半径', 'sys_offset_tube_radius', '100', '', '', ''),
  63. (18, 16, '试管圆心间距', 'sys_offset_tube_distance', '100', '', '', ''),
  64. (19, 16, '试管高度', 'sys_offset_tube_height', '300', '', '', ''),
  65. (20, 16, '试管架高度', 'sys_offset_tube_rack_height', '280', '', '', ''),
  66. (21, 16, '拍子高度', 'sys_offset_lid_height', '350', '', '', ''),
  67. (22, 16, '试管夹取高度', 'sys_offset_tube_take_height', '10', '', '', ''),
  68. (23, 16, '拍子夹取高度', 'sys_offset_lid_take_height', '10', '', '', ''),
  69. (24, 16, '试管架夹取高度', 'sys_offset_tube_rack_take_height', '10', '', '', '');
  70. -- 创建 solutions 溶液 表
  71. CREATE TABLE IF NOT EXISTS solutions
  72. (
  73. id INTEGER PRIMARY KEY AUTOINCREMENT,
  74. name VARCHAR NOT NULL,
  75. create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  76. update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
  77. );
  78. INSERT INTO "solutions" ("id", "name", "create_time", "update_time")
  79. VALUES (1, '硫酸', '2025-02-18 02:44:07', '2025-02-18 02:44:07');
  80. INSERT INTO "solutions" ("id", "name", "create_time", "update_time")
  81. VALUES (2, '盐酸', '2025-02-18 02:44:07', '2025-02-18 02:44:07');
  82. INSERT INTO "solutions" ("id", "name", "create_time", "update_time")
  83. VALUES (3, '硝酸', '2025-02-18 02:44:07', '2025-02-18 02:44:07');
  84. INSERT INTO "solutions" ("id", "name", "create_time", "update_time")
  85. VALUES (4, '氢氟酸', '2025-02-18 02:46:23', '2025-02-18 02:46:23');
  86. INSERT INTO "solutions" ("id", "name", "create_time", "update_time")
  87. VALUES (5, '过氧酸', '2025-02-18 02:46:35', '2025-02-18 02:46:35');
  88. INSERT INTO "solutions" ("id", "name", "create_time", "update_time")
  89. VALUES (6, '磷酸', '2025-02-18 02:46:43', '2025-02-18 02:46:43');
  90. INSERT INTO "solutions" ("id", "name", "create_time", "update_time")
  91. VALUES (7, '纯水', '2025-02-18 02:46:50', '2025-02-18 02:46:50');
  92. -- 创建 ores 矿石 表
  93. CREATE TABLE IF NOT EXISTS ores
  94. (
  95. id INTEGER PRIMARY KEY AUTOINCREMENT,
  96. name VARCHAR NOT NULL,
  97. create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  98. update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
  99. );
  100. INSERT INTO "ores" ("id", "name", "create_time", "update_time")
  101. VALUES (1, '金矿石', '2025-02-18 02:47:35', '2025-02-18 02:47:35');
  102. INSERT INTO "ores" ("id", "name", "create_time", "update_time")
  103. VALUES (2, '银矿石', '2025-02-18 02:47:41', '2025-02-18 02:47:41');
  104. -- 创建 crafts 工艺 表
  105. CREATE TABLE IF NOT EXISTS crafts
  106. (
  107. id INTEGER PRIMARY KEY AUTOINCREMENT,
  108. name VARCHAR NOT NULL,
  109. steps TEXT,
  110. ores_id INTEGER,
  111. create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  112. update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
  113. );
  114. INSERT INTO "crafts" ("name", "steps", "ores_id")
  115. VALUES ('测试工艺1',
  116. '[{"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}}]',
  117. 1);
  118. INSERT INTO "crafts" ("name", "steps", "ores_id")
  119. VALUES ('测试工艺2',
  120. '[{"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}}]',
  121. 1);
  122. INSERT INTO "crafts" ("name", "steps", "ores_id")
  123. VALUES ('测试工艺3',
  124. '[{"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}}]',
  125. 1);
  126. -- 创建 tasks 实验
  127. CREATE TABLE IF NOT EXISTS tasks
  128. (
  129. id INTEGER PRIMARY KEY AUTOINCREMENT,
  130. name VARCHAR NOT NULL,
  131. start_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  132. end_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  133. status INTEGER,
  134. create_user INTEGER,
  135. create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  136. update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  137. is_deleted INTEGER
  138. );
  139. -- 创建 container 容器
  140. CREATE TABLE IF NOT EXISTS container
  141. (
  142. id INTEGER PRIMARY KEY AUTOINCREMENT,
  143. type INTEGER,
  144. solution_id INTEGER,
  145. pump_id TEXT,
  146. capacity_total INTEGER,
  147. capacity_used INTEGER
  148. );
  149. INSERT INTO container (id, type, solution_id, pump_id, capacity_total, capacity_used)
  150. VALUES (1, 0, 1, 'P001', 5000, 0),
  151. (2, 0, 2, 'P002', 5000, 2500),
  152. (3, 0, 3, 'P003', 5000, 2600),
  153. (4, 0, 4, 'P004', 5000, 4000),
  154. (5, 0, 5, 'P005', 5000, 2400),
  155. (6, 0, 6, 'P006', 5000, 4500),
  156. (7, 0, 7, 'P007', 5000, 4900),
  157. (8, 0, 3, 'P008', 5000, 100),
  158. (9, 1, null, 'P009', 5000, 0);
  159. -- 创建 logs 日志
  160. CREATE TABLE IF NOT EXISTS logs
  161. (
  162. id INTEGER PRIMARY KEY AUTOINCREMENT,
  163. text TEXT,
  164. create_user INTEGER,
  165. create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
  166. );
  167. -- 创建 task_steps 步骤记录
  168. CREATE TABLE IF NOT EXISTS task_steps
  169. (
  170. id INTEGER PRIMARY KEY AUTOINCREMENT,
  171. task_id INTEGER,
  172. step_description TEXT,
  173. create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
  174. );
  175. -- 创建 ctrl_func 设备控制方法记录表
  176. CREATE TABLE ctrl_func
  177. (
  178. id INTEGER PRIMARY KEY AUTOINCREMENT,
  179. name TEXT NOT NULL,
  180. func_cmd TEXT NOT NULL,
  181. create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  182. update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
  183. );
  184. INSERT INTO ctrl_func (name, func_cmd)
  185. VALUES ('开门', 'openDoor'),
  186. ('关门', 'closeDoor'),
  187. ('张开夹爪', 'openClaw'),
  188. ('收合夹爪', 'closeClaw'),
  189. ('移至加热区', 'moveToHeatArea'),
  190. ('移动单个试管', 'moveTube'),
  191. ('移至加液区', 'moveToActionArea'),
  192. ('拍照', 'takePhoto'),
  193. ('开始加热', 'startHeat'),
  194. ('停止加热', 'stopHeat'),
  195. ('开始摇匀', 'startShakeUp'),
  196. ('结束摇匀', 'stopShakeUp'),
  197. ('添加溶液', 'injectFluid'),
  198. ('机械臂移动至指定坐标', 'moveMachineArm'),
  199. ('抬起托盘', 'upTray'),
  200. ('降下托盘', 'downTray');
  201. -- 创建 ctrl_func_step 设备控制方法步骤表,params为null的话会从传入参数获取
  202. CREATE TABLE ctrl_func_step
  203. (
  204. id INTEGER PRIMARY KEY AUTOINCREMENT,
  205. func_cmd TEXT NOT NULL,
  206. device_cmd TEXT NOT NULL,
  207. remarks TEXT,
  208. params TEXT,
  209. create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  210. update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
  211. );
  212. INSERT INTO ctrl_func_step (func_cmd, device_cmd, remarks, params)
  213. VALUES ('openDoor', 'openDoor', null, null),
  214. ('openDoor', 'openDoor', null, null),
  215. ('openDoor', 'openDoor', null, null);