<?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.business.mapper.HwDeviceMapper" >
<resultMap type= "HwDevice" id= "HwDeviceResult" >
<result property= "deviceId" column= "device_id" />
<result property= "deviceCode" column= "device_code" />
<result property= "deviceName" column= "device_name" />
<result property= "sceneId" column= "scene_id" />
<result property= "monitorUnitId" column= "monitor_unit_id" />
<result property= "deviceType" column= "device_type" />
<result property= "networkingMode" column= "networking_mode" />
<result property= "accessProtocol" column= "access_protocol" />
<result property= "dataFormat" column= "data_format" />
<result property= "releatedDeviceId" column= "releated_device_id" />
<result property= "deviceModeId" column= "device_mode_id" />
<result property= "accessGwProtocol" column= "access_gw_protocol" />
<result property= "activeStatus" column= "active_status" />
<result property= "deviceStatus" column= "device_status" />
<result property= "activeTime" column= "active_time" />
<result property= "publishTime" column= "publish_time" />
<result property= "devicePic" column= "device_pic" />
<result property= "ipAddress" column= "ip_address" />
<result property= "areaId" column= "area_id" />
<result property= "deviceLocation" column= "device_location" />
<result property= "currentModuleVersion" column= "current_module_version" />
<result property= "currentSinglechipVersion" column= "current_singlechip_version" />
<result property= "remark" column= "remark" />
<result property= "createBy" column= "create_by" />
<result property= "createTime" column= "create_time" />
<result property= "updateBy" column= "update_by" />
<result property= "updateTime" column= "update_time" />
<result property= "deviceField" column= "device_field" />
<result property= "tenantId" column= "tenant_id" />
<result property= "onlineStatus" column= "online_status" />
<result property= "sceneName" column= "scene_name" />
<result property= "tenantName" column= "tenant_name" />
<result property= "deviceModeName" column= "device_mode_name" />
<result property= "monitorUnitName" column= "monitor_unit_name" />
<result property= "functionName" column= "function_name" />
</resultMap>
<resultMap id= "TreeDeviceVoResult" type= "com.ruoyi.business.domain.VO.TreeDeviceVo" >
<result property= "voId" column= "vo_id" />
<result property= "voName" column= "vo_name" />
<result property= "parentId" column= "parent_id" />
<result property= "prop" column= "prop" />
</resultMap>
<resultMap id= "TreeAreaVoResult" type= "com.ruoyi.business.domain.VO.TreeAreaVo" >
<result property= "areaId" column= "area_id" />
<result property= "areaName" column= "area_name" />
<!-- <result property="ancestors" column="ancestors" /> -->
<!-- <result property="parentId" column="parent_id" /> -->
<!-- <result property="areaStatus" column="area_status" /> -->
<!-- <result property="orderNum" column="order_num" /> -->
</resultMap>
<!-- 以下为监控平台接口所用 -->
<resultMap id= "DeviceModeVoResult" type= "com.ruoyi.business.domain.VO.DeviceModeVo" >
<result property= "deviceModeName" column= "device_mode_name" />
<result property= "sum" column= "sum" />
<result property= "err" column= "err" />
</resultMap>
<select id= "selectDeviceModeNameVo" resultMap= "DeviceModeVoResult" >
-- SELECT b.device_mode_name as device_mode_name ,a.sum as sum FROM hw_device_mode b
-- LEFT JOIN (SELECT device_mode_id,count(*) as sum FROM hw_device where device_status !=9 GROUP BY device_mode_id order by sum desc
-- ) a on a.device_mode_id = b.device_mode_id left join hw_scene c on b.scene_id = c.scene_id
select a.device_mode_name,sum(a.sum) sum from (select
b.device_mode_name as device_mode_name ,
a.sum as sum
from
hw_device_mode b
left join (
select
device_mode_id,
count(*) as sum
from
hw_device
where device_status !=9
group by
device_mode_id
order by
sum desc
) a on
a.device_mode_id = b.device_mode_id
left join hw_scene c on
b.scene_id = c.scene_id) a group by a.device_mode_name
</select>
<select id= "selectDeviceByDeviceModeByDeviceModeFunction" parameterType= "Long" resultType= "String" >
select count(*) from hw_device_mode_function where device_mode_id =
(SELECT device_mode_id from hw_device where device_id = #{deviceId}) and function_type = '1'
</select>
<select id= "selectDeviceModeFunctionByFunctionType" parameterType= "Long" resultType= "String" >
</select>
<select id= "selectDeviceNum" parameterType= "Long" resultMap= "HwDeviceResult" >
<include refid= "selectHwDeviceVo" />
where hd.scene_id = #{sceneId}
</select>
<select id= "selectDeviceByMonitorId" parameterType= "Long" resultMap= "HwDeviceResult" >
<include refid= "selectHwDeviceVo" />
where hd.monitor_unit_id = #{monitorUnitId}
</select>
<select id= "selectDeviceByDeviceModeBySceneId" parameterType= "Long" resultMap= "HwDeviceResult" >
select * from hw_device where device_mode_id = (
SELECT device_mode_id from hw_device_mode where scene_id = #{sceneId} )
</select>
<select id= "selectDeviceByDeviceModeByMonitorUnitId" parameterType= "Long" resultMap= "HwDeviceResult" >
select * from hw_device where device_mode_id = (
SELECT device_mode_id from hw_device_mode where monitor_unit_id = #{monitorUnitId} )
</select>
<!-- 以上为监控平台接口所用 -->
<sql id= "selectHwDeviceVo" >
select hd.device_id,
hd.device_code,
hd.device_name,
hd.scene_id,
hd.monitor_unit_id,
hmu.monitor_unit_name,
hd.device_type,
hd.networking_mode,
hd.access_protocol,
hd.data_format,
hd.releated_device_id,
hd.device_mode_id,
hd.access_gw_protocol,
hd.active_status,
hd.device_status,
hd.active_time,
hd.device_pic,
hd.ip_address,
hd.area_id,
hd.device_location,
hd.current_module_version,
hd.current_singlechip_version,
hd.remark,
hd.create_by,
hd.create_time,
hd.update_by,
hd.update_time,
hd.device_field,
hd.tenant_id,
hd.online_status
from hw_device hd
left join hw_monitor_unit hmu on hmu.monitor_unit_id = hd.monitor_unit_id
</sql>
<select id= "selectHwDeviceList" parameterType= "HwDevice" resultMap= "HwDeviceResult" >
<include refid= "selectHwDeviceVo" />
<where >
and device_status !='9'
<if test= "deviceCode != null and deviceCode != ''" > and hd.device_code like concat('%', #{deviceCode}, '%')</if>
<if test= "deviceName != null and deviceName != ''" > and hd.device_name like concat('%', #{deviceName}, '%')</if>
<if test= "sceneId != null " > and hd.scene_id = #{sceneId}</if>
<if test= "monitorUnitId != null " > and hd.monitor_unit_id = #{monitorUnitId}</if>
<if test= "deviceType != null and deviceType != ''" > and hd.device_type = #{deviceType}</if>
<if test= "networkingMode != null and networkingMode != ''" > and hd.networking_mode = #{networkingMode}</if>
<if test= "accessProtocol != null " > and hd.access_protocol = #{accessProtocol}</if>
<if test= "dataFormat != null " > and hd.data_format = #{dataFormat}</if>
<if test= "releatedDeviceId != null " > and hd.releated_device_id = #{releatedDeviceId}</if>
<if test= "deviceModeId != null " > and hd.device_mode_id = #{deviceModeId}</if>
<if test= "accessGwProtocol != null " > and hd.access_gw_protocol = #{accessGwProtocol}</if>
<if test= "activeStatus != null and activeStatus != ''" > and hd.active_status = #{activeStatus}</if>
<if test= "deviceStatus != null and deviceStatus != ''" > and hd.device_status = #{deviceStatus}</if>
<if test= "activeTime != null " > and hd.active_time = #{activeTime}</if>
<if test= "devicePic != null and devicePic != ''" > and hd.device_pic = #{devicePic}</if>
<if test= "ipAddress != null and ipAddress != ''" > and hd.ip_address = #{ipAddress}</if>
<if test= "areaId != null " > and hd.area_id = #{areaId}</if>
<if test= "deviceLocation != null and deviceLocation != ''" > and hd.device_location = #{deviceLocation}</if>
<if test= "currentModuleVersion != null and currentModuleVersion != ''" > and hd.current_module_version = #{currentModuleVersion}</if>
<if test= "currentSinglechipVersion != null and currentSinglechipVersion != ''" > and hd.current_singlechip_version = #{currentSinglechipVersion}</if>
<if test= "deviceField != null and deviceField != ''" > and hd.device_field = #{deviceField}</if>
<if test= "tenantId != null " > and hd.tenant_id = #{tenantId}</if>
<if test= "onlineStatus != null and onlineStatus != ''" > and hd.online_status = #{onlineStatus}</if>
<!-- 租户数据范围过滤 -->
${params.tenantDataScope}
</where>
</select>
<select id= "selectHwDeviceByDeviceId" parameterType= "Long" resultMap= "HwDeviceResult" >
<include refid= "selectHwDeviceVo" />
where hd.device_id = #{deviceId}
</select>
<insert id= "insertHwDevice" parameterType= "HwDevice" useGeneratedKeys= "true" keyProperty= "deviceId" >
insert into hw_device
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "deviceCode != null and deviceCode != ''" > device_code,</if>
<if test= "deviceName != null and deviceName != ''" > device_name,</if>
<if test= "sceneId != null" > scene_id,</if>
<if test= "monitorUnitId != null" > monitor_unit_id,</if>
<if test= "deviceType != null and deviceType != ''" > device_type,</if>
<if test= "networkingMode != null and networkingMode != ''" > networking_mode,</if>
<if test= "accessProtocol != null" > access_protocol,</if>
<if test= "dataFormat != null" > data_format,</if>
<if test= "releatedDeviceId != null" > releated_device_id,</if>
<if test= "deviceModeId != null" > device_mode_id,</if>
<if test= "accessGwProtocol != null" > access_gw_protocol,</if>
<if test= "activeStatus != null and activeStatus != ''" > active_status,</if>
<if test= "deviceStatus != null and deviceStatus != ''" > device_status,</if>
<if test= "activeTime != null" > active_time,</if>
<if test= "devicePic != null" > device_pic,</if>
<if test= "ipAddress != null" > ip_address,</if>
<if test= "areaId != null" > area_id,</if>
<if test= "deviceLocation != null" > device_location,</if>
<if test= "currentModuleVersion != null" > current_module_version,</if>
<if test= "currentSinglechipVersion != null" > current_singlechip_version,</if>
<if test= "remark != null" > remark,</if>
<if test= "createBy != null" > create_by,</if>
<if test= "createTime != null" > create_time,</if>
<if test= "updateBy != null" > update_by,</if>
<if test= "updateTime != null" > update_time,</if>
<if test= "deviceField != null" > device_field,</if>
<if test= "tenantId != null" > tenant_id,</if>
<if test= "onlineStatus != null and onlineStatus != ''" > online_status,</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "deviceCode != null and deviceCode != ''" > #{deviceCode},</if>
<if test= "deviceName != null and deviceName != ''" > #{deviceName},</if>
<if test= "sceneId != null" > #{sceneId},</if>
<if test= "monitorUnitId != null" > #{monitorUnitId},</if>
<if test= "deviceType != null and deviceType != ''" > #{deviceType},</if>
<if test= "networkingMode != null and networkingMode != ''" > #{networkingMode},</if>
<if test= "accessProtocol != null" > #{accessProtocol},</if>
<if test= "dataFormat != null" > #{dataFormat},</if>
<if test= "releatedDeviceId != null" > #{releatedDeviceId},</if>
<if test= "deviceModeId != null" > #{deviceModeId},</if>
<if test= "accessGwProtocol != null" > #{accessGwProtocol},</if>
<if test= "activeStatus != null and activeStatus != ''" > #{activeStatus},</if>
<if test= "deviceStatus != null and deviceStatus != ''" > #{deviceStatus},</if>
<if test= "activeTime != null" > #{activeTime},</if>
<if test= "devicePic != null" > #{devicePic},</if>
<if test= "ipAddress != null" > #{ipAddress},</if>
<if test= "areaId != null" > #{areaId},</if>
<if test= "deviceLocation != null" > #{deviceLocation},</if>
<if test= "currentModuleVersion != null" > #{currentModuleVersion},</if>
<if test= "currentSinglechipVersion != null" > #{currentSinglechipVersion},</if>
<if test= "remark != null" > #{remark},</if>
<if test= "createBy != null" > #{createBy},</if>
<if test= "createTime != null" > #{createTime},</if>
<if test= "updateBy != null" > #{updateBy},</if>
<if test= "updateTime != null" > #{updateTime},</if>
<if test= "deviceField != null" > #{deviceField},</if>
<if test= "tenantId != null" > #{tenantId},</if>
<if test= "onlineStatus != null and onlineStatus != ''" > #{onlineStatus},</if>
</trim>
</insert>
<update id= "updateHwDevice" parameterType= "HwDevice" >
update hw_device
<trim prefix= "SET" suffixOverrides= "," >
<if test= "deviceCode != null and deviceCode != ''" > device_code = #{deviceCode},</if>
<if test= "deviceName != null and deviceName != ''" > device_name = #{deviceName},</if>
<if test= "sceneId != null" > scene_id = #{sceneId},</if>
<if test= "monitorUnitId != null" > monitor_unit_id = #{monitorUnitId},</if>
<if test= "deviceType != null and deviceType != ''" > device_type = #{deviceType},</if>
<if test= "networkingMode != null and networkingMode != ''" > networking_mode = #{networkingMode},</if>
<if test= "accessProtocol != null" > access_protocol = #{accessProtocol},</if>
<if test= "dataFormat != null" > data_format = #{dataFormat},</if>
<if test= "releatedDeviceId != null" > releated_device_id = #{releatedDeviceId},</if>
<if test= "deviceModeId != null" > device_mode_id = #{deviceModeId},</if>
<if test= "accessGwProtocol != null" > access_gw_protocol = #{accessGwProtocol},</if>
<if test= "activeStatus != null and activeStatus != ''" > active_status = #{activeStatus},</if>
<if test= "deviceStatus != null and deviceStatus != ''" > device_status = #{deviceStatus},</if>
<if test= "activeTime != null" > active_time = #{activeTime},</if>
<if test= "publishTime != null" > publish_time = #{publishTime},</if>
<if test= "devicePic != null" > device_pic = #{devicePic},</if>
<if test= "ipAddress != null" > ip_address = #{ipAddress},</if>
<if test= "areaId != null" > area_id = #{areaId},</if>
<if test= "deviceLocation != null" > device_location = #{deviceLocation},</if>
<if test= "currentModuleVersion != null" > current_module_version = #{currentModuleVersion},</if>
<if test= "currentSinglechipVersion != null" > current_singlechip_version = #{currentSinglechipVersion},</if>
<if test= "remark != null" > remark = #{remark},</if>
<if test= "createBy != null" > create_by = #{createBy},</if>
<if test= "createTime != null" > create_time = #{createTime},</if>
<if test= "updateBy != null" > update_by = #{updateBy},</if>
<if test= "updateTime != null" > update_time = #{updateTime},</if>
<if test= "deviceField != null" > device_field = #{deviceField},</if>
<if test= "tenantId != null" > tenant_id = #{tenantId},</if>
<if test= "onlineStatus != null and onlineStatus != ''" > online_status = #{onlineStatus},</if>
</trim>
where device_id = #{deviceId}
</update>
<delete id= "deleteHwDeviceByDeviceId" parameterType= "Long" >
update hw_device set device_status = '9',device_code=null where device_id = #{deviceId}
</delete>
<delete id= "deleteHwDeviceByDeviceIds" parameterType= "String" >
delete from hw_device where device_id in
<foreach item= "deviceId" collection= "array" open= "(" separator= "," close= ")" >
#{deviceId}
</foreach>
</delete>
<select id= "getOnlineDeviceNum" parameterType= "Long" >
SELECT count(1) as count FROM hw_device hd
where hd.device_status=1 and ((hd.device_type=2
and exists (select 1 from hw_device hdd where hd.releated_device_id=hdd.device_id and hdd.online_status=1 and hdd.device_status=1)) or (hd.device_type=3 and hd.online_status=1))
<if test= "sceneId != null and sceneId!=0" > and hd.scene_id=#{sceneId}</if>
</select>
<sql id= "selectHwDeviceJoinVo" >
select hd.device_code,hd.device_name, hd.device_status,hd.online_status, hd.device_pic,hd.active_time,hd.device_mode_id,
hmu.monitor_unit_name
from hw_device hd left join hw_monitor_unit hmu on hd.monitor_unit_id = hmu.monitor_unit_id </sql>
<select id= "selectHwDeviceJoinByDeviceId" parameterType= "Long" resultMap= "HwDeviceResult" >
<include refid= "selectHwDeviceJoinVo" />
where hd.device_id = #{deviceId}
</select>
<select id= "selectLinkedDevices" parameterType= "Long" resultMap= "HwDeviceResult" >
<include refid= "selectHwDeviceJoinVo" />
where exists (select 1 from hw_alarm_rule_link harl where hd.device_id=harl.link_device_id
and hd.device_id = #{deviceId})
</select>
<select id= "selectHwDeviceJoinList" parameterType= "HwDevice" resultMap= "HwDeviceResult" >
select hd.device_id,hd.device_code,hd.device_name,hd.device_type,
hd.tenant_id,hd.scene_id,hd.monitor_unit_id,hd.device_mode_id,hd.active_status,
hd.active_time,hd.device_status,hd.online_status,hd.releated_device_id,hd.device_pic,
hd.publish_time,hd.access_gw_protocol,hd.access_protocol,hd.data_format,hd.networking_mode,
hs.scene_name,hmu.monitor_unit_name,hdmf.device_mode_name,ht.tenant_name
from hw_device hd
left join hw_scene hs on hd.scene_id = hs.scene_id
left join hw_monitor_unit hmu on hd.monitor_unit_id = hmu.monitor_unit_id
left join hw_device_mode hdmf on hd.device_mode_id = hdmf.device_mode_id
left join hw_tenant ht on hd.tenant_id=ht.tenant_id
<where >
and hd.device_status != '9'
<if test= "deviceCode != null and deviceCode != ''" > and hd.device_code like concat('%', #{deviceCode}, '%')</if>
<if test= "deviceName != null and deviceName != ''" > and hd.device_name like concat('%', #{deviceName}, '%')</if>
<if test= "sceneId != null " > and hd.scene_id = #{sceneId}</if>
<if test= "monitorUnitId != null " > and hd.monitor_unit_id = #{monitorUnitId}</if>
<if test= "deviceType != null and deviceType != ''" > and hd.device_type = #{deviceType}</if>
<if test= "deviceModeId != null " > and hd.device_mode_id = #{deviceModeId}</if>
<if test= "activeStatus != null and activeStatus != ''" > and hd.active_status = #{activeStatus}</if>
<if test= "deviceStatus != null and deviceStatus != ''" > and hd.device_status = #{deviceStatus}</if>
<if test= "tenantId != null " > and hd.tenant_id = #{tenantId}</if>
<if test= "releatedDeviceId != null " > and hd.releated_device_id = #{releatedDeviceId}</if>
<if test= "onlineStatus != null and onlineStatus != ''" > and hd.online_status = #{onlineStatus}</if>
<!-- 租户数据范围过滤 -->
${params.tenantDataScope}
</where>
order by hd.device_id desc
</select>
<select id= "checkExistSubDevice" parameterType= "Long" resultType= "int" >
select count(1) from hw_device where releated_device_id = #{releatedDeviceId} and device_status != '9'
</select>
<select id= "selectHwDeviceByDeviceCode" parameterType= "String" resultMap= "HwDeviceResult" >
<include refid= "selectHwDeviceVo" />
where hd.device_code = #{deviceCode} limit 1
</select>
<select id= "selectDeviceNumCount" parameterType= "HwDevice" >
select count(1) as sum from hw_device
where device_status = '1' and (device_type='2' or device_type='3')
<if test= "sceneId != null and sceneId!=0" > and scene_id = #{sceneId}</if>
<if test= "monitorUnitId != null and monitorUnitId!=0" > and monitor_unit_id = #{monitorUnitId}</if>
</select>
<select id= "selectAbnormalDeviceNumCount" parameterType= "HwDevice" >
select count(1) as sum from hw_device hd
where hd.device_status = '1' and (hd.device_type='2' or hd.device_type='3')
and exists (select 1 from hw_alarm_info hai where hd.device_id=hai.device_id and hai.handle_status='0')
<if test= "sceneId != null and sceneId!=0" > and hd.scene_id = #{sceneId}</if>
<if test= "monitorUnitId != null and monitorUnitId!=0" > and hd.monitor_unit_id = #{monitorUnitId}</if>
</select>
<select id= "selectHwDeviceListByMonitor" parameterType= "HwDevice" resultMap= "HwDeviceResult" >
<include refid= "selectHwDeviceVo" />
<where >
<if test= "sceneId != null " > and hd.scene_id = #{sceneId}</if>
<if test= "monitorUnitId != null " > and hd.monitor_unit_id = #{monitorUnitId}</if>
and hd.device_status !='9' and (device_type='2' or device_type='3')
<!-- 租户数据范围过滤 -->
${params.tenantDataScope}
</where>
order by hd.device_id desc
</select>
<select id= "selectAllocatedList" parameterType= "HwDevice" resultMap= "HwDeviceResult" >
select distinct hd.device_id,hd.device_code,hd.device_name,hd.device_type,hd.publish_time,hmu.monitor_unit_name
from hw_device hd left join hw_monitor_unit hmu on hd.monitor_unit_id = hmu.monitor_unit_id
where hd.device_status != '9' and
exists (select 1 from hw_offline_target hot where hot.target_id=hd.device_id and hot.offline_rule_id = #{offlineRuleId})
<if test= "deviceCode != null and deviceCode != ''" >
AND hd.device_code like concat('%', #{deviceCode}, '%')
</if>
<if test= "deviceName != null and deviceName != ''" >
AND hd.device_name like concat('%', #{deviceName}, '%')
</if>
<if test= "monitorUnitId != null " > and hd.monitor_unit_id = #{monitorUnitId}</if>
<if test= "deviceType != null and deviceType != ''" > and hd.device_type = #{deviceType}</if>
<!-- 数据范围过滤 -->
${params.tenantDataScope}
</select>
<select id= "selectUnallocatedList" parameterType= "HwDevice" resultMap= "HwDeviceResult" >
select distinct hd.device_id,hd.device_code,hd.device_name,hd.device_type,hd.publish_time,hmu.monitor_unit_name
from hw_device hd left join hw_monitor_unit hmu on hd.monitor_unit_id = hmu.monitor_unit_id
where hd.device_status != '9' and hd.scene_id=#{sceneId}
and not exists (select 1 from hw_offline_target hot where hot.target_id=hd.device_id and hot.target_type = 1)
<if test= "deviceCode != null and deviceCode != ''" >
AND hd.device_code like concat('%', #{deviceCode}, '%')
</if>
<if test= "deviceName != null and deviceName != ''" >
AND hd.device_name like concat('%', #{deviceName}, '%')
</if>
<if test= "monitorUnitId != null " > and hd.monitor_unit_id = #{monitorUnitId}</if>
<if test= "deviceType != null and deviceType != ''" > and hd.device_type = #{deviceType}</if>
<!-- 租户数据范围过滤 -->
${params.tenantDataScope}
</select>
<select id= "getOnlineDeviceNum1" resultType= "java.lang.Integer" parameterType= "java.lang.Long" >
select count(1) from
(select
b.device_mode_name device_mode_name
from
hw_device hd left join hw_device_mode b on hd.device_mode_id = b.device_mode_id
where
hd.device_status = 1
and ((hd.device_type = 2
and exists (
select
1
from
hw_device hdd
where
hd.releated_device_id = hdd.device_id
and hdd.online_status = 1
and hdd.device_status = 1))
or (hd.device_type = 3
and hd.online_status = 1))
<if test= "sceneId != null and sceneId!=0" > and hd.scene_id=#{sceneId}</if> ) a where a.device_mode_name = '定位信标'
</select>
<select id= "getDeviceByModel" resultType= "com.ruoyi.business.domain.HwDevice"
parameterType="java.lang.Long">
select * from hw_device where device_mode_id = #{modelId}
</select>
<select id= "selectDeviceList" resultMap= "TreeDeviceVoResult" >
select hd.device_id as vo_id ,hd.monitor_unit_id as parent_id ,hd.device_name as vo_name ,
group_concat(hdmf.function_name separator',') as prop
from hw_device hd
left join hw_device_mode hdm on hd.device_mode_id = hdm.device_mode_id
left join hw_device_mode_function hdmf on hdm.device_mode_id = hdmf.device_mode_id
where hd.device_status != 9
group by hd.device_id
</select>
<select id= "selectPropBydeviceIdAndFunctionName" resultType= "String" >
select function_identifier from hw_device_mode_function hdmf
where function_name = #{functionName} and device_mode_id = (
select device_mode_id from hw_device hd where device_id = #{deviceModeId})
</select>
<select id= "getDeviceByAreaId" parameterType= "Long" resultMap= "HwDeviceResult" >
select * from hw_device hd
<where >
and area_id = #{areaId}
and device_status !=9
<if test= "tenantId != null and tenantId != ''" > and tenant_id =#{tenantId}</if>
</where>
</select>
<select id= "getTreeArea" parameterType= "Long" resultMap= "TreeAreaVoResult" >
select ha2.area_id as area_id,ha2.area_name as area_name from hw_area ha,hw_area ha2
where ha.area_id = ha2.parent_id and ha.area_id = #{areaId}
</select>
<select id= "getDeviceListInMonitorUnit" parameterType= "Long" resultMap= "HwDeviceResult" >
SELECT hd.*, hmu.monitor_unit_name
FROM hw_device hd
LEFT JOIN hw_monitor_unit hmu ON hmu.monitor_unit_id = hd.monitor_unit_id
WHERE hd.device_mode_id IN (
SELECT hdmf.device_mode_id
FROM hw_device_mode_function hdmf
WHERE hdmf.function_identifier = 'latitude'
)
AND hd.device_status != 9
AND hd.monitor_unit_id = #{monitorUnitId}
</select>
<select id= "selectFunctionNameByFunctionIdentifier" parameterType= "String" resultType= "String" >
select distinct function_name from hw_device_mode_function where function_identifier = #{functionIdentifier}
</select>
<select id= "selectDeviceIfAlarm" parameterType= "Long" resultType= "Long" >
select count(*) from
(select * from hw_alarm_info where device_id = #{deviceId} and handle_status = 0) as a
</select>
<select id= "selectDeviceIfAlarmElectronFence" resultType= "java.lang.Long" parameterType= "java.lang.Long" >
select count(*) from
(select * from hw_alarm_info where device_id = #{deviceId} and handle_status = 0 and alarm_info_type = 4) as a
</select>
</mapper>