feat: 启用考勤异常直接推送,重构钉钉推送适配逻辑
1. 启用app版考勤异常推送:移除push_abnormal中的注释,直接调用钉钉推送接口,不再仅打印日志
2. 更新钉钉推送文档与适配逻辑:
- 重构dingtalk_sender参数为search_keyword/verify_keyword替代target/display_name
- 更新考勤异常推送分组与参数格式,适配新的OCR推送逻辑
3. 移除影刀审批脚本的单聊推送支持,统一使用群机器人推送
4. 优化缺勤分析缓存逻辑,移除历史月缓存限制,改用懒加载缓存
5. 为影刀考勤异常脚本新增联调测试模式,避免联调期间打扰真实员工
This commit is contained in:
@@ -204,14 +204,14 @@ def build_notify_text(items: List[dict]) -> str:
|
||||
|
||||
|
||||
def push_abnormal(items: List[dict]) -> int:
|
||||
"""按「姓名-工号」分组生成钉钉通知文本(暂不实际发送,先供人工确认)。
|
||||
"""按「姓名-工号」分组生成钉钉通知文本并直接推送(app 版主脚本直接调用,无需全局变量)。
|
||||
|
||||
同一人员多条异常合并为一条通知,大幅减少推送次数。
|
||||
|
||||
Returns:
|
||||
生成通知的人员数(即推送次数)
|
||||
成功推送的人员数(即推送次数)
|
||||
"""
|
||||
from app.utils.dingtalk_sender import send_to_person # noqa: F401
|
||||
from app.utils.dingtalk_sender import send_to_person
|
||||
|
||||
groups: Dict[tuple, List[dict]] = {}
|
||||
for it in items:
|
||||
@@ -224,10 +224,8 @@ def push_abnormal(items: List[dict]) -> int:
|
||||
|
||||
for (_name, _code), group in groups.items():
|
||||
text = build_notify_text(group)
|
||||
# 先注释掉实际推送,仅输出文本供确认
|
||||
logger.info("【待推送通知】\n%s", text)
|
||||
# send_to_person(_name, text=text)
|
||||
# logger.info("已向 %s 推送考勤异常通知(%d 条合并)", _name, len(group))
|
||||
send_to_person(_name, text=text)
|
||||
logger.info("已向 %s 推送考勤异常通知(%d 条合并)", _name, len(group))
|
||||
return len(groups)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user