cleanup-p02-data.sql 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. -- ============================================================
  2. -- T09 项目:可选清理脚本
  3. -- ============================================================
  4. -- 用途:T09 用 P02 的菜单/字典/角色没问题,但 P02 的业务基础数据
  5. -- (产品/产线/工艺/员工/部门)大概率不适用 T09。本脚本提供
  6. -- 可选清理,按需执行(执行前请确认)。
  7. --
  8. -- 执行方式:
  9. -- mysql -u mes_cloud -p mes_cloud_t09 < cleanup-p02-data.sql
  10. --
  11. -- 强烈建议:先备份,再执行:
  12. -- mysqldump -u root -p --default-character-set=utf8mb4 mes_cloud_t09 > backup_before_cleanup.sql
  13. -- ============================================================
  14. USE mes_cloud_t09;
  15. SET FOREIGN_KEY_CHECKS = 0;
  16. -- ----------------------------------------
  17. -- 1. 业务基础数据(T09 必清)
  18. -- ----------------------------------------
  19. -- mes_icons 是菜单功能图标定义,T09 复用 P02 的,不要清
  20. -- 产品/产线/工艺:T09 重新录入
  21. TRUNCATE TABLE mes_product;
  22. TRUNCATE TABLE mes_product_model;
  23. TRUNCATE TABLE mes_line;
  24. TRUNCATE TABLE mes_line_process;
  25. TRUNCATE TABLE mes_line_process_material;
  26. TRUNCATE TABLE mes_line_process_user;
  27. TRUNCATE TABLE mes_process_product;
  28. TRUNCATE TABLE mes_process_check;
  29. TRUNCATE TABLE mes_process_check_record;
  30. TRUNCATE TABLE mes_process_check_record_items;
  31. -- 班次/生产组:T09 按实际工厂组织重建
  32. TRUNCATE TABLE mes_shift;
  33. TRUNCATE TABLE mes_group;
  34. TRUNCATE TABLE mes_group_oprno;
  35. TRUNCATE TABLE mes_group_user;
  36. TRUNCATE TABLE mes_user_skill;
  37. TRUNCATE TABLE mes_skill;
  38. -- 客户:T09 业主就一个广汽埃安,旧客户清掉
  39. TRUNCATE TABLE mes_customer;
  40. -- 模板:返工/检验模板按 T09 实际场景配
  41. TRUNCATE TABLE mes_template;
  42. TRUNCATE TABLE mes_template_items;
  43. TRUNCATE TABLE mes_template_items_copy;
  44. TRUNCATE TABLE mes_repair_items;
  45. -- 报警/审批/审核流程:按 T09 流程重配
  46. TRUNCATE TABLE mes_process_alarm;
  47. TRUNCATE TABLE mes_apply;
  48. TRUNCATE TABLE mes_approval;
  49. TRUNCATE TABLE mes_approval_node;
  50. -- 大屏计划:按 T09 配
  51. TRUNCATE TABLE mes_screen_plan;
  52. -- 设备状态历史:T09 从 0 开始
  53. TRUNCATE TABLE mes_device_state;
  54. -- ----------------------------------------
  55. -- 2. 用户/组织(建议保留管理员,清掉 P02 员工)
  56. -- ----------------------------------------
  57. -- 仅保留 system 超管账号,清掉 P02 现场员工
  58. DELETE FROM js_sys_user_role WHERE user_code NOT IN ('system');
  59. DELETE FROM js_sys_user_data_scope WHERE user_code NOT IN ('system');
  60. DELETE FROM js_sys_employee_office WHERE emp_code NOT IN ('system');
  61. DELETE FROM js_sys_employee_post WHERE emp_code NOT IN ('system');
  62. DELETE FROM js_sys_employee WHERE emp_code NOT IN ('system');
  63. DELETE FROM js_sys_user WHERE user_code NOT IN ('system');
  64. -- 公司/部门:T09 重建。如要保留某个,注释掉对应行
  65. -- TRUNCATE TABLE js_sys_company;
  66. -- TRUNCATE TABLE js_sys_company_office;
  67. -- TRUNCATE TABLE js_sys_office;
  68. -- TRUNCATE TABLE js_sys_post;
  69. -- ----------------------------------------
  70. -- 3. 框架代码生成器残留(可选清理)
  71. -- ----------------------------------------
  72. -- TRUNCATE TABLE js_gen_table;
  73. -- TRUNCATE TABLE js_gen_table_column;
  74. SET FOREIGN_KEY_CHECKS = 1;
  75. SELECT '清理完成。下一步:用 system / 默认密码登录 T09 后台,重建组织/产品/产线' AS msg;