|
|
|
@@ -22,11 +22,27 @@ |
|
|
|
<if test=" null != id "> |
|
|
|
and `id` = #{id} |
|
|
|
</if> |
|
|
|
|
|
|
|
|
|
|
|
<if test=" null != tenantId "> |
|
|
|
and `tenant_id` = #{tenantId} |
|
|
|
</if> |
|
|
|
|
|
|
|
|
|
|
|
<if test=" null != meterId "> |
|
|
|
and `box_id` = #{meterId} |
|
|
|
</if> |
|
|
|
|
|
|
|
<if test=" null != meterId "> |
|
|
|
and `meter_id` = #{meterId} |
|
|
|
</if> |
|
|
|
|
|
|
|
<if test=" null != address "> |
|
|
|
and `address` = #{address} |
|
|
|
</if> |
|
|
|
|
|
|
|
<if test=" null != totalPower "> |
|
|
|
and `total_power` is not null |
|
|
|
</if> |
|
|
|
|
|
|
|
<if test=" null != ids "> |
|
|
|
and id in |
|
|
|
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> |
|
|
|
@@ -44,4 +60,57 @@ |
|
|
|
</select> |
|
|
|
|
|
|
|
|
|
|
|
<resultMap id="BaseResultMap" type="com.iformall.domain.po.KwMeterDataVo"> |
|
|
|
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> |
|
|
|
<result column="totalPower" jdbcType="INTEGER" property="totalPower"/> |
|
|
|
<result column="usedPower" jdbcType="INTEGER" property="usedPower"/> |
|
|
|
<result column="reportTime" jdbcType="TIMESTAMP" property="reportTime"/> |
|
|
|
<result column="recordStartTime" jdbcType="TIMESTAMP" property="recordStartTime"/> |
|
|
|
<result column="recordEndTime" jdbcType="TIMESTAMP" property="recordEndTime"/> |
|
|
|
</resultMap> |
|
|
|
|
|
|
|
<sql id="dynamicWhereConditionsVo"> |
|
|
|
where 1 = 1 |
|
|
|
|
|
|
|
<if test=" null != tenantId "> |
|
|
|
and `tenant_id` = #{tenantId} |
|
|
|
</if> |
|
|
|
|
|
|
|
<if test=" null != meterId "> |
|
|
|
and `box_id` = #{meterId} |
|
|
|
</if> |
|
|
|
|
|
|
|
<if test=" null != meterId "> |
|
|
|
and `meter_id` = #{meterId} |
|
|
|
</if> |
|
|
|
|
|
|
|
<if test=" null != address "> |
|
|
|
and `address` = #{address} |
|
|
|
</if> |
|
|
|
|
|
|
|
<if test=" null != startTime and null != endTime "> |
|
|
|
and `create_time` between #{startTime} and #{endTime} |
|
|
|
</if> |
|
|
|
|
|
|
|
</sql> |
|
|
|
|
|
|
|
|
|
|
|
<select id="findVoList" parameterType="com.iformall.domain.dto.KwMeterDataDto" resultMap="BaseResultMap"> |
|
|
|
select |
|
|
|
temp.tenant_id, |
|
|
|
date_format(temp.create_time, '%Y-%m-%d %H:00:00') as reportTime, |
|
|
|
max(temp.create_time) as recordStartTime, |
|
|
|
max(temp.sumPower) as totalPower |
|
|
|
from |
|
|
|
(SELECT tenant_id, |
|
|
|
sum(total_power) as sumPower, |
|
|
|
create_time, device_time |
|
|
|
FROM kw_meter_data |
|
|
|
where |
|
|
|
<include refid="dynamicWhereConditions"/> |
|
|
|
group by device_time) as temp |
|
|
|
group by reportTime |
|
|
|
order by reportTime desc |
|
|
|
</select> |
|
|
|
|
|
|
|
</mapper> |