物管理后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
4.4 KiB

<?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.thing.device.source.mapper.IotThingSourceMapper">
<resultMap type="com.thing.device.source.entity.IotThingSourceEntity" id="iotThingSourceMap">
<result property="id" column="id"/>
<result property="pid" column="pid"/>
<result property="thingRelationId" column="thing_relation_id"/>
<result property="thingName" column="thing_name"/>
<result property="thingCode" column="thing_code"/>
<result property="thingAttrName" column="thing_attr_name"/>
<result property="thingAttrCode" column="thing_attr_code"/>
<result property="thingAttrCodeType" column="thing_attr_code_type"/>
<result property="thingAttrType" column="thing_attr_type"/>
<result property="thingAttrUnit" column="thing_attr_unit"/>
<result property="thingIcon" column="thing_icon"/>
<result property="gatherFrequency" column="gather_frequency"/>
<result property="dataTreatingMark" column="data_treating_mark"/>
<result property="dataRule" column="data_rule"/>
<result property="configType" column="config_type"/>
<result property="remark" column="remark"/>
<result property="extendData" column="extend_data"/>
<result property="tenantCode" column="tenant_code"/>
<result property="companyId" column="company_id"/>
<result property="deptId" column="dept_id"/>
<result property="creator" column="creator"/>
<result property="createDate" column="create_date"/>
<result property="updater" column="updater"/>
<result property="updateDate" column="update_date"/>
</resultMap>
<select id="getParentList" resultType="com.thing.device.source.dto.IotThingSourcePidDTO">
SELECT
its.id,
its.root_id,
its.thing_id,
its.thing_code,
its.thing_attr_code,
its.thing_attr_name,
its.thing_attr_code_type,
its.data_deal_config as data_rule,
its.thing_serial,
its.thing_icon,
its.thing_attr_unit,
its.gather_frequency,
its.thing_attr_boundary,
itt.ID AS thing_tenant_id,
its.data_treating_mark,
its.data_deal_config
FROM
iot_thing_source its
INNER JOIN iot_thing_entity itt ON its.thing_id = itt.id
<where>
-- its.pid is null
1=1
<if test="thingIdList != null">
and its.thing_id in
<foreach item="thingId" collection="thingIdList" open="(" separator="," close=")">
#{thingId}
</foreach>
</if>
<if test="rootIdList != null">
and its.root_id in
<foreach item="rootId" collection="rootIdList" open="(" separator="," close=")">
#{rootId}
</foreach>
</if>
<if test="thingAttrCodeList != null">
and its.thing_attr_code in
<foreach item="thingAttrCode" collection="thingAttrCodeList" open="(" separator="," close=")">
#{thingAttrCode}
</foreach>
</if>
<if test="thingAttrCodeType != null and thingAttrCodeType.trim() != ''">
and its.thing_attr_code_type = #{thingAttrCodeType}
</if>
<if test="configType != null and configType.trim() != ''">
and its.config_type = #{configType}
</if>
</where>
</select>
<select id="getChildList" resultType="com.thing.device.source.dto.IotThingSourcePidDTO">
SELECT
its.ID,
its.pid,
its.thing_code,
its.thing_attr_code,
its.thing_attr_code_type,
itt.ID AS thing_id,
its.thing_serial
FROM
iot_thing_source its
INNER JOIN iot_thing_entity itt ON its.thing_id = itt.id
<where>
its.pid in
<foreach item="pid" collection="pidList" open="(" separator="," close=")">
#{pid}
</foreach>
</where>
</select>
<select id="getRootIdsByThingIdAndConfigTypeAndTenantCode" resultType="java.lang.Long">
SELECT DISTINCT(root_id) from iot_thing_source where thing_id=#{thingId} and config_type=#{configType} and tenant_code=#{tenantCode}
</select>
</mapper>