| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?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.xunmei.iot.mapper.IotAlarmRuleSourceMapper">
- <select id="selectDetailData" resultType="com.xunmei.iot.vo.alarm.IotAlarmRuleSourceDetailVo">
- select r.id as ruleId,
- r.enabled as enable,
- r.name as ruleName,
- r.remark as ruleRemark,
- r.type as ruleType,
- e.source_type as sourceType
- from t_app_alarm_rule r
- inner join t_app_alarm_rule_express e on r.id = e.rule_id
- where r.id = #{ruleId}
- </select>
- <resultMap id="product_type_data" type="com.xunmei.iot.vo.alarm.ProductTypeDataVo">
- <result property="type" column="type"/>
- <result property="valueType" column="value_type"/>
- <result property="typeText" column="type_text"/>
- <collection property="deviceTempList" ofType="com.xunmei.iot.vo.alarm.ProductDeviceTempVo">
- <result property="deviceId" column="device_id"/>
- <result property="strDeviceId" column="strDeviceId"/>
- <result property="orgId" column="org_id"/>
- <result property="orgName" column="org_name"/>
- <result property="orgPath" column="org_path"/>
- </collection>
- </resultMap>
- <select id="selectRuleDevice" resultMap="product_type_data">
- SELECT
- a.source_type AS type,
- d.source_type_des as type_text,
- b.value_type,
- b.`value` AS device_id,
- concat(b.org_id,'-',b.value) as strDeviceId,
- b.org_id,
- c.`name` AS org_name,
- c.path AS org_path
- FROM
- ( SELECT rule_id, source_type FROM iot_alarm_rule_express GROUP BY source_type, rule_id ) a
- LEFT JOIN iot_alarm_rule_source b ON a.rule_id = b.rule_id AND a.source_type = b.source_type
- LEFT JOIN sys_org c ON b.org_id = c.id
- LEFT JOIN (select source_type,source_type_des from iot_alarm_system_field GROUP BY source_type,source_type_des) d on a.source_type = d.source_type
- where a.rule_id = #{ruleId}
- </select>
- <!--<select id="selectDeviceList" resultType="com.xunmei.iot.vo.alarm.IotAlarmRuleSourceDeviceVo">
- SELECT DISTINCT
- d.device_code AS deviceId,
- d.device_name AS deviceName,
- d.org_id AS orgId,
- d.org_path AS orgPath,
- b.short_name as org_name
- FROM
- iot_sensor d
- LEFT JOIN sys_org b ON d.org_id = b.id
- where 1=1
- <if test="param.includeSub == false">
- and d.org_id = #{param.orgId}
- </if>
- <if test="param.includeSub == true">
- and b.path like concat((select path from sys_org where id = #{param.orgId} ),'%')
- </if>
- and d.device_type = #{param.type}
- <if test="param.deviceName != null and param.deviceName != ''">
- and d.device_name like concat('%',#{param.deviceName},'%')
- </if>
- </select>-->
- <select id="selectDeviceList" resultType="com.xunmei.iot.vo.alarm.IotAlarmRuleSourceDeviceVo">
- SELECT DISTINCT
- concat(d.iot_token,'_',d.device_product,'_',d.device_code) AS deviceId,
- d.device_name AS deviceName,
- d.org_id AS orgId,
- d.org_path AS orgPath,
- b.short_name as org_name
- FROM
- iot_device_info d
- LEFT JOIN sys_org b ON d.org_id = b.id
- where 1=1
- <if test="param.includeSub == false">
- and d.org_id = #{param.orgId}
- </if>
- <if test="param.includeSub == true">
- and b.path like concat((select path from sys_org where id = #{param.orgId} ),'%')
- </if>
- and d.device_type = #{param.type}
- <if test="param.deviceName != null and param.deviceName != ''">
- and d.device_name like concat('%',#{param.deviceName},'%')
- </if>
- </select>
- <select id="getRuleSourceSize" resultType="com.xunmei.iot.vo.alarm.IotAlarmRuleSourceTotalVo">
- SELECT
- a.source_type,
- a.source_type_des AS source_name,
- IFNULL( b.source_size, 0 ) AS source_size
- FROM
- ( SELECT source_type, source_type_des FROM iot_alarm_system_field where enable = 1 and alarm_rule_property = 1 GROUP BY source_type, source_type_des ) a
- LEFT JOIN ( SELECT rule_id, source_type, count(*) source_size FROM iot_alarm_rule_source WHERE rule_id = #{ruleId} GROUP BY rule_id, source_type ) b ON a.source_type = b.source_type
- </select>
- </mapper>
|