zhangnaisong
2024-08-06 4dbd2e0a473ef33ecf8a7200f62b61d4dbd87f25
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
<?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.sy.mapper.ArdTankLockMapper">
    
    <resultMap type="ArdTankLock" id="ArdTankLockResult">
        <result property="id"    column="id"    />
        <result property="lockNum"    column="lock_num"    />
        <result property="lockName"    column="lock_name"    />
        <result property="imgPositionTop"    column="img_position_top"    />
        <result property="imgPositionLeft"    column="img_position_left"    />
        <result property="carId"    column="car_id"    />
        <result property="enable"    column="enable"    />
        <result property="restartState"    column="restart_state"    />
        <result property="onlineTime"    column="online_time"    />
    </resultMap>
 
    <resultMap type="ArdTankLock" id="ArdTankLockWithStateResult">
        <result property="id"    column="id"    />
        <result property="lockNum"    column="lock_num"    />
        <result property="lockName"    column="lock_name"    />
        <result property="imgPositionTop"    column="img_position_top"    />
        <result property="imgPositionLeft"    column="img_position_left"    />
        <result property="carId"    column="car_id"    />
        <result property="enable"    column="enable"    />
        <result property="restartState"    column="restart_state"    />
        <result property="onlineTime"    column="online_time"    />
        <association property="ardTankLockState" javaType="com.ruoyi.sy.domain.ArdTankLockState">
            <result property="id"    column="sid"    />
            <result property="lockId"    column="lock_id"    />
            <result property="lockNum"    column="slock_num"    />
            <result property="lockState"    column="lock_state"    />
            <result property="lockPositionState"    column="lock_position_state"    />
            <result property="lockShellState"    column="lock_shell_state"    />
            <result property="restartState"    column="srestart_state"    />
            <result property="batterVoltage"    column="batter_voltage"    />
            <result property="powerVoltage"    column="power_voltage"    />
            <result property="uploadTime"    column="upload_time"    />
            <result property="uniqueMark"    column="unique_mark"    />
            <result property="lockStateMark"    column="lock_state_mark"    />
        </association>
    </resultMap>
 
    <resultMap type="ArdTankLock" id="ArdTankLockWithPasswordResult">
        <result property="id"    column="id"    />
        <result property="lockNum"    column="lock_num"    />
        <result property="lockName"    column="lock_name"    />
        <result property="imgPositionTop"    column="img_position_top"    />
        <result property="imgPositionLeft"    column="img_position_left"    />
        <result property="carId"    column="car_id"    />
        <result property="enable"    column="enable"    />
        <result property="restartState"    column="restart_state"    />
        <result property="onlineTime"    column="online_time"    />
        <collection property="ardTankLockPasswords" ofType="com.ruoyi.sy.domain.ArdTankLockPassword">
            <result property="id"    column="pid"    />
            <result property="lockId"    column="lock_id"    />
            <result property="password"    column="password"    />
            <result property="no"    column="no"    />
            <result property="createTime"    column="create_time"    />
            <result property="useTime"    column="use_time"    />
        </collection>
    </resultMap>
 
    <resultMap type="ArdTankLock" id="ArdTankLockWithWallAndStateResult">
        <result property="id"    column="id"    />
        <result property="lockNum"    column="lock_num"    />
        <result property="lockName"    column="lock_name"    />
        <result property="imgPositionTop"    column="img_position_top"    />
        <result property="imgPositionLeft"    column="img_position_left"    />
        <result property="carId"    column="car_id"    />
        <result property="enable"    column="enable"    />
        <result property="restartState"    column="restart_state"    />
        <result property="onlineTime"    column="online_time"    />
        <association property="ardTankLockState" javaType="com.ruoyi.sy.domain.ArdTankLockState">
            <result property="id"    column="sid"    />
            <result property="lockId"    column="slock_id"    />
            <result property="lockNum"    column="slock_num"    />
            <result property="lockState"    column="lock_state"    />
            <result property="lockPositionState"    column="lock_position_state"    />
            <result property="lockShellState"    column="lock_shell_state"    />
            <result property="restartState"    column="srestart_state"    />
            <result property="batterVoltage"    column="batter_voltage"    />
            <result property="powerVoltage"    column="power_voltage"    />
            <result property="uploadTime"    column="upload_time"    />
            <result property="uniqueMark"    column="unique_mark"    />
            <result property="lockStateMark"    column="lock_state_mark"    />
        </association>
        <collection property="ardTankWallLockList" ofType="com.ruoyi.sy.domain.ArdTankWallLock">
            <result property="processType"    column="process_type"    />
            <result property="id"    column="mid"    />
            <result property="wallId"    column="wall_id"    />
            <result property="lockId"    column="lock_id"    />
            <association property="ardTankWall" javaType="com.ruoyi.sy.domain.ArdTankWall">
                <result property="id"    column="wid"    />
                <result property="wallName"    column="wall_name"    />
                <result property="wallPoi"    column="wall_poi"    />
                <result property="wallType"    column="wall_type"    />
            </association>
        </collection>
    </resultMap>
 
    <sql id="selectArdTankLockVo">
        select id, lock_num, lock_name, img_position_top, img_position_left, car_id, enable, restart_state, online_time from ard_tank_lock
    </sql>
 
    <select id="selectArdTankLockList" parameterType="ArdTankLock" resultMap="ArdTankLockResult">
        <include refid="selectArdTankLockVo"/>
        <where>  
            <if test="lockNum != null  and lockNum != ''"> and lock_num = #{lockNum}</if>
            <if test="lockName != null  and lockName != ''"> and lock_name like '%'||#{lockName}||'%'</if>
            <if test="imgPositionTop != null  and imgPositionTop != ''"> and img_position_top = #{imgPositionTop}</if>
            <if test="imgPositionLeft != null  and imgPositionLeft != ''"> and img_position_left = #{imgPositionLeft}</if>
            <if test="carId != null  and carId != ''"> and car_id = #{carId}</if>
            <if test="enable != null  and enable != ''"> and enable = #{enable}</if>
            <if test="restartState != null  and restartState != ''"> and restart_state = #{restartState}</if>
            <if test="onlineTime != null  and onlineTime != ''"> and online_time = #{onlineTime}</if>
        </where>
    </select>
    
    <select id="selectArdTankLockById" parameterType="String" resultMap="ArdTankLockResult">
        <include refid="selectArdTankLockVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertArdTankLock" parameterType="ArdTankLock">
        insert into ard_tank_lock
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="lockNum != null">lock_num,</if>
            <if test="lockName != null">lock_name,</if>
            <if test="imgPositionTop != null">img_position_top,</if>
            <if test="imgPositionLeft != null">img_position_left,</if>
            <if test="carId != null">car_id,</if>
            <if test="enable != null">enable,</if>
            <if test="restartState != null">restart_state,</if>
            <if test="onlineTime != null">online_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="lockNum != null">#{lockNum},</if>
            <if test="lockName != null">#{lockName},</if>
            <if test="imgPositionTop != null">#{imgPositionTop},</if>
            <if test="imgPositionLeft != null">#{imgPositionLeft},</if>
            <if test="carId != null">#{carId},</if>
            <if test="enable != null">#{enable},</if>
            <if test="restartState != null">#{restartState},</if>
            <if test="onlineTime != null">#{onlineTime},</if>
         </trim>
    </insert>
 
    <update id="updateArdTankLock" parameterType="ArdTankLock">
        update ard_tank_lock
        <trim prefix="SET" suffixOverrides=",">
            <if test="lockNum != null">lock_num = #{lockNum},</if>
            <if test="lockName != null">lock_name = #{lockName},</if>
            <if test="imgPositionTop != null">img_position_top = #{imgPositionTop},</if>
            <if test="imgPositionLeft != null">img_position_left = #{imgPositionLeft},</if>
            <if test="carId != null">car_id = #{carId},</if>
            <if test="enable != null">enable = #{enable},</if>
            <if test="restartState != null">restart_state = #{restartState},</if>
            <if test="onlineTime != null">online_time = #{onlineTime},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteArdTankLockById" parameterType="String">
        delete from ard_tank_lock where id = #{id}
    </delete>
 
    <delete id="deleteArdTankLockByIds" parameterType="String">
        delete from ard_tank_lock where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
    <select id="getAll" resultMap="ArdTankLockResult">
        select * from ard_tank_lock atl order by atl.car_id,lock_num
    </select>
 
    <insert id="insertArdTankLocks" parameterType="com.ruoyi.sy.domain.ArdTankLock" >
        insert into ard_tank_lock (id, lock_num, lock_name,
        img_position_top, img_position_left, car_id,
        enable, restart_state, online_time)
        values
        <foreach collection ="ardTankLocks" item="ardTankLock" separator =",">
            (#{ardTankLock.id},#{ardTankLock.lockNum},#{ardTankLock.lockName},
            #{ardTankLock.imgPositionTop},#{ardTankLock.imgPositionLeft},
            #{ardTankLock.carId},#{ardTankLock.enable},#{ardTankLock.restartState},
             #{ardTankLock.onlineTime})
        </foreach >
    </insert>
 
    <select id="getLockByCarId" resultMap="ArdTankLockWithStateResult" parameterType="java.lang.String">
        select t.id,t.lock_num,t.lock_name,t.img_position_top,t.img_position_left,
        t.car_id,t.enable,t.restart_state,t.online_time,t.sid,t.lock_id,t.slock_num,
        t.lock_state,t.lock_position_state,t.lock_shell_state,t.srestart_state,
        t.batter_voltage,t.power_voltage,t.upload_time,t.unique_mark,
        t.lock_state_mark from (select atl.id,atl.lock_num,atl.lock_name,atl.img_position_top,
        atl.img_position_left,atl.car_id,atl.enable,atl.restart_state,
        coalesce(atl.online_time,'') as online_time,coalesce(atls.id,'') as sid,
        coalesce(atls.lock_id,'') as lock_id,coalesce(atls.lock_num,'') as slock_num,
        coalesce(atls.lock_state,'') as lock_state,coalesce(atls.lock_position_state,'') as lock_position_state,
        coalesce(atls.lock_shell_state,'') as lock_shell_state,coalesce(atls.restart_state,'') as srestart_state,
        coalesce(atls.batter_voltage,'') as batter_voltage,coalesce(atls.power_voltage,'') as power_voltage,
        coalesce(atls.upload_time,'') as upload_time,coalesce(atls.unique_mark,'') as unique_mark,
        case atls.lock_state
          when '关锁状态' then false
          when '异常状态' then false
          /*when '动作状态' then false*/
          when '操控中...' then false
          when '开锁状态' then true
          else false
          end as lock_state_mark,
        rank() over(partition by atl.lock_num order by atls.upload_time desc,atl.lock_num) rn
        from ard_tank_lock atl
        left join ard_tank_lock_state atls on atl."id" = atls.lock_id
        where car_id = #{carId} order by atls.upload_time desc,atl.lock_num)t where t.rn = 1
    </select>
 
    <delete id="deleteLockByCarId" parameterType="java.lang.String">
        delete from ard_tank_lock where car_id = #{carId}
    </delete>
 
    <delete id="deleteArdTankLockByIdSet" >
        delete from ard_tank_lock where id in
        <foreach item="id" collection="idSet" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
    <select id="selectArdTankLockTotal" resultType="java.lang.Long">
        select count(distinct atl.car_id) from ard_tank_lock atl
    </select>
 
    <select id="getLockByCarIdList" resultType="com.ruoyi.sy.domain.ArdTankLock" >
        select * from ard_tank_lock atl where car_id in
        <foreach item="id" collection="carIdList" open="(" separator="," close=")">
            #{id}
        </foreach>
        order by atl.car_id,lock_num
    </select>
 
    <select id="selectArdTankLockAllTotal" resultType="java.lang.Long">
        select count(*) from ard_tank_lock atl
    </select>
 
    <select id="selectArdTankLockTotalByCarIdList" resultType="java.lang.Long">
        select count(*) from ard_tank_lock where car_id in
        <foreach item="id" collection="carIdList" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>
 
    <delete id="deleteArdTankLockAndWallByCarIds" >
        delete from ard_tank_wall_lock atwl where atwl.lock_id in (
        select atl.id from ard_tank_lock atl
        where atl.car_id in
        <foreach item="carId" collection="carIds" open="(" separator="," close=")">
            #{carId}
        </foreach>
        );
        delete from ard_tank_lock atl
        where atl.car_id in
        <foreach item="carId" collection="carIds" open="(" separator="," close=")">
            #{carId}
        </foreach>
    </delete>
 
    <select id="getIdByLockNum" resultType="java.lang.String" parameterType="java.lang.String">
        select id from ard_tank_lock atl where atl.lock_num = #{lockNum}
    </select>
 
    <select id="selectArdTankLockWithPassword" resultMap="ArdTankLockWithPasswordResult" >
        select atl."id",atl.lock_num,atl.lock_name,atl.img_position_top,
        atl.img_position_left,atl.car_id,atl."enable",atl.restart_state,
        atl.online_time,atlp."id" as pid,atlp.lock_id,atlp."password",
        atlp.create_time,atlp.use_time  from ard_tank_lock atl
        left join ard_tank_lock_password atlp on atl.id = atlp.lock_id and use_time is null
    </select>
 
    <select id="getArdTankLockAllWithState" resultMap="ArdTankLockWithStateResult" >
        select t.id,t.lock_num,t.lock_name,t.img_position_top,t.img_position_left,
        t.car_id,t.enable,t.restart_state,t.online_time,t.sid,t.lock_id,t.slock_num,
        t.lock_state,t.lock_position_state,t.lock_shell_state,t.srestart_state,
        t.batter_voltage,t.power_voltage,t.upload_time,t.unique_mark,
        t.lock_state_mark from (select atl.id,atl.lock_num,atl.lock_name,atl.img_position_top,
        atl.img_position_left,atl.car_id,atl.enable,atl.restart_state,
        coalesce(atl.online_time,'') as online_time,coalesce(atls.id,'') as sid,
        coalesce(atls.lock_id,'') as lock_id,coalesce(atls.lock_num,'') as slock_num,
        coalesce(atls.lock_state,'') as lock_state,coalesce(atls.lock_position_state,'') as lock_position_state,
        coalesce(atls.lock_shell_state,'') as lock_shell_state,coalesce(atls.restart_state,'') as srestart_state,
        coalesce(atls.batter_voltage,'') as batter_voltage,coalesce(atls.power_voltage,'') as power_voltage,
        coalesce(atls.upload_time,'') as upload_time,coalesce(atls.unique_mark,'') as unique_mark,
        case atls.lock_state
            when '关锁状态' then false
            when '异常状态' then false
            /*when '动作状态' then false*/
            when '操控中...' then false
            when '开锁状态' then true
            else false
            end as lock_state_mark,
        rank() over(partition by atl.lock_num order by atls.upload_time desc,atl.lock_num) rn
        from ard_tank_lock atl
        left join ard_tank_lock_state atls on atl."id" = atls.lock_id)t where t.rn = 1
    </select>
 
    <select id="getArdTankLockCount" resultType="java.lang.Long" >
        select count(*) from ard_tank_lock
    </select>
 
    <select id="getArdTankLockWithStateByCarId" resultMap="ArdTankLockWithStateResult" >
        select t.id,t.lock_num,t.lock_name,t.img_position_top,t.img_position_left,
        t.car_id,t.enable,t.restart_state,t.online_time,t.sid,t.lock_id,t.slock_num,
        t.lock_state,t.lock_position_state,t.lock_shell_state,t.srestart_state,
        t.batter_voltage,t.power_voltage,t.upload_time,t.unique_mark from (
        select atl.*,atls.id as sid,atls.lock_id,atls.lock_num as slock_num,atls.lock_state,
        atls.lock_position_state,atls.lock_shell_state,atls.restart_state as srestart_state,
        atls.batter_voltage,atls.power_voltage,atls.upload_time,atls.unique_mark,
        rank() over(partition by atl.lock_num,atl.online_time order by atls.upload_time desc) rn
        from ard_tank_lock atl
        left join ard_tank_lock_state atls on atl.lock_num = atls.lock_num
        where atl.car_id = #{carId})t where t.rn = 1
    </select>
 
    <update id="updateLockEnableByCarId" parameterType="java.lang.String">
        update ard_tank_lock set enable = #{enable}
        where car_id = #{carId}
    </update>
 
    <select id="selectArdTankLockWithWallAndStateByCarId" resultMap="ArdTankLockWithWallAndStateResult" >
        select t.id,t.lock_num,t.lock_name,t.img_position_top,t.img_position_left,
        t.car_id,t.enable,t.restart_state,t.online_time,t.mid,t.wall_id,t.lock_id,
        t.process_type,t.wid,t.wall_name,t.wall_poi,t.wall_type,t.sid,t.slock_id,
        t.slock_num,t.lock_state,t.lock_position_state,t.lock_shell_state,t.srestart_state,
        t.batter_voltage,t.power_voltage,t.upload_time,t.unique_mark from
        (select atl.id,atl.lock_num,atl.lock_name,atl.img_position_top,
        atl.img_position_left,atl.car_id,atl.enable,atl.restart_state,
        coalesce(atl.online_time,'') as online_time,atwl.id as mid,
        atwl.wall_id,atwl.lock_id,atwl.process_type,atw.id as wid,
        atw.wall_name,atw.wall_poi,atw.wall_type,coalesce(atls.id,'') as sid,
        coalesce(atls.lock_id,'') as slock_id,coalesce(atls.lock_num,'') as slock_num,
        coalesce(atls.lock_state,'') as lock_state,coalesce(atls.lock_position_state,'') as lock_position_state,
        coalesce(atls.lock_shell_state,'') as lock_shell_state,coalesce(atls.restart_state,'') as srestart_state,
        coalesce(atls.batter_voltage,'') as batter_voltage,coalesce(atls.power_voltage,'') as power_voltage,
        coalesce(atls.upload_time,'') as upload_time,coalesce(atls.unique_mark,'') as unique_mark,
        rank() over(partition by atl.lock_num order by atls.upload_time desc,atl.lock_num) rn
        from ard_tank_lock atl
        inner join ard_tank_wall_lock atwl on atl.id = atwl.lock_id
        inner join ard_tank_wall atw on atwl.wall_id = atw.id
        left join ard_tank_lock_state atls on atl."id" = atls.lock_id
        where atl.car_id = #{carId} and atwl.process_type != '0')t where t.rn = 1
    </select>
</mapper>