Commit 6d219a41b8f6783cf5c337f0f92581cba0483567
Merge branch 'fix/teambition/2024-10-28' into 'master_dev'
DeviceMapper.findDevicesByDeviceTypeAndOrganizationId方法优化 See merge request yunteng/thingskit!458
Showing
1 changed file
with
8 additions
and
2 deletions
@@ -563,12 +563,18 @@ | @@ -563,12 +563,18 @@ | ||
563 | </foreach> | 563 | </foreach> |
564 | </select> | 564 | </select> |
565 | <select id="findDevicesByDeviceTypeAndOrganizationId" resultMap="deviceMap"> | 565 | <select id="findDevicesByDeviceTypeAndOrganizationId" resultMap="deviceMap"> |
566 | - SELECT | 566 | + SELECT DISTINCT |
567 | <include refid="basicColumns"/>,dev.transport_type | 567 | <include refid="basicColumns"/>,dev.transport_type |
568 | FROM device ifd | 568 | FROM device ifd |
569 | left join device_profile dev on ifd.device_profile_id = dev.id | 569 | left join device_profile dev on ifd.device_profile_id = dev.id |
570 | <if test="isSceneLinkage == true or isExcludeEdge == true or isExcludeCloud == true"> | 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 | </if> | 578 | </if> |
573 | <!-- <if test="edgeId != null">--> | 579 | <!-- <if test="edgeId != null">--> |
574 | <!-- LEFT JOIN relation re on re.to_id = ifd.id--> | 580 | <!-- LEFT JOIN relation re on re.to_id = ifd.id--> |