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 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()
)
UPDATE erf_flow_instance
SET status = #{status},
current_node_code = #{currentNodeCode}
WHERE apply_no = #{applyNo}
AND site = #{site}
AND order_type = #{orderType}
UPDATE erf_flow_instance
SET status = 'COMPLETED',
end_time = GETDATE()
WHERE apply_no = #{applyNo}
AND site = #{site}
AND order_type = #{orderType}
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}
DELETE FROM erf_flow_node_instance
WHERE apply_no = #{applyNo}
AND site = #{site}
AND order_type = #{orderType}
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}