gasWellWatch/src/main/resources/mapper/DeviceDao.xml

165 lines
7.7 KiB
XML
Raw Normal View History

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>
<select id="historyPage" resultType="com.isu.gaswellwatch.vo.DeviceHistoryVO">
2024-12-11 17:55:13 +08:00
select t.collection_time,t.oil_pressure,t.cas_pressure,t.pre_pressure
<if test="deviceProduct!=null and deviceProduct=='knpc'">,t.run_mode,t.status_end_time,t.temperature,t.humidity,t.well_status,t.plug_status</if>
2024-12-09 21:01:54 +08:00
<if test="deviceProduct!=null and deviceProduct=='etc'">,t.current_status_remaining_time as statusEndTime,t.controller_current_status as runMode,t.solenoid_valve_status as wellStatus</if>
2024-12-11 17:55:13 +08:00
<if test="deviceProduct!=null and deviceProduct=='scss'">,t.ctl_model as runMode,t.remaining_time_action as statusEndTime,t.solar_voltage,t.first_solenoid_status as wellStatus</if>
2024-12-08 21:18:38 +08:00
from ${tableName} t
<where>
t.device_id = #{deviceId}
2024-12-12 14:52:02 +08:00
<if test="startTime!=null">
and t.collection_time &gt;= #{startTime}
</if>
2024-12-12 14:52:02 +08:00
<if test="endTime!=null">
and t.collection_time &lt;= #{endTime}
</if>
2024-12-08 21:18:38 +08:00
</where>
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}
2024-12-11 02:08:20 +08:00
<if test="startTime!=null and startTime!=''">
2024-11-26 18:46:34 +08:00
and t.create_time &gt;= #{startTime}
</if>
2024-12-11 02:08:20 +08:00
<if test="endTime!=null and endTime!=''">
2024-11-26 18:46:34 +08:00
and t.create_time &lt;= #{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-12-10 21:17:08 +08:00
<select id="getPressureChartData" resultType="com.isu.gaswellwatch.vo.DeviceHistoryVO">
select t.collection_time,t.oil_pressure,t.cas_pressure
from ${tableName} t
<where>
t.device_id = #{deviceId}
2024-12-11 02:08:20 +08:00
<if test="startTime!=null and startTime!=''">
2024-12-10 21:17:08 +08:00
and t.collection_time &gt;= #{startTime}
</if>
2024-12-11 02:08:20 +08:00
<if test="endTime!=null and endTime!=''">
2024-12-10 21:17:08 +08:00
and t.collection_time &lt;= #{endTime}
</if>
</where>
order by t.collection_time asc
</select>
<select id="getSwitchStatusData" resultType="com.isu.gaswellwatch.vo.DeviceHistoryVO">
select t.collection_time
<if test="deviceProduct!=null and deviceProduct=='knpc'">,t.well_status</if>
<if test="deviceProduct!=null and deviceProduct=='etc'">,t.solenoid_valve_status as wellStatus</if>
<if test="deviceProduct!=null and deviceProduct=='scss'">,t.first_solenoid_status as wellStatus</if>
from ${tableName} t
<where>
t.device_id = #{deviceId}
2024-12-12 14:52:02 +08:00
<if test="startTime!=null">
2024-12-10 21:17:08 +08:00
and t.collection_time &gt;= #{startTime}
</if>
2024-12-12 14:52:02 +08:00
<if test="endTime!=null">
2024-12-10 21:17:08 +08:00
and t.collection_time &lt;= #{endTime}
</if>
</where>
order by t.collection_time asc
</select>
2024-12-12 14:52:02 +08:00
<select id="getDeviceHistoryData" resultType="com.isu.gaswellwatch.vo.DeviceHistoryVO">
select t.collection_time,t.oil_pressure,t.cas_pressure,t.pre_pressure
<if test="deviceProduct!=null and deviceProduct=='knpc'">,t.run_mode,t.status_end_time,t.temperature,t.humidity,t.well_status,t.plug_status</if>
<if test="deviceProduct!=null and deviceProduct=='etc'">,t.current_status_remaining_time as statusEndTime,t.controller_current_status as runMode,t.solenoid_valve_status as wellStatus</if>
<if test="deviceProduct!=null and deviceProduct=='scss'">,t.ctl_model as runMode,t.remaining_time_action as statusEndTime,t.solar_voltage,t.first_solenoid_status as wellStatus</if>
from ${tableName} t
<where>
t.device_id = #{deviceId}
<if test="startTime!=null">
and t.collection_time &gt;= #{startTime}
</if>
<if test="endTime!=null">
and t.collection_time &lt;= #{endTime}
</if>
</where>
order by t.collection_time desc
</select>
2024-11-25 01:04:53 +08:00
</mapper>