2024-11-25 01:04:53 +08:00
|
|
|
<?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">
|
2024-11-25 15:48:00 +08:00
|
|
|
<mapper namespace="com.isu.gaswellwatch.dao.DeviceDao">
|
2024-11-25 01:04:53 +08:00
|
|
|
|
2024-11-25 15:48:00 +08:00
|
|
|
<resultMap id="DeviceVOMap" type="com.isu.gaswellwatch.vo.DeviceVO">
|
2024-11-25 01:04:53 +08:00
|
|
|
<id column="id" property="id"/>
|
|
|
|
<result column="code" property="code"/>
|
|
|
|
<result column="gas_station" property="gasStation"/>
|
|
|
|
<result column="gateway_sn" property="gatewaySn"/>
|
|
|
|
<result column="details" property="details"/>
|
|
|
|
<result column="create_time" property="createTime"/>
|
|
|
|
<result column="update_time" property="updateTime"/>
|
|
|
|
<association property="deviceType" javaType="com.isu.gaswellwatch.entity.Dictionary" select="getDic" column="device_type">
|
|
|
|
</association>
|
|
|
|
<association property="product" javaType="com.isu.gaswellwatch.entity.Dictionary" select="getDic" column="product">
|
|
|
|
</association>
|
|
|
|
<association property="gasWell" javaType="com.isu.gaswellwatch.entity.GasWell" >
|
|
|
|
<id column="gasWellId" property="id"/>
|
|
|
|
<result column="gasWellName" property="name"/>
|
2024-11-26 18:46:34 +08:00
|
|
|
<result column="gasWellBlock" property="blockId"/>
|
2024-11-25 01:04:53 +08:00
|
|
|
</association>
|
|
|
|
</resultMap>
|
|
|
|
|
2024-11-25 15:48:00 +08:00
|
|
|
<resultMap id="DeviceMap" type="com.isu.gaswellwatch.entity.Device" autoMapping="true">
|
|
|
|
<id column="id" property="id"/>
|
|
|
|
<result column="code" property="code"/>
|
|
|
|
<result column="gas_station" property="gasStation"/>
|
|
|
|
<result column="gateway_sn" property="gatewaySn"/>
|
|
|
|
<result column="details" property="details"/>
|
|
|
|
<result column="create_time" property="createTime"/>
|
|
|
|
<result column="update_time" property="updateTime"/>
|
|
|
|
<result property="deviceType" column="device_type"/>
|
|
|
|
<result property="product" column="product"/>
|
|
|
|
<result property="gasWell" column="gas_well"/>
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
<select id="page" resultMap="DeviceVOMap">
|
2024-11-25 01:04:53 +08:00
|
|
|
select u.id, u.device_type, u.code, u.gas_station, u.product, u.gateway_sn,
|
2024-11-25 15:48:00 +08:00
|
|
|
u.gas_well, u.details, u.create_time, u.update_time,g.name as gasWellName,g.id as gasWellId
|
2024-11-25 01:04:53 +08:00
|
|
|
from device u left join gas_well g on u.gas_well = g.id
|
|
|
|
<where>
|
|
|
|
<if test="gasWellName!=null and gasWellName!='' ">
|
|
|
|
and g.name LIKE CONCAT('%',#{gasWellName},'%')
|
|
|
|
</if>
|
|
|
|
<if test="gasStationName!=null and gasStationName!='' ">
|
|
|
|
and u.gas_station LIKE CONCAT('%',#{gasStationName},'%')
|
|
|
|
</if>
|
|
|
|
<if test="deviceTypeId!=null and deviceTypeId!='' ">
|
|
|
|
and u.device_type = #{deviceTypeId}
|
|
|
|
</if>
|
2024-11-28 16:38:54 +08:00
|
|
|
<if test="blockId!=null and blockId!='' ">
|
|
|
|
and g.block_id = #{blockId}
|
|
|
|
</if>
|
2024-11-25 01:04:53 +08:00
|
|
|
</where>
|
|
|
|
order by u.id desc
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="getDic" parameterType="java.lang.Long" resultType="com.isu.gaswellwatch.entity.Dictionary">
|
2024-11-25 15:48:00 +08:00
|
|
|
SELECT d.id,d.type,d.code,d.name,d.value,d.sort
|
2024-11-25 01:04:53 +08:00
|
|
|
FROM Dictionary d
|
|
|
|
where d.id=#{dicId}
|
|
|
|
</select>
|
|
|
|
|
2024-11-25 15:48:00 +08:00
|
|
|
<select id="getDeviceById" resultMap="DeviceVOMap">
|
|
|
|
select u.id, u.device_type, u.code, u.gas_station, u.product, u.gateway_sn,
|
2024-11-26 18:46:34 +08:00
|
|
|
u.gas_well, u.details, u.create_time, u.update_time,g.name as gasWellName,g.id as gasWellId,g.block_id as gasWellBlock
|
2024-11-25 15:48:00 +08:00
|
|
|
from device u left join gas_well g on u.gas_well = g.id
|
|
|
|
where u.id = #{id}
|
|
|
|
</select>
|
|
|
|
|
2024-11-26 03:12:53 +08:00
|
|
|
|
|
|
|
<select id="historyPage" resultType="com.isu.gaswellwatch.vo.DeviceHistoryVO">
|
2024-11-28 10:14:57 +08:00
|
|
|
select t.collection_time,t.oil_pressure,t.cas_pressure,t.run_mode,t.plug_status from ${tableName} t where
|
2024-11-26 03:12:53 +08:00
|
|
|
t.device_id = #{deviceId}
|
|
|
|
<if test="startTime!=null">
|
|
|
|
and t.collection_time >= #{startTime}
|
|
|
|
</if>
|
|
|
|
<if test="endTime!=null">
|
|
|
|
and t.collection_time <= #{endTime}
|
|
|
|
</if>
|
|
|
|
order by t.collection_time desc
|
|
|
|
</select>
|
|
|
|
|
2024-11-26 18:46:34 +08:00
|
|
|
<select id="deviceOptLogPage" resultType="com.isu.gaswellwatch.entity.DeviceOptLog">
|
|
|
|
select t.* from device_opt_log t where t.device_id = #{deviceId}
|
|
|
|
<if test="startTime!=null">
|
|
|
|
and t.create_time >= #{startTime}
|
|
|
|
</if>
|
|
|
|
<if test="endTime!=null">
|
|
|
|
and t.create_time <= #{endTime}
|
|
|
|
</if>
|
|
|
|
order by t.create_time desc
|
|
|
|
</select>
|
|
|
|
|
2024-11-28 01:30:00 +08:00
|
|
|
<select id="getDeviceVOByIds" resultMap="DeviceVOMap">
|
|
|
|
select u.id, u.device_type, u.code, u.gas_station, u.product, u.gateway_sn,
|
|
|
|
u.gas_well, u.details, u.create_time, u.update_time
|
|
|
|
from device u
|
|
|
|
where u.id in
|
|
|
|
<foreach collection="idList" item="id" open="(" separator="," close=")">
|
|
|
|
#{id}
|
|
|
|
</foreach>
|
|
|
|
</select>
|
|
|
|
|
2024-11-25 01:04:53 +08:00
|
|
|
</mapper>
|
|
|
|
|