songhuangfeng123
2022-08-15 c9529bd19a8d61666b71824dd751682c1e9dc288
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
<?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.incidentManage.repository.AccidentReportInfoRepository">
 
    <resultMap type="com.gkhy.safePlatform.incidentManage.entity.AccidentReportInfoPageDO" id="AccidentReportInfoPageDOResult">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="accident_express_id" property="accidentExpressId"/>
        <result column="status" property="status"/>
        <result column="accident_type" property="accidentType"/>
        <result column="accident_grade" property="accidentGrade"/>
    </resultMap>
 
    <select id="selectAccidentReportList" resultMap="AccidentReportInfoPageDOResult">
        SELECT
        a.id,
        a.`accident_express_id`,
        a.`accident_type`,
        a.`accident_grade`,
        a.`status`,
        b.accident_name as accidentName,
        b.accident_department_id as accidentDepartmentId,
        b.occurrence_place as occurrencePlace,
        b.occurrence_time as occurrenceTime
        FROM
        accident_report a
        LEFT JOIN accident_express b ON a.accident_express_id = b.id
        WHERE
        a.del_flag = 0
        <if test="query.status != null  and query.status != ''">and a.`status` = #{query.status}</if>
    </select>
 
    <insert id="addAccidentReport" parameterType="com.gkhy.safePlatform.incidentManage.entity.AccidentReportInfo"
            keyProperty="id" useGeneratedKeys="true">
        insert into accident_report
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null ">id,</if>
            <if test="delFlag != null ">del_flag,</if>
            <if test="gmtCreate != null ">gmt_create,</if>
            <if test="gmtModitify != null ">gmt_moditify,</if>
            <if test="createUid != null ">create_uid,</if>
            <if test="updateUid != null ">update_uid,</if>
 
            <if test="status != null ">status,</if>
            <if test="accidentExpressId != null ">accident_express_id,</if>
            <if test="accidentType != null and accidentType != ''">accident_type,</if>
            <if test="accidentGrade != null and accidentGrade != ''">accident_grade,</if>
            <if test="economicLoss != null ">economic_loss,</if>
            <if test="minorInjuryNum != null ">minor_injury_num,</if>
            <if test="seriousInjuryNum != null ">serious_injury_num,</if>
            <if test="deathNum != null ">death_num,</if>
            <if test="accidentCause != null and accidentCause != ''">accident_cause,</if>
            <if test="reportDeadline != null ">report_deadline,</if>
            <if test="accidentLevel != null and accidentLevel != ''">accident_level,</if>
            <if test="accidentDelayApply != null and accidentDelayApply != ''">accident_delay_apply,</if>
            <if test="comprehensiveAnalysisDirect != null and comprehensiveAnalysisDirect != ''">comprehensive_analysis_direct,</if>
            <if test="comprehensiveAnalysisIndirect != null and comprehensiveAnalysisIndirect != ''">comprehensive_analysis_indirect,</if>
            <if test="rectificationMeasures != null and rectificationMeasures != ''">rectification_measures,</if>
            <if test="accidentHandling != null and accidentHandling != ''">accident_handling,</if>
            <if test="fillInUserUid != null ">fill_in_user_uid,</if>
            <if test="fillInTime != null ">fill_in_time,</if>
            <if test="fillInUserName != null and fillInUserName != ''">fill_in_user_name,</if>
            <if test="relevantPersonnelRecords != null and relevantPersonnelRecords != ''">relevant_personnel_records,</if>
            <if test="otherMaterials != null and otherMaterials != ''">other_materials,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null ">#{id},</if>
            <if test="delFlag != null ">#{delFlag},</if>
            <if test="gmtCreate != null ">#{gmtCreate},</if>
            <if test="gmtModitify != null ">#{gmtModitify},</if>
            <if test="createUid != null ">#{createUid},</if>
            <if test="updateUid != null ">#{updateUid},</if>
            <if test="status != null ">#{status},</if>
            <if test="accidentExpressId != null ">#{accidentExpressId},</if>
            <if test="accidentType != null and accidentType != ''">#{accidentType},</if>
            <if test="accidentGrade != null and accidentGrade != ''">#{accidentGrade},</if>
            <if test="economicLoss != null ">#{economicLoss},</if>
            <if test="minorInjuryNum != null ">#{minorInjuryNum},</if>
            <if test="seriousInjuryNum != null ">#{seriousInjuryNum},</if>
            <if test="deathNum != null ">#{deathNum},</if>
            <if test="accidentCause != null and accidentCause != ''">#{accidentCause},</if>
            <if test="reportDeadline != null ">#{reportDeadline},</if>
            <if test="accidentLevel != null and accidentLevel != ''">#{accidentLevel},</if>
            <if test="accidentDelayApply != null and accidentDelayApply != ''">#{accidentDelayApply},</if>
            <if test="comprehensiveAnalysisDirect != null and comprehensiveAnalysisDirect != ''">#{comprehensiveAnalysisDirect},</if>
            <if test="comprehensiveAnalysisIndirect != null and comprehensiveAnalysisIndirect != ''">#{comprehensiveAnalysisIndirect},</if>
            <if test="rectificationMeasures != null and rectificationMeasures != ''">#{rectificationMeasures},</if>
            <if test="accidentHandling != null and accidentHandling != ''">#{accidentHandling},</if>
            <if test="fillInUserUid != null ">#{fillInUserUid},</if>
            <if test="fillInTime != null ">#{fillInTime},</if>
            <if test="fillInUserName != null and fillInUserName != ''">#{fillInUserName},</if>
            <if test="relevantPersonnelRecords != null and relevantPersonnelRecords != ''">#{relevantPersonnelRecords},</if>
            <if test="otherMaterials != null and otherMaterials != ''">#{otherMaterials},</if>
        </trim>
    </insert>
 
 
    <resultMap type="com.gkhy.safePlatform.incidentManage.entity.AccidentReportInfoDetailDO" id="AccidentReportInfoDetailDOResult">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="status" property="status"/>
        <result column="accident_express_id" property="accidentExpressId"/>
        <result column="accident_type" property="accidentType"/>
        <result column="accident_grade" property="accidentGrade"/>
        <result column="economic_loss" property="economicLoss"/>
        <result column="minor_injury_num" property="minorInjuryNum"/>
        <result column="serious_injury_num" property="seriousInjuryNum"/>
        <result column="death_num" property="deathNum"/>
        <result column="accident_cause" property="accidentCause"/>
        <result column="report_deadline" property="reportDeadline"/>
        <result column="accident_level" property="accidentLevel"/>
        <result column="accident_delay_apply" property="accidentDelayApply"/>
        <result column="comprehensive_analysis_direct" property="comprehensiveAnalysisDirect"/>
        <result column="comprehensive_analysis_indirect" property="comprehensiveAnalysisIndirect"/>
        <result column="rectification_measures" property="rectificationMeasures"/>
        <result column="accident_handling" property="accidentHandling"/>
        <result column="fill_in_user_uid" property="fillInUserUid"/>
        <result column="fill_in_user_name" property="fillInUserName"/>
        <result column="fill_in_time" property="fillInTime"/>
        <result column="relevant_personnel_records" property="relevantPersonnelRecords"/>
        <result column="other_materials" property="otherMaterials"/>
    </resultMap>
 
    <select id="selectAccidentReportById" resultMap="AccidentReportInfoDetailDOResult">
    SELECT
        a.id,
        a.STATUS,
        a.`accident_express_id`,
        a.`accident_type`,
        a.`accident_grade`,
        a.`economic_loss`,
        a.minor_injury_num,
        a.serious_injury_num,
        a.`death_num`,
        a.`accident_cause`,
        a.`report_deadline`,
        a.`accident_level`,
        a.accident_delay_apply,
        a.comprehensive_analysis_direct,
        a.`comprehensive_analysis_indirect`,
        a.`rectification_measures`,
        a.`accident_handling`,
        a.`fill_in_user_uid`,
        a.fill_in_time,
        a.fill_in_user_name,
        a.`relevant_personnel_records`,
        a.`other_materials`,
        b.accident_name AS accidentName,
        b.accident_department_id AS accidentDepartmentId,
        b.occurrence_place AS occurrencePlace,
        b.occurrence_time AS occurrenceTime
    FROM
        accident_report a
        LEFT JOIN accident_express b ON a.accident_express_id = b.id
        WHERE a.del_flag = 0 and a.id = #{id}
    </select>
 
    <update id="updateAccidentReport" parameterType="com.gkhy.safePlatform.incidentManage.entity.AccidentReportInfo">
        update accident_report
        <trim prefix="SET" suffixOverrides=",">
            <if test="gmtModitify != null ">gmt_moditify = #{gmtModitify},</if>
            <if test="updateUid != null ">update_uid = #{updateUid},</if>
 
            <if test="status != null ">status = #{status},</if>
            <if test="accidentExpressId != null ">accident_express_id = #{accidentExpressId},</if>
            <if test="accidentType != null and accidentType != ''">accident_type = #{accidentType},</if>
            <if test="accidentGrade != null and accidentGrade != ''">accident_grade = #{accidentGrade},</if>
            <if test="economicLoss != null ">economic_loss = #{economicLoss},</if>
            <if test="minorInjuryNum != null ">minor_injury_num = #{minorInjuryNum},</if>
            <if test="seriousInjuryNum != null ">serious_injury_num = #{seriousInjuryNum},</if>
            <if test="deathNum != null ">death_num = #{deathNum},</if>
            <if test="accidentCause != null and accidentCause != ''">accident_cause = #{accidentCause},</if>
            <if test="reportDeadline != null ">report_deadline = #{reportDeadline},</if>
            <if test="accidentLevel != null and accidentLevel != ''">accident_level = #{accidentLevel},</if>
            <if test="accidentDelayApply != null and accidentDelayApply != ''">accident_delay_apply = #{accidentDelayApply},</if>
            <if test="comprehensiveAnalysisDirect != null and comprehensiveAnalysisDirect != ''">comprehensive_analysis_direct = #{comprehensiveAnalysisDirect},</if>
            <if test="comprehensiveAnalysisIndirect != null and comprehensiveAnalysisIndirect != ''">comprehensive_analysis_indirect = #{comprehensiveAnalysisIndirect},</if>
            <if test="rectificationMeasures != null and rectificationMeasures != ''">rectification_measures = #{rectificationMeasures},</if>
            <if test="accidentHandling != null and accidentHandling != ''">accident_handling = #{accidentHandling},</if>
            <if test="fillInUserUid != null ">fill_in_user_uid = #{fillInUserUid},</if>
            <if test="fillInTime != null ">fill_in_time = #{fillInTime},</if>
            <if test="fillInUserName != null and fillInUserName != ''">fill_in_user_name = #{fillInUserName},</if>
            <if test="relevantPersonnelRecords != null and relevantPersonnelRecords != ''">relevant_personnel_records = #{relevantPersonnelRecords},</if>
            <if test="otherMaterials != null and otherMaterials != ''">other_materials = #{otherMaterials},</if>
        </trim>
        where id = #{id}
    </update>
 
    <update id="deleteAccidentReportById">
        update accident_report set del_flag = 1 where id = #{id}
    </update>
 
 
    <resultMap type="com.gkhy.safePlatform.incidentManage.entity.AccidentReportCount"
               id="emergencyDrillExecuteCountChart">
        <result column="num" property="num"/>
        <result column="name" property="name"/>
        <result column="minorInjuryNum" property="minorInjuryNum"/>
        <result column="seriousInjuryNum" property="seriousInjuryNum"/>
        <result column="deathNum" property="deathNum"/>
        <result column="economicLoss" property="economicLoss"/>
    </resultMap>
    <select id="selectByTimeAndType" resultMap="emergencyDrillExecuteCountChart">
        SELECT
        a.accident_level AS `name`,
        count( 0 ) AS num,
        sum( economic_loss ) AS economicLoss,
        sum( minor_injury_num ) AS minorInjuryNum,
        sum( serious_injury_num ) AS seriousInjuryNum,
        sum( death_num ) AS deathNum
        FROM
        `accident_report` a
        WHERE
        del_flag = 0
        AND a.gmt_create <![CDATA[ >= ]]> #{query.startTime}
        AND a.gmt_create <![CDATA[ <= ]]> #{query.endTime}
        <if test="query.level != null and query.level != ''" >and b.drill_level = #{query.level}</if>
        GROUP BY
        accident_level
    </select>
</mapper>