Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
pengjinning committed Feb 15, 2025
1 parent bec219d commit 9fb497e
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: jackning 270580156@qq.com
* @Date: 2024-05-11 18:14:28
* @LastEditors: jackning 270580156@qq.com
* @LastEditTime: 2025-02-15 14:38:02
* @LastEditTime: 2025-02-15 16:45:21
* @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 @@ -56,7 +56,8 @@ public class TicketProcessEntity extends BaseEntity {

// 是否已部署流程
@Builder.Default
private boolean isDeployed = false;
@Column(name = "is_deployed")
private boolean deployed = false;

// 部署id
private String deploymentId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: jackning 270580156@qq.com
* @Date: 2024-05-11 18:25:55
* @LastEditors: jackning 270580156@qq.com
* @LastEditTime: 2025-02-15 13:59:11
* @LastEditTime: 2025-02-15 16:45:16
* @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 @@ -13,6 +13,7 @@
*/
package com.bytedesk.ticket.process;

import java.util.List;
import java.util.Optional;

import org.springframework.data.jpa.repository.JpaRepository;
Expand All @@ -24,5 +25,7 @@ public interface TicketProcessRepository extends JpaRepository<TicketProcessEnti

Optional<TicketProcessEntity> findByKeyAndOrgUid(String key, String orgUid);

List<TicketProcessEntity> findByOrgUidAndDeployedTrue(String orgUid);

// Boolean existsByPlatform(String platform);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: jackning 270580156@qq.com
* @Date: 2024-05-11 18:26:04
* @LastEditors: jackning 270580156@qq.com
* @LastEditTime: 2025-02-15 14:41:50
* @LastEditTime: 2025-02-15 16:45:53
* @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 @@ -43,7 +43,7 @@ public class TicketProcessRequest extends BaseRequest {
// private String content;

// 是否已部署流程
private boolean isDeployed;
private boolean deployed;

// 部署id
private String deploymentId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: jackning 270580156@qq.com
* @Date: 2024-05-11 18:26:12
* @LastEditors: jackning 270580156@qq.com
* @LastEditTime: 2025-02-15 14:42:07
* @LastEditTime: 2025-02-15 16:45:49
* @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 @@ -43,7 +43,7 @@ public class TicketProcessResponse extends BaseResponse {
private String content;

// 是否已部署流程
private boolean isDeployed;
private boolean deployed;

// 部署id
private String deploymentId;
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-02-15 15:10:47
* @LastEditors: jackning 270580156@qq.com
* @LastEditTime: 2025-02-15 16:35:36
* @LastEditTime: 2025-02-15 16:43:48
* @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 @@ -15,6 +15,8 @@

import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

import org.flowable.engine.RepositoryService;
import org.flowable.engine.repository.Deployment;
Expand All @@ -36,20 +38,39 @@ public class TicketProcessService {
// 查询流程
public List<ProcessDefinition> query(TicketProcessRequest request) {
String orgUid = request.getOrgUid();
if (orgUid == null) {
throw new RuntimeException("租户ID不能为空");
}

// 先查询已部署的流程定义实体
List<TicketProcessEntity> deployedProcesses = ticketProcessRepository.findByOrgUidAndDeployedTrue(orgUid);

// 收集所有部署ID
Set<String> deploymentIds = deployedProcesses.stream()
.map(TicketProcessEntity::getDeploymentId)
.filter(id -> id != null)
.collect(Collectors.toSet());

if (deploymentIds.isEmpty()) {
return List.of();
}

// 查询租户流程定义
List<ProcessDefinition> processList = repositoryService.createProcessDefinitionQuery()
.processDefinitionTenantId(orgUid) // 按租户ID过滤
.latestVersion() // 只查询最新版本
.active() // 查询激活的流程
.orderByProcessDefinitionVersion().desc() // 按版本降序排序
.list();
.deploymentIds(deploymentIds) // 按部署ID过滤
.processDefinitionTenantId(orgUid) // 按租户ID过滤
.latestVersion() // 只查询最新版本
.active() // 查询激活的流程
.orderByProcessDefinitionVersion().desc() // 按版本降序排序
.list();

for (ProcessDefinition processDefinition : processList) {
log.info("租户流程定义 tenantId={}, name={}, key={}, version={}",
log.info("租户流程定义 tenantId={}, name={}, key={}, version={}, deploymentId={}",
processDefinition.getTenantId(),
processDefinition.getName(),
processDefinition.getKey(),
processDefinition.getVersion());
processDefinition.getVersion(),
processDefinition.getDeploymentId());
}

return processList;
Expand Down

0 comments on commit 9fb497e

Please sign in to comment.