l3能源成本分摊(部分完成留存)
This commit is contained in:
@@ -101,4 +101,66 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectLatestBefore" resultMap="EmsEnergyConsumptionResult">
|
||||
SELECT *
|
||||
FROM ems_energy_consumption
|
||||
WHERE meter_id = #{meterId}
|
||||
AND end_time <= #{endTime}
|
||||
ORDER BY end_time DESC
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectOverlapRange" resultMap="EmsEnergyConsumptionResult">
|
||||
SELECT *
|
||||
FROM ems_energy_consumption
|
||||
WHERE meter_id = #{meterId}
|
||||
AND end_time >= #{startTime}
|
||||
AND start_time <= #{endTime}
|
||||
ORDER BY start_time ASC
|
||||
</select>
|
||||
|
||||
<select id="selectCoveringRange" resultMap="EmsEnergyConsumptionResult">
|
||||
SELECT *
|
||||
FROM ems_energy_consumption
|
||||
WHERE meter_id = #{meterId}
|
||||
AND start_time <= #{startTime}
|
||||
AND end_time >= #{endTime}
|
||||
ORDER BY start_time ASC
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectLatestTwoReadings" resultMap="EmsEnergyConsumptionResult">
|
||||
SELECT *
|
||||
FROM ems_energy_consumption
|
||||
WHERE meter_id = #{meterId}
|
||||
ORDER BY end_time DESC
|
||||
LIMIT 2
|
||||
</select>
|
||||
|
||||
<!-- 统计查询 -->
|
||||
<select id="getStatistics" parameterType="com.klp.ems.domain.bo.EmsEnergyConsumptionBo" resultType="java.util.Map">
|
||||
SELECT
|
||||
COUNT(*) AS totalCount,
|
||||
IFNULL(SUM(consumption), 0) AS totalConsumption,
|
||||
IFNULL(AVG(consumption), 0) AS avgConsumption,
|
||||
IFNULL(MAX(consumption), 0) AS maxConsumption,
|
||||
IFNULL(MIN(consumption), 0) AS minConsumption
|
||||
FROM ems_energy_consumption
|
||||
WHERE 1=1
|
||||
<if test="meterId != null">
|
||||
AND meter_id = #{meterId}
|
||||
</if>
|
||||
<if test="energyTypeId != null">
|
||||
AND meter_id IN (
|
||||
SELECT meter_id FROM ems_meter WHERE energy_type_id = #{energyTypeId}
|
||||
)
|
||||
</if>
|
||||
<if test="startTime != null">
|
||||
AND start_time >= #{startTime}
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
AND end_time <= #{endTime}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user