refactor(leave): 重构请假审批校验逻辑,升级排班数据获取方式
1. 请假解析器新增工号、开始/结束日期字段,优化日期取值逻辑 2. 排班数据从考勤逐日接口改为HR排班接口,支持跨月和未来日期查询 3. 校验逻辑改用工号查询排班,新增HR会话缓存复用机制 4. 修复测试用例适配新的排班数据结构 5. 更新文档说明钉钉推送消息格式变更 6. 雇主险脚本优化文件选择逻辑,按文件名日期而非修改时间排序 7. 影刀登录模块移除环境变量依赖,内置默认配置 8. 加班审批脚本适配新的消息推送格式,新增超期处理类型
This commit is contained in:
@@ -151,6 +151,9 @@ def main(text, title='消息通知', status='info', webhook='', secret='', serve
|
||||
|
||||
main("订单同步失败,错误原因:接口超时")
|
||||
|
||||
支持逐条推送多条:text 传「文本列表」时按顺序逐条发送,列表项可为纯文本,
|
||||
也可为字典 {text, title?, status?} 自定义该条标题与颜色(缺省用 main 的 title/status)。
|
||||
|
||||
可选参数:
|
||||
title: 消息标题(默认 消息通知)
|
||||
status: info|success|warning|error,决定标题颜色(默认 info)
|
||||
@@ -162,7 +165,8 @@ def main(text, title='消息通知', status='info', webhook='', secret='', serve
|
||||
返回: {"success": bool, "message": str}
|
||||
"""
|
||||
try:
|
||||
if not text or not str(text).strip():
|
||||
if text is None or (isinstance(text, str) and not str(text).strip()) \
|
||||
or (isinstance(text, list) and not text):
|
||||
return {'success': False, 'message': '通知文本不能为空'}
|
||||
env_key = (env or 'prod').strip().lower()
|
||||
if env_key not in ENV_CONFIGS:
|
||||
@@ -174,13 +178,32 @@ def main(text, title='消息通知', status='info', webhook='', secret='', serve
|
||||
if not webhook:
|
||||
return {'success': False, 'message': f'环境 [{env_key}] 的 webhook 未配置,请先在 dingtalk_robot.py 中填写'}
|
||||
robot = DingTalkRobot(webhook=webhook, secret=secret, server_name=server_name)
|
||||
robot.send(str(title), str(text), status=status, server_name=server_name)
|
||||
return {'success': True, 'message': f'已推送通知 [{env_key}/{status}]:{title}'}
|
||||
|
||||
items = text if isinstance(text, list) else [text]
|
||||
sent = 0
|
||||
last_title, last_status = title, status
|
||||
for item in items:
|
||||
if isinstance(item, dict):
|
||||
t = item.get('text')
|
||||
ti = item.get('title', title)
|
||||
st = item.get('status', status)
|
||||
else:
|
||||
t, ti, st = item, title, status
|
||||
if t is None or not str(t).strip():
|
||||
continue
|
||||
robot.send(str(ti), str(t), status=st, server_name=server_name)
|
||||
sent += 1
|
||||
last_title, last_status = ti, st
|
||||
if sent == 0:
|
||||
return {'success': False, 'message': '通知文本为空'}
|
||||
if len(items) == 1:
|
||||
return {'success': True, 'message': f'已推送通知 [{env_key}/{last_status}]:{last_title}'}
|
||||
return {'success': True, 'message': f'已推送 {sent} 条通知 [{env_key}]'}
|
||||
except Exception as e:
|
||||
return {'success': False, 'message': str(e)}
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
text = '测试消息:钉钉机器人连接正常。'
|
||||
text = ['测试消息:钉钉机器人连接正常。', '测试消息:钉钉机器人连接正常。']
|
||||
notice_type='dev'
|
||||
print(main(text, env=notice_type))
|
||||
|
||||
Reference in New Issue
Block a user