z1415143022
2025-03-25 75f9894ebac12b13c7ead27c3e16db833ee9251a
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
<?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.comprehensivestatistics.mapper.MonthlyComprehensiveMapper">
    <resultMap id="dataItemMap" type="com.zhitan.comprehensivestatistics.domain.MonthlyComprehensive">
        <result column="index_id" property="indexId"/>
        <result column="index_name" property="indexName"/>
        <result column="time_type" property="timeType"/>
        <result column="time_code" property="timeCode"/>
        <result column="unit_id" property="unitId"/>
        <result column="value1" property="value1"/>
        <result column="value2" property="value2"/>
        <result column="value3" property="value3"/>
        <result column="value4" property="value4"/>
        <result column="value5" property="value5"/>
        <result column="value6" property="value6"/>
        <result column="value7" property="value7"/>
        <result column="value8" property="value8"/>
        <result column="value9" property="value9"/>
        <result column="value10" property="value10"/>
        <result column="value11" property="value11"/>
        <result column="value12" property="value12"/>
        <result column="value13" property="value13"/>
        <result column="value14" property="value14"/>
        <result column="value15" property="value15"/>
        <result column="value16" property="value16"/>
        <result column="value17" property="value17"/>
        <result column="value18" property="value18"/>
        <result column="value19" property="value19"/>
        <result column="value20" property="value20"/>
        <result column="value21" property="value21"/>
        <result column="value22" property="value22"/>
        <result column="value23" property="value23"/>
        <result column="value24" property="value24"/>
        <result column="value25" property="value25"/>
        <result column="value26" property="value26"/>
        <result column="value27" property="value27"/>
        <result column="value28" property="value28"/>
        <result column="value29" property="value29"/>
        <result column="value30" property="value30"/>
        <result column="value31" property="value31"/>
    </resultMap>
    <!--全厂能耗统计-->
    <select id="getMonthlyComprehensiveList" resultMap="dataItemMap">
        SELECT
            aa.index_id,
            aa.index_name,
            aa.unit_id,
        <foreach item="item" index="index" collection="dataList">
            COALESCE ( MAX ( CASE WHEN data_time = #{item.dataTime} THEN "value" END ), null ) AS ${item.value},
        </foreach>
            aa.time_type,
            aa.order_num orderNum
        FROM
        (
            SELECT
                ni.index_id,
                ei."name" AS "index_name",
                ei.unit_id,
                di."value",
                di.data_time,
                di.time_type,
                mn.order_num
            FROM
                model_node mn
                LEFT JOIN node_index ni ON ni.node_id = mn.node_id
                LEFT JOIN energy_index ei ON ei.index_id = ni.index_id
                LEFT JOIN data_item di ON ni.index_id = di.index_id
            WHERE
                mn.parent_id = #{nodeId}
                AND di.data_time >= #{beginTime}
                AND di.data_time &lt;= #{endTime}
                AND di.time_type = #{timeType}
            <if test="indexStorageId !='' and indexStorageId !=null">
                and ei.energy_id=#{indexStorageId}
            </if>
        ) aa
        GROUP BY
        aa.index_id, aa.index_name, aa.unit_id, aa.time_type, aa.order_num
        ORDER BY aa.order_num ASC
    </select>
 
    <select id="getListChart" resultMap="dataItemMap">
        SELECT
            di.index_id,
            ci.name AS "index_name",
            ci.unit_id,
            di."value",
            di.data_time,
            di.time_type,
            di.time_code
        FROM
        data_item di LEFT JOIN energy_index ci ON di.index_id = ci.index_id
        WHERE
            di.index_id =#{indexId}
            AND di.data_time &lt;= #{endTime}
            AND di.data_time >= #{beginTime}
            AND di.time_type = #{timeType}
        ORDER BY
            di.time_code;
    </select>
</mapper>