feat: 更新晋升和晋档逻辑以反映新规则

- 更新晋档和晋级的时间计算逻辑,使用新的起始时间和间隔
- 修改了处理晋升记录的列名,确保与新规则一致
- 调整了异常处理信息,以便更清晰地指示错误来源
This commit is contained in:
Miu Li 2025-06-02 23:18:02 +08:00
parent 68bd515030
commit cb0275485d

24
main.py
View File

@ -26,7 +26,7 @@ Promote = pd.read_excel("原数据.xlsx", sheet_name="职务变动") #
Level_Limit = pd.read_excel("原数据.xlsx", sheet_name="职位规则",usecols="A:B", skiprows=2, names=["limit","role"])
for index, row in BaseData.iterrows():
for col in ["出生年月","任职年月","原职时间","参加工作时间","入职时间", "二档起始", "五档起始", "日期2"]:
for col in ["出生年月","任职年月","原职时间","参加工作时间","入职时间", "晋档起始", "晋级起始", "日期2"]:
BaseData.at[index, col] = custom_date_parser(row[col])
for index, row in Promote.iterrows():
@ -227,20 +227,20 @@ for index, row in BaseData.iterrows():
for index, prow in promote.iterrows(): # 添加晋升记录
History_pd.loc[len(History_pd)] = [prow["工资执行时间"], prow["新职务"], "", "", "", "", "晋升"]
try:
calctime=row["档起始"] + relativedelta(minute=1)
while True: # 添加二级记录
calctime += relativedelta(years=2)
calctime=row["档起始"] + relativedelta(minute=1)
while True: # 添加晋档记录
calctime += relativedelta(years=row["晋档间隔"])
if calctime > nowtime:
break
History_pd.loc[len(History_pd)] = [calctime, "", "", "", "", "", "两年晋档"]
calctime=row["五档起始"]
while True: # 添加级记录
calctime += relativedelta(years=5)
History_pd.loc[len(History_pd)] = [calctime, "", "", "", "", "", "晋档"]
calctime=row["晋级起始"]
while True: # 添加级记录
calctime += relativedelta(years=row["晋级间隔"])
if calctime > nowtime:
break
History_pd.loc[len(History_pd)] = [calctime, "", "", "", "", "", "五年晋级"]
History_pd.loc[len(History_pd)] = [calctime, "", "", "", "", "", "晋级"]
except:
raise Exception(f"二、五档起始时间格式错误:{row['档起始']}{row['五档起始']}")
raise Exception(f"晋级、档起始时间格式错误:{row['档起始']}{row['晋级起始']}")
for rule in Rule_Level: # 工资调标
if row["入职时间"] < rule["start"]:
History_pd.loc[len(History_pd)] = [rule["start"], "", "", "", "", "", "工资调标"]
@ -258,9 +258,9 @@ for index, row in BaseData.iterrows():
History_pd.at[index, "职务"] = rule["rule"][rule["rule"]["原名称"] == History_pd.iloc[index]["职务"]]["现名称"].values[0]
if index > 0 and hrow["级别档次"] == "":
jb, dc = split_level(History_pd.iloc[index-1]["级别档次"])
if hrow["变动原因"] == "两年晋档":
if hrow["变动原因"] == "晋档":
History_pd.at[index, "级别档次"] = f"{jb}-{dc+1}"
elif hrow["变动原因"] == "五年晋级":
elif hrow["变动原因"] == "晋级":
History_pd.at[index, "级别档次"] = f"{jb-1}-{dc-1}"
elif hrow["变动原因"] == "工资调标":
History_pd.at[index, "级别档次"] = f"{jb}-{dc}"