EquipmentMapper.xml
11.1 KB
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
<?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.equipment.mapper.EquipmentMapper">
<resultMap type="Equipment" id="EquipmentResult">
<result property="id" column="id" />
<result property="siteName" column="site_name" />
<result property="address" column="address" />
<result property="ip" column="ip" />
<result property="status" column="status" />
<result property="promise" column="promise" />
<result property="image" column="image" />
<result property="deviceId" column="device_id" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
<result property="remark" column="remark" />
<result property="lastHeartRes" column="last_heart_res" />
<result property="onlineClient" column="online_client" />
</resultMap>
<sql id="selectEquipmentVo">
select id, site_name, address, ip, status, promise, image, device_id, create_time, update_time, create_by, update_by, remark,last_heart_res,online_client from equipment
</sql>
<select id="selectEquipmentList" parameterType="Equipment" resultMap="EquipmentResult">
<include refid="selectEquipmentVo"/>
<where>
<if test="siteName != null and siteName != ''"> and site_name like concat('%', #{siteName}, '%')</if>
<if test="address != null and address != ''"> and address = #{address}</if>
<if test="ip != null and ip != ''"> and ip = #{ip}</if>
<if test="status != null "> and status = #{status}</if>
<if test="promise != null and promise != ''"> and promise = #{promise}</if>
<if test="image != null and image != ''"> and image = #{image}</if>
<if test="deviceId != null and deviceId != ''"> and device_id = #{deviceId}</if>
<if test="onlineClient != null and onlineClient != ''"> and online_client = #{onlineClient}</if>
</where>
order by id desc
</select>
<select id="selectEquipmentById" parameterType="Long" resultMap="EquipmentResult">
<include refid="selectEquipmentVo"/>
where id = #{id}
</select>
<select id="selectEquipmentByDeviceId" resultType="com.ruoyi.equipment.domain.Equipment">
<if test="deviceId !=null and deviceId != ''">
<include refid="selectEquipmentVo"></include>
where device_id = #{deviceId}
</if>
</select>
<select id="count" resultType="java.lang.Integer">
select count(*) from equipment
where status = 1
</select>
<select id="querySignListByJobCode" resultType="com.ruoyi.domain.EquipmentDriverExpand">
select driver_face_device_id.* from driver_face_device_id,equipment
where driver_face_device_id.device_id = equipment.device_id
<if test="drivers != null and drivers.size() > 0">
and job_code in
<foreach collection="drivers" item="item" open="(" separator="," close=")">
#{item.jobCode}
</foreach>
</if>
</select>
<select id="queryEquipmentByDeviceId" resultType="com.ruoyi.equipment.domain.Equipment">
select * from equipment
where device_id = #{deviceId}
</select>
<select id="queryLog" resultType="com.ruoyi.equipment.domain.EquipmentLog">
select * from equipment_log
where device_id = #{deviceId}
order by off_line_time desc
</select>
<insert id="insertEquipment" parameterType="Equipment" useGeneratedKeys="true" keyProperty="id">
insert into equipment
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="siteName != null and siteName != ''">site_name,</if>
<if test="address != null and address != ''">address,</if>
<if test="ip != null and ip != ''">ip,</if>
<if test="status != null">status,</if>
<if test="promise != null and promise != ''">promise,</if>
<if test="image != null">image,</if>
<if test="deviceId != null">device_id,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
<if test="remark != null">remark,</if>
<if test="lastHeartRes != null">last_heart_res,</if>
<if test="onlineClient != null">online_client,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="siteName != null and siteName != ''">#{siteName},</if>
<if test="address != null and address != ''">#{address},</if>
<if test="ip != null and ip != ''">#{ip},</if>
<if test="status != null">#{status},</if>
<if test="promise != null and promise != ''">#{promise},</if>
<if test="image != null">#{image},</if>
<if test="deviceId != null">#{deviceId},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="remark != null">#{remark},</if>
<if test="lastHeartRes != null">#{lastHeartRes},</if>
<if test="onlineClient != null">#{online_client},</if>
</trim>
</insert>
<insert id="insertEquipmentOffLineLog">
insert into equipment_log (device_id,off_line_time,recovery_flag)
values
<foreach collection="list" item="item" separator=",">
(
#{item.deviceId},
#{item.lastHeartRes},
2
)
</foreach>
on duplicate key update
device_id = values(device_id)
</insert>
<update id="updateEquipment" parameterType="Equipment">
update equipment
<trim prefix="SET" suffixOverrides=",">
<if test="siteName != null and siteName != ''">site_name = #{siteName},</if>
<if test="address != null and address != ''">address = #{address},</if>
<if test="ip != null and ip != ''">ip = #{ip},</if>
<if test="status != null">status = #{status},</if>
<if test="promise != null and promise != ''">promise = #{promise},</if>
<if test="image != null">image = #{image},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="lastHeartRes != null">last_heart_res = #{lastHeartRes},</if>
<if test="onlineClient != null">online_client = #{onlineClient},</if>
</trim>
where 1 = 1
<if test="id !=null">
and id = #{id}
</if>
<if test="deviceId !=null and id == null">
and device_id = #{deviceId}
</if>
</update>
<update id="updateEquipments">
<foreach collection="list" item="item">
update equipment set last_heart_res = #{item.lastHeartRes}, online_client = #{item.onlineClient}
where device_id = #{item.deviceId};
</foreach>
</update>
<update id="updateEquipmentByDeviceId">
update equipment
<trim prefix="SET" suffixOverrides=",">
<if test="siteName != null and siteName != ''">site_name = #{siteName},</if>
<if test="address != null and address != ''">address = #{address},</if>
<if test="ip != null and ip != ''">ip = #{ip},</if>
<if test="status != null">status = #{status},</if>
<if test="promise != null and promise != ''">promise = #{promise},</if>
<if test="image != null">image = #{image},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="lastHeartRes != null">last_heart_res = #{lastHeartRes},</if>
<if test="onlineClient != null">online_client = #{onlineClient},</if>
</trim>
where device_id = #{deviceId}
</update>
<update id="updateEquipmentLog">
<foreach collection="recoveryList" item="item" separator=";" index="index">
update equipment_log set recovery_time = #{item.recoveryTime},recovery_flag = #{item.recoveryFlag}
where device_id = #{item.deviceId} and recovery_flag = 2
</foreach>
</update>
<delete id="deleteEquipmentById" parameterType="Long">
delete from equipment where id = #{id}
</delete>
<delete id="deleteEquipmentByIds" parameterType="String">
delete from equipment where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<delete id="deleteExRecord">
DELETE
FROM
equipment_exception
WHERE
id IN (
SELECT
ee.id
FROM
(
SELECT
id
FROM
equipment_exception
WHERE
create_time LIKE CONCAT( DATE_FORMAT( NOW(), "%Y-%m-%d" ), "%" )
AND job_code IN (
SELECT
s1.job_code
FROM
scheduling s1
INNER JOIN (
SELECT
job_code,
schedule_date,
MIN( fcsj_t ) AS min_fcsj_t
FROM
scheduling
WHERE
bc_type = 'out'
AND schedule_date = DATE_FORMAT( NOW(), '%Y-%m-%d' )
GROUP BY
job_code,
schedule_date
) s2 ON s1.job_code = s2.job_code
AND s1.schedule_date = s2.schedule_date
AND s1.fcsj_t = s2.min_fcsj_t
)
) as ee
)
</delete>
</mapper>