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 c2cff019
authored
May 10, 2026
by
林冲
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修复第五步step5_process_goods_type_group 的bug
1 parent
ceb1390b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
9 deletions
scene_refactor_data/scene_split_processor.py
scene_refactor_data/刷数据脚本执行顺序.md
scene_refactor_data/scene_split_processor.py
View file @
c2cff01
...
@@ -165,7 +165,7 @@ class SceneSplitProcessor:
...
@@ -165,7 +165,7 @@ class SceneSplitProcessor:
({source}, {merchant_id}, {scene_type}, '{new_code}', {enable_flag}, {submit_flag},
({source}, {merchant_id}, {scene_type}, '{new_code}', {enable_flag}, {submit_flag},
'{DATA_MIGRATION_USER}', '{created_date_str}', '{DATA_MIGRATION_USER}', NOW(), 'N');
'{DATA_MIGRATION_USER}', '{created_date_str}', '{DATA_MIGRATION_USER}', NOW(), 'N');
"""
"""
self
.
logger
.
info
(
f
" 执行插入SQL: {insert_sql.strip()}"
)
self
.
logger
.
debug
(
f
" 执行插入SQL: {insert_sql.strip()}"
)
if
self
.
db
.
execute_update
(
insert_sql
):
if
self
.
db
.
execute_update
(
insert_sql
):
# 获取新插入的ID
# 获取新插入的ID
new_id_sql
=
"SELECT LAST_INSERT_ID();"
new_id_sql
=
"SELECT LAST_INSERT_ID();"
...
@@ -338,7 +338,7 @@ class SceneSplitProcessor:
...
@@ -338,7 +338,7 @@ class SceneSplitProcessor:
{reality_shop_merchant_id}, {reality_shop_merchant_name}, {reality_shop_user_type}, {reality_shop_level},
{reality_shop_merchant_id}, {reality_shop_merchant_name}, {reality_shop_user_type}, {reality_shop_level},
{rule_audit_id}, '{DATA_MIGRATION_USER}', '{created_date_str}', '{DATA_MIGRATION_USER}', NOW(), 'N');
{rule_audit_id}, '{DATA_MIGRATION_USER}', '{created_date_str}', '{DATA_MIGRATION_USER}', NOW(), 'N');
"""
"""
self
.
logger
.
info
(
f
" 执行插入SQL: {insert_sql.strip()}"
)
self
.
logger
.
debug
(
f
" 执行插入SQL: {insert_sql.strip()}"
)
if
self
.
db
.
execute_update
(
insert_sql
):
if
self
.
db
.
execute_update
(
insert_sql
):
new_id_sql
=
"SELECT LAST_INSERT_ID();"
new_id_sql
=
"SELECT LAST_INSERT_ID();"
result
=
self
.
db
.
execute_query_one
(
new_id_sql
)
result
=
self
.
db
.
execute_query_one
(
new_id_sql
)
...
@@ -645,9 +645,8 @@ class SceneSplitProcessor:
...
@@ -645,9 +645,8 @@ class SceneSplitProcessor:
new_settle_rule_group_id
=
item
[
'new_settle_rule_group_id'
]
new_settle_rule_group_id
=
item
[
'new_settle_rule_group_id'
]
# 从映射表查询新ID
# 从映射表查询新ID
mappings
=
self
.
id_mapper
.
get_mappings
(
goods_type_group_table
,
old_id
,
base_scene_code
)
new_goods_type_group_id
=
self
.
id_mapper
.
get_new_id_by_scene
(
goods_type_group_table
,
old_id
,
base_scene_code
)
if
mappings
:
if
new_goods_type_group_id
:
new_goods_type_group_id
=
mappings
[
0
][
'new_id'
]
update_batch
.
append
({
update_batch
.
append
({
'settle_rule_id'
:
new_settle_rule_group_id
,
'settle_rule_id'
:
new_settle_rule_group_id
,
'new_goods_type_group_id'
:
new_goods_type_group_id
'new_goods_type_group_id'
:
new_goods_type_group_id
...
@@ -1345,7 +1344,7 @@ class SceneSplitProcessor:
...
@@ -1345,7 +1344,7 @@ class SceneSplitProcessor:
{enable_flag}, {submit_flag},
{enable_flag}, {submit_flag},
'{DATA_MIGRATION_USER}', '{created_date_str}', '{DATA_MIGRATION_USER}', NOW(), 'N');
'{DATA_MIGRATION_USER}', '{created_date_str}', '{DATA_MIGRATION_USER}', NOW(), 'N');
"""
"""
self
.
logger
.
info
(
f
" 执行插入SQL: {insert_sql.strip()}"
)
self
.
logger
.
debug
(
f
" 执行插入SQL: {insert_sql.strip()}"
)
if
self
.
db
.
execute_update
(
insert_sql
):
if
self
.
db
.
execute_update
(
insert_sql
):
new_id_sql
=
"SELECT LAST_INSERT_ID();"
new_id_sql
=
"SELECT LAST_INSERT_ID();"
result
=
self
.
db
.
execute_query_one
(
new_id_sql
)
result
=
self
.
db
.
execute_query_one
(
new_id_sql
)
...
@@ -1475,7 +1474,7 @@ class SceneSplitProcessor:
...
@@ -1475,7 +1474,7 @@ class SceneSplitProcessor:
# 建立映射
# 建立映射
for
i
,
item
in
enumerate
(
batch
):
for
i
,
item
in
enumerate
(
batch
):
new_id
=
first_new_id
+
i
new_id
=
first_new_id
+
i
self
.
id_mapper
.
add_mapping
(
'
table11
'
,
item
[
'old_id'
],
new_id
,
item
[
'base_scene_code'
])
self
.
id_mapper
.
add_mapping
(
'
dj_car_life_merchant_goods_type_group_reconciliation_rule
'
,
item
[
'old_id'
],
new_id
,
item
[
'base_scene_code'
])
copy_count
+=
1
copy_count
+=
1
self
.
logger
.
info
(
f
" 批次 {batch_num}/{total_batches} 插入完成,本批 {len(batch)} 条,累计 {copy_count} 条"
)
self
.
logger
.
info
(
f
" 批次 {batch_num}/{total_batches} 插入完成,本批 {len(batch)} 条,累计 {copy_count} 条"
)
...
@@ -1494,7 +1493,7 @@ class SceneSplitProcessor:
...
@@ -1494,7 +1493,7 @@ class SceneSplitProcessor:
query_mapping_sql
=
"""
query_mapping_sql
=
"""
SELECT old_id, new_id, base_scene_code
SELECT old_id, new_id, base_scene_code
FROM tmp_rule_id_mapping
FROM tmp_rule_id_mapping
WHERE table_name = '
table11
'
WHERE table_name = '
dj_car_life_merchant_goods_type_group_reconciliation_rule
'
ORDER BY old_id, base_scene_code;
ORDER BY old_id, base_scene_code;
"""
"""
mappings
=
self
.
db
.
execute_query
(
query_mapping_sql
)
mappings
=
self
.
db
.
execute_query
(
query_mapping_sql
)
...
@@ -1617,7 +1616,7 @@ class SceneSplitProcessor:
...
@@ -1617,7 +1616,7 @@ class SceneSplitProcessor:
query_mapping_sql
=
"""
query_mapping_sql
=
"""
SELECT old_id, new_id, base_scene_code
SELECT old_id, new_id, base_scene_code
FROM tmp_rule_id_mapping
FROM tmp_rule_id_mapping
WHERE table_name = '
table11
'
WHERE table_name = '
dj_car_life_merchant_goods_type_group_reconciliation_rule
'
ORDER BY old_id, base_scene_code;
ORDER BY old_id, base_scene_code;
"""
"""
mappings
=
self
.
db
.
execute_query
(
query_mapping_sql
)
mappings
=
self
.
db
.
execute_query
(
query_mapping_sql
)
...
...
scene_refactor_data/刷数据脚本执行顺序.md
0 → 100644
View file @
c2cff01
## 确认数据库是目标数据库
[
db_config.yaml
](
db_config.yaml
)
test_smartcarlife_db这个配置生产的数据库链接
## 刷规则做baseSceneCode更新和scene=0的拆分
python main_scene_split.py --env test
## merchantGoodsCode数据补全(依赖订单-善天、商品数据补全-诗林)
python main_merchant_goods_code.py
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