统计报表-sql优化

This commit is contained in:
2025-07-09 14:36:11 +08:00
parent 84d77c2d33
commit 3eb8636e53
3 changed files with 7 additions and 50 deletions

View File

@ -464,10 +464,10 @@
WHERE p.site_id = #{siteId}
and p.device_id = #{deviceId}
<if test="startDate != null">
AND p.data_update_time &gt;= DATE(#{startDate})
AND p.data_update_time &gt;= #{startDate}
</if>
<if test="endDate != null">
AND p.data_update_time &lt; DATE(#{endDate})
AND p.data_update_time &lt; #{endDate}
</if>
</sql>
@ -487,19 +487,6 @@
</choose>
</sql>
<sql id="groupChooseFilter">
<choose>
<when test="dataType == 1">
,activePower
</when>
<when test="dataType == 2">
,reactivePower
</when>
<when test="dataType == 3">
,uCurrent,vCurrent,wCurrent
</when>
</choose>
</sql>
<select id="getPcsActivePowerByDay" parameterType="com.xzzn.ems.domain.vo.DateSearchRequest" resultType="com.xzzn.ems.domain.vo.PcsStatisListVo">
select CONCAT(t.date_month,'/',t.date_day) as statisDate,
<include refid="dataTypeChooseFilter"/>
@ -512,8 +499,6 @@
AND latest.max_update_time = t.data_update_time
and latest.date_month = t.date_month
and latest.date_day = t.date_day
group by statisDate
<include refid="groupChooseFilter"/>
order by statisDate desc
</select>
@ -528,8 +513,6 @@
AND latest.device_id = t.device_id
AND latest.max_update_time = t.data_update_time
and latest.date_month = t.date_month
group by statisDate
<include refid="groupChooseFilter"/>
order by statisDate desc
</select>
@ -543,8 +526,6 @@
) latest inner join ems_pcs_data t ON latest.site_id = t.site_id
AND latest.device_id = t.device_id
AND latest.max_update_time = t.data_update_time
group by statisDate
<include refid="groupChooseFilter"/>
order by statisDate desc
</select>
</mapper>