業(yè)務(wù)流程:

image.png
2. 實(shí)現(xiàn):

image.png
**接下來就開始通過圖形化界面進(jìn)行工作流的設(shè)計(jì)了:**
首先要設(shè)計(jì)好貸款請(qǐng)求的處理流程:
接收用戶發(fā)出的貸款申請(qǐng)->檢查信用度->評(píng)估貸款請(qǐng)求
->批準(zhǔn)->處理請(qǐng)求\
->拒絕->郵件通知用戶->結(jié)束
點(diǎn)擊上圖中的編輯圖標(biāo),進(jìn)入工作流的圖形化界面設(shè)計(jì)
-
首先定義開始事件,開始事件用于觸發(fā)工作流
image.png
image.png
image.png
該開始事件設(shè)置兩個(gè)初始參數(shù):amount(貸款金額)、credit(信用度).
-
增加檢查信用度的服務(wù)任務(wù)
image.png
服務(wù)任務(wù)需要一個(gè)java實(shí)現(xiàn)類
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的返回的值會(huì)在代理表達(dá)式中使用,注意這里需要將該類的包名加入到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>
<!--工作流中的實(shí)現(xiàn)信用檢查的服務(wù)任務(wù)-->
<!-- <context:component-scan base-package="wht.ora20796.components"/>-->
<context:component-scan base-package="*.*.components"/>
</beans>
完成之后配置服務(wù)任務(wù)的代理表達(dá)式的值

image.png
-
使用單一網(wǎng)關(guān)處理接受和拒絕
image.png
image.png
image.png -
拒絕后通過郵件提醒
image.png
image.png
在該組件上填寫相應(yīng)的信息
-
增加評(píng)估請(qǐng)求的人工任務(wù)
image.png
image.png
image.png
設(shè)置任務(wù)的到期時(shí)間為(到期時(shí)間的表示方法為ISO8601)3分鐘,并選擇審批規(guī)則,指定審批人為周杰森。
-
在評(píng)估請(qǐng)求環(huán)節(jié)添加邊界定時(shí)事件(注意線要連正確了)
如果3分鐘后沒處理轉(zhuǎn)交管理員
image.png -
新增管理員評(píng)估處理評(píng)估請(qǐng)求超時(shí)的任務(wù)
image.png
設(shè)置審批規(guī)則中指定人為admin;不設(shè)置到期日期。
- 使用單一網(wǎng)關(guān)處理審批通過和未通過,若通過,則處理請(qǐng)求。
image.png
通過新增跳轉(zhuǎn)條件:{approveResult=='APPROVED'} 未通過新增跳轉(zhuǎn)條件:{approveResult=='REJECTED'}
處理請(qǐng)求需新增一個(gè)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"+"處理借款申請(qǐng)"+"\n\n");
}
@Override
public String getBeanName() {
return "processLoan";
}
}

image.png
2. 發(fā)布工作流

image.png
進(jìn)入工作流測(cè)試頁面:

image.png
接下來請(qǐng)自行測(cè)試...
常見bug:
問題1

image.png
比如:
問題2

image.png
問題3

image.png
問題4:郵件發(fā)送錯(cuò)誤

image.png

image.png
或者:

image.png
問題5:發(fā)布不成功,未知錯(cuò)誤發(fā)生,無法保存模型
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

image.png
沒有名稱

image.png
問題5:發(fā)布不成功,未知錯(cuò)誤發(fā)送,無法保存模型
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)

image.png
換瀏覽器,換一個(gè)非IE內(nèi)核的,其他瀏覽器也不要選兼容模式,要選高速/極速瀏覽器














