场景模型测试工具
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.
 
 
 
 
 
scmy/psdc-business/src/main/resources/mapper/business/PsdcStatisticsMonthMapper.xml

332 lines
14 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.PsdcStatisticsMonthMapper">
<resultMap type="com.psdc.entity.PsdcStatisticsMonth" id="PsdcStatisticsMonthMap">
<result property="monthId" column="month_id"/>
<result property="deviceId" column="device_id"/>
<result property="deviceName" column="device_name"/>
<result property="monthDate" column="month_date"/>
<result property="day01" column="day_01"/>
<result property="day02" column="day_02"/>
<result property="day03" column="day_03"/>
<result property="day04" column="day_04"/>
<result property="day05" column="day_05"/>
<result property="day06" column="day_06"/>
<result property="day07" column="day_07"/>
<result property="day08" column="day_08"/>
<result property="day09" column="day_09"/>
<result property="day10" column="day_10"/>
<result property="day11" column="day_11"/>
<result property="day12" column="day_12"/>
<result property="day13" column="day_13"/>
<result property="day14" column="day_14"/>
<result property="day15" column="day_15"/>
<result property="day16" column="day_16"/>
<result property="day17" column="day_17"/>
<result property="day18" column="day_18"/>
<result property="day19" column="day_19"/>
<result property="day20" column="day_20"/>
<result property="day21" column="day_21"/>
<result property="day22" column="day_22"/>
<result property="day23" column="day_23"/>
<result property="day24" column="day_24"/>
<result property="day25" column="day_25"/>
<result property="day26" column="day_26"/>
<result property="day27" column="day_27"/>
<result property="day28" column="day_28"/>
<result property="day29" column="day_29"/>
<result property="day30" column="day_30"/>
<result property="day31" column="day_31"/>
</resultMap>
<!-- 通过ID查询单条数据 -->
<select id="queryById" resultMap="PsdcStatisticsMonthMap">
select month_id,
device_id,
device_name,
month_date,
day_01,
day_02,
day_03,
day_04,
day_05,
day_06,
day_07,
day_08,
day_09,
day_10,
day_11,
day_12,
day_13,
day_14,
day_15,
day_16,
day_17,
day_18,
day_19,
day_20,
day_21,
day_22,
day_23,
day_24,
day_25,
day_26,
day_27,
day_28,
day_29,
day_30,
day_31
from psdc_statistics_month
where month_id = #{monthId}
</select>
<!--分页查询指定行数据-->
<select id="queryAllByLimit" resultMap="PsdcStatisticsMonthMap">
select
month_id,device_id,device_name,month_date,day_01,day_02,day_03,day_04,day_05,day_06,day_07,day_08,day_09,day_10,day_11,day_12,day_13,day_14,day_15,day_16,day_17,day_18,day_19,day_20,day_21,day_22,day_23,day_24,day_25,day_26,day_27,day_28,day_29,day_30,day_31
from psdc_statistics_month
<where>
<if test="deviceId != null and deviceId != ''">
and device_id = #{deviceId}
</if>
<!-- 开始时间检索 -->
<if test="startTime != null and startTime != ''">
AND date_format(month_date,'%Y-%m') &gt;= #{startTime}
</if>
<!-- 结束时间检索 -->
<if test="endTime != null and endTime != ''">
AND date_format(month_date,'%Y-%m') &lt;= #{endTime}
</if>
</where>
</select>
<insert id="insertMonth">
Insert into psdc_statistics_month(
month_date,
device_id,
device_name
<if test="day01 != null and day01 != 0">,day_01,</if>
<if test="day02 != null and day02 != 0">day_02,</if>
<if test="day03 != null and day03 != 0">day_03,</if>
<if test="day04 != null and day04 != 0">day_04,</if>
<if test="day05 != null and day05 != 0">day_05,</if>
<if test="day06 != null and day06 != 0">day_06,</if>
<if test="day07 != null and day07 != 0">day_07,</if>
<if test="day08 != null and day08 != 0">day_08,</if>
<if test="day09 != null and day09 != 0">day_09,</if>
<if test="day10 != null and day10 != 0">day_10,</if>
<if test="day11 != null and day11 != 0">day_11,</if>
<if test="day12 != null and day12 != 0">day_12,</if>
<if test="day13 != null and day13 != 0">day_13,</if>
<if test="day14 != null and day14 != 0">day_14,</if>
<if test="day15 != null and day15 != 0">day_15,</if>
<if test="day16 != null and day16 != 0">day_16,</if>
<if test="day17 != null and day17 != 0">day_17,</if>
<if test="day18 != null and day18 != 0">day_18,</if>
<if test="day19 != null and day19 != 0">day_19,</if>
<if test="day20 != null and day20 != 0">day_20,</if>
<if test="day21 != null and day21 != 0">day_21,</if>
<if test="day22 != null and day22 != 0">day_22,</if>
<if test="day23 != null and day23 != 0">day_23,</if>
<if test="day24 != null and day24 != 0">day_24,</if>
<if test="day25 != null and day25 != 0">day_25,</if>
<if test="day26 != null and day26 != 0">day_26,</if>
<if test="day27 != null and day27 != 0">day_27,</if>
<if test="day28 != null and day28 != 0">day_28,</if>
<if test="day29 != null and day29 != 0">day_29,</if>
<if test="day30 != null and day30 != 0">day_30,</if>
<if test="day31 != null and day31 != 0">day_31,</if>
)values(
#{monthDate},
#{deviceId},
#{deviceName}
<if test="day01 != null and day01 != 0">,#{day01},</if>
<if test="day02 != null and day02 != 0">#{day02},</if>
<if test="day03 != null and day03 != 0">#{day03},</if>
<if test="day04 != null and day04 != 0">#{day04},</if>
<if test="day05 != null and day05 != 0">#{day05},</if>
<if test="day06 != null and day06 != 0">#{day06},</if>
<if test="day07 != null and day07 != 0">#{day07},</if>
<if test="day08 != null and day08 != 0">#{day08},</if>
<if test="day09 != null and day09 != 0">#{day09},</if>
<if test="day10 != null and day10 != 0">#{day10},</if>
<if test="day11 != null and day11 != 0">#{day11},</if>
<if test="day12 != null and day12 != 0">#{day12},</if>
<if test="day13 != null and day13 != 0">#{day13},</if>
<if test="day14 != null and day14 != 0">#{day14},</if>
<if test="day15 != null and day15 != 0">#{day15},</if>
<if test="day16 != null and day16 != 0">#{day16},</if>
<if test="day17 != null and day17 != 0">#{day17},</if>
<if test="day18 != null and day18 != 0">#{day18},</if>
<if test="day19 != null and day19 != 0">#{day19},</if>
<if test="day20 != null and day20 != 0">#{day20},</if>
<if test="day21 != null and day21 != 0">#{day21},</if>
<if test="day22 != null and day22 != 0">#{day22},</if>
<if test="day23 != null and day23 != 0">#{day23},</if>
<if test="day24 != null and day24 != 0">#{day24},</if>
<if test="day25 != null and day25 != 0">#{day25},</if>
<if test="day26 != null and day26 != 0">#{day26},</if>
<if test="day27 != null and day27 != 0">#{day27},</if>
<if test="day28 != null and day28 != 0">#{day28},</if>
<if test="day29 != null and day29 != 0">#{day29},</if>
<if test="day30 != null and day30 != 0">#{day30},</if>
<if test="day31 != null and day31 != 0">#{day31},</if>
)
</insert>
<!--新增数据-->
<insert id="insert" useGeneratedKeys = 'true' keyProperty="monthId">
insert into psdc_statistics_month(month_id, device_id, device_name, month_date, day_01, day_02, day_03, day_04,
day_05, day_06, day_07, day_08, day_09, day_10, day_11, day_12, day_13,
day_14, day_15, day_16, day_17, day_18, day_19, day_20, day_21, day_22,
day_23, day_24, day_25, day_26, day_27, day_28, day_29, day_30, day_31)
values (#{monthId}, #{deviceId}, #{deviceName}, #{monthDate}, #{day01}, #{day02}, #{day03}, #{day04}, #{day05},
#{day06}, #{day07}, #{day08}, #{day09}, #{day10}, #{day11}, #{day12}, #{day13}, #{day14}, #{day15},
#{day16}, #{day17}, #{day18}, #{day19}, #{day20}, #{day21}, #{day22}, #{day23}, #{day24}, #{day25},
#{day26}, #{day27}, #{day28}, #{day29}, #{day30}, #{day31})
</insert>
<!-- 更新数据 -->
<update id="updatePoint">
update psdc_statistics_month
set ${monthPoint} = #{value}
where month_id = #{monthId};
</update>
<!-- 更新数据 -->
<update id="update">
update psdc_statistics_month
<set>
<if test="monthId != null and monthId != ''">
month_id = #{monthId},
</if>
<if test="deviceId != null and deviceId != ''">
device_id = #{deviceId},
</if>
<if test="deviceName != null and deviceName != ''">
device_name = #{deviceName},
</if>
<if test="month_date != null and month_date != ''">
month_date = #{monthDate},
</if>
<if test="day01 != null and day01 != ''">
day_01 = #{day01},
</if>
<if test="day02 != null and day02 != ''">
day_02 = #{day02},
</if>
<if test="day03 != null and day03 != ''">
day_03 = #{day03},
</if>
<if test="day04 != null and day04 != ''">
day_04 = #{day04},
</if>
<if test="day05 != null and day05 != ''">
day_05 = #{day05},
</if>
<if test="day06 != null and day06 != ''">
day_06 = #{day06},
</if>
<if test="day07 != null and day07 != ''">
day_07 = #{day07},
</if>
<if test="day08 != null and day08 != ''">
day_08 = #{day08},
</if>
<if test="day09 != null and day09 != ''">
day_09 = #{day09},
</if>
<if test="day10 != null and day10 != ''">
day_10 = #{day10},
</if>
<if test="day11 != null and day11 != ''">
day_11 = #{day11},
</if>
<if test="day12 != null and day12 != ''">
day_12 = #{day12},
</if>
<if test="day13 != null and day13 != ''">
day_13 = #{day13},
</if>
<if test="day14 != null and day14 != ''">
day_14 = #{day14},
</if>
<if test="day15 != null and day15 != ''">
day_15 = #{day15},
</if>
<if test="day16 != null and day16 != ''">
day_16 = #{day16},
</if>
<if test="day17 != null and day17 != ''">
day_17 = #{day17},
</if>
<if test="day18 != null and day18 != ''">
day_18 = #{day18},
</if>
<if test="day19 != null and day19 != ''">
day_19 = #{day19},
</if>
<if test="day20 != null and day20 != ''">
day_20 = #{day20},
</if>
<if test="day21 != null and day21 != ''">
day_21 = #{day21},
</if>
<if test="day22 != null and day22 != ''">
day_22 = #{day22},
</if>
<if test="day23 != null and day23 != ''">
day_23 = #{day23},
</if>
<if test="day24 != null and day24 != ''">
day_24 = #{day24},
</if>
<if test="day25 != null and day25 != ''">
day_25 = #{day25},
</if>
<if test="day26 != null and day26 != ''">
day_26 = #{day26},
</if>
<if test="day27 != null and day27 != ''">
day_27 = #{day27},
</if>
<if test="day28 != null and day28 != ''">
day_28 = #{day28},
</if>
<if test="day29 != null and day29 != ''">
day_29 = #{day29},
</if>
<if test="day30 != null and day30 != ''">
day_30 = #{day30},
</if>
<if test="day31 != null and day31 != ''">
day_31 = #{day31},
</if>
</set>
where month_id = #{monthId}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete
from psdc_statistics_month
where month_id = #{monthId}
</delete>
<!-- 根据设备id和日期查询-->
<select id="queryByDeviceIdAndDate" resultMap="PsdcStatisticsMonthMap">
select * from psdc_statistics_month where device_id = #{deviceId} and date_format(month_date,'%Y-%m') = #{date}
</select>
<!-- 算一行数据总和-->
<select id="queryOneLineSum" resultType="double">
select ifnull(day_01,0.0) + ifnull(day_02,0.0) + ifnull(day_03,0.0) + ifnull(day_04,0.0) + ifnull(day_05,0.0) +
ifnull(day_06,0.0) + ifnull(day_07,0.0) + ifnull(day_08,0.0) + ifnull(day_09,0.0) + ifnull(day_10,0.0) +
ifnull(day_11,0.0) + ifnull(day_12,0.0) + ifnull(day_13,0.0) + ifnull(day_14,0.0) + ifnull(day_15,0.0) +
ifnull(day_16,0.0) + ifnull(day_17,0.0) + ifnull(day_18,0.0) + ifnull(day_19,0.0) + ifnull(day_20,0.0) +
ifnull(day_21,0.0) + ifnull(day_22,0.0) + ifnull(day_23,0.0) + ifnull(day_24,0.0) + ifnull(day_25,0.0) +
ifnull(day_26,0.0) + ifnull(day_27,0.0) + ifnull(day_28,0.0) + ifnull(day_29,0.0) + ifnull(day_30,0.0) +
ifnull(day_31,0.0) as total from psdc_statistics_month where device_id = #{deviceId} and date_format(month_date,'%Y-%m') = #{date}
</select>
</mapper>