电价配置

This commit is contained in:
2025-10-09 19:58:50 +08:00
parent 7121fdecfa
commit d8d0a83c87
11 changed files with 1145 additions and 0 deletions

View File

@ -0,0 +1,151 @@
<?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.xzzn.ems.mapper.EmsEnergyPriceConfigMapper">
<resultMap type="EmsEnergyPriceConfig" id="EmsEnergyPriceConfigResult">
<result property="id" column="id" />
<result property="year" column="year" />
<result property="month" column="month" />
<result property="peak" column="peak" />
<result property="high" column="high" />
<result property="flat" column="flat" />
<result property="valley" column="valley" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectEmsEnergyPriceConfigVo">
select id, year, month, peak, high, flat, valley, create_by, create_time, update_by, update_time, remark from ems_energy_price_config
</sql>
<select id="selectEmsEnergyPriceConfigList" parameterType="EmsEnergyPriceConfig" resultMap="EmsEnergyPriceConfigResult">
<include refid="selectEmsEnergyPriceConfigVo"/>
<where>
<if test="year != null and year != ''"> and year = #{year}</if>
<if test="month != null and month != ''"> and month = #{month}</if>
<if test="peak != null "> and peak = #{peak}</if>
<if test="high != null "> and high = #{high}</if>
<if test="flat != null "> and flat = #{flat}</if>
<if test="valley != null "> and valley = #{valley}</if>
<if test="siteId != null and siteId != ''"> and site_id = #{siteId}</if>
</where>
</select>
<select id="selectEmsEnergyPriceConfigById" parameterType="Long" resultMap="EmsEnergyPriceConfigResult">
<include refid="selectEmsEnergyPriceConfigVo"/>
where id = #{id}
</select>
<insert id="insertEmsEnergyPriceConfig" parameterType="EmsEnergyPriceConfig" useGeneratedKeys="true" keyProperty="id">
insert into ems_energy_price_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="year != null and year != ''">year,</if>
<if test="month != null and month != ''">month,</if>
<if test="peak != null">peak,</if>
<if test="high != null">high,</if>
<if test="flat != null">flat,</if>
<if test="valley != null">valley,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="year != null and year != ''">#{year},</if>
<if test="month != null and month != ''">#{month},</if>
<if test="peak != null">#{peak},</if>
<if test="high != null">#{high},</if>
<if test="flat != null">#{flat},</if>
<if test="valley != null">#{valley},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateEmsEnergyPriceConfig" parameterType="EmsEnergyPriceConfig">
update ems_energy_price_config
<trim prefix="SET" suffixOverrides=",">
<if test="year != null and year != ''">year = #{year},</if>
<if test="month != null and month != ''">month = #{month},</if>
<if test="peak != null">peak = #{peak},</if>
<if test="high != null">high = #{high},</if>
<if test="flat != null">flat = #{flat},</if>
<if test="valley != null">valley = #{valley},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteEmsEnergyPriceConfigById" parameterType="Long">
delete from ems_energy_price_config where id = #{id}
</delete>
<delete id="deleteEmsEnergyPriceConfigByIds" parameterType="String">
delete from ems_energy_price_config where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="getCurrentYearConfigList" resultMap="EmsEnergyPriceConfigResult">
<include refid="selectEmsEnergyPriceConfigVo"/>
<where>
year = #{currentYear}
</where>
</select>
<insert id="insertOrUpdateEmsEnergyPriceConfig" parameterType="com.xzzn.ems.domain.EmsEnergyPriceConfig"
useGeneratedKeys="true" keyProperty="id">
INSERT INTO ems_energy_price_config (
id,
year,
month,
peak,
high,
flat,
valley,
create_by,
create_time,
update_by,
update_time,
remark
) VALUES (
#{id},
#{year},
#{month},
#{peak},
#{high},
#{flat},
#{valley},
'system',
NOW(),
'system',
NOW(),
#{remark}
) ON DUPLICATE KEY UPDATE
peak = #{peak},
high = #{high},
flat = #{flat},
valley = #{valley},
update_time = NOW();
</insert>
<select id="getConfigListByYearAndMonth" resultMap="EmsEnergyPriceConfigResult">
<include refid="selectEmsEnergyPriceConfigVo"/>
where year = #{currentYear}
and month = #{month}
</select>
</mapper>

View File

@ -0,0 +1,127 @@
<?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.xzzn.ems.mapper.EmsPriceTimeConfigMapper">
<resultMap type="EmsPriceTimeConfig" id="EmsPriceTimeConfigResult">
<result property="id" column="id" />
<result property="startTime" column="start_time" />
<result property="endTime" column="end_time" />
<result property="costType" column="cost_type" />
<result property="priceId" column="price_id" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectEmsPriceTimeConfigVo">
select id, start_time, end_time, cost_type, price_id, create_by, create_time, update_by, update_time, remark from ems_price_time_config
</sql>
<select id="selectEmsPriceTimeConfigList" parameterType="EmsPriceTimeConfig" resultMap="EmsPriceTimeConfigResult">
<include refid="selectEmsPriceTimeConfigVo"/>
<where>
<if test="startTime != null and startTime != ''"> and start_time = #{startTime}</if>
<if test="endTime != null and endTime != ''"> and end_time = #{endTime}</if>
<if test="costType != null and costType != ''"> and cost_type = #{costType}</if>
<if test="priceId != null "> and price_id = #{priceId}</if>
</where>
</select>
<select id="selectEmsPriceTimeConfigById" parameterType="Long" resultMap="EmsPriceTimeConfigResult">
<include refid="selectEmsPriceTimeConfigVo"/>
where id = #{id}
</select>
<insert id="insertEmsPriceTimeConfig" parameterType="EmsPriceTimeConfig" useGeneratedKeys="true" keyProperty="id">
insert into ems_price_time_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="startTime != null and startTime != ''">start_time,</if>
<if test="endTime != null and endTime != ''">end_time,</if>
<if test="costType != null and costType != ''">cost_type,</if>
<if test="priceId != null">price_id,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="startTime != null and startTime != ''">#{startTime},</if>
<if test="endTime != null and endTime != ''">#{endTime},</if>
<if test="costType != null and costType != ''">#{costType},</if>
<if test="priceId != null">#{priceId},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateEmsPriceTimeConfig" parameterType="EmsPriceTimeConfig">
update ems_price_time_config
<trim prefix="SET" suffixOverrides=",">
<if test="startTime != null and startTime != ''">start_time = #{startTime},</if>
<if test="endTime != null and endTime != ''">end_time = #{endTime},</if>
<if test="costType != null and costType != ''">cost_type = #{costType},</if>
<if test="priceId != null">price_id = #{priceId},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteEmsPriceTimeConfigById" parameterType="Long">
delete from ems_price_time_config where id = #{id}
</delete>
<delete id="deleteEmsPriceTimeConfigByIds" parameterType="String">
delete from ems_price_time_config where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="getTimeRangeByPriceId" resultType="com.xzzn.ems.domain.vo.EnergyPriceTimeRange">
Select start_time as startTime,
end_time as endTime,
cost_type as costType
from ems_price_time_config
where price_id = #{priceId}
</select>
<insert id="batchInsert" parameterType="java.util.List">
INSERT INTO ems_price_time_config (
start_time, end_time, cost_type, price_id, create_by, create_time, update_by, update_time, remark
) VALUES
<!-- 遍历集合生成多条记录注意separator和括号闭合 -->
<foreach collection="list" item="item" separator=",">
(
#{item.startTime},
#{item.endTime},
#{item.costType},
#{item.priceId},
#{item.createBy},
#{item.createTime},
#{item.updateBy},
#{item.updateTime},
#{item.remark}
)
</foreach>
</insert>
<delete id="deleteTimeRangeByPriceId" parameterType="Long">
delete from ems_price_time_config where price_id in
<foreach item="priceId" collection="array" open="(" separator="," close=")">
#{priceId}
</foreach>
</delete>
</mapper>