45 lines
2.3 KiB
Python
45 lines
2.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""从考核方案工作簿提取「项目经理(王宇航)」sheet,注入导出占位符,生成导出模板"""
|
|
import sys, io, shutil
|
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
|
import openpyxl
|
|
|
|
SRC = r'F:/zentao/1/信息技术部绩效考核标准-新版 - AI下的考核方案.xlsx'
|
|
DST = r'F:/zentao/1/PM/codes/zentao/src/main/resources/templates/scope/项目经理考核-王宇航.xlsx'
|
|
TARGET_CLS = r'F:/zentao/1/PM/codes/zentao/target/classes/templates/scope/项目经理考核-王宇航.xlsx'
|
|
|
|
wb = openpyxl.load_workbook(SRC)
|
|
keep = '项目经理(王宇航)'
|
|
for name in list(wb.sheetnames):
|
|
if name != keep:
|
|
wb.remove(wb[name])
|
|
ws = wb[keep]
|
|
|
|
# 表头占位符(与通用模板同位置)
|
|
ws['F2'] = '{name}'
|
|
ws['H2'] = '{date}'
|
|
|
|
# 数据行占位符(G=绩效数据明细, H=本期结果得分;行版式按王宇航 sheet)
|
|
ws['G4'] = '{detail_workloadTeamScore}'; ws['H4'] = '{workloadTeamScore}' # 团队工作量 0.4
|
|
ws['G5'] = '{detail_versionPlanFinishedRate}'; ws['H5'] = '{versionPlanFinishedRate}' # 版本计划 0.1
|
|
ws['G6'] = '{detail_bugScore}'; ws['H6'] = '{bugScore}' # 线上Bug 0.1
|
|
ws['G7'] = '{detail_documentQualityScore}'; ws['H7'] = '{documentQualityScore}' # 文档齐备 0.1
|
|
ws['H8'] = '{developFeedbackStory}' # 问题管理 0.05
|
|
ws['H9'] = '{systemStabilityScore}' # 系统稳定性 0.2
|
|
ws['H10'] = '{professionalSkillEnhancementScore}' # 专业技能 0.05
|
|
ws['H11'] = '{total}' # 合计
|
|
|
|
wb.save(DST)
|
|
shutil.copy(DST, TARGET_CLS) # target/classes 同步一份,IDE 方式运行的服务免重启生效
|
|
|
|
# 校验:重新打开,确认占位符齐全、公式与合并单元格未丢
|
|
wb2 = openpyxl.load_workbook(DST)
|
|
ws2 = wb2.active
|
|
ph = [f'{c.coordinate}={c.value}' for row in ws2.iter_rows() for c in row
|
|
if isinstance(c.value, str) and '{' in c.value]
|
|
print('sheets:', wb2.sheetnames)
|
|
print('placeholders(%d):' % len(ph))
|
|
for p in ph: print(' ', p)
|
|
print('C11 formula:', ws2['C11'].value)
|
|
print('merged:', [str(r) for r in ws2.merged_cells.ranges])
|