chat聊天OA请假优化

This commit is contained in:
runny committed 2026-05-16 16:55:23 +08:00
1 parent 3b31867319
commit 05abffc5f0
5 files changed
+67 -25

No files matched your search

+16 -16
View File
@@ -198,22 +198,14 @@ WHERE c002001 = ?
return str(datetime.now().year)
@classmethod
def _render_section(cls, title: str, record: dict | None, requested_year: int | None) -> str:
def _render_table_row(cls, index: int, title: str, record: dict | None, requested_year: int | None) -> str:
response_year = cls._resolve_response_year(record, requested_year)
if not record:
return (
f"### {title}\n\n"
f"暂未查询到您 {response_year} 年度的{title}记录。"
)
remaining = cls._format_quota(record.get("remaining_hours"))
return (
f"### {title}\n\n"
f"您当前{title}剩余额度为 {remaining}。\n"
f"- 年度:{response_year}\n"
f"- 年度可休:{cls._format_quota(record.get('total_hours'))}\n"
f"- 已休:{cls._format_quota(record.get('used_hours'))}\n"
f"- 当前剩余:{remaining}"
)
return f"| {index} | {title} | {response_year} | 暂无数据 | 暂无数据 | 暂无数据 |"
total = cls._format_quota(record.get('total_hours'))
used = cls._format_quota(record.get('used_hours'))
remaining = cls._format_quota(record.get('remaining_hours'))
return f"| {index} | {title} | {response_year} | {total} | {used} | {remaining} |"
@classmethod
def _build_result_text(cls, leave_type: str, requested_year: int | None, annual_result, childcare_result):
@@ -235,11 +227,19 @@ WHERE c002001 = ?
)
sections = [
f"您好,已为您查询到 {intro_year} 年度假期情况:",
"",
"| 序号 | 假别 | 年度 | 可休 | 已休 | 当前剩余 |",
"| :---: | :---: | :---: | :---: | :---: | :---: |",
]
index = 1
if leave_type in ("annual", "all"):
sections.extend(["", cls._render_section("年假", annual_record, requested_year)])
sections.append(cls._render_table_row(index, "年假", annual_record, requested_year))
index += 1
if leave_type in ("childcare", "all"):
sections.extend(["", cls._render_section("育儿假", childcare_record, requested_year)])
sections.append(cls._render_table_row(index, "育儿假", childcare_record, requested_year))
index += 1
sections.extend(
[
"",