fix: 更新职级上限规则处理逻辑以支持新职位名称的级别限制
- 调整职位规则读取逻辑,增加对级别限制的处理 - 修改列索引以适应新的数据结构 - 优化异常处理,确保在角色不存在时记录警告信息
This commit is contained in:
parent
cb0275485d
commit
cdb2716064
16
main.py
16
main.py
@ -23,7 +23,6 @@ def custom_date_parser(x):
|
|||||||
|
|
||||||
BaseData = pd.read_excel("原数据.xlsx", sheet_name="入职信息")
|
BaseData = pd.read_excel("原数据.xlsx", sheet_name="入职信息")
|
||||||
Promote = pd.read_excel("原数据.xlsx", sheet_name="职务变动") #
|
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 index, row in BaseData.iterrows():
|
||||||
for col in ["出生年月","任职年月","原职时间","参加工作时间","入职时间", "晋档起始", "晋级起始", "日期2"]:
|
for col in ["出生年月","任职年月","原职时间","参加工作时间","入职时间", "晋档起始", "晋级起始", "日期2"]:
|
||||||
@ -75,6 +74,14 @@ while True: # 名称变化
|
|||||||
except:
|
except:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
# 读取职位对应的级别限制
|
||||||
|
Level_Limit_tmp = pd.read_excel("原数据.xlsx", sheet_name="职位规则", usecols="A:A", skiprows=2, names=["limit"])
|
||||||
|
Level_Limit = {}
|
||||||
|
for rule in Rule_Role:
|
||||||
|
for index, row in rule["rule"].iterrows():
|
||||||
|
Level_Limit[row["role"]] = Level_Limit_tmp.iloc[index]["limit"]
|
||||||
|
|
||||||
|
|
||||||
logging.info("规则加载完成")
|
logging.info("规则加载完成")
|
||||||
|
|
||||||
Rule_Role = sorted(Rule_Role, key=lambda x: x['start'])
|
Rule_Role = sorted(Rule_Role, key=lambda x: x['start'])
|
||||||
@ -115,10 +122,9 @@ def level_salary(level:str, time):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
def role_limit(role:str):
|
def role_limit(role:str):
|
||||||
try:
|
if role in Level_Limit.keys():
|
||||||
tmp = Level_Limit[Level_Limit["role"] == role].iloc[0]
|
return Level_Limit[role]
|
||||||
return tmp["limit"]
|
else:
|
||||||
except:
|
|
||||||
logging.warning(f"职位[{role}]不存在职级上限规则")
|
logging.warning(f"职位[{role}]不存在职级上限规则")
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user