<select id="getByCondition" resultMap="BaseResultMap">
SELECT
sm.id id,
sm.scene_id scene_id,
sm.name name,
sm.unit unit,
sm.relation_id relation_id,
sm.relation_type relation_type,
sm.icon icon,
sm.description description,
sm.device_name device_name,
sm.create_time create_time,
sm.last_update_time last_update_time,
sm.last_update_account last_update_account
FROM sm_monitorpoint sm
LEFT JOIN dm_virtualdeviceparam dvp ON sm.relation_id=dvp.id
LEFT JOIN dm_virtualdevice dv ON dv.id=dvp.device_id
WHERE relation_type=#{relationType}
<if test="deviceTypeList!=null and deviceTypeList.size>0">
AND dv.device_type_id IN
<foreach collection="deviceTypeList" separator="," open="(" close=")" index="index">
#{deviceTypeList[${index}]}
</foreach>
</if>
<if test="sceneIdList!=null and sceneIdList.size>0">
AND sm.scene_id IN
<foreach collection="sceneIdList" separator="," open="(" close=")" index="index">
#{sceneIdList[${index}]}
</foreach>
</if>
<if test="keywords!=null and keywords!=''">
AND (sm.name LIKE CONCAT('%',#{keywords},'%'))
</if>
</select>
SELECT
sm.id id,
sm.scene_id scene_id,
sm.name name,
sm.unit unit,
sm.relation_id relation_id,
sm.relation_type relation_type,
sm.icon icon,
sm.description description,
sm.device_name device_name,
sm.create_time create_time,
sm.last_update_time last_update_time,
sm.last_update_account last_update_account
FROM sm_monitorpoint sm
LEFT JOIN dm_virtualdeviceparam dvp ON sm.relation_id=dvp.id
LEFT JOIN dm_virtualdevice dv ON dv.id=dvp.device_id
WHERE relation_type=#{relationType}
<if test="deviceTypeList!=null and deviceTypeList.size>0">
AND dv.device_type_id IN
<foreach collection="deviceTypeList" separator="," open="(" close=")" index="index">
#{deviceTypeList[${index}]}
</foreach>
</if>
<if test="sceneIdList!=null and sceneIdList.size>0">
AND sm.scene_id IN
<foreach collection="sceneIdList" separator="," open="(" close=")" index="index">
#{sceneIdList[${index}]}
</foreach>
</if>
<if test="keywords!=null and keywords!=''">
AND (sm.name LIKE CONCAT('%',#{keywords},'%'))
</if>
</select>