Forge business workflow status must be maintained by the business module, not inferred only from Flowable screens.
Use these values unless the domain has a strong reason to extend them:
| Status | Meaning | Typical allowed actions |
|---|---|---|
DRAFT |
Created but not submitted | edit, delete, submit |
IN_PROCESS |
Flow instance is running in approval nodes | view, save allowed node fields |
NEED_MODIFY |
Rejected back to applicant modify node | edit permitted fields, resubmit, terminate |
APPROVED |
Flow completed successfully | readonly, domain side effects |
REJECTED |
Applicant terminated or flow rejected | readonly/delete depending on domain |
CANCELED |
Flow canceled/withdrawn/terminated | readonly/delete depending on domain |
Add at least:
`status` varchar(32) NOT NULL DEFAULT 'DRAFT' COMMENT '业务状态',
`business_key` varchar(128) DEFAULT NULL COMMENT '流程业务Key',
`process_instance_id` varchar(128) DEFAULT NULL COMMENT '流程实例ID'
Add per-node approver and remark fields only when the business table must retain them for search/reporting. Otherwise task comments can stay in flow task history.
Code-first Services should use:
@FlowBind(modelKey = MODEL_KEY, businessType = BUSINESS_TYPE)
public class XxxServiceImpl {
@FlowCallback(on = {
FlowCallback.ON_TASK_CREATED,
FlowCallback.ON_TASK_COMPLETED,
FlowCallback.ON_COMPLETED,
FlowCallback.ON_REJECTED,
FlowCallback.ON_CANCELED
})
@Transactional(rollbackFor = Exception.class)
public void handleFlowEvent(FlowEventContext context) {
// load by tenant + businessKey; update idempotently
}
}
Required handling:
ON_TASK_CREATED: repair business status from current active node. This is critical for reject-to-modify flows.ON_TASK_COMPLETED: copy task variables needed by the business and move status for reject/resubmit decisions.ON_COMPLETED: set approved and copy final variables, but do not assume this event is the only reliable source.ON_REJECTED: set rejected with reason.ON_CANCELED: set canceled with reason.Do not trust event ordering as the only source of truth. Add repair at three points:
TASK_CREATED callback:
IN_PROCESS -> NEED_MODIFY.NEED_MODIFY -> IN_PROCESS.Task form save:
IN_PROCESS, repair to NEED_MODIFY before validation.NEED_MODIFY, repair to IN_PROCESS before validation.Page/detail query:
sys_flow_task by business_key.task_def_key back to expected business status.recordId, businessKey, and user IDs as strings in frontend. Do not convert Snowflake IDs to JS Number.tenantId + businessKey.ai_business_flow_instance_link; do not add duplicate frontend start paths.business_key/process_instance_id.