「DAY21」表單簽核模組設計與實作(三)
Posted on October 5, 2023 • 1 min read • 128 words我們今天把camunda啟動起來,並且將程式搭建起來。
我們今天把camunda啟動起來,並且將程式搭建起來。
我們在「填寫表單」這邊要新增一個表單。

我們先新增camunda 7的Form

取名為「fillForm」。

我們要達成的目標如下:

從左邊拖曳text field到表單中。

在「Genetal」中填入以下參數

在「Validation」中填入以下參數

從左邊在拖曳一個text field到表單中。

在「Genetal」中填入以下參數

接著我們點擊空白處

我們將「form」的ID設定為「Form_itcamp」。

回到「main.bpmn」,並點選「填寫表單」。

在配置相中,填入以下參數。

我們打開IDEA my-project

新增一個package [com.example.form_IntegrityCheck]

在package [com.example.form_IntegrityCheck]底下新增一個class [Form_IntegrityCheck]

將底下這段程式碼複製貼上
package com.example.form_IntegrityCheck;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.logging.Logger;
@Component("Form_IntegrityCheck")
public class Form_IntegrityCheck implements JavaDelegate{
private final Logger LOGGER = Logger.getLogger(Form_IntegrityCheck.class.getName());
@Override
public void execute(DelegateExecution execution)throws Exception{
LOGGER.info("checking form....... ");
boolean isFormComplete = checkRequestIntegrity(execution);
System.out.println(isFormComplete);
LOGGER.info("Is Complete?"+isFormComplete);
execution.setVariable("isFormComplete", isFormComplete);
if (!isFormComplete){
execution.setVariable("declineMessage", "Form isn't Complet ,Plesase check again~");
}
}
private boolean checkRequestIntegrity(DelegateExecution execution) {
String id = (String) execution.getVariable("id");
String name = (String) execution.getVariable("name");
LOGGER.fine(id + ": " + name);
return id != null && !id.isEmpty() && name != null && !name.isEmpty();
}
}我們回到BPMN,點選「檢查申請完整性」。

將以下配置填入。

接著,我們將「main.bpmn」放在「src/main/resources」,「fillForm.form」放在「src/main/resources/forms」。

接著啟動

請打開瀏覽器輸入
localhost:8090帳號密碼皆為demo/demo
我們到「tasklist」起一個流程。

直接按「start」

就可以看到流程出來囉

我們明天來驗證這個流程是不是有問題,要怎麼修正。
如果有任何問題,歡迎在下方留言!! 筆者頭一回寫技術文,如果內容有誤,或者內容的呈現上有所缺陷,如果您願意,歡迎在下方留言給我呦~~這是我的部落格,歡迎點擊閱覽喔~~會不定期更新文章