一种工单流程设计
<scxml version="1.0" xmlns="http://www.w3.org/2005/07/scxml" xmlns:appeal="http://www.test-inc.com/schema/scxml" xmlns:cs="http://commons.apache.org/scxml" initial="ready"> <state id="ready"> <transition event="seller-appeal" target="create"/> <transition event="transfer" target="end"> <appeal:transfer request="$request" from="$from" to="$to"/> </transition> </state> <!-- 创建工单 --> <state id="create"> <onentry> <!-- 事务创建工单,工单状态更新为"waitAssign" --> <appeal:create request="$request" status="waitAssign"/> </onentry> <!-- 如果自动分单失败,可以再次触发"create.entry"事件--> <transition event="create.entry" cond="$request.appeal.status='waitAssign'" target="waitIntervening"> <!-- 自动分单 --> <appeal:assign request="$request" status="waitIntervening"/> </transition> </state> <!-- 等待小二介入 --> <state id="waitIntervening"> <onentry> <!-- 插入超时提醒 --> <appeal:timeout bizId="$appealId" method="add"/> </onentry> <!-- 小二介入 --> <transition event="intervening" target="processing"/> </state> <!-- 处理中 --> <state id="processing"> <onentry> <!-- 断言更新状态成功,如果不成功就不需要进行下一步,因为有可能是并发重复请求 --> <appeal:assert expr="@appealService.updateStatus($appealId, 'processing')"/> <!-- 删除超时提醒 --> <appeal:timeout bizId="$appealId" method="delete"/> </onentry> <!-- 暂存 --> <transition event="save" target="processing"> <appeal:save request="$request"/> </transition> <!-- 退回 --> <transition event="refuse" target="end"> <appeal:refuse request="$request" status="returned"/> </transition> <!-- 完结 --> <transition event="finish" target="end"> <appeal:finish request="$request" status="processed"/> </transition> </state> <state id="end" final="true"/> </scxml>