泛微E8查询流程状态以及当前所处节点

泛微E8查询流程状态以及当前所处节点

Scroll Down
SELECT
    A.REQUESTID '请求ID',
    A.REQUESTNAME '请求标题',
    NODE.NODENAME '当前节点名称',
    (CASE WHEN A.CREATER=1 THEN '系统管理员' ELSE RES.LASTNAME END) '创建人姓名',
    A.CREATEDATE + ' ' + A.CREATETIME '创建时间',
    CR.LASTNAME '接收人姓名',
    CR.RECEIVEDATE + ' ' + CR.RECEIVETIME '接收时间',
    BASE.WORKFLOWNAME '工作流名称',
    A.STATUS '出口名称',
    (CASE WHEN A.CURRENTNODETYPE=0 THEN '创建节点' WHEN A.CURRENTNODETYPE=1 THEN '审批节点' WHEN A.CURRENTNODETYPE=2 THEN '处理节点' ELSE '其他节点' END) '节点类型'
FROM WORKFLOW_REQUESTBASE A
INNER JOIN WORKFLOW_NODEBASE NODE ON NODE.ID=A.CURRENTNODEID
LEFT JOIN HRMRESOURCE RES ON RES.ID=A.CREATER
INNER JOIN WORKFLOW_BASE BASE ON BASE.ID=A.WORKFLOWID
INNER JOIN (SELECT REQUESTID, R1.LASTNAME, RECEIVEDATE, RECEIVETIME FROM WORKFLOW_CURRENTOPERATOR C1
INNER JOIN HRMRESOURCE R1 ON R1.ID=C1.USERID
WHERE C1.ID IN (SELECT MAX(ID) FROM WORKFLOW_CURRENTOPERATOR GROUP BY REQUESTID)) CR ON CR.REQUESTID=A.REQUESTID
WHERE CURRENTNODETYPE != 3
AND (
    (
        EXISTS (
            SELECT 1
            FROM WORKFLOW_BASE WB
            WHERE A.WORKFLOWID = WB.ID
            AND WB.ISVALID IN ('0', '1', '2', '3')
            AND WB.ID IN (
                SELECT ID
                FROM WORKFLOW_BASE WORKBASE, WORKFLOW_VERSIONINFO WORKVERSION
                WHERE WORKBASE.ID = WORKVERSION.WFID
                AND WFVERSIONID IN (
                    SELECT WORKFLOWID FROM WORKFLOW_MONITOR_DETAIL WHERE INFOID = 0
                )
            )
        )
    )
)
AND A.DELETED < 1
ORDER BY A.REQUESTID DESC