From 5bbf6b97525dd92c81fe91447953e7819f8a4e18 Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期一, 17 八月 2026 16:49:46 +0800
Subject: [PATCH] 上级账户可以将下属账户添加的团队成员退出团队

---
 docs/clean_business_data.sql |  330 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 330 insertions(+), 0 deletions(-)

diff --git a/docs/clean_business_data.sql b/docs/clean_business_data.sql
new file mode 100644
index 0000000..3f41649
--- /dev/null
+++ b/docs/clean_business_data.sql
@@ -0,0 +1,330 @@
+-- =============================================
+-- 涓氬姟鏁版嵁娓呯悊瀛樺偍杩囩▼
+-- 璇存槑锛�
+--   1. 浠呮竻鐞嗐�愪笟鍔″崟鎹�/杩愯鏁版嵁銆戯紝淇濈暀銆愬熀纭�鏁版嵁/閰嶇疆/涓绘暟鎹��
+--   2. 淇濈暀鑼冨洿锛欱PM 閰嶇疆銆丅I 澶у睆銆丟oView 澶у睆銆佸瓧鍏�/鑿滃崟/瑙掕壊/鐢ㄦ埛銆�
+--      鐗╂枡/鍒嗙被/鍗曚綅/浠撳簱/搴撲綅/杞﹂棿/宸ヤ綔绔�/璁惧/宸ュ叿/宸ュ簭/宸ヨ壓/璐ㄦ鏂规/缂洪櫡/鎸囨爣銆�
+--      缂栫爜瑙勫垯銆佹潯鐮侀厤缃�佸畨鐏厤缃�佺彮缁勬帓鐝�丅OM/SOP/SIP銆�
+--      CRM 瀹㈡埛/鑱旂郴浜�/鍟嗘満鐘舵��/鍚堝悓閰嶇疆/瀹㈡埛闄愬埗/鍏捣閰嶇疆銆�
+--      ERP 渚涘簲鍟�/缁撶畻璐︽埛銆丼RM 渚涘簲鍟嗕富琛�/鍒嗙被/鎷涙姇鏍囬厤缃��
+--      HRM 鍛樺伐妗f鍙婅�冨嫟/钖祫/绀句繚/绋庣巼閰嶇疆銆丄I 妯″瀷/宸ュ叿/瑙掕壊/鐭ヨ瘑搴�/宸ヤ綔娴併��
+--      IM 鏁忔劅璇�/琛ㄦ儏鍖呫�侀�氱煡鍏憡鍐呭銆佺郴缁熸潈闄愮敤鎴蜂綋绯荤瓑
+--   3. 鑻ュ瓨鍌ㄨ繃绋嬪凡瀛樺湪锛岃鍏堟墽琛� DROP PROCEDURE sp_clean_business_data; 鍐嶆墽琛屾湰鑴氭湰
+-- =============================================
+
+CREATE DEFINER=`root`@`%` PROCEDURE `sp_clean_business_data`()
+BEGIN
+    SET FOREIGN_KEY_CHECKS = 0;
+
+    -- ============================================================
+    -- 1. 绯荤粺杩愯鏁版嵁锛堟棩蹇� / Token / 楠岃瘉鐮� / 绔欏唴淇� / 绀句氦缁戝畾锛�
+    -- ============================================================
+    TRUNCATE TABLE system_login_log;
+    TRUNCATE TABLE system_operate_log;
+    TRUNCATE TABLE system_notify_message;
+    TRUNCATE TABLE system_oauth2_access_token;
+    TRUNCATE TABLE system_oauth2_refresh_token;
+    TRUNCATE TABLE system_oauth2_code;
+    TRUNCATE TABLE system_oauth2_approve;
+    TRUNCATE TABLE system_sms_code;
+    TRUNCATE TABLE system_sms_log;
+    TRUNCATE TABLE system_mail_log;
+    TRUNCATE TABLE system_social_user;
+    TRUNCATE TABLE system_social_user_bind;
+    TRUNCATE TABLE infra_api_access_log;
+    TRUNCATE TABLE infra_api_error_log;
+    TRUNCATE TABLE infra_job_log;
+
+    -- ============================================================
+    -- 2. 鏂囦欢涓庨檮浠�
+    -- ============================================================
+    TRUNCATE TABLE system_storage_attachment;
+    TRUNCATE TABLE system_storage_blob;
+    TRUNCATE TABLE storage_attachment;
+    TRUNCATE TABLE storage_blob;
+    TRUNCATE TABLE infra_file;
+    TRUNCATE TABLE infra_file_content;
+
+    -- ============================================================
+    -- 3. BPM 娴佺▼瀹炰緥涓庡鎵瑰巻鍙�
+    --    淇濈暀锛氭祦绋嬪畾涔�/琛ㄥ崟/鍒嗙被/琛ㄨ揪寮�/鐩戝惉鍣�/鐢ㄦ埛缁�/涓氬姟闄勪欢閰嶇疆
+    -- ============================================================
+    TRUNCATE TABLE bpm_oa_leave;
+    TRUNCATE TABLE bpm_process_instance_copy;
+    TRUNCATE TABLE act_hi_procinst;
+    TRUNCATE TABLE act_hi_taskinst;
+    TRUNCATE TABLE act_hi_actinst;
+    TRUNCATE TABLE act_hi_varinst;
+    TRUNCATE TABLE act_hi_identitylink;
+    TRUNCATE TABLE act_hi_comment;
+    TRUNCATE TABLE act_hi_detail;
+    TRUNCATE TABLE act_hi_attachment;
+    TRUNCATE TABLE act_hi_entitylink;
+    TRUNCATE TABLE act_hi_tsk_log;
+    TRUNCATE TABLE act_ru_task;
+    TRUNCATE TABLE act_ru_execution;
+    TRUNCATE TABLE act_ru_actinst;
+    TRUNCATE TABLE act_ru_variable;
+    TRUNCATE TABLE act_ru_identitylink;
+    TRUNCATE TABLE act_ru_job;
+    TRUNCATE TABLE act_ru_timer_job;
+    TRUNCATE TABLE act_ru_deadletter_job;
+    TRUNCATE TABLE act_ru_suspended_job;
+    TRUNCATE TABLE act_ru_external_job;
+    TRUNCATE TABLE act_ru_history_job;
+    TRUNCATE TABLE act_ru_event_subscr;
+    TRUNCATE TABLE act_ru_entitylink;
+    TRUNCATE TABLE act_evt_log;
+
+    -- ============================================================
+    -- 4. MES 鐢熶骇妯″潡 鈥� 涓氬姟鍗曟嵁
+    -- ============================================================
+    TRUNCATE TABLE mes_pro_work_order_param_record_detail;
+    TRUNCATE TABLE mes_pro_work_order_param_record;
+    TRUNCATE TABLE mes_pro_work_order_process;
+    TRUNCATE TABLE mes_pro_work_order_bom;
+    TRUNCATE TABLE mes_pro_work_order;
+    TRUNCATE TABLE mes_pro_task_issue;
+    TRUNCATE TABLE mes_pro_task;
+    TRUNCATE TABLE mes_pro_feedback;
+    TRUNCATE TABLE mes_pro_mps_merge_item;
+    TRUNCATE TABLE mes_pro_mps;
+    TRUNCATE TABLE mes_pro_card_process;
+    TRUNCATE TABLE mes_pro_card;
+    TRUNCATE TABLE mes_pro_work_record_log;
+    TRUNCATE TABLE mes_pro_work_record;
+    TRUNCATE TABLE mes_pro_andon_record;
+
+    -- ============================================================
+    -- 5. MES 浠撳簱妯″潡 鈥� 涓氬姟鍗曟嵁
+    -- ============================================================
+    TRUNCATE TABLE mes_wm_transaction;
+    TRUNCATE TABLE mes_wm_stock_reserve;
+    TRUNCATE TABLE mes_wm_material_stock;
+    TRUNCATE TABLE mes_wm_sn;
+    TRUNCATE TABLE mes_wm_batch;
+    TRUNCATE TABLE mes_wm_barcode;
+    TRUNCATE TABLE mes_wm_stock_taking_task_result;
+    TRUNCATE TABLE mes_wm_stock_taking_task_line;
+    TRUNCATE TABLE mes_wm_stock_taking_task;
+    TRUNCATE TABLE mes_wm_stock_taking_plan_param;
+    TRUNCATE TABLE mes_wm_stock_taking_plan;
+    TRUNCATE TABLE mes_wm_package_line;
+    TRUNCATE TABLE mes_wm_package;
+    TRUNCATE TABLE mes_wm_item_receipt_detail;
+    TRUNCATE TABLE mes_wm_item_receipt_line;
+    TRUNCATE TABLE mes_wm_item_receipt;
+    TRUNCATE TABLE mes_wm_item_consume_detail;
+    TRUNCATE TABLE mes_wm_item_consume_line;
+    TRUNCATE TABLE mes_wm_item_consume;
+    TRUNCATE TABLE mes_wm_product_produce_detail;
+    TRUNCATE TABLE mes_wm_product_produce_line;
+    TRUNCATE TABLE mes_wm_product_produce;
+    TRUNCATE TABLE mes_wm_product_issue_detail;
+    TRUNCATE TABLE mes_wm_product_issue_line;
+    TRUNCATE TABLE mes_wm_product_issue;
+    TRUNCATE TABLE mes_wm_product_receipt_detail;
+    TRUNCATE TABLE mes_wm_product_receipt_line;
+    TRUNCATE TABLE mes_wm_product_receipt;
+    TRUNCATE TABLE mes_wm_product_sales_detail;
+    TRUNCATE TABLE mes_wm_product_sales_line;
+    TRUNCATE TABLE mes_wm_product_sales;
+    TRUNCATE TABLE mes_wm_misc_receipt_detail;
+    TRUNCATE TABLE mes_wm_misc_receipt_line;
+    TRUNCATE TABLE mes_wm_misc_receipt;
+    TRUNCATE TABLE mes_wm_misc_issue_detail;
+    TRUNCATE TABLE mes_wm_misc_issue_line;
+    TRUNCATE TABLE mes_wm_misc_issue;
+    TRUNCATE TABLE mes_wm_outsource_receipt_detail;
+    TRUNCATE TABLE mes_wm_outsource_receipt_line;
+    TRUNCATE TABLE mes_wm_outsource_receipt;
+    TRUNCATE TABLE mes_wm_outsource_issue_detail;
+    TRUNCATE TABLE mes_wm_outsource_issue_line;
+    TRUNCATE TABLE mes_wm_outsource_issue;
+    TRUNCATE TABLE mes_wm_return_vendor_detail;
+    TRUNCATE TABLE mes_wm_return_vendor_line;
+    TRUNCATE TABLE mes_wm_return_vendor;
+    TRUNCATE TABLE mes_wm_return_issue_detail;
+    TRUNCATE TABLE mes_wm_return_issue_line;
+    TRUNCATE TABLE mes_wm_return_issue;
+    TRUNCATE TABLE mes_wm_return_sales_detail;
+    TRUNCATE TABLE mes_wm_return_sales_line;
+    TRUNCATE TABLE mes_wm_return_sales;
+    TRUNCATE TABLE mes_wm_sales_notice_line;
+    TRUNCATE TABLE mes_wm_sales_notice;
+    TRUNCATE TABLE mes_wm_transfer_detail;
+    TRUNCATE TABLE mes_wm_transfer_line;
+    TRUNCATE TABLE mes_wm_transfer;
+    TRUNCATE TABLE mes_wm_arrival_notice_line;
+    TRUNCATE TABLE mes_wm_arrival_notice;
+
+    -- ============================================================
+    -- 6. MES 璐ㄦ妯″潡 鈥� 涓氬姟鍗曟嵁
+    -- ============================================================
+    TRUNCATE TABLE mes_qc_indicator_result_detail;
+    TRUNCATE TABLE mes_qc_indicator_result;
+    TRUNCATE TABLE mes_qc_defect_record;
+    TRUNCATE TABLE mes_qc_ncr;
+    TRUNCATE TABLE mes_qc_iqc_line;
+    TRUNCATE TABLE mes_qc_iqc;
+    TRUNCATE TABLE mes_qc_ipqc_line;
+    TRUNCATE TABLE mes_qc_ipqc;
+    TRUNCATE TABLE mes_qc_oqc_line;
+    TRUNCATE TABLE mes_qc_oqc;
+    TRUNCATE TABLE mes_qc_rqc_line;
+    TRUNCATE TABLE mes_qc_rqc;
+
+    -- ============================================================
+    -- 7. MES 璁惧妯″潡 鈥� 鐐规/淇濆吇/缁翠慨/璁¢噺妫�娴嬭褰�
+    -- ============================================================
+    TRUNCATE TABLE mes_dv_check_record_line;
+    TRUNCATE TABLE mes_dv_check_record;
+    TRUNCATE TABLE mes_dv_mainten_record_line;
+    TRUNCATE TABLE mes_dv_mainten_record;
+    TRUNCATE TABLE mes_dv_repair_line;
+    TRUNCATE TABLE mes_dv_repair;
+    TRUNCATE TABLE mes_dv_metering_check;
+
+    -- ============================================================
+    -- 8. MES 宸ヨ壓/璁捐妯″潡 鈥� 涓氬姟鍗曟嵁锛堢紪鐮佺敓鎴愯褰曚负娴佹按鏁版嵁锛�
+    -- ============================================================
+    TRUNCATE TABLE mes_pd_archive;
+    TRUNCATE TABLE mes_pd_document_audit;
+    TRUNCATE TABLE mes_pd_document;
+    TRUNCATE TABLE mes_pd_project;
+    TRUNCATE TABLE mes_md_auto_code_record;
+
+    -- ============================================================
+    -- 9. CRM 妯″潡 鈥� 涓氬姟鍗曟嵁
+    --    淇濈暀锛歝rm_customer / crm_contact / crm_business_status(_type)
+    --          / crm_contract_config / crm_customer_limit_config / crm_customer_pool_config
+    -- ============================================================
+    TRUNCATE TABLE crm_receivable_plan;
+    TRUNCATE TABLE crm_receivable;
+    TRUNCATE TABLE crm_contract_product;
+    TRUNCATE TABLE crm_contract;
+    TRUNCATE TABLE crm_sale_quotation_product;
+    TRUNCATE TABLE crm_sale_quotation;
+    TRUNCATE TABLE crm_business_product;
+    TRUNCATE TABLE crm_contact_business;
+    TRUNCATE TABLE crm_business;
+    TRUNCATE TABLE crm_clue;
+    TRUNCATE TABLE crm_follow_up_record;
+    TRUNCATE TABLE crm_invoice;
+    TRUNCATE TABLE crm_sales_target;
+    TRUNCATE TABLE crm_permission;
+
+    -- ============================================================
+    -- 10. 鍞悗妯″潡 鈥� 涓氬姟鍗曟嵁
+    -- ============================================================
+    TRUNCATE TABLE after_sale_return_item;
+    TRUNCATE TABLE after_sale_return;
+    TRUNCATE TABLE after_sale_ticket_item;
+    TRUNCATE TABLE after_sale_ticket;
+    TRUNCATE TABLE after_sale_repair;
+    TRUNCATE TABLE after_sale_permission;
+
+    -- ============================================================
+    -- 11. ERP 妯″潡 鈥� 涓氬姟鍗曟嵁
+    --    淇濈暀锛歟rp_supplier / erp_account
+    -- ============================================================
+    TRUNCATE TABLE erp_finance_payment_item;
+    TRUNCATE TABLE erp_finance_payment;
+    TRUNCATE TABLE erp_finance_receipt_item;
+    TRUNCATE TABLE erp_finance_receipt;
+    TRUNCATE TABLE erp_purchase_order_items;
+    TRUNCATE TABLE erp_purchase_order;
+    TRUNCATE TABLE erp_purchase_request_items;
+    TRUNCATE TABLE erp_purchase_request;
+    TRUNCATE TABLE erp_sale_order_items;
+    TRUNCATE TABLE erp_sale_order;
+    TRUNCATE TABLE erp_purchase_invoice;
+
+    -- ============================================================
+    -- 12. SRM 妯″潡 鈥� 涓氬姟鍗曟嵁
+    --    淇濈暀锛歴rm_supplier / srm_supplier_contact / srm_supplier_category
+    --          / srm_tender_config
+    -- ============================================================
+    TRUNCATE TABLE srm_bid_award;
+    TRUNCATE TABLE srm_bid_evaluation;
+    TRUNCATE TABLE srm_bid_open;
+    TRUNCATE TABLE srm_tender_bid;
+    TRUNCATE TABLE srm_tender_material;
+    TRUNCATE TABLE srm_tender_project;
+    TRUNCATE TABLE srm_delivery_plan;
+    TRUNCATE TABLE srm_purchase_collaboration;
+    TRUNCATE TABLE srm_supplier_quote;
+    TRUNCATE TABLE srm_supplier_evaluation;
+    TRUNCATE TABLE srm_supplier_certificate;
+    TRUNCATE TABLE srm_supplier_apply;
+
+    -- ============================================================
+    -- 13. HRM 妯″潡 鈥� 涓氬姟鍗曟嵁
+    --    淇濈暀锛歨rm_employee 鍙婃。妗堝瓙琛紙鏁欒偛/宸ヤ綔缁忓巻/绱ф�ヨ仈绯讳汉/
+    --          绀句繚鍏Н閲�/钖叕妗f/鍚堝悓锛夈�佽�冨嫟鑺傚亣鏃�/瑙勫垯銆佽鍋囩被鍨嬮厤缃��
+    --          钖叕缁撴瀯銆佺ぞ淇濆叕绉噾鏂规銆佷釜绋庣◣鐜囬厤缃�
+    -- ============================================================
+    TRUNCATE TABLE hrm_salary_payment_detail;
+    TRUNCATE TABLE hrm_salary_payment;
+    TRUNCATE TABLE hrm_salary_calculation;
+    TRUNCATE TABLE hrm_attendance_summary;
+    TRUNCATE TABLE hrm_attendance_record;
+    TRUNCATE TABLE hrm_attendance_exception;
+    TRUNCATE TABLE hrm_leave_application;
+    TRUNCATE TABLE hrm_resignation_application;
+    TRUNCATE TABLE hrm_transfer_application;
+
+    -- ============================================================
+    -- 14. AI 妯″潡 鈥� 瀵硅瘽涓庣敓鎴愬唴瀹�
+    --    淇濈暀锛歛i_api_key / ai_model / ai_tool / ai_chat_role
+    --          / ai_knowledge(_document/_segment) / ai_workflow
+    -- ============================================================
+    TRUNCATE TABLE ai_chat_message;
+    TRUNCATE TABLE ai_chat_conversation;
+    TRUNCATE TABLE ai_image;
+    TRUNCATE TABLE ai_mind_map;
+    TRUNCATE TABLE ai_music;
+    TRUNCATE TABLE ai_write;
+
+    -- ============================================================
+    -- 15. IM 妯″潡 鈥� 浼氳瘽涓庢秷鎭�
+    --    淇濈暀锛歩m_sensitive_word / im_face_pack / im_face_pack_item
+    -- ============================================================
+    TRUNCATE TABLE im_group_message_receipt;
+    TRUNCATE TABLE im_group_message;
+    TRUNCATE TABLE im_private_message;
+    TRUNCATE TABLE im_message_file;
+    TRUNCATE TABLE im_group_request;
+    TRUNCATE TABLE im_group_member;
+    TRUNCATE TABLE im_group;
+    TRUNCATE TABLE im_friend_request;
+    TRUNCATE TABLE im_friend;
+    TRUNCATE TABLE im_conversation_read;
+    TRUNCATE TABLE im_conversation;
+    TRUNCATE TABLE im_channel_message;
+    TRUNCATE TABLE im_channel_material;
+    TRUNCATE TABLE im_channel;
+    TRUNCATE TABLE im_rtc_participant;
+    TRUNCATE TABLE im_rtc_call;
+    TRUNCATE TABLE im_user_online;
+    TRUNCATE TABLE im_face_user_item;
+
+    -- ============================================================
+    -- 16. OA 宸茶/鎸囧畾浜哄叧鑱旓紙淇濈暀閫氱煡鍏憡鍐呭 oa_notice / system_notice锛�
+    -- ============================================================
+    TRUNCATE TABLE oa_notice_read;
+    TRUNCATE TABLE oa_notice_user;
+
+    -- ============================================================
+    -- 17. 绀轰緥鏁版嵁
+    -- ============================================================
+    TRUNCATE TABLE yudao_demo01_contact;
+    TRUNCATE TABLE yudao_demo02_category;
+    TRUNCATE TABLE yudao_demo03_course;
+    TRUNCATE TABLE yudao_demo03_grade;
+    TRUNCATE TABLE yudao_demo03_student;
+
+    SET FOREIGN_KEY_CHECKS = 1;
+
+    SELECT '涓氬姟鏁版嵁娓呯悊瀹屾垚' AS result;
+END

--
Gitblit v1.9.3