-- ============================================================ -- T09 项目:可选清理脚本 -- ============================================================ -- 用途:T09 用 P02 的菜单/字典/角色没问题,但 P02 的业务基础数据 -- (产品/产线/工艺/员工/部门)大概率不适用 T09。本脚本提供 -- 可选清理,按需执行(执行前请确认)。 -- -- 执行方式: -- mysql -u mes_cloud -p mes_cloud_t09 < cleanup-p02-data.sql -- -- 强烈建议:先备份,再执行: -- mysqldump -u root -p --default-character-set=utf8mb4 mes_cloud_t09 > backup_before_cleanup.sql -- ============================================================ USE mes_cloud_t09; SET FOREIGN_KEY_CHECKS = 0; -- ---------------------------------------- -- 1. 业务基础数据(T09 必清) -- ---------------------------------------- -- mes_icons 是菜单功能图标定义,T09 复用 P02 的,不要清 -- 产品/产线/工艺:T09 重新录入 TRUNCATE TABLE mes_product; TRUNCATE TABLE mes_product_model; TRUNCATE TABLE mes_line; TRUNCATE TABLE mes_line_process; TRUNCATE TABLE mes_line_process_material; TRUNCATE TABLE mes_line_process_user; TRUNCATE TABLE mes_process_product; TRUNCATE TABLE mes_process_check; TRUNCATE TABLE mes_process_check_record; TRUNCATE TABLE mes_process_check_record_items; -- 班次/生产组:T09 按实际工厂组织重建 TRUNCATE TABLE mes_shift; TRUNCATE TABLE mes_group; TRUNCATE TABLE mes_group_oprno; TRUNCATE TABLE mes_group_user; TRUNCATE TABLE mes_user_skill; TRUNCATE TABLE mes_skill; -- 客户:T09 业主就一个广汽埃安,旧客户清掉 TRUNCATE TABLE mes_customer; -- 模板:返工/检验模板按 T09 实际场景配 TRUNCATE TABLE mes_template; TRUNCATE TABLE mes_template_items; TRUNCATE TABLE mes_template_items_copy; TRUNCATE TABLE mes_repair_items; -- 报警/审批/审核流程:按 T09 流程重配 TRUNCATE TABLE mes_process_alarm; TRUNCATE TABLE mes_apply; TRUNCATE TABLE mes_approval; TRUNCATE TABLE mes_approval_node; -- 大屏计划:按 T09 配 TRUNCATE TABLE mes_screen_plan; -- 设备状态历史:T09 从 0 开始 TRUNCATE TABLE mes_device_state; -- ---------------------------------------- -- 2. 用户/组织(建议保留管理员,清掉 P02 员工) -- ---------------------------------------- -- 仅保留 system 超管账号,清掉 P02 现场员工 DELETE FROM js_sys_user_role WHERE user_code NOT IN ('system'); DELETE FROM js_sys_user_data_scope WHERE user_code NOT IN ('system'); DELETE FROM js_sys_employee_office WHERE emp_code NOT IN ('system'); DELETE FROM js_sys_employee_post WHERE emp_code NOT IN ('system'); DELETE FROM js_sys_employee WHERE emp_code NOT IN ('system'); DELETE FROM js_sys_user WHERE user_code NOT IN ('system'); -- 公司/部门:T09 重建。如要保留某个,注释掉对应行 -- TRUNCATE TABLE js_sys_company; -- TRUNCATE TABLE js_sys_company_office; -- TRUNCATE TABLE js_sys_office; -- TRUNCATE TABLE js_sys_post; -- ---------------------------------------- -- 3. 框架代码生成器残留(可选清理) -- ---------------------------------------- -- TRUNCATE TABLE js_gen_table; -- TRUNCATE TABLE js_gen_table_column; SET FOREIGN_KEY_CHECKS = 1; SELECT '清理完成。下一步:用 system / 默认密码登录 T09 后台,重建组织/产品/产线' AS msg;