V3.0.0 叠加客户亏损筛选,生成最终发放记录
新增功能: - 读取1月/2月亏损表,按客户名称匹配考核数据 - 车辆考核追踪新增列:客户名称、客户是否亏损、考核应发、最终发放、未发放原因 - 月汇总新增亏损筛选section:亏损拦截/未匹配/最终发放/汇总 - 3月无亏损表,全部正常发放 - 亏损拦截不补发 规则:客户亏损→该客户下所有车不发;未匹配→标注待人工确认 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -179,6 +179,47 @@ VEHICLE_TARGET_MAP = {
|
||||
('现代氢能科技(广州)有限公司', '4.5吨货车'): ('恒运50辆4.5T普货', 5000, 260),
|
||||
}
|
||||
|
||||
def read_loss_data(month):
|
||||
"""读取亏损表,返回 {客户名称: '是'/'否'} 字典。无亏损表返回None"""
|
||||
import os
|
||||
fp = f'{month}月.xlsx'
|
||||
if not os.path.exists(fp):
|
||||
return None
|
||||
|
||||
wb = openpyxl.load_workbook(fp, data_only=True)
|
||||
ws = wb[wb.sheetnames[0]]
|
||||
h = [c.value for c in next(ws.iter_rows(min_row=1, max_row=1))]
|
||||
|
||||
# 1月: 列名"项目","1月是否亏损"
|
||||
# 2月: 列名"客户名称","是否亏损"
|
||||
client_col = None; loss_col = None
|
||||
for i, col_name in enumerate(h):
|
||||
if col_name and ('项目' in str(col_name) or '客户' in str(col_name)):
|
||||
client_col = i
|
||||
if col_name and '亏损' in str(col_name):
|
||||
loss_col = i
|
||||
|
||||
if client_col is None or loss_col is None:
|
||||
wb.close()
|
||||
return None
|
||||
|
||||
result = {}
|
||||
for row in ws.iter_rows(min_row=2, values_only=True):
|
||||
client = row[client_col]
|
||||
loss = row[loss_col]
|
||||
if client:
|
||||
result[str(client).strip()] = str(loss).strip() if loss else ''
|
||||
wb.close()
|
||||
return result
|
||||
|
||||
def get_vehicle_client_map(D):
|
||||
"""从考核源数据构建 {车牌号: 客户名称} 映射(取最新月的客户名)"""
|
||||
plate_client = {}
|
||||
for m in sorted(D.keys()):
|
||||
for r in D[m]:
|
||||
plate_client[r['车牌号']] = r.get('客户名称', '')
|
||||
return plate_client
|
||||
|
||||
def read_master_vehicles(fp='里程任务考核_Q1汇总.xlsx'):
|
||||
"""从现有Q1汇总文件读取全量车辆台账"""
|
||||
wb = openpyxl.load_workbook(fp, data_only=True)
|
||||
|
||||
Reference in New Issue
Block a user