Skip to content

Commit

Permalink
update modules/ticket: mod 3 files
Browse files Browse the repository at this point in the history
  • Loading branch information
pengjinning committed Feb 18, 2025
1 parent 4de080c commit 328acf5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: jackning 270580156@qq.com
* @Date: 2024-01-29 16:21:24
* @LastEditors: jackning 270580156@qq.com
* @LastEditTime: 2025-02-18 13:23:22
* @LastEditTime: 2025-02-18 23:10:50
* @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.
Expand Down Expand Up @@ -457,6 +457,23 @@ public ThreadEntity save(@NonNull ThreadEntity thread) {
return null;
}

public void deleteByTopic(String topic) {
List<ThreadEntity> threads = findListByTopic(topic);
threads.forEach(thread -> {
thread.setDeleted(true);
save(thread);
});
}

@Override
public void deleteByUid(String uid) {
Optional<ThreadEntity> threadOptional = findByUid(uid);
threadOptional.ifPresent(thread -> {
thread.setDeleted(true);
save(thread);
});
}

@Caching(evict = {
@CacheEvict(value = "thread", key = "#thread.uid"),
@CacheEvict(value = "thread", key = "#thread.topic")
Expand All @@ -479,11 +496,7 @@ public Page<ThreadResponse> queryByUser(ThreadRequest request) {
throw new UnsupportedOperationException("Unimplemented method 'queryByUser'");
}

@Override
public void deleteByUid(String uid) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'deleteByUid'");
}


@Override
public void handleOptimisticLockingFailureException(ObjectOptimisticLockingFailureException e,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: jackning 270580156@qq.com
* @Date: 2025-01-23 14:52:45
* @LastEditors: jackning 270580156@qq.com
* @LastEditTime: 2025-02-18 22:35:38
* @LastEditTime: 2025-02-18 23:13:46
* @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.
Expand All @@ -26,6 +26,7 @@
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import com.bytedesk.core.thread.ThreadRestService;
import com.bytedesk.kbase.upload.UploadEntity;
import com.bytedesk.kbase.upload.UploadTypeEnum;
import com.bytedesk.kbase.upload.event.UploadCreateEvent;
Expand All @@ -49,6 +50,8 @@ public class TicketEventListener {

private final TaskService taskService;

private final ThreadRestService threadRestService;

@EventListener
public void handleTicketCreateEvent(TicketCreateEvent event) {
TicketEntity ticket = event.getTicket();
Expand Down Expand Up @@ -76,17 +79,20 @@ public void handleTicketCreateEvent(TicketCreateEvent event) {
.businessKey(ticket.getUid())
.variables(variables)
.start();

log.info("流程实例创建成功: processInstanceId={}, businessKey={}",
processInstance.getId(), processInstance.getBusinessKey());

// 3. 验证任务是否创建
// Task task = taskService.createTaskQuery()
// .processDefinitionKey(TicketConsts.TICKET_PROCESS_KEY_GROUP_SIMPLE)
// .taskDefinitionKey(TicketConsts.TICKET_USER_TASK_ASSIGN_TO_GROUP)
// .processInstanceId(processInstance.getId())
// .singleResult();
// log.info("流程任务创建状态: task={}", task);
// 3. 创建任务
Task task = taskService.createTaskQuery()
.processInstanceId(processInstance.getId())
.taskAssignee(ticket.getReporter().getUid())
.singleResult();
if (task != null) {
// 完成工单创建任务
taskService.complete(task.getId());
} else {
log.error("工单创建任务创建失败: task={}", task);
}

// 4. 设置流程实例变量
// 可以在流程执行的任何时候调用, 每次调用都会产生一次变量更新历史记录
Expand Down Expand Up @@ -140,6 +146,8 @@ public void handleTicketUpdateEvent(TicketUpdateEvent event) {
if (processInstance != null) {
runtimeService.deleteProcessInstance(processInstance.getId(), "deleted by user");
}
// 同步删除工单会话
threadRestService.deleteByTopic(ticket.getServiceThreadTopic());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: jackning 270580156@qq.com
* @Date: 2025-01-29 12:24:32
* @LastEditors: jackning 270580156@qq.com
* @LastEditTime: 2025-02-18 22:38:55
* @LastEditTime: 2025-02-18 23:16:29
* @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.
Expand Down Expand Up @@ -289,7 +289,7 @@ public TicketResponse claimTicket(TicketRequest request) {
// 2. 查询任务
Task task = taskService.createTaskQuery()
.processInstanceId(ticket.getProcessInstanceId()) // 使用processInstanceId查询
// .taskDefinitionKey(TicketConsts.TICKET_USER_TASK_CREATE_TICKET)
.taskDefinitionKey(TicketConsts.TICKET_USER_TASK_ASSIGN_TO_GROUP)
.active() // 只查询活动的任务
.singleResult();

Expand Down

0 comments on commit 328acf5

Please sign in to comment.