Merge remote-tracking branch 'origin/master'

This commit is contained in:
yjz
2023-10-26 18:06:00 +08:00
4 changed files with 45 additions and 40 deletions
@@ -30,6 +30,7 @@ import org.activiti.editor.language.json.converter.BpmnJsonConverter;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.delegate.BaseExecutionListener;
import org.activiti.engine.delegate.TaskListener;
import org.activiti.engine.repository.*;
@@ -446,25 +447,28 @@ public class ModelerController {
// 获取流程引擎
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
// 获取RuntimeService并删除所有流程实例
List<ProcessInstance> instances = processEngine.getRuntimeService()
.createProcessInstanceQuery()
.list();
for (ProcessInstance instance : instances) {
processEngine.getRuntimeService()
.deleteProcessInstance(instance.getId(), "Cleanup all instances");
// 获取RuntimeService并批量删除所有流程实例
RuntimeService runtimeService = processEngine.getRuntimeService();
List<String> instanceIds = runtimeService.createProcessInstanceQuery().list()
.stream()
.map(ProcessInstance::getId)
.collect(Collectors.toList());
for (String id : instanceIds) {
runtimeService.deleteProcessInstance(id, "Cleanup all instances");
}
// 获取RepositoryService并删除所有流程
List<ProcessDefinition> definitions = processEngine.getRepositoryService()
.createProcessDefinitionQuery()
.list();
for (ProcessDefinition definition : definitions) {
processEngine.getRepositoryService()
.deleteDeployment(definition.getDeploymentId(), true);
// 获取RepositoryService并批量删除所有流程
RepositoryService repositoryService = processEngine.getRepositoryService();
List<String> deploymentIds = repositoryService.createProcessDefinitionQuery().list()
.stream()
.map(ProcessDefinition::getDeploymentId)
.collect(Collectors.toList());
for (String id : deploymentIds) {
repositoryService.deleteDeployment(id, true);
}
}
}
@@ -3,7 +3,6 @@ package com.jero.modules.activiti.process.esInitChange.entity.vo;
import com.jero.modules.activiti.process.common.entity.CommonVO;
import com.jero.modules.activiti.process.esInitChange.entity.ProcessEsInitChange;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
@@ -18,5 +17,5 @@ public class InitChangeDataVO {
List<ProcessEsInitChange> dataList;
FlowUserInfoVO flowUserInfoVO;
InitChangeFlowUserVO initChangeFlowUserVO;
}
@@ -8,7 +8,7 @@ import lombok.Data;
* @Date: 2023/10/9 16:57
*/
@Data
public class FlowUserInfoVO {
public class InitChangeFlowUserVO {
@ApiModelProperty("主起草人")
private String mainDraftUser;
@@ -18,7 +18,7 @@ import com.jero.modules.activiti.process.common.enums.ProcessType;
import com.jero.modules.activiti.process.common.service.ActFlowCommonService;
import com.jero.modules.activiti.process.common.service.ProcessDraftService;
import com.jero.modules.activiti.process.esInitChange.entity.ProcessEsInitChange;
import com.jero.modules.activiti.process.esInitChange.entity.vo.FlowUserInfoVO;
import com.jero.modules.activiti.process.esInitChange.entity.vo.InitChangeFlowUserVO;
import com.jero.modules.activiti.process.esInitChange.entity.vo.InitChangeDataVO;
import com.jero.modules.activiti.process.esInitChange.service.ProcessEsInitChangeService;
import com.jero.modules.activiti.process.esInitChange.mapper.ProcessEsInitChangeMapper;
@@ -30,7 +30,6 @@ import com.jero.modules.laws.enterprise.service.ESSequenceNumberProvider;
import com.jero.modules.laws.enterprise.util.EnterpriseStandardUtil;
import com.jero.modules.sys.utils.UserUtils;
import lombok.extern.slf4j.Slf4j;
import org.activiti.engine.TaskService;
import org.activiti.engine.runtime.ProcessInstance;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -96,17 +95,17 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl<ProcessEsInitCha
initChangeDataVO.setDataList(dataList);
// 选人组件内容填充
List<ProcessNode> nodeList = processNodeService.getNodeList(processDefinitionId, processInstanceId);
FlowUserInfoVO flowUserInfoVO = new FlowUserInfoVO();
InitChangeFlowUserVO initChangeFlowUserVO = new InitChangeFlowUserVO();
Map<String, ProcessNode> userMap = nodeList.stream().collect(Collectors.toMap(ProcessNode::getVariableName, node -> node));
flowUserInfoVO.setCreateUser(userMap.get("createUser").getLinkUserIds());
flowUserInfoVO.setContactUser(userMap.get("contactUser").getLinkUserIds());
flowUserInfoVO.setMainDraftUserLeader(userMap.get("mainDraftUserLeader").getLinkUserIds());
flowUserInfoVO.setMainDraftUserLeaderLeader(userMap.get("mainDraftUserLeaderLeader").getLinkUserIds());
flowUserInfoVO.setStandardizationApprovalUser(userMap.get("standardizationApprovalUser").getLinkUserIds());
flowUserInfoVO.setNewMainDraftUserLeaderLeader(userMap.get("newMainDraftUserLeaderLeader").getLinkUserIds());
flowUserInfoVO.setNewMainDraftUserLeader(userMap.get("newMainDraftUserLeader").getLinkUserIds());
flowUserInfoVO.setCopyUser(userMap.get("copyUser").getLinkUserIds());
initChangeDataVO.setFlowUserInfoVO(flowUserInfoVO);
initChangeFlowUserVO.setCreateUser(userMap.get("createUser").getLinkUserIds());
initChangeFlowUserVO.setContactUser(userMap.get("contactUser").getLinkUserIds());
initChangeFlowUserVO.setMainDraftUserLeader(userMap.get("mainDraftUserLeader").getLinkUserIds());
initChangeFlowUserVO.setMainDraftUserLeaderLeader(userMap.get("mainDraftUserLeaderLeader").getLinkUserIds());
initChangeFlowUserVO.setStandardizationApprovalUser(userMap.get("standardizationApprovalUser").getLinkUserIds());
initChangeFlowUserVO.setNewMainDraftUserLeaderLeader(userMap.get("newMainDraftUserLeaderLeader").getLinkUserIds());
initChangeFlowUserVO.setNewMainDraftUserLeader(userMap.get("newMainDraftUserLeader").getLinkUserIds());
initChangeFlowUserVO.setCopyUser(userMap.get("copyUser").getLinkUserIds());
initChangeDataVO.setInitChangeFlowUserVO(initChangeFlowUserVO);
return initChangeDataVO;
}
@@ -159,6 +158,9 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl<ProcessEsInitCha
String userId = UserUtils.getUserId();
CommonVO commonVO = initChangeDataVO.getCommonVO();
String taskId = commonVO.getTaskId();
if (StrUtil.isBlank(taskId) && !actFlowCommonService.taskExists(taskId)) {
throw new JeroBootException("taskId为空或任务不存在");
}
List<ProcessEsInitChange> esInitChangeList = initChangeDataVO.getDataList();
Map<String, Object> variables = new HashMap<>();
String processInstanceId = actFlowCommonService.getProcessInstanceIdByTaskId(taskId);
@@ -236,20 +238,20 @@ public class ProcessEsInitChangeServiceImpl extends ServiceImpl<ProcessEsInitCha
}
public Map<String, Object> setVariables(InitChangeDataVO initChangeData) {
FlowUserInfoVO flowUserInfoVO = initChangeData.getFlowUserInfoVO();
InitChangeFlowUserVO initChangeFlowUserVO = initChangeData.getInitChangeFlowUserVO();
ProcessEsInitChange initChange = initChangeData.getDataList().get(0);
Map<String, Object> map = new HashMap<>();
// 设置流程中各个节点的人
map.put("createUser", UserUtils.getUserIdByUserName(flowUserInfoVO.getCreateUser()));
map.put("contactUser", flowUserInfoVO.getContactUser());
map.put("standardExpertList", Optional.ofNullable(flowUserInfoVO.getStandardExpert()).map(s -> Arrays.asList(s.split(","))).orElse(Collections.emptyList()));
map.put("mainDraftUserLeader", flowUserInfoVO.getMainDraftUserLeader());
map.put("mainDraftUserLeaderLeader", flowUserInfoVO.getMainDraftUserLeaderLeader());
map.put("standardizationApprovalUser", flowUserInfoVO.getStandardizationApprovalUser());
map.put("newMainDraftUserLeaderLeader", flowUserInfoVO.getNewMainDraftUserLeaderLeader());
map.put("newMainDraftUserLeader", flowUserInfoVO.getNewMainDraftUserLeader());
map.put("relatedUserList", Optional.ofNullable(flowUserInfoVO.getRelatedUser()).map(s -> Arrays.asList(s.split(","))).orElse(Collections.emptyList()));
map.put("copyUser", flowUserInfoVO.getCopyUser());
map.put("createUser", initChangeFlowUserVO.getMainDraftUser());
map.put("contactUser", initChangeFlowUserVO.getContactUser());
map.put("standardExpertList", Optional.ofNullable(initChangeFlowUserVO.getStandardExpert()).map(s -> Arrays.asList(s.split(","))).orElse(Collections.emptyList()));
map.put("mainDraftUserLeader", initChangeFlowUserVO.getMainDraftUserLeader());
map.put("mainDraftUserLeaderLeader", initChangeFlowUserVO.getMainDraftUserLeaderLeader());
map.put("standardizationApprovalUser", initChangeFlowUserVO.getStandardizationApprovalUser());
map.put("newMainDraftUserLeaderLeader", initChangeFlowUserVO.getNewMainDraftUserLeaderLeader());
map.put("newMainDraftUserLeader", initChangeFlowUserVO.getNewMainDraftUserLeader());
map.put("relatedUserList", Optional.ofNullable(initChangeFlowUserVO.getRelatedUser()).map(s -> Arrays.asList(s.split(","))).orElse(Collections.emptyList()));
map.put("copyUser", initChangeFlowUserVO.getCopyUser());
// 设置流程分支判断变量
map.put("applicationCategory", initChange.getApplicationCategory());
map.put("projectType", initChange.getProjectType());