HAP_工作流自定義操作

業(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ì)
  1. 首先定義開始事件,開始事件用于觸發(fā)工作流


    image.png

    image.png

    image.png

    該開始事件設(shè)置兩個(gè)初始參數(shù):amount(貸款金額)、credit(信用度).

  2. 增加檢查信用度的服務(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
  1. 使用單一網(wǎng)關(guān)處理接受和拒絕


    image.png

    image.png

    image.png
  2. 拒絕后通過郵件提醒


    image.png

    image.png

    在該組件上填寫相應(yīng)的信息

  3. 增加評(píng)估請(qǐng)求的人工任務(wù)


    image.png

    image.png

    image.png

    設(shè)置任務(wù)的到期時(shí)間為(到期時(shí)間的表示方法為ISO8601)3分鐘,并選擇審批規(guī)則,指定審批人為周杰森。

  4. 在評(píng)估請(qǐng)求環(huán)節(jié)添加邊界定時(shí)事件(注意線要連正確了)
    如果3分鐘后沒處理轉(zhuǎn)交管理員


    image.png
  5. 新增管理員評(píng)估處理評(píng)估請(qǐng)求超時(shí)的任務(wù)


    image.png

    設(shè)置審批規(guī)則中指定人為admin;不設(shè)置到期日期。

  6. 使用單一網(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)核的,其他瀏覽器也不要選兼容模式,要選高速/極速瀏覽器

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 1.Typescript中的&理解 參數(shù)中的 & 表示props對(duì)象同時(shí)擁有了TagManagementState...
    Lethe35閱讀 7,807評(píng)論 0 1
  • 夜晚是沉重的, 隔壁傳來的說話聲。 如同遙遠(yuǎn)的某個(gè)晚上聽到, 回憶,就像勁馳的冬風(fēng)一般, 吹的我腦袋迷糊, 讀了好...
    驕傲的鞋子閱讀 263評(píng)論 0 0
  • 衣帶漸寬終不悔,為兒消得人憔悴。父母之愛子,大抵就是這樣了吧。滴水之恩尚且涌泉相報(bào),那大于天的養(yǎng)育之恩,又該如何報(bào)...
    山月不知心事閱讀 820評(píng)論 0 6
  • 長久以來,我感到痛苦。 我似乎得了很嚴(yán)重的抑郁癥,醫(yī)生安慰我,讓我積極配合治療,可是他看我的眼神空洞而冷漠。我知道...
    江中云閱讀 369評(píng)論 0 0
  • 市殘聯(lián)領(lǐng)導(dǎo)來校傳達(dá)重要指示
    菏澤兒童康復(fù)中心閱讀 128評(píng)論 0 0

友情鏈接更多精彩內(nèi)容