张晓波
2023-09-19 164694c47c35d6654df69b533e8dbf8b5423efc5
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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
<?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.thhy.secure.modules.biz.train.mapper.TSecureTrainMapper">
  <resultMap id="BaseResultMap" type="com.thhy.secure.modules.biz.train.entity.TSecureTrain">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri May 26 12:59:50 CST 2023.
    -->
    <id column="secure_id" jdbcType="VARCHAR" property="secureId" />
    <result column="secure_name" jdbcType="VARCHAR" property="secureName" />
    <result column="secure_type" jdbcType="VARCHAR" property="secureType" />
    <result column="secure_time" jdbcType="TIMESTAMP" property="secureTime" />
    <result column="company_id" jdbcType="VARCHAR" property="companyId" />
    <result column="is_use" jdbcType="INTEGER" property="isUse" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="create_user" jdbcType="VARCHAR" property="createUser" />
  </resultMap>
 
 
  <insert id="secureTrainInsert" >
    insert into t_secure_train
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="secureId != null">
        secure_id,
      </if>
      <if test="secureName != null">
        secure_name,
      </if>
      <if test="secureType != null">
        secure_type,
      </if>
      <if test="secureTime != null">
        secure_time,
      </if>
      <if test="companyId != null">
        company_id,
      </if>
      <if test="isUse != null">
        is_use,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="createUser != null">
        create_user,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="secureId != null">
        #{secureId,jdbcType=VARCHAR},
      </if>
      <if test="secureName != null">
        #{secureName,jdbcType=VARCHAR},
      </if>
      <if test="secureType != null">
        #{secureType,jdbcType=VARCHAR},
      </if>
      <if test="secureTime != null">
        #{secureTime,jdbcType=TIMESTAMP},
      </if>
      <if test="companyId != null">
        #{companyId,jdbcType=VARCHAR},
      </if>
      <if test="isUse != null">
        #{isUse,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createUser != null">
        #{createUser,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
 
  <insert id="secureTrainPathInsert">
    insert into t_secure_path
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="securePathId != null">
        secure_path_id,
      </if>
      <if test="secureId != null">
        secure_id,
      </if>
      <if test="securePathVideo != null">
        secure_path_video,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="securePathId != null">
        #{securePathId,jdbcType=VARCHAR},
      </if>
      <if test="secureId != null">
        #{secureId,jdbcType=VARCHAR},
      </if>
      <if test="securePathVideo != null">
        #{securePathVideo,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="secureTrainList" resultType="com.thhy.secure.modules.biz.train.entity.TSecureTrain">
        SELECT
        tst.secure_id as secureId,
        tst.secure_name as secureName,
        sd.dict_name as dictName,
        tst.secure_time as secureTime
    FROM
        t_secure_train tst
        LEFT JOIN sys_dict sd ON tst.secure_type = sd.dict_id
        where tst.is_use=1
        <if test="companyId!=null and companyId!='' ">
            and tst.company_id=#{companyId}
        </if>
        <if test="secureName!=null and secureName!='' ">
            and tst.secure_name like concat('%',#{secureName},'%')
        </if>
        <if test="strTime!=null and strTime!='' and  endTime!=null and endTime!='' ">
          and tst.secure_time between #{strTime} and #{endTime}
        </if>
        order by tst.create_time desc
  </select>
 
  <select id="totalsSum"  resultType="java.lang.String">
    SELECT
    count( ppu.user_id ) AS suma
FROM
    t_secure_group tsg
    LEFT JOIN sys_plat_position_user ppu ON tsg.group_id = ppu.position_id
    LEFT JOIN sys_position sp ON ppu.position_id = sp.pos_id
    where 1=1
    <if test="secureId!=null and secureId!='' ">
        and tsg.secure_id=#{secureId}
    </if>
    <if test="companyId!=null and companyId!='' ">
      and sp.company_id=#{companyId}
    </if>
GROUP BY
    tsg.secure_id
  </select>
  <select id="completesSum" parameterType="java.lang.String" resultType="java.lang.String">
   SELECT
    COUNT( tsr.user_id ) as completes
FROM
    t_secure_record tsr
    where  tsr.secure_id=#{secureId}
GROUP BY
    tsr.secure_id
  </select>
 
  <select id="secureTrainInfo" parameterType="java.lang.String" resultType="com.thhy.secure.modules.biz.train.entity.dto.SecureTrainDto">
    SELECT
    tst.secure_id as secureId,
    tst.secure_name as secureName,
    sd.dict_name as dictName,
    tst.secure_type as secureType,
    tst.secure_time as secureTime
    FROM
    t_secure_train tst
    LEFT JOIN sys_dict sd ON tst.secure_type = sd.dict_id
    where tst.is_use=1
    <if test="secureId!=null and secureId!='' ">
      and tst.secure_id=#{secureId}
    </if>
  </select>
 
  <select id="securePath" parameterType="java.lang.String" resultType="com.thhy.secure.modules.biz.train.entity.dto.SecurePathDto">
    select secure_path_video as securePathVideo from  t_secure_path
    where secure_id=#{secureId}
  </select>
  <select id="secureGroup" parameterType="java.lang.String" resultType="com.thhy.secure.modules.biz.train.entity.dto.SecureGroupDto">
        select tsg.group_id as groupId,
            sp.pos_name as groupName
         from  t_secure_group tsg
        left join  sys_position sp
         on tsg.group_id=sp.pos_id
         where tsg.secure_id=#{secureId}
  </select>
 
  <select id="secureTrainPull" resultType="com.thhy.secure.modules.biz.train.entity.dto.SecureTrainDto">
        select
         secure_id as secureId,
    secure_name as secureName
        from
        t_secure_train
        where is_use=1
        <if test="companyId!=null and companyId!='' ">
            and company_id=#{companyId}
        </if>
    <if test="secureType!=null and secureType!='' ">
      and secure_type=#{secureType}
    </if>
  </select>
  <update id="secureTrainDel" >
    update  t_secure_train set is_use=2
    where secure_id=#{secureId}
  </update>
 
  <select id="secureTrainRecord" parameterType="java.lang.String" resultType="com.thhy.secure.modules.biz.train.entity.dto.SecureGroupUserDto">
    SELECT
    tsr.user_id as userId,
    spu.real_name as realName,
    spu.phone as phone,
    sp.pos_name as posName,
    tsr.create_time as createTime,
    group_concat(sg.group_name) as groupName
    FROM
    t_secure_record tsr
    LEFT JOIN sys_users su ON tsr.user_id = su.user_id
    LEFT JOIN sys_plat_user spu ON su.plat_id = spu.user_id
    LEFT JOIN sys_plat_position_user pu ON su.plat_id = pu.user_id
    LEFT JOIN sys_position sp ON pu.position_id = sp.pos_id
    LEFT JOIN sys_group_user sgu ON spu.user_id = sgu.user_id
    LEFT JOIN sys_group sg ON sgu.group_id = sg.group_id
    where 1=1
    <if test="secureId!=null and secureId!='' ">
        and tsr.secure_id=#{secureId}
    </if>
    <if test="groupId!=null and groupId!='' ">
      and sg.group_id=#{groupId}
    </if>
    <if test="realName!=null and realName!='' ">
      and spu.real_name  like  concat('%',#{realName},'%')
    </if>
    GROUP BY
    tsr.user_id,
    sp.pos_id,tsr.create_time
  </select>
  <update id="secureTrainUpdate" >
    update t_secure_train
    <set>
      <if test="secureName != null">
        secure_name = #{secureName,jdbcType=VARCHAR},
      </if>
      <if test="secureType != null">
        secure_type = #{secureType,jdbcType=VARCHAR},
      </if>
      <if test="secureTime != null">
        secure_time = #{secureTime,jdbcType=TIMESTAMP},
      </if>
      <if test="companyId != null">
        company_id = #{companyId,jdbcType=VARCHAR},
      </if>
      <if test="isUse != null">
        is_use = #{isUse,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createUser != null">
        create_user = #{createUser,jdbcType=VARCHAR},
      </if>
    </set>
    where secure_id = #{secureId,jdbcType=VARCHAR}
  </update>
  <delete id="secureTrainGroupDel" parameterType="java.lang.String">
    delete  from  t_secure_group where secure_id=#{secureId}
  </delete>
  <delete id="secureTrainPathDel" parameterType="java.lang.String">
    delete from  t_secure_path where  secure_id=#{secureId}
  </delete>
  <insert id="secureTrainGroupInsert">
    insert into t_secure_group
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="secureGroupId != null">
        secure_group_id,
      </if>
      <if test="secureId != null">
        secure_id,
      </if>
      <if test="groupId != null">
        group_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="secureGroupId != null">
        #{secureGroupId,jdbcType=VARCHAR},
      </if>
      <if test="secureId != null">
        #{secureId,jdbcType=VARCHAR},
      </if>
      <if test="groupId != null">
        #{groupId,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="secureTrainUserInfo" parameterType="java.lang.String" resultType="com.thhy.secure.modules.biz.train.entity.OpenUserInfo">
        select
         spu.job_num as jobNum,
         spu.real_name as realName,
         spu.sex as sex,
         spu.photo,
         sp.pos_name as posName,
         sd.depart_name as departName,
         spu.user_id as userId,
         100 as an
         from sys_plat_user spu left join
        sys_plat_position_user sppu on spu.user_id=sppu.user_id
        left join sys_position sp on sp.pos_id=sppu.position_id
        left join sys_depart_user sdu on spu.user_id=sdu.user_id
        left join sys_depart sd on sdu.depart_id=sd.depart_id
        where 1=1
        <if test="openId!=null and openId!='' ">
          and spu.open_id=#{openId}
        </if>
        <if test="userId!=null and userId!='' ">
          and spu.user_id=#{userId}
        </if>
  </select>
  <select id="platId" parameterType="java.lang.String" resultType="java.lang.String">
    select plat_id from sys_users where user_id=#{userId}
  </select>
 
  <select id="secureTrainUser" resultType="com.thhy.secure.modules.biz.train.entity.dto.SecureTrainUserDto">
    SELECT
    tst.secure_id AS secureId,
    tst.secure_name AS secureName,
    tst.secure_type AS secureType,
    tst.secure_time AS secureTime,
    sd.dict_name AS dictName
    FROM
    t_secure_train tst
    LEFT JOIN t_secure_group tsg ON tst.secure_id = tsg.secure_id
    LEFT JOIN sys_position sp ON tsg.group_id = sp.pos_id
    LEFT JOIN sys_plat_position_user ppu ON sp.pos_id = ppu.position_id
    LEFT JOIN sys_dict sd ON tst.secure_type = sd.dict_id
    WHERE
    tst.is_use = 1
    <if test="companyId!=null and companyId!='' ">
      AND tst.company_id = #{companyId}
    </if>
    <if test="platId!=null and platId!='' ">
      AND ppu.user_id =#{platId}
  </if>
    GROUP BY tst.secure_id
  </select>
 
  <select id="secureRecord" parameterType="java.lang.String" resultType="java.lang.String">
    select secure_id from t_secure_record where user_id=#{userId}  group by secure_id
  </select>
  <insert id="secureTrainRecordInsert" >
    insert into t_secure_record
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="recordId != null">
        record_id,
      </if>
      <if test="secureId != null">
        secure_id,
      </if>
      <if test="userId != null">
        user_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="recordId != null">
        #{recordId,jdbcType=VARCHAR},
      </if>
      <if test="secureId != null">
        #{secureId,jdbcType=VARCHAR},
      </if>
      <if test="userId != null">
        #{userId,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
 
</mapper>