张晓波
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
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
<?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.screen.modules.biz.agv.mapper.AgvStateHistoryMapper">
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        t.id as id,
        t.accurate_stop as accurateStop,
        t.agv_back_laser_swtich as agvBackLaserSwtich,
        t.agv_base_angular_vel as agvBaseAngularVel,
        t.agv_base_linear_vel as agvBaseLinearVel,
        t.agv_collision as agvCollision,
        t.agv_control_style as agvControlStyle,
        t.agv_current_landmark_rFID as agvCurrentLandmarkRFID,
        t.agv_dest_rFID as agvDestRFID,
        t.agv_emergency_button as agvEmergencyButton,
        t.agv_front_laser_switch as agvFrontLaserSwitch,
        t.agv_id as agvId,
        t.agv_jacking_state as agvJackingState,
        t.agv_liftup_heavy_state as agvLiftupHeavyState,
        t.agv_model_rFID as agvModelRFID,
        t.agv_move_style as agvMoveStyle,
        t.agv_task_state as agvTaskState,
        t.agv_vel_direction as agvVelDirection,
        t.agv_vel_level as agvVelLevel,
        t.agv_working_state as agvWorkingState,
        t.battery1_charge as battery1Charge,
        t.battery1_current as battery1Current,
        t.battery1_error_code as battery1ErrorCode,
        t.battery1_voltage as battery1Voltage,
        t.error_code as errorCode,
        t.error_content as errorContent,
    </sql>
 
    <sql id="condition_query">
        <where>
            <trim suffixOverrides=" AND ">
                <if test="accurateStop!=null">
                    t.accurate_stop = #{accurateStop} AND
                </if>
                <if test="agvBackLaserSwtich!=null">
                    t.agv_back_laser_swtich = #{agvBackLaserSwtich} AND
                </if>
                <if test="agvBaseAngularVel!=null">
                    t.agv_base_angular_vel = #{agvBaseAngularVel} AND
                </if>
                <if test="agvBaseLinearVel!=null">
                    t.agv_base_linear_vel = #{agvBaseLinearVel} AND
                </if>
                <if test="agvCollision!=null">
                    t.agv_collision = #{agvCollision} AND
                </if>
                <if test="agvControlStyle!=null and agvControlStyle!=''">
                    t.agv_control_style = #{agvControlStyle} AND
                </if>
                <if test="agvCurrentLandmarkRFID!=null">
                    t.agv_current_landmark_rFID = #{agvCurrentLandmarkRFID} AND
                </if>
                <if test="agvDestRFID!=null">
                    t.agv_dest_rFID = #{agvDestRFID} AND
                </if>
                <if test="agvEmergencyButton!=null">
                    t.agv_emergency_button = #{agvEmergencyButton} AND
                </if>
                <if test="agvFrontLaserSwitch!=null">
                    t.agv_front_laser_switch = #{agvFrontLaserSwitch} AND
                </if>
                <if test="agvId!=null and agvId!=''">
                    t.agv_id = #{agvId} AND
                </if>
                <if test="agvJackingState!=null and agvJackingState!=''">
                    t.agv_jacking_state = #{agvJackingState} AND
                </if>
                <if test="agvLiftupHeavyState!=null and agvLiftupHeavyState!=''">
                    t.agv_liftup_heavy_state = #{agvLiftupHeavyState} AND
                </if>
                <if test="agvModelRFID!=null">
                    t.agv_model_rFID = #{agvModelRFID} AND
                </if>
                <if test="agvMoveStyle!=null and agvMoveStyle!=''">
                    t.agv_move_style = #{agvMoveStyle} AND
                </if>
                <if test="agvTaskState!=null and agvTaskState!=''">
                    t.agv_task_state = #{agvTaskState} AND
                </if>
                <if test="agvVelDirection!=null and agvVelDirection!=''">
                    t.agv_vel_direction = #{agvVelDirection} AND
                </if>
                <if test="agvVelLevel!=null and agvVelLevel!=''">
                    t.agv_vel_level = #{agvVelLevel} AND
                </if>
                <if test="agvWorkingState!=null and agvWorkingState!=''">
                    t.agv_working_state = #{agvWorkingState} AND
                </if>
                <if test="battery1Charge!=null">
                    t.battery1_charge = #{battery1Charge} AND
                </if>
                <if test="battery1Current!=null">
                    t.battery1_current = #{battery1Current} AND
                </if>
                <if test="battery1ErrorCode!=null">
                    t.battery1_error_code = #{battery1ErrorCode} AND
                </if>
                <if test="battery1Voltage!=null">
                    t.battery1_voltage = #{battery1Voltage} AND
                </if>
                <if test="errorCode!=null">
                    t.error_code = #{errorCode} AND
                </if>
                <if test="errorContent!=null and errorContent!=''">
                    t.error_content = #{errorContent} AND
                </if>
            </trim>
        </where>
    </sql>
 
    <select id="queryById" resultType="com.thhy.screen.modules.biz.agv.entity.AgvStateHistory">
        select <include refid="Base_Column_List" />
        from t_agv_state_history t
        where t.id=#{id}
    </select>
 
    <select id="queryVersionById" resultType="integer">
        select version from t_agv_state_history
        where id=#{id}
    </select>
 
    <!--查询列表-->
    <select id="findList" resultType="com.thhy.screen.modules.biz.agv.entity.AgvStateHistory">
        SELECT
        <include refid="Base_Column_List" />
        from t_agv_state_history t
        <include refid="condition_query" />
    </select>
 
    <!--查询列表-->
    <select id="findAll" resultType="com.thhy.screen.modules.biz.agv.entity.AgvStateHistory">
        SELECT
        <include refid="Base_Column_List" />
        from t_agv_state_history t
    </select>
 
    <select id="leastData" resultType="com.thhy.screen.modules.biz.agv.entity.AgvStateHistory">
        select
            t.id as id,
            t.accurate_stop as accurateStop,
            t.agv_back_laser_swtich as agvBackLaserSwtich,
            t.agv_base_angular_vel as agvBaseAngularVel,
            t.agv_base_linear_vel as agvBaseLinearVel,
            t.agv_collision as agvCollision,
            t.agv_control_style as agvControlStyle,
            t.agv_current_landmark_rFID as agvCurrentLandmarkRFID,
            t.agv_dest_rFID as agvDestRFID,
            t.agv_emergency_button as agvEmergencyButton,
            t.agv_front_laser_switch as agvFrontLaserSwitch,
            t.agv_id as agvId,
            t.agv_jacking_state as agvJackingState,
            t.agv_liftup_heavy_state as agvLiftupHeavyState,
            t.agv_model_rFID as agvModelRFID,
            t.agv_move_style as agvMoveStyle,
            t.agv_task_state as agvTaskState,
            t.agv_vel_direction as agvVelDirection,
            t.agv_vel_level as agvVelLevel,
            t.agv_working_state as agvWorkingState,
            t.battery1_charge as battery1Charge,
            t.battery1_current as battery1Current,
            t.battery1_error_code as battery1ErrorCode,
            t.battery1_voltage as battery1Voltage,
            t.error_code as errorCode,
            t.error_content as errorContent
             FROM
            (
                select agv_id,MAX(id) as maxId from t_agv_state_history GROUP BY agv_id
            ) a
                left join t_agv_state_history t on a.maxId = t.id
    </select>
 
    <!--插入操作-->
    <insert id="insert">
        insert into t_agv_state_history
        <trim prefix="(" suffix=")" suffixOverrides="," >
            <if test="accurateStop != null">
                accurate_stop,
            </if>
            <if test="agvBackLaserSwtich != null">
                agv_back_laser_swtich,
            </if>
            <if test="agvBaseAngularVel != null">
                agv_base_angular_vel,
            </if>
            <if test="agvBaseLinearVel != null">
                agv_base_linear_vel,
            </if>
            <if test="agvCollision != null">
                agv_collision,
            </if>
            <if test="agvControlStyle != null">
                agv_control_style,
            </if>
            <if test="agvCurrentLandmarkRFID != null">
                agv_current_landmark_rFID,
            </if>
            <if test="agvDestRFID != null">
                agv_dest_rFID,
            </if>
            <if test="agvEmergencyButton != null">
                agv_emergency_button,
            </if>
            <if test="agvFrontLaserSwitch != null">
                agv_front_laser_switch,
            </if>
            <if test="agvId != null">
                agv_id,
            </if>
            <if test="agvJackingState != null">
                agv_jacking_state,
            </if>
            <if test="agvLiftupHeavyState != null">
                agv_liftup_heavy_state,
            </if>
            <if test="agvModelRFID != null">
                agv_model_rFID,
            </if>
            <if test="agvMoveStyle != null">
                agv_move_style,
            </if>
            <if test="agvTaskState != null">
                agv_task_state,
            </if>
            <if test="agvVelDirection != null">
                agv_vel_direction,
            </if>
            <if test="agvVelLevel != null">
                agv_vel_level,
            </if>
            <if test="agvWorkingState != null">
                agv_working_state,
            </if>
            <if test="battery1Charge != null">
                battery1_charge,
            </if>
            <if test="battery1Current != null">
                battery1_current,
            </if>
            <if test="battery1ErrorCode != null">
                battery1_error_code,
            </if>
            <if test="battery1Voltage != null">
                battery1_voltage,
            </if>
            <if test="errorCode != null">
                error_code,
            </if>
            <if test="errorContent != null">
                error_content,
            </if>
            <if test="id != null">
                id,
            </if>
        </trim>
 
        <trim prefix="values (" suffix=")" suffixOverrides="," >
            <if test="accurateStop != null">
                #{accurateStop},
            </if>
            <if test="agvBackLaserSwtich != null">
                #{agvBackLaserSwtich},
            </if>
            <if test="agvBaseAngularVel != null">
                #{agvBaseAngularVel},
            </if>
            <if test="agvBaseLinearVel != null">
                #{agvBaseLinearVel},
            </if>
            <if test="agvCollision != null">
                #{agvCollision},
            </if>
            <if test="agvControlStyle != null">
                #{agvControlStyle},
            </if>
            <if test="agvCurrentLandmarkRFID != null">
                #{agvCurrentLandmarkRFID},
            </if>
            <if test="agvDestRFID != null">
                #{agvDestRFID},
            </if>
            <if test="agvEmergencyButton != null">
                #{agvEmergencyButton},
            </if>
            <if test="agvFrontLaserSwitch != null">
                #{agvFrontLaserSwitch},
            </if>
            <if test="agvId != null">
                #{agvId},
            </if>
            <if test="agvJackingState != null">
                #{agvJackingState},
            </if>
            <if test="agvLiftupHeavyState != null">
                #{agvLiftupHeavyState},
            </if>
            <if test="agvModelRFID != null">
                #{agvModelRFID},
            </if>
            <if test="agvMoveStyle != null">
                #{agvMoveStyle},
            </if>
            <if test="agvTaskState != null">
                #{agvTaskState},
            </if>
            <if test="agvVelDirection != null">
                #{agvVelDirection},
            </if>
            <if test="agvVelLevel != null">
                #{agvVelLevel},
            </if>
            <if test="agvWorkingState != null">
                #{agvWorkingState},
            </if>
            <if test="battery1Charge != null">
                #{battery1Charge},
            </if>
            <if test="battery1Current != null">
                #{battery1Current},
            </if>
            <if test="battery1ErrorCode != null">
                #{battery1ErrorCode},
            </if>
            <if test="battery1Voltage != null">
                #{battery1Voltage},
            </if>
            <if test="errorCode != null">
                #{errorCode},
            </if>
            <if test="errorContent != null">
                #{errorContent},
            </if>
            <if test="id != null">
                #{id},
            </if>
        </trim>
    </insert>
 
 
    <!--更新操作-->
    <update id="update">
        update t_agv_state_history
        <set>
            <if test="accurateStop != null">
                accurate_stop=#{accurateStop},
            </if>
            <if test="agvBackLaserSwtich != null">
                agv_back_laser_swtich=#{agvBackLaserSwtich},
            </if>
            <if test="agvBaseAngularVel != null">
                agv_base_angular_vel=#{agvBaseAngularVel},
            </if>
            <if test="agvBaseLinearVel != null">
                agv_base_linear_vel=#{agvBaseLinearVel},
            </if>
            <if test="agvCollision != null">
                agv_collision=#{agvCollision},
            </if>
            <if test="agvControlStyle != null">
                agv_control_style=#{agvControlStyle},
            </if>
            <if test="agvCurrentLandmarkRFID != null">
                agv_current_landmark_rFID=#{agvCurrentLandmarkRFID},
            </if>
            <if test="agvDestRFID != null">
                agv_dest_rFID=#{agvDestRFID},
            </if>
            <if test="agvEmergencyButton != null">
                agv_emergency_button=#{agvEmergencyButton},
            </if>
            <if test="agvFrontLaserSwitch != null">
                agv_front_laser_switch=#{agvFrontLaserSwitch},
            </if>
            <if test="agvId != null">
                agv_id=#{agvId},
            </if>
            <if test="agvJackingState != null">
                agv_jacking_state=#{agvJackingState},
            </if>
            <if test="agvLiftupHeavyState != null">
                agv_liftup_heavy_state=#{agvLiftupHeavyState},
            </if>
            <if test="agvModelRFID != null">
                agv_model_rFID=#{agvModelRFID},
            </if>
            <if test="agvMoveStyle != null">
                agv_move_style=#{agvMoveStyle},
            </if>
            <if test="agvTaskState != null">
                agv_task_state=#{agvTaskState},
            </if>
            <if test="agvVelDirection != null">
                agv_vel_direction=#{agvVelDirection},
            </if>
            <if test="agvVelLevel != null">
                agv_vel_level=#{agvVelLevel},
            </if>
            <if test="agvWorkingState != null">
                agv_working_state=#{agvWorkingState},
            </if>
            <if test="battery1Charge != null">
                battery1_charge=#{battery1Charge},
            </if>
            <if test="battery1Current != null">
                battery1_current=#{battery1Current},
            </if>
            <if test="battery1ErrorCode != null">
                battery1_error_code=#{battery1ErrorCode},
            </if>
            <if test="battery1Voltage != null">
                battery1_voltage=#{battery1Voltage},
            </if>
            <if test="errorCode != null">
                error_code=#{errorCode},
            </if>
            <if test="errorContent != null">
                error_content=#{errorContent},
            </if>
        </set>
        where id=#{id}
    </update>
 
    <!--逻辑删除-->
    <update id="deletelogic">
        update t_agv_state_history
        SET is_use = 0
        where id=#{id}
    </update>
 
    <!--根据ID删除-->
    <delete id="deleteById">
        delete from t_agv_state_history
        where id=#{id}
    </delete>
 
</mapper>