Blame view

backend/bpm/src/main/resources/mapper/BpmCustomSignDataMapper.xml 6.14 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<?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.BpmCustomSignDataDao">
	<resultMap id="BpmCustomSignData" type="com.hotent.bpm.persistence.model.BpmCustomSignData">
		<id property="id" column="id_" jdbcType="VARCHAR"/>
		<result property="type" column="type_" jdbcType="VARCHAR"/>
		<result property="status" column="status_" jdbcType="VARCHAR"/>
		<result property="parentId" column="parent_id_" jdbcType="VARCHAR"/>
		<result property="path" column="path_" jdbcType="VARCHAR"/>
		<result property="instId" column="inst_id_" jdbcType="VARCHAR"/>
		<result property="nodeId" column="node_id_" jdbcType="VARCHAR"/>
		<result property="taskId" column="task_id_" jdbcType="VARCHAR"/>
		<result property="executor" column="executor" jdbcType="VARCHAR"/>
		<result property="isRead" column="is_read_" jdbcType="VARCHAR"/>
	</resultMap>
	
	<insert id="create" parameterType="com.hotent.bpm.persistence.model.BpmCustomSignData">
		INSERT INTO bpm_custom_signdata
		(id_,type_,status_,parent_id_,path_,inst_id_,node_id_,task_id_)
		VALUES 
		(#{id,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{parentId,jdbcType=VARCHAR}, #{path,jdbcType=VARCHAR}, #{instId,jdbcType=VARCHAR}, #{nodeId,jdbcType=VARCHAR}, #{taskId,jdbcType=VARCHAR})
	</insert>
	
	<select id="get"   parameterType="java.lang.String" resultMap="BpmCustomSignData">
		SELECT * FROM bpm_custom_signdata 
		WHERE 
		id_=#{id}
	</select>
	
	<select id="getByTaskIdAndStatus"   parameterType="java.lang.String" resultMap="BpmCustomSignData">
		SELECT * FROM bpm_custom_signdata 
		<where>
			task_id_=#{taskId}
			<if test="status!=null">
			and status_ = #{status}
			</if> 
		</where>
	</select>
	
	<select id="getByInstIdAndStatus"   parameterType="java.lang.String" resultMap="BpmCustomSignData">
		SELECT * FROM bpm_custom_signdata 
		<where>
			inst_id_=#{instId}
			<if test="status!=null">
			and status_ = #{status}
			</if> 
		</where>
	</select>
	
	<select id="getByInstIdAndStatusList" resultMap="BpmCustomSignData">
		SELECT * FROM bpm_custom_signdata
		<where>
			inst_id_=#{instId}
			and status_  in 
			<foreach collection="statusList" index="index" item="status" open="(" separator="," close=")"> 
            #{status} 
        	</foreach>  
		</where>
	</select>
	
	<select id="getSequentialSonByTaskId" resultMap="BpmCustomSignData">
		SELECT
			*
		FROM
			bpm_custom_signdata
		WHERE
		type_ = 'sequential'
		AND (status_ = 'approval'
				OR status_ = 'withdrawApproval' )
		AND parent_id_ = (
			SELECT
				sign.id_
			FROM
				bpm_custom_signdata sign
			WHERE
				sign.task_id_ =#{taskId}
		)
	</select>
	
	<select id="getParallelSonByPath" resultMap="BpmCustomSignData">
		SELECT
			*
		FROM
			bpm_custom_signdata
		WHERE
		type_ = 'parallel'
		AND (status_ = 'approval'
				OR status_ = 'withdrawApproval' )
		AND path_ like '${path}%' 
	</select>
	
	<select id="getParallelAllSonByPath" resultMap="BpmCustomSignData">
		SELECT
			signdata.*,
			opinion.QUALFIEDS_ as "executor",
			opinion.is_read_ as "is_read_"
		FROM
			bpm_custom_signdata signdata
		LEFT JOIN bpm_check_opinion opinion on opinion.task_id_ =  signdata.task_id_ 
		WHERE
		signdata.type_ = 'parallel'
		AND signdata.path_ like '${path}%' 
		AND signdata.path_ != #{path}
	</select>
	
	<select id="getSignDataByBeforeSignTaskId" resultMap="BpmCustomSignData">
		SELECT
			*
		FROM
			bpm_custom_signdata
		WHERE
			(
				status_ = 'approval'
				OR status_ = 'withdrawApproval'
			)
		AND inst_id_ = #{instId}
		AND node_id_ = (
			SELECT
				TO_NODE_ID_
			FROM
				bpm_exe_stack_relation
			WHERE
				TO_NODE_TYPE_ = 'customSignTask'
			AND FROM_STACK_ID_ = (
				SELECT
					STACK_ID_
				FROM
					bpm_exe_stack_executor
				WHERE
					TASK_ID_ = #{taskId}
			)
		)
	</select>
	
	<select id="getAllSignDataByBeforeSignTaskId" resultMap="BpmCustomSignData">
		SELECT
			signdata.*,
			opinion.QUALFIEDS_ as "executor",
			opinion.is_read_ as "is_read_"
		FROM
			bpm_custom_signdata signdata
		LEFT JOIN bpm_check_opinion opinion on opinion.task_id_ =  signdata.task_id_ 
		WHERE
		signdata.inst_id_ = #{instId}
		AND signdata.node_id_ = (
			SELECT
				TO_NODE_ID_
			FROM
				bpm_exe_stack_relation
			WHERE
				TO_NODE_TYPE_ = 'customSignTask'
			AND FROM_STACK_ID_ = (
				SELECT
					STACK_ID_
				FROM
					bpm_exe_stack_executor
				WHERE
					TASK_ID_ = #{taskId}
			)
		)
	</select>
	
	<update id="updateStatusByInstId" parameterType="java.lang.String">
		UPDATE bpm_custom_signdata SET
		status_=#{newStatus,jdbcType=VARCHAR}
		WHERE
		inst_id_=#{instId}
		and status_  in 
		<foreach collection="statusList" index="index" item="status" open="(" separator="," close=")"> 
           #{status} 
       	</foreach>
	</update>
	
	
	<select id="query" parameterType="java.util.Map" resultMap="BpmCustomSignData">
		SELECT * FROM bpm_custom_signdata
		<where>
			<if test="whereSql!=null">
				${whereSql}
			</if>
		</where>
		<if test="orderBySql!=null">
			ORDER BY ${orderBySql}
		</if>
		<if test="orderBySql==null">
			ORDER BY id_ DESC
		</if>
	</select>
	
	<update id="updateStatusByTaskId" parameterType="java.lang.String">
		UPDATE bpm_custom_signdata SET
		status_=#{newStatus,jdbcType=VARCHAR}
		<if test="newCreateTaskId!=null">
		,task_id_=#{newCreateTaskId,jdbcType=VARCHAR}
		</if>
		WHERE
		task_id_=#{taskId,jdbcType=VARCHAR}
		and status_ in 
		<foreach collection="oldStatus" index="index" item="status" open="(" separator="," close=")"> 
           #{status} 
       	</foreach>
	</update>
	
	<delete id="remove" parameterType="java.lang.String">
		DELETE FROM bpm_custom_signdata 
		WHERE
		id_=#{id}
	</delete>
	
	<delete id="removeByInstId" parameterType="java.lang.String">
		DELETE FROM bpm_custom_signdata 
		WHERE
		inst_id_=#{instId}
	</delete>
	
	<select id="getBrotherByTaskId"  resultMap="BpmCustomSignData">
		SELECT * FROM bpm_custom_signdata 
		where 
		 status_ in 
		<foreach collection="status" index="index" item="val" open="(" separator="," close=")"> 
           #{val} 
       	</foreach>
		  and parent_id_ = ( select b.parent_id_ from bpm_custom_signdata b where b.task_id_ = #{taskId} )
	</select>
	
</mapper>