Commit 462a7f93 authored by 郑越's avatar 郑越

修改

parent 2890402c
......@@ -52,13 +52,15 @@ public class CmmnListenerNotificationHelper {
public void executeTaskListeners(HumanTask humanTask, TaskEntity taskEntity, String eventType) {
for (FlowableListener listener : humanTask.getTaskListeners()) {
String event = listener.getEvent();
System.out.println("get executeTaskListeners eventName:" + event);
if (event.equals(eventType) || event.equals(TaskListener.EVENTNAME_ALL_EVENTS)) {
TaskListener taskListener = createTaskListener(listener);
System.out.println("get executeTaskListeners taskListener:" + taskListener.toString());
taskEntity.setEventName(eventType);
taskEntity.setEventHandlerId(listener.getId());
try {
System.out.println("get executeTaskListeners notify:" + taskEntity.toString());
taskListener.notify(taskEntity);
} catch (Exception e) {
throw new FlowableException("Exception while invoking TaskListener: " + e.getMessage(), e);
......
......@@ -14,6 +14,11 @@
</parent>
<dependencies>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-bpmn-converter</artifactId>
......@@ -281,6 +286,18 @@
<version>4.0.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
</dependencies>
......
package org.flowable.engine.impl.bpmn.listener;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.StringUtils;
import org.flowable.common.engine.impl.el.FixedValue;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.task.service.delegate.DelegateTask;
import org.flowable.task.service.delegate.TaskListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.client.RestTemplate;
import org.flowable.engine.RuntimeService;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import org.flowable.engine.impl.context.Context;
@Component(value="taskBusinessCallListener")
public class TaskBusinessCallListener implements TaskListener
{
/**
* rest接口
*/
private FixedValue restUrl;
/**
* 参数 多个的话用分号隔开 实例 userCode:00004737;status:1
*/
private FixedValue params;
@Autowired
private RestTemplate restTemplate;
@Autowired
private ObjectMapper objectMapper;
@Autowired
private RuntimeService runtimeService;
private static TaskBusinessCallListener taskBusinessCallListener;
@PostConstruct
public void init(){
System.out.println("---------init------"+this);
taskBusinessCallListener = this;
taskBusinessCallListener.restTemplate = this.restTemplate;
taskBusinessCallListener.objectMapper = this.objectMapper;
taskBusinessCallListener.runtimeService = this.runtimeService;
System.out.println("---------init------"+this.restTemplate);
}
@Override
public void notify(DelegateTask delegateTask) {
try {
String processInstanceId = delegateTask.getProcessInstanceId();
String restUrlStr = null, paramsStr = null;
if (restUrl != null) {
restUrlStr = restUrl.getExpressionText();
}
if (params != null) {
paramsStr = params.getExpressionText();
}
System.out.println(restUrlStr+"?FlowDefID="+processInstanceId);
System.out.println(paramsStr);
restUrlStr+="?FlowDefID="+processInstanceId;
//执行回调
this.callBack(processInstanceId, restUrlStr, paramsStr);
}catch (Exception e) {
System.out.println("-----TaskBusinessCallListener----"+ e);
}
}
public void callBack(String pocessInstanceId, String restUrl, String params) {
String paramsJson = null;
try {
Map<String, Object> paramMap = new HashMap<String, Object>();
RuntimeService runtime = Context.getProcessEngineConfiguration().getRuntimeService();
ProcessInstance processInstance = runtime.createProcessInstanceQuery().processInstanceId(pocessInstanceId).singleResult();
paramMap.put("FlowDefID", processInstance.getBusinessKey());
//paramMap.put("FlowDefID", pocessInstanceId);
this.setParams(params, paramMap);
this.objectMapper=new ObjectMapper();
paramsJson = this.objectMapper.writeValueAsString(paramMap);
//执行dubbo方法
//LOGGER.info("开始调用业务系统接口" + restUrl + ",业务参数:" + paramsJson);
this.restTemplate=new RestTemplate();
this.restTemplate.postForObject(restUrl, paramsJson, String.class);
} catch (Exception e) {
System.out.println("---------callBack------"+e);
//throw new FlowableException("Exception while invoking TaskListener: " + e.getMessage(), e);
}
}
/**
* 设置参数
* @param parameters 参数
* @param paramMap 传值map
*/
public void setParams(String parameters, Map<String, Object> paramMap) {
if (StringUtils.isNotBlank(parameters)) {
String[] ps = parameters.split(";");
if (ps != null && ps.length > 0) {
for (String p : ps) {
String[] split = p.split(":");
if (split != null && split.length > 0) {
paramMap.put(split[0], split[1]);
}
}
}
}
}
}
......@@ -79,6 +79,7 @@ public class TaskFormResource {
Map<String,Object> flowParas=new HashMap<>();
flowParas.putAll(paras);
flowParas.put("outcome","拒绝");
taskService.complete(taskId,flowParas);
if (bok){
......
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>Flowable UI Parent</name>
<artifactId>flowable-ui-parent</artifactId>
<packaging>pom</packaging>
<parent>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot</artifactId>
<relativePath>../flowable-spring-boot/pom.xml</relativePath>
<version>6.6.1-SNAPSHOT</version>
</parent>
<properties>
<!-- Maven build properties -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<modules>
<module>flowable-ui-common</module>
<module>flowable-ui-admin-logic</module>
<module>flowable-ui-admin-rest</module>
<module>flowable-ui-admin-conf</module>
<module>flowable-ui-admin-frontend</module>
<module>flowable-ui-idm-logic</module>
<module>flowable-ui-idm-rest</module>
<module>flowable-ui-idm-conf</module>
<module>flowable-ui-idm-frontend</module>
<module>flowable-ui-modeler-logic</module>
<module>flowable-ui-modeler-rest</module>
<module>flowable-ui-modeler-conf</module>
<module>flowable-ui-modeler-frontend</module>
<module>flowable-ui-task-logic</module>
<module>flowable-ui-task-rest</module>
<module>flowable-ui-task-conf</module>
<module>flowable-ui-task-frontend</module>
<module>flowable-spring-boot-starter-ui-admin</module>
<module>flowable-spring-boot-starter-ui-idm</module>
<module>flowable-spring-boot-starter-ui-modeler</module>
<module>flowable-spring-boot-starter-ui-task</module>
<module>flowable-ui-app</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-admin-logic</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-admin-rest</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-admin-conf</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-admin-frontend</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-idm-logic</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-idm-rest</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-idm-conf</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-idm-frontend</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-modeler-logic</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-modeler-rest</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-modeler-conf</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-modeler-frontend</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-task-logic</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-task-rest</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-task-conf</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-ui-task-frontend</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter-ui-admin</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter-ui-idm</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter-ui-modeler</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter-ui-task</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<profiles>
<profile>
<id>docker</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment