refactor(workflows): 统一替换 yingdao 目录引用为 workflows
1. 将所有文档、代码中对 `yingdao/` 目录的引用替换为 `workflows/`,统一影刀版代码的命名空间 2. 调整 workflows/share 模块内的路径引用与文档注释,确保一致性 3. 同步更新测试代码与配置文件中的旧目录引用
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""考勤月报封存检查 - Excel 报告导出(webhost 场景插件)
|
||||
|
||||
与 desktop/plugins/seal_check/report.py 保持同步(桌面版为单一真源)。
|
||||
|
||||
输出:考勤月报封存检查_{月份}_{时间戳}.xlsx(汇总 + 检查1~5 Sheet,空 Sheet 保留表头)
|
||||
"""
|
||||
import os
|
||||
from datetime import datetime
|
||||
from typing import Dict, List
|
||||
|
||||
from webhost.backend.plugins.seal_check import config
|
||||
from webhost.backend.plugins.seal_check.logic import OUTPUT_COLUMNS, TYPE_1, TYPE_3, TYPE_4, TYPE_5
|
||||
|
||||
CHECK_TAB_TITLES = {
|
||||
1: "检查1_在职天数排班异常",
|
||||
2: "检查2_排休天数异常",
|
||||
3: "检查3_封存非最新值",
|
||||
4: "检查4_出勤天数异常",
|
||||
5: "检查5_未封存名单",
|
||||
}
|
||||
|
||||
CHECK_DESCRIPTIONS = {
|
||||
1: TYPE_1,
|
||||
2: "当月排休不满足……天规则(动态)",
|
||||
3: TYPE_3,
|
||||
4: TYPE_4,
|
||||
5: TYPE_5,
|
||||
}
|
||||
|
||||
|
||||
def export_report(rows_map: Dict[int, List[dict]], month: str, notes: List[str] = None,
|
||||
save_dir: str = None) -> str:
|
||||
try:
|
||||
import pandas as pd
|
||||
except ImportError:
|
||||
raise RuntimeError("缺少 pandas / openpyxl 依赖,无法导出 Excel")
|
||||
|
||||
save_dir = save_dir or config.SAVE_DIR
|
||||
os.makedirs(save_dir, exist_ok=True)
|
||||
ts = datetime.now().strftime("%Y%m%d_%H%M%S")
|
||||
path = os.path.join(save_dir, f"考勤月报封存检查_{month}_{ts}.xlsx")
|
||||
|
||||
with pd.ExcelWriter(path, engine="openpyxl") as writer:
|
||||
summary = []
|
||||
for i in range(1, 6):
|
||||
n = len(rows_map.get(i, []))
|
||||
summary.append({
|
||||
"检查项": CHECK_TAB_TITLES[i],
|
||||
"命中条数": n,
|
||||
"异常类型": CHECK_DESCRIPTIONS[i],
|
||||
"说明": "详见对应 Sheet" if n else "无异常",
|
||||
})
|
||||
if notes:
|
||||
summary.append({"检查项": "备注", "命中条数": len(notes),
|
||||
"异常类型": "", "说明": ";".join(notes)})
|
||||
pd.DataFrame(summary).to_excel(writer, sheet_name="汇总", index=False)
|
||||
|
||||
for i in range(1, 6):
|
||||
df = pd.DataFrame(rows_map.get(i, []), columns=OUTPUT_COLUMNS)
|
||||
df.to_excel(writer, sheet_name=CHECK_TAB_TITLES[i], index=False)
|
||||
|
||||
return path
|
||||
Reference in New Issue
Block a user