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.

164 lines
7.8 KiB

6 months ago
6 months ago
  1. -- 创建 sys_user 表
  2. CREATE TABLE IF NOT EXISTS sys_user (
  3. id INTEGER PRIMARY KEY AUTOINCREMENT,
  4. username TEXT NOT NULL,
  5. nickname TEXT,
  6. password TEXT NOT NULL,
  7. avatar TEXT,
  8. role INTEGER,
  9. is_deleted INTEGER DEFAULT 0,
  10. create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  11. update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
  12. );
  13. -- 插入测试数据
  14. INSERT INTO sys_user (username, nickname, password, avatar, role, is_deleted)
  15. VALUES
  16. ('admin', 'Admin', '12345', 'admin.png', 0, 0),
  17. ('john_doe', 'John Doe', 'password123', 'avatar1.png', 1, 0),
  18. ('jane_smith', 'Jane Smith', 'password456', 'avatar2.png', 2, 0);
  19. -- 创建 sys_role 表
  20. CREATE TABLE IF NOT EXISTS sys_role (
  21. id INTEGER PRIMARY KEY AUTOINCREMENT,
  22. name TEXT NOT NULL,
  23. code TEXT NOT NULL,
  24. create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  25. update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
  26. );
  27. -- 插入角色数据
  28. INSERT INTO sys_role (name, code)
  29. VALUES
  30. ('管理员', 'ADMIN'),
  31. ('普通用户', 'USER');
  32. -- 创建 系统配置 表
  33. CREATE TABLE IF NOT EXISTS sys_settings (
  34. id INTEGER PRIMARY KEY AUTOINCREMENT,
  35. parent_id INTEGER NOT NULL,
  36. name TEXT NOT NULL,
  37. code TEXT,
  38. value1 TEXT,
  39. value2 TEXT,
  40. value3 TEXT,
  41. value4 TEXT
  42. );
  43. INSERT INTO sys_settings (id, parent_id, name, code, value1, value2, value3, value4)
  44. VALUES
  45. (1, -1, '加热区域配置', 'heat_area', '坐标', '硬件代号', '温度', '工艺id' ),
  46. (2, 1, 'A1', 'heat_area_A1', '1,1,1', 'hardware_1', '1', ''),
  47. (3, 1, 'A2', 'heat_area_A2', '2,2,2', 'hardware_2', '2',''),
  48. (4, 1, 'A3', 'heat_area_A3', '3,3,3', 'hardware_3', '3',''),
  49. (5, 1, 'A4', 'heat_area_A4', '4,4,4', 'hardware_4', '4',''),
  50. (6, 1, 'A5', 'heat_area_A5', '5,5,5', 'hardware_5', '5',''),
  51. (7, 1, 'A6', 'heat_area_A6', '6,6,6', 'hardware_6', '6',''),
  52. (8, -1, '加液区域配置', 'solution_area', '坐标', '硬件代号', '','' ),
  53. (9, 8, '加液区', 'solution_area_A7', '7,7,7', '77', '','' ),
  54. (10, -1, '拍子区域配置', 'lid_area', '坐标', '硬件代号', '' ,''),
  55. (11, 10, '拍子存放区', 'lid_area_A8', '8,8,8', '88', '','' ),
  56. (12, -1, '其他系统配置', 'sys_setting', '系统配置的值', '', '' ,''),
  57. (13, 12, '溶液量低提示', 'sys_setting_volume', '300', '', '',''),
  58. (14, 12, '异常处理区', 'sys_setting_abnormal_area', '7' , '', '',''),
  59. (15, 12, '设备信息', 'sys_setting_info', '12345' , '', '',''),
  60. (16, -1, '偏移量', 'sys_offset', '毫米' , '', '',''),
  61. (17, 16, '试管半径', 'sys_offset_tube_radius', '100' , '', '',''),
  62. (18, 16, '试管圆心间距', 'sys_offset_tube_distance', '100' , '', '',''),
  63. (19, 16, '试管高度', 'sys_offset_tube_height', '300' , '', '',''),
  64. (20, 16, '试管架高度', 'sys_offset_tube_rack_height', '280' , '', '',''),
  65. (21, 16, '拍子高度', 'sys_offset_lid_height', '350' , '', '',''),
  66. (22, 16, '试管夹取高度', 'sys_offset_tube_take_height', '10' , '', '',''),
  67. (23, 16, '拍子夹取高度', 'sys_offset_lid_take_height', '10' , '', '',''),
  68. (24, 16, '试管架夹取高度', 'sys_offset_tube_rack_take_height', '10' , '', '','');
  69. -- 创建 solutions 溶液 表
  70. CREATE TABLE IF NOT EXISTS solutions (
  71. id INTEGER PRIMARY KEY AUTOINCREMENT,
  72. name VARCHAR NOT NULL,
  73. create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  74. update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
  75. );
  76. INSERT INTO "solutions" ("id", "name", "create_time", "update_time") VALUES (1, '硫酸', '2025-02-18 02:44:07', '2025-02-18 02:44:07');
  77. INSERT INTO "solutions" ("id", "name", "create_time", "update_time") VALUES (2, '盐酸', '2025-02-18 02:44:07', '2025-02-18 02:44:07');
  78. INSERT INTO "solutions" ("id", "name", "create_time", "update_time") VALUES (3, '硝酸', '2025-02-18 02:44:07', '2025-02-18 02:44:07');
  79. INSERT INTO "solutions" ("id", "name", "create_time", "update_time") VALUES (4, '氢氟酸', '2025-02-18 02:46:23', '2025-02-18 02:46:23');
  80. INSERT INTO "solutions" ("id", "name", "create_time", "update_time") VALUES (5, '过氧酸', '2025-02-18 02:46:35', '2025-02-18 02:46:35');
  81. INSERT INTO "solutions" ("id", "name", "create_time", "update_time") VALUES (6, '磷酸', '2025-02-18 02:46:43', '2025-02-18 02:46:43');
  82. INSERT INTO "solutions" ("id", "name", "create_time", "update_time") VALUES (7, '纯水', '2025-02-18 02:46:50', '2025-02-18 02:46:50');
  83. -- 创建 ores 矿石 表
  84. CREATE TABLE IF NOT EXISTS ores (
  85. id INTEGER PRIMARY KEY AUTOINCREMENT,
  86. name VARCHAR NOT NULL,
  87. create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  88. update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
  89. );
  90. INSERT INTO "ores" ("id", "name", "create_time", "update_time") VALUES (1, '金矿石', '2025-02-18 02:47:35', '2025-02-18 02:47:35');
  91. INSERT INTO "ores" ("id", "name", "create_time", "update_time") VALUES (2, '银矿石', '2025-02-18 02:47:41', '2025-02-18 02:47:41');
  92. -- 创建 crafts 工艺 表
  93. CREATE TABLE IF NOT EXISTS crafts (
  94. id INTEGER PRIMARY KEY AUTOINCREMENT,
  95. name VARCHAR NOT NULL,
  96. steps TEXT,
  97. ores_id INTEGER,
  98. create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  99. update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
  100. );
  101. 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);
  102. 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);
  103. 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);
  104. -- 创建 tasks 实验
  105. CREATE TABLE IF NOT EXISTS tasks (
  106. id INTEGER PRIMARY KEY AUTOINCREMENT,
  107. name VARCHAR NOT NULL,
  108. start_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  109. end_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  110. status INTEGER,
  111. create_user INTEGER,
  112. create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  113. update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  114. is_deleted INTEGER
  115. );
  116. -- 创建 container 容器
  117. CREATE TABLE IF NOT EXISTS container (
  118. id INTEGER PRIMARY KEY AUTOINCREMENT,
  119. type INTEGER,
  120. solution_id INTEGER,
  121. pump_id TEXT,
  122. capacity_total INTEGER,
  123. capacity_used INTEGER
  124. );
  125. INSERT INTO container (id, type, solution_id, pump_id, capacity_total, capacity_used)
  126. VALUES
  127. (1, 0, 1, 'P001', 100, 0),
  128. (2, 0, 2, 'P002', 100, 0),
  129. (3, 0, 3, 'P003', 100, 0),
  130. (4, 0, 4, 'P004', 100, 0),
  131. (5, 0, 5, 'P005', 100, 0),
  132. (6, 0, 6, 'P006', 100, 0),
  133. (7, 0, 7, 'P007', 100, 0),
  134. (8, 0, 3, 'P008', 100, 0),
  135. (9, 1, null, 'P009', 100, 0);
  136. -- 创建 logs 日志
  137. CREATE TABLE IF NOT EXISTS logs (
  138. id INTEGER PRIMARY KEY AUTOINCREMENT,
  139. text TEXT,
  140. create_user INTEGER,
  141. create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
  142. );
  143. -- 创建 task_steps 步骤记录
  144. CREATE TABLE IF NOT EXISTS task_steps (
  145. id INTEGER PRIMARY KEY AUTOINCREMENT,
  146. task_id INTEGER,
  147. step_description TEXT
  148. );