| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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.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; |
| | |
| | | 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<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 |
| | |
| | | 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)); |
| | | } |
| | | |
| | | } |