chore: curate monthly assessment evidence and scripts

This commit is contained in:
kkfluous
2026-08-25 12:26:35 +08:00
parent 2956496fb0
commit 52dde9195a
117 changed files with 10743 additions and 179 deletions
+52 -7
View File
@@ -61,22 +61,32 @@ def write_total(ws, rn, month, all_data):
def write_rules_sheet(wb):
ws = wb.active; ws.title='考核奖励规则'
WH(ws,['考核目标','月度目标里程(km)','奖励金额(元)'])
for i,(n,km,b) in enumerate([('交投40辆4.5T普货',3000,150),('交投190辆4.5T冷链车',3000,150),
('羚牛136辆4.5T冷链车',5000,260),('恒运50辆4.5T普货',5000,260),('羚牛100辆18T',6000,1000)],2):
WR(ws,i,[n,km,b])
WH(ws,['考核目标','月度目标里程(km)','当月达标','当月未达标','结转','补发/累计补发'])
for i,(n,km,g,b,c,o,is18t) in enumerate([
('交投40辆4.5T普货',3000,150,0,150,150,False),
('交投190辆4.5T冷链车',3000,150,0,150,150,False),
('羚牛136辆4.5T冷链车',5000,260,0,260,260,False),
('恒运50辆4.5T普货',5000,260,0,260,260,False),
('羚牛100辆18T',6000,1000,0,1000,1000,True),
('2026年7月指定4辆18T',5000,150,0,150,150,True),
],2):
WR(ws,i,[n,km,
f'{g}元×天数折算',
f'{b}元×天数折算' if is18t else '不发',
f'{c}元整月',
f'{o}元×折算'])
AW(ws)
def write_detail_sheet(wb, records, month):
ws = wb.create_sheet(f'里程明细{month}')
WH(ws,['车牌号','部门名称','销售经理','客户名称','合同编号','考核目标','月度目标里程','对应月奖励金额',
WH(ws,['车牌号','部门名称','销售经理','客户名称','合同编号','考核目标','月度目标里程','月奖励金额',
'考核天数',f'{month}月应考核里程',f'{month}月实际行驶里程','完成率',f'{month}月是否达标',
f'{month}月奖金(天数折算)','多跑里程','可结转月数','考核状态'])
rn=2
for r in sorted(records, key=lambda x: (x['销售经理'],x['车牌号'])):
t,a = r['应考核里程(km)'], r['实际行驶里程(km)']
WR(ws,rn,[r['车牌号'],r['部门名称'],r['销售经理'],r.get('客户名称',''),r.get('合同编号',''),
r.get('考核目标',''),r['月度目标里程'],r['对应月奖励金额'],r['考核天数'],
r.get('考核目标',''),r['月度目标里程'],r['奖励基准_达标'],r['考核天数'],
R(t),R(a),R(a/t,4) if t>0 else 0,r['是否达标'],R(r['奖金']),R(r['多跑']),r['可结转'],
r.get('考核状态','')]); rn+=1
AW(ws)
@@ -162,6 +172,41 @@ def write_calc_process_mar(wb, G1, G2, G3, feb_data):
c5,R(cbp3) if cbp3>0 else 0,R(total) if total>0 else 0]); rn+=1
AW(ws)
def write_calc_process_generic(wb, month, G_all, all_data):
"""通用计算过程sheet,支持1-6月"""
G_cur = G_all[month]
headers = ['车牌号','销售经理','部门',
f'{month}月记录数',f'{month}月总天数',f'{month}月应考核',f'{month}月实际',f'{month}月有达标',f'{month}月奖金',
'累计应考核','累计实际','累计达标','可结转','结转发放']
headers += [f'补发{m}' for m in range(1, month)]
headers += ['当月奖金', f'累计补发{month}', f'{month}月发放合计']
ws = wb.create_sheet(f'{month}月计算过程')
WH(ws, headers)
rn = 2
for k in sorted(G_cur.keys(), key=lambda x: (x[1], x[0])):
g = G_cur[k]
if g.get('虚拟'):
continue
cum_q_str = '达标' if g.get('cum_q') else '未达标'
dq_str = '' if g['有达标'] else ''
carry = g.get('结转', 0)
bonus = g.get('当月奖金', 0)
cbp = g.get('累计补发当月', 0)
back_pays = [g.get(f'补发{m}', 0) for m in range(1, month)]
total = carry + bonus + cbp + sum(back_pays)
row = [k[0], k[1], g['部门'],
len(g['recs']), g['天数'], R(g['应考核']), R(g['实际']), dq_str, R(g['奖金']),
R(g.get('cum_t', 0)), R(g.get('cum_a', 0)), cum_q_str,
g.get('可结转', 0), R(carry)]
row += [R(bp) for bp in back_pays]
row += [R(bonus), R(cbp), R(total)]
WR(ws, rn, row)
rn += 1
AW(ws)
def write_summary_jan(wb, records, loss_data=None, plate_client=None):
ws = wb.create_sheet('1月汇总')
jan_dl=[{'车牌':r['车牌号'],'销售':r['销售经理'],'部门':r['部门名称'],'':r['奖金']} for r in records if r['是否达标']=='达标']
@@ -452,7 +497,7 @@ def write_salesperson_sheet(wb, person, dept, settle_month, D, G, month_data, ve
mkm = g_cur['目标km']
# 第1行:车辆信息 + 各月里程/目标
row = [plate, first.get('考核目标',''), g_cur['奖励']]
row = [plate, first.get('考核目标',''), g_cur['奖励达标']]
cum_t = 0; cum_a = 0
for m in range(1, settle_month+1):
gm = G.get(m, {}).get((plate, person))