Class WorkflowThreadRoutingStrategy
java.lang.Object
com.bytedesk.service.routing_strategy.AbstractThreadRoutingStrategy
com.bytedesk.service.routing_strategy.WorkflowThreadRoutingStrategy
@Component("workflowThreadStrategy")
public class WorkflowThreadRoutingStrategy
extends AbstractThreadRoutingStrategy
工作流线程路由策略
功能特点: - 基于工作流的自动化对话处理 - 不支持转人工,完全自动化流程 - 支持会话复用和状态管理
处理流程: 1. 验证工作流配置 2. 检查现有会话状态 3. 创建或复用工作流会话 4. 启动工作流处理
- Since:
- 1.0.0
- Author:
- jackning 270580156@qq.com
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.springframework.context.ApplicationEventPublisher
private final MessageRestService
private final QueueMemberRestService
private final QueueService
private final ThreadRestService
private final VisitorThreadService
private final WorkflowRestService
Fields inherited from class com.bytedesk.service.routing_strategy.AbstractThreadRoutingStrategy
DEFAULT_OFFLINE_MESSAGE, DEFAULT_WELCOME_MESSAGE, ESTIMATED_WAIT_TIME_PER_PERSON, MESSAGE_CACHE_MINUTES, QUEUE_NEXT_MESSAGE, QUEUE_WAITING_MESSAGE_TEMPLATE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate MessageProtobuf
createAndSaveWelcomeMessage
(String content, ThreadEntity thread) 创建并保存工作流欢迎消息createThread
(VisitorRequest visitorRequest) 创建线程的核心方法 由具体实现类负责处理不同类型的线程创建逻辑createWorkflowThread
(VisitorRequest request) 创建工作流会话private ThreadEntity
getOrCreateWorkflowThread
(VisitorRequest request, WorkflowEntity workflowEntity, String topic) 获取或创建工作流会话protected ThreadRestService
获取线程服务实例 由具体实现类提供private MessageProtobuf
getWorkflowContinueMessage
(WorkflowEntity workflowEntity, ThreadEntity thread) 获取工作流继续对话消息private WorkflowEntity
getWorkflowEntity
(String workflowUid) 获取工作流实体private String
获取工作流欢迎消息 工作流使用默认欢迎消息private MessageProtobuf
handleExistingWorkflowThread
(WorkflowEntity workflowEntity, ThreadEntity thread) 处理现有的工作流会话private boolean
isExistingWorkflowThread
(ThreadEntity thread) 检查是否为现有的工作流会话private MessageProtobuf
processNewWorkflowThread
(VisitorRequest request, ThreadEntity thread, WorkflowEntity workflowEntity) 处理新的工作流会话private void
publishWorkflowThreadEvent
(ThreadEntity savedThread) 发布工作流线程事件private void
updateQueueMemberForWorkflow
(QueueMemberEntity queueMemberEntity) 更新队列成员状态为工作流自动接受Methods inherited from class com.bytedesk.service.routing_strategy.AbstractThreadRoutingStrategy
executeWithExceptionHandling, generateQueueMessage, getThreadByUid, getValidOfflineMessage, getValidWelcomeMessage, handleStrategyException, isActiveThread, isClosedThread, isMessageInCacheTime, isNewThread, logThreadStatusChange, saveThread, validateThread, validateUid
-
Field Details
-
workflowRestService
-
threadRestService
-
visitorThreadService
-
queueService
-
queueMemberRestService
-
applicationEventPublisher
private final org.springframework.context.ApplicationEventPublisher applicationEventPublisher -
messageRestService
-
-
Constructor Details
-
WorkflowThreadRoutingStrategy
public WorkflowThreadRoutingStrategy()
-
-
Method Details
-
getThreadRestService
Description copied from class:AbstractThreadRoutingStrategy
获取线程服务实例 由具体实现类提供- Specified by:
getThreadRestService
in classAbstractThreadRoutingStrategy
- Returns:
- ThreadRestService实例
-
createThread
Description copied from class:AbstractThreadRoutingStrategy
创建线程的核心方法 由具体实现类负责处理不同类型的线程创建逻辑- Specified by:
createThread
in classAbstractThreadRoutingStrategy
- Parameters:
visitorRequest
- 访客请求信息- Returns:
- 消息协议对象
-
createWorkflowThread
创建工作流会话- Parameters:
request
- 访客请求- Returns:
- 消息协议对象
-
getWorkflowEntity
获取工作流实体 -
getOrCreateWorkflowThread
private ThreadEntity getOrCreateWorkflowThread(VisitorRequest request, WorkflowEntity workflowEntity, String topic) 获取或创建工作流会话 -
isExistingWorkflowThread
检查是否为现有的工作流会话 -
handleExistingWorkflowThread
private MessageProtobuf handleExistingWorkflowThread(WorkflowEntity workflowEntity, ThreadEntity thread) 处理现有的工作流会话 -
processNewWorkflowThread
private MessageProtobuf processNewWorkflowThread(VisitorRequest request, ThreadEntity thread, WorkflowEntity workflowEntity) 处理新的工作流会话 -
getWorkflowWelcomeMessage
获取工作流欢迎消息 工作流使用默认欢迎消息 -
updateQueueMemberForWorkflow
更新队列成员状态为工作流自动接受 -
publishWorkflowThreadEvent
发布工作流线程事件 -
createAndSaveWelcomeMessage
创建并保存工作流欢迎消息 -
getWorkflowContinueMessage
private MessageProtobuf getWorkflowContinueMessage(WorkflowEntity workflowEntity, @Nonnull ThreadEntity thread) 获取工作流继续对话消息
-