map/das/src/main/resources/mapper/SysImpTabMappingMapper.xml
2025-01-17 10:32:15 +08:00

138 lines
5.2 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.das.modules.node.mapper.SysImpTabMappingMapper">
<resultMap type="com.das.modules.node.domain.vo.SysTabMappingVo" id="SysImpTabMappingMap">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="linkId" column="link_id" jdbcType="BIGINT"/>
<result property="linkName" column="link_name" jdbcType="VARCHAR"/>
<result property="equipmentId" column="equipment_id" jdbcType="BIGINT"/>
<result property="equipmentName" column="equipment_name" jdbcType="VARCHAR"/>
<result property="equipmentCode" column="equipment_code" jdbcType="VARCHAR"/>
<result property="measPointType" column="meas_point_type" jdbcType="INTEGER"/>
<result property="measPointCode" column="meas_point_code" jdbcType="VARCHAR"/>
<result property="measPointName" column="meas_point_name" jdbcType="VARCHAR"/>
<result property="highSpeed" column="highspeed" jdbcType="INTEGER"/>
<result property="params" column="params" jdbcType="VARCHAR"/>
<result property="porder" column="porder" jdbcType="INTEGER"/>
</resultMap>
<resultMap type="com.das.modules.node.domain.vo.EquipmentVo" id="EquipmentMap">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="iotModelId" column="iot_model_id" jdbcType="BIGINT"/>
<result property="iotAddr" column="iot_addr" jdbcType="VARCHAR"/>
</resultMap>
<select id="getMappingInfoListByLinkId" resultMap="SysImpTabMappingMap">
select
t1.id,
t1.link_id,
t2.link_name,
t1.equipment_id,
t3."name" as equipment_name,
t3.code as equipment_code,
t1.meas_point_type ,
t1.meas_point_code ,
t1.meas_point_name,
t1.highspeed,
t1.params ,
t1.porder
from
sys_imptabmapping t1
left join sys_communicationlink t2 on t2.id = t1.link_id
left join sys_equipment t3 on t3.id = t1.equipment_id
where
t1.link_id = #{linkId}
order by
t1.equipment_id ,
t1.meas_point_type,
t1.porder
</select>
<select id="getMappingInfoListByLinkIdAndType" resultMap="SysImpTabMappingMap">
select
t1.id,
t1.link_id,
t2.link_name,
t1.equipment_id,
t3."name" as equipment_name,
t3.code as equipment_code,
t1.meas_point_type ,
t1.meas_point_code ,
t1.meas_point_name,
t1.highspeed,
t1.params ,
t1.porder
from
sys_imptabmapping t1
left join sys_communicationlink t2 on t2.id = t1.link_id
left join sys_equipment t3 on t3.id = t1.equipment_id
where
t1.link_id = #{linkId} and t1.meas_point_type = #{type}
order by
t1.porder
</select>
<select id="getMappingInfoListByLinkIdAndDeviceId" resultMap="SysImpTabMappingMap">
select
t1.id,
t1.link_id,
t2.link_name,
t1.equipment_id,
t3."name" as equipment_name,
t3.code as equipment_code,
t1.meas_point_type ,
t1.meas_point_code ,
t1.meas_point_name,
t1.highspeed,
t1.params ,
t1.porder
from
sys_imptabmapping t1
left join sys_communicationlink t2 on t2.id = t1.link_id
left join sys_equipment t3 on t3.id = t1.equipment_id
where
t1.link_id = #{linkId} and t1.equipment_id = #{deviceId}
order by
t1.equipment_id ,
t1.meas_point_type,
t1.porder
</select>
<select id="getBindDeviceByLink" resultMap="EquipmentMap">
select t.id ,t."name",t.iot_model_id,t.iot_addr from sys_equipment t where t.id in (select distinct equipment_id from sys_imptabmapping where link_id =#{linkId})
</select>
<delete id="deleteMappingByLinkId">
delete from sys_imptabmapping where link_id = #{linkId}
</delete>
<select id="getTemperatureMappingListByDeviceId" resultType="com.das.modules.node.entity.SysTabMapping">
select
t1.*
from
sys_imptabmapping t1,
sys_equipment t2,
sys_iot_model t3,
sys_iot_model_field t4
where
t1.equipment_id = t2.id
and t2.iot_model_id = t3.id
and t3.id = t4.iot_model_id
and t1.meas_point_code = t4.attribute_code
and t4.attribute_type = 138 and t4.attribute_name like '%温度%'
and t2.id = #{info.deviceId}
<if test="info.attributes !=null and info.attributes.size() > 0">
and t1.meas_point_code in
<foreach collection="info.attributes" item="attribute" open="(" close=")" separator=",">
#{attribute}
</foreach>
</if>
</select>
</mapper>