From 69ca4623656131e3cb817fb70e5d62058f25eb5d Mon Sep 17 00:00:00 2001 From: jack ning Date: Tue, 1 Apr 2025 15:25:58 +0800 Subject: [PATCH] update modules/ticket: add 2 mod 5 files --- .../core/thread/AbstractThreadEntity.java | 8 +- .../bytedesk/core/thread/ThreadRequest.java | 6 +- .../bytedesk/core/thread/ThreadResponse.java | 8 +- .../bytedesk/ticket/consts/TicketConsts.java | 14 +- .../ticket/TicketThreadEventListener.java | 139 ++++++------ ...20.xml => thread-agent-process.bpmn20.xml} | 2 +- .../processes/thread-group-process.bpmn20.xml | 210 ++++++++++++++++++ .../processes/thread-robot-process.bpmn20.xml | 210 ++++++++++++++++++ 8 files changed, 507 insertions(+), 90 deletions(-) rename modules/ticket/src/main/resources/processes/{group-thread-process.bpmn20.xml => thread-agent-process.bpmn20.xml} (99%) create mode 100644 modules/ticket/src/main/resources/processes/thread-group-process.bpmn20.xml create mode 100644 modules/ticket/src/main/resources/processes/thread-robot-process.bpmn20.xml diff --git a/modules/core/src/main/java/com/bytedesk/core/thread/AbstractThreadEntity.java b/modules/core/src/main/java/com/bytedesk/core/thread/AbstractThreadEntity.java index 1b2201a5e0..f0d4675b35 100644 --- a/modules/core/src/main/java/com/bytedesk/core/thread/AbstractThreadEntity.java +++ b/modules/core/src/main/java/com/bytedesk/core/thread/AbstractThreadEntity.java @@ -2,7 +2,7 @@ * @Author: jackning 270580156@qq.com * @Date: 2024-06-29 13:00:33 * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2025-04-01 14:54:04 + * @LastEditTime: 2025-04-01 15:00:27 * @Description: bytedesk.com https://github.com/Bytedesk/bytedesk * Please be aware of the BSL license restrictions before installing Bytedesk IM – * selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license. @@ -206,10 +206,10 @@ public abstract class AbstractThreadEntity extends BaseEntity { private List ticketors = new ArrayList<>(); // 流程实例ID - private String processInstanceId; + // private String processInstanceId; - // 流程定义实体UID - private String processEntityUid; + // // 流程定义实体UID + // private String processEntityUid; // belongs to user @ManyToOne(fetch = FetchType.LAZY) diff --git a/modules/core/src/main/java/com/bytedesk/core/thread/ThreadRequest.java b/modules/core/src/main/java/com/bytedesk/core/thread/ThreadRequest.java index 7f126f3833..1e38995e19 100644 --- a/modules/core/src/main/java/com/bytedesk/core/thread/ThreadRequest.java +++ b/modules/core/src/main/java/com/bytedesk/core/thread/ThreadRequest.java @@ -144,8 +144,8 @@ public class ThreadRequest extends BaseRequest { private Boolean mergeByTopic = false; // 流程实例ID - private String processInstanceId; + // private String processInstanceId; - // 流程定义实体UID - private String processEntityUid; + // // 流程定义实体UID + // private String processEntityUid; } diff --git a/modules/core/src/main/java/com/bytedesk/core/thread/ThreadResponse.java b/modules/core/src/main/java/com/bytedesk/core/thread/ThreadResponse.java index 111077c8dd..76e16d52a8 100644 --- a/modules/core/src/main/java/com/bytedesk/core/thread/ThreadResponse.java +++ b/modules/core/src/main/java/com/bytedesk/core/thread/ThreadResponse.java @@ -2,7 +2,7 @@ * @Author: jackning 270580156@qq.com * @Date: 2024-02-21 10:01:27 * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2025-04-01 13:37:46 + * @LastEditTime: 2025-04-01 15:00:38 * @Description: bytedesk.com https://github.com/Bytedesk/bytedesk * Please be aware of the BSL license restrictions before installing Bytedesk IM – * selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license. @@ -111,8 +111,8 @@ public class ThreadResponse extends BaseResponse { private UserProtobuf owner; // 流程实例ID - private String processInstanceId; + // private String processInstanceId; - // 流程定义实体UID - private String processEntityUid; + // // 流程定义实体UID + // private String processEntityUid; } diff --git a/modules/ticket/src/main/java/com/bytedesk/ticket/consts/TicketConsts.java b/modules/ticket/src/main/java/com/bytedesk/ticket/consts/TicketConsts.java index 8c696e69a5..0eed5e63b2 100644 --- a/modules/ticket/src/main/java/com/bytedesk/ticket/consts/TicketConsts.java +++ b/modules/ticket/src/main/java/com/bytedesk/ticket/consts/TicketConsts.java @@ -2,7 +2,7 @@ * @Author: jackning 270580156@qq.com * @Date: 2025-01-23 15:00:11 * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2025-04-01 14:30:52 + * @LastEditTime: 2025-04-01 15:25:39 * @Description: bytedesk.com https://github.com/Bytedesk/bytedesk * Please be aware of the BSL license restrictions before installing Bytedesk IM – * selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license. @@ -87,9 +87,17 @@ public class TicketConsts { // thread-process public static final String THREAD_PROCESS_NAME_GROUP = I18Consts.I18N_PREFIX + "thread.process.name.group"; - public static final String THREAD_PROCESS_KEY_GROUP = "groupThreadProcess"; + public static final String THREAD_PROCESS_KEY_GROUP = "threadGroupProcess"; - public static final String THREAD_PROCESS_PATH_GROUP = "processes/group-thread-process.bpmn20.xml"; + public static final String THREAD_PROCESS_PATH_GROUP = "processes/thread-group-process.bpmn20.xml"; + + public static final String THREAD_PROCESS_KEY_AGENT = "threadGroupProcess"; + + public static final String THREAD_PROCESS_PATH_GROUP = "processes/thread-group-process.bpmn20.xml"; + + public static final String THREAD_PROCESS_KEY_GROUP = "threadGroupProcess"; + + public static final String THREAD_PROCESS_PATH_GROUP = "processes/thread-group-process.bpmn20.xml"; // variables public static final String TICKET_VARIABLE_THREAD_UID = "threadUid"; diff --git a/modules/ticket/src/main/java/com/bytedesk/ticket/ticket/TicketThreadEventListener.java b/modules/ticket/src/main/java/com/bytedesk/ticket/ticket/TicketThreadEventListener.java index 822ac14d81..bc7f1b80bb 100644 --- a/modules/ticket/src/main/java/com/bytedesk/ticket/ticket/TicketThreadEventListener.java +++ b/modules/ticket/src/main/java/com/bytedesk/ticket/ticket/TicketThreadEventListener.java @@ -2,7 +2,7 @@ * @Author: jackning 270580156@qq.com * @Date: 2025-04-01 14:08:03 * @LastEditors: jackning 270580156@qq.com - * @LastEditTime: 2025-04-01 14:46:46 + * @LastEditTime: 2025-04-01 14:59:08 * @Description: bytedesk.com https://github.com/Bytedesk/bytedesk * Please be aware of the BSL license restrictions before installing Bytedesk IM – * selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license. @@ -13,23 +13,11 @@ */ package com.bytedesk.ticket.ticket; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; - -import org.flowable.engine.RuntimeService; -import org.flowable.engine.TaskService; -import org.flowable.engine.runtime.ProcessInstance; -import org.flowable.task.api.Task; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; import com.bytedesk.core.thread.ThreadEntity; -import com.bytedesk.core.thread.ThreadRestService; import com.bytedesk.core.thread.event.ThreadCreateEvent; -import com.bytedesk.ticket.consts.TicketConsts; - import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -38,11 +26,11 @@ import lombok.extern.slf4j.Slf4j; @RequiredArgsConstructor public class TicketThreadEventListener { - private final RuntimeService runtimeService; + // private final RuntimeService runtimeService; - private final TaskService taskService; + // private final TaskService taskService; - private final ThreadRestService threadRestService; + // private final ThreadRestService threadRestService; @EventListener public void onThreadCreateEvent(ThreadCreateEvent event) { @@ -58,69 +46,70 @@ public class TicketThreadEventListener { return; } log.info("开始创建工单流程实例: threadUid={}, orgUid={}", thread.getUid(), thread.getOrgUid()); - // 1. 准备流程变量 - Map variables = new HashMap<>(); - // 基本变量 - variables.put(TicketConsts.TICKET_VARIABLE_THREAD_UID, thread.getUid()); - // variables.put(TicketConsts.TICKET_VARIABLE_DEPARTMENT_UID, thread.getDepartmentUid()); - // variables.put(TicketConsts.TICKET_VARIABLE_REPORTER_UID, thread.getReporter().getUid()); - variables.put(TicketConsts.TICKET_VARIABLE_ORGUID, thread.getOrgUid()); - // - // variables.put(TicketConsts.TICKET_VARIABLE_DESCRIPTION, thread.getDescription()); - // variables.put(TicketConsts.TICKET_VARIABLE_START_USER_ID, thread.getReporter().getUid()); - // variables.put(TicketConsts.TICKET_VARIABLE_STATUS, thread.getStatus()); - // variables.put(TicketConsts.TICKET_VARIABLE_PRIORITY, thread.getPriority()); - // variables.put(TicketConsts.TICKET_VARIABLE_CATEGORY_UID, thread.getCategoryUid()); + // // 1. 准备流程变量 + // Map variables = new HashMap<>(); + // // 基本变量 + // variables.put(TicketConsts.TICKET_VARIABLE_THREAD_UID, thread.getUid()); + // // variables.put(TicketConsts.TICKET_VARIABLE_DEPARTMENT_UID, thread.getDepartmentUid()); + // // variables.put(TicketConsts.TICKET_VARIABLE_REPORTER_UID, thread.getReporter().getUid()); + // variables.put(TicketConsts.TICKET_VARIABLE_ORGUID, thread.getOrgUid()); + // // + // // variables.put(TicketConsts.TICKET_VARIABLE_DESCRIPTION, thread.getDescription()); + // // variables.put(TicketConsts.TICKET_VARIABLE_START_USER_ID, thread.getReporter().getUid()); + // // variables.put(TicketConsts.TICKET_VARIABLE_STATUS, thread.getStatus()); + // // variables.put(TicketConsts.TICKET_VARIABLE_PRIORITY, thread.getPriority()); + // // variables.put(TicketConsts.TICKET_VARIABLE_CATEGORY_UID, thread.getCategoryUid()); - // 2. 启动流程实例 - ProcessInstance processInstance = runtimeService.createProcessInstanceBuilder() - .processDefinitionKey(TicketConsts.THREAD_PROCESS_KEY_GROUP) - .tenantId(thread.getOrgUid()) - // .name(thread.getTitle()) - .businessKey(thread.getUid()) - .variables(variables) - .start(); - log.info("流程实例创建成功: processInstanceId={}, businessKey={}", - processInstance.getId(), processInstance.getBusinessKey()); + // // 2. 启动流程实例 + // ProcessInstance processInstance = runtimeService.createProcessInstanceBuilder() + // .processDefinitionKey(TicketConsts.THREAD_PROCESS_KEY_GROUP) + // .tenantId(thread.getOrgUid()) + // // .name(thread.getTitle()) + // .businessKey(thread.getUid()) + // .variables(variables) + // .start(); + // log.info("流程实例创建成功: processInstanceId={}, businessKey={}", + // processInstance.getId(), processInstance.getBusinessKey()); - // 3. 创建任务 - Task task = taskService.createTaskQuery() - .processInstanceId(processInstance.getId()) - // .taskAssignee(thread.getReporter().getUid()) - .singleResult(); - if (task != null) { - // 完成工单创建任务 - taskService.complete(task.getId()); - } else { - log.error("工单创建任务创建失败: task={}", task); - } + // // 3. 创建任务 + // Task task = taskService.createTaskQuery() + // .processInstanceId(processInstance.getId()) + // // .taskAssignee(thread.getReporter().getUid()) + // .singleResult(); + // if (task != null) { + // // 完成工单创建任务 + // taskService.complete(task.getId()); + // } else { + // log.error("工单创建任务创建失败: task={}", task); + // } - // 4. 设置流程实例变量 - // 可以在流程执行的任何时候调用, 每次调用都会产生一次变量更新历史记录 - // 适合设置运行时的动态变量或需要更新的变量 - // 每次调用都会有一次数据库操作 - runtimeService.setVariable(processInstance.getId(), TicketConsts.TICKET_VARIABLE_START_TIME, new Date()); + // // 4. 设置流程实例变量 + // // 可以在流程执行的任何时候调用, 每次调用都会产生一次变量更新历史记录 + // // 适合设置运行时的动态变量或需要更新的变量 + // // 每次调用都会有一次数据库操作 + // runtimeService.setVariable(processInstance.getId(), TicketConsts.TICKET_VARIABLE_START_TIME, new Date()); - // 5. 设置 SLA 时间 - // String slaTime = switch (thread.getPriority()) { - // case "CRITICAL" -> "PT30M"; - // case "URGENT" -> "PT1H"; - // case "HIGH" -> "PT2H"; - // case "MEDIUM" -> "PT4H"; - // case "LOW" -> "PT8H"; - // default -> "P1D"; - // }; - // runtimeService.setVariable(processInstance.getId(), TicketConsts.TICKET_VARIABLE_SLA_TIME, slaTime); - // 第一步的assignee设置为reporter - // runtimeService.setVariable(processInstance.getId(), TicketConsts.TICKET_VARIABLE_ASSIGNEE, - // thread.getReporter()); - // 6. 更新工单的流程实例ID - Optional threadOptional = threadRestService.findByUid(thread.getUid()); - if (threadOptional.isPresent()) { - ThreadEntity threadEntity = threadOptional.get(); - threadEntity.setProcessInstanceId(processInstance.getId()); - threadRestService.save(threadEntity); - } + // // 5. 设置 SLA 时间 + // // String slaTime = switch (thread.getPriority()) { + // // case "CRITICAL" -> "PT30M"; + // // case "URGENT" -> "PT1H"; + // // case "HIGH" -> "PT2H"; + // // case "MEDIUM" -> "PT4H"; + // // case "LOW" -> "PT8H"; + // // default -> "P1D"; + // // }; + // // runtimeService.setVariable(processInstance.getId(), TicketConsts.TICKET_VARIABLE_SLA_TIME, slaTime); + // // 第一步的assignee设置为reporter + // // runtimeService.setVariable(processInstance.getId(), TicketConsts.TICKET_VARIABLE_ASSIGNEE, + // // thread.getReporter()); + + // // 6. 更新工单的流程实例ID + // Optional threadOptional = threadRestService.findByUid(thread.getUid()); + // if (threadOptional.isPresent()) { + // ThreadEntity threadEntity = threadOptional.get(); + // threadEntity.setProcessInstanceId(processInstance.getId()); + // threadRestService.save(threadEntity); + // } } diff --git a/modules/ticket/src/main/resources/processes/group-thread-process.bpmn20.xml b/modules/ticket/src/main/resources/processes/thread-agent-process.bpmn20.xml similarity index 99% rename from modules/ticket/src/main/resources/processes/group-thread-process.bpmn20.xml rename to modules/ticket/src/main/resources/processes/thread-agent-process.bpmn20.xml index da9e264fcd..d7730852cf 100644 --- a/modules/ticket/src/main/resources/processes/group-thread-process.bpmn20.xml +++ b/modules/ticket/src/main/resources/processes/thread-agent-process.bpmn20.xml @@ -1,6 +1,6 @@ - + diff --git a/modules/ticket/src/main/resources/processes/thread-group-process.bpmn20.xml b/modules/ticket/src/main/resources/processes/thread-group-process.bpmn20.xml new file mode 100644 index 0000000000..aaf0a069af --- /dev/null +++ b/modules/ticket/src/main/resources/processes/thread-group-process.bpmn20.xml @@ -0,0 +1,210 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 客服人员接待访客 + + + + + + + + + + + + + + + + + + + + + + ${slaTime} + + + + + + + + + + + + + 访客填写满意度评价 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/ticket/src/main/resources/processes/thread-robot-process.bpmn20.xml b/modules/ticket/src/main/resources/processes/thread-robot-process.bpmn20.xml new file mode 100644 index 0000000000..b6ad01b9ef --- /dev/null +++ b/modules/ticket/src/main/resources/processes/thread-robot-process.bpmn20.xml @@ -0,0 +1,210 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 客服人员接待访客 + + + + + + + + + + + + + + + + + + + + + + ${slaTime} + + + + + + + + + + + + + 访客填写满意度评价 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file