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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<?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.basic.data.enerInfoManage.mapper.SysEnergyMapper">
 
    <resultMap type="SysEnergy" id="SysEnergyResult">
        <result property="oprMan"    column="opr_man"    />
        <result property="oprTime"    column="opr_time"    />
        <result property="modMan"    column="mod_man"    />
        <result property="modTime"    column="mod_time"    />
        <result property="enerid"    column="enerid"    />
        <result property="enername"    column="enername"    />
        <result property="muid"    column="muid"    />
        <result property="enerclassid"    column="enerclassid"    />
        <result property="enersno"    column="enersno"    />
        <result property="isstorage"    column="isstorage"    />
        <result property="note"    column="note"    />
    </resultMap>
 
    <sql id="selectSysEnergyVo">
        select
        a.opr_man, a.opr_time, a.mod_man, a.mod_time, a.enerid, a.enername,
        a.muid as muidString, a.enerclassid, a.enersno, a.isstorage, a.note,enerclassname
        from sys_energy a left join sys_enerclass  b on a.enerclassid = b.enerclassid
    </sql>
 
    <select id="getenerclassname" resultType="SysEnerclass">
        select enerclassid,enerclassname from sys_enerclass
    </select>
 
    <select id="selectSysEnergyList" parameterType="SysEnergy" resultMap="SysEnergyResult">
        select
        a.opr_man, a.opr_time, a.mod_man, a.mod_time, a.enerid, a.enername,
        a.muid as muidString, a.enerclassid, a.enersno, a.isstorage, a.note,enerclassname,
        c.dict_label as muidName
        from sys_energy a left join sys_enerclass  b on a.enerclassid = b.enerclassid
        left join sys_dict_data c on a.muid = c.dict_sort and dict_type = 'sys_unit'
        <where>
            <if test="enername != null  and enername != ''"> and enername like concat('%', #{enername}, '%')</if>
            <if test="enerclassname != null  and enerclassname != ''"> and enerclassname = #{enerclassname}</if>
        </where>
    </select>
 
    <select id="selectSysEnergyById" parameterType="Integer" resultMap="SysEnergyResult">
        select
        a.opr_man, a.opr_time, a.mod_man, a.mod_time, a.enerid, a.enername,
        a.muid as muidString, a.enerclassid, a.enersno, a.isstorage, a.note,enerclassname,
        c.dict_label as muidName,d.coefficient,d.coefficient2,d.execdate as coefficientexecdate,d.note as coefficientnote
        from sys_energy a left join sys_enerclass  b on a.enerclassid = b.enerclassid
        left join sys_dict_data c on a.muid = c.dict_sort and dict_type = 'sys_unit'
            left join sys_enercoefficient d on a.enerid = d.enerid
        where a.enerid = #{enerid}
    </select>
 
    <insert id="insertSysEnergy" parameterType="SysEnergy">
        insert into sys_energy
        <trim prefix="(" suffix=")" suffixOverrides=",">
            mod_time,
            opr_time,
            <if test="oprMan != null  and oprMan != ''">opr_man,</if>
            <if test="modMan != null  and modMan != ''">mod_man,</if>
            <if test="enerid != null ">enerid,</if>
            <if test="enername != null  and enername != ''">enername,</if>
            <if test="muidString != null ">muid,</if>
            <if test="enerclassid != null ">enerclassid,</if>
            <if test="enersno != null  and enersno != ''">enersno,</if>
            <if test="isstorage != null ">isstorage,</if>
            <if test="note != null  and note != ''">note,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            now(),
            now(),
            <if test="oprMan != null  and oprMan != ''">#{oprMan},</if>
            <if test="modMan != null  and modMan != ''">#{modMan},</if>
            <if test="enerid != null ">#{enerid},</if>
            <if test="enername != null  and enername != ''">#{enername},</if>
            <if test="muidString != null ">#{muidString},</if>
            <if test="enerclassid != null ">#{enerclassid},</if>
            <if test="enersno != null  and enersno != ''">#{enersno},</if>
            <if test="isstorage != null ">#{isstorage},</if>
            <if test="note != null  and note != ''">#{note},</if>
         </trim>
    </insert>
 
    <update id="updateSysEnergy" parameterType="SysEnergy">
        update sys_energy
        <trim prefix="SET" suffixOverrides=",">
            mod_time = now(),
            <if test="modMan != null  and modMan != ''">mod_man = #{modMan},</if>
            <if test="enerid != null ">enerid = #{enerid},</if>
            <if test="enername != null  and enername != ''">enername = #{enername},</if>
            <if test="muidString != null ">muid = #{muidString},</if>
            <if test="enerclassid != null ">enerclassid = #{enerclassid},</if>
            <if test="enersno != null  and enersno != ''">enersno = #{enersno},</if>
            <if test="isstorage != null ">isstorage = #{isstorage},</if>
            <if test="note != null  and note != ''">note = #{note},</if>
        </trim>
        where enerid = #{enerid}
    </update>
 
    <delete id="deleteSysEnergyById" parameterType="String">
        delete from sys_energy where enerid = #{enerid}
    </delete>
 
    <delete id="deleteSysEnergyByIds" parameterType="String">
        delete from sys_energy where enerid in
        <foreach item="enerid" collection="array" open="(" separator="," close=")">
            #{enerid}
        </foreach>
    </delete>
 
    <select id="getEnerClassid" parameterType="String" resultType="Integer">
        select enerclassid from sys_enerclass where enerclassname = #{enerclassname}
    </select>
 
    <select id="selectSameEnergyNameNum" parameterType="String" resultType="Integer">
        select COUNT(enerid) from sys_energy where enername = #{enername}
    </select>
 
    <select id="selectIdByName" parameterType="String" resultType="Integer">
        select enerid from sys_energy where enername = #{enername}
    </select>
 
    <select id="getPriceCountByEnerid" parameterType="SysEnergy" resultType="Integer">
        select COUNT(objectid) from sys_price where objectid = #{enerid} and objecttype = 1 and execdate = #{execdate}
    </select>
 
    <insert id="insertEnergyPrice" parameterType="SysEnergy">
        insert into sys_price
        <trim prefix="(" suffix=")" suffixOverrides=",">
            mod_time,
            opr_time,
            <if test="oprMan != null  and oprMan != ''">opr_man,</if>
            <if test="modMan != null  and modMan != ''">mod_man,</if>
            objectid,
            objecttype,
            price,
            execdate,
            <if test="note != null  and note != ''">note,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            now(),
            now(),
            <if test="oprMan != null  and oprMan != ''">#{oprMan},</if>
            <if test="modMan != null  and modMan != ''">#{modMan},</if>
            <if test="enerid != null ">#{enerid},</if>
            1,
            #{price},
            #{execdate},
            <if test="note != null  and note != ''">#{pricenote},</if>
        </trim>
    </insert>
 
    <update id="updateEnergyPrice" parameterType="SysEnergy" >
        update sys_price
        <trim prefix="SET" suffixOverrides=",">
            mod_time = now(),
            <if test="modMan != null  and modMan != ''">mod_man = #{modMan},</if>
            price = #{price},
            execdate = #{execdate},
            <if test="note != null  and note != ''">note = #{pricenote},</if>
        </trim>
    </update>
 
    <select id="getCoefficientCountByEnerid" parameterType="Integer" resultType="Integer">
        select COUNT(enerid) from sys_enercoefficient where enerid = #{enerid}
    </select>
 
    <insert id="insertEnergyCoefficient" parameterType="SysEnergy">
        insert into sys_enercoefficient
        <trim prefix="(" suffix=")" suffixOverrides=",">
            mod_time,
            opr_time,
            <if test="oprMan != null  and oprMan != ''">opr_man,</if>
            <if test="modMan != null  and modMan != ''">mod_man,</if>
            enerid,
            coefficient,
            coefficient2,
            execdate,
            <if test="note != null  and note != ''">note,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            now(),
            now(),
            <if test="oprMan != null  and oprMan != ''">#{oprMan},</if>
            <if test="modMan != null  and modMan != ''">#{modMan},</if>
            <if test="enerid != null ">#{enerid},</if>
            #{coefficient},
            #{coefficient2},
            #{coefficientexecdate},
            <if test="note != null  and note != ''">#{coefficientnote},</if>
        </trim>
    </insert>
 
    <update id="updateEnergyCoefficient" parameterType="SysEnergy" >
        update sys_enercoefficient
        <trim prefix="SET" suffixOverrides=",">
            mod_time = now(),
            <if test="modMan != null  and modMan != ''">mod_man = #{modMan},</if>
            coefficient = #{coefficient},
            coefficient2 = #{coefficient2},
            execdate = #{coefficientexecdate},
            <if test="note != null  and note != ''">note = #{coefficientnote},</if>
        </trim>
        where enerid = #{enerid}
    </update>
 
</mapper>