mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
<?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.dg.core.db.gen.mapper.TransactionEventMapper">
 
    <resultMap type="com.dg.core.db.gen.entity.TransactionEvent" id="TransactionEventEntityResult">
        <id     property="id"      column="id"      />
        <id     property="departmentId"      column="department_id"      />
        <id     property="departmentArea"      column="department_area"      />
        <id     property="classifyId"      column="classify_id"      />
        <id     property="matterName"      column="matter_name"      />
        <id     property="associateIds"      column="associate_ids"      />
        <id     property="transactionNum"      column="transaction_num"      />
        <id     property="browseNum"      column="browse_num"      />
        <id     property="basicInformation"      column="basic_information"      />
        <id     property="acceptConditions"      column="accept_conditions"      />
        <id     property="applicationMaterial"      column="application_material"      />
        <id     property="handlingProcedures"      column="handling_procedures"      />
        <id     property="rates"      column="rates"      />
        <id     property="createTime"      column="create_time"      />
        <id     property="updateTime"      column="update_time"      />
        <id     property="queryTime"      column="query_time"      />
 
        <id     property="associateNames"      column="associate_names"      />
        <id     property="queryTime"      column="query_time"      />
        <id     property="basicInformationUrl"      column="basic_information_url"      />
        <id     property="acceptConditionsUrl"      column="accept_conditions_url"      />
        <id     property="applicationMaterialUrl"      column="application_material_url"      />
        <id     property="handlingProceduresUrl"      column="handling_procedures_url"      />
        <id     property="ratesUrl"      column="rates_url"      />
        <id     property="basicInformationFileName"      column="basic_information_file_name"      />
        <id     property="acceptConditionsFileName"      column="accept_conditions_file_name"      />
        <id     property="applicationMaterialFileName"      column="application_material_file_name"      />
        <id     property="handlingProceduresFileName"      column="handling_procedures_file_name"      />
        <id     property="ratesFileName"      column="rates_file_name"      />
        <id     property="operationalGuidelineUrl"      column="operational_guideline_url"      />
        <id     property="operationalGuidelineVideoUrl"      column="operational_guideline_video_url"      />
 
        <id     property="setGist"      column="set_gist"      />
        <id     property="setGistUrl"      column="set_gist_url"      />
        <id     property="setGistName"      column="set_gist_name"      />
 
        <id     property="commonProblem"      column="common_problem"      />
        <id     property="commonProblemUrl"      column="common_problem_url"      />
        <id     property="commonProblemName"      column="common_problem_name"      />
        <id     property="operationalGuidelineVideoName"      column="operational_guideline_video_name"      />
        <id     property="operationalGuidelineName"      column="operational_guideline_name"      />
        <id     property="transactionArea"      column="transaction_area"      />
        <id     property="transactionAreaUrl"      column="transaction_area_url"      />
        <id     property="transactionAreaName"      column="transaction_area_name"      />
        <id     property="classifyIds"      column="classify_ids"      />
        <id     property="departmentIds"      column="department_ids"      />
 
    </resultMap>
 
    <sql id="selectTransactionEventEntityVo">
        SELECT
            id,
            department_id,
            concat(
                IFNULL((SELECT name FROM automessage_area_code_2022 WHERE automessage_area_code_2022.code=(select city from automessage_organization_chart
                        where automessage_organization_chart.id=department_id)),''),
                IFNULL((SELECT name FROM automessage_area_code_2022 WHERE automessage_area_code_2022.code=(select district from automessage_organization_chart
                        where automessage_organization_chart.id=department_id)),''),
                IFNULL((SELECT name FROM automessage_area_code_2022 WHERE automessage_area_code_2022.code=(select village from automessage_organization_chart
                where automessage_organization_chart.id=department_id)),'')
            ) AS department_area,
            (select contact_number from automessage_organization_chart where automessage_organization_chart.id=department_id) as contactNumber,
            classify_id,
            matter_name,
            associate_ids,
            transaction_num,
            browse_num,
            basic_information,
            accept_conditions,
            application_material,
            handling_procedures,
            rates,
            create_time,
            update_time,
            query_time,
            associate_names,
            basic_information_url,
            accept_conditions_url,
            application_material_url,
            handling_procedures_url,
            rates_url,
            basic_information_file_name,
            accept_conditions_file_name,
            application_material_file_name,
            handling_procedures_file_name,
            rates_file_name,
            operational_guideline_url,
            set_gist,
            set_gist_url,
            set_gist_name,
            common_problem,
            common_problem_url,
            common_problem_name,
            operational_guideline_video_url,
            operational_guideline_video_name,
            operational_guideline_name,
            transaction_area,
            transaction_area_url,
            transaction_area_name,
            classify_ids,
            department_ids,
            (SELECT GROUP_CONCAT(organization_name) FROM automessage_organization_chart WHERE id in (SELECT
                 substring_index(substring_index(department_ids,',', b.help_topic_id + 1), ',', -1) result
             FROM
                 mysql.help_topic b
             where
                     b.help_topic_id &lt; (LENGTH(department_ids) - LENGTH(REPLACE(department_ids, ',', '')) + 1))) as departmentNames,
            (IF((select classify_grade from automessage_classify_administration where automessage_classify_administration.id=automessage_transaction_event.classify_id)='2',
                (select classify_name from automessage_classify_administration where automessage_classify_administration.id=(select parent_id from
                automessage_classify_administration where automessage_classify_administration.id=automessage_transaction_event.classify_id)),
                (select classify_name from automessage_classify_administration where automessage_classify_administration.id=automessage_transaction_event.classify_id))) as classifyName,
            (select organization_name from automessage_organization_chart where automessage_organization_chart.id=automessage_transaction_event.department_id) as departmentName,
            concat(
            (select classify_name from  automessage_classify_administration  where id=(select parent_id from  automessage_classify_administration  where id=automessage_transaction_event.classify_id)),
            '>',(select classify_name from  automessage_classify_administration  where id=automessage_transaction_event.classify_id)
            ) sumClassifyName
        FROM
            automessage_transaction_event
    </sql>
 
    <sql id="selectTransactionEventList">
        SELECT
            id,
            department_id,
            concat(
                    IFNULL((SELECT name FROM automessage_area_code_2022 WHERE automessage_area_code_2022.code=(select city from automessage_organization_chart
                                                                                       where automessage_organization_chart.id=department_id)),''),
                    IFNULL((SELECT name FROM automessage_area_code_2022 WHERE automessage_area_code_2022.code=(select district from automessage_organization_chart
                                                                                       where automessage_organization_chart.id=department_id)),''),
                    IFNULL((SELECT name FROM automessage_area_code_2022 WHERE automessage_area_code_2022.code=(select village from automessage_organization_chart
                                                                                       where automessage_organization_chart.id=department_id)),'')
                ) AS department_area,
            classify_id,
            (IF((select classify_grade from automessage_classify_administration where automessage_classify_administration.id=automessage_transaction_event.classify_id)='2',
                (select classify_name from automessage_classify_administration where automessage_classify_administration.id=(select parent_id from
                    automessage_classify_administration where automessage_classify_administration.id=automessage_transaction_event.classify_id)),
                (select classify_name from automessage_classify_administration where automessage_classify_administration.id=automessage_transaction_event.classify_id))) as classifyName,
            (select organization_name from automessage_organization_chart where automessage_organization_chart.id=automessage_transaction_event.department_id) as departmentName,
            matter_name,
            associate_ids,
            associate_names,
            transaction_num,
            browse_num,
            department_ids,
            (SELECT GROUP_CONCAT(organization_name) FROM automessage_organization_chart WHERE id in (SELECT
              substring_index(substring_index(department_ids,',', b.help_topic_id + 1), ',', -1) result
          FROM
              mysql.help_topic b
          where
                  b.help_topic_id &lt; (LENGTH(department_ids) - LENGTH(REPLACE(department_ids, ',', '')) + 1))) as departmentNames,
            create_time,
            update_time
        FROM
            automessage_transaction_event
    </sql>
 
    <select id="selectConfigData" parameterType="string"  resultMap="TransactionEventEntityResult">
        <include refid="selectTransactionEventEntityVo"/>
        where id=#{Id}
    </select>
 
    <select id="selectConfigList"  resultMap="TransactionEventEntityResult">
        <include refid="selectTransactionEventList"/>
        <where>
            <if test="keyword != null and keyword != ''">
                AND (
                    (matter_name like concat('%', #{keyword}, '%')) or
                    (department_id in (SELECT id FROM automessage_organization_chart WHERE organization_name like concat('%', #{keyword}, '%')))
                    or (classify_id in (SELECT id FROM automessage_classify_administration WHERE classify_name like concat('%', #{keyword}, '%')))
                    )
 
            </if>
            <if test="classifyGrade != null and classifyGrade != ''">
                AND (select classify_grade from automessage_classify_administration where automessage_classify_administration.id=classify_id) = #{classifyGrade}
            </if>
            <if test="ids != null">
                and department_id IN
                <foreach collection="ids" item="param"  open="(" close=")" separator=",">
                    #{param}
                </foreach>
            </if>
        </where>
        order by create_time desc
    </select>
 
    <!-- 根据分类筛选数据 -->
    <select id="selectClassifyList"  resultMap="TransactionEventEntityResult">
        <include refid="selectTransactionEventList"/>
        <where>
            <if test="ids != null">
                and classify_id IN
                <foreach collection="ids" item="param"  open="(" close=")" separator=",">
                    #{param}
                </foreach>
            </if>
        </where>
        order by create_time desc
    </select>
 
 
 
    <select id="selectListByIds"  resultMap="TransactionEventEntityResult">
        <include refid="selectTransactionEventList"/>
        WHERE id IN
        <foreach collection="array" item="id" index="index" open="(" close=")" separator=",">
            #{id}
        </foreach>
        order by create_time desc
    </select>
 
    <insert id="insertConfig" parameterType="com.dg.core.db.gen.entity.TransactionEvent">
        insert into automessage_transaction_event (
        <if test="id != null">id,</if>
        <if test="departmentId != null and departmentId != '' ">department_id,</if>
        <if test="departmentArea != null">department_area,</if>
        <if test="classifyId != null and classifyId != '' ">classify_id,</if>
        <if test="matterName != null and matterName != '' ">matter_name,</if>
        <if test="associateIds != null ">associate_ids,</if>
        <if test="transactionNum != null ">transaction_num,</if>
        <if test="browseNum != null  ">browse_num,</if>
        <if test="basicInformation != null and basicInformation != '' ">basic_information,</if>
        <if test="acceptConditions != null and acceptConditions != '' ">accept_conditions,</if>
        <if test="applicationMaterial != null and applicationMaterial != '' ">application_material,</if>
        <if test="handlingProcedures != null and handlingProcedures != '' ">handling_procedures,</if>
        <if test="rates != null and rates != '' ">rates,</if>
        <if test="associateNames != null  ">associate_names,</if>
        <if test="queryTime != null">query_time,</if>
        <if test="basicInformationUrl != null and basicInformationUrl != '' ">basic_information_url,</if>
        <if test="acceptConditionsUrl != null and acceptConditionsUrl != '' ">accept_conditions_url,</if>
        <if test="applicationMaterialUrl != null and applicationMaterialUrl != '' ">application_material_url,</if>
        <if test="handlingProceduresUrl != null and handlingProceduresUrl != '' ">handling_procedures_url,</if>
        <if test="ratesUrl != null and ratesUrl != '' ">rates_url,</if>
        <if test="basicInformationFileName != null and basicInformationFileName != '' ">basic_information_file_name,</if>
        <if test="acceptConditionsFileName != null and acceptConditionsFileName != '' ">accept_conditions_file_name,</if>
        <if test="applicationMaterialFileName != null and applicationMaterialFileName != '' ">application_material_file_name,</if>
        <if test="handlingProceduresFileName != null and handlingProceduresFileName != '' ">handling_procedures_file_name,</if>
        <if test="ratesFileName != null and ratesFileName != '' ">rates_file_name,</if>
        <if test="operationalGuidelineUrl != null and operationalGuidelineUrl != '' ">operational_guideline_url,</if>
        <if test="operationalGuidelineVideoUrl != null and operationalGuidelineVideoUrl != '' ">operational_guideline_video_url,</if>
        <if test="setGist != null and setGist != '' ">set_gist,</if>
        <if test="setGistUrl != null and setGistUrl != '' ">set_gist_url,</if>
        <if test="setGistName != null and setGistName != '' ">set_gist_name,</if>
        <if test="commonProblem != null and commonProblem != '' ">common_problem,</if>
        <if test="commonProblemUrl != null and commonProblemUrl != '' ">common_problem_url,</if>
        <if test="commonProblemName != null and commonProblemName != '' ">common_problem_name,</if>
        <if test="operationalGuidelineVideoName != null and operationalGuidelineVideoName != '' ">operational_guideline_video_name,</if>
        <if test="operationalGuidelineName != null and operationalGuidelineName != '' ">operational_guideline_name,</if>
        <if test="transactionArea != null ">transaction_area,</if>
        <if test="transactionAreaUrl != null ">transaction_area_url,</if>
        <if test="transactionAreaName != null ">transaction_area_name,</if>
        <if test="classifyIds != null ">classify_ids,</if>
        <if test="departmentIds != null ">department_ids,</if>
        update_time,
        create_time
        )values(
        <if test="id != null">#{id},</if>
        <if test="departmentId != null and departmentId != '' ">#{departmentId},</if>
        <if test="departmentArea != null">#{departmentArea},</if>
        <if test="classifyId != null and classifyId != '' ">#{classifyId},</if>
        <if test="matterName != null and matterName != '' ">#{matterName},</if>
        <if test="associateIds != null ">#{associateIds},</if>
        <if test="transactionNum != null ">#{transactionNum},</if>
        <if test="browseNum != null  ">#{browseNum},</if>
        <if test="basicInformation != null and basicInformation != '' ">#{basicInformation},</if>
        <if test="acceptConditions != null and acceptConditions != '' ">#{acceptConditions},</if>
        <if test="applicationMaterial != null and applicationMaterial != '' ">#{applicationMaterial},</if>
        <if test="handlingProcedures != null and handlingProcedures != '' ">#{handlingProcedures},</if>
        <if test="rates != null and rates != '' ">#{rates},</if>
        <if test="associateNames != null  ">#{associateNames},</if>
        <if test="queryTime != null">#{queryTime},</if>
        <if test="basicInformationUrl != null and basicInformationUrl != '' ">#{basicInformationUrl},</if>
        <if test="acceptConditionsUrl != null and acceptConditionsUrl != '' ">#{acceptConditionsUrl},</if>
        <if test="applicationMaterialUrl != null and applicationMaterialUrl != '' ">#{applicationMaterialUrl},</if>
        <if test="handlingProceduresUrl != null and handlingProceduresUrl != '' ">#{handlingProceduresUrl},</if>
        <if test="ratesUrl != null and ratesUrl != '' ">#{ratesUrl},</if>
        <if test="basicInformationFileName != null and basicInformationFileName != '' ">#{basicInformationFileName},</if>
        <if test="acceptConditionsFileName != null and acceptConditionsFileName != '' ">#{acceptConditionsFileName},</if>
        <if test="applicationMaterialFileName != null and applicationMaterialFileName != '' ">#{applicationMaterialFileName},</if>
        <if test="handlingProceduresFileName != null and handlingProceduresFileName != '' ">#{handlingProceduresFileName},</if>
        <if test="ratesFileName != null and ratesFileName != '' ">#{ratesFileName},</if>
        <if test="operationalGuidelineUrl != null and operationalGuidelineUrl != '' ">#{operationalGuidelineUrl},</if>
        <if test="operationalGuidelineVideoUrl != null and operationalGuidelineVideoUrl != '' ">#{operationalGuidelineVideoUrl},</if>
        <if test="setGist != null and setGist != '' ">#{setGist},</if>
        <if test="setGistUrl != null and setGistUrl != '' ">#{setGistUrl},</if>
        <if test="setGistName != null and setGistName != '' ">#{setGistName},</if>
        <if test="commonProblem != null and commonProblem != '' ">#{commonProblem},</if>
        <if test="commonProblemUrl != null and commonProblemUrl != '' ">#{commonProblemUrl},</if>
        <if test="commonProblemName != null and commonProblemName != '' ">#{commonProblemName},</if>
        <if test="operationalGuidelineVideoName != null and operationalGuidelineVideoName != '' ">#{operationalGuidelineVideoName},</if>
        <if test="operationalGuidelineName != null and operationalGuidelineName != '' ">#{operationalGuidelineName},</if>
        <if test="transactionArea != null ">#{transactionArea},</if>
        <if test="transactionAreaUrl != null ">#{transactionAreaUrl},</if>
        <if test="transactionAreaName != null ">#{transactionAreaName},</if>
        <if test="classifyIds != null ">#{classifyIds},</if>
        <if test="departmentIds != null ">#{departmentIds},</if>
        sysdate(),
        sysdate()
        )
    </insert>
 
    <update id="updateConfig" parameterType="com.dg.core.db.gen.entity.TransactionEvent">
        update automessage_transaction_event
        <set>
            <if test="id != null">id=#{id},</if>
            <if test="departmentId != null and departmentId != '' ">department_id=#{departmentId},</if>
            <if test="departmentArea != null">department_area=#{departmentArea},</if>
            <if test="classifyId != null and classifyId != '' ">classify_id=#{classifyId},</if>
            <if test="matterName != null and matterName != '' ">matter_name=#{matterName},</if>
            <if test="associateIds != null  ">associate_ids=#{associateIds},</if>
            <if test="transactionNum != null ">transaction_num=#{transactionNum},</if>
            <if test="browseNum != null  ">browse_num=#{browseNum},</if>
            <if test="basicInformation != null">basic_information=#{basicInformation},</if>
            <if test="acceptConditions != null ">accept_conditions=#{acceptConditions},</if>
            <if test="applicationMaterial != null ">application_material=#{applicationMaterial},</if>
            <if test="handlingProcedures != null ">handling_procedures=#{handlingProcedures},</if>
            <if test="rates != null ">rates=#{rates},</if>
            <if test="associateNames != null ">associate_names=#{associateNames},</if>
            <if test="queryTime != null">query_time=#{queryTime},</if>
            <if test="basicInformationUrl != null">basic_information_url=#{basicInformationUrl},</if>
            <if test="acceptConditionsUrl != null  ">accept_conditions_url=#{acceptConditionsUrl},</if>
            <if test="applicationMaterialUrl != null  ">application_material_url=#{applicationMaterialUrl},</if>
            <if test="handlingProceduresUrl != null  ">handling_procedures_url=#{handlingProceduresUrl},</if>
            <if test="ratesUrl != null  ">rates_url=#{ratesUrl},</if>
            <if test="basicInformationFileName != null  ">basic_information_file_name=#{basicInformationFileName},</if>
            <if test="acceptConditionsFileName != null  ">accept_conditions_file_name=#{acceptConditionsFileName},</if>
            <if test="applicationMaterialFileName != null  ">application_material_file_name=#{applicationMaterialFileName},</if>
            <if test="handlingProceduresFileName != null ">handling_procedures_file_name=#{handlingProceduresFileName},</if>
            <if test="ratesFileName != null ">rates_file_name=#{ratesFileName},</if>
            <if test="operationalGuidelineUrl != null">operational_guideline_url=#{operationalGuidelineUrl},</if>
            <if test="setGist != null and setGist != '' ">set_gist=#{setGist},</if>
            <if test="setGistUrl != null and setGistUrl != '' ">set_gist_url=#{setGistUrl},</if>
            <if test="setGistName != null and setGistName != '' ">set_gist_name=#{setGistName},</if>
            <if test="commonProblem != null and commonProblem != '' ">common_problem=#{commonProblem},</if>
            <if test="commonProblemUrl != null and commonProblemUrl != '' ">common_problem_url=#{commonProblemUrl},</if>
            <if test="commonProblemName != null and commonProblemName != '' ">common_problem_name=#{commonProblemName},</if>
            <if test="operationalGuidelineVideoUrl != null ">operational_guideline_video_url=#{operationalGuidelineVideoUrl},</if>
            <if test="operationalGuidelineVideoName != null and operationalGuidelineVideoName != '' ">operational_guideline_video_name=#{operationalGuidelineVideoName},</if>
            <if test="operationalGuidelineName != null and operationalGuidelineName != '' ">operational_guideline_name=#{operationalGuidelineName},</if>
            <if test="transactionArea != null ">transaction_area=#{transactionArea},</if>
            <if test="transactionAreaUrl != null ">transaction_area_url=#{transactionAreaUrl},</if>
            <if test="transactionAreaName != null ">transaction_area_name=#{transactionAreaName},</if>
            <if test="classifyIds != null ">classify_ids=#{classifyIds},</if>
            <if test="departmentIds != null ">department_ids=#{departmentIds},</if>
            update_time=sysdate()
        </set>
        where  id= #{id}
    </update>
 
    <delete id="deleteConfigById" parameterType="string">
        delete from automessage_transaction_event where id= #{Id}
    </delete>
 
    <select id="countNum" resultType="integer">
        select count(id) from automessage_transaction_event
        <where>
            <if test="keyword != null and keyword != ''">
                AND (matter_name like concat('%', #{keyword}, '%')) or
                (department_id in (SELECT id FROM automessage_organization_chart WHERE organization_name like concat('%', #{keyword}, '%')))
                or (classify_id in (SELECT id FROM automessage_classify_administration WHERE classify_name like concat('%', #{keyword}, '%')))
                or (associate_names like concat('%', #{keyword}, '%'))
            </if>
            <if test="classifyGrade != null and classifyGrade != ''">
                AND (select classify_grade from classify_administration where classify_grade.id=classify_id) = #{classifyGrade}
            </if>
            <if test="ids != null">
                and department_id IN
                <foreach collection="ids" item="param"  open="(" close=")" separator=",">
                    #{param}
                </foreach>
            </if>
        </where>
    </select>
 
 
    <select id="queryMatterNameList"  resultMap="TransactionEventEntityResult">
       select id,matter_name from  automessage_transaction_event
        <where>
            <if test="matterName != null and matterName != ''">
                AND (matter_name like concat('%', #{matterName}, '%') )
            </if>
            <if test="classifyId != null and classifyId != ''">
               and (classify_id= #{classifyId} or classify_id in (select id FROM automessage_classify_administration where parent_id =#{classifyId} ))
            </if>
 
        </where>
        order by create_time desc
    </select>
 
    <select id="queryAssociateNamesList"  resultMap="TransactionEventEntityResult">
        select id,matter_name from  automessage_transaction_event
        <where>
            <if test="associateNames != null and associateNames != ''">
                AND (associate_names like concat('%', #{associateNames}, '%') )
            </if>
            <if test="classifyId != null and classifyId != ''">
                and (classify_id= #{classifyId} or classify_id in (select id FROM automessage_classify_administration where parent_id =#{classifyId} ))
            </if>
 
        </where>
        order by create_time desc
    </select>
 
    <select id="sumTransactionNum"  resultMap="TransactionEventEntityResult">
        select sum(TransactionNum)sumTransactionNum,  count(*) counttransaction from (
        SELECT (select count(id) from automessage_guide_repair_order where state in (3,4) and  a.id=matter_id) TransactionNum
        from automessage_transaction_event a)k
    </select>
 
    <select id="queryByClassifyIdList"  resultMap="TransactionEventEntityResult">
        <include refid="selectTransactionEventEntityVo"/>
        where  (classify_id= #{classifyId} or classify_id in (select id FROM automessage_classify_administration where parent_id =#{classifyId} ))
        <if test="departmentId!=null">
            and  department_id in (select id from automessage_organization_chart where id=#{departmentId}  or parent_id=#{departmentId})
        </if>
        order by create_time desc
    </select>
 
    <select id="countNumByClassifyIdList" resultType="integer">
        select count(id) from automessage_transaction_event
        where  (classify_id= #{classifyId} or classify_id in (select id FROM automessage_classify_administration where parent_id =#{classifyId} ))
        <if test="departmentId!=null">
          and   department_id=#{departmentId}
        </if>
        order by create_time desc
    </select>
 
 
    <update id="updateConfigByMatterName" parameterType="com.dg.core.db.gen.entity.TransactionEvent">
        update automessage_transaction_event
        <set>
            browse_num=browse_num+1,query_time=sysdate()
        </set>
        <where>
            matter_name like concat('%', #{matterName}, '%')
        </where>
 
    </update>
 
    <select id="countNumByMatterName" resultType="integer">
        select count(id) from automessage_transaction_event
        <where>
            <if test="matterName != null and matterName != ''">
                AND matter_name like concat('%', #{matterName}, '%')
            </if>
 
        </where>
    </select>
 
    <select id="selectSearch" resultType="com.dg.core.db.manual.pojo.Search">
        select  id,title,content,views, type FROM(
                 select  id,organization_name title,resume content,null views,1 type  from   automessage_organization_chart where grade=1  UNION
                 select  id,matter_name title,concat((select classify_name from  automessage_classify_administration
                                                      where id=(select parent_id from  automessage_classify_administration  where id=automessage_transaction_event.classify_id)),
                                                     '>',(select classify_name from  automessage_classify_administration  where id=automessage_transaction_event.classify_id)) content,
                         browse_num views,2 type from automessage_transaction_event UNION
                 SELECT id ,name title,concat((select organization_name from automessage_organization_chart where id=automessage_policy_documents.department_id ),'>','政策文件') content,null        views,5 type FROM     automessage_policy_documents where type=2      UNION
                 SELECT id ,name title,concat((select organization_name from automessage_organization_chart where id=automessage_policy_documents.department_id ),'>','法律法规') content,null        views,6 type FROM     automessage_policy_documents where type=1
             ) k
        where  k.title like concat('%',#{keyWord}, '%') or k.content  like concat('%', #{keyWord}, '%')
    </select>
 
    <select id="selectSearchList" resultType="com.dg.core.db.manual.pojo.Search">
        select   distinct classify_id,  content,type,parentClassifyId  from   ( select  id,matter_name title,concat((select classify_name from  automessage_classify_administration
                                                                                                    where id=(select parent_id from  automessage_classify_administration  where id=automessage_transaction_event.classify_id)),
                                                                                                   '/',(select classify_name from  automessage_classify_administration  where id=automessage_transaction_event.classify_id)) content,
                                                                   classify_id,(select parent_id from automessage_classify_administration  where id=automessage_transaction_event.classify_id) parentClassifyId,
                                                                       2 type from automessage_transaction_event) k
        where  k.title like concat('%',#{keyWord}, '%') or k.content like concat('%',#{keyWord}, '%')
    </select>
 
    <select id="selectSearchAssociate" resultType="com.dg.core.db.manual.pojo.Search">
       select  id,matter_name title,concat((select classify_name from  automessage_classify_administration
                                  where id=(select parent_id from  automessage_classify_administration  where id=automessage_transaction_event.classify_id)),
                                 '>',(select classify_name from  automessage_classify_administration  where id=automessage_transaction_event.classify_id)) content,
               browse_num views ,3 type from automessage_transaction_event where  associate_names like   concat('%',#{keyWord}, '%')
    </select>
 
    <select id="selectSearchAssociateDistinct" resultType="com.dg.core.db.manual.pojo.Search" >
             select  distinct   classify_id,
                    (select ifnull(concat((select classify_name from automessage_classify_administration where c.parent_id=id),'/',classify_name),classify_name)  content  from automessage_classify_administration c where c.id=t.classify_id) content,
                    3 type from automessage_transaction_event t where  associate_names like  concat('%',#{keyWord}, '%')
    </select>
 
    <select id="selectDataIfExist" resultType="string">
        select id from automessage_transaction_event
        where department_id=#{departmentId}
        and matter_name=#{matterName}
    </select>
 
    <select id="selectclassifyId" resultType="string">
        select id from automessage_transaction_event
        where classify_id=#{classifyId}
    </select>
 
 
 
</mapper>