liulingling.177216
2024-08-26 349f1cfc5fa77fbc636d542df0d8050fddec48c2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?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.dingzhuo.energy.project.electricity.mapper.ElectricityPriceMapper">
 
    <resultMap type="ElectricityPrice" id="ElectricityPriceResult">
        <result property="id"    column="id"    />
        <result property="effectiveDate"    column="effective_date"    />
        <result property="priceId"    column="price_id"    />
        <result property="beginDate"    column="begin_date"    />
        <result property="endDate"    column="end_date"    />
        <result property="effectiveName"    column="effective_name"    />
    </resultMap>
 
    <sql id="selectElectricityPriceVo">
        select id, effective_date, price_id, begin_date, end_date, effective_name from electricity_price
    </sql>
 
    <select id="selectElectricityPriceList" parameterType="ElectricityPrice" resultMap="ElectricityPriceResult">
        select e.id, e.effective_date,e.price_id,
                e.begin_date,
                e.end_date,
                e.effective_name,
                t.price
        from electricity_price e LEFT JOIN time_period_price t ON e.price_id=t.id
        <where> 1=1
            <if test="effectiveName != null  and effectiveName != ''"> and e.effective_name like concat('%', #{effectiveName}, '%')</if>
            <if test="effectiveDate != null "> and e.effective_date = #{effectiveDate}</if>
        </where>
        order by effective_date desc
    </select>
 
    <select id="selectElectricityPriceById" parameterType="String" resultMap="ElectricityPriceResult">
        <include refid="selectElectricityPriceVo"/>
        where id = #{id}
    </select>
 
    <insert id="insertElectricityPrice" parameterType="ElectricityPrice">
        insert into electricity_price
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null  and id != ''">id,</if>
            <if test="effectiveDate != null ">effective_date,</if>
            <if test="priceId != null  and priceId != ''">price_id,</if>
            <if test="beginDate != null ">begin_date,</if>
            <if test="endDate != null ">end_date,</if>
            <if test="effectiveName != null  and effectiveName != ''">effective_name,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null  and id != ''">#{id},</if>
            <if test="effectiveDate != null ">#{effectiveDate},</if>
            <if test="priceId != null  and priceId != ''">#{priceId},</if>
            <if test="beginDate != null ">#{beginDate},</if>
            <if test="endDate != null ">#{endDate},</if>
            <if test="effectiveName != null  and effectiveName != ''">#{effectiveName},</if>
        </trim>
    </insert>
 
    <update id="updateElectricityPrice" parameterType="ElectricityPrice">
        update electricity_price
        <trim prefix="SET" suffixOverrides=",">
            <if test="effectiveDate != null ">effective_date = #{effectiveDate},</if>
            <if test="priceId != null  and priceId != ''">price_id = #{priceId},</if>
            <if test="beginDate != null ">begin_date = #{beginDate},</if>
            <if test="endDate != null ">end_date = #{endDate},</if>
            <if test="effectiveName != null  and effectiveName != ''">effective_name = #{effectiveName},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteElectricityPriceById" parameterType="String">
        delete from electricity_price where id = #{id}
    </delete>
 
    <delete id="deleteElectricityPriceByIds" parameterType="String">
        delete from electricity_price where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <!--生效日期-->
    <select id="selectList" parameterType="ElectricityPrice" resultMap="ElectricityPriceResult">
        select distinct effective_date from electricity_price
        <where>
            <if test="effectiveName != null  and effectiveName != ''"> and effective_name like concat('%', #{effectiveName}, '%')</if>
        </where>
        order by effective_date desc
    </select>
</mapper>