185 lines
5.6 KiB
XML
185 lines
5.6 KiB
XML
<?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.yfd.platform.modules.auxcontrol.mapper.DeviceSignalMapper">
|
|
|
|
<!-- 查询辅控设备信号表-->
|
|
<select id="selectDeviceSignalMap" resultType="java.util.Map">
|
|
SELECT
|
|
sc.station_code,
|
|
sc.station_name,
|
|
sc.area_id,
|
|
sc.area_name,
|
|
sc.bay_id,
|
|
sc.bay_name,
|
|
sc.component_id,
|
|
sc.component_name,
|
|
sc.main_device_name,
|
|
a.station_id,
|
|
a.systemcode,
|
|
a.device_name,
|
|
a.device_code,
|
|
b.*
|
|
FROM
|
|
fk_meter_device a
|
|
INNER JOIN fk_device_signal b ON ( a.device_id = b.meter_device_id )
|
|
INNER JOIN fk_gateway_device c ON ( a.netdevice_ip = c.ip_addr )
|
|
INNER JOIN iis_substation_component sc ON ( sc.component_id = b.main_component_id )
|
|
WHERE
|
|
1 =1
|
|
<if test="slaveIp != null and slaveIp != ''">
|
|
and c.ip_addr = #{slaveIp}
|
|
</if>
|
|
<if test="type=='yx'">
|
|
and b.yx_addr = #{address}
|
|
</if>
|
|
<if test="type=='yc'">
|
|
and b.yc_addr = #{address}
|
|
</if>
|
|
limit 1
|
|
</select>
|
|
|
|
<!-- 查询辅控设备信号表-->
|
|
<select id="selectOneDeviceSignal" resultType="com.yfd.platform.modules.auxcontrol.domain.DeviceSignal">
|
|
SELECT
|
|
b.*
|
|
FROM
|
|
fk_meter_device a
|
|
JOIN fk_device_signal b ON ( a.device_id = b.meter_device_id )
|
|
JOIN fk_gateway_device c ON ( a.netdevice_ip = c.ip_addr )
|
|
WHERE
|
|
<if test="slaveIp != null and slaveIp != ''">
|
|
c.ip_addr = #{slaveIp}
|
|
</if>
|
|
<if test="type=='yx'">
|
|
and b.yx_addr = #{type}
|
|
</if>
|
|
<if test="type=='yc'">
|
|
and b.yc_addr = #{type}
|
|
</if>
|
|
limit 1
|
|
</select>
|
|
<select id="getDeviceSignalMaps" resultType="java.util.Map">
|
|
SELECT
|
|
fds.signal_id,
|
|
fds.signal_code,
|
|
fds.signal_name,
|
|
isc.main_device_id,
|
|
isc.main_device_name,
|
|
isc.component_id,
|
|
isc.component_name,
|
|
isc.station_code,
|
|
isc.area_id,
|
|
isc.area_name,
|
|
isc.bay_id,
|
|
isc.bay_name
|
|
FROM
|
|
fk_device_signal fds
|
|
INNER JOIN iis_substation_component isc ON isc.component_id = fds.main_component_id
|
|
WHERE 1=1
|
|
<if test="stationCode != null and stationCode != ''">
|
|
AND isc.station_code = #{stationCode}
|
|
</if>
|
|
|
|
<if test="signalName != null and signalName != ''">
|
|
AND fds.signal_name LIKE CONCAT('%',#{signalName},'%')
|
|
</if>
|
|
</select>
|
|
<select id="selectDeviceSignalByIp" resultType="com.yfd.platform.modules.auxcontrol.domain.DeviceSignal">
|
|
SELECT
|
|
a.signal_id,
|
|
a.meter_device_id,
|
|
a.signal_name,
|
|
'' signal_unit,
|
|
a.yx_addr,
|
|
a.yc_addr,
|
|
CASE
|
|
|
|
WHEN b.STATUS = '01' THEN
|
|
'1' ELSE '0'
|
|
END yx_value
|
|
FROM
|
|
fk_device_signal a
|
|
JOIN fk_gateway_device b ON ( a.yx_addr = b.iec_addr )
|
|
WHERE
|
|
b.device_type = '30'
|
|
AND b.ip_addr = #{ip}
|
|
</select>
|
|
<select id="querySignalDataById" resultType="java.util.Map">
|
|
SELECT
|
|
fds.signal_id,
|
|
fds.signal_code,
|
|
fds.signal_type,
|
|
fds.signal_name,
|
|
fds.signal_unit,
|
|
fds.normal_range,
|
|
fds.ykyt_type,
|
|
fmd.device_model,
|
|
fmd.device_code,
|
|
fmd.place,
|
|
fgd.ip_addr,
|
|
fgd.Protocol,
|
|
fgd.frequency,
|
|
fmd.device_name,
|
|
fgd.device_type
|
|
FROM
|
|
fk_device_signal fds
|
|
INNER JOIN fk_meter_device fmd ON fds.meter_device_id = fmd.device_id
|
|
INNER JOIN fk_gateway_device fgd ON fgd.ip_addr = fmd.netdevice_ip
|
|
WHERE signal_id =#{signalId}
|
|
LIMIT 1
|
|
</select>
|
|
<select id="queryYxData" resultType="java.util.Map">
|
|
SELECT
|
|
md.device_type,
|
|
ds.signal_name,
|
|
ds.signal_code,
|
|
ds.yx_addr,
|
|
ds.yx_value,
|
|
md.`status`
|
|
FROM
|
|
fk_device_signal ds
|
|
INNER JOIN fk_meter_device md ON ds.meter_device_id = md.device_id
|
|
WHERE
|
|
ds.yx_addr IS NOT NULL
|
|
AND ds.yx_addr != ''
|
|
<if test="stationId != null and stationId != ''">
|
|
AND md.station_id = #{stationId}
|
|
</if>
|
|
<if test="areaId != null and areaId != ''">
|
|
AND md.region = #{areaId}
|
|
</if>
|
|
<if test="type != null and type != ''">
|
|
AND md.device_type = #{type}
|
|
</if>
|
|
ORDER BY
|
|
md.device_type,
|
|
ds.signal_code
|
|
</select>
|
|
|
|
<select id="countDeviceTypeStatus" resultType="java.util.Map">
|
|
SELECT
|
|
IFNULL(md.device_type, 'all') AS device_type,
|
|
COUNT(*) AS total,
|
|
SUM(CASE WHEN md.`status` = '01' THEN 1 ELSE 0 END) AS online_count
|
|
FROM
|
|
fk_device_signal ds
|
|
INNER JOIN fk_meter_device md ON ds.meter_device_id = md.device_id
|
|
WHERE
|
|
ds.yx_addr IS NOT NULL
|
|
AND ds.yx_addr != ''
|
|
<if test="stationId != null and stationId != ''">
|
|
AND md.station_id = #{stationId}
|
|
</if>
|
|
<if test="areaId != null and areaId != ''">
|
|
AND md.region = #{areaId}
|
|
</if>
|
|
<if test="type != null and type != ''">
|
|
AND md.device_type = #{type}
|
|
</if>
|
|
GROUP BY
|
|
md.device_type WITH ROLLUP
|
|
ORDER BY
|
|
md.device_type;
|
|
</select>
|
|
</mapper>
|