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

SELECT A.workflowid  '工作流id',
    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   ---workflow_requestbase 工作流请求基本信息表
INNER JOIN WORKFLOW_NODEBASE NODE ON NODE.ID=A.CURRENTNODEID   --WORKFLOW_NODEBASE 工作流节点基本信息表
LEFT JOIN HRMRESOURCE RES ON RES.ID=A.CREATER---HRMRESOURCE 
INNER JOIN WORKFLOW_BASE BASE ON BASE.ID=A.WORKFLOWID  --workflow_base 工作流基本信息表
INNER JOIN (SELECT REQUESTID, R1.LASTNAME, RECEIVEDATE, RECEIVETIME 
              FROM WORKFLOW_CURRENTOPERATOR C1          ---WORKFLOW_CURRENTOPERATOR 工作流请求节点操作人信息表
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
 

你可能感兴趣的:(泛微OA,其他)