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 1bfa9f08
authored
Sep 08, 2026
by
周立明
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
延保数据统计
1 parent
4ec2c0f1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
13 deletions
.workbuddy/memory/2026-09-08.md
data-process/build_store_effect_board.py
data-process/outputs/store_effect_summary/门店店效人效汇总表_2026-08.xlsx
.workbuddy/memory/2026-09-08.md
View file @
1bfa9f0
...
@@ -65,3 +65,16 @@
...
@@ -65,3 +65,16 @@
-
用户确认把 1.1、2.3 客单价也改掉。第819、821行由
`pct(...)`
改为
`div2(...)`
(分母分别用 1.1交车数 / 2.3成交单数);两条字段说明同步去掉
`*100%`
。
-
用户确认把 1.1、2.3 客单价也改掉。第819、821行由
`pct(...)`
改为
`div2(...)`
(分母分别用 1.1交车数 / 2.3成交单数);两条字段说明同步去掉
`*100%`
。
-
现三条客单价统一走
`div2`
(纯除法、2位小数、不乘100%):1.1=产值/交车数、2.1=产值/成交单数、2.3=产值/成交单数。
-
现三条客单价统一走
`div2`
(纯除法、2位小数、不乘100%):1.1=产值/交车数、2.1=产值/成交单数、2.3=产值/成交单数。
-
实测(task_id=32):1.1产值≈0.01→≈0.00;2.1=2510.14;2.3产值/成交单数=0→0.00(数据未填充)。
-
实测(task_id=32):1.1产值≈0.01→≈0.00;2.1=2510.14;2.3产值/成交单数=0→0.00(数据未填充)。
## 2.3 全指标改从 report_extended_warranty 读取
-
用户要求 2.3 全部改从
`report_extended_warranty`
(模型
`ReportExtendedWarranty`
,task_id=32)读取,条件同 task_id + is_deleted=0:
-
2.3产值 = store_output_value(门店产值) 之和
-
2.3毛利率 = gross_profit(毛利测算) 之和 / 2.3产值
*
100%
-
2.3毛利率(含人力)= (gross_profit 之和 + marketing_fee(营销费用) 之和) / 2.3产值
*
100%
-
2.3交车数 = delivery_cnt(交车) 之和
-
2.3接待数 = touch_cnt(触客) 之和
-
2.3成交单数 = deal_cnt(成交数) 之和
-
代码改动:
`_lr_sum_one`
增加 'warranty' 分支(import ReportExtendedWarranty,tag='延保');新增
`fetch_extended_warranty_23_sum(col_attr,...)`
安全包装(并行于
`fetch_equity_21_sum`
)。
`compute_metrics`
中 2.3产值/交车数/接待数/成交单数/毛利率/毛利率(含人力) 全部改为
`fetch_extended_warranty_23_sum`
(原走指标系统 A036/A075/A084 或主机厂 dsum)。字段说明同步更新(去掉"待接入,当前0")。
-
注:
`ind_23`
、
`stores_23`
变量现仅用于已废弃的指标路径,保留无副作用。
-
实测(task_id=32):2.3产值=78,524,941;gross_profit=23,235,523.22、marketing_fee=3,022,248.73(数据干净,非2.1脏数据);→ 2.3毛利率=29.59%、2.3毛利率(含人力)=33.44%;delivery_cnt=7588、touch_cnt=13736、deal_cnt=8267;2.3成交客单价=9498.60。2.3达成率=76.94%。
**至此 1.1/2.1/2.3 三条业务线全部从结果表取数,指标系统(A036/A075/A084)仅剩 全国经营总产值/店均产值 在用。**
-
至此三大业务线(1.1轻改 inshop+park、2.1权益 equity、2.3延保 warranty)取数口径全部迁移完毕。
data-process/build_store_effect_board.py
View file @
1bfa9f0
...
@@ -559,12 +559,15 @@ def _lr_sum_one(which, col_attr, period_start, period_end):
...
@@ -559,12 +559,15 @@ def _lr_sum_one(which, col_attr, period_start, period_end):
task_id 解析:优先与汇总同周期(period_start>=/period_end<=),否则取最新(最大) task_id。
task_id 解析:优先与汇总同周期(period_start>=/period_end<=),否则取最新(最大) task_id。
"""
"""
from
app
import
app
,
db
from
app
import
app
,
db
from
models
import
ReportLightReformInshop
,
ReportLightReformPark
,
ReportEquityService
from
models
import
(
ReportLightReformInshop
,
ReportLightReformPark
,
ReportEquityService
,
ReportExtendedWarranty
)
from
sqlalchemy
import
func
from
sqlalchemy
import
func
model_cls
=
(
ReportLightReformInshop
if
which
==
'inshop'
model_cls
=
(
ReportLightReformInshop
if
which
==
'inshop'
else
ReportLightReformPark
if
which
==
'park'
else
ReportLightReformPark
if
which
==
'park'
else
ReportEquityService
)
else
ReportEquityService
if
which
==
'equity'
tag
=
'轻改'
if
which
in
(
'inshop'
,
'park'
)
else
'权益'
else
ReportExtendedWarranty
)
tag
=
(
'轻改'
if
which
in
(
'inshop'
,
'park'
)
else
'权益'
if
which
==
'equity'
else
'延保'
)
with
app
.
app_context
():
with
app
.
app_context
():
q
=
db
.
session
.
query
(
model_cls
.
task_id
)
.
filter
(
model_cls
.
is_deleted
==
0
)
q
=
db
.
session
.
query
(
model_cls
.
task_id
)
.
filter
(
model_cls
.
is_deleted
==
0
)
if
period_start
and
period_end
:
if
period_start
and
period_end
:
...
@@ -614,6 +617,15 @@ def fetch_equity_21_sum(col_attr, period_start, period_end):
...
@@ -614,6 +617,15 @@ def fetch_equity_21_sum(col_attr, period_start, period_end):
return
Decimal
(
'0'
)
return
Decimal
(
'0'
)
def
fetch_extended_warranty_23_sum
(
col_attr
,
period_start
,
period_end
):
"""延保盈利测算结果表(report_extended_warranty)某数值列之和;同 task_id, is_deleted=0。返回 Decimal。"""
try
:
return
_lr_sum_one
(
'warranty'
,
col_attr
,
period_start
,
period_end
)
except
Exception
as
e
:
logger
.
warning
(
f
"[延保] 读取失败,{col_attr} 置0: {e}"
)
return
Decimal
(
'0'
)
def
compute_metrics
(
src
,
period_start
,
period_end
):
def
compute_metrics
(
src
,
period_start
,
period_end
):
exact_map
,
keys
=
load_brand_category
()
exact_map
,
keys
=
load_brand_category
()
s1
,
s2
=
parse_saas
(
src
)
s1
,
s2
=
parse_saas
(
src
)
...
@@ -669,7 +681,7 @@ def compute_metrics(src, period_start, period_end):
...
@@ -669,7 +681,7 @@ def compute_metrics(src, period_start, period_end):
stores_23
=
uniq
(
s1
,
lambda
r
:
r
[
'biz_type'
]
==
'2.3'
)
stores_23
=
uniq
(
s1
,
lambda
r
:
r
[
'biz_type'
]
==
'2.3'
)
m
[
'1.1交车数'
]
=
fetch_light_reform_11_sum
(
'delivery_cnt'
,
period_start
,
period_end
)
m
[
'1.1交车数'
]
=
fetch_light_reform_11_sum
(
'delivery_cnt'
,
period_start
,
period_end
)
m
[
'2.1交车数'
]
=
fetch_equity_21_sum
(
'delivery_cnt'
,
period_start
,
period_end
)
m
[
'2.1交车数'
]
=
fetch_equity_21_sum
(
'delivery_cnt'
,
period_start
,
period_end
)
m
[
'2.3交车数'
]
=
dsum
(
stores_23
)
m
[
'2.3交车数'
]
=
fetch_extended_warranty_23_sum
(
'delivery_cnt'
,
period_start
,
period_end
)
# ---- 6.1 二手车 ----
# ---- 6.1 二手车 ----
uc
=
parse_used_car
(
src
,
period_start
,
period_end
)
uc
=
parse_used_car
(
src
,
period_start
,
period_end
)
...
@@ -759,19 +771,26 @@ def compute_metrics(src, period_start, period_end):
...
@@ -759,19 +771,26 @@ def compute_metrics(src, period_start, period_end):
# 2.1毛利率(含人力)=(gross_profit 之和 + marketing_fee 之和)/ 2.1产值 *100%,四舍五入保留百分比后2位
# 2.1毛利率(含人力)=(gross_profit 之和 + marketing_fee 之和)/ 2.1产值 *100%,四舍五入保留百分比后2位
mkt_21
=
fetch_equity_21_sum
(
'marketing_fee'
,
period_start
,
period_end
)
mkt_21
=
fetch_equity_21_sum
(
'marketing_fee'
,
period_start
,
period_end
)
m
[
'2.1毛利率(含人力)'
]
=
pct
(
gp_21
+
mkt_21
,
m
[
'2.1产值'
])
m
[
'2.1毛利率(含人力)'
]
=
pct
(
gp_21
+
mkt_21
,
m
[
'2.1产值'
])
m
[
'2.3产值'
]
=
ind_sum
(
ind_23
,
stores_23
,
'A036'
)
# 2.3产值:report_extended_warranty.store_output_value(门店产值) 之和,同 task_id, is_deleted=0
m
[
'2.3产值'
]
=
fetch_extended_warranty_23_sum
(
'store_output_value'
,
period_start
,
period_end
)
# 1.1成交单数 = park.deal_cnt(成交数) 之和 + inshop.total_deal_cnt(总成交数) 之和
# 1.1成交单数 = park.deal_cnt(成交数) 之和 + inshop.total_deal_cnt(总成交数) 之和
# 条件:同 task_id, is_deleted=0
# 条件:同 task_id, is_deleted=0
m
[
'1.1成交单数'
]
=
(
fetch_light_reform_11_sum_one
(
'park'
,
'deal_cnt'
,
period_start
,
period_end
)
m
[
'1.1成交单数'
]
=
(
fetch_light_reform_11_sum_one
(
'park'
,
'deal_cnt'
,
period_start
,
period_end
)
+
fetch_light_reform_11_sum_one
(
'inshop'
,
'total_deal_cnt'
,
period_start
,
period_end
))
+
fetch_light_reform_11_sum_one
(
'inshop'
,
'total_deal_cnt'
,
period_start
,
period_end
))
m
[
'2.1成交单数'
]
=
fetch_equity_21_sum
(
'deal_cnt'
,
period_start
,
period_end
)
m
[
'2.1成交单数'
]
=
fetch_equity_21_sum
(
'deal_cnt'
,
period_start
,
period_end
)
m
[
'2.3成交单数'
]
=
ind_sum
(
ind_23
,
stores_23
,
'A075'
)
# 2.3毛利率 =(gross_profit 之和 / 2.3产值)*100%,四舍五入保留百分比后2位
gp_23
=
fetch_extended_warranty_23_sum
(
'gross_profit'
,
period_start
,
period_end
)
m
[
'2.3毛利率'
]
=
pct
(
gp_23
,
m
[
'2.3产值'
])
# 2.3毛利率(含人力)=(gross_profit 之和 + marketing_fee 之和)/ 2.3产值 *100%,四舍五入保留百分比后2位
mkt_23
=
fetch_extended_warranty_23_sum
(
'marketing_fee'
,
period_start
,
period_end
)
m
[
'2.3毛利率(含人力)'
]
=
pct
(
gp_23
+
mkt_23
,
m
[
'2.3产值'
])
m
[
'2.3成交单数'
]
=
fetch_extended_warranty_23_sum
(
'deal_cnt'
,
period_start
,
period_end
)
# 1.1接待数 = park.arrival_cnt(到店数) 之和 + inshop.delivery_touch_cnt(交付触客数) 之和
# 1.1接待数 = park.arrival_cnt(到店数) 之和 + inshop.delivery_touch_cnt(交付触客数) 之和
# 条件:同 task_id, is_deleted=0
# 条件:同 task_id, is_deleted=0
m
[
'1.1接待数'
]
=
(
fetch_light_reform_11_sum_one
(
'park'
,
'arrival_cnt'
,
period_start
,
period_end
)
m
[
'1.1接待数'
]
=
(
fetch_light_reform_11_sum_one
(
'park'
,
'arrival_cnt'
,
period_start
,
period_end
)
+
fetch_light_reform_11_sum_one
(
'inshop'
,
'delivery_touch_cnt'
,
period_start
,
period_end
))
+
fetch_light_reform_11_sum_one
(
'inshop'
,
'delivery_touch_cnt'
,
period_start
,
period_end
))
m
[
'2.1接待数'
]
=
fetch_equity_21_sum
(
'touch_cnt'
,
period_start
,
period_end
)
m
[
'2.1接待数'
]
=
fetch_equity_21_sum
(
'touch_cnt'
,
period_start
,
period_end
)
m
[
'2.3接待数'
]
=
ind_sum
(
ind_23
,
stores_23
,
'A084'
)
m
[
'2.3接待数'
]
=
fetch_extended_warranty_23_sum
(
'touch_cnt'
,
period_start
,
period_end
)
lux_stores
=
{
r
[
'store'
]
for
r
in
allrows
if
r
[
'category'
]
==
'豪华'
}
lux_stores
=
{
r
[
'store'
]
for
r
in
allrows
if
r
[
'category'
]
==
'豪华'
}
nonlux_stores
=
{
r
[
'store'
]
for
r
in
allrows
if
r
[
'category'
]
!=
'豪华'
}
nonlux_stores
=
{
r
[
'store'
]
for
r
in
allrows
if
r
[
'category'
]
!=
'豪华'
}
...
@@ -1025,15 +1044,15 @@ FIELD_NOTES = [
...
@@ -1025,15 +1044,15 @@ FIELD_NOTES = [
(
'2.1成交单数'
,
'report_equity_service.deal_cnt(成交数) 之和,条件:同 task_id, is_deleted=0'
),
(
'2.1成交单数'
,
'report_equity_service.deal_cnt(成交数) 之和,条件:同 task_id, is_deleted=0'
),
(
'2.1成交客单价'
,
'2.1产值/2.1成交单数,四舍五入保留2位小数'
),
(
'2.1成交客单价'
,
'2.1产值/2.1成交单数,四舍五入保留2位小数'
),
(
'2.3预算'
,
'sheet1业务类型=2.3明细的"预估产值(纠偏)"之和'
),
(
'2.3预算'
,
'sheet1业务类型=2.3明细的"预估产值(纠偏)"之和'
),
(
'2.3产值'
,
'
结果表:红黄门店盈利测算-延保 的"门店产值"之和【从源重算:待接入,当前0】
'
),
(
'2.3产值'
,
'
report_extended_warranty.store_output_value(门店产值) 之和,条件:同 task_id, is_deleted=0
'
),
(
'2.3达成率'
,
'(2.3产值/2.3预算)*100
%
'
),
(
'2.3达成率'
,
'(2.3产值/2.3预算)*100
%
'
),
(
'2.3毛利率'
,
'
延保结果表"毛利测算"之和/2.3产值【待接入,当前0】
'
),
(
'2.3毛利率'
,
'
report_extended_warranty.gross_profit(毛利测算) 之和 / 2.3产值 *100
%
,四舍五入保留百分比后2位;同 task_id, is_deleted=0
'
),
(
'2.3毛利率(含人力)'
,
'(
毛利测算+营销成本)/2.3产值【待接入,当前0】
'
),
(
'2.3毛利率(含人力)'
,
'(
report_extended_warranty.gross_profit(毛利测算) 之和 + marketing_fee(营销费用) 之和)/ 2.3产值 *100
%
,四舍五入保留百分比后2位;同 task_id, is_deleted=0
'
),
(
'2.3交车数'
,
'
本项目从源重算:主机厂数据表交车数之和
'
),
(
'2.3交车数'
,
'
report_extended_warranty.delivery_cnt(交车) 之和,条件:同 task_id, is_deleted=0
'
),
(
'2.3接待数'
,
'
延保结果表"触客数"之和【待接入,当前0】
'
),
(
'2.3接待数'
,
'
report_extended_warranty.touch_cnt(触客) 之和,条件:同 task_id, is_deleted=0
'
),
(
'2.3触客率'
,
'(2.3接待数/2.3交车数)*100
%
'
),
(
'2.3触客率'
,
'(2.3接待数/2.3交车数)*100
%
'
),
(
'2.3转化率'
,
'(2.3成交单数/2.3接待数)*100
%
'
),
(
'2.3转化率'
,
'(2.3成交单数/2.3接待数)*100
%
'
),
(
'2.3成交单数'
,
'
延保结果表"成交数"之和【待接入,当前0】
'
),
(
'2.3成交单数'
,
'
report_extended_warranty.deal_cnt(成交数) 之和,条件:同 task_id, is_deleted=0
'
),
(
'2.3成交客单价'
,
'2.3产值/2.3成交单数,四舍五入保留2位小数'
),
(
'2.3成交客单价'
,
'2.3产值/2.3成交单数,四舍五入保留2位小数'
),
(
'6.1预算'
,
'默认为空'
),
(
'6.1预算'
,
'默认为空'
),
(
'6.1产值'
,
'二手车台账-汇总销售台账:拍卖日期在周期内 的拍卖价格之和'
),
(
'6.1产值'
,
'二手车台账-汇总销售台账:拍卖日期在周期内 的拍卖价格之和'
),
...
...
data-process/outputs/store_effect_summary/门店店效人效汇总表_2026-08.xlsx
View file @
1bfa9f0
No preview for this file type
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