From a1a9360d97a061570f24758c1a02f2915a21559b Mon Sep 17 00:00:00 2001 From: PengJ <2413927716@qq.com> Date: Wed, 12 Nov 2025 09:58:16 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=BA=94=E6=80=A5=E5=8D=95=E3=80=91?= =?UTF-8?q?=E5=8F=82=E4=B8=8E=E4=BA=BA=E5=91=98=E5=AD=90=E8=A1=A8=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=BF=AE=E5=A4=8Dsql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/sql/修复应急单参与人员子表数据.sql | 42 +++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 db/sql/修复应急单参与人员子表数据.sql diff --git a/db/sql/修复应急单参与人员子表数据.sql b/db/sql/修复应急单参与人员子表数据.sql new file mode 100644 index 0000000..a241d6e --- /dev/null +++ b/db/sql/修复应急单参与人员子表数据.sql @@ -0,0 +1,42 @@ +-- 修复应急单参与人员子表数据 +INSERT INTO emergency_order_operator (id, order_id, operator_type, user_id, join_type, join_date) SELECT + CONCAT(2,LPAD(FLOOR(RAND() * POWER(10, 10)), 10, '0'), LPAD(FLOOR(RAND() * POWER(10, 7)), 7, '0')) AS id, + t.* +FROM + ( + SELECT + id AS order_id, + 0 AS operator_type, + operation_user_id AS user_id, + 0 AS join_type, + operation_response_time AS join_date + FROM + emergency_order + WHERE + operation_user_id IS NOT NULL UNION ALL + SELECT + id AS order_id, + 1 AS operator_type, + major_user_id AS user_id, + 0 AS join_type, + major_response_time AS join_date + FROM + emergency_order + WHERE + major_user_id IS NOT NULL UNION ALL + SELECT + id AS order_id, + 1 AS operator_type, + major_user_two_id AS user_id, + 0 AS join_type, + major_response_time AS join_date + FROM + emergency_order + WHERE + major_user_two_id IS NOT NULL + ) t + LEFT JOIN emergency_order_operator t1 ON t1.order_id = t.order_id + AND t1.user_id = t.user_id + AND t1.operator_type = t.operator_type +WHERE + t1.id IS NULL; \ No newline at end of file