feat(ems): 新增能耗统计分析功能
- 新增环比分析、同比分析接口与实现 - 支持按设备、能源类型、区域(含子区域)过滤统计 - 实现日、周、月、年维度的数据汇总与对比计算 - 扩展 Mapper 层支持带设备列表的时间区间查询 - 新增多个 VO 类用于封装分析结果数据结构 - 完善 Controller 接口接收过滤参数并调用服务层 -优化区域递归查找逻辑以支持层级结构查询 - 提供工具方法处理空值与比率计算 - 添加新的 BO 类用于传递查询与范围参数 - 更新配置文件注释但未启用新路由规则
This commit is contained in:
@@ -48,4 +48,57 @@
|
||||
month
|
||||
</select>
|
||||
|
||||
<!-- 过滤版:按设备集合(energyTypeId/locationId会先解析出设备集合) -->
|
||||
<select id="selectDailySummaryWithMeters" parameterType="com.klp.ems.domain.bo.TimeRangeWithMetersBo" resultType="com.klp.ems.domain.vo.SummaryDailyVo">
|
||||
SELECT
|
||||
DATE(end_time) AS day,
|
||||
SUM(consumption) AS totalConsumption
|
||||
FROM ems_energy_consumption
|
||||
WHERE DATE(end_time) BETWEEN #{start} AND #{end}
|
||||
<if test="meterIds != null and meterIds.size() > 0">
|
||||
AND meter_id IN
|
||||
<foreach collection="meterIds" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
GROUP BY DATE(end_time)
|
||||
ORDER BY day
|
||||
</select>
|
||||
|
||||
<select id="selectMonthlySummaryWithMeters" parameterType="com.klp.ems.domain.bo.TimeRangeWithMetersBo" resultType="com.klp.ems.domain.vo.SummaryMonthlyVo">
|
||||
SELECT
|
||||
DATE_FORMAT(end_time, '%Y-%m') AS month,
|
||||
SUM(consumption) AS totalConsumption
|
||||
FROM ems_energy_consumption
|
||||
WHERE DATE_FORMAT(end_time, '%Y') = #{start}
|
||||
<if test="meterIds != null and meterIds.size() > 0">
|
||||
AND meter_id IN
|
||||
<foreach collection="meterIds" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
GROUP BY DATE_FORMAT(end_time, '%Y-%m')
|
||||
ORDER BY month
|
||||
</select>
|
||||
|
||||
<select id="sumConsumptionBetween" resultType="java.lang.Double">
|
||||
SELECT IFNULL(SUM(consumption), 0)
|
||||
FROM ems_energy_consumption
|
||||
WHERE end_time >= #{startTime}
|
||||
AND end_time <= #{endTime}
|
||||
</select>
|
||||
|
||||
<select id="sumConsumptionBetweenWithMeters" parameterType="com.klp.ems.domain.bo.TimeRangeWithMetersBo" resultType="java.lang.Double">
|
||||
SELECT IFNULL(SUM(consumption), 0)
|
||||
FROM ems_energy_consumption
|
||||
WHERE end_time >= #{start}
|
||||
AND end_time <= #{end}
|
||||
<if test="meterIds != null and meterIds.size() > 0">
|
||||
AND meter_id IN
|
||||
<foreach collection="meterIds" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user