From 95a283a441c93ce5ab63df93bc39beadd2f34f51 Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期一, 04 三月 2024 20:15:04 +0800
Subject: [PATCH] 近义词查询规则功能完善
---
Source/UBCS/ubcs-ops/ubcs-flow/src/main/java/com/vci/ubcs/flow/engine/service/impl/FlowEngineServiceImpl.java | 70 ++++++++++++++++++++++++++++++++++-
1 files changed, 68 insertions(+), 2 deletions(-)
diff --git a/Source/UBCS/ubcs-ops/ubcs-flow/src/main/java/com/vci/ubcs/flow/engine/service/impl/FlowEngineServiceImpl.java b/Source/UBCS/ubcs-ops/ubcs-flow/src/main/java/com/vci/ubcs/flow/engine/service/impl/FlowEngineServiceImpl.java
index 7eb8c9b..f277e82 100644
--- a/Source/UBCS/ubcs-ops/ubcs-flow/src/main/java/com/vci/ubcs/flow/engine/service/impl/FlowEngineServiceImpl.java
+++ b/Source/UBCS/ubcs-ops/ubcs-flow/src/main/java/com/vci/ubcs/flow/engine/service/impl/FlowEngineServiceImpl.java
@@ -20,6 +20,7 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vci.ubcs.flow.core.dto.FlowTaskDTO;
import com.vci.ubcs.flow.core.entity.BladeFlow;
import com.vci.ubcs.flow.core.enums.FlowModeEnum;
import com.vci.ubcs.flow.core.utils.TaskUtil;
@@ -34,9 +35,10 @@
import com.vci.ubcs.system.user.entity.User;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.flowable.bpmn.converter.BpmnXMLConverter;
-import org.flowable.bpmn.model.BpmnModel;
+import org.flowable.bpmn.model.*;
import org.flowable.bpmn.model.Process;
import org.flowable.common.engine.impl.util.IoUtil;
import org.flowable.common.engine.impl.util.io.StringStreamSource;
@@ -54,6 +56,7 @@
import org.flowable.engine.task.Comment;
import org.flowable.image.ProcessDiagramGenerator;
import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.mp.support.Condition;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.FileUtil;
@@ -62,6 +65,7 @@
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
+import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
@@ -90,6 +94,12 @@
private final HistoryService historyService;
private final TaskService taskService;
private final ProcessEngine processEngine;
+
+ /**
+ * 鏁版嵁鎿嶄綔瀵硅薄
+ */
+ @Resource
+ private FlowMapper flowMapper;
@Override
public IPage<FlowModel> selectFlowPage(IPage<FlowModel> page, FlowModel flowModel) {
@@ -296,6 +306,7 @@
@Override
public boolean deployModel(String modelId, String category, List<String> tenantIdList) {
+
FlowModel model = this.getById(modelId);
if (model == null) {
throw new ServiceException("鏈壘鍒版ā鍨� id: " + modelId);
@@ -346,6 +357,12 @@
@Override
public FlowModel submitModel(FlowModel model) {
+
+ //楠岃瘉閲嶅key
+ if(StringUtils.isEmpty(model.getId())&&getFlowModelByKey(model.getModelKey())!=null){
+ throw new ServiceException("you cannot definition repetition 娴佺▼key!");
+ }
+
FlowModel flowModel = new FlowModel();
flowModel.setId(model.getId());
flowModel.setVersion(Func.toInt(model.getVersion(), 0) + 1);
@@ -467,6 +484,50 @@
}
/**
+ * 鏍规嵁娴佺▼妯″瀷key鑾峰彇XML涓妭鐐归厤缃殑澶勭悊浜�
+ *
+ * @param key
+ * @return
+ */
+ @Override
+ public List<FlowTaskDTO> getNodeByFlowableKey(String key){
+ String processDefinitionId = repositoryService.createProcessDefinitionQuery().latestVersion().processDefinitionKey(key).singleResult().getId();
+ BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
+ Process process = bpmnModel.getProcesses().get(0);//鍙湁涓�涓�
+
+ List<FlowTaskDTO> ll = new ArrayList<>();
+ if (CollectionUtils.isNotEmpty(process.getFlowElements())) {
+ for (FlowElement flowElement : process.getFlowElements()) {
+ if (flowElement instanceof UserTask) {
+ FlowTaskDTO flowTaskUserC = new FlowTaskDTO();
+ flowTaskUserC.setTaskId(flowElement.getId());
+ flowTaskUserC.setTaskName(flowElement.getName());
+ ll.add(flowTaskUserC);
+ }
+ }
+ }
+ return ll;
+ }
+ @Override
+ public FlowTaskDTO getNodeByFlowableKey(String key, String taskId){
+ String processDefinitionId = repositoryService.createProcessDefinitionQuery().latestVersion().processDefinitionKey(key).singleResult().getId();
+ BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
+ Process process = bpmnModel.getProcesses().get(0);//鍙湁涓�涓�
+
+ FlowTaskDTO flowTaskUserC = new FlowTaskDTO();
+ if (CollectionUtils.isNotEmpty(process.getFlowElements())) {
+ for (FlowElement flowElement : process.getFlowElements()) {
+ if (flowElement instanceof UserTask&&taskId.equals(flowElement.getId())) {
+ flowTaskUserC.setTaskId(flowElement.getId());
+ flowTaskUserC.setTaskName(flowElement.getName());
+ break;
+ }
+ }
+ }
+ return flowTaskUserC;
+ }
+
+ /**
* 鏄惁宸插畬缁�
*
* @param processInstanceId 娴佺▼瀹炰緥id
@@ -476,7 +537,6 @@
return historyService.createHistoricProcessInstanceQuery().finished()
.processInstanceId(processInstanceId).count() > 0;
}
-
/**
* xml杞琤pmn json
@@ -556,4 +616,10 @@
}
}
+ public FlowModel getFlowModelByKey(String key){
+ Map kv = new HashMap();
+ kv.put("model_key",key);
+ return baseMapper.selectOne(Condition.getQueryWrapper(kv, FlowModel.class));
+ }
+
}
--
Gitblit v1.9.3