<?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">
<mapper namespace="com.jeeplus.flowable.mapper.FlowMapper">

    <update id="updateProcInsIdByBusinessId">
        UPDATE ${businessTable}
        SET proc_ins_id = #{procInsId}
        <if test="procDefId != null and procDefId != ''">
            ,process_definition_id = #{procDefId}
        </if>
        WHERE id = #{businessId}
    </update>
    <select id="getTaskIdByprocInstId" resultType="java.lang.String">
        select ID_ from act_hi_procinst where PROC_INST_ID_ = #{procInstId}
    </select>

	<select id="getTaskAuditUsersByprocInstId" resultType="java.lang.String">
		select ID_ from act_ru_task where PROC_INST_ID_ = #{procInstId}
	</select>

    <select id="getTaskInfoByTaskId" resultType="com.jeeplus.flowable.model.ActRuTaskInfo">
		select
		  ID_ as "id",
		  REV_ as "rev",
		  EXECUTION_ID_ as "executionId",
		  PROC_INST_ID_ as "procInstId",
		  PROC_DEF_ID_ as "procDefId",
		  TASK_DEF_ID_ as "taskDefId",
		  SCOPE_ID_ as "scopeId",
		  SUB_SCOPE_ID_ as "subScopeId",
		  SCOPE_TYPE_ as "scopeType",
		  SCOPE_DEFINITION_ID_ as "scopeDefinitionId",
		  NAME_ as "name",
		  PARENT_TASK_ID_ as "parentTaskId",
		  DESCRIPTION_ as "description",
		  TASK_DEF_KEY_ as "taskDefKey",
		  OWNER_ as "owner",
		  ASSIGNEE_ as "assignee",
		  DELEGATION_ as "delegation",
		  PRIORITY_ as "priority",
		  CREATE_TIME_ as "createTime",
		  DUE_DATE_ as "dueDate",
		  CATEGORY_ as "category",
		  SUSPENSION_STATE_ as "suspensionState",
		  TENANT_ID_ as "tenantId",
		  FORM_KEY_ as "formKey",
		  CLAIM_TIME_ as "claimTime",
		  IS_COUNT_ENABLED_ as "isCountEnabled",
		  VAR_COUNT_ as "varCount",
		  ID_LINK_COUNT_ as "idLinkCount",
		  SUB_TASK_COUNT_  as "subTaskCount"
		from
		  act_ru_task
		where ID_= #{taskId}
		order by CREATE_TIME_ desc
		limit 1
	</select>

    <select id="getTenantIdByProcDefKey" resultType="java.lang.String">
		select
		  TENANT_ID_ as "tenantId"
		from
		  ACT_RE_PROCDEF
		where KEY_ = #{procDefKey}
		limit 1
	</select>
    <select id="getActNameByDefId" resultType="java.lang.String">
		select NAME_ from act_re_deployment where KEY_ = #{procDefId}
		limit 1
	</select>

</mapper>
