Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
data_report
/
data-report
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 9d832189
authored
Sep 07, 2026
by
周立明
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'v1.1' of
http://192.168.3.233:8090/data_report/data-report
into v1.1
2 parents
c5399886
19d7c06c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
9 deletions
data-process/light_reform_inshop_processor.py
data-process/light_reform_park_processor.py
data-process/report_utils.py
data-process/light_reform_inshop_processor.py
View file @
9d83218
...
@@ -25,7 +25,7 @@ from report_utils import (
...
@@ -25,7 +25,7 @@ from report_utils import (
parse_inshop_delivery_touch
,
parse_commerce_policy_inshop
,
parse_inshop_delivery_touch
,
parse_commerce_policy_inshop
,
parse_labor_cost
,
is_luxury_brand
,
parse_labor_cost
,
is_luxury_brand
,
parse_budget_achieve_excel
,
extract_budget_ratio
,
prorate_by_period
,
parse_budget_achieve_excel
,
extract_budget_ratio
,
prorate_by_period
,
fetch_park_daily_report
,
fetch_light_reform_goods_stats
,
fuzzy_match_store
,
fetch_park_daily_report
,
fetch_light_reform_goods_stats
,
f
etch_light_reform_finance_stats
,
f
uzzy_match_store
,
get_with_fallback
,
safe_div
,
safe_div_pct
,
safe_div_pct_decimal
,
get_with_fallback
,
safe_div
,
safe_div_pct
,
safe_div_pct_decimal
,
)
)
from
models
import
ReportLightReformInshop
,
db
from
models
import
ReportLightReformInshop
,
db
...
@@ -158,14 +158,15 @@ class LightReformInshopProcessor:
...
@@ -158,14 +158,15 @@ class LightReformInshopProcessor:
daily_report_map
=
fetch_park_daily_report
(
period_start
,
period_end
,
scene_type
=
1
)
daily_report_map
=
fetch_park_daily_report
(
period_start
,
period_end
,
scene_type
=
1
)
# 2c. 品类成交数 + 产值(店中店+园区店共用 SQL,按 dj_order_type + AITO/HIMA 关键字聚合)
# 2c. 品类成交数 + 产值(店中店+园区店共用 SQL,按 dj_order_type + AITO/HIMA 关键字聚合)
goods_stats_map
=
fetch_light_reform_goods_stats
(
period_start
,
period_end
)
goods_stats_map
=
fetch_light_reform_goods_stats
(
period_start
,
period_end
)
# 2d. 财务成本分项(店中店+园区店共用 SQL,按 dj_order_type + 品类 + 原厂/副厂切分)
finance_map
=
fetch_light_reform_finance_stats
(
period_start
,
period_end
,
scene_type
=
1
)
# 2b. 模糊匹配到门店 → 组装 sql_data dict(get_with_fallback 双优先用)
# 2b. 模糊匹配到门店 → 组装 sql_data dict(get_with_fallback 双优先用)
# 店中店:delivery_cnt→交车;equity→交付触客;after_sale→售后触客;
# 售后首保/事故回厂数 → 无 SQL,默认 0
biz_sql_data
=
{}
biz_sql_data
=
{}
for
rec
in
base_records
:
for
rec
in
base_records
:
sn
=
rec
.
get
(
'store_name'
,
''
)
sn
=
rec
.
get
(
'store_name'
,
''
)
dr
=
fuzzy_match_store
(
sn
,
daily_report_map
)
or
{}
dr
=
fuzzy_match_store
(
sn
,
daily_report_map
)
or
{}
gs
=
fuzzy_match_store
(
sn
,
goods_stats_map
)
or
{}
gs
=
fuzzy_match_store
(
sn
,
goods_stats_map
)
or
{}
fs
=
fuzzy_match_store
(
sn
,
finance_map
)
or
{}
biz_sql_data
[
sn
]
=
{
biz_sql_data
[
sn
]
=
{
# —— 日报类(来自 fetch_park_daily_report)——
# —— 日报类(来自 fetch_park_daily_report)——
'delivery_cnt'
:
dr
.
get
(
'delivery_cnt'
,
0
),
'delivery_cnt'
:
dr
.
get
(
'delivery_cnt'
,
0
),
...
@@ -175,7 +176,7 @@ class LightReformInshopProcessor:
...
@@ -175,7 +176,7 @@ class LightReformInshopProcessor:
'aftersales_shigu_cnt'
:
0
,
# 无 SQL
'aftersales_shigu_cnt'
:
0
,
# 无 SQL
'sales_order_cnt'
:
0
,
# 无 SQL(销售大定数)
'sales_order_cnt'
:
0
,
# 无 SQL(销售大定数)
'sales_touch_cnt'
:
0
,
# 无 SQL(销售触客数)
'sales_touch_cnt'
:
0
,
# 无 SQL(销售触客数)
# —— 品类成交数 + 产值(来自 fetch_
inshop
_goods_stats)——
# —— 品类成交数 + 产值(来自 fetch_
light_reform
_goods_stats)——
'total_deal_cnt'
:
gs
.
get
(
'total_deal_cnt'
,
0
),
'total_deal_cnt'
:
gs
.
get
(
'total_deal_cnt'
,
0
),
'window_film_oe_cnt'
:
gs
.
get
(
'window_film_oe_cnt'
,
0
),
'window_film_oe_cnt'
:
gs
.
get
(
'window_film_oe_cnt'
,
0
),
'window_film_nonoe_cnt'
:
gs
.
get
(
'window_film_nonoe_cnt'
,
0
),
'window_film_nonoe_cnt'
:
gs
.
get
(
'window_film_nonoe_cnt'
,
0
),
...
@@ -188,6 +189,17 @@ class LightReformInshopProcessor:
...
@@ -188,6 +189,17 @@ class LightReformInshopProcessor:
'internal_settle_value'
:
gs
.
get
(
'internal_settle_value'
,
Decimal
(
'0'
)),
'internal_settle_value'
:
gs
.
get
(
'internal_settle_value'
,
Decimal
(
'0'
)),
'oe_output_value'
:
gs
.
get
(
'oe_output_value'
,
Decimal
(
'0'
)),
'oe_output_value'
:
gs
.
get
(
'oe_output_value'
,
Decimal
(
'0'
)),
'nonoe_output_value'
:
gs
.
get
(
'nonoe_output_value'
,
Decimal
(
'0'
)),
'nonoe_output_value'
:
gs
.
get
(
'nonoe_output_value'
,
Decimal
(
'0'
)),
# —— 财务成本分项(来自 fetch_light_reform_finance_stats)——
'product_cost_finance'
:
fs
.
get
(
'product_cost_finance'
,
Decimal
(
'0'
)),
'internal_settle_cost'
:
fs
.
get
(
'internal_settle_cost'
,
Decimal
(
'0'
)),
'oe_product_cost'
:
fs
.
get
(
'oe_product_cost'
,
Decimal
(
'0'
)),
'nonoe_product_cost'
:
fs
.
get
(
'nonoe_product_cost'
,
Decimal
(
'0'
)),
'window_film_cost'
:
fs
.
get
(
'window_film_cost'
,
Decimal
(
'0'
)),
'car_wrap_cost'
:
fs
.
get
(
'car_wrap_cost'
,
Decimal
(
'0'
)),
'premium_cost'
:
fs
.
get
(
'premium_cost'
,
Decimal
(
'0'
)),
'store_share'
:
fs
.
get
(
'store_share'
,
Decimal
(
'0'
)),
'construction_income'
:
fs
.
get
(
'construction_income'
,
Decimal
(
'0'
)),
'market_fee'
:
fs
.
get
(
'market_fee'
,
Decimal
(
'0'
)),
}
}
# ========== Step3: 上月预算明细(已在 Step1 从 Excel 解析) ==========
# ========== Step3: 上月预算明细(已在 Step1 从 Excel 解析) ==========
...
...
data-process/light_reform_park_processor.py
View file @
9d83218
...
@@ -32,7 +32,7 @@ from report_utils import (
...
@@ -32,7 +32,7 @@ from report_utils import (
parse_labor_cost
,
is_luxury_brand
,
parse_labor_cost
,
is_luxury_brand
,
parse_budget_achieve_excel
,
extract_budget_ratio
,
prorate_by_period
,
parse_budget_achieve_excel
,
extract_budget_ratio
,
prorate_by_period
,
fetch_indicator_data
,
fetch_park_daily_report
,
fetch_light_reform_goods_stats
,
fetch_indicator_data
,
fetch_park_daily_report
,
fetch_light_reform_goods_stats
,
fetch_est_delivery_count
,
fuzzy_match_store
,
fetch_
light_reform_finance_stats
,
fetch_
est_delivery_count
,
fuzzy_match_store
,
get_with_fallback
,
safe_div
,
safe_div_pct
,
safe_div_pct_decimal
,
get_with_fallback
,
safe_div
,
safe_div_pct
,
safe_div_pct_decimal
,
)
)
from
models
import
ReportLightReformPark
,
db
from
models
import
ReportLightReformPark
,
db
...
@@ -166,13 +166,15 @@ class LightReformParkProcessor:
...
@@ -166,13 +166,15 @@ class LightReformParkProcessor:
goods_stats_map
=
fetch_light_reform_goods_stats
(
period_start
,
period_end
)
goods_stats_map
=
fetch_light_reform_goods_stats
(
period_start
,
period_end
)
# 3c. 预估交车数(静态配置表,无日期参数,traffic_party_name 即门店名)
# 3c. 预估交车数(静态配置表,无日期参数,traffic_party_name 即门店名)
est_delivery_map
=
fetch_est_delivery_count
(
base_scene_code
=
'100101'
)
est_delivery_map
=
fetch_est_delivery_count
(
base_scene_code
=
'100101'
)
# 3d. 模糊匹配到门店 → 组装 sql_data dict
# 3d. 财务成本分项(店中店+园区店共用 SQL,park 侧仅消费 4 项)
# 园区店:delivery_cnt → 交车;equity + after_sale → 到店数;无效到店无 SQL → 0
finance_map
=
fetch_light_reform_finance_stats
(
period_start
,
period_end
,
scene_type
=
1
)
# 3e. 模糊匹配到门店 → 组装 sql_data dict
biz_sql_data
=
{}
biz_sql_data
=
{}
for
rec
in
base_records
:
for
rec
in
base_records
:
sn
=
rec
.
get
(
'store_name'
,
''
)
sn
=
rec
.
get
(
'store_name'
,
''
)
dr
=
fuzzy_match_store
(
sn
,
daily_report_map
)
or
{}
dr
=
fuzzy_match_store
(
sn
,
daily_report_map
)
or
{}
gs
=
fuzzy_match_store
(
sn
,
goods_stats_map
)
or
{}
gs
=
fuzzy_match_store
(
sn
,
goods_stats_map
)
or
{}
fs
=
fuzzy_match_store
(
sn
,
finance_map
)
or
{}
eq
=
dr
.
get
(
'equity_to_shop_count'
,
0
)
eq
=
dr
.
get
(
'equity_to_shop_count'
,
0
)
af
=
dr
.
get
(
'after_sale_equity_to_shop_count'
,
0
)
af
=
dr
.
get
(
'after_sale_equity_to_shop_count'
,
0
)
biz_sql_data
[
sn
]
=
{
biz_sql_data
[
sn
]
=
{
...
@@ -188,10 +190,15 @@ class LightReformParkProcessor:
...
@@ -188,10 +190,15 @@ class LightReformParkProcessor:
# —— 产值(来自 fetch_light_reform_goods_stats)——
# —— 产值(来自 fetch_light_reform_goods_stats)——
'store_sales_output'
:
gs
.
get
(
'store_output_value'
,
Decimal
(
'0'
)),
'store_sales_output'
:
gs
.
get
(
'store_output_value'
,
Decimal
(
'0'
)),
'internal_settle_value'
:
gs
.
get
(
'internal_settle_value'
,
Decimal
(
'0'
)),
'internal_settle_value'
:
gs
.
get
(
'internal_settle_value'
,
Decimal
(
'0'
)),
# —— 预估交车数(来自 fetch_est_delivery_count
,traffic_party_name 即门店名
)——
# —— 预估交车数(来自 fetch_est_delivery_count)——
'est_delivery_cnt'
:
fuzzy_match_store
(
sn
,
est_delivery_map
)
or
0
,
'est_delivery_cnt'
:
fuzzy_match_store
(
sn
,
est_delivery_map
)
or
0
,
# —— 财务分项(park 仅消费产品成本/内部结算成本/流量费/市场费)——
'product_cost_finance'
:
fs
.
get
(
'product_cost_finance'
,
Decimal
(
'0'
)),
'internal_settle_cost'
:
fs
.
get
(
'internal_settle_cost'
,
Decimal
(
'0'
)),
'traffic_fee_finance'
:
fs
.
get
(
'store_share'
,
Decimal
(
'0'
)),
# 流量费 = gopa.shop_traffic_money (dj_order_type!=6)
'market_fee_weighted'
:
fs
.
get
(
'market_fee'
,
Decimal
(
'0'
)),
# 市场费加权测算 = fee 四项费用累计
}
}
# 3
e. 其他聚合 SQL(成本/市场费/流量费等)后续接入,当前保持默认
0
# 3
f. 其他字段(service_fee / construction_cost 等) park 从 Excel 或公式取,保持
0
# ========== Step4: 上月预算明细(已在 Step1 从 Excel 解析) ==========
# ========== Step4: 上月预算明细(已在 Step1 从 Excel 解析) ==========
prev_budget_map
=
budget_achieve_map
prev_budget_map
=
budget_achieve_map
...
...
data-process/report_utils.py
View file @
9d83218
This diff is collapsed.
Click to expand it.
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