Commit 146ce0af085c6aef80cf111c35cf788262b0f0ac

Authored by lijianfa_14810364212
1 parent 01eea2e0

DeviceMapper.findDevicesByDeviceTypeAndOrganizationId方法优化

... ... @@ -563,12 +563,18 @@
563 563 </foreach>
564 564 </select>
565 565 <select id="findDevicesByDeviceTypeAndOrganizationId" resultMap="deviceMap">
566   - SELECT
  566 + SELECT DISTINCT
567 567 <include refid="basicColumns"/>,dev.transport_type
568 568 FROM device ifd
569 569 left join device_profile dev on ifd.device_profile_id = dev.id
570 570 <if test="isSceneLinkage == true or isExcludeEdge == true or isExcludeCloud == true">
571   - LEFT JOIN relation re on re.to_id = ifd.id and re.from_type = 'EDGE' and( re.relation_type = 'ManagedByEdge' or re.relation_type = 'Contains')
  571 + LEFT JOIN relation re on re.to_id = ifd.id and re.from_type = 'EDGE' and
  572 + (
  573 + re.relation_type = 'ManagedByEdge'
  574 + <if test="isSceneLinkage == true">
  575 + or re.relation_type = 'Contains'
  576 + </if>
  577 + )
572 578 </if>
573 579 <!-- <if test="edgeId != null">-->
574 580 <!-- LEFT JOIN relation re on re.to_id = ifd.id-->
... ...