feat: wire feishu notifications into workflows
This commit is contained in:
@@ -18,6 +18,8 @@ from review_agent.models import (
|
||||
RegulatoryReviewBatch,
|
||||
WorkflowNodeRun,
|
||||
)
|
||||
from review_agent.notifications.dispatcher import dispatch_workflow_notification
|
||||
from review_agent.notifications.workflow_adapters import build_regulatory_review_context
|
||||
from review_agent.regulatory_review.services.completeness_check import run_completeness_check
|
||||
from review_agent.regulatory_review.services.consistency_check import run_consistency_check
|
||||
from review_agent.regulatory_review.services.export import build_assistant_summary, export_review_results
|
||||
@@ -146,14 +148,25 @@ class RegulatoryWorkflowExecutor:
|
||||
self.batch.finished_at = timezone.now()
|
||||
self.batch.save(update_fields=["status", "error_message", "finished_at"])
|
||||
record_event(self.batch, "workflow_failed", {"message": str(exc)})
|
||||
self._dispatch_completion_notification()
|
||||
return
|
||||
|
||||
self.batch.status = RegulatoryReviewBatch.Status.SUCCESS
|
||||
self.batch.finished_at = timezone.now()
|
||||
self.batch.save(update_fields=["status", "finished_at"])
|
||||
record_event(self.batch, "workflow_completed", {"batch_id": self.batch.pk})
|
||||
self._dispatch_completion_notification()
|
||||
logger.info("法规核查工作流完成 batch_no=%s findings=%s", self.batch.batch_no, len(self.findings))
|
||||
|
||||
def _dispatch_completion_notification(self) -> None:
|
||||
try:
|
||||
dispatch_workflow_notification(build_regulatory_review_context(self.batch))
|
||||
except Exception as exc:
|
||||
logger.warning(
|
||||
"Regulatory review notification failed without blocking workflow",
|
||||
extra={"batch_id": self.batch.pk, "error": str(exc)},
|
||||
)
|
||||
|
||||
def _nodes(self):
|
||||
return WorkflowNodeRun.objects.filter(
|
||||
workflow_type="regulatory_review",
|
||||
|
||||
Reference in New Issue
Block a user