wangbo 3 years ago
parent
commit
7febe8b328
1 changed files with 6 additions and 5 deletions
  1. 6 5
      sms_water/src/main/resources/mapper/SceneMapper.xml

+ 6 - 5
sms_water/src/main/resources/mapper/SceneMapper.xml

@@ -471,11 +471,12 @@
             and SCENE_TYPE_NAME in('水源','水厂','泵站')
         </where>
         group by a.scene_name, a.id, sort
+
         union all
 
-        select sum(amount) amount, id, GROUP_CONCAT(scene_id SEPARATOR ',') scene_id, name, sort
-        from(
-            select count(1) amount, d.id,c.PARENT_SCENE_ID scene_id, d.device_name name,1 sort
+        select count(*) amount, id, GROUP_CONCAT(DISTINCT scene_id SEPARATOR ',') scene_id, name,1 sort from
+        (
+            select d.id,c.PARENT_SCENE_ID scene_id, d.device_name name
             from sms_alarm_details c
             INNER JOIN sms_device d on c.DEVICE_ID=d.ID
             INNER JOIN sms_scene a on  c.PARENT_SCENE_ID=a.ID
@@ -516,8 +517,8 @@
                 and c.alarm_start_time &lt; date_format(#{endDate,jdbcType=VARCHAR},'%Y-%m-%d')
                 and SCENE_TYPE_NAME='管网'
             </where>
-            group by d.device_name, d.id, c.scene_id, sort)
-            ) t
+            ) t1
+            group by name, id, scene_id, sort ) t
             order by amount desc
     </select>