Files
hospital_performance/backend/app/utils/__init__.py
2026-02-28 15:06:52 +08:00

34 lines
758 B
Python

"""
工具函数模块
"""
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}"