业务流程:

2. 实现:

**接下来就开始通过图形化界面进行工作流的设计了:**
首先要设计好贷款请求的处理流程:
接收用户发出的贷款申请->检查信用度->评估贷款请求
->批准->处理请求\
->拒绝->邮件通知用户->结束
点击上图中的编辑图标,进入工作流的图形化界面设计
-
首先定义开始事件,开始事件用于触发工作流
image.png
image.png
image.png
该开始事件设置两个初始参数:amount(贷款金额)、credit(信用度).
-
增加检查信用度的服务任务
image.png
服务任务需要一个java实现类
package wht.ora20796.components;
import com.hand.hap.activiti.custom.IActivitiBean;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.JavaDelegate;
import org.springframework.stereotype.Component;
@Component
public class CreditService implements JavaDelegate, IActivitiBean {
@Override
public String getBeanName() {
return "checkCredit";
}
@Override
public void execute(DelegateExecution delegateExecution) {
Integer amount = delegateExecution.getVariable("amount", Integer.class);
Integer credit = delegateExecution.getVariable("credit", Integer.class);
if (amount > credit * 1000) {
delegateExecution.setVariable("accept", Boolean.FALSE);
} else {
delegateExecution.setVariable("accept", Boolean.TRUE);
}
}
}
getBeanName的返回的值会在代理表达式中使用,注意这里需要将该类的包名加入到spring扫描的包路径中.
更改spring配置文件applicationContext-beans.xml 如下
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<!--自定义上传配置-->
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!--setthemaxuploadsize100MB-->
<property name="maxUploadSize">
<value>104857600</value>
</property>
<property name="maxInMemorySize">
<value>4096</value>
</property>
</bean>
<!--工作流中的实现信用检查的服务任务-->
<!-- <context:component-scan base-package="wht.ora20796.components"/>-->
<context:component-scan base-package="*.*.components"/>
</beans>
完成之后配置服务任务的代理表达式的值

-
使用单一网关处理接受和拒绝
image.png
image.png
image.png
-
拒绝后通过邮件提醒
image.png
image.png
在该组件上填写相应的信息
-
增加评估请求的人工任务
image.png
image.png
image.png
设置任务的到期时间为(到期时间的表示方法为ISO8601)3分钟,并选择审批规则,指定审批人为周杰森。
-
在评估请求环节添加边界定时事件(注意线要连正确了)
如果3分钟后没处理转交管理员
image.png
-
新增管理员评估处理评估请求超时的任务
image.png
设置审批规则中指定人为admin;不设置到期日期。
- 使用单一网关处理审批通过和未通过,若通过,则处理请求。
image.png
通过新增跳转条件:{approveResult=='APPROVED'} 未通过新增跳转条件:{approveResult=='REJECTED'}
处理请求需新增一个java类,如下:
package wht.ora20796.components;
import com.hand.hap.activiti.custom.IActivitiBean;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.JavaDelegate;
import org.springframework.stereotype.Component;
@Component
public class ProcessLoan implements JavaDelegate,IActivitiBean {
@Override
public void execute(DelegateExecution delegateExecution) {
System.out.println("\n\n"+"处理借款申请"+"\n\n");
}
@Override
public String getBeanName() {
return "processLoan";
}
}

2. 发布工作流

进入工作流测试页面:

接下来请自行测试...
常见bug:
问题1

比如:
问题2

问题3

问题4:邮件发送错误


或者:

问题5:发布不成功,未知错误发生,无法保存模型
2018-08-07 09:52:22.615 ERROR [10001] [1534602146e843089bc5979677368ca6] com.hand.hap.activiti.controllers.ModelSaveRestResource - Error saving model
org.apache.batik.transcoder.TranscoderException: null
Enclosed Exception:
Element type "path" must be followed by either attribute specifications, ">" or "/>".
at

没有名称

问题5:发布不成功,未知错误发送,无法保存模型
2018-08-07 09:52:22.615 ERROR [10001] [1534602146e843089bc5979677368ca6] com.hand.hap.activiti.controllers.ModelSaveRestResource - Error saving model
org.apache.batik.transcoder.TranscoderException: null
Enclosed Exception:
Element type "path" must be followed by either attribute specifications, ">" or "/>".
at
org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:136)

换浏览器,换一个非IE内核的,其他浏览器也不要选兼容模式,要选高速/极速浏览器
网友评论