EquipmentMapper.xml
8.69 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
<?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.pojo.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>
<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>
<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="deviceId != null">device_id = #{deviceId},</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="deviceId != null">device_id = #{deviceId},</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>
<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>
</mapper>