You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
249 lines
12 KiB
249 lines
12 KiB
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.psdc.mapper.PsdcStatisticsDayMapper">
|
|
<resultMap type="com.psdc.entity.PsdcStatisticsDay" id="PsdcStatisticsDayMap">
|
|
<result property="dayId" column="day_id" />
|
|
<result property="dayDate" column="day_date" />
|
|
<result property="deviceId" column="device_id" />
|
|
<result property="deviceName" column="device_name" />
|
|
<result property="hour00" column="hour_00" />
|
|
<result property="hour01" column="hour_01" />
|
|
<result property="hour02" column="hour_02" />
|
|
<result property="hour03" column="hour_03" />
|
|
<result property="hour04" column="hour_04" />
|
|
<result property="hour05" column="hour_05" />
|
|
<result property="hour06" column="hour_06" />
|
|
<result property="hour07" column="hour_07" />
|
|
<result property="hour08" column="hour_08" />
|
|
<result property="hour09" column="hour_09" />
|
|
<result property="hour10" column="hour_10" />
|
|
<result property="hour11" column="hour_11" />
|
|
<result property="hour12" column="hour_12" />
|
|
<result property="hour13" column="hour_13" />
|
|
<result property="hour14" column="hour_14" />
|
|
<result property="hour15" column="hour_15" />
|
|
<result property="hour16" column="hour_16" />
|
|
<result property="hour17" column="hour_17" />
|
|
<result property="hour18" column="hour_18" />
|
|
<result property="hour19" column="hour_19" />
|
|
<result property="hour20" column="hour_20" />
|
|
<result property="hour21" column="hour_21" />
|
|
<result property="hour22" column="hour_22" />
|
|
<result property="hour23" column="hour_23" />
|
|
</resultMap>
|
|
|
|
<!-- 通过ID查询单条数据 -->
|
|
<select id="queryById" resultMap="PsdcStatisticsDayMap">
|
|
select
|
|
day_id,day_date,device_id,device_name,hour_00,hour_01,hour_02,hour_03,hour_04,hour_05,hour_06,hour_07,hour_08,hour_09,hour_10,hour_11,hour_12,hour_13,hour_14,hour_15,hour_16,hour_17,hour_18,hour_19,hour_20,hour_21,hour_22,hour_23
|
|
from psdc_statistics_day
|
|
where day_id = #{dayId}
|
|
</select>
|
|
|
|
<!--分页查询指定行数据-->
|
|
<select id="queryAllByLimit" resultMap="PsdcStatisticsDayMap">
|
|
Select
|
|
day_id,day_date,pd.device_id,pd.device_name,hour_00,hour_01,hour_02,hour_03,hour_04,hour_05,hour_06,hour_07,hour_08,hour_09,hour_10,hour_11,hour_12,hour_13,hour_14,hour_15,hour_16,hour_17,hour_18,hour_19,hour_20,hour_21,hour_22,hour_23
|
|
From psdc_statistics_day psd Left Join psdc_device pd On pd.device_id = psd.device_id
|
|
<where>
|
|
<if test="deviceId != null and deviceId != ''">
|
|
And psd.device_id = #{deviceId}
|
|
</if>
|
|
<if test="startTime != null and startTime != ''"><!-- 开始时间检索 -->
|
|
And date_format(day_date,'%Y-%m-%d') >= #{startTime}
|
|
</if>
|
|
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
|
|
And date_format(day_date,'%Y-%m-%d') <= #{endTime}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
|
|
<!--新增数据-->
|
|
<insert id="insert" >
|
|
insert into psdc_statistics_day(day_id,day_date,device_id,device_name,hour_00,hour_01,hour_02,hour_03,hour_04,hour_05,hour_06,hour_07,hour_08,hour_09,hour_10,hour_11,hour_12,hour_13,hour_14,hour_15,hour_16,hour_17,hour_18,hour_19,hour_20,hour_21,hour_22,hour_23)
|
|
values (#{dayId},#{dayDate},#{deviceId},#{deviceName},#{hour00},#{hour01},#{hour02},#{hour03},#{hour04},#{hour05},#{hour06},#{hour07},#{hour08},#{hour09},#{hour10},#{hour11},#{hour12},#{hour13},#{hour14},#{hour15},#{hour16},#{hour17},#{hour18},#{hour19},#{hour20},#{hour21},#{hour22},#{hour23})
|
|
</insert>
|
|
|
|
|
|
<update id="updateTodayDevEnergy">
|
|
Update psdc_statistics_day Set ${valNo} = #{powerValue}
|
|
Where device_id = #{devId} And day_date = #{samDate}
|
|
</update>
|
|
|
|
|
|
<insert id="insertDay" >
|
|
Insert into psdc_statistics_day(
|
|
day_date,
|
|
device_id,
|
|
device_name
|
|
<if test="hour00 != null and hour00 != 0">,hour_00,</if>
|
|
<if test="hour01 != null and hour01 != 0">hour_01,</if>
|
|
<if test="hour02 != null and hour02 != 0">hour_02,</if>
|
|
<if test="hour03 != null and hour03 != 0">hour_03,</if>
|
|
<if test="hour04 != null and hour04 != 0">hour_04,</if>
|
|
<if test="hour05 != null and hour05 != 0">hour_05,</if>
|
|
<if test="hour06 != null and hour06 != 0">hour_06,</if>
|
|
<if test="hour07 != null and hour07 != 0">hour_07,</if>
|
|
<if test="hour08 != null and hour08 != 0">hour_08,</if>
|
|
<if test="hour09 != null and hour09 != 0">hour_09,</if>
|
|
<if test="hour10 != null and hour10 != 0">hour_10,</if>
|
|
<if test="hour11 != null and hour11 != 0">hour_11,</if>
|
|
<if test="hour12 != null and hour12 != 0">hour_12,</if>
|
|
<if test="hour13 != null and hour13 != 0">hour_13,</if>
|
|
<if test="hour14 != null and hour14 != 0">hour_14,</if>
|
|
<if test="hour15 != null and hour15 != 0">hour_15,</if>
|
|
<if test="hour16 != null and hour16 != 0">hour_16,</if>
|
|
<if test="hour17 != null and hour17 != 0">hour_17,</if>
|
|
<if test="hour18 != null and hour18 != 0">hour_18,</if>
|
|
<if test="hour19 != null and hour19 != 0">hour_19,</if>
|
|
<if test="hour20 != null and hour20 != 0">hour_20,</if>
|
|
<if test="hour21 != null and hour21 != 0">hour_21,</if>
|
|
<if test="hour22 != null and hour22 != 0">hour_22,</if>
|
|
<if test="hour23 != null and hour23 != 0">hour_23,</if>
|
|
)values(
|
|
#{dayDate},
|
|
#{deviceId},
|
|
#{deviceName}
|
|
<if test="hour00 != null and hour00 != 0">,#{hour00},</if>
|
|
<if test="hour01 != null and hour01 != 0">#{hour01},</if>
|
|
<if test="hour02 != null and hour02 != 0">#{hour02},</if>
|
|
<if test="hour03 != null and hour03 != 0">#{hour03},</if>
|
|
<if test="hour04 != null and hour04 != 0">#{hour04},</if>
|
|
<if test="hour05 != null and hour05 != 0">#{hour05},</if>
|
|
<if test="hour06 != null and hour06 != 0">#{hour06},</if>
|
|
<if test="hour07 != null and hour07 != 0">#{hour07},</if>
|
|
<if test="hour08 != null and hour08 != 0">#{hour08},</if>
|
|
<if test="hour09 != null and hour09 != 0">#{hour09},</if>
|
|
<if test="hour10 != null and hour10 != 0">#{hour10},</if>
|
|
<if test="hour11 != null and hour11 != 0">#{hour11},</if>
|
|
<if test="hour12 != null and hour12 != 0">#{hour12},</if>
|
|
<if test="hour13 != null and hour13 != 0">#{hour13},</if>
|
|
<if test="hour14 != null and hour14 != 0">#{hour14},</if>
|
|
<if test="hour15 != null and hour15 != 0">#{hour15},</if>
|
|
<if test="hour16 != null and hour16 != 0">#{hour16},</if>
|
|
<if test="hour17 != null and hour17 != 0">#{hour17},</if>
|
|
<if test="hour18 != null and hour18 != 0">#{hour18},</if>
|
|
<if test="hour19 != null and hour19 != 0">#{hour19},</if>
|
|
<if test="hour20 != null and hour20 != 0">#{hour20},</if>
|
|
<if test="hour21 != null and hour21 != 0">#{hour21},</if>
|
|
<if test="hour22 != null and hour22 != 0">#{hour22},</if>
|
|
<if test="hour23 != null and hour23 != 0">#{hour23},</if>
|
|
)
|
|
</insert>
|
|
|
|
|
|
<!-- 更新数据 -->
|
|
<update id="update">
|
|
update psdc_statistics_day
|
|
<set>
|
|
<if test="day_date != null and day_date != ''">
|
|
day_date = #{dayDate},
|
|
</if>
|
|
<if test="deviceId != null and deviceId != ''">
|
|
device_id = #{deviceId},
|
|
</if>
|
|
<if test="deviceName != null and deviceName != ''">
|
|
device_name = #{deviceName},
|
|
</if>
|
|
<if test="hour00 != null and hour00 != ''">
|
|
hour_00 = #{hour00},
|
|
</if>
|
|
<if test="hour01 != null and hour01 != ''">
|
|
hour_01 = #{hour01},
|
|
</if>
|
|
<if test="hour02 != null and hour02 != ''">
|
|
hour_02 = #{hour02},
|
|
</if>
|
|
<if test="hour03 != null and hour03 != ''">
|
|
hour_03 = #{hour03},
|
|
</if>
|
|
<if test="hour04 != null and hour04 != ''">
|
|
hour_04 = #{hour04},
|
|
</if>
|
|
<if test="hour05 != null and hour05 != ''">
|
|
hour_05 = #{hour05},
|
|
</if>
|
|
<if test="hour06 != null and hour06 != ''">
|
|
hour_06 = #{hour06},
|
|
</if>
|
|
<if test="hour07 != null and hour07 != ''">
|
|
hour_07 = #{hour07},
|
|
</if>
|
|
<if test="hour08 != null and hour08 != ''">
|
|
hour_08 = #{hour08},
|
|
</if>
|
|
<if test="hour09 != null and hour09 != ''">
|
|
hour_09 = #{hour09},
|
|
</if>
|
|
<if test="hour10 != null and hour10 != ''">
|
|
hour_10 = #{hour10},
|
|
</if>
|
|
<if test="hour11 != null and hour11 != ''">
|
|
hour_11 = #{hour11},
|
|
</if>
|
|
<if test="hour12 != null and hour12 != ''">
|
|
hour_12 = #{hour12},
|
|
</if>
|
|
<if test="hour13 != null and hour13 != ''">
|
|
hour_13 = #{hour13},
|
|
</if>
|
|
<if test="hour14 != null and hour14 != ''">
|
|
hour_14 = #{hour14},
|
|
</if>
|
|
<if test="hour15 != null and hour15 != ''">
|
|
hour_15 = #{hour15},
|
|
</if>
|
|
<if test="hour16 != null and hour16 != ''">
|
|
hour_16 = #{hour16},
|
|
</if>
|
|
<if test="hour17 != null and hour17 != ''">
|
|
hour_17 = #{hour17},
|
|
</if>
|
|
<if test="hour18 != null and hour18 != ''">
|
|
hour_18 = #{hour18},
|
|
</if>
|
|
<if test="hour19 != null and hour19 != ''">
|
|
hour_19 = #{hour19},
|
|
</if>
|
|
<if test="hour20 != null and hour20 != ''">
|
|
hour_20 = #{hour20},
|
|
</if>
|
|
<if test="hour21 != null and hour21 != ''">
|
|
hour_21 = #{hour21},
|
|
</if>
|
|
<if test="hour22 != null and hour22 != ''">
|
|
hour_22 = #{hour22},
|
|
</if>
|
|
<if test="hour23 != null and hour23 != ''">
|
|
hour_23 = #{hour23},
|
|
</if>
|
|
</set>
|
|
where day_id = #{dayId}
|
|
</update>
|
|
|
|
<!--通过主键删除-->
|
|
<delete id="deleteById">
|
|
delete from psdc_statistics_day where day_id = #{dayId}
|
|
</delete>
|
|
|
|
<!-- 计算一行数据总和-->
|
|
<select id="queryOneLineSum" resultType="double">
|
|
select ifnull(hour_00,0.0) + ifnull(hour_01,0.0) + ifnull(hour_02,0.0) + ifnull(hour_03,0.0) + ifnull(hour_04,0.0) +
|
|
ifnull(hour_05,0.0) + ifnull(hour_06,0.0) + ifnull(hour_07,0.0) + ifnull(hour_08,0.0) + ifnull(hour_09,0.0) +
|
|
ifnull(hour_10,0.0) + ifnull(hour_11,0.0) + ifnull(hour_12,0.0) + ifnull(hour_13,0.0) + ifnull(hour_14,0.0) +
|
|
ifnull(hour_15,0.0) + ifnull(hour_16,0.0) + ifnull(hour_17,0.0) + ifnull(hour_18,0.0) + ifnull(hour_19,0.0) +
|
|
ifnull(hour_20,0.0) + ifnull(hour_21,0.0) + ifnull(hour_22,0.0) + ifnull(hour_23,0.0) as total
|
|
from psdc_statistics_day where device_id = #{deviceId} and date_format(day_date,'%Y-%m-d') = #{datetime}
|
|
</select>
|
|
|
|
<select id="count" resultType="java.lang.Integer">
|
|
Select count(1) From psdc_statistics_day
|
|
Where device_id = #{deviceId} And day_date = #{datetime}
|
|
</select>
|
|
|
|
<update id="updateDay">
|
|
Update psdc_statistics_day Set ${valNo} = #{powerValue}
|
|
Where device_id = #{devId} And date_format(day_date,'%Y-%m-d') = #{samDate}
|
|
</update>
|
|
</mapper> |