add backend source code
This commit is contained in:
33
backend/app/utils/__init__.py
Normal file
33
backend/app/utils/__init__.py
Normal file
@@ -0,0 +1,33 @@
|
||||
"""
|
||||
工具函数模块
|
||||
"""
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
|
||||
def get_current_period() -> tuple[int, int]:
|
||||
"""获取当前考核周期(年、月)"""
|
||||
now = datetime.now()
|
||||
return now.year, now.month
|
||||
|
||||
|
||||
def format_period(year: int, month: int) -> str:
|
||||
"""格式化考核周期"""
|
||||
return f"{year}年{month:02d}月"
|
||||
|
||||
|
||||
def calculate_score_level(score: float) -> str:
|
||||
"""计算绩效等级"""
|
||||
if score >= 90:
|
||||
return "优秀"
|
||||
elif score >= 80:
|
||||
return "良好"
|
||||
elif score >= 60:
|
||||
return "合格"
|
||||
else:
|
||||
return "不合格"
|
||||
|
||||
|
||||
def generate_employee_id(department_code: str, sequence: int) -> str:
|
||||
"""生成员工工号"""
|
||||
return f"{department_code}{sequence:04d}"
|
||||
Reference in New Issue
Block a user