Compare commits
4 Commits
V2.3.0
...
f2de5d5500
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f2de5d5500 | ||
|
|
54ecbc352f | ||
|
|
cdc4cec2ff | ||
|
|
8c2f4e73dd |
@@ -169,6 +169,16 @@ def collect_vehicle_payments(G, feb_data, mar_data):
|
|||||||
for i, r in enumerate(records): r['期数'] = i + 1
|
for i, r in enumerate(records): r['期数'] = i + 1
|
||||||
return payments, info
|
return payments, info
|
||||||
|
|
||||||
|
# (归属公司+车型) → 考核目标 映射,用于补全无考核记录的车辆
|
||||||
|
VEHICLE_TARGET_MAP = {
|
||||||
|
('广州开发区交投氢能运营管理有限公司', '4.5吨冷链车'): ('交投190辆4.5T冷链车', 3000, 150),
|
||||||
|
('广州开发区交投氢能运营管理有限公司', '4.5吨货车'): ('交投40辆4.5T普货', 3000, 150),
|
||||||
|
('羚牛氢能科技(广东)有限公司', '4.5吨冷链车'): ('羚牛136辆4.5T冷链车', 5000, 260),
|
||||||
|
('羚牛氢能科技(广东)有限公司', '18吨双飞翼货车'): ('羚牛100辆18T', 6000, 1000),
|
||||||
|
('现代氢能科技(广州)有限公司', '4.5吨货车'): ('恒运50辆4.5T普货', 5000, 260),
|
||||||
|
('现代氢能科技(广州)有限公司', '4.5吨货车'): ('恒运50辆4.5T普货', 5000, 260),
|
||||||
|
}
|
||||||
|
|
||||||
def read_master_vehicles(fp='里程任务考核_Q1汇总.xlsx'):
|
def read_master_vehicles(fp='里程任务考核_Q1汇总.xlsx'):
|
||||||
"""从现有Q1汇总文件读取全量车辆台账"""
|
"""从现有Q1汇总文件读取全量车辆台账"""
|
||||||
wb = openpyxl.load_workbook(fp, data_only=True)
|
wb = openpyxl.load_workbook(fp, data_only=True)
|
||||||
|
|||||||
@@ -186,7 +186,8 @@ def write_summary_month(wb, month, month_data, section_names):
|
|||||||
# ============================================================
|
# ============================================================
|
||||||
|
|
||||||
def write_salesperson_sheet(wb, person, dept, settle_month, D, G, month_data, vehicle_payments):
|
def write_salesperson_sheet(wb, person, dept, settle_month, D, G, month_data, vehicle_payments):
|
||||||
ws = wb.create_sheet(f'业务员_{person}')
|
short_dept = dept.replace('业务','') if '业务' in dept else dept
|
||||||
|
ws = wb.create_sheet(f'{short_dept}-{person}')
|
||||||
ws.cell(row=1,column=1,value=f'{person} | {dept} | {settle_month}月绩效对账单').font=Font(bold=True,size=14)
|
ws.cell(row=1,column=1,value=f'{person} | {dept} | {settle_month}月绩效对账单').font=Font(bold=True,size=14)
|
||||||
|
|
||||||
plates = set()
|
plates = set()
|
||||||
@@ -351,13 +352,26 @@ def write_vehicle_tracking_sheet(wb, settle_month, G, master_vehicles, vehicle_p
|
|||||||
headers += ['本月发放明细','累计已发期数','累计已发金额','剩余可发期数']
|
headers += ['本月发放明细','累计已发期数','累计已发金额','剩余可发期数']
|
||||||
WH(ws, headers)
|
WH(ws, headers)
|
||||||
|
|
||||||
|
from calc_engine import VEHICLE_TARGET_MAP, RULES
|
||||||
|
|
||||||
rn=2
|
rn=2
|
||||||
for mv in master_vehicles:
|
for mv in master_vehicles:
|
||||||
plate=mv['车牌号']
|
plate=mv['车牌号']
|
||||||
info=vehicle_info.get(plate, {})
|
info=vehicle_info.get(plate, {})
|
||||||
pays=vehicle_payments.get(plate, [])
|
pays=vehicle_payments.get(plate, [])
|
||||||
|
|
||||||
|
# 补全缺失的考核目标
|
||||||
|
target_name = info.get('考核目标','')
|
||||||
|
monthly_bonus = info.get('月度奖励',0)
|
||||||
|
if not target_name:
|
||||||
|
company = mv.get('归属公司','')
|
||||||
|
vtype = mv.get('车型确定','')
|
||||||
|
mapped = VEHICLE_TARGET_MAP.get((company, vtype))
|
||||||
|
if mapped:
|
||||||
|
target_name, _, monthly_bonus = mapped
|
||||||
|
|
||||||
row=[plate,mv.get('车架号',''),mv.get('归属公司',''),mv.get('车型确定',''),
|
row=[plate,mv.get('车架号',''),mv.get('归属公司',''),mv.get('车型确定',''),
|
||||||
info.get('考核目标',''),info.get('月度奖励',0) or '']
|
target_name or '',monthly_bonus or '']
|
||||||
|
|
||||||
cum_t=0; cum_a=0
|
cum_t=0; cum_a=0
|
||||||
for m in range(1, settle_month+1):
|
for m in range(1, settle_month+1):
|
||||||
@@ -369,7 +383,8 @@ def write_vehicle_tracking_sheet(wb, settle_month, G, master_vehicles, vehicle_p
|
|||||||
t=g['应考核']; a=g['实际']
|
t=g['应考核']; a=g['实际']
|
||||||
cum_t+=t; cum_a+=a
|
cum_t+=t; cum_a+=a
|
||||||
q='达标' if g['有达标'] else '未达标'
|
q='达标' if g['有达标'] else '未达标'
|
||||||
lines.append(f"{g['销售']}: {R(a,0)}/{R(t,0)} {q}")
|
sd = g['部门'].replace('业务','') if '业务' in g.get('部门','') else g.get('部门','')
|
||||||
|
lines.append(f"{sd}-{g['销售']}: {R(a,0)}/{R(t,0)} {q}")
|
||||||
row.append('\n'.join(lines))
|
row.append('\n'.join(lines))
|
||||||
else:
|
else:
|
||||||
row.append('')
|
row.append('')
|
||||||
@@ -383,7 +398,8 @@ def write_vehicle_tracking_sheet(wb, settle_month, G, master_vehicles, vehicle_p
|
|||||||
if tp:
|
if tp:
|
||||||
pay_lines = []
|
pay_lines = []
|
||||||
for p in sorted(tp, key=lambda x: x['业务员']):
|
for p in sorted(tp, key=lambda x: x['业务员']):
|
||||||
pay_lines.append(f"{p['业务员']}: {R(p['金额'])}({p['类型']})")
|
pd = p.get('部门','').replace('业务','') if '业务' in p.get('部门','') else p.get('部门','')
|
||||||
|
pay_lines.append(f"{pd}-{p['业务员']}: {R(p['金额'])}({p['类型']})")
|
||||||
row.append('\n'.join(pay_lines))
|
row.append('\n'.join(pay_lines))
|
||||||
else:
|
else:
|
||||||
row.append('')
|
row.append('')
|
||||||
|
|||||||
8
main.py
8
main.py
@@ -74,13 +74,13 @@ for settle_month in [1, 2, 3]:
|
|||||||
else:
|
else:
|
||||||
write_summary_month(wb, 3, mar_data, ['结转','补发1月','补发2月','当月','累计补发3月'])
|
write_summary_month(wb, 3, mar_data, ['结转','补发1月','补发2月','当月','累计补发3月'])
|
||||||
|
|
||||||
# Sheet 5-16: 业务员
|
# Sheet 5: 车辆考核追踪
|
||||||
|
write_vehicle_tracking_sheet(wb, settle_month, G, master_vehicles, vehicle_payments, vehicle_info)
|
||||||
|
|
||||||
|
# Sheet 6-17: 业务员
|
||||||
for person in sorted(all_persons.keys()):
|
for person in sorted(all_persons.keys()):
|
||||||
write_salesperson_sheet(wb, person, all_persons[person], settle_month, D, G, month_data, vehicle_payments)
|
write_salesperson_sheet(wb, person, all_persons[person], settle_month, D, G, month_data, vehicle_payments)
|
||||||
|
|
||||||
# Sheet 17: 车辆考核追踪
|
|
||||||
write_vehicle_tracking_sheet(wb, settle_month, G, master_vehicles, vehicle_payments, vehicle_info)
|
|
||||||
|
|
||||||
# 删除默认空sheet
|
# 删除默认空sheet
|
||||||
if 'Sheet' in wb.sheetnames:
|
if 'Sheet' in wb.sheetnames:
|
||||||
del wb['Sheet']
|
del wb['Sheet']
|
||||||
|
|||||||
Reference in New Issue
Block a user