Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
dj
/
dealaccountdata
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 29cd9e90
authored
May 14, 2026
by
林冲
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
解决字符关联报错merchant_goods_code_processor.py
1 parent
436f52e3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
scene_refactor_data/merchant_goods_code_processor.py
scene_refactor_data/merchant_goods_code_processor.py
View file @
29cd9e9
...
...
@@ -93,16 +93,16 @@ class MerchantGoodsCodeProcessor:
# 4. 批量查询键临时表(内存表,用于JOIN优化)
create_query_keys_sql
=
f
"""
CREATE TABLE IF NOT EXISTS {self.query_keys_table} (
merchant_id BIGINT
NOT NULL
,
base_scene_code VARCHAR(20)
NOT NULL
,
upgrade_goods_id BIGINT
NOT NULL
,
merchant_id BIGINT,
base_scene_code VARCHAR(20)
COLLATE utf8mb4_unicode_ci
,
upgrade_goods_id BIGINT,
settle_rule_id BIGINT,
division_rule_id BIGINT,
reconciliation_rule_id BIGINT,
KEY idx_merchant_goods (merchant_id, base_scene_code, upgrade_goods_id),
KEY idx_finance (settle_rule_id, division_rule_id, base_scene_code, upgrade_goods_id),
KEY idx_reconciliation (reconciliation_rule_id, base_scene_code, upgrade_goods_id)
) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COMMENT='批量查询键临时表';
) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 CO
LLATE=utf8mb4_unicode_ci CO
MMENT='批量查询键临时表';
"""
self
.
db
.
execute_update
(
create_context_sql
)
...
...
@@ -437,14 +437,14 @@ class MerchantGoodsCodeProcessor:
# 2. 批量插入查询键到临时表(每次1000条)
values_list
=
[]
for
merchant_id
,
base_scene_code
,
upgrade_goods_id
in
query_keys
:
values_list
.
append
(
f
"({merchant_id}, '{base_scene_code}', {upgrade_goods_id})"
)
values_list
.
append
(
f
"({merchant_id}, '{base_scene_code}', {upgrade_goods_id}
, NULL, NULL, NULL
)"
)
# 分批插入,避免SQL过长
batch_size
=
1000
for
i
in
range
(
0
,
len
(
values_list
),
batch_size
):
batch_values
=
values_list
[
i
:
i
+
batch_size
]
insert_sql
=
f
"""
INSERT INTO {self.query_keys_table} (merchant_id, base_scene_code, upgrade_goods_id)
INSERT INTO {self.query_keys_table} (merchant_id, base_scene_code, upgrade_goods_id
, settle_rule_id, division_rule_id, reconciliation_rule_id
)
VALUES {','.join(batch_values)};
"""
self
.
db
.
execute_update
(
insert_sql
)
...
...
@@ -1062,14 +1062,14 @@ class MerchantGoodsCodeProcessor:
# 2. 批量插入查询键到临时表(每次1000条)
values_list
=
[]
for
settle_rule_id
,
division_rule_id
,
base_scene_code
,
upgrade_goods_id
in
query_keys
:
values_list
.
append
(
f
"(
{settle_rule_id}, {division_rule_id}, '{base_scene_code}', {upgrade_goods_id}
)"
)
values_list
.
append
(
f
"(
NULL, '{base_scene_code}', {upgrade_goods_id}, {settle_rule_id}, {division_rule_id}, NULL
)"
)
# 分批插入,避免SQL过长
batch_size
=
1000
for
i
in
range
(
0
,
len
(
values_list
),
batch_size
):
batch_values
=
values_list
[
i
:
i
+
batch_size
]
insert_sql
=
f
"""
INSERT INTO {self.query_keys_table} (
settle_rule_id, division_rule_id, base_scene_code, upgrade_goods
_id)
INSERT INTO {self.query_keys_table} (
merchant_id, base_scene_code, upgrade_goods_id, settle_rule_id, division_rule_id, reconciliation_rule
_id)
VALUES {','.join(batch_values)};
"""
self
.
db
.
execute_update
(
insert_sql
)
...
...
@@ -1127,14 +1127,14 @@ class MerchantGoodsCodeProcessor:
# 2. 批量插入查询键到临时表(每次1000条)
values_list
=
[]
for
reconciliation_rule_id
,
base_scene_code
,
upgrade_goods_id
in
query_keys
:
values_list
.
append
(
f
"(
{reconciliation_rule_id}, '{base_scene_code}', {upgrade_goods
_id})"
)
values_list
.
append
(
f
"(
NULL, '{base_scene_code}', {upgrade_goods_id}, NULL, NULL, {reconciliation_rule
_id})"
)
# 分批插入,避免SQL过长
batch_size
=
1000
for
i
in
range
(
0
,
len
(
values_list
),
batch_size
):
batch_values
=
values_list
[
i
:
i
+
batch_size
]
insert_sql
=
f
"""
INSERT INTO {self.query_keys_table} (
reconciliation_rule_id, base_scene_code, upgrade_goods
_id)
INSERT INTO {self.query_keys_table} (
merchant_id, base_scene_code, upgrade_goods_id, settle_rule_id, division_rule_id, reconciliation_rule
_id)
VALUES {','.join(batch_values)};
"""
self
.
db
.
execute_update
(
insert_sql
)
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment