ustcyc
2025-01-07 de5d55508afd27fb2b47e6d4d6fd9984525c222c
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
<?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.zhitan.basicdata.mapper.SysEnergyMapper">
 
    <resultMap type="SysEnergy" id="SysEnergyResult">
        <result property="enername"    column="enername"    />
        <result property="muid"    column="muid"    />
        <result property="enerclassid"    column="enerclassid"    />
        <result property="enerclassname"    column="enerclassname"    />
        <result property="enersno"    column="enersno"    />
        <result property="isstorage"    column="isstorage"    />
        <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="note"    column="note"    />
        <result property="enerid"    column="enerid"    />
        <result property="coefficient"    column="coefficient"    />
        <result property="execdate"    column="execdate"    />
        <result property="price"    column="price"    />
        <result property="emissionFactors"    column="emission_factors"    />
        <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="selectSysEnergyVo">
        select enername, muid, enerclassid, enersno, isstorage, opr_man, opr_time, mod_man, mod_time, note, enerid, coefficient, execdate, price, emission_factors, create_by, create_time, update_by, update_time, remark from sys_energy
    </sql>
    <select id="getenerclassname" resultType="SysEnerclass">
        select enerclassid,enerclassname from sys_enerclass order by create_time
    </select>
 
    <select id="selectSysEnergyList" parameterType="SysEnergy" resultMap="SysEnergyResult">
        <include refid="selectSysEnergyVo"/>
        <where>
            <if test="enername != null  and enername != ''"> and enername like concat('%', #{enername}, '%')</if>
            <if test="muid != null  and muid != ''"> and muid = #{muid}</if>
            <if test="enerclassid != null  and enerclassid != ''"> and enerclassid = #{enerclassid}</if>
            <if test="enersno != null  and enersno != ''"> and enersno = #{enersno}</if>
            <if test="isstorage != null  and isstorage != ''"> and isstorage = #{isstorage}</if>
            <if test="oprMan != null  and oprMan != ''"> and opr_man = #{oprMan}</if>
            <if test="oprTime != null "> and opr_time = #{oprTime}</if>
            <if test="modMan != null  and modMan != ''"> and mod_man = #{modMan}</if>
            <if test="modTime != null "> and mod_time = #{modTime}</if>
            <if test="note != null  and note != ''"> and note = #{note}</if>
            <if test="enerid != null  and enerid != ''"> and enerid = #{enerid}</if>
            <if test="coefficient != null  and coefficient != ''"> and coefficient = #{coefficient}</if>
            <if test="execdate != null "> and execdate = #{execdate}</if>
            <if test="price != null  and price != ''"> and price = #{price}</if>
            <if test="emissionFactors != null  and emissionFactors != ''"> and emission_factors = #{emissionFactors}</if>
        </where>
        order by create_time
    </select>
 
    <select id="selectSysEnergyById" parameterType="Integer" resultMap="SysEnergyResult">
        <include refid="selectSysEnergyVo"/>
        where enerid = #{enerid}
    </select>
 
    <insert id="insertSysEnergy" parameterType="SysEnergy">
        insert into sys_energy
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="enername != null">enername,</if>
            <if test="muid != null">muid,</if>
            <if test="enerclassid != null">enerclassid,</if>
            <if test="enersno != null">enersno,</if>
            <if test="isstorage != null">isstorage,</if>
            <if test="oprMan != null and oprMan != ''">opr_man,</if>
            <if test="oprTime != null">opr_time,</if>
            <if test="modMan != null">mod_man,</if>
            <if test="modTime != null">mod_time,</if>
            <if test="note != null">note,</if>
            <if test="enerid != null and enerid != ''">enerid,</if>
            <if test="coefficient != null">coefficient,</if>
            <if test="execdate != null">execdate,</if>
            <if test="price != null">price,</if>
            <if test="emissionFactors != null">emission_factors,</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="enername != null">#{enername},</if>
            <if test="muid != null">#{muid},</if>
            <if test="enerclassid != null">#{enerclassid},</if>
            <if test="enersno != null">#{enersno},</if>
            <if test="isstorage != null">#{isstorage},</if>
            <if test="oprMan != null and oprMan != ''">#{oprMan},</if>
            <if test="oprTime != null">now(),</if>
            <if test="modMan != null">#{modMan},</if>
            <if test="modTime != null">now(),,</if>
            <if test="note != null">#{note},</if>
            <if test="enerid != null and enerid != ''">#{enerid},</if>
            <if test="coefficient != null">#{coefficient},</if>
            <if test="execdate != null">#{execdate},</if>
            <if test="price != null">#{price},</if>
            <if test="emissionFactors != null">#{emissionFactors},</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="updateSysEnergy" parameterType="SysEnergy">
        update sys_energy
        <trim prefix="SET" suffixOverrides=",">
            <if test="muid != null">muid = #{muid},</if>
            <if test="enerclassid != null">enerclassid = #{enerclassid},</if>
            <if test="enername != null">enername = #{enername},</if>
            <if test="enersno != null">enersno = #{enersno},</if>
            <if test="isstorage != null">isstorage = #{isstorage},</if>
            <if test="oprMan != null and oprMan != ''">opr_man = #{oprMan},</if>
            <if test="oprTime != null">opr_time = now(),</if>
            <if test="modMan != null">mod_man = #{modMan},</if>
            <if test="modTime != null">mod_time = now(),</if>
            <if test="note != null">note = #{note},</if>
            <if test="enerid != null and enerid != ''">enerid = #{enerid},</if>
            <if test="coefficient != null">coefficient = #{coefficient},</if>
            <if test="execdate != null">execdate = #{execdate},</if>
            <if test="price != null">price = #{price},</if>
            <if test="emissionFactors != null">emission_factors = #{emissionFactors},</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 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>
 
    <select id="listAllEnergyType" resultType="EnergyTypeModel">
        select enername, enersno from sys_energy
    </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,
            carbon_emission_coefficient,
            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},
            #{carbonEmissionCoefficient},
            #{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},
            carbon_emission_coefficient = #{carbonEmissionCoefficient},
            <if test="note != null  and note != ''">note = #{coefficientnote},</if>
        </trim>
        where enerid = #{enerid}
    </update>
 
 
    <select id="selectSysEnergyPage"  resultMap="SysEnergyResult">
        select a.*,b.enerclassname from sys_energy a left join sys_enerclass b on a.enerclassid = b.enerclassid
        <where>
            <if test="sysEnergy.enername != null  and sysEnergy.enername != ''"> and a.enername like concat('%', #{sysEnergy.enername}, '%')</if>
            <if test="sysEnergy.enerclassid != null  and sysEnergy.enerclassid != ''"> and a.enerclassid = #{sysEnergy.enerclassid}</if>
        </where>
        order by a.create_time
    </select>
</mapper>