feat(ui): 工作台界面全部替换为element plus
This commit is contained in:
1 parent
26d213c05b
commit
d5f988a16c
38 files changed
+4501
-3087
No files matched your search
@@ -5,6 +5,7 @@ backend/app/services/voucher_check/notification.py
|
||||
依赖:wecom_notify、notify_config_service、ScheduleTask.notify_user_ids_json、engine_persistence。
|
||||
逻辑:缺件按文件类型接收人拆成每人一封,正文只含该人负责且本批缺失的类型;
|
||||
卡片标题为「销售开票附件缺件提醒」,不写业务方代号和批次号;
|
||||
卡片发出后紧跟本批检核结果 Excel,收件人不用进详情才知道缺哪张票;
|
||||
排程「启用通知」为总开关;技术失败仍走排程通知人;domain_notification_managed 避免通用排程重复通知。
|
||||
"""
|
||||
|
||||
@@ -59,7 +60,7 @@ def _missing_textcard(period_month: str, items: list[dict[str, Any]]) -> tuple[s
|
||||
_friendly_period_label(period_month),
|
||||
"销售开票附件已检核,你负责的类型还有缺件:",
|
||||
*[_missing_type_line(item) for item in items],
|
||||
"请尽快补齐。完整清单见详情里的 Excel。",
|
||||
"请尽快补齐。缺件明细见下一条 Excel。",
|
||||
]
|
||||
)
|
||||
return "销售开票附件缺件提醒", body
|
||||
@@ -113,6 +114,36 @@ def _persist_skip(
|
||||
return send_status
|
||||
|
||||
|
||||
def _send_excel_file(wecom_userid: str, media_id: str) -> bool:
|
||||
"""
|
||||
把已上传的检核结果 Excel 发给一个收件人。
|
||||
核心逻辑:企微文件消息与 textcard 是两条消息,失败只记日志,不回滚已发出的卡片。
|
||||
|
||||
Returns:
|
||||
企业微信 errcode 为 0 时为 True。
|
||||
"""
|
||||
from app.services.integrations.wecom.notify import send_wecom_file_message
|
||||
|
||||
try:
|
||||
data = send_wecom_file_message(wecom_userid, media_id)
|
||||
except Exception as exc:
|
||||
current_app.logger.warning(
|
||||
"[voucher-check] excel file failed user=%s err=%s",
|
||||
wecom_userid,
|
||||
exc,
|
||||
)
|
||||
return False
|
||||
if data.get("errcode") == 0:
|
||||
return True
|
||||
current_app.logger.warning(
|
||||
"[voucher-check] excel file failed user=%s errcode=%s errmsg=%s",
|
||||
wecom_userid,
|
||||
data.get("errcode"),
|
||||
data.get("errmsg"),
|
||||
)
|
||||
return False
|
||||
|
||||
|
||||
def send_batch_missing_summary(
|
||||
*,
|
||||
task: ScheduleTask,
|
||||
@@ -122,11 +153,17 @@ def send_batch_missing_summary(
|
||||
period_month: str,
|
||||
stats: dict[str, Any],
|
||||
excel_filename: str | None,
|
||||
excel_bytes: bytes | None = None,
|
||||
enabled: bool,
|
||||
) -> str:
|
||||
"""
|
||||
按文件类型接收人发送缺件 textcard。
|
||||
核心逻辑:每人一封,只列出该人负责且本批缺失的类型;标题写明销售开票附件,不写业务方代号和批次号。无缺件或无人可发则写审计不发空消息。
|
||||
按文件类型接收人发送缺件 textcard,并附上本批检核结果 Excel。
|
||||
核心逻辑:每人一封,只列出该人负责且本批缺失的类型;标题写明销售开票附件,不写业务方代号和批次号。
|
||||
Excel 全批共用一份,上传一次后随卡片发给每个收件人。附件失败不挡住卡片,原因写入审计。
|
||||
无缺件或无人可发则写审计不发空消息。
|
||||
|
||||
Args:
|
||||
excel_bytes: 与排程落库同一份检核结果。为空时只发卡片。
|
||||
|
||||
Returns:
|
||||
send_status:sent / skipped_no_missing / skipped_no_recipients / skipped_disabled / failed
|
||||
@@ -213,9 +250,20 @@ def send_batch_missing_summary(
|
||||
_build_jump_url,
|
||||
_create_audit,
|
||||
send_wecom_textcard_message,
|
||||
upload_wecom_temp_media,
|
||||
)
|
||||
|
||||
media_id = None
|
||||
file_note = None
|
||||
if excel_bytes and excel_filename:
|
||||
try:
|
||||
media_id = upload_wecom_temp_media(excel_bytes, excel_filename)
|
||||
except Exception as exc:
|
||||
file_note = "Excel 附件上传失败"
|
||||
current_app.logger.warning("[voucher-check] excel upload failed: %s", exc)
|
||||
|
||||
ok_any = False
|
||||
file_failed = False
|
||||
sent_ids: list[int] = []
|
||||
for user in users:
|
||||
items = plan["user_rules"].get(int(user.id)) or []
|
||||
@@ -234,6 +282,8 @@ def send_batch_missing_summary(
|
||||
audit.status = "sent"
|
||||
ok_any = True
|
||||
sent_ids.append(int(user.id))
|
||||
if media_id and not _send_excel_file(user.wecom_userid, media_id):
|
||||
file_failed = True
|
||||
else:
|
||||
audit.error_code = str(data.get("errcode"))
|
||||
audit.error_message = str(data.get("errmsg", "unknown"))[:255]
|
||||
@@ -244,11 +294,16 @@ def send_batch_missing_summary(
|
||||
exc,
|
||||
)
|
||||
|
||||
skip_reason = None
|
||||
if file_failed and not file_note:
|
||||
file_note = "部分 Excel 附件发送失败"
|
||||
reasons: list[str] = []
|
||||
if not ok_any:
|
||||
skip_reason = "企业微信发送失败"
|
||||
reasons.append("企业微信发送失败")
|
||||
elif plan["unmapped_codes"]:
|
||||
skip_reason = "部分文件类型未配置接收人"
|
||||
reasons.append("部分文件类型未配置接收人")
|
||||
if file_note:
|
||||
reasons.append(file_note)
|
||||
skip_reason = ";".join(reasons) or None
|
||||
persist_notification(
|
||||
run_id=engine_run_id,
|
||||
excel_filename=excel_filename,
|
||||
|
||||
Reference in new issue
Block a user