-- 查询流程状态
SELECT id,
CASE `status` WHEN 1 THEN '初始化中' WHEN 2 THEN '运行中' WHEN 3 THEN '挂起' WHEN 4 THEN '停止' WHEN 5 THEN '完成' ELSE '取消运行' END   statusLabel,
created_at,finish_at,cancel_at,user_id,data_id  FROM workflow_instance 


-- 查询实例当前的节点状态 
SELECT b.id AS nodeid,
b.name,
CASE a.status WHEN 0 THEN '无效的' WHEN 1 THEN '等待运行' WHEN 2 THEN '正在运行' WHEN 3 THEN '正常完成' WHEN 4 THEN '逾期完成' ELSE '' END   statusLabel,
a.* 
FROM workflow_instance_node a 
LEFT JOIN workflow_node b ON a.workflow_node_id = b.id 
WHERE a.instance_id = 1 
ORDER BY b.id ASC  

-- 查询实例 全局变量 
SELECT
b.`name`,b.`label`, 
a.`variable_value`
FROM `workflow_instance_variable` a 
LEFT JOIN `workflow_variable` b ON a.`workflow_variable_id` = b.id 
WHERE a.`instance_id` = 1 

-- 查询实例节点变量 
SELECT c.id AS nodeId,c.`name` AS nodeName,b.name,b.label,a.`variable_value` ,b.* 
FROM `workflow_instance_node_variable` a 
LEFT JOIN `workflow_node_variable` b ON a.`workflow_node_variable_id` = b.id 
LEFT JOIN `workflow_node` c ON b.`node_id` = c.id 
WHERE a.`instance_id` = 1 
AND a.`workflow_node_id` =3
ORDER BY b.id ASC 


-- 查询实例 节点处理人的处理状态 
SELECT b.name,a.*  FROM workflow_instance_node_personnel a 
LEFT JOIN workflow_node b ON a.workflow_node_id = b.id 
WHERE a.instance_id = 1 

-- 消息通知 
SELECT * FROM notice ORDER BY id DESC 

-- 日志
SELECT b.name,a.* FROM workflow_instance_log a 
LEFT JOIN workflow_node b ON a.workflow_node_id = b.id 