Kaynağa Gözat

统计报表

wangyangyang 4 yıl önce
ebeveyn
işleme
ea5b0f2d73

+ 7 - 6
sms_water/src/main/resources/mapper/DayReportMapper.xml

@@ -100,10 +100,11 @@
         a.month as "month" ,
         a.day as "day" ,
         a.hour as "hour" ,
-        a.parent_scene_id as "parentSceneId",
-        a.parent_scene_name as "parentSceneName"
+        b.parent_scene_id as "parentSceneId",
+        c.SCENE_NAME as "parentSceneName"
         FROM sms_day_report a
         inner join sms_device_parm b on a.DEVICE_ID = b.DEVICE_ID and a.ATTRIBUTE_ID=b.ATTRIBUTE_ID
+        inner join sms_scene c on b.PARENT_SCENE_ID=c.id
         <where>
             b.IS_REPORT=1
             <if test="dayReport.tenantId != null  and dayReport.tenantId != ''">and a.tenant_id =
@@ -112,12 +113,12 @@
             <if test="dayReport.year != null ">and a.year = #{dayReport.year}</if>
             <if test="dayReport.month != null ">and a.month = #{dayReport.month}</if>
             <if test="dayReport.day != null ">and a.day = #{dayReport.day}</if>
-            and a.parent_scene_id in
+            and b.parent_scene_id in
             <foreach collection="dayReport.parentSceneIds" item="dramaId" open="(" close=")" separator=",">
                 #{dramaId}
             </foreach>
         </where>
-        order by a.parent_scene_id,a.year,a.month,a.day,a.hour
+        order by b.parent_scene_id,a.year,a.month,a.day,a.hour
     </select>
     <select id="findAttributeList" resultType="com.huaxu.dto.ReportAttributeDto">
         SELECT tab.attributeName,tab.ATTRIBUTE_TYPE,min(tab.minValue) as "minValue",
@@ -143,7 +144,7 @@
         <if test="report.month != null ">and c.`MONTH`=#{report.month}</if>
         <if test="report.day != null ">and c.`DAY`=#{report.day}</if>
         <if test="report.hour != null ">and c.`HOUR`=#{report.hour}</if>
-        <if test="report.parentSceneId != null ">and c.PARENT_SCENE_ID=#{report.parentSceneId}</if>
+        <if test="report.parentSceneId != null ">and a.PARENT_SCENE_ID=#{report.parentSceneId}</if>
         ORDER BY a.SEQ
         ) as tab
         group by tab.attributeName,tab.ATTRIBUTE_TYPE
@@ -179,7 +180,7 @@
         <if test="report.year != null ">and c.`YEAR`=#{report.year}</if>
         <if test="report.month != null ">and c.`MONTH`=#{report.month}</if>
         <if test="report.day != null ">and c.`DAY`=#{report.day}</if>
-        <if test="report.parentSceneId != null ">and c.PARENT_SCENE_ID=#{report.parentSceneId}</if>
+        <if test="report.parentSceneId != null ">and a.PARENT_SCENE_ID=#{report.parentSceneId}</if>
         and (a.PARM_TYPE =3 or a.PARM_TYPE =4 or a.PARM_TYPE =5 or a.PARM_TYPE =6)) tab
         group by tab.year,tab.month,tab.day,tab.HOUR
         order by tab.year desc,tab.month desc,tab.day desc,tab.hour desc

+ 1 - 1
sms_water/src/main/resources/mapper/DeviceParmMapper.xml

@@ -203,7 +203,7 @@
         from
         (SELECT
         IFNULL(a.REMARK,b.`NAME`) AS "attributeName",
-        b.ATTRIBUTE_TYPE as "attributeType"
+        a.parm_type as "attributeType"
         FROM sms_device_parm a
         INNER JOIN sms_device_attribute b on a.ATTRIBUTE_ID=b.ID
         where

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

@@ -99,10 +99,11 @@
         a.year as "year" ,
         a.month as "month" ,
         a.day as "day" ,
-        a.parent_scene_id as "parentSceneId",
-        a.parent_scene_name as "parentSceneName"
+        b.parent_scene_id as "parentSceneId",
+        c.SCENE_NAME as "parentSceneName"
         FROM sms_month_report a
         inner join sms_device_parm b on a.DEVICE_ID = b.DEVICE_ID and a.ATTRIBUTE_ID=b.ATTRIBUTE_ID
+        inner join sms_scene c on b.PARENT_SCENE_ID=c.id
         <where>
             b.IS_REPORT=1
             <if test="monthReport.tenantId != null  and monthReport.tenantId != ''">and a.tenant_id =
@@ -110,12 +111,12 @@
             </if>
             <if test="monthReport.year != null ">and a.year = #{monthReport.year}</if>
             <if test="monthReport.month != null ">and a.month = #{monthReport.month}</if>
-            and a.parent_scene_id in
+            and b.parent_scene_id in
             <foreach collection = "monthReport.parentSceneIds" item = "dramaId" open = "(" close = ")" separator = "," >
                 #{dramaId}
             </foreach>
         </where>
-        order by  a.parent_scene_id,a.year,a.month,a.day
+        order by  b.parent_scene_id,a.year,a.month,a.day
     </select>
     <select id="findAttributeList" resultType="com.huaxu.dto.ReportAttributeDto">
         SELECT tab.attributeName,tab.ATTRIBUTE_TYPE,min(tab.minValue) as "minValue",
@@ -140,7 +141,7 @@
         <if test="report.year != null ">and c.`YEAR`=#{report.year}</if>
         <if test="report.month != null ">and c.`MONTH`=#{report.month}</if>
         <if test="report.day != null ">and c.`DAY`=#{report.day}</if>
-        <if test="report.parentSceneId != null ">and c.PARENT_SCENE_ID=#{report.parentSceneId}</if>
+        <if test="report.parentSceneId != null ">and a.PARENT_SCENE_ID=#{report.parentSceneId}</if>
         ORDER BY a.SEQ
         ) as tab
         group by tab.attributeName,tab.ATTRIBUTE_TYPE

+ 7 - 6
sms_water/src/main/resources/mapper/YearReportMapper.xml

@@ -98,22 +98,23 @@
         a.tenant_id as "tenantId" ,
         a.year as "year" ,
         a.month as "month" ,
-        a.parent_scene_id as "parentSceneId",
-        a.parent_scene_name as "parentSceneName"
+        b.parent_scene_id as "parentSceneId",
+        c.SCENE_NAME as "parentSceneName"
         FROM sms_year_report a
         inner join sms_device_parm b on a.DEVICE_ID = b.DEVICE_ID and a.ATTRIBUTE_ID=b.ATTRIBUTE_ID
+        inner join sms_scene c on b.PARENT_SCENE_ID=c.id
         <where>
             b.IS_REPORT=1
             <if test="yearReport.tenantId != null  and yearReport.tenantId != ''">and a.tenant_id =
                 #{yearReport.tenantId}
             </if>
             <if test="yearReport.year != null ">and a.year = #{yearReport.year}</if>
-            and a.parent_scene_id in
+            and b.parent_scene_id in
             <foreach collection = "yearReport.parentSceneIds" item = "dramaId" open = "(" close = ")" separator = "," >
                 #{dramaId}
             </foreach>
         </where>
-        order by  a.parent_scene_id,a.year,a.month
+        order by  b.parent_scene_id,a.year,a.month
     </select>
     <select id="findAttributeList" resultType="com.huaxu.dto.ReportAttributeDto">
         SELECT tab.attributeName,tab.ATTRIBUTE_TYPE,min(tab.minValue) as "minValue",
@@ -137,7 +138,7 @@
         </if>
         <if test="report.year != null ">and c.`YEAR`=#{report.year}</if>
         <if test="report.month != null ">and c.`MONTH`=#{report.month}</if>
-        <if test="report.parentSceneId != null ">and c.PARENT_SCENE_ID=#{report.parentSceneId}</if>
+        <if test="report.parentSceneId != null ">and a.PARENT_SCENE_ID=#{report.parentSceneId}</if>
         ORDER BY a.SEQ
         ) as tab
         group by tab.attributeName,tab.ATTRIBUTE_TYPE
@@ -172,7 +173,7 @@
         </if>
         <if test="report.year != null ">and c.`YEAR`=#{report.year}</if>
         <if test="report.month != null ">and c.`MONTH`=#{report.month}</if>
-        <if test="report.parentSceneId != null ">and c.PARENT_SCENE_ID=#{report.parentSceneId}</if>
+        <if test="report.parentSceneId != null ">and a.PARENT_SCENE_ID=#{report.parentSceneId}</if>
         and (a.PARM_TYPE =3 or a.PARM_TYPE =4 or a.PARM_TYPE =5 or a.PARM_TYPE =6)) tab
         group by tab.year,tab.month
         order by tab.year desc,tab.month desc