ActExecutionMapper.xml 7.78 KB
<?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.hotent.bpm.persistence.dao.ActExecutionDao">
	<resultMap id="ActExecution" type="com.hotent.bpm.persistence.model.ActExecution">
		<id property="id" column="ID_" jdbcType="VARCHAR"/>
		<result property="rev" column="REV_" jdbcType="NUMERIC"/>
		<result property="procInstId" column="PROC_INST_ID_" jdbcType="VARCHAR"/>
		<result property="businessKey" column="BUSINESS_KEY_" jdbcType="VARCHAR"/>
		<result property="parentId" column="PARENT_ID_" jdbcType="VARCHAR"/>
		<result property="procDefId" column="PROC_DEF_ID_" jdbcType="VARCHAR"/>
		<result property="superExec" column="SUPER_EXEC_" jdbcType="VARCHAR"/>
		<result property="actId" column="ACT_ID_" jdbcType="VARCHAR"/>
		<result property="isActive" column="IS_ACTIVE_" jdbcType="BOOLEAN"/>
		<result property="isConcurrent" column="IS_CONCURRENT_" jdbcType="BOOLEAN"/>
		<result property="isScope" column="IS_SCOPE_" jdbcType="BOOLEAN"/>
		<result property="isEventScope" column="IS_EVENT_SCOPE_" jdbcType="BOOLEAN"/>
		<result property="suspensionState" column="SUSPENSION_STATE_" jdbcType="NUMERIC"/>
		<result property="cachedEntState" column="CACHED_ENT_STATE_" jdbcType="NUMERIC"/>
	</resultMap>
	
	<select id="getByParentsId"   parameterType="java.lang.String" resultType="java.lang.String">
		SELECT ID_ FROM act_ru_execution  WHERE  PARENT_ID_=#{parentId}
	</select>
	
	<select id="getBySupperId"   parameterType="java.lang.String" resultType="java.lang.String">
		SELECT ID_ FROM act_ru_execution  WHERE  SUPER_EXEC_=#{supperId}
	</select>
	
	<delete id="delTaskByByInstList">
		delete FROM act_ru_task where PROC_INST_ID_
		in <foreach collection="list" index="index" item="instId" open="(" separator="," close=")"> 
            #{instId} 
        	</foreach>
	</delete>
	
	
	<delete id="delCandidateByInstList">
		delete FROM act_ru_identitylink where PROC_INST_ID_
		in <foreach collection="list" index="index" item="instId" open="(" separator="," close=")"> 
            #{instId} 
        	</foreach> 
	</delete>
	
	<delete id="delEventSubByInstList">
		delete FROM act_ru_event_subscr where PROC_INST_ID_
		in <foreach collection="list" index="index" item="instId" open="(" separator="," close=")"> 
            #{instId} 
        	</foreach> 
	</delete>
	
	
	<delete id="delVarsByInstList">
		delete FROM act_ru_variable where PROC_INST_ID_
		in <foreach collection="list" index="index" item="instId" open="(" separator="," close=")"> 
            #{instId} 
        	</foreach> 
	</delete>
	
	<delete id="delHiVarByInstList">
		delete FROM act_hi_varinst where PROC_INST_ID_
		in <foreach collection="list" index="index" item="instId" open="(" separator="," close=")"> 
            #{instId} 
        	</foreach> 
	</delete>
	
	<delete id="delHiTaskByInstList">
		delete FROM act_hi_taskinst where PROC_INST_ID_
		in <foreach collection="list" index="index" item="instId" open="(" separator="," close=")"> 
            #{instId} 
        	</foreach> 
	</delete>
	
	<delete id="delHiProcinstByInstList">
		delete FROM act_hi_procinst where PROC_INST_ID_
		in <foreach collection="list" index="index" item="instId" open="(" separator="," close=")"> 
            #{instId} 
        	</foreach> 
	</delete>
	
	<delete id="delHiCandidateByInstList">
		delete FROM act_hi_identitylink where PROC_INST_ID_
		in <foreach collection="list" index="index" item="instId" open="(" separator="," close=")"> 
            #{instId} 
        	</foreach> 
	</delete>
	
	
	<delete id="delHiActInstByInstList">
		delete FROM act_hi_actinst where PROC_INST_ID_
		in <foreach collection="list" index="index" item="instId" open="(" separator="," close=")"> 
            #{instId} 
        	</foreach> 
	</delete>
	
	
	
	<delete id="delExectionByInstList">
		delete FROM act_ru_execution where PROC_INST_ID_
		in <foreach collection="list" index="index" item="instId" open="(" separator="," close=")"> 
            #{instId} 
        	</foreach> 
	</delete>
	
	
	<!-- 撤回发起人 需要清除多实例任务相关的数据 如 会签, 同步的act_ru_variable ,act_ru_execution 数据 -->
	<delete id="delActiveByInstList"  >
	  delete FROM act_ru_execution where PROC_INST_ID_
	  in <foreach collection="list" index="index" item="instId" open="(" separator="," close=")"> 
	            #{instId}
	         </foreach> 
	       AND ID_ != PARENT_ID_
	</delete>
	
	<delete id="delActiveVarsByInstList">
		delete FROM act_ru_variable where execution_id_ in (
			select id_ from act_ru_execution where PROC_INST_ID_
		  in <foreach collection="list" index="index" item="instId" open="(" separator="," close=")"> 
		            #{instId} 
		         </foreach> 
		         AND ID_ != PARENT_ID_
		)
	</delete>
	
	<update id="updateRejectExecution" parameterType="com.hotent.bpm.persistence.model.ActExecution">
		UPDATE act_ru_execution SET IS_SCOPE_ = 0,IS_ACTIVE_ = 0,ACT_ID_=#{actId},CACHED_ENT_STATE_=1  WHERE PARENT_ID_=#{parentId} AND ID_ != #{execId}
	</update>
	
	<update id="updateRejectExecution" databaseId="pg" parameterType="com.hotent.bpm.persistence.model.ActExecution">
		UPDATE act_ru_execution SET IS_SCOPE_ = false,IS_ACTIVE_ = false,ACT_ID_=#{actId},CACHED_ENT_STATE_=1  WHERE PARENT_ID_=#{parentId} AND ID_ != #{execId}
	</update>
	
	<delete id="removeByParentIds">
	  delete FROM act_ru_execution where PARENT_ID_
	  in <foreach collection="parentIds" index="index" item="parentId" open="(" separator="," close=")"> 
	            #{parentId}
	         </foreach> 
	       AND ID_ != PARENT_ID_
	</delete>

	<update id="updateRejectExecutionByProcInstIdAndNodeIds">
		UPDATE act_ru_execution SET IS_SCOPE_ = 0,IS_ACTIVE_ = 0,CACHED_ENT_STATE_=1  WHERE PROC_INST_ID_=#{procInstId} AND ID_ not in
		<foreach collection="execIds" item="execId" separator="," open="(" close=")">
			#{execId}
		</foreach>
        and ACT_ID_ in
		<foreach collection="parentUpdateNodeIds" item="nodeId" separator="," open="(" close=")">
			#{nodeId}
		</foreach>
	</update>

	<update id="updateRejectExecutionByProcInstIdAndNodeIds" databaseId="pg" >
		UPDATE act_ru_execution SET IS_SCOPE_ = false,IS_ACTIVE_ = false,CACHED_ENT_STATE_=1  WHERE PROC_INST_ID_=#{procInstId} AND  ID_ not in
		<foreach collection="execIds" item="execId" separator="," open="(" close=")">
			#{execId}
		</foreach>
		and ACT_ID_ in
		<foreach collection="parentUpdateNodeIds" item="nodeId" separator="," open="(" close=")">
			#{nodeId}
		</foreach>
	</update>

	<select id="getRejectByProcInstId" resultMap="ActExecution">
 		select * from act_ru_execution where PROC_INST_ID_=#{procInstId}
	</select>

	<update id="updateActIdByIdAndActId">
		UPDATE act_ru_execution SET ACT_ID_ = #{actId} WHERE  ID_ = #{executionId}
	</update>

	<delete id="delVariableExcludeProcInstIdAndExecId">
		delete from act_ru_variable where PROC_INST_ID_ = #{procInstId} and EXECUTION_ID_ != PROC_INST_ID_ and id_ != #{execId};
	</delete>

	<select id="getExecutionIdsByProcInstIdAndNodeIds" resultType="string" >
		select id_ from  act_ru_execution WHERE PROC_INST_ID_=#{procInstId} 
		<if test="@com.hotent.base.ognl.Ognl@isNotEmpty(execIds)">
			AND ID_ not in
			<foreach collection="execIds" item="execId" separator="," open="(" close=")">
				#{execId}
			</foreach>
		</if>
		and ACT_ID_ in
		<foreach collection="parentUpdateNodeIds" item="nodeId" separator="," open="(" close=")">
			#{nodeId}
		</foreach>
	</select>

	<delete id="delVarsByExecutionIds">
		delete from act_ru_variable where  EXECUTION_ID_  in
		<foreach collection="executionIds" item="executionId" separator="," open="(" close=")">
			#{executionId}
		</foreach>
	</delete>

	<delete id="delExecutionByExecutionIds">
		delete from act_ru_execution where  id_  in
		<foreach collection="executionIds" item="executionId" separator="," open="(" close=")">
			#{executionId}
		</foreach>
	</delete>
	
</mapper>