mirror of
https://gitee.com/270580156/weiyu.git
synced 2026-05-14 11:18:02 +00:00
update modules/ticket: add 1 mod 2 files
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2025-02-15 15:44:10
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-02-15 15:44:13
|
||||
* @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.
|
||||
* Business Source License 1.1: https://github.com/Bytedesk/bytedesk/blob/main/LICENSE
|
||||
* contact: 270580156@qq.com
|
||||
*
|
||||
* Copyright (c) 2025 by bytedesk.com, All Rights Reserved.
|
||||
*/
|
||||
package com.bytedesk.ticket.process;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ProcessDefinitionResponse implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String id;
|
||||
private String key;
|
||||
private String name;
|
||||
private String description;
|
||||
private int version;
|
||||
private String deploymentId;
|
||||
private String tenantId;
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2024-05-11 18:25:36
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-02-15 15:22:17
|
||||
* @LastEditTime: 2025-02-15 15:45:34
|
||||
* @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.
|
||||
@@ -14,6 +14,7 @@
|
||||
package com.bytedesk.ticket.process;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.flowable.engine.repository.ProcessDefinition;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -75,14 +76,24 @@ public class TicketProcessRestController extends BaseRestController<TicketProces
|
||||
|
||||
return ResponseEntity.ok(JsonResult.success());
|
||||
}
|
||||
|
||||
// 查询流程
|
||||
// 修改查询方法
|
||||
@RequestMapping("/query/deployments")
|
||||
public ResponseEntity<?> queryProcessDefinition(TicketProcessRequest request) {
|
||||
List<ProcessDefinition> definitions = processService.query(request);
|
||||
|
||||
List<ProcessDefinitionResponse> dtos = definitions.stream()
|
||||
.map(def -> ProcessDefinitionResponse.builder()
|
||||
.id(def.getId())
|
||||
.key(def.getKey())
|
||||
.name(def.getName())
|
||||
.description(def.getDescription())
|
||||
.version(def.getVersion())
|
||||
.deploymentId(def.getDeploymentId())
|
||||
.tenantId(def.getTenantId())
|
||||
.build())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<ProcessDefinition> processDefinition = processService.query(request);
|
||||
|
||||
return ResponseEntity.ok(JsonResult.success(processDefinition));
|
||||
return ResponseEntity.ok(JsonResult.success(dtos));
|
||||
}
|
||||
|
||||
// 部署流程
|
||||
@@ -94,11 +105,11 @@ public class TicketProcessRestController extends BaseRestController<TicketProces
|
||||
return ResponseEntity.ok(JsonResult.success(processDefinition));
|
||||
}
|
||||
|
||||
// 删除流程
|
||||
@RequestMapping("/delete/deployment")
|
||||
public ResponseEntity<?> deleteDeployment(TicketProcessRequest request) {
|
||||
|
||||
List<ProcessDefinition> processDefinition = processService.delete(request);
|
||||
// 取消部署流程
|
||||
@RequestMapping("/undeploy")
|
||||
public ResponseEntity<?> undeployProcess(TicketProcessRequest request) {
|
||||
|
||||
List<ProcessDefinition> processDefinition = processService.undeploy(request);
|
||||
|
||||
return ResponseEntity.ok(JsonResult.success(processDefinition));
|
||||
}
|
||||
|
||||
@@ -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 15:17:26
|
||||
* @LastEditTime: 2025-02-15 16:01: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.
|
||||
@@ -14,6 +14,7 @@
|
||||
package com.bytedesk.ticket.process;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.flowable.engine.RepositoryService;
|
||||
import org.flowable.engine.repository.Deployment;
|
||||
@@ -30,6 +31,8 @@ public class TicketProcessService {
|
||||
|
||||
private final RepositoryService repositoryService;
|
||||
|
||||
private final TicketProcessRepository ticketProcessRepository;
|
||||
|
||||
// 查询流程
|
||||
public List<ProcessDefinition> query(TicketProcessRequest request) {
|
||||
String orgUid = request.getOrgUid();
|
||||
@@ -54,10 +57,12 @@ public class TicketProcessService {
|
||||
|
||||
// 部署流程
|
||||
public ProcessDefinition deploy(TicketProcessRequest request) {
|
||||
// 部署流程
|
||||
String orgUid = request.getOrgUid();
|
||||
// BPMN流程定义XML字符串
|
||||
String bpmnXml = request.getContent();
|
||||
Optional<TicketProcessEntity> ticketProcess = ticketProcessRepository.findByUid(request.getUid());
|
||||
if (!ticketProcess.isPresent()) {
|
||||
throw new RuntimeException("流程定义不存在" + request.getUid());
|
||||
}
|
||||
String orgUid = ticketProcess.get().getOrgUid();
|
||||
String bpmnXml = ticketProcess.get().getContent();
|
||||
|
||||
// 部署流程
|
||||
Deployment deployment = repositoryService.createDeployment()
|
||||
@@ -65,6 +70,11 @@ public class TicketProcessService {
|
||||
.addString(request.getKey() + ".bpmn20.xml", bpmnXml)
|
||||
.tenantId(orgUid)
|
||||
.deploy();
|
||||
|
||||
// 更新流程定义
|
||||
ticketProcess.get().setDeployed(true);
|
||||
ticketProcess.get().setDeploymentId(deployment.getId());
|
||||
ticketProcessRepository.save(ticketProcess.get());
|
||||
|
||||
// 验证部署结果
|
||||
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
|
||||
@@ -81,10 +91,13 @@ public class TicketProcessService {
|
||||
}
|
||||
|
||||
// 删除流程
|
||||
public List<ProcessDefinition> delete(TicketProcessRequest request) {
|
||||
// 删除流程
|
||||
String orgUid = request.getOrgUid();
|
||||
String processKey = request.getKey();
|
||||
public List<ProcessDefinition> undeploy(TicketProcessRequest request) {
|
||||
Optional<TicketProcessEntity> ticketProcess = ticketProcessRepository.findByUid(request.getUid());
|
||||
if (!ticketProcess.isPresent()) {
|
||||
throw new RuntimeException("流程定义不存在" + request.getUid());
|
||||
}
|
||||
String orgUid = ticketProcess.get().getOrgUid();
|
||||
String processKey = ticketProcess.get().getKey();
|
||||
|
||||
// 查询指定租户的所有版本流程定义
|
||||
List<ProcessDefinition> processes = repositoryService.createProcessDefinitionQuery()
|
||||
@@ -111,6 +124,12 @@ public class TicketProcessService {
|
||||
pd.getDeploymentId(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 取消流程部署
|
||||
ticketProcess.get().setDeployed(false);
|
||||
ticketProcess.get().setDeploymentId(null);
|
||||
ticketProcessRepository.save(ticketProcess.get());
|
||||
|
||||
|
||||
// 验证删除结果
|
||||
List<ProcessDefinition> remainingProcesses = repositoryService.createProcessDefinitionQuery()
|
||||
|
||||
Reference in New Issue
Block a user