| | |
| | | */ |
| | | package com.vci.ubcs.flow.engine.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | |
| | | 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.collections4.MapUtils; |
| | | 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; |
| | |
| | | import org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl; |
| | | import org.flowable.engine.impl.persistence.entity.ProcessDefinitionEntityImpl; |
| | | import org.flowable.engine.repository.Deployment; |
| | | import org.flowable.engine.repository.DeploymentQuery; |
| | | import org.flowable.engine.repository.ProcessDefinition; |
| | | import org.flowable.engine.repository.ProcessDefinitionQuery; |
| | | import org.flowable.engine.runtime.ProcessInstance; |
| | |
| | | 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; |
| | |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.w3c.dom.*; |
| | | import org.xml.sax.InputSource; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.xml.parsers.DocumentBuilder; |
| | | import javax.xml.parsers.DocumentBuilderFactory; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.io.StringReader; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | 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) { |
| | |
| | | |
| | | @Override |
| | | public boolean deployModel(String modelId, String category, List<String> tenantIdList) { |
| | | |
| | | FlowModel model = this.getById(modelId); |
| | | if (model == null) { |
| | | throw new ServiceException("未找到模型 id: " + modelId); |
| | |
| | | |
| | | @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); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 根据流程模型key获取XML中节点配置的处理人 |
| | | * |
| | | * @param key |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Map<String,String>> getNodeByFlowableKey(String key){ |
| | | String processDefinitionId = repositoryService.createProcessDefinitionQuery().latestVersion().processDefinitionKey(key).singleResult().getId(); |
| | | BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId); |
| | | Process process = bpmnModel.getProcesses().get(0);//只有一个 |
| | | |
| | | List<Map<String,String>> ll = new ArrayList<>(); |
| | | if (CollectionUtils.isNotEmpty(process.getFlowElements())) { |
| | | for (FlowElement flowElement : process.getFlowElements()) { |
| | | if (flowElement instanceof UserTask) { |
| | | Map<String,String> mi = new HashMap<>(); |
| | | mi.put("taskId",flowElement.getId()); |
| | | mi.put("taskName",flowElement.getName()); |
| | | ll.add(mi); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return ll; |
| | | } |
| | | |
| | | /** |
| | | * 是否已完结 |
| | | * |
| | | * @param processInstanceId 流程实例id |
| | |
| | | return historyService.createHistoricProcessInstanceQuery().finished() |
| | | .processInstanceId(processInstanceId).count() > 0; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * xml转bpmn json |
| | |
| | | } |
| | | } |
| | | |
| | | public FlowModel getFlowModelByKey(String key){ |
| | | Map kv = new HashMap(); |
| | | kv.put("model_key",key); |
| | | return baseMapper.selectOne(Condition.getQueryWrapper(kv, FlowModel.class)); |
| | | } |
| | | |
| | | } |