wlzboy
2026-02-26 f5c900c58513bad824381e69750ac7667ef35de0
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
<?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.ruoyi.system.mapper.VehicleAbnormalAlertMapper">
    
    <resultMap type="VehicleAbnormalAlert" id="VehicleAbnormalAlertResult">
        <result property="alertId"    column="alert_id"    />
        <result property="vehicleId"    column="vehicle_id"    />
        <result property="vehicleNo"    column="vehicle_no"    />
        <result property="alertDate"    column="alert_date"    />
        <result property="alertTime"    column="alert_time"    />
        <result property="mileage"    column="mileage"    />
        <result property="alertType"    column="alert_type"    />
        <result property="alertReason"    column="alert_reason"    />
        <result property="startTime"    column="start_time"    />
        <result property="endTime"    column="end_time"    />
        <result property="alertCount"    column="alert_count"    />
        <result property="status"    column="status"    />
        <result property="handlerId"    column="handler_id"    />
        <result property="handlerName"    column="handler_name"    />
        <result property="handleTime"    column="handle_time"    />
        <result property="handleRemark"    column="handle_remark"    />
        <result property="notifyStatus"    column="notify_status"    />
        <result property="notifyTime"    column="notify_time"    />
        <result property="notifyUsers"    column="notify_users"    />
        <result property="deptId"    column="dept_id"    />
        <result property="deptName"    column="dept_name"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>
 
    <sql id="selectVehicleAbnormalAlertVo">
        select alert_id, vehicle_id, vehicle_no, alert_date, alert_time, mileage, alert_type, alert_reason, 
               start_time, end_time, alert_count, status, handler_id, handler_name, handle_time, handle_remark, 
               notify_status, notify_time, notify_users, dept_id, dept_name, create_time, update_time
        from tb_vehicle_abnormal_alert
    </sql>
 
    <select id="selectVehicleAbnormalAlertList" parameterType="VehicleAbnormalAlert" resultMap="VehicleAbnormalAlertResult">
        <include refid="selectVehicleAbnormalAlertVo"/>
        <where>  
            <if test="vehicleId != null "> and vehicle_id = #{vehicleId}</if>
            <if test="vehicleNo != null  and vehicleNo != ''"> and vehicle_no like concat('%', #{vehicleNo}, '%')</if>
            <if test="alertDate != null "> and date(alert_date) = date(#{alertDate})</if>
            <if test="params.beginAlertTime != null and params.beginAlertTime != ''"><!-- 开始时间检索 -->
                AND date_format(alert_time,'%y%m%d') &gt;= date_format(#{params.beginAlertTime},'%y%m%d')
            </if>
            <if test="params.endAlertTime != null and params.endAlertTime != ''"><!-- 结束时间检索 -->
                AND date_format(alert_time,'%y%m%d') &lt;= date_format(#{params.endAlertTime},'%y%m%d')
            </if>
            <if test="alertType != null  and alertType != ''"> and alert_type = #{alertType}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="deptName != null  and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
        </where>
        order by alert_time desc
    </select>
    
    <select id="selectVehicleAbnormalAlertByAlertId" parameterType="Long" resultMap="VehicleAbnormalAlertResult">
        <include refid="selectVehicleAbnormalAlertVo"/>
        where alert_id = #{alertId}
    </select>
        
    <insert id="insertVehicleAbnormalAlert" parameterType="VehicleAbnormalAlert" useGeneratedKeys="true" keyProperty="alertId">
        insert into tb_vehicle_abnormal_alert
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="vehicleId != null">vehicle_id,</if>
            <if test="vehicleNo != null and vehicleNo != ''">vehicle_no,</if>
            <if test="alertDate != null">alert_date,</if>
            <if test="alertTime != null">alert_time,</if>
            <if test="mileage != null">mileage,</if>
            <if test="alertType != null">alert_type,</if>
            <if test="alertReason != null">alert_reason,</if>
            <if test="startTime != null">start_time,</if>
            <if test="endTime != null">end_time,</if>
            <if test="alertCount != null">alert_count,</if>
            <if test="status != null">status,</if>
            <if test="handlerId != null">handler_id,</if>
            <if test="handlerName != null">handler_name,</if>
            <if test="handleTime != null">handle_time,</if>
            <if test="handleRemark != null">handle_remark,</if>
            <if test="notifyStatus != null">notify_status,</if>
            <if test="notifyTime != null">notify_time,</if>
            <if test="notifyUsers != null">notify_users,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="deptName != null">dept_name,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="vehicleId != null">#{vehicleId},</if>
            <if test="vehicleNo != null and vehicleNo != ''">#{vehicleNo},</if>
            <if test="alertDate != null">#{alertDate},</if>
            <if test="alertTime != null">#{alertTime},</if>
            <if test="mileage != null">#{mileage},</if>
            <if test="alertType != null">#{alertType},</if>
            <if test="alertReason != null">#{alertReason},</if>
            <if test="startTime != null">#{startTime},</if>
            <if test="endTime != null">#{endTime},</if>
            <if test="alertCount != null">#{alertCount},</if>
            <if test="status != null">#{status},</if>
            <if test="handlerId != null">#{handlerId},</if>
            <if test="handlerName != null">#{handlerName},</if>
            <if test="handleTime != null">#{handleTime},</if>
            <if test="handleRemark != null">#{handleRemark},</if>
            <if test="notifyStatus != null">#{notifyStatus},</if>
            <if test="notifyTime != null">#{notifyTime},</if>
            <if test="notifyUsers != null">#{notifyUsers},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="deptName != null">#{deptName},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>
 
    <update id="updateVehicleAbnormalAlert" parameterType="VehicleAbnormalAlert">
        update tb_vehicle_abnormal_alert
        <trim prefix="SET" suffixOverrides=",">
            <if test="vehicleId != null">vehicle_id = #{vehicleId},</if>
            <if test="vehicleNo != null and vehicleNo != ''">vehicle_no = #{vehicleNo},</if>
            <if test="alertDate != null">alert_date = #{alertDate},</if>
            <if test="alertTime != null">alert_time = #{alertTime},</if>
            <if test="mileage != null">mileage = #{mileage},</if>
            <if test="alertType != null">alert_type = #{alertType},</if>
            <if test="alertReason != null">alert_reason = #{alertReason},</if>
            <if test="startTime != null">start_time = #{startTime},</if>
            <if test="endTime != null">end_time = #{endTime},</if>
            <if test="alertCount != null">alert_count = #{alertCount},</if>
            <if test="status != null">status = #{status},</if>
            <if test="handlerId != null">handler_id = #{handlerId},</if>
            <if test="handlerName != null">handler_name = #{handlerName},</if>
            <if test="handleTime != null">handle_time = #{handleTime},</if>
            <if test="handleRemark != null">handle_remark = #{handleRemark},</if>
            <if test="notifyStatus != null">notify_status = #{notifyStatus},</if>
            <if test="notifyTime != null">notify_time = #{notifyTime},</if>
            <if test="notifyUsers != null">notify_users = #{notifyUsers},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="deptName != null">dept_name = #{deptName},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where alert_id = #{alertId}
    </update>
 
    <delete id="deleteVehicleAbnormalAlertByAlertId" parameterType="Long">
        delete from tb_vehicle_abnormal_alert where alert_id = #{alertId}
    </delete>
 
    <delete id="deleteVehicleAbnormalAlertByAlertIds" parameterType="String">
        delete from tb_vehicle_abnormal_alert where alert_id in 
        <foreach item="alertId" collection="array" open="(" separator="," close=")">
            #{alertId}
        </foreach>
    </delete>
    
    <select id="selectDailyAlertCount" resultType="int">
        select count(*) from tb_vehicle_abnormal_alert
        where vehicle_id = #{vehicleId} and date(alert_date) = date(#{alertDate})
    </select>
    
    <select id="selectLastAlertTime" resultType="java.util.Date">
        select max(alert_time) from tb_vehicle_abnormal_alert
        where vehicle_id = #{vehicleId}
    </select>
    
    <update id="batchHandleAlert">
        update tb_vehicle_abnormal_alert
        set status = '1',
            handler_id = #{handlerId},
            handler_name = #{handlerName},
            handle_time = now(),
            handle_remark = #{handleRemark}
        where alert_id in
        <foreach item="alertId" collection="alertIds" open="(" separator="," close=")">
            #{alertId}
        </foreach>
    </update>
</mapper>