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
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
<?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.statisticalData.mapper.GxdhCountMapper">
    
    <resultMap type="GxdhCount" id="GxdhCountResult">
        <result property="id"    column="id"    />
        <result property="repProductType"    column="rep_product_type"    />
        <result property="electricIndex"    column="electric_index"    />
        <result property="gasIndex"    column="gas_index"    />
        <result property="steamIndex"    column="steam_index"    />
        <result property="varietyType"    column="variety_type"    />
    </resultMap>
 
    <resultMap type="GxdhCountIndex" id="GxdhCountIndexResult">
        <result property="index_id"    column="index_id"    />
        <result property="repProductType"    column="rep_product_type"    />
        <result property="varietyType"    column="variety_type"    />
        <result property="FL"    column="fl"    />
        <result property="a1" column="a1"/>
        <result property="a2" column="a2"/>
        <result property="a3" column="a3"/>
        <result property="a4" column="a4"/>
        <result property="a5" column="a5"/>
        <result property="a6" column="a6"/>
        <result property="a7" column="a7"/>
        <result property="a8" column="a8"/>
        <result property="a9" column="a9"/>
        <result property="a10" column="a10"/>
        <result property="a11" column="a11"/>
        <result property="a12" column="a12"/>
        <result property="a13" column="a13"/>
        <result property="a14" column="a14"/>
        <result property="a15" column="a15"/>
        <result property="a16" column="a16"/>
        <result property="a17" column="a17"/>
        <result property="a18" column="a18"/>
        <result property="a19" column="a19"/>
        <result property="a20" column="a20"/>
        <result property="a21" column="a21"/>
        <result property="a22" column="a22"/>
        <result property="a23" column="a23"/>
        <result property="a24" column="a24"/>
        <result property="a25" column="a25"/>
        <result property="a26" column="a26"/>
        <result property="a27" column="a27"/>
        <result property="a28" column="a28"/>
        <result property="a29" column="a29"/>
        <result property="a30" column="a30"/>
        <result property="a31" column="a31"/>
        <result property="a32" column="a32"/>
        <result property="a33" column="a33"/>
        <result property="a34" column="a34"/>
        <result property="a35" column="a35"/>
        <result property="a36" column="a36"/>
    </resultMap>
 
    <sql id="selectGxdhCountVo">
        select id, rep_product_type, electric_index, gas_index, steam_index, variety_type from gxdh_count
    </sql>
 
    <select id="selectGxdhCountList" parameterType="GxdhCount" resultMap="GxdhCountResult">
        <include refid="selectGxdhCountVo"/>
        <where>  
            <if test="repProductType != null  and repProductType != ''"> and rep_product_type = #{repProductType}</if>
            <if test="varietyType != null  and varietyType != ''"> and variety_type = #{varietyType}</if>
        </where>
    </select>
    
    <select id="selectGxdhCountById" parameterType="String" resultMap="GxdhCountResult">
        <include refid="selectGxdhCountVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertGxdhCount" parameterType="GxdhCount">
        insert into gxdh_count
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null  and id != ''">id,</if>
            <if test="repProductType != null  and repProductType != ''">rep_product_type,</if>
            <if test="electricIndex != null  and electricIndex != ''">electric_index,</if>
            <if test="gasIndex != null  and gasIndex != ''">gas_index,</if>
            <if test="steamIndex != null  and steamIndex != ''">steam_index,</if>
            <if test="varietyType != null  and varietyType != ''">variety_type,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null  and id != ''">#{id},</if>
            <if test="repProductType != null  and repProductType != ''">#{repProductType},</if>
            <if test="electricIndex != null  and electricIndex != ''">#{electricIndex},</if>
            <if test="gasIndex != null  and gasIndex != ''">#{gasIndex},</if>
            <if test="steamIndex != null  and steamIndex != ''">#{steamIndex},</if>
            <if test="varietyType != null  and varietyType != ''">#{varietyType},</if>
         </trim>
    </insert>
 
    <update id="updateGxdhCount" parameterType="GxdhCount">
        update gxdh_count
        <trim prefix="SET" suffixOverrides=",">
            <if test="repProductType != null  and repProductType != ''">rep_product_type = #{repProductType},</if>
            <if test="electricIndex != null  and electricIndex != ''">electric_index = #{electricIndex},</if>
            <if test="gasIndex != null  and gasIndex != ''">gas_index = #{gasIndex},</if>
            <if test="steamIndex != null  and steamIndex != ''">steam_index = #{steamIndex},</if>
            <if test="varietyType != null  and varietyType != ''">variety_type = #{varietyType},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteGxdhCountById" parameterType="String">
        delete from gxdh_count where id = #{id}
    </delete>
 
    <delete id="deleteGxdhCountByIds" parameterType="String">
        delete from gxdh_count where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
    <select id="selectGxdhCountIndexList" parameterType="GxdhCountIndex" resultMap="GxdhCountIndexResult">
        <!--能源消耗量 或  产品产量的  焦炭的  电   煤气 蒸汽 -->
        SELECT
        aa.index_id,
        MAX ( CASE WHEN to_char(data_time,'mm') = '01'        THEN "value" END ) AS     A1    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '02'        THEN "value" END ) AS     A2    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '03'        THEN "value" END ) AS     A3    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '04'        THEN "value" END ) AS     A4    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '05'        THEN "value" END ) AS     A5    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '06'        THEN "value" END ) AS     A6    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '07'        THEN "value" END ) AS     A7    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '08'        THEN "value" END ) AS     A8    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '09'        THEN "value" END ) AS     A9    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '10'        THEN "value" END ) AS     A10    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '11'        THEN "value" END ) AS     A11    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '12'        THEN "value" END ) AS     A12    ,
        max(rep_product_type) rep_product_type,
        max(variety_type) variety_type,
        'DIAN' as FL
        FROM
        (
        SELECT
        a.index_id,
        "value",
        data_time,
        b.rep_product_type,
        b.variety_type
        FROM
        data_item a,
        gxdh_count b
        WHERE
        to_char(data_time,'YYYY') = #{selectYear}
        AND time_type = 'MONTH'
        and b.variety_type=#{varietyType}
        and b.rep_product_type=#{repProductType}
        and a.index_id = b.electric_index
        ) aa
        GROUP BY
        aa.index_id
        UNION all
        SELECT
        aa.index_id,
        MAX ( CASE WHEN to_char(data_time,'mm') = '01'        THEN "value" END ) AS     A1    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '02'        THEN "value" END ) AS     A2    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '03'        THEN "value" END ) AS     A3    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '04'        THEN "value" END ) AS     A4    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '05'        THEN "value" END ) AS     A5    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '06'        THEN "value" END ) AS     A6    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '07'        THEN "value" END ) AS     A7    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '08'        THEN "value" END ) AS     A8    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '09'        THEN "value" END ) AS     A9    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '10'        THEN "value" END ) AS     A10    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '11'        THEN "value" END ) AS     A11    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '12'        THEN "value" END ) AS     A12    ,
        max(rep_product_type),
        max(variety_type),
        'MQ' as FL
        FROM
        (
        SELECT
        a.index_id,
        "value",
        data_time,
        b.rep_product_type,
        b.variety_type
        FROM
        data_item a,
        gxdh_count b
        WHERE
        to_char(data_time,'YYYY') = #{selectYear}
        AND time_type = 'MONTH'
        and b.variety_type=#{varietyType}
        and b.rep_product_type=#{repProductType}
        and  a.index_id = b.gas_index
        ) aa
        GROUP BY
        aa.index_id
        UNION all
        SELECT
        aa.index_id,
        MAX ( CASE WHEN to_char(data_time,'mm') = '01'        THEN "value" END ) AS     A1    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '02'        THEN "value" END ) AS     A2    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '03'        THEN "value" END ) AS     A3    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '04'        THEN "value" END ) AS     A4    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '05'        THEN "value" END ) AS     A5    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '06'        THEN "value" END ) AS     A6    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '07'        THEN "value" END ) AS     A7    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '08'        THEN "value" END ) AS     A8    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '09'        THEN "value" END ) AS     A9    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '10'        THEN "value" END ) AS     A10    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '11'        THEN "value" END ) AS     A11    ,
        MAX ( CASE WHEN to_char(data_time,'mm') = '12'        THEN "value" END ) AS     A12    ,
        max(rep_product_type),
        max(variety_type),
        'ZQ' as FL
        FROM
        (
        SELECT
        a.index_id,
        "value",
        data_time,
        b.rep_product_type,
        b.variety_type
        FROM
        data_item a,
        gxdh_count b
        WHERE
        to_char(data_time,'YYYY') = #{selectYear}
        AND time_type = 'MONTH'
        and b.variety_type=#{varietyType}
        and b.rep_product_type=#{repProductType}
        and a.index_id = b.steam_index
        ) aa
        GROUP BY
        aa.index_id
    </select>
 
</mapper>