@golemio/energetics 1.4.3-dev.1411262009 → 1.4.3-rc.1417628927
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/db/migrations/postgresql/sqls/20230116095151-correct_v_energetis_upadate-down.sql +27 -27
- package/db/migrations/postgresql/sqls/20230116095151-correct_v_energetis_upadate-up.sql +28 -28
- package/db/migrations/postgresql/sqls/20230202122506-v_energetics_last_updates-down.sql +64 -64
- package/db/migrations/postgresql/sqls/20230202122506-v_energetics_last_updates-up.sql +168 -168
- package/db/migrations/postgresql/sqls/20230208144859-v_energetics_last_updates_corr-down.sql +50 -50
- package/db/migrations/postgresql/sqls/20230208144859-v_energetics_last_updates_corr-up.sql +51 -51
- package/db/migrations/postgresql/sqls/20230216151258-new_views_out_of_prague-down.sql +461 -461
- package/db/migrations/postgresql/sqls/20230216151258-new_views_out_of_prague-up.sql +464 -464
- package/db/migrations/postgresql/sqls/20230220063725-another_view_out_of_prague_-down.sql +126 -126
- package/db/migrations/postgresql/sqls/20230220063725-another_view_out_of_prague_-up.sql +127 -127
- package/db/migrations/postgresql/sqls/20230220132403-v_gas_reserve_correct-down.sql +111 -111
- package/db/migrations/postgresql/sqls/20230220132403-v_gas_reserve_correct-up.sql +110 -110
- package/dist/integration-engine/commodity-providers/ioc/Di.js +1 -1
- package/dist/integration-engine/commodity-providers/ioc/Di.js.map +1 -1
- package/docs/index.md +3 -0
- package/package.json +3 -3
|
@@ -1,461 +1,461 @@
|
|
|
1
|
-
CREATE OR REPLACE VIEW v_consumption_energy_delta
|
|
2
|
-
AS WITH delta AS (
|
|
3
|
-
SELECT es.time_utc,
|
|
4
|
-
es.addr,
|
|
5
|
-
es.var,
|
|
6
|
-
es.commodity,
|
|
7
|
-
es.unit,
|
|
8
|
-
es.value,
|
|
9
|
-
es.meter,
|
|
10
|
-
lag(es.value) OVER (PARTITION BY es.addr, es.var, es.meter ORDER BY es.time_utc) AS last_value,
|
|
11
|
-
lag(es.time_utc) OVER (PARTITION BY es.addr, es.var, es.meter ORDER BY es.time_utc) AS last_timeutc,
|
|
12
|
-
es.value - lag(es.value) OVER (PARTITION BY es.addr, es.var, es.meter ORDER BY es.time_utc) AS delta_value,
|
|
13
|
-
min.consumption_min AS prumerna_spotreba,
|
|
14
|
-
date_part('epoch'::text, es.time_utc - lag(es.time_utc) OVER (PARTITION BY es.addr, es.var, es.meter ORDER BY es.time_utc)) / 60::double precision AS minut_mereni
|
|
15
|
-
FROM energetics.consumption_energy_consumption es
|
|
16
|
-
JOIN energetics.v_consumption_energy_avg_consumption_min min ON es.addr::text = min.addr::text AND es.var::text = min.var::text AND es.meter::text = min.meter::text
|
|
17
|
-
WHERE es.var::text = 'core'::text AND (es.addr::text ~~ '%F%'::text OR es.addr::text = '/2.1/VP2'::text) AND es.value > 0::numeric
|
|
18
|
-
)
|
|
19
|
-
SELECT delta.time_utc,
|
|
20
|
-
delta.addr,
|
|
21
|
-
delta.var,
|
|
22
|
-
delta.commodity,
|
|
23
|
-
delta.unit,
|
|
24
|
-
delta.value,
|
|
25
|
-
delta.meter,
|
|
26
|
-
delta.last_value,
|
|
27
|
-
delta.last_timeutc,
|
|
28
|
-
CASE
|
|
29
|
-
WHEN abs(delta.delta_value::double precision / 60::double precision) > abs(1000::double precision * delta.prumerna_spotreba) THEN 0::numeric
|
|
30
|
-
ELSE delta.delta_value
|
|
31
|
-
END AS delta_value,
|
|
32
|
-
delta.minut_mereni
|
|
33
|
-
FROM delta;
|
|
34
|
-
|
|
35
|
-
CREATE OR REPLACE VIEW v_consumption_energy_buildings_real
|
|
36
|
-
AS SELECT consumption_energy_buildings.id,
|
|
37
|
-
consumption_energy_buildings.building_name,
|
|
38
|
-
consumption_energy_buildings.description,
|
|
39
|
-
consumption_energy_buildings.building_address_code,
|
|
40
|
-
consumption_energy_buildings.building_label,
|
|
41
|
-
consumption_energy_buildings.current_note,
|
|
42
|
-
consumption_energy_buildings.main_use,
|
|
43
|
-
consumption_energy_buildings.secondary_use,
|
|
44
|
-
consumption_energy_buildings.year_of_construction,
|
|
45
|
-
consumption_energy_buildings.method_of_protection,
|
|
46
|
-
consumption_energy_buildings.built_up_area,
|
|
47
|
-
consumption_energy_buildings.heated_bulding_volume,
|
|
48
|
-
consumption_energy_buildings.students_count,
|
|
49
|
-
consumption_energy_buildings.employees_count,
|
|
50
|
-
consumption_energy_buildings.classrooms_count,
|
|
51
|
-
consumption_energy_buildings.beds_count,
|
|
52
|
-
consumption_energy_buildings.eno_id,
|
|
53
|
-
consumption_energy_buildings.csu_code,
|
|
54
|
-
consumption_energy_buildings.ku_code,
|
|
55
|
-
consumption_energy_buildings.allotment_number,
|
|
56
|
-
consumption_energy_buildings.registration_unit,
|
|
57
|
-
consumption_energy_buildings.gas_consumption_normatives,
|
|
58
|
-
consumption_energy_buildings.heat_consumption_normatives,
|
|
59
|
-
consumption_energy_buildings.water_consumption_normatives,
|
|
60
|
-
consumption_energy_buildings.electricity_consumption_normatives_per_person,
|
|
61
|
-
consumption_energy_buildings.electricity_consumption_normatives,
|
|
62
|
-
consumption_energy_buildings.energetic_management,
|
|
63
|
-
consumption_energy_buildings.opening_hours,
|
|
64
|
-
consumption_energy_buildings.weekend_opening_hours,
|
|
65
|
-
consumption_energy_buildings.latitude,
|
|
66
|
-
consumption_energy_buildings.longitude,
|
|
67
|
-
consumption_energy_buildings.address_street,
|
|
68
|
-
consumption_energy_buildings.address_house_number,
|
|
69
|
-
consumption_energy_buildings.address_city,
|
|
70
|
-
consumption_energy_buildings.address_country,
|
|
71
|
-
consumption_energy_buildings.address_mail,
|
|
72
|
-
consumption_energy_buildings.address_phone,
|
|
73
|
-
consumption_energy_buildings.address_web_address,
|
|
74
|
-
consumption_energy_buildings.penb_penbnumber,
|
|
75
|
-
consumption_energy_buildings.penb_issue_date,
|
|
76
|
-
consumption_energy_buildings.penb_total_building_envelope_area,
|
|
77
|
-
consumption_energy_buildings.penb_volume_factor_of_avshape,
|
|
78
|
-
consumption_energy_buildings.penb_total_energy_reference_area,
|
|
79
|
-
consumption_energy_buildings.penb_total_provided_energy,
|
|
80
|
-
consumption_energy_buildings.penb_total_provided_energy_category,
|
|
81
|
-
consumption_energy_buildings.penb_primary_non_renewable_energy,
|
|
82
|
-
consumption_energy_buildings.penb_primary_non_renewable_energy_category,
|
|
83
|
-
consumption_energy_buildings.penb_building_envelope,
|
|
84
|
-
consumption_energy_buildings.penb_building_envelope_category,
|
|
85
|
-
consumption_energy_buildings.penb_heating,
|
|
86
|
-
consumption_energy_buildings.penb_heating_category,
|
|
87
|
-
consumption_energy_buildings.penb_cooling,
|
|
88
|
-
consumption_energy_buildings.penb_cooling_category,
|
|
89
|
-
consumption_energy_buildings.penb_ventilation,
|
|
90
|
-
consumption_energy_buildings.penb_ventilation_category,
|
|
91
|
-
consumption_energy_buildings.penb_humidity_adjustment,
|
|
92
|
-
consumption_energy_buildings.penb_humidity_adjustment_category,
|
|
93
|
-
consumption_energy_buildings.penb_warm_water,
|
|
94
|
-
consumption_energy_buildings.penb_warm_water_category,
|
|
95
|
-
consumption_energy_buildings.penb_lighting,
|
|
96
|
-
consumption_energy_buildings.penb_lighting_category,
|
|
97
|
-
consumption_energy_buildings.energy_audits_energy_audit,
|
|
98
|
-
consumption_energy_buildings.energy_audits_earegistration_number,
|
|
99
|
-
consumption_energy_buildings.energy_audits_created_at,
|
|
100
|
-
consumption_energy_buildings.building_envelope_side_wall_prevailing_construction,
|
|
101
|
-
consumption_energy_buildings.building_envelope_side_wall_area,
|
|
102
|
-
consumption_energy_buildings.building_envelope_side_wall_heat_insulation,
|
|
103
|
-
consumption_energy_buildings.building_envelope_side_wall_year_of_adjustment,
|
|
104
|
-
consumption_energy_buildings.building_envelope_side_wall_technical_condition,
|
|
105
|
-
consumption_energy_buildings.building_envelope_filling_of_hole_construction,
|
|
106
|
-
consumption_energy_buildings.building_envelope_filling_of_hole_area,
|
|
107
|
-
consumption_energy_buildings.building_envelope_filling_of_hole_year_of_adjustment,
|
|
108
|
-
consumption_energy_buildings.building_envelope_filling_of_hole_technical_condition,
|
|
109
|
-
consumption_energy_buildings.building_envelope_roof_construction,
|
|
110
|
-
consumption_energy_buildings.building_envelope_roof_area,
|
|
111
|
-
consumption_energy_buildings.building_envelope_roof_thermal_insulation,
|
|
112
|
-
consumption_energy_buildings.building_envelope_roof_year_of_adjustment,
|
|
113
|
-
consumption_energy_buildings.building_envelope_roof_technical_condition,
|
|
114
|
-
consumption_energy_buildings.building_envelope_floor_of_the_lowest_heated_floor_construction,
|
|
115
|
-
consumption_energy_buildings.building_envelope_floor_of_the_lowest_heated_floor_area,
|
|
116
|
-
consumption_energy_buildings.floor_of_the_lowest_heated_floor_thermal_insulation,
|
|
117
|
-
consumption_energy_buildings.building_envelope_floor_of_the_lowest_heated_floor_year_of_adju,
|
|
118
|
-
consumption_energy_buildings.floor_of_the_lowest_heated_floor_technical_condition,
|
|
119
|
-
consumption_energy_buildings.fuel_and_energy_coal,
|
|
120
|
-
consumption_energy_buildings.fuel_and_energy_gas,
|
|
121
|
-
consumption_energy_buildings.fuel_and_energy_electricity,
|
|
122
|
-
consumption_energy_buildings.fuel_and_energy_czt,
|
|
123
|
-
consumption_energy_buildings.fuel_and_energy_oze,
|
|
124
|
-
consumption_energy_buildings.fuel_and_energy_other,
|
|
125
|
-
consumption_energy_buildings.technical_equipment_heating_main_source_of_heat,
|
|
126
|
-
consumption_energy_buildings.technical_equipment_heating_heat_percentage,
|
|
127
|
-
consumption_energy_buildings.technical_equipment_heating_secondary_source_of_heat,
|
|
128
|
-
consumption_energy_buildings.technical_equipment_heating_heating_system,
|
|
129
|
-
consumption_energy_buildings.technical_equipment_heating_year,
|
|
130
|
-
consumption_energy_buildings.technical_equipment_heating_technical_condition,
|
|
131
|
-
consumption_energy_buildings.technical_equipment_cooling_cooling_system,
|
|
132
|
-
consumption_energy_buildings.technical_equipment_cooling_cooling_area_percentage,
|
|
133
|
-
consumption_energy_buildings.technical_equipment_cooling_year,
|
|
134
|
-
consumption_energy_buildings.technical_equipment_cooling_technical_condition,
|
|
135
|
-
consumption_energy_buildings.technical_equipment_ventilation_ventilation,
|
|
136
|
-
consumption_energy_buildings.technical_equipment_ventilation_year,
|
|
137
|
-
consumption_energy_buildings.technical_equipment_ventilation_technical_condition,
|
|
138
|
-
consumption_energy_buildings.technical_equipment_humidity_adjustment_humidity_adjustment,
|
|
139
|
-
consumption_energy_buildings.technical_equipment_humidity_adjustment_year,
|
|
140
|
-
consumption_energy_buildings.technical_equipment_humidity_adjustment_technical_condition,
|
|
141
|
-
consumption_energy_buildings.technical_equipment_hot_water_predominant_way_of_heating_tv,
|
|
142
|
-
consumption_energy_buildings.technical_equipment_hot_water_hot_water_source,
|
|
143
|
-
consumption_energy_buildings.technical_equipment_hot_water_year,
|
|
144
|
-
consumption_energy_buildings.technical_equipment_hot_water_technical_condition,
|
|
145
|
-
consumption_energy_buildings.technical_equipment_lighting_lighting,
|
|
146
|
-
consumption_energy_buildings.technical_equipment_lighting_year,
|
|
147
|
-
consumption_energy_buildings.technical_equipment_lighting_technical_condition,
|
|
148
|
-
consumption_energy_buildings.technical_equipment_lighting_other_technological_elements,
|
|
149
|
-
consumption_energy_buildings.technical_equipment_lighting_measurement_method,
|
|
150
|
-
consumption_energy_buildings.oze_energy_production_solar_energy_photovoltaic,
|
|
151
|
-
consumption_energy_buildings.oze_energy_production_solar_energy_photothermal,
|
|
152
|
-
consumption_energy_buildings.oze_energy_production_integrated_turbines_wind_energy,
|
|
153
|
-
consumption_energy_buildings.oze_energy_production_heat_pump,
|
|
154
|
-
consumption_energy_buildings.waste_and_emissions_solid_waste_production,
|
|
155
|
-
consumption_energy_buildings.waste_and_emissions_tied_co2_emissions,
|
|
156
|
-
consumption_energy_buildings.waste_and_emissions_sox_emissions,
|
|
157
|
-
consumption_energy_buildings.waste_and_emissions_operating_co_2emissions,
|
|
158
|
-
consumption_energy_buildings.link
|
|
159
|
-
FROM energetics.consumption_energy_buildings
|
|
160
|
-
WHERE consumption_energy_buildings.building_label::text <> ALL (ARRAY['ZKB 1'::character varying::text, 'ZKB 2'::character varying::text, 'TB1'::character varying::text, 'TB2'::character varying::text]);
|
|
161
|
-
|
|
162
|
-
CREATE OR REPLACE VIEW v_consumption_energy_buildings_w_data
|
|
163
|
-
AS SELECT consumption_energy_buildings.id,
|
|
164
|
-
consumption_energy_buildings.building_name,
|
|
165
|
-
consumption_energy_buildings.description,
|
|
166
|
-
consumption_energy_buildings.building_address_code,
|
|
167
|
-
consumption_energy_buildings.building_label,
|
|
168
|
-
consumption_energy_buildings.current_note,
|
|
169
|
-
consumption_energy_buildings.main_use,
|
|
170
|
-
consumption_energy_buildings.secondary_use,
|
|
171
|
-
consumption_energy_buildings.year_of_construction,
|
|
172
|
-
consumption_energy_buildings.method_of_protection,
|
|
173
|
-
consumption_energy_buildings.built_up_area,
|
|
174
|
-
consumption_energy_buildings.heated_bulding_volume,
|
|
175
|
-
consumption_energy_buildings.students_count,
|
|
176
|
-
consumption_energy_buildings.employees_count,
|
|
177
|
-
consumption_energy_buildings.classrooms_count,
|
|
178
|
-
consumption_energy_buildings.beds_count,
|
|
179
|
-
consumption_energy_buildings.eno_id,
|
|
180
|
-
consumption_energy_buildings.csu_code,
|
|
181
|
-
consumption_energy_buildings.ku_code,
|
|
182
|
-
consumption_energy_buildings.allotment_number,
|
|
183
|
-
consumption_energy_buildings.registration_unit,
|
|
184
|
-
consumption_energy_buildings.gas_consumption_normatives,
|
|
185
|
-
consumption_energy_buildings.heat_consumption_normatives,
|
|
186
|
-
consumption_energy_buildings.water_consumption_normatives,
|
|
187
|
-
consumption_energy_buildings.electricity_consumption_normatives_per_person,
|
|
188
|
-
consumption_energy_buildings.electricity_consumption_normatives,
|
|
189
|
-
consumption_energy_buildings.energetic_management,
|
|
190
|
-
consumption_energy_buildings.opening_hours,
|
|
191
|
-
consumption_energy_buildings.weekend_opening_hours,
|
|
192
|
-
consumption_energy_buildings.latitude,
|
|
193
|
-
consumption_energy_buildings.longitude,
|
|
194
|
-
consumption_energy_buildings.address_street,
|
|
195
|
-
consumption_energy_buildings.address_house_number,
|
|
196
|
-
consumption_energy_buildings.address_city,
|
|
197
|
-
consumption_energy_buildings.address_country,
|
|
198
|
-
consumption_energy_buildings.address_mail,
|
|
199
|
-
consumption_energy_buildings.address_phone,
|
|
200
|
-
consumption_energy_buildings.address_web_address,
|
|
201
|
-
consumption_energy_buildings.penb_penbnumber,
|
|
202
|
-
consumption_energy_buildings.penb_issue_date,
|
|
203
|
-
consumption_energy_buildings.penb_total_building_envelope_area,
|
|
204
|
-
consumption_energy_buildings.penb_volume_factor_of_avshape,
|
|
205
|
-
consumption_energy_buildings.penb_total_energy_reference_area,
|
|
206
|
-
consumption_energy_buildings.penb_total_provided_energy,
|
|
207
|
-
consumption_energy_buildings.penb_total_provided_energy_category,
|
|
208
|
-
consumption_energy_buildings.penb_primary_non_renewable_energy,
|
|
209
|
-
consumption_energy_buildings.penb_primary_non_renewable_energy_category,
|
|
210
|
-
consumption_energy_buildings.penb_building_envelope,
|
|
211
|
-
consumption_energy_buildings.penb_building_envelope_category,
|
|
212
|
-
consumption_energy_buildings.penb_heating,
|
|
213
|
-
consumption_energy_buildings.penb_heating_category,
|
|
214
|
-
consumption_energy_buildings.penb_cooling,
|
|
215
|
-
consumption_energy_buildings.penb_cooling_category,
|
|
216
|
-
consumption_energy_buildings.penb_ventilation,
|
|
217
|
-
consumption_energy_buildings.penb_ventilation_category,
|
|
218
|
-
consumption_energy_buildings.penb_humidity_adjustment,
|
|
219
|
-
consumption_energy_buildings.penb_humidity_adjustment_category,
|
|
220
|
-
consumption_energy_buildings.penb_warm_water,
|
|
221
|
-
consumption_energy_buildings.penb_warm_water_category,
|
|
222
|
-
consumption_energy_buildings.penb_lighting,
|
|
223
|
-
consumption_energy_buildings.penb_lighting_category,
|
|
224
|
-
consumption_energy_buildings.energy_audits_energy_audit,
|
|
225
|
-
consumption_energy_buildings.energy_audits_earegistration_number,
|
|
226
|
-
consumption_energy_buildings.energy_audits_created_at,
|
|
227
|
-
consumption_energy_buildings.building_envelope_side_wall_prevailing_construction,
|
|
228
|
-
consumption_energy_buildings.building_envelope_side_wall_area,
|
|
229
|
-
consumption_energy_buildings.building_envelope_side_wall_heat_insulation,
|
|
230
|
-
consumption_energy_buildings.building_envelope_side_wall_year_of_adjustment,
|
|
231
|
-
consumption_energy_buildings.building_envelope_side_wall_technical_condition,
|
|
232
|
-
consumption_energy_buildings.building_envelope_filling_of_hole_construction,
|
|
233
|
-
consumption_energy_buildings.building_envelope_filling_of_hole_area,
|
|
234
|
-
consumption_energy_buildings.building_envelope_filling_of_hole_year_of_adjustment,
|
|
235
|
-
consumption_energy_buildings.building_envelope_filling_of_hole_technical_condition,
|
|
236
|
-
consumption_energy_buildings.building_envelope_roof_construction,
|
|
237
|
-
consumption_energy_buildings.building_envelope_roof_area,
|
|
238
|
-
consumption_energy_buildings.building_envelope_roof_thermal_insulation,
|
|
239
|
-
consumption_energy_buildings.building_envelope_roof_year_of_adjustment,
|
|
240
|
-
consumption_energy_buildings.building_envelope_roof_technical_condition,
|
|
241
|
-
consumption_energy_buildings.building_envelope_floor_of_the_lowest_heated_floor_construction,
|
|
242
|
-
consumption_energy_buildings.building_envelope_floor_of_the_lowest_heated_floor_area,
|
|
243
|
-
consumption_energy_buildings.floor_of_the_lowest_heated_floor_thermal_insulation,
|
|
244
|
-
consumption_energy_buildings.building_envelope_floor_of_the_lowest_heated_floor_year_of_adju,
|
|
245
|
-
consumption_energy_buildings.floor_of_the_lowest_heated_floor_technical_condition,
|
|
246
|
-
consumption_energy_buildings.fuel_and_energy_coal,
|
|
247
|
-
consumption_energy_buildings.fuel_and_energy_gas,
|
|
248
|
-
consumption_energy_buildings.fuel_and_energy_electricity,
|
|
249
|
-
consumption_energy_buildings.fuel_and_energy_czt,
|
|
250
|
-
consumption_energy_buildings.fuel_and_energy_oze,
|
|
251
|
-
consumption_energy_buildings.fuel_and_energy_other,
|
|
252
|
-
consumption_energy_buildings.technical_equipment_heating_main_source_of_heat,
|
|
253
|
-
consumption_energy_buildings.technical_equipment_heating_heat_percentage,
|
|
254
|
-
consumption_energy_buildings.technical_equipment_heating_secondary_source_of_heat,
|
|
255
|
-
consumption_energy_buildings.technical_equipment_heating_heating_system,
|
|
256
|
-
consumption_energy_buildings.technical_equipment_heating_year,
|
|
257
|
-
consumption_energy_buildings.technical_equipment_heating_technical_condition,
|
|
258
|
-
consumption_energy_buildings.technical_equipment_cooling_cooling_system,
|
|
259
|
-
consumption_energy_buildings.technical_equipment_cooling_cooling_area_percentage,
|
|
260
|
-
consumption_energy_buildings.technical_equipment_cooling_year,
|
|
261
|
-
consumption_energy_buildings.technical_equipment_cooling_technical_condition,
|
|
262
|
-
consumption_energy_buildings.technical_equipment_ventilation_ventilation,
|
|
263
|
-
consumption_energy_buildings.technical_equipment_ventilation_year,
|
|
264
|
-
consumption_energy_buildings.technical_equipment_ventilation_technical_condition,
|
|
265
|
-
consumption_energy_buildings.technical_equipment_humidity_adjustment_humidity_adjustment,
|
|
266
|
-
consumption_energy_buildings.technical_equipment_humidity_adjustment_year,
|
|
267
|
-
consumption_energy_buildings.technical_equipment_humidity_adjustment_technical_condition,
|
|
268
|
-
consumption_energy_buildings.technical_equipment_hot_water_predominant_way_of_heating_tv,
|
|
269
|
-
consumption_energy_buildings.technical_equipment_hot_water_hot_water_source,
|
|
270
|
-
consumption_energy_buildings.technical_equipment_hot_water_year,
|
|
271
|
-
consumption_energy_buildings.technical_equipment_hot_water_technical_condition,
|
|
272
|
-
consumption_energy_buildings.technical_equipment_lighting_lighting,
|
|
273
|
-
consumption_energy_buildings.technical_equipment_lighting_year,
|
|
274
|
-
consumption_energy_buildings.technical_equipment_lighting_technical_condition,
|
|
275
|
-
consumption_energy_buildings.technical_equipment_lighting_other_technological_elements,
|
|
276
|
-
consumption_energy_buildings.technical_equipment_lighting_measurement_method,
|
|
277
|
-
consumption_energy_buildings.oze_energy_production_solar_energy_photovoltaic,
|
|
278
|
-
consumption_energy_buildings.oze_energy_production_solar_energy_photothermal,
|
|
279
|
-
consumption_energy_buildings.oze_energy_production_integrated_turbines_wind_energy,
|
|
280
|
-
consumption_energy_buildings.oze_energy_production_heat_pump,
|
|
281
|
-
consumption_energy_buildings.waste_and_emissions_solid_waste_production,
|
|
282
|
-
consumption_energy_buildings.waste_and_emissions_tied_co2_emissions,
|
|
283
|
-
consumption_energy_buildings.waste_and_emissions_sox_emissions,
|
|
284
|
-
consumption_energy_buildings.waste_and_emissions_operating_co_2emissions,
|
|
285
|
-
consumption_energy_buildings.link
|
|
286
|
-
FROM energetics.consumption_energy_buildings
|
|
287
|
-
WHERE (btrim(consumption_energy_buildings.building_address_code::text) IN ( SELECT DISTINCT v_consumption_energy_consumption.building_address_code
|
|
288
|
-
FROM energetics.v_consumption_energy_consumption)) AND consumption_energy_buildings.building_address_code::text !~~ '10.%'::text;
|
|
289
|
-
|
|
290
|
-
CREATE OR REPLACE VIEW v_consumption_energy_consumption_month_el_f
|
|
291
|
-
AS SELECT date_part('year'::text, consumption_energy_consumption.time_utc) AS rok,
|
|
292
|
-
date_part('month'::text, consumption_energy_consumption.time_utc) AS mesic,
|
|
293
|
-
consumption_energy_consumption.addr,
|
|
294
|
-
consumption_energy_consumption.var,
|
|
295
|
-
consumption_energy_consumption.commodity,
|
|
296
|
-
consumption_energy_consumption.unit,
|
|
297
|
-
sum(consumption_energy_consumption.value::numeric(10,2)) / 4::numeric AS value,
|
|
298
|
-
max(consumption_energy_consumption.time_utc::date) AS data_do,
|
|
299
|
-
count(*) AS count
|
|
300
|
-
FROM energetics.consumption_energy_consumption
|
|
301
|
-
WHERE (consumption_energy_consumption.var::text = ANY (ARRAY['EFwActi'::character varying::text, 'EFwActiNT'::character varying::text, 'EFwActi'::character varying::text])) AND consumption_energy_consumption.addr::text ~~ '%/EF%'::text
|
|
302
|
-
GROUP BY (date_part('year'::text, consumption_energy_consumption.time_utc)), (date_part('month'::text, consumption_energy_consumption.time_utc)), consumption_energy_consumption.addr, consumption_energy_consumption.var, consumption_energy_consumption.commodity, consumption_energy_consumption.unit
|
|
303
|
-
UNION
|
|
304
|
-
SELECT v_consumption_vrtbovsky_palac.measure_year AS rok,
|
|
305
|
-
v_consumption_vrtbovsky_palac.measure_month AS mesic,
|
|
306
|
-
v_consumption_vrtbovsky_palac.addr::character varying(255) AS addr,
|
|
307
|
-
v_consumption_vrtbovsky_palac.var::character varying(255) AS var,
|
|
308
|
-
v_consumption_vrtbovsky_palac.commodity::character varying(255) AS commodity,
|
|
309
|
-
v_consumption_vrtbovsky_palac.unit::character varying(255) AS unit,
|
|
310
|
-
sum(v_consumption_vrtbovsky_palac.consumption) AS value,
|
|
311
|
-
v_consumption_vrtbovsky_palac.data_do::date AS data_do,
|
|
312
|
-
count(*) AS count
|
|
313
|
-
FROM energetics.v_consumption_vrtbovsky_palac
|
|
314
|
-
WHERE v_consumption_vrtbovsky_palac.commodity = 'electricity'::text
|
|
315
|
-
GROUP BY v_consumption_vrtbovsky_palac.measure_year, v_consumption_vrtbovsky_palac.measure_month, v_consumption_vrtbovsky_palac.data_do, v_consumption_vrtbovsky_palac.addr, v_consumption_vrtbovsky_palac.var, v_consumption_vrtbovsky_palac.commodity, v_consumption_vrtbovsky_palac.unit;
|
|
316
|
-
|
|
317
|
-
CREATE OR REPLACE VIEW v_consumption_gas_reserve
|
|
318
|
-
AS WITH kalendar AS (
|
|
319
|
-
SELECT den.den::date AS den
|
|
320
|
-
FROM generate_series('2019-01-01 00:00:00+01'::timestamp with time zone, now() - '1 day'::interval, '1 day'::interval) den(den)
|
|
321
|
-
), meraky AS (
|
|
322
|
-
SELECT DISTINCT consumption_energy_devices.addr
|
|
323
|
-
FROM energetics.consumption_energy_devices
|
|
324
|
-
WHERE consumption_energy_devices.meter_type::text = 'Plynoměr'::text
|
|
325
|
-
), daily_delta_core AS (
|
|
326
|
-
SELECT date_trunc('day'::text, v_consumption_energy_delta.time_utc - '06:00:00'::interval)::date AS measured_from,
|
|
327
|
-
v_consumption_energy_delta.addr,
|
|
328
|
-
v_consumption_energy_delta.var,
|
|
329
|
-
sum(v_consumption_energy_delta.delta_value) AS delta_value
|
|
330
|
-
FROM energetics.v_consumption_energy_delta
|
|
331
|
-
WHERE v_consumption_energy_delta.commodity::text = 'gas'::text AND date_part('year'::text, v_consumption_energy_delta.time_utc - '06:00:00'::interval) >= 2019::double precision
|
|
332
|
-
GROUP BY (date_trunc('day'::text, v_consumption_energy_delta.time_utc - '06:00:00'::interval)::date), v_consumption_energy_delta.addr, v_consumption_energy_delta.var
|
|
333
|
-
), daily_delta_core2 AS (
|
|
334
|
-
SELECT date_trunc('day'::text, consumption_energy_consumption.time_utc - '06:00:00'::interval)::date AS measured_from,
|
|
335
|
-
consumption_energy_consumption.addr,
|
|
336
|
-
consumption_energy_consumption.var,
|
|
337
|
-
sum(consumption_energy_consumption.value) AS delta_value
|
|
338
|
-
FROM energetics.consumption_energy_consumption
|
|
339
|
-
WHERE consumption_energy_consumption.var::text = 'core2'::text AND consumption_energy_consumption.time_utc::date > '2018-12-31'::date
|
|
340
|
-
GROUP BY (date_trunc('day'::text, consumption_energy_consumption.time_utc - '06:00:00'::interval)::date), consumption_energy_consumption.addr, consumption_energy_consumption.var
|
|
341
|
-
), delta_dates AS (
|
|
342
|
-
SELECT daily_delta_core.measured_from,
|
|
343
|
-
daily_delta_core.addr,
|
|
344
|
-
daily_delta_core.var,
|
|
345
|
-
daily_delta_core.delta_value,
|
|
346
|
-
lag(daily_delta_core.measured_from, 1) OVER (PARTITION BY daily_delta_core.addr ORDER BY daily_delta_core.measured_from) AS measured_before,
|
|
347
|
-
lead(daily_delta_core.measured_from, 1) OVER (PARTITION BY daily_delta_core.addr ORDER BY daily_delta_core.measured_from) AS measured_after,
|
|
348
|
-
lag(daily_delta_core.delta_value, 1) OVER (PARTITION BY daily_delta_core.addr ORDER BY daily_delta_core.measured_from) AS delta_before,
|
|
349
|
-
lead(daily_delta_core.delta_value, 1) OVER (PARTITION BY daily_delta_core.addr ORDER BY daily_delta_core.measured_from) AS delta_after
|
|
350
|
-
FROM daily_delta_core
|
|
351
|
-
), delta_date_diff AS (
|
|
352
|
-
SELECT delta_dates.measured_from,
|
|
353
|
-
delta_dates.addr,
|
|
354
|
-
delta_dates.var,
|
|
355
|
-
delta_dates.delta_value,
|
|
356
|
-
delta_dates.measured_before,
|
|
357
|
-
delta_dates.measured_after,
|
|
358
|
-
delta_dates.delta_before,
|
|
359
|
-
delta_dates.delta_after,
|
|
360
|
-
CASE
|
|
361
|
-
WHEN (delta_dates.measured_after - delta_dates.measured_from) > 1 AND (delta_dates.measured_from - delta_dates.measured_before) > 1 THEN 'mid'::text
|
|
362
|
-
WHEN (delta_dates.measured_after - delta_dates.measured_from) > 1 THEN 'begin'::text
|
|
363
|
-
WHEN (delta_dates.measured_from - delta_dates.measured_before) > 1 THEN 'end'::text
|
|
364
|
-
ELSE 'ok'::text
|
|
365
|
-
END AS value_type,
|
|
366
|
-
CASE
|
|
367
|
-
WHEN (delta_dates.measured_after - delta_dates.measured_from) > 1 AND (delta_dates.measured_from - delta_dates.measured_before) > 1 THEN (delta_dates.delta_value / 2::numeric + delta_dates.delta_after) / (delta_dates.measured_after - delta_dates.measured_from + 1)::numeric
|
|
368
|
-
WHEN (delta_dates.measured_after - delta_dates.measured_from) > 1 THEN (delta_dates.delta_value + delta_dates.delta_after) / (delta_dates.measured_after - delta_dates.measured_from + 1)::numeric
|
|
369
|
-
ELSE NULL::numeric
|
|
370
|
-
END AS fix
|
|
371
|
-
FROM delta_dates
|
|
372
|
-
), joined_table AS (
|
|
373
|
-
SELECT kalendar.den AS measured_from,
|
|
374
|
-
meraky.addr,
|
|
375
|
-
diff.delta_value,
|
|
376
|
-
diff.value_type,
|
|
377
|
-
diff.fix,
|
|
378
|
-
core2.delta_value AS core2_delta,
|
|
379
|
-
CASE
|
|
380
|
-
WHEN diff.value_type = 'ok'::text THEN COALESCE(core2.delta_value, diff.delta_value)
|
|
381
|
-
ELSE diff.fix
|
|
382
|
-
END AS final_fix,
|
|
383
|
-
CASE
|
|
384
|
-
WHEN diff.value_type = 'ok'::text THEN COALESCE(core2.var, diff.var)
|
|
385
|
-
ELSE 'core'::character varying
|
|
386
|
-
END AS final_var
|
|
387
|
-
FROM kalendar
|
|
388
|
-
LEFT JOIN meraky ON true
|
|
389
|
-
LEFT JOIN delta_date_diff diff ON diff.measured_from = kalendar.den AND diff.addr::text = meraky.addr::text
|
|
390
|
-
LEFT JOIN daily_delta_core2 core2 ON core2.measured_from = kalendar.den AND core2.addr::text = meraky.addr::text
|
|
391
|
-
ORDER BY meraky.addr, kalendar.den
|
|
392
|
-
), fixed_table AS (
|
|
393
|
-
SELECT q.measured_from,
|
|
394
|
-
q.addr,
|
|
395
|
-
q.delta_value,
|
|
396
|
-
q.value_type,
|
|
397
|
-
q.fix,
|
|
398
|
-
q.core2_delta,
|
|
399
|
-
q.final_fix,
|
|
400
|
-
q.final_var,
|
|
401
|
-
q.value_partition,
|
|
402
|
-
first_value(q.final_fix) OVER w AS value
|
|
403
|
-
FROM ( SELECT joined_table.measured_from,
|
|
404
|
-
joined_table.addr,
|
|
405
|
-
joined_table.delta_value,
|
|
406
|
-
joined_table.value_type,
|
|
407
|
-
joined_table.fix,
|
|
408
|
-
joined_table.core2_delta,
|
|
409
|
-
joined_table.final_fix,
|
|
410
|
-
joined_table.final_var,
|
|
411
|
-
sum(
|
|
412
|
-
CASE
|
|
413
|
-
WHEN joined_table.final_fix IS NULL THEN 0
|
|
414
|
-
ELSE 1
|
|
415
|
-
END) OVER (PARTITION BY joined_table.addr ORDER BY joined_table.measured_from) AS value_partition
|
|
416
|
-
FROM joined_table) q
|
|
417
|
-
WINDOW w AS (PARTITION BY q.addr, q.value_partition ORDER BY q.measured_from)
|
|
418
|
-
)
|
|
419
|
-
SELECT fixed_table.measured_from,
|
|
420
|
-
fixed_table.addr,
|
|
421
|
-
fixed_table.value AS delta_value,
|
|
422
|
-
fixed_table.final_var,
|
|
423
|
-
row_number() OVER (PARTITION BY fixed_table.addr, (date_trunc('month'::text, fixed_table.measured_from::timestamp with time zone)) ORDER BY fixed_table.value DESC) AS ran
|
|
424
|
-
FROM fixed_table
|
|
425
|
-
WHERE fixed_table.value IS NOT NULL;
|
|
426
|
-
|
|
427
|
-
CREATE OR REPLACE VIEW v_consumption_energy_devices_active
|
|
428
|
-
AS SELECT consumption_energy_devices.id,
|
|
429
|
-
consumption_energy_devices.addr,
|
|
430
|
-
consumption_energy_devices.description,
|
|
431
|
-
consumption_energy_devices.meter_number,
|
|
432
|
-
consumption_energy_devices.meter_index,
|
|
433
|
-
consumption_energy_devices.location_number,
|
|
434
|
-
consumption_energy_devices.location_description,
|
|
435
|
-
consumption_energy_devices.include_in_evaluation,
|
|
436
|
-
consumption_energy_devices.meter_type,
|
|
437
|
-
consumption_energy_devices.category,
|
|
438
|
-
consumption_energy_devices.unit,
|
|
439
|
-
consumption_energy_devices.replaced_meter_id,
|
|
440
|
-
consumption_energy_devices.deleted,
|
|
441
|
-
consumption_energy_devices.building_id
|
|
442
|
-
FROM energetics.consumption_energy_devices
|
|
443
|
-
WHERE NOT (consumption_energy_devices.id IN ( SELECT consumption_energy_devices_1.replaced_meter_id::integer AS replaced_meter_id
|
|
444
|
-
FROM energetics.consumption_energy_devices consumption_energy_devices_1
|
|
445
|
-
WHERE consumption_energy_devices_1.replaced_meter_id::text <> ''::text)) AND (consumption_energy_devices.addr::text <> ALL (ARRAY['aaa'::character varying::text, 'VF1'::character varying::text, 'TF1'::character varying::text, 'EF1'::character varying::text, 'PF1'::character varying::text, '01/VF1'::character varying::text, 'Návštěvnost'::character varying::text])) AND consumption_energy_devices.deleted::text <> '1'::text
|
|
446
|
-
UNION
|
|
447
|
-
SELECT me.me_id AS id,
|
|
448
|
-
me.me_id::character varying(255) AS addr,
|
|
449
|
-
NULL::character varying(255) AS description,
|
|
450
|
-
NULL::character varying(255) AS meter_number,
|
|
451
|
-
NULL::character varying(255) AS meter_index,
|
|
452
|
-
NULL::character varying(255) AS location_number,
|
|
453
|
-
NULL::character varying(255) AS location_description,
|
|
454
|
-
NULL::character varying(255) AS include_in_evaluation,
|
|
455
|
-
NULL::character varying(255) AS meter_type,
|
|
456
|
-
NULL::character varying(255) AS category,
|
|
457
|
-
NULL::character varying(255) AS unit,
|
|
458
|
-
NULL::character varying(255) AS replaced_meter_id,
|
|
459
|
-
NULL::character varying(255) AS deleted,
|
|
460
|
-
111 AS building_id
|
|
461
|
-
FROM energetics.vpalac_measuring_equipment me;
|
|
1
|
+
CREATE OR REPLACE VIEW v_consumption_energy_delta
|
|
2
|
+
AS WITH delta AS (
|
|
3
|
+
SELECT es.time_utc,
|
|
4
|
+
es.addr,
|
|
5
|
+
es.var,
|
|
6
|
+
es.commodity,
|
|
7
|
+
es.unit,
|
|
8
|
+
es.value,
|
|
9
|
+
es.meter,
|
|
10
|
+
lag(es.value) OVER (PARTITION BY es.addr, es.var, es.meter ORDER BY es.time_utc) AS last_value,
|
|
11
|
+
lag(es.time_utc) OVER (PARTITION BY es.addr, es.var, es.meter ORDER BY es.time_utc) AS last_timeutc,
|
|
12
|
+
es.value - lag(es.value) OVER (PARTITION BY es.addr, es.var, es.meter ORDER BY es.time_utc) AS delta_value,
|
|
13
|
+
min.consumption_min AS prumerna_spotreba,
|
|
14
|
+
date_part('epoch'::text, es.time_utc - lag(es.time_utc) OVER (PARTITION BY es.addr, es.var, es.meter ORDER BY es.time_utc)) / 60::double precision AS minut_mereni
|
|
15
|
+
FROM energetics.consumption_energy_consumption es
|
|
16
|
+
JOIN energetics.v_consumption_energy_avg_consumption_min min ON es.addr::text = min.addr::text AND es.var::text = min.var::text AND es.meter::text = min.meter::text
|
|
17
|
+
WHERE es.var::text = 'core'::text AND (es.addr::text ~~ '%F%'::text OR es.addr::text = '/2.1/VP2'::text) AND es.value > 0::numeric
|
|
18
|
+
)
|
|
19
|
+
SELECT delta.time_utc,
|
|
20
|
+
delta.addr,
|
|
21
|
+
delta.var,
|
|
22
|
+
delta.commodity,
|
|
23
|
+
delta.unit,
|
|
24
|
+
delta.value,
|
|
25
|
+
delta.meter,
|
|
26
|
+
delta.last_value,
|
|
27
|
+
delta.last_timeutc,
|
|
28
|
+
CASE
|
|
29
|
+
WHEN abs(delta.delta_value::double precision / 60::double precision) > abs(1000::double precision * delta.prumerna_spotreba) THEN 0::numeric
|
|
30
|
+
ELSE delta.delta_value
|
|
31
|
+
END AS delta_value,
|
|
32
|
+
delta.minut_mereni
|
|
33
|
+
FROM delta;
|
|
34
|
+
|
|
35
|
+
CREATE OR REPLACE VIEW v_consumption_energy_buildings_real
|
|
36
|
+
AS SELECT consumption_energy_buildings.id,
|
|
37
|
+
consumption_energy_buildings.building_name,
|
|
38
|
+
consumption_energy_buildings.description,
|
|
39
|
+
consumption_energy_buildings.building_address_code,
|
|
40
|
+
consumption_energy_buildings.building_label,
|
|
41
|
+
consumption_energy_buildings.current_note,
|
|
42
|
+
consumption_energy_buildings.main_use,
|
|
43
|
+
consumption_energy_buildings.secondary_use,
|
|
44
|
+
consumption_energy_buildings.year_of_construction,
|
|
45
|
+
consumption_energy_buildings.method_of_protection,
|
|
46
|
+
consumption_energy_buildings.built_up_area,
|
|
47
|
+
consumption_energy_buildings.heated_bulding_volume,
|
|
48
|
+
consumption_energy_buildings.students_count,
|
|
49
|
+
consumption_energy_buildings.employees_count,
|
|
50
|
+
consumption_energy_buildings.classrooms_count,
|
|
51
|
+
consumption_energy_buildings.beds_count,
|
|
52
|
+
consumption_energy_buildings.eno_id,
|
|
53
|
+
consumption_energy_buildings.csu_code,
|
|
54
|
+
consumption_energy_buildings.ku_code,
|
|
55
|
+
consumption_energy_buildings.allotment_number,
|
|
56
|
+
consumption_energy_buildings.registration_unit,
|
|
57
|
+
consumption_energy_buildings.gas_consumption_normatives,
|
|
58
|
+
consumption_energy_buildings.heat_consumption_normatives,
|
|
59
|
+
consumption_energy_buildings.water_consumption_normatives,
|
|
60
|
+
consumption_energy_buildings.electricity_consumption_normatives_per_person,
|
|
61
|
+
consumption_energy_buildings.electricity_consumption_normatives,
|
|
62
|
+
consumption_energy_buildings.energetic_management,
|
|
63
|
+
consumption_energy_buildings.opening_hours,
|
|
64
|
+
consumption_energy_buildings.weekend_opening_hours,
|
|
65
|
+
consumption_energy_buildings.latitude,
|
|
66
|
+
consumption_energy_buildings.longitude,
|
|
67
|
+
consumption_energy_buildings.address_street,
|
|
68
|
+
consumption_energy_buildings.address_house_number,
|
|
69
|
+
consumption_energy_buildings.address_city,
|
|
70
|
+
consumption_energy_buildings.address_country,
|
|
71
|
+
consumption_energy_buildings.address_mail,
|
|
72
|
+
consumption_energy_buildings.address_phone,
|
|
73
|
+
consumption_energy_buildings.address_web_address,
|
|
74
|
+
consumption_energy_buildings.penb_penbnumber,
|
|
75
|
+
consumption_energy_buildings.penb_issue_date,
|
|
76
|
+
consumption_energy_buildings.penb_total_building_envelope_area,
|
|
77
|
+
consumption_energy_buildings.penb_volume_factor_of_avshape,
|
|
78
|
+
consumption_energy_buildings.penb_total_energy_reference_area,
|
|
79
|
+
consumption_energy_buildings.penb_total_provided_energy,
|
|
80
|
+
consumption_energy_buildings.penb_total_provided_energy_category,
|
|
81
|
+
consumption_energy_buildings.penb_primary_non_renewable_energy,
|
|
82
|
+
consumption_energy_buildings.penb_primary_non_renewable_energy_category,
|
|
83
|
+
consumption_energy_buildings.penb_building_envelope,
|
|
84
|
+
consumption_energy_buildings.penb_building_envelope_category,
|
|
85
|
+
consumption_energy_buildings.penb_heating,
|
|
86
|
+
consumption_energy_buildings.penb_heating_category,
|
|
87
|
+
consumption_energy_buildings.penb_cooling,
|
|
88
|
+
consumption_energy_buildings.penb_cooling_category,
|
|
89
|
+
consumption_energy_buildings.penb_ventilation,
|
|
90
|
+
consumption_energy_buildings.penb_ventilation_category,
|
|
91
|
+
consumption_energy_buildings.penb_humidity_adjustment,
|
|
92
|
+
consumption_energy_buildings.penb_humidity_adjustment_category,
|
|
93
|
+
consumption_energy_buildings.penb_warm_water,
|
|
94
|
+
consumption_energy_buildings.penb_warm_water_category,
|
|
95
|
+
consumption_energy_buildings.penb_lighting,
|
|
96
|
+
consumption_energy_buildings.penb_lighting_category,
|
|
97
|
+
consumption_energy_buildings.energy_audits_energy_audit,
|
|
98
|
+
consumption_energy_buildings.energy_audits_earegistration_number,
|
|
99
|
+
consumption_energy_buildings.energy_audits_created_at,
|
|
100
|
+
consumption_energy_buildings.building_envelope_side_wall_prevailing_construction,
|
|
101
|
+
consumption_energy_buildings.building_envelope_side_wall_area,
|
|
102
|
+
consumption_energy_buildings.building_envelope_side_wall_heat_insulation,
|
|
103
|
+
consumption_energy_buildings.building_envelope_side_wall_year_of_adjustment,
|
|
104
|
+
consumption_energy_buildings.building_envelope_side_wall_technical_condition,
|
|
105
|
+
consumption_energy_buildings.building_envelope_filling_of_hole_construction,
|
|
106
|
+
consumption_energy_buildings.building_envelope_filling_of_hole_area,
|
|
107
|
+
consumption_energy_buildings.building_envelope_filling_of_hole_year_of_adjustment,
|
|
108
|
+
consumption_energy_buildings.building_envelope_filling_of_hole_technical_condition,
|
|
109
|
+
consumption_energy_buildings.building_envelope_roof_construction,
|
|
110
|
+
consumption_energy_buildings.building_envelope_roof_area,
|
|
111
|
+
consumption_energy_buildings.building_envelope_roof_thermal_insulation,
|
|
112
|
+
consumption_energy_buildings.building_envelope_roof_year_of_adjustment,
|
|
113
|
+
consumption_energy_buildings.building_envelope_roof_technical_condition,
|
|
114
|
+
consumption_energy_buildings.building_envelope_floor_of_the_lowest_heated_floor_construction,
|
|
115
|
+
consumption_energy_buildings.building_envelope_floor_of_the_lowest_heated_floor_area,
|
|
116
|
+
consumption_energy_buildings.floor_of_the_lowest_heated_floor_thermal_insulation,
|
|
117
|
+
consumption_energy_buildings.building_envelope_floor_of_the_lowest_heated_floor_year_of_adju,
|
|
118
|
+
consumption_energy_buildings.floor_of_the_lowest_heated_floor_technical_condition,
|
|
119
|
+
consumption_energy_buildings.fuel_and_energy_coal,
|
|
120
|
+
consumption_energy_buildings.fuel_and_energy_gas,
|
|
121
|
+
consumption_energy_buildings.fuel_and_energy_electricity,
|
|
122
|
+
consumption_energy_buildings.fuel_and_energy_czt,
|
|
123
|
+
consumption_energy_buildings.fuel_and_energy_oze,
|
|
124
|
+
consumption_energy_buildings.fuel_and_energy_other,
|
|
125
|
+
consumption_energy_buildings.technical_equipment_heating_main_source_of_heat,
|
|
126
|
+
consumption_energy_buildings.technical_equipment_heating_heat_percentage,
|
|
127
|
+
consumption_energy_buildings.technical_equipment_heating_secondary_source_of_heat,
|
|
128
|
+
consumption_energy_buildings.technical_equipment_heating_heating_system,
|
|
129
|
+
consumption_energy_buildings.technical_equipment_heating_year,
|
|
130
|
+
consumption_energy_buildings.technical_equipment_heating_technical_condition,
|
|
131
|
+
consumption_energy_buildings.technical_equipment_cooling_cooling_system,
|
|
132
|
+
consumption_energy_buildings.technical_equipment_cooling_cooling_area_percentage,
|
|
133
|
+
consumption_energy_buildings.technical_equipment_cooling_year,
|
|
134
|
+
consumption_energy_buildings.technical_equipment_cooling_technical_condition,
|
|
135
|
+
consumption_energy_buildings.technical_equipment_ventilation_ventilation,
|
|
136
|
+
consumption_energy_buildings.technical_equipment_ventilation_year,
|
|
137
|
+
consumption_energy_buildings.technical_equipment_ventilation_technical_condition,
|
|
138
|
+
consumption_energy_buildings.technical_equipment_humidity_adjustment_humidity_adjustment,
|
|
139
|
+
consumption_energy_buildings.technical_equipment_humidity_adjustment_year,
|
|
140
|
+
consumption_energy_buildings.technical_equipment_humidity_adjustment_technical_condition,
|
|
141
|
+
consumption_energy_buildings.technical_equipment_hot_water_predominant_way_of_heating_tv,
|
|
142
|
+
consumption_energy_buildings.technical_equipment_hot_water_hot_water_source,
|
|
143
|
+
consumption_energy_buildings.technical_equipment_hot_water_year,
|
|
144
|
+
consumption_energy_buildings.technical_equipment_hot_water_technical_condition,
|
|
145
|
+
consumption_energy_buildings.technical_equipment_lighting_lighting,
|
|
146
|
+
consumption_energy_buildings.technical_equipment_lighting_year,
|
|
147
|
+
consumption_energy_buildings.technical_equipment_lighting_technical_condition,
|
|
148
|
+
consumption_energy_buildings.technical_equipment_lighting_other_technological_elements,
|
|
149
|
+
consumption_energy_buildings.technical_equipment_lighting_measurement_method,
|
|
150
|
+
consumption_energy_buildings.oze_energy_production_solar_energy_photovoltaic,
|
|
151
|
+
consumption_energy_buildings.oze_energy_production_solar_energy_photothermal,
|
|
152
|
+
consumption_energy_buildings.oze_energy_production_integrated_turbines_wind_energy,
|
|
153
|
+
consumption_energy_buildings.oze_energy_production_heat_pump,
|
|
154
|
+
consumption_energy_buildings.waste_and_emissions_solid_waste_production,
|
|
155
|
+
consumption_energy_buildings.waste_and_emissions_tied_co2_emissions,
|
|
156
|
+
consumption_energy_buildings.waste_and_emissions_sox_emissions,
|
|
157
|
+
consumption_energy_buildings.waste_and_emissions_operating_co_2emissions,
|
|
158
|
+
consumption_energy_buildings.link
|
|
159
|
+
FROM energetics.consumption_energy_buildings
|
|
160
|
+
WHERE consumption_energy_buildings.building_label::text <> ALL (ARRAY['ZKB 1'::character varying::text, 'ZKB 2'::character varying::text, 'TB1'::character varying::text, 'TB2'::character varying::text]);
|
|
161
|
+
|
|
162
|
+
CREATE OR REPLACE VIEW v_consumption_energy_buildings_w_data
|
|
163
|
+
AS SELECT consumption_energy_buildings.id,
|
|
164
|
+
consumption_energy_buildings.building_name,
|
|
165
|
+
consumption_energy_buildings.description,
|
|
166
|
+
consumption_energy_buildings.building_address_code,
|
|
167
|
+
consumption_energy_buildings.building_label,
|
|
168
|
+
consumption_energy_buildings.current_note,
|
|
169
|
+
consumption_energy_buildings.main_use,
|
|
170
|
+
consumption_energy_buildings.secondary_use,
|
|
171
|
+
consumption_energy_buildings.year_of_construction,
|
|
172
|
+
consumption_energy_buildings.method_of_protection,
|
|
173
|
+
consumption_energy_buildings.built_up_area,
|
|
174
|
+
consumption_energy_buildings.heated_bulding_volume,
|
|
175
|
+
consumption_energy_buildings.students_count,
|
|
176
|
+
consumption_energy_buildings.employees_count,
|
|
177
|
+
consumption_energy_buildings.classrooms_count,
|
|
178
|
+
consumption_energy_buildings.beds_count,
|
|
179
|
+
consumption_energy_buildings.eno_id,
|
|
180
|
+
consumption_energy_buildings.csu_code,
|
|
181
|
+
consumption_energy_buildings.ku_code,
|
|
182
|
+
consumption_energy_buildings.allotment_number,
|
|
183
|
+
consumption_energy_buildings.registration_unit,
|
|
184
|
+
consumption_energy_buildings.gas_consumption_normatives,
|
|
185
|
+
consumption_energy_buildings.heat_consumption_normatives,
|
|
186
|
+
consumption_energy_buildings.water_consumption_normatives,
|
|
187
|
+
consumption_energy_buildings.electricity_consumption_normatives_per_person,
|
|
188
|
+
consumption_energy_buildings.electricity_consumption_normatives,
|
|
189
|
+
consumption_energy_buildings.energetic_management,
|
|
190
|
+
consumption_energy_buildings.opening_hours,
|
|
191
|
+
consumption_energy_buildings.weekend_opening_hours,
|
|
192
|
+
consumption_energy_buildings.latitude,
|
|
193
|
+
consumption_energy_buildings.longitude,
|
|
194
|
+
consumption_energy_buildings.address_street,
|
|
195
|
+
consumption_energy_buildings.address_house_number,
|
|
196
|
+
consumption_energy_buildings.address_city,
|
|
197
|
+
consumption_energy_buildings.address_country,
|
|
198
|
+
consumption_energy_buildings.address_mail,
|
|
199
|
+
consumption_energy_buildings.address_phone,
|
|
200
|
+
consumption_energy_buildings.address_web_address,
|
|
201
|
+
consumption_energy_buildings.penb_penbnumber,
|
|
202
|
+
consumption_energy_buildings.penb_issue_date,
|
|
203
|
+
consumption_energy_buildings.penb_total_building_envelope_area,
|
|
204
|
+
consumption_energy_buildings.penb_volume_factor_of_avshape,
|
|
205
|
+
consumption_energy_buildings.penb_total_energy_reference_area,
|
|
206
|
+
consumption_energy_buildings.penb_total_provided_energy,
|
|
207
|
+
consumption_energy_buildings.penb_total_provided_energy_category,
|
|
208
|
+
consumption_energy_buildings.penb_primary_non_renewable_energy,
|
|
209
|
+
consumption_energy_buildings.penb_primary_non_renewable_energy_category,
|
|
210
|
+
consumption_energy_buildings.penb_building_envelope,
|
|
211
|
+
consumption_energy_buildings.penb_building_envelope_category,
|
|
212
|
+
consumption_energy_buildings.penb_heating,
|
|
213
|
+
consumption_energy_buildings.penb_heating_category,
|
|
214
|
+
consumption_energy_buildings.penb_cooling,
|
|
215
|
+
consumption_energy_buildings.penb_cooling_category,
|
|
216
|
+
consumption_energy_buildings.penb_ventilation,
|
|
217
|
+
consumption_energy_buildings.penb_ventilation_category,
|
|
218
|
+
consumption_energy_buildings.penb_humidity_adjustment,
|
|
219
|
+
consumption_energy_buildings.penb_humidity_adjustment_category,
|
|
220
|
+
consumption_energy_buildings.penb_warm_water,
|
|
221
|
+
consumption_energy_buildings.penb_warm_water_category,
|
|
222
|
+
consumption_energy_buildings.penb_lighting,
|
|
223
|
+
consumption_energy_buildings.penb_lighting_category,
|
|
224
|
+
consumption_energy_buildings.energy_audits_energy_audit,
|
|
225
|
+
consumption_energy_buildings.energy_audits_earegistration_number,
|
|
226
|
+
consumption_energy_buildings.energy_audits_created_at,
|
|
227
|
+
consumption_energy_buildings.building_envelope_side_wall_prevailing_construction,
|
|
228
|
+
consumption_energy_buildings.building_envelope_side_wall_area,
|
|
229
|
+
consumption_energy_buildings.building_envelope_side_wall_heat_insulation,
|
|
230
|
+
consumption_energy_buildings.building_envelope_side_wall_year_of_adjustment,
|
|
231
|
+
consumption_energy_buildings.building_envelope_side_wall_technical_condition,
|
|
232
|
+
consumption_energy_buildings.building_envelope_filling_of_hole_construction,
|
|
233
|
+
consumption_energy_buildings.building_envelope_filling_of_hole_area,
|
|
234
|
+
consumption_energy_buildings.building_envelope_filling_of_hole_year_of_adjustment,
|
|
235
|
+
consumption_energy_buildings.building_envelope_filling_of_hole_technical_condition,
|
|
236
|
+
consumption_energy_buildings.building_envelope_roof_construction,
|
|
237
|
+
consumption_energy_buildings.building_envelope_roof_area,
|
|
238
|
+
consumption_energy_buildings.building_envelope_roof_thermal_insulation,
|
|
239
|
+
consumption_energy_buildings.building_envelope_roof_year_of_adjustment,
|
|
240
|
+
consumption_energy_buildings.building_envelope_roof_technical_condition,
|
|
241
|
+
consumption_energy_buildings.building_envelope_floor_of_the_lowest_heated_floor_construction,
|
|
242
|
+
consumption_energy_buildings.building_envelope_floor_of_the_lowest_heated_floor_area,
|
|
243
|
+
consumption_energy_buildings.floor_of_the_lowest_heated_floor_thermal_insulation,
|
|
244
|
+
consumption_energy_buildings.building_envelope_floor_of_the_lowest_heated_floor_year_of_adju,
|
|
245
|
+
consumption_energy_buildings.floor_of_the_lowest_heated_floor_technical_condition,
|
|
246
|
+
consumption_energy_buildings.fuel_and_energy_coal,
|
|
247
|
+
consumption_energy_buildings.fuel_and_energy_gas,
|
|
248
|
+
consumption_energy_buildings.fuel_and_energy_electricity,
|
|
249
|
+
consumption_energy_buildings.fuel_and_energy_czt,
|
|
250
|
+
consumption_energy_buildings.fuel_and_energy_oze,
|
|
251
|
+
consumption_energy_buildings.fuel_and_energy_other,
|
|
252
|
+
consumption_energy_buildings.technical_equipment_heating_main_source_of_heat,
|
|
253
|
+
consumption_energy_buildings.technical_equipment_heating_heat_percentage,
|
|
254
|
+
consumption_energy_buildings.technical_equipment_heating_secondary_source_of_heat,
|
|
255
|
+
consumption_energy_buildings.technical_equipment_heating_heating_system,
|
|
256
|
+
consumption_energy_buildings.technical_equipment_heating_year,
|
|
257
|
+
consumption_energy_buildings.technical_equipment_heating_technical_condition,
|
|
258
|
+
consumption_energy_buildings.technical_equipment_cooling_cooling_system,
|
|
259
|
+
consumption_energy_buildings.technical_equipment_cooling_cooling_area_percentage,
|
|
260
|
+
consumption_energy_buildings.technical_equipment_cooling_year,
|
|
261
|
+
consumption_energy_buildings.technical_equipment_cooling_technical_condition,
|
|
262
|
+
consumption_energy_buildings.technical_equipment_ventilation_ventilation,
|
|
263
|
+
consumption_energy_buildings.technical_equipment_ventilation_year,
|
|
264
|
+
consumption_energy_buildings.technical_equipment_ventilation_technical_condition,
|
|
265
|
+
consumption_energy_buildings.technical_equipment_humidity_adjustment_humidity_adjustment,
|
|
266
|
+
consumption_energy_buildings.technical_equipment_humidity_adjustment_year,
|
|
267
|
+
consumption_energy_buildings.technical_equipment_humidity_adjustment_technical_condition,
|
|
268
|
+
consumption_energy_buildings.technical_equipment_hot_water_predominant_way_of_heating_tv,
|
|
269
|
+
consumption_energy_buildings.technical_equipment_hot_water_hot_water_source,
|
|
270
|
+
consumption_energy_buildings.technical_equipment_hot_water_year,
|
|
271
|
+
consumption_energy_buildings.technical_equipment_hot_water_technical_condition,
|
|
272
|
+
consumption_energy_buildings.technical_equipment_lighting_lighting,
|
|
273
|
+
consumption_energy_buildings.technical_equipment_lighting_year,
|
|
274
|
+
consumption_energy_buildings.technical_equipment_lighting_technical_condition,
|
|
275
|
+
consumption_energy_buildings.technical_equipment_lighting_other_technological_elements,
|
|
276
|
+
consumption_energy_buildings.technical_equipment_lighting_measurement_method,
|
|
277
|
+
consumption_energy_buildings.oze_energy_production_solar_energy_photovoltaic,
|
|
278
|
+
consumption_energy_buildings.oze_energy_production_solar_energy_photothermal,
|
|
279
|
+
consumption_energy_buildings.oze_energy_production_integrated_turbines_wind_energy,
|
|
280
|
+
consumption_energy_buildings.oze_energy_production_heat_pump,
|
|
281
|
+
consumption_energy_buildings.waste_and_emissions_solid_waste_production,
|
|
282
|
+
consumption_energy_buildings.waste_and_emissions_tied_co2_emissions,
|
|
283
|
+
consumption_energy_buildings.waste_and_emissions_sox_emissions,
|
|
284
|
+
consumption_energy_buildings.waste_and_emissions_operating_co_2emissions,
|
|
285
|
+
consumption_energy_buildings.link
|
|
286
|
+
FROM energetics.consumption_energy_buildings
|
|
287
|
+
WHERE (btrim(consumption_energy_buildings.building_address_code::text) IN ( SELECT DISTINCT v_consumption_energy_consumption.building_address_code
|
|
288
|
+
FROM energetics.v_consumption_energy_consumption)) AND consumption_energy_buildings.building_address_code::text !~~ '10.%'::text;
|
|
289
|
+
|
|
290
|
+
CREATE OR REPLACE VIEW v_consumption_energy_consumption_month_el_f
|
|
291
|
+
AS SELECT date_part('year'::text, consumption_energy_consumption.time_utc) AS rok,
|
|
292
|
+
date_part('month'::text, consumption_energy_consumption.time_utc) AS mesic,
|
|
293
|
+
consumption_energy_consumption.addr,
|
|
294
|
+
consumption_energy_consumption.var,
|
|
295
|
+
consumption_energy_consumption.commodity,
|
|
296
|
+
consumption_energy_consumption.unit,
|
|
297
|
+
sum(consumption_energy_consumption.value::numeric(10,2)) / 4::numeric AS value,
|
|
298
|
+
max(consumption_energy_consumption.time_utc::date) AS data_do,
|
|
299
|
+
count(*) AS count
|
|
300
|
+
FROM energetics.consumption_energy_consumption
|
|
301
|
+
WHERE (consumption_energy_consumption.var::text = ANY (ARRAY['EFwActi'::character varying::text, 'EFwActiNT'::character varying::text, 'EFwActi'::character varying::text])) AND consumption_energy_consumption.addr::text ~~ '%/EF%'::text
|
|
302
|
+
GROUP BY (date_part('year'::text, consumption_energy_consumption.time_utc)), (date_part('month'::text, consumption_energy_consumption.time_utc)), consumption_energy_consumption.addr, consumption_energy_consumption.var, consumption_energy_consumption.commodity, consumption_energy_consumption.unit
|
|
303
|
+
UNION
|
|
304
|
+
SELECT v_consumption_vrtbovsky_palac.measure_year AS rok,
|
|
305
|
+
v_consumption_vrtbovsky_palac.measure_month AS mesic,
|
|
306
|
+
v_consumption_vrtbovsky_palac.addr::character varying(255) AS addr,
|
|
307
|
+
v_consumption_vrtbovsky_palac.var::character varying(255) AS var,
|
|
308
|
+
v_consumption_vrtbovsky_palac.commodity::character varying(255) AS commodity,
|
|
309
|
+
v_consumption_vrtbovsky_palac.unit::character varying(255) AS unit,
|
|
310
|
+
sum(v_consumption_vrtbovsky_palac.consumption) AS value,
|
|
311
|
+
v_consumption_vrtbovsky_palac.data_do::date AS data_do,
|
|
312
|
+
count(*) AS count
|
|
313
|
+
FROM energetics.v_consumption_vrtbovsky_palac
|
|
314
|
+
WHERE v_consumption_vrtbovsky_palac.commodity = 'electricity'::text
|
|
315
|
+
GROUP BY v_consumption_vrtbovsky_palac.measure_year, v_consumption_vrtbovsky_palac.measure_month, v_consumption_vrtbovsky_palac.data_do, v_consumption_vrtbovsky_palac.addr, v_consumption_vrtbovsky_palac.var, v_consumption_vrtbovsky_palac.commodity, v_consumption_vrtbovsky_palac.unit;
|
|
316
|
+
|
|
317
|
+
CREATE OR REPLACE VIEW v_consumption_gas_reserve
|
|
318
|
+
AS WITH kalendar AS (
|
|
319
|
+
SELECT den.den::date AS den
|
|
320
|
+
FROM generate_series('2019-01-01 00:00:00+01'::timestamp with time zone, now() - '1 day'::interval, '1 day'::interval) den(den)
|
|
321
|
+
), meraky AS (
|
|
322
|
+
SELECT DISTINCT consumption_energy_devices.addr
|
|
323
|
+
FROM energetics.consumption_energy_devices
|
|
324
|
+
WHERE consumption_energy_devices.meter_type::text = 'Plynoměr'::text
|
|
325
|
+
), daily_delta_core AS (
|
|
326
|
+
SELECT date_trunc('day'::text, v_consumption_energy_delta.time_utc - '06:00:00'::interval)::date AS measured_from,
|
|
327
|
+
v_consumption_energy_delta.addr,
|
|
328
|
+
v_consumption_energy_delta.var,
|
|
329
|
+
sum(v_consumption_energy_delta.delta_value) AS delta_value
|
|
330
|
+
FROM energetics.v_consumption_energy_delta
|
|
331
|
+
WHERE v_consumption_energy_delta.commodity::text = 'gas'::text AND date_part('year'::text, v_consumption_energy_delta.time_utc - '06:00:00'::interval) >= 2019::double precision
|
|
332
|
+
GROUP BY (date_trunc('day'::text, v_consumption_energy_delta.time_utc - '06:00:00'::interval)::date), v_consumption_energy_delta.addr, v_consumption_energy_delta.var
|
|
333
|
+
), daily_delta_core2 AS (
|
|
334
|
+
SELECT date_trunc('day'::text, consumption_energy_consumption.time_utc - '06:00:00'::interval)::date AS measured_from,
|
|
335
|
+
consumption_energy_consumption.addr,
|
|
336
|
+
consumption_energy_consumption.var,
|
|
337
|
+
sum(consumption_energy_consumption.value) AS delta_value
|
|
338
|
+
FROM energetics.consumption_energy_consumption
|
|
339
|
+
WHERE consumption_energy_consumption.var::text = 'core2'::text AND consumption_energy_consumption.time_utc::date > '2018-12-31'::date
|
|
340
|
+
GROUP BY (date_trunc('day'::text, consumption_energy_consumption.time_utc - '06:00:00'::interval)::date), consumption_energy_consumption.addr, consumption_energy_consumption.var
|
|
341
|
+
), delta_dates AS (
|
|
342
|
+
SELECT daily_delta_core.measured_from,
|
|
343
|
+
daily_delta_core.addr,
|
|
344
|
+
daily_delta_core.var,
|
|
345
|
+
daily_delta_core.delta_value,
|
|
346
|
+
lag(daily_delta_core.measured_from, 1) OVER (PARTITION BY daily_delta_core.addr ORDER BY daily_delta_core.measured_from) AS measured_before,
|
|
347
|
+
lead(daily_delta_core.measured_from, 1) OVER (PARTITION BY daily_delta_core.addr ORDER BY daily_delta_core.measured_from) AS measured_after,
|
|
348
|
+
lag(daily_delta_core.delta_value, 1) OVER (PARTITION BY daily_delta_core.addr ORDER BY daily_delta_core.measured_from) AS delta_before,
|
|
349
|
+
lead(daily_delta_core.delta_value, 1) OVER (PARTITION BY daily_delta_core.addr ORDER BY daily_delta_core.measured_from) AS delta_after
|
|
350
|
+
FROM daily_delta_core
|
|
351
|
+
), delta_date_diff AS (
|
|
352
|
+
SELECT delta_dates.measured_from,
|
|
353
|
+
delta_dates.addr,
|
|
354
|
+
delta_dates.var,
|
|
355
|
+
delta_dates.delta_value,
|
|
356
|
+
delta_dates.measured_before,
|
|
357
|
+
delta_dates.measured_after,
|
|
358
|
+
delta_dates.delta_before,
|
|
359
|
+
delta_dates.delta_after,
|
|
360
|
+
CASE
|
|
361
|
+
WHEN (delta_dates.measured_after - delta_dates.measured_from) > 1 AND (delta_dates.measured_from - delta_dates.measured_before) > 1 THEN 'mid'::text
|
|
362
|
+
WHEN (delta_dates.measured_after - delta_dates.measured_from) > 1 THEN 'begin'::text
|
|
363
|
+
WHEN (delta_dates.measured_from - delta_dates.measured_before) > 1 THEN 'end'::text
|
|
364
|
+
ELSE 'ok'::text
|
|
365
|
+
END AS value_type,
|
|
366
|
+
CASE
|
|
367
|
+
WHEN (delta_dates.measured_after - delta_dates.measured_from) > 1 AND (delta_dates.measured_from - delta_dates.measured_before) > 1 THEN (delta_dates.delta_value / 2::numeric + delta_dates.delta_after) / (delta_dates.measured_after - delta_dates.measured_from + 1)::numeric
|
|
368
|
+
WHEN (delta_dates.measured_after - delta_dates.measured_from) > 1 THEN (delta_dates.delta_value + delta_dates.delta_after) / (delta_dates.measured_after - delta_dates.measured_from + 1)::numeric
|
|
369
|
+
ELSE NULL::numeric
|
|
370
|
+
END AS fix
|
|
371
|
+
FROM delta_dates
|
|
372
|
+
), joined_table AS (
|
|
373
|
+
SELECT kalendar.den AS measured_from,
|
|
374
|
+
meraky.addr,
|
|
375
|
+
diff.delta_value,
|
|
376
|
+
diff.value_type,
|
|
377
|
+
diff.fix,
|
|
378
|
+
core2.delta_value AS core2_delta,
|
|
379
|
+
CASE
|
|
380
|
+
WHEN diff.value_type = 'ok'::text THEN COALESCE(core2.delta_value, diff.delta_value)
|
|
381
|
+
ELSE diff.fix
|
|
382
|
+
END AS final_fix,
|
|
383
|
+
CASE
|
|
384
|
+
WHEN diff.value_type = 'ok'::text THEN COALESCE(core2.var, diff.var)
|
|
385
|
+
ELSE 'core'::character varying
|
|
386
|
+
END AS final_var
|
|
387
|
+
FROM kalendar
|
|
388
|
+
LEFT JOIN meraky ON true
|
|
389
|
+
LEFT JOIN delta_date_diff diff ON diff.measured_from = kalendar.den AND diff.addr::text = meraky.addr::text
|
|
390
|
+
LEFT JOIN daily_delta_core2 core2 ON core2.measured_from = kalendar.den AND core2.addr::text = meraky.addr::text
|
|
391
|
+
ORDER BY meraky.addr, kalendar.den
|
|
392
|
+
), fixed_table AS (
|
|
393
|
+
SELECT q.measured_from,
|
|
394
|
+
q.addr,
|
|
395
|
+
q.delta_value,
|
|
396
|
+
q.value_type,
|
|
397
|
+
q.fix,
|
|
398
|
+
q.core2_delta,
|
|
399
|
+
q.final_fix,
|
|
400
|
+
q.final_var,
|
|
401
|
+
q.value_partition,
|
|
402
|
+
first_value(q.final_fix) OVER w AS value
|
|
403
|
+
FROM ( SELECT joined_table.measured_from,
|
|
404
|
+
joined_table.addr,
|
|
405
|
+
joined_table.delta_value,
|
|
406
|
+
joined_table.value_type,
|
|
407
|
+
joined_table.fix,
|
|
408
|
+
joined_table.core2_delta,
|
|
409
|
+
joined_table.final_fix,
|
|
410
|
+
joined_table.final_var,
|
|
411
|
+
sum(
|
|
412
|
+
CASE
|
|
413
|
+
WHEN joined_table.final_fix IS NULL THEN 0
|
|
414
|
+
ELSE 1
|
|
415
|
+
END) OVER (PARTITION BY joined_table.addr ORDER BY joined_table.measured_from) AS value_partition
|
|
416
|
+
FROM joined_table) q
|
|
417
|
+
WINDOW w AS (PARTITION BY q.addr, q.value_partition ORDER BY q.measured_from)
|
|
418
|
+
)
|
|
419
|
+
SELECT fixed_table.measured_from,
|
|
420
|
+
fixed_table.addr,
|
|
421
|
+
fixed_table.value AS delta_value,
|
|
422
|
+
fixed_table.final_var,
|
|
423
|
+
row_number() OVER (PARTITION BY fixed_table.addr, (date_trunc('month'::text, fixed_table.measured_from::timestamp with time zone)) ORDER BY fixed_table.value DESC) AS ran
|
|
424
|
+
FROM fixed_table
|
|
425
|
+
WHERE fixed_table.value IS NOT NULL;
|
|
426
|
+
|
|
427
|
+
CREATE OR REPLACE VIEW v_consumption_energy_devices_active
|
|
428
|
+
AS SELECT consumption_energy_devices.id,
|
|
429
|
+
consumption_energy_devices.addr,
|
|
430
|
+
consumption_energy_devices.description,
|
|
431
|
+
consumption_energy_devices.meter_number,
|
|
432
|
+
consumption_energy_devices.meter_index,
|
|
433
|
+
consumption_energy_devices.location_number,
|
|
434
|
+
consumption_energy_devices.location_description,
|
|
435
|
+
consumption_energy_devices.include_in_evaluation,
|
|
436
|
+
consumption_energy_devices.meter_type,
|
|
437
|
+
consumption_energy_devices.category,
|
|
438
|
+
consumption_energy_devices.unit,
|
|
439
|
+
consumption_energy_devices.replaced_meter_id,
|
|
440
|
+
consumption_energy_devices.deleted,
|
|
441
|
+
consumption_energy_devices.building_id
|
|
442
|
+
FROM energetics.consumption_energy_devices
|
|
443
|
+
WHERE NOT (consumption_energy_devices.id IN ( SELECT consumption_energy_devices_1.replaced_meter_id::integer AS replaced_meter_id
|
|
444
|
+
FROM energetics.consumption_energy_devices consumption_energy_devices_1
|
|
445
|
+
WHERE consumption_energy_devices_1.replaced_meter_id::text <> ''::text)) AND (consumption_energy_devices.addr::text <> ALL (ARRAY['aaa'::character varying::text, 'VF1'::character varying::text, 'TF1'::character varying::text, 'EF1'::character varying::text, 'PF1'::character varying::text, '01/VF1'::character varying::text, 'Návštěvnost'::character varying::text])) AND consumption_energy_devices.deleted::text <> '1'::text
|
|
446
|
+
UNION
|
|
447
|
+
SELECT me.me_id AS id,
|
|
448
|
+
me.me_id::character varying(255) AS addr,
|
|
449
|
+
NULL::character varying(255) AS description,
|
|
450
|
+
NULL::character varying(255) AS meter_number,
|
|
451
|
+
NULL::character varying(255) AS meter_index,
|
|
452
|
+
NULL::character varying(255) AS location_number,
|
|
453
|
+
NULL::character varying(255) AS location_description,
|
|
454
|
+
NULL::character varying(255) AS include_in_evaluation,
|
|
455
|
+
NULL::character varying(255) AS meter_type,
|
|
456
|
+
NULL::character varying(255) AS category,
|
|
457
|
+
NULL::character varying(255) AS unit,
|
|
458
|
+
NULL::character varying(255) AS replaced_meter_id,
|
|
459
|
+
NULL::character varying(255) AS deleted,
|
|
460
|
+
111 AS building_id
|
|
461
|
+
FROM energetics.vpalac_measuring_equipment me;
|