Blame view

backend/bpm/src/main/resources/mapper/BpmBusLinkMapper.xml 6.16 KB
8ea9c133   陈威   初始化提交
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?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.BpmBusLinkDao">
	<resultMap id="BpmBusLink" type="com.hotent.bpm.persistence.model.BpmBusLink">
		<id property="id" column="id_" jdbcType="VARCHAR"/>
		<result property="defId" column="def_id_" jdbcType="VARCHAR"/>
		<result property="procInstId" column="proc_inst_id_" jdbcType="VARCHAR"/>
		<result property="businesskey" column="businesskey_" jdbcType="NUMERIC"/>
		<result property="businesskeyStr" column="businesskey_str_" jdbcType="VARCHAR"/>
		<result property="sysCode" column="SYS_CODE_" jdbcType="VARCHAR"/>
		<result property="formIdentify" column="form_identify_" jdbcType="VARCHAR"/>
		<result property="startId" column="start_id_" jdbcType="VARCHAR"/>
		<result property="startor" column="startor_" jdbcType="VARCHAR"/>
		<result property="createDate" column="create_date_" jdbcType="TIMESTAMP"/>
		<result property="startGroupId" column="start_group_id_" jdbcType="VARCHAR"/>
		<result property="startGroup" column="start_group_" jdbcType="VARCHAR"/>
		<result property="isMain" column="IS_MAIN_" jdbcType="NUMERIC"/>
		<result property="boDefCode" column="BO_DEF_CODE_" jdbcType="VARCHAR"/>
		<result property="saveMode" column="SAVE_MODE_" jdbcType="VARCHAR"/>
	</resultMap>
	
	<select id="getByBusinesKey" parameterType="java.util.Map" resultMap="BpmBusLink">
		SELECT * FROM bpm_bus_link 
		<where>
			<choose>
				<when test="isNumber">
					and businesskey_=#{businessKey}
				</when>
				<otherwise>
					and businesskey_str_=#{businessKey}
				</otherwise>
			</choose>
			<if test="formIdentity!=null">
				and form_identify_=#{formIdentity}
			</if>
            <if test="boDefCode!=null">
                and bo_def_code_=#{boDefCode}
            </if>
            <if test="defIds!=null">
                and def_id_ in
                <foreach collection="defIds" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
		</where>
	</select>
	
	<delete id="delByBusinesKey" parameterType="java.util.Map">
		DELETE FROM bpm_bus_link 
		<where>
			<choose>
				<when test="isNumber">
					and businesskey_=#{businessKey}
				</when>
				<otherwise>
					and businesskey_str_=#{businessKey}
				</otherwise>
			</choose>
			<if test="formIdentity!=null">
				and form_identify_=#{formIdentity}
			</if>
		</where>
	</delete>
	
	
	
	
	<select id="isExsitPartition_mysql" parameterType="java.util.Map" resultType="Long"> 
		select count(*) from information_schema.partitions  where table_schema = schema() and table_name='BPM_BUS_LINK' and partition_name = #{partitionName}
	</select>
	<select id="isExsitPartition_oracle" parameterType="java.util.Map" resultType="Long"> 
		select count(*) from user_tab_partitions where table_name = 'BPM_BUS_LINK' and partition_name = #{partitionName}
	</select>
	 
	<select id="createPartition_mysql" parameterType="java.util.Map" >
		alter table BPM_BUS_LINK add partition (partition ${partitionName} values in (#{formIdentify}))
	</select>
	<select id="createPartition_oracle" parameterType="java.util.Map" >
		 ALTER TABLE BPM_BUS_LINK ADD PARTITION ${partitionName} VALUES ( #{formIdentify} ) NOCOMPRESS
	</select>
	
	
	
	<select id="getMysqlVersion" resultType="String">
		select VERSION();
	</select>
	
	<select id="getByInstId" resultMap="BpmBusLink">
		SELECT * FROM bpm_bus_link where proc_inst_id_=#{procInstId,jdbcType=VARCHAR} and IS_MAIN_=1
	</select>
	
	<select id="getAllByInstId" resultMap="BpmBusLink">
		SELECT * FROM bpm_bus_link where proc_inst_id_=#{procInstId,jdbcType=VARCHAR}
	</select>
	
	<select id="getByDefId" resultMap="BpmBusLink">
		SELECT * FROM bpm_bus_link where def_id_=#{defId,jdbcType=VARCHAR}
	</select>

	<select id="filterByDone" resultType="java.lang.String">
		SELECT DISTINCT <if test="isNumberPk"> BUSINESSKEY_</if><if test="!isNumberPk"> BUSINESSKEY_STR_</if>
		FROM bpm_bus_link bbl
				 LEFT JOIN bpm_pro_inst inst
						   ON inst.ID_ = bbl.PROC_INST_ID_
				 LEFT JOIN bpm_check_opinion bco
						   ON bco.PROC_INST_ID_ = bbl.PROC_INST_ID_
		WHERE bbl.FORM_IDENTIFY_ = #{formIdentity}
			and
			  auditor_ = #{userId}
		   or agent_leader_id_ = #{userId}
			AND bco.status_ NOT IN
				('skip', 'copyto', 'copyto_reply', 'start_commu', 'lockTask', 'end_revoke', 'start', 'end', 'feedback',
				 'signRecoverCancel', 'signLineRetracted')
			AND inst.status_ != 'draft'
			AND inst.IS_DELE_ != 1
	</select>

	<select id="filterByRequest" resultType="java.lang.String">
		SELECT DISTINCT <if test="isNumberPk"> BUSINESSKEY_</if><if test="!isNumberPk"> BUSINESSKEY_STR_</if>
		FROM bpm_bus_link bbl
		LEFT JOIN bpm_pro_inst inst
		ON inst.ID_ = BBL.PROC_INST_ID_
		WHERE bbl.FORM_IDENTIFY_ = #{formIdentity}
		AND inst.IS_DELE_ = 0
		AND inst.CREATE_BY_ = #{userId}
	</select>

	<select id="filterByRead" resultType="java.lang.String">
		SELECT DISTINCT <if test="isNumberPk"> BUSINESSKEY_</if><if test="!isNumberPk"> BUSINESSKEY_STR_</if>
		FROM bpm_bus_link bbl
			 LEFT JOIN bpm_task_notice btn
	   			ON btn.PROC_INST_ID_ = BBL.PROC_INST_ID_
		WHERE bbl.FORM_IDENTIFY_ = #{formIdentity}
		  	and (btn.ASSIGNEE_ID_ = #{userId} or btn.OWNER_ID_ = #{userId})
		union
		SELECT DISTINCT BUSINESSKEY_STR_
		FROM bpm_bus_link bbl2
		    left join bpm_task_notice_done btnd
		        on btnd.PROC_INST_ID_ = bbl2.PROC_INST_ID_
		where bbl2.FORM_IDENTIFY_ = #{formIdentity}
		  	and btnd.AUDITOR_ = #{userId}
	</select>
	
	<delete id="deleteBatch" parameterType="list">
		DELETE FROM bpm_bus_link 
		WHERE 
		id_ IN
        <foreach collection="list" item="id" open="(" close=")" separator=",">
            #{id}
        </foreach>
		
	</delete>
	
	<delete id="delBatchByBusinesKey" parameterType="java.util.Map">
		
		DELETE FROM bpm_bus_link where 
		<foreach collection="list" item="item" separator="or">
			 ( 
			<choose>
				<when test="item.isNumber">
					businesskey_=#{item.businessKey}
				</when>
				<otherwise>
					businesskey_str_=#{item.businessKey}
				</otherwise>
			</choose>
			<if test="item.formIdentity!=null">
				and form_identify_=#{item.formIdentity}
			</if>
			) 
		</foreach>
	</delete>

</mapper>