You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
238 lines
8.5 KiB
238 lines
8.5 KiB
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<!-- rqrq - 流程实例Mapper XML -->
|
|
<mapper namespace="com.xujie.modules.workFlow.mapper.ErfFlowInstanceMapper">
|
|
|
|
<!-- 查询流程实例列表(分页) - rqrq -->
|
|
<select id="searchInstanceList" resultType="ErfFlowInstanceData">
|
|
SELECT
|
|
i.apply_no,
|
|
i.order_ref1,
|
|
i.site,
|
|
i.order_type,
|
|
i.flow_code,
|
|
i.flow_version,
|
|
i.status,
|
|
i.current_node_code,
|
|
i.start_time,
|
|
i.end_time,
|
|
i.remark,
|
|
t.flow_name,
|
|
n.node_name AS currentNodeName
|
|
FROM erf_flow_instance i
|
|
LEFT JOIN erf_flow_template t ON t.flow_code = i.flow_code AND t.flow_version = i.flow_version AND t.site = i.site
|
|
LEFT JOIN erf_flow_node n ON n.flow_code = i.flow_code AND n.flow_version = i.flow_version
|
|
AND n.site = i.site AND n.node_code = i.current_node_code
|
|
<where>
|
|
<if test="query.site != null and query.site != ''">
|
|
AND i.site = #{query.site}
|
|
</if>
|
|
<if test="query.applyNo != null and query.applyNo != ''">
|
|
AND i.apply_no LIKE '%' + #{query.applyNo} + '%'
|
|
</if>
|
|
<if test="query.orderRef1 != null and query.orderRef1 != ''">
|
|
AND i.order_ref1 LIKE '%' + #{query.orderRef1} + '%'
|
|
</if>
|
|
<if test="query.orderType != null and query.orderType != ''">
|
|
AND i.order_type = #{query.orderType}
|
|
</if>
|
|
<if test="query.status != null and query.status != ''">
|
|
AND i.status = #{query.status}
|
|
</if>
|
|
</where>
|
|
ORDER BY i.start_time DESC
|
|
</select>
|
|
|
|
<!-- 查询节点实例列表 -->
|
|
<select id="searchNodeInstanceList" resultType="ErfFlowNodeInstanceData">
|
|
SELECT
|
|
ni.apply_no,
|
|
ni.node_code,
|
|
ni.attempt_no,
|
|
ni.site,
|
|
ni.order_type,
|
|
ni.department_id,
|
|
ni.department_name,
|
|
ni.assignee_user_id,
|
|
ni.assignee_name,
|
|
ni.status,
|
|
ni.comment,
|
|
ni.receive_time,
|
|
ni.complete_time,
|
|
ni.duration_seconds,
|
|
n.node_name,
|
|
n.node_order,
|
|
n.approve_type
|
|
FROM erf_flow_node_instance ni
|
|
LEFT JOIN erf_flow_instance i ON i.apply_no = ni.apply_no AND i.site = ni.site AND i.order_type = ni.order_type
|
|
LEFT JOIN erf_flow_node n ON n.flow_code = i.flow_code AND n.flow_version = i.flow_version
|
|
AND n.site = i.site AND n.node_code = ni.node_code
|
|
WHERE ni.apply_no = #{applyNo}
|
|
AND ni.site = #{site}
|
|
AND ni.order_type = #{orderType}
|
|
ORDER BY n.node_order, ni.attempt_no
|
|
</select>
|
|
|
|
<!-- 插入流程实例 - rqrq -->
|
|
<insert id="insertInstance">
|
|
INSERT INTO erf_flow_instance (
|
|
apply_no, order_ref1, site, order_type, flow_code, flow_version,
|
|
status, current_node_code, start_time
|
|
) VALUES (
|
|
#{applyNo}, #{orderRef1}, #{site}, #{orderType}, #{flowCode}, #{flowVersion},
|
|
#{status}, #{currentNodeCode}, GETDATE()
|
|
)
|
|
</insert>
|
|
|
|
<!-- 插入节点实例 -->
|
|
<insert id="insertNodeInstance">
|
|
INSERT INTO erf_flow_node_instance (
|
|
apply_no, node_code, attempt_no, site, order_type,
|
|
department_id, department_name, assignee_user_id, assignee_name, status, receive_time
|
|
) VALUES (
|
|
#{applyNo}, #{nodeCode}, #{attemptNo}, #{site}, #{orderType},
|
|
#{departmentId}, #{departmentName}, #{assigneeUserId}, #{assigneeName}, #{status}, GETDATE()
|
|
)
|
|
</insert>
|
|
|
|
<!-- 更新流程实例状态 -->
|
|
<update id="updateInstanceStatus">
|
|
UPDATE erf_flow_instance
|
|
SET status = #{status},
|
|
current_node_code = #{currentNodeCode}
|
|
WHERE apply_no = #{applyNo}
|
|
AND site = #{site}
|
|
AND order_type = #{orderType}
|
|
</update>
|
|
|
|
<!-- 更新流程实例完成 -->
|
|
<update id="updateInstanceCompleted">
|
|
UPDATE erf_flow_instance
|
|
SET status = 'COMPLETED',
|
|
end_time = GETDATE()
|
|
WHERE apply_no = #{applyNo}
|
|
AND site = #{site}
|
|
AND order_type = #{orderType}
|
|
</update>
|
|
|
|
<!-- 更新节点实例状态 -->
|
|
<update id="updateNodeInstanceStatus">
|
|
UPDATE erf_flow_node_instance
|
|
SET status = #{status},
|
|
comment = #{comment},
|
|
complete_time = GETDATE()
|
|
WHERE apply_no = #{applyNo}
|
|
AND node_code = #{nodeCode}
|
|
AND attempt_no = #{attemptNo}
|
|
AND site = #{site}
|
|
AND order_type = #{orderType}
|
|
</update>
|
|
|
|
<!-- 获取节点实例详情 -->
|
|
<select id="getNodeInstanceDetail" resultType="ErfFlowNodeInstanceData">
|
|
SELECT
|
|
ni.apply_no,
|
|
ni.node_code,
|
|
ni.attempt_no,
|
|
ni.site,
|
|
ni.order_type,
|
|
ni.assignee_user_id,
|
|
ni.assignee_name,
|
|
ni.status,
|
|
ni.comment,
|
|
ni.receive_time,
|
|
ni.complete_time,
|
|
n.node_name,
|
|
n.node_order,
|
|
n.approve_type,
|
|
i.flow_code,
|
|
i.flow_version
|
|
FROM erf_flow_node_instance ni
|
|
LEFT JOIN erf_flow_instance i ON i.apply_no = ni.apply_no AND i.site = ni.site AND i.order_type = ni.order_type
|
|
LEFT JOIN erf_flow_node n ON n.flow_code = i.flow_code AND n.flow_version = i.flow_version
|
|
AND n.site = i.site AND n.node_code = ni.node_code
|
|
WHERE ni.apply_no = #{applyNo}
|
|
AND ni.node_code = #{nodeCode}
|
|
AND ni.attempt_no = #{attemptNo}
|
|
AND ni.site = #{site}
|
|
AND ni.order_type = #{orderType}
|
|
</select>
|
|
|
|
<!-- 获取流程实例 - rqrq -->
|
|
<select id="getInstanceByApplyNo" resultType="ErfFlowInstanceData">
|
|
SELECT
|
|
i.apply_no,
|
|
i.order_ref1,
|
|
i.site,
|
|
i.order_type,
|
|
i.flow_code,
|
|
i.flow_version,
|
|
i.status,
|
|
i.current_node_code,
|
|
i.start_time,
|
|
i.end_time,
|
|
t.flow_name
|
|
FROM erf_flow_instance i
|
|
LEFT JOIN erf_flow_template t ON t.flow_code = i.flow_code AND t.flow_version = i.flow_version AND t.site = i.site
|
|
WHERE i.apply_no = #{applyNo}
|
|
AND i.site = #{site}
|
|
AND i.order_type = #{orderType}
|
|
</select>
|
|
|
|
<!-- 获取当前节点的最大尝试次数 -->
|
|
<select id="getMaxAttemptNo" resultType="Integer">
|
|
SELECT ISNULL(MAX(attempt_no), 0)
|
|
FROM erf_flow_node_instance
|
|
WHERE apply_no = #{applyNo}
|
|
AND node_code = #{nodeCode}
|
|
AND site = #{site}
|
|
AND order_type = #{orderType}
|
|
</select>
|
|
|
|
<!-- 获取待审批的节点实例 -->
|
|
<select id="getPendingNodeInstance" resultType="ErfFlowNodeInstanceData">
|
|
SELECT TOP 1
|
|
ni.apply_no,
|
|
ni.node_code,
|
|
ni.attempt_no,
|
|
ni.site,
|
|
ni.order_type,
|
|
ni.assignee_user_id,
|
|
ni.assignee_name,
|
|
ni.status,
|
|
n.node_name,
|
|
n.node_order,
|
|
n.approve_type
|
|
FROM erf_flow_node_instance ni
|
|
LEFT JOIN erf_flow_instance i ON i.apply_no = ni.apply_no AND i.site = ni.site AND i.order_type = ni.order_type
|
|
LEFT JOIN erf_flow_node n ON n.flow_code = i.flow_code AND n.flow_version = i.flow_version
|
|
AND n.site = i.site AND n.node_code = ni.node_code
|
|
WHERE ni.apply_no = #{applyNo}
|
|
AND ni.node_code = #{nodeCode}
|
|
AND ni.site = #{site}
|
|
AND ni.order_type = #{orderType}
|
|
AND ni.status = 'PENDING'
|
|
ORDER BY ni.attempt_no DESC
|
|
</select>
|
|
|
|
<!-- 删除指定单据的所有节点实例 - rqrq -->
|
|
<delete id="deleteNodeInstancesByApplyNo">
|
|
DELETE FROM erf_flow_node_instance
|
|
WHERE apply_no = #{applyNo}
|
|
AND site = #{site}
|
|
AND order_type = #{orderType}
|
|
</delete>
|
|
|
|
<!-- 重启流程实例 - rqrq -->
|
|
<update id="restartInstance">
|
|
UPDATE erf_flow_instance
|
|
SET status = 'RUNNING',
|
|
current_node_code = #{currentNodeCode},
|
|
start_time = GETDATE(),
|
|
end_time = NULL
|
|
WHERE apply_no = #{applyNo}
|
|
AND site = #{site}
|
|
AND order_type = #{orderType}
|
|
</update>
|
|
|
|
</mapper>
|