wangbo 3 years ago
parent
commit
42bdc07b2e
1 changed files with 11 additions and 11 deletions
  1. 11 11
      sms_water/src/main/resources/mapper/SceneMapper.xml

+ 11 - 11
sms_water/src/main/resources/mapper/SceneMapper.xml

@@ -466,8 +466,8 @@
                     and (a.DEPT_ORG_ID is null or a.DEPT_ORG_ID =0)
                 </if>
             </if>
-            and c.date_create &gt;= date_format(#{startDate,jdbcType=VARCHAR},'%Y-%m-%d')
-            and c.date_create &lt; date_format(#{endDate,jdbcType=VARCHAR},'%Y-%m-%d')
+            and c.alarm_start_time &gt;= date_format(#{startDate,jdbcType=VARCHAR},'%Y-%m-%d')
+            and c.alarm_start_time &lt; date_format(#{endDate,jdbcType=VARCHAR},'%Y-%m-%d')
             and SCENE_TYPE_NAME in('水源','水厂','泵站')
         </where>
         group by a.scene_name, a.id, sort
@@ -477,7 +477,7 @@
         select count(1) amount, d.id,c.scene_id, d.device_name name,1 sort
         from sms_alarm_details c
         INNER JOIN sms_device d on c.DEVICE_ID=d.ID
-        INNER JOIN sms_scene a on  c.SCENE_ID=a.ID
+        INNER JOIN sms_scene a on  c.PARENT_SCENE_ID=a.ID
         INNER JOIN sms_scene_type b on a.SCENE_TYPE_ID=b.ID
         <where>
             a.PARENT_SCENE_ID=0 and a.STATUS=1
@@ -511,8 +511,8 @@
                     and (a.DEPT_ORG_ID is null or a.DEPT_ORG_ID =0)
                 </if>
             </if>
-            and c.date_create &gt;= date_format(#{startDate,jdbcType=VARCHAR},'%Y-%m-%d')
-            and c.date_create &lt; date_format(#{endDate,jdbcType=VARCHAR},'%Y-%m-%d')
+            and c.alarm_start_time &gt;= date_format(#{startDate,jdbcType=VARCHAR},'%Y-%m-%d')
+            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
@@ -530,8 +530,8 @@
                 from sms_alarm_details c
                 where c.device_id = #{scene.id}
             </if>
-            and c.date_create &gt;= date_format(#{startDate,jdbcType=VARCHAR},'%Y-%m-%d')
-            and c.date_create &lt; date_format(#{endDate,jdbcType=VARCHAR},'%Y-%m-%d')
+            and c.alarm_start_time &gt;= date_format(#{startDate,jdbcType=VARCHAR},'%Y-%m-%d')
+            and c.alarm_start_time &lt; date_format(#{endDate,jdbcType=VARCHAR},'%Y-%m-%d')
             group by DATE_FORMAT(c.DATE_CREATE,'%Y-%m-%d')
     </select>
 
@@ -564,14 +564,14 @@
                             INNER JOIN sms_alarm_details c on c.PARENT_SCENE_ID=a.ID
                             INNER JOIN sms_device_attribute e on e.ID = c.ATTRIBUTE_ID and e.STATUS=1
                             LEFT JOIN sms_device_parm d on d.ATTRIBUTE_ID = c.ATTRIBUTE_ID and d.DEVICE_ID=c.DEVICE_ID and d.TENANT_ID=c.TENANT_ID and d.PARENT_SCENE_ID=c.PARENT_SCENE_ID and d.STATUS=1
-                            INNER JOIN sms_alarm_setting f on f.device_id = c.device_id and f.SCENE_ID=c.SCENE_ID and f.STATUS=1
+                            INNER JOIN sms_alarm_setting f on f.device_id = c.device_id and f.SCENE_ID=c.SCENE_ID  and f.ATTRIBUTE_ID=c.ATTRIBUTE_ID and f.STATUS=1
                             where a.ID = #{scene.id}
                         </if>
                         <if test="sort == 1">
                             from sms_alarm_details c
                             INNER JOIN sms_device_attribute e on e.ID = c.ATTRIBUTE_ID and e.STATUS=1
                             LEFT JOIN sms_device_parm d on d.ATTRIBUTE_ID = c.ATTRIBUTE_ID and d.DEVICE_ID=c.DEVICE_ID and d.TENANT_ID=c.TENANT_ID and d.PARENT_SCENE_ID=c.PARENT_SCENE_ID and d.STATUS=1
-                            INNER JOIN sms_alarm_setting f on f.device_id = c.device_id and f.SCENE_ID=c.SCENE_ID and f.STATUS=1
+                            INNER JOIN sms_alarm_setting f on f.device_id = c.device_id and f.SCENE_ID=c.SCENE_ID and f.ATTRIBUTE_ID=c.ATTRIBUTE_ID and f.STATUS=1
                             where c.device_id = #{scene.id}
                         </if>
                         and c.date_create &gt;= date_format(#{startDate,jdbcType=VARCHAR},'%Y-%m-%d')
@@ -591,8 +591,8 @@
                         from sms_alarm_details c
                         where c.device_id = #{scene.id} and alarm_type='状态报警'
                     </if>
-                    and c.date_create &gt;= date_format(#{startDate,jdbcType=VARCHAR},'%Y-%m-%d')
-                    and c.date_create &lt; date_format(#{endDate,jdbcType=VARCHAR},'%Y-%m-%d')
+                    and c.alarm_start_time &gt;= date_format(#{startDate,jdbcType=VARCHAR},'%Y-%m-%d')
+                    and c.alarm_start_time &lt; date_format(#{endDate,jdbcType=VARCHAR},'%Y-%m-%d')
                 ) t1
                 group by label
             ) t2