2025-10-16 15:16:46 +08:00
|
|
|
<?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.securitycontrol.screen.mapper.SjEnergyReductionMapper">
|
|
|
|
|
<resultMap id="BaseResultMap" type="com.securitycontrol.screen.domain.SjEnergyReduction">
|
|
|
|
|
<!--@mbg.generated-->
|
|
|
|
|
<!--@Table sj_energy_reduction-->
|
|
|
|
|
<id column="id" jdbcType="BIGINT" property="id" />
|
|
|
|
|
<result column="type" jdbcType="VARCHAR" property="type" />
|
|
|
|
|
<result column="create_time" jdbcType="DATE" property="createTime" />
|
|
|
|
|
<result column="data_num" jdbcType="VARCHAR" property="dataNum" />
|
|
|
|
|
<result column="date" property="date"/>
|
|
|
|
|
</resultMap>
|
|
|
|
|
<sql id="Base_Column_List">
|
|
|
|
|
<!--@mbg.generated-->
|
|
|
|
|
id, `type`, create_time, data_num
|
|
|
|
|
</sql>
|
|
|
|
|
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
|
|
|
|
<!--@mbg.generated-->
|
|
|
|
|
select
|
|
|
|
|
<include refid="Base_Column_List" />
|
|
|
|
|
from sj_energy_reduction
|
|
|
|
|
where id = #{id,jdbcType=BIGINT}
|
|
|
|
|
</select>
|
|
|
|
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
|
|
|
|
<!--@mbg.generated-->
|
|
|
|
|
delete from sj_energy_reduction
|
|
|
|
|
where id = #{id,jdbcType=BIGINT}
|
|
|
|
|
</delete>
|
|
|
|
|
<insert id="insert" parameterType="com.securitycontrol.screen.domain.SjEnergyReduction">
|
|
|
|
|
<!--@mbg.generated-->
|
|
|
|
|
insert into sj_energy_reduction (id, `type`, create_time,
|
|
|
|
|
data_num)
|
|
|
|
|
values (#{id,jdbcType=BIGINT}, #{type,jdbcType=VARCHAR}, #{createTime,jdbcType=DATE},
|
|
|
|
|
#{dataNum,jdbcType=VARCHAR})
|
|
|
|
|
</insert>
|
|
|
|
|
<insert id="insertSelective" parameterType="com.securitycontrol.screen.domain.SjEnergyReduction">
|
|
|
|
|
<!--@mbg.generated-->
|
|
|
|
|
insert into sj_energy_reduction
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="id != null">
|
|
|
|
|
id,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="type != null">
|
|
|
|
|
`type`,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="createTime != null">
|
|
|
|
|
create_time,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="dataNum != null">
|
|
|
|
|
data_num,
|
|
|
|
|
</if>
|
|
|
|
|
</trim>
|
|
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="id != null">
|
|
|
|
|
#{id,jdbcType=BIGINT},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="type != null">
|
|
|
|
|
#{type,jdbcType=VARCHAR},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="createTime != null">
|
|
|
|
|
#{createTime,jdbcType=DATE},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="dataNum != null">
|
|
|
|
|
#{dataNum,jdbcType=VARCHAR},
|
|
|
|
|
</if>
|
|
|
|
|
</trim>
|
|
|
|
|
</insert>
|
|
|
|
|
<update id="updateByPrimaryKeySelective" parameterType="com.securitycontrol.screen.domain.SjEnergyReduction">
|
|
|
|
|
<!--@mbg.generated-->
|
|
|
|
|
update sj_energy_reduction
|
|
|
|
|
<set>
|
|
|
|
|
<if test="type != null">
|
|
|
|
|
`type` = #{type,jdbcType=VARCHAR},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="createTime != null">
|
|
|
|
|
create_time = #{createTime,jdbcType=DATE},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="dataNum != null">
|
|
|
|
|
data_num = #{dataNum,jdbcType=VARCHAR},
|
|
|
|
|
</if>
|
|
|
|
|
</set>
|
|
|
|
|
where id = #{id,jdbcType=BIGINT}
|
|
|
|
|
</update>
|
|
|
|
|
<update id="updateByPrimaryKey" parameterType="com.securitycontrol.screen.domain.SjEnergyReduction">
|
|
|
|
|
<!--@mbg.generated-->
|
|
|
|
|
update sj_energy_reduction
|
|
|
|
|
set `type` = #{type,jdbcType=VARCHAR},
|
|
|
|
|
create_time = #{createTime,jdbcType=DATE},
|
|
|
|
|
data_num = #{dataNum,jdbcType=VARCHAR}
|
|
|
|
|
where id = #{id,jdbcType=BIGINT}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<select id="selectEnergyReduction" resultMap="BaseResultMap">
|
|
|
|
|
SELECT
|
|
|
|
|
t.type,
|
|
|
|
|
date_list.dt AS date,
|
|
|
|
|
COALESCE(e.data_num, '0') AS data_num
|
|
|
|
|
FROM
|
|
|
|
|
-- 所有类型
|
|
|
|
|
(SELECT DISTINCT type FROM sj_energy_reduction WHERE type IS NOT NULL) t
|
|
|
|
|
CROSS JOIN
|
|
|
|
|
-- 生成日期序列
|
2025-10-17 16:23:48 +08:00
|
|
|
( SELECT DATE_ADD(#{startTime}, INTERVAL (ones.a + tens.a * 10) DAY) AS dt
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT 0 AS a UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3
|
|
|
|
|
UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7
|
|
|
|
|
UNION ALL SELECT 8 UNION ALL SELECT 9) AS ones
|
|
|
|
|
CROSS JOIN
|
|
|
|
|
(SELECT 0 AS a UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3
|
|
|
|
|
UNION ALL SELECT 4 UNION ALL SELECT 5) AS tens
|
|
|
|
|
WHERE DATE_ADD(#{startTime}, INTERVAL (ones.a + tens.a * 10) DAY) <= #{endTime} ) AS date_list
|
2025-10-16 15:16:46 +08:00
|
|
|
LEFT JOIN sj_energy_reduction e
|
|
|
|
|
ON t.type = e.type
|
|
|
|
|
AND date_list.dt = e.create_time
|
|
|
|
|
WHERE date_list.dt BETWEEN #{startTime} AND #{endTime}
|
|
|
|
|
ORDER BY t.type, date_list.dt
|
|
|
|
|
</select>
|
|
|
|
|
</mapper>
|