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
<?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"      />
 
    </resultMap>
 
    <sql id="selectTransactionEventEntityVo">
        SELECT
            id,
            department_id,
            department_area,
            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,
            (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,
            department_area,
            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,
            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="matterAndUser != null and matterAndUser != ''">
                AND associate_names like concat('%', #{matterAndUser}, '%') or matter_name like concat('%', #{matterAndUser}, '%')
            </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="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 and associateIds != '' ">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 and associateNames != '' ">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>
        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 and associateIds != '' ">#{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 and associateNames != '' ">#{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>
        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 and associateIds != '' ">associate_ids=#{associateIds},</if>
            <if test="transactionNum != null ">transaction_num=#{transactionNum},</if>
            <if test="browseNum != null  ">browse_num=#{browseNum},</if>
            <if test="basicInformation != null and basicInformation != '' ">basic_information=#{basicInformation},</if>
            <if test="acceptConditions != null and acceptConditions != '' ">accept_conditions=#{acceptConditions},</if>
            <if test="applicationMaterial != null and applicationMaterial != '' ">application_material=#{applicationMaterial},</if>
            <if test="handlingProcedures != null and handlingProcedures != '' ">handling_procedures=#{handlingProcedures},</if>
            <if test="rates != null and rates != '' ">rates=#{rates},</if>
            <if test="associateNames != null and associateNames != '' ">associate_names=#{associateNames},</if>
            <if test="queryTime != null">query_time=#{queryTime},</if>
            <if test="basicInformationUrl != null and basicInformationUrl != '' ">basic_information_url=#{basicInformationUrl},</if>
            <if test="acceptConditionsUrl != null and acceptConditionsUrl != '' ">accept_conditions_url=#{acceptConditionsUrl},</if>
            <if test="applicationMaterialUrl != null and applicationMaterialUrl != '' ">application_material_url=#{applicationMaterialUrl},</if>
            <if test="handlingProceduresUrl != null and handlingProceduresUrl != '' ">handling_procedures_url=#{handlingProceduresUrl},</if>
            <if test="ratesUrl != null and ratesUrl != '' ">rates_url=#{ratesUrl},</if>
            <if test="basicInformationFileName != null and basicInformationFileName != '' ">basic_information_file_name=#{basicInformationFileName},</if>
            <if test="acceptConditionsFileName != null and acceptConditionsFileName != '' ">accept_conditions_file_name=#{acceptConditionsFileName},</if>
            <if test="applicationMaterialFileName != null and applicationMaterialFileName != '' ">application_material_file_name=#{applicationMaterialFileName},</if>
            <if test="handlingProceduresFileName != null and handlingProceduresFileName != '' ">handling_procedures_file_name=#{handlingProceduresFileName},</if>
            <if test="ratesFileName != null and ratesFileName != '' ">rates_file_name=#{ratesFileName},</if>
            <if test="operationalGuidelineUrl != null and operationalGuidelineUrl != '' ">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 and operationalGuidelineVideoUrl != '' ">operational_guideline_video_url=#{operationalGuidelineVideoUrl},</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="matterAndUser != null and matterAndUser != ''">
                AND associate_names like concat('%', #{matterAndUser}, '%') or matter_name like concat('%', #{matterAndUser}, '%')
            </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">
        <include refid="selectTransactionEventEntityVo"/>
        <where>
            <if test="matterName != null and matterName != ''">
                AND (matter_name like concat('%', #{matterName}, '%') or #{matterName} like concat('%', matter_name, '%'))
            </if>
 
        </where>
        order by create_time desc
    </select>
 
     <select id="sumTransactionNum"  resultMap="TransactionEventEntityResult">
        select sum(transaction_num)sumTransactionNum,count(*) counttransaction   FROM automessage_transaction_event
    </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=#{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  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,
                                                             transaction_num views,2 type from automessage_transaction_event
                                                 ) 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  id,title,content,views, type FROM(
                                                     select  id,organization_name title,resume content,null views,1 type  from   automessage_organization_chart  UNION
                                                     select  id,classify_name title,null content,null views,4 type from  automessage_classify_administration UNION
                                                     select  id,matter_name title,null content,transaction_num views,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,
                transaction_num views ,3 type from automessage_transaction_event where  associate_names like   concat('%',#{keyWord}, '%')
    </select>
 
 
    <!--  首页统计  勿动  -->
    <select id="countStatisticsNum" resultType="integer">
        select count(id) from automessage_transaction_event
        <where>
            <if test="classifyIds != null">
                and classify_id IN
                <foreach collection="classifyIds" item="param"  open="(" close=")" separator=",">
                    #{param}
                </foreach>
            </if>
        </where>
    </select>
 
 
 
 
</mapper>