郑永安
2023-06-19 7a6abd05683528032687c75e80e0bd2030a3e46c
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
<?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.gkhy.safePlatform.specialWork.repository.ApprovalRuleStepRepository" >
    <resultMap id="BaseResultMap" type="com.gkhy.safePlatform.specialWork.entity.ApprovalRuleStep" >
        <id column="step_id" property="stepId" jdbcType="BIGINT" />
        <result column="rule_id" property="ruleId" jdbcType="BIGINT"/>
        <result column="step_name" property="stepName" jdbcType="VARCHAR"/>
        <result column="status" property="status" jdbcType="TINYINT"/>
        <result column="step_serial" property="stepSerial" jdbcType="INTEGER"/>
        <result column="enable_order" property="enableOrder" jdbcType="BOOLEAN"/>
        <result column="type" property="type" jdbcType="TINYINT"/>
        <result column="continue_time" property="continueTime" jdbcType="INTEGER"/>
        <result column="continue_time_unit" property="continueTimeUnit" jdbcType="TINYINT"/>
        <result column="pre_step_id" property="preStepId" jdbcType="BIGINT"/>
        <result column="next_step_id" property="nextStepId" jdbcType="BIGINT"/>
        <result column="gmt_create" property="gmtCreate" jdbcType="TIMESTAMP"/>
        <result column="gmt_modified" property="gmtModified" jdbcType="TIMESTAMP"/>
        <result column="create_uid" property="createUid" jdbcType="BIGINT"/>
        <result column="create_uname" property="createUname" jdbcType="VARCHAR"/>
        <result column="modified_uname" property="modifiedUname" jdbcType="VARCHAR"/>
        <result column="modified_uid" property="modifiedUid" jdbcType="BIGINT"/>
        <result column="audit_type" property="auditType" jdbcType="TINYINT"/>
 
 
 
    </resultMap>
    <sql id="all_Column_List" >
        <!--          -->
        step_id,rule_id,step_name,status,step_serial,enable_order,type,continue_time,continue_time_unit,pre_step_id,next_step_id,gmt_create,gmt_modified,create_uid,create_uname,modified_uname,modified_uid, audit_type
    </sql>
    <sql id="base_table_name">approval_rule_step</sql>
    <select id="listByConditions" resultMap="BaseResultMap"
            parameterType="com.gkhy.safePlatform.specialWork.model.query.db.ApprovalRuleStepListDbQuery">
        select <include refid="all_Column_List"></include> from <include refid="base_table_name"></include>
        <where>
            <if test="query.ruleId != null and query.ruleId > 0">
                and rule_id = #{query.ruleId}
            </if>
            <if test="query.status != null">
                and status = #{query.status}
            </if>
            <if test="query.type != null">
                and type = #{query.type}
            </if>
            <if test="query.stepName != null and query.stepName != ''">
                and step_name like concat('%',#{query.stepName},'%')
            </if>
        </where>
    </select>
 
    <select id="listByRuleId" resultMap="BaseResultMap">
        select step_id,rule_id,step_name,status,step_serial,enable_order,type,continue_time,continue_time_unit,pre_step_id,next_step_id,audit_type from <include refid="base_table_name"></include>
        where rule_id = #{ruleId} and status = #{status} order by step_serial asc
    </select>
 
 
    <!--批量删除层级-根据主键-->
    <update id="updateStatusByStepIds" >
        update <include refid="base_table_name"></include>
        set status = #{status}
        where
        step_id in
        <foreach collection="stepIds" item="stepId" open="(" close=")" separator=",">
            #{stepId}
        </foreach>
    </update>
    <!--删除层级-单挑-->
    <update id="updateStatusByStepId" >
        update <include refid="base_table_name"></include>
        set status = #{status}
        where
        step_id = #{stepId}
    </update>
 
    <!--批量删除层级-根据规则ids-->
    <update id="updateStatusByRuleIds" >
        update <include refid="base_table_name"></include>
        set status = #{status}
        where
        rule_id in
        <foreach collection="ruleIds" item="ruleId" open="(" close=")" separator=",">
            #{ruleId}
        </foreach>
    </update>
 
    <!--删除层级-根据规则id-->
    <update id="updateStatusByRuleId" >
        update <include refid="base_table_name"></include>
        set status = #{status}
        where
        rule_id = #{ruleId}
    </update>
 
    <select id="getStepById" resultMap="BaseResultMap">
        select <include refid="all_Column_List"></include> from <include refid="base_table_name"></include>
        where step_id = #{stepId} and status = #{status}
    </select>
 
    <!--批量删除层级-根据规则ids-->
    <update id="updateStatusByRuleIdAndNotInIds" >
        update <include refid="base_table_name"></include>
        set status = #{status}
        where
        rule_id = #{ruleId}
        and step_id not in
        <foreach collection="idList" item="id" open="(" close=")" separator=",">
            #{id}
        </foreach>
    </update>
    <!--根据规则获取层级id集合-->
    <select id="listStepIdByRuleId" resultType="java.lang.Long">
        select step_id from <include refid="base_table_name"></include>
        where rule_id = #{ruleId} and status = #{status}
    </select>
 
    <update id="updateStepAndEmptyPreStepId"
            parameterType="com.gkhy.safePlatform.specialWork.entity.ApprovalRuleUnit" >
        update
        approval_rule_step
        <trim  suffixOverrides=",">
        <if test="ruleId != null">
            set rule_id = #{ruleId},
        </if>
        <if test="stepName != null and stepName != '' ">
            step_name = #{stepName},
        </if>
        <if test="status != null">
            status = #{status},
        </if>
        <if test="stepSerial != null">
            step_serial = #{stepSerial},
        </if>
        <if test="enableOrder != null">
            enable_order = #{enableOrder},
        </if>
        <if test="type != null">
            type = #{type},
        </if>
        <if test="continueTime != null">
            continue_time = #{continueTime},
        </if>
        <if test="continueTime != null">
            continue_time_unit = #{continueTime},
        </if>
 
        pre_step_id = null,
 
        <if test="nextStepId != null">
            next_step_id = #{nextStepId},
        </if>
        <if test="modifiedUname != null">
            modified_uname = #{modifiedUname},
        </if>
        <if test="gmtModified != null">
            gmt_modified = #{gmtModified},
        </if>
        <if test="modifiedUid != null">
            modified_uid = #{modifiedUid},
        </if>
        </trim>
         where  step_id = #{stepId}
    </update>
 
    <update id="updateBatchStep"  parameterType="java.util.List">
        <foreach collection="list" item="step" index="index" open="" close="" separator=";">
            update approval_rule_step
            <set>
                <if test="step.ruleId != null">
                    rule_id = #{step.ruleId},
                </if>
                <if test="step.stepName != null and step.stepName != '' ">
                    step_name = #{step.stepName},
                </if>
                <if test="step.status != null">
                    status = #{step.status},
                </if>
                <if test="step.stepSerial != null">
                    step_serial = #{step.stepSerial},
                </if>
                <if test="step.enableOrder != null">
                    enable_order = #{step.enableOrder},
                </if>
                <if test="step.personType != null">
                    person_type = #{step.personType},
                </if>
                <if test="step.approvalType != null">
                    approval_type = #{step.approvalType},
                </if>
                <if test="step.contentType != null">
                    content_type = #{step.contentType},
                </if>
                <if test="step.continueTime != null">
                    continue_time = #{step.continueTime},
                </if>
                <if test="step.continueTimeUnit != null">
                    continue_time_unit = #{step.continueTimeUnit},
                </if>
                <if test="step.preStepId == null">
                    pre_step_id = null,
                </if>
                <if test="step.preStepId != null">
                    pre_step_id = #{step.preStepId},
                </if>
                <if test="step.nextStepId != null">
                    next_step_id = #{step.nextStepId},
                </if>
                <if test="step.modifiedUname != null">
                    modified_uname = #{step.modifiedUname},
                </if>
                <if test="step.gmtModified != null">
                    gmt_modified = #{step.gmtModified},
                </if>
                <if test="step.modifiedUid != null">
                    modified_uid = #{step.modifiedUid},
                </if>
                <if test="step.auditType != null">
                    audit_type = #{step.auditType},
                </if>
            </set>
            where  step_id = #{step.stepId}
        </foreach>
 
    </update>
 
    <insert id="saveStepList" >
        insert into
        approval_rule_step
        <trim prefix="(" suffix=") values" suffixOverrides=",">
            step_id,
            step_name,
            rule_id,
            status,
            step_serial,
            enable_order,
            person_type,
            approval_type,
            content_type,
            continue_time,
            continue_time_unit,
            pre_step_id,
            next_step_id,
            gmt_create,
            gmt_modified,
            create_uid,
            create_uname,
            modified_uid,
            modified_uname,
            audit_type
        </trim>
        <foreach collection="list" item="stand" separator=",">
          <trim prefix="(" suffix=")" suffixOverrides=",">
            #{stand.stepId},
            #{stand.stepName},
            #{stand.ruleId},
            #{stand.status},
            #{stand.stepSerial},
            #{stand.enableOrder},
            #{stand.personType},
            #{stand.approvalType},
            #{stand.contentType},
            #{stand.continueTime},
            #{stand.continueTimeUnit},
            #{stand.preStepId},
            #{stand.nextStepId},
            #{stand.gmtCreate},
            #{stand.gmtModified},
            #{stand.createUid},
            #{stand.createUname},
            #{stand.modifiedUid},
            #{stand.modifiedUname},
            #{stand.auditType}
          </trim>
         </foreach>
    </insert>
</mapper>