@golemio/energetics 1.0.6-dev.418384571 → 1.0.6-dev.441812601
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/.config.json +3 -0
- package/db/migrations/postgresql/20211116133054-init-energetics.js +53 -0
- package/db/migrations/postgresql/20220103101845-electricity-consumption-view.js +53 -0
- package/db/migrations/postgresql/package.json +3 -0
- package/db/migrations/postgresql/sqls/20211116133054-init-energetics-down.sql +41 -0
- package/db/migrations/postgresql/sqls/20211116133054-init-energetics-up.sql +1675 -0
- package/db/migrations/postgresql/sqls/20220103101845-electricity-consumption-view-down.sql +1 -0
- package/db/migrations/postgresql/sqls/20220103101845-electricity-consumption-view-up.sql +8 -0
- package/db/migrations/postgresql/sqls/package.json +3 -0
- package/dist/integration-engine/workers/EnergeticsEnesaWorker.js +3 -0
- package/dist/integration-engine/workers/EnergeticsEnesaWorker.js.map +1 -1
- package/dist/integration-engine/workers/EnergeticsVpalacWorker.js +5 -0
- package/dist/integration-engine/workers/EnergeticsVpalacWorker.js.map +1 -1
- package/dist/schema-definitions/index.d.ts +1 -0
- package/dist/schema-definitions/index.js +1 -0
- package/dist/schema-definitions/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,1675 @@
|
|
|
1
|
+
CREATE TABLE vpalac_meter_mapping (
|
|
2
|
+
location_code int4 NULL,
|
|
3
|
+
met_nazev varchar(100) NULL,
|
|
4
|
+
sublocation_id int4 NULL,
|
|
5
|
+
me_extid varchar(100) NULL,
|
|
6
|
+
location_name varchar(100) NULL,
|
|
7
|
+
var_id int4 NULL
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
CREATE TABLE consumption_energy_buildings (
|
|
11
|
+
id int4 NOT NULL,
|
|
12
|
+
building_name varchar(255) NOT NULL,
|
|
13
|
+
description varchar(255) NOT NULL,
|
|
14
|
+
building_address_code varchar(255) NOT NULL,
|
|
15
|
+
building_label varchar(255) NOT NULL,
|
|
16
|
+
current_note varchar(255) NOT NULL,
|
|
17
|
+
main_use varchar(255) NOT NULL,
|
|
18
|
+
secondary_use varchar(255) NOT NULL,
|
|
19
|
+
year_of_construction varchar(255) NOT NULL,
|
|
20
|
+
method_of_protection varchar(255) NOT NULL,
|
|
21
|
+
built_up_area varchar(255) NOT NULL,
|
|
22
|
+
heated_bulding_volume varchar(255) NOT NULL,
|
|
23
|
+
students_count varchar(255) NOT NULL,
|
|
24
|
+
employees_count varchar(255) NOT NULL,
|
|
25
|
+
classrooms_count varchar(255) NOT NULL,
|
|
26
|
+
beds_count varchar(255) NOT NULL,
|
|
27
|
+
eno_id varchar(255) NOT NULL,
|
|
28
|
+
csu_code varchar(255) NOT NULL,
|
|
29
|
+
ku_code varchar(255) NOT NULL,
|
|
30
|
+
allotment_number varchar(255) NOT NULL,
|
|
31
|
+
registration_unit varchar(255) NOT NULL,
|
|
32
|
+
gas_consumption_normatives varchar(255) NOT NULL,
|
|
33
|
+
heat_consumption_normatives varchar(255) NOT NULL,
|
|
34
|
+
water_consumption_normatives varchar(255) NOT NULL,
|
|
35
|
+
electricity_consumption_normatives_per_person varchar(255) NOT NULL,
|
|
36
|
+
electricity_consumption_normatives varchar(255) NOT NULL,
|
|
37
|
+
energetic_management varchar(255) NOT NULL,
|
|
38
|
+
opening_hours varchar(255) NOT NULL,
|
|
39
|
+
weekend_opening_hours varchar(255) NOT NULL,
|
|
40
|
+
latitude varchar(255) NOT NULL,
|
|
41
|
+
longitude varchar(255) NOT NULL,
|
|
42
|
+
address_street varchar(255) NOT NULL,
|
|
43
|
+
address_house_number varchar(255) NOT NULL,
|
|
44
|
+
address_city varchar(255) NOT NULL,
|
|
45
|
+
address_country varchar(255) NOT NULL,
|
|
46
|
+
address_mail varchar(255) NOT NULL,
|
|
47
|
+
address_phone varchar(255) NOT NULL,
|
|
48
|
+
address_web_address varchar(255) NOT NULL,
|
|
49
|
+
penb_penbnumber varchar(255) NOT NULL,
|
|
50
|
+
penb_issue_date varchar(255) NOT NULL,
|
|
51
|
+
penb_total_building_envelope_area varchar(255) NOT NULL,
|
|
52
|
+
penb_volume_factor_of_avshape varchar(255) NOT NULL,
|
|
53
|
+
penb_total_energy_reference_area varchar(255) NOT NULL,
|
|
54
|
+
penb_total_provided_energy varchar(255) NOT NULL,
|
|
55
|
+
penb_total_provided_energy_category varchar(255) NOT NULL,
|
|
56
|
+
penb_primary_non_renewable_energy varchar(255) NOT NULL,
|
|
57
|
+
penb_primary_non_renewable_energy_category varchar(255) NOT NULL,
|
|
58
|
+
penb_building_envelope varchar(255) NOT NULL,
|
|
59
|
+
penb_building_envelope_category varchar(255) NOT NULL,
|
|
60
|
+
penb_heating varchar(255) NOT NULL,
|
|
61
|
+
penb_heating_category varchar(255) NOT NULL,
|
|
62
|
+
penb_cooling varchar(255) NOT NULL,
|
|
63
|
+
penb_cooling_category varchar(255) NOT NULL,
|
|
64
|
+
penb_ventilation varchar(255) NOT NULL,
|
|
65
|
+
penb_ventilation_category varchar(255) NOT NULL,
|
|
66
|
+
penb_humidity_adjustment varchar(255) NOT NULL,
|
|
67
|
+
penb_humidity_adjustment_category varchar(255) NOT NULL,
|
|
68
|
+
penb_warm_water varchar(255) NOT NULL,
|
|
69
|
+
penb_warm_water_category varchar(255) NOT NULL,
|
|
70
|
+
penb_lighting varchar(255) NOT NULL,
|
|
71
|
+
penb_lighting_category varchar(255) NOT NULL,
|
|
72
|
+
energy_audits_energy_audit varchar(255) NOT NULL,
|
|
73
|
+
energy_audits_earegistration_number varchar(255) NOT NULL,
|
|
74
|
+
energy_audits_created_at varchar(255) NOT NULL,
|
|
75
|
+
building_envelope_side_wall_prevailing_construction varchar(255) NOT NULL,
|
|
76
|
+
building_envelope_side_wall_area varchar(255) NOT NULL,
|
|
77
|
+
building_envelope_side_wall_heat_insulation varchar(255) NOT NULL,
|
|
78
|
+
building_envelope_side_wall_year_of_adjustment varchar(255) NOT NULL,
|
|
79
|
+
building_envelope_side_wall_technical_condition varchar(255) NOT NULL,
|
|
80
|
+
building_envelope_filling_of_hole_construction varchar(255) NOT NULL,
|
|
81
|
+
building_envelope_filling_of_hole_area varchar(255) NOT NULL,
|
|
82
|
+
building_envelope_filling_of_hole_year_of_adjustment varchar(255) NOT NULL,
|
|
83
|
+
building_envelope_filling_of_hole_technical_condition varchar(255) NOT NULL,
|
|
84
|
+
building_envelope_roof_construction varchar(255) NOT NULL,
|
|
85
|
+
building_envelope_roof_area varchar(255) NOT NULL,
|
|
86
|
+
building_envelope_roof_thermal_insulation varchar(255) NOT NULL,
|
|
87
|
+
building_envelope_roof_year_of_adjustment varchar(255) NOT NULL,
|
|
88
|
+
building_envelope_roof_technical_condition varchar(255) NOT NULL,
|
|
89
|
+
building_envelope_floor_of_the_lowest_heated_floor_construction varchar(255) NOT NULL,
|
|
90
|
+
building_envelope_floor_of_the_lowest_heated_floor_area varchar(255) NOT NULL,
|
|
91
|
+
floor_of_the_lowest_heated_floor_thermal_insulation varchar(255) NOT NULL,
|
|
92
|
+
building_envelope_floor_of_the_lowest_heated_floor_year_of_adju varchar(255) NOT NULL,
|
|
93
|
+
floor_of_the_lowest_heated_floor_technical_condition varchar(255) NOT NULL,
|
|
94
|
+
fuel_and_energy_coal varchar(255) NOT NULL,
|
|
95
|
+
fuel_and_energy_gas varchar(255) NOT NULL,
|
|
96
|
+
fuel_and_energy_electricity varchar(255) NOT NULL,
|
|
97
|
+
fuel_and_energy_czt varchar(255) NOT NULL,
|
|
98
|
+
fuel_and_energy_oze varchar(255) NOT NULL,
|
|
99
|
+
fuel_and_energy_other varchar(255) NOT NULL,
|
|
100
|
+
technical_equipment_heating_main_source_of_heat varchar(255) NOT NULL,
|
|
101
|
+
technical_equipment_heating_heat_percentage varchar(255) NOT NULL,
|
|
102
|
+
technical_equipment_heating_secondary_source_of_heat varchar(255) NOT NULL,
|
|
103
|
+
technical_equipment_heating_heating_system varchar(255) NOT NULL,
|
|
104
|
+
technical_equipment_heating_year varchar(255) NOT NULL,
|
|
105
|
+
technical_equipment_heating_technical_condition varchar(255) NOT NULL,
|
|
106
|
+
technical_equipment_cooling_cooling_system varchar(255) NOT NULL,
|
|
107
|
+
technical_equipment_cooling_cooling_area_percentage varchar(255) NOT NULL,
|
|
108
|
+
technical_equipment_cooling_year varchar(255) NOT NULL,
|
|
109
|
+
technical_equipment_cooling_technical_condition varchar(255) NOT NULL,
|
|
110
|
+
technical_equipment_ventilation_ventilation varchar(255) NOT NULL,
|
|
111
|
+
technical_equipment_ventilation_year varchar(255) NOT NULL,
|
|
112
|
+
technical_equipment_ventilation_technical_condition varchar(255) NOT NULL,
|
|
113
|
+
technical_equipment_humidity_adjustment_humidity_adjustment varchar(255) NOT NULL,
|
|
114
|
+
technical_equipment_humidity_adjustment_year varchar(255) NOT NULL,
|
|
115
|
+
technical_equipment_humidity_adjustment_technical_condition varchar(255) NOT NULL,
|
|
116
|
+
technical_equipment_hot_water_predominant_way_of_heating_tv varchar(255) NOT NULL,
|
|
117
|
+
technical_equipment_hot_water_hot_water_source varchar(255) NOT NULL,
|
|
118
|
+
technical_equipment_hot_water_year varchar(255) NOT NULL,
|
|
119
|
+
technical_equipment_hot_water_technical_condition varchar(255) NOT NULL,
|
|
120
|
+
technical_equipment_lighting_lighting varchar(255) NOT NULL,
|
|
121
|
+
technical_equipment_lighting_year varchar(255) NOT NULL,
|
|
122
|
+
technical_equipment_lighting_technical_condition varchar(255) NOT NULL,
|
|
123
|
+
technical_equipment_lighting_other_technological_elements varchar(255) NOT NULL,
|
|
124
|
+
technical_equipment_lighting_measurement_method varchar(255) NOT NULL,
|
|
125
|
+
oze_energy_production_solar_energy_photovoltaic varchar(255) NOT NULL,
|
|
126
|
+
oze_energy_production_solar_energy_photothermal varchar(255) NOT NULL,
|
|
127
|
+
oze_energy_production_integrated_turbines_wind_energy varchar(255) NOT NULL,
|
|
128
|
+
oze_energy_production_heat_pump varchar(255) NOT NULL,
|
|
129
|
+
waste_and_emissions_solid_waste_production varchar(255) NOT NULL,
|
|
130
|
+
waste_and_emissions_tied_co2_emissions varchar(255) NOT NULL,
|
|
131
|
+
waste_and_emissions_sox_emissions varchar(255) NOT NULL,
|
|
132
|
+
waste_and_emissions_operating_co_2emissions varchar(255) NOT NULL,
|
|
133
|
+
link varchar(255) NOT NULL,
|
|
134
|
+
create_batch_id int8 NULL,
|
|
135
|
+
created_at timestamp NULL,
|
|
136
|
+
created_by varchar(150) NULL,
|
|
137
|
+
update_batch_id int8 NULL,
|
|
138
|
+
updated_at timestamp NULL,
|
|
139
|
+
updated_by varchar(150) NULL,
|
|
140
|
+
CONSTRAINT consumption_energy_buildings_pkey PRIMARY KEY (id)
|
|
141
|
+
);
|
|
142
|
+
CREATE INDEX consumption_energy_buildings_create_batch ON consumption_energy_buildings USING btree (create_batch_id);
|
|
143
|
+
CREATE INDEX consumption_energy_buildings_update_batch ON consumption_energy_buildings USING btree (update_batch_id);
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
CREATE TABLE consumption_energy_consumption (
|
|
147
|
+
time_utc timestamp NOT NULL,
|
|
148
|
+
value numeric(30, 15) NOT NULL,
|
|
149
|
+
addr varchar(255) NOT NULL,
|
|
150
|
+
var varchar(255) NOT NULL,
|
|
151
|
+
"type" varchar(255) NULL,
|
|
152
|
+
commodity varchar(255) NULL,
|
|
153
|
+
unit varchar(255) NULL,
|
|
154
|
+
meter varchar(255) NOT NULL,
|
|
155
|
+
create_batch_id int8 NULL,
|
|
156
|
+
created_at timestamp NULL,
|
|
157
|
+
created_by varchar(150) NULL,
|
|
158
|
+
update_batch_id int8 NULL,
|
|
159
|
+
updated_at timestamp NULL,
|
|
160
|
+
updated_by varchar(150) NULL,
|
|
161
|
+
CONSTRAINT consumption_energy_consumption_pkey PRIMARY KEY (time_utc, addr, var, meter)
|
|
162
|
+
);
|
|
163
|
+
CREATE INDEX consumption_energy_consumption_create_batch ON consumption_energy_consumption USING btree (create_batch_id);
|
|
164
|
+
CREATE INDEX consumption_energy_consumption_update_batch ON consumption_energy_consumption USING btree (update_batch_id);
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
CREATE TABLE consumption_energy_devices (
|
|
168
|
+
id int4 NOT NULL,
|
|
169
|
+
addr varchar(255) NOT NULL,
|
|
170
|
+
description varchar(255) NOT NULL,
|
|
171
|
+
meter_number varchar(255) NOT NULL,
|
|
172
|
+
meter_index varchar(255) NOT NULL,
|
|
173
|
+
location_number varchar(255) NOT NULL,
|
|
174
|
+
location_description varchar(255) NOT NULL,
|
|
175
|
+
include_in_evaluation varchar(255) NOT NULL,
|
|
176
|
+
meter_type varchar(255) NOT NULL,
|
|
177
|
+
category varchar(255) NOT NULL,
|
|
178
|
+
unit varchar(255) NOT NULL,
|
|
179
|
+
replaced_meter_id varchar(255) NOT NULL,
|
|
180
|
+
deleted varchar(255) NOT NULL,
|
|
181
|
+
building_id int4 NOT NULL,
|
|
182
|
+
create_batch_id int8 NULL,
|
|
183
|
+
created_at timestamp NULL,
|
|
184
|
+
created_by varchar(150) NULL,
|
|
185
|
+
update_batch_id int8 NULL,
|
|
186
|
+
updated_at timestamp NULL,
|
|
187
|
+
updated_by varchar(150) NULL,
|
|
188
|
+
CONSTRAINT consumption_energy_devices_pkey PRIMARY KEY (id)
|
|
189
|
+
);
|
|
190
|
+
CREATE INDEX consumption_energy_devices_create_batch ON consumption_energy_devices USING btree (create_batch_id);
|
|
191
|
+
CREATE INDEX consumption_energy_devices_update_batch ON consumption_energy_devices USING btree (update_batch_id);
|
|
192
|
+
|
|
193
|
+
CREATE TABLE vpalac_measurement (
|
|
194
|
+
var_id int4 NOT NULL,
|
|
195
|
+
time_measurement int8 NOT NULL,
|
|
196
|
+
value numeric NULL,
|
|
197
|
+
created_at timestamptz NULL DEFAULT now(),
|
|
198
|
+
updated_at timestamptz NULL,
|
|
199
|
+
CONSTRAINT vpalac_measurement_pk PRIMARY KEY (var_id, time_measurement)
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
CREATE TABLE vpalac_measuring_equipment (
|
|
203
|
+
me_id int4 NOT NULL,
|
|
204
|
+
me_fakt bool NULL,
|
|
205
|
+
umisteni varchar(250) NULL,
|
|
206
|
+
mis_nazev varchar(255) NULL,
|
|
207
|
+
me_serial varchar(50) NULL,
|
|
208
|
+
me_od timestamptz NULL,
|
|
209
|
+
me_do timestamptz NULL,
|
|
210
|
+
pot_id int4 NOT NULL,
|
|
211
|
+
poc_typode int4 NULL,
|
|
212
|
+
var_id int4 NULL,
|
|
213
|
+
mis_id int4 NULL,
|
|
214
|
+
met_id int4 NULL,
|
|
215
|
+
me_extid varchar(50) NULL,
|
|
216
|
+
me_zapoc bool NULL,
|
|
217
|
+
me_plom varchar(250) NULL,
|
|
218
|
+
created_at timestamptz NULL DEFAULT now(),
|
|
219
|
+
updated_at timestamptz NULL,
|
|
220
|
+
CONSTRAINT vpalac_measuring_equipment_pkey PRIMARY KEY (me_id, pot_id)
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
CREATE TABLE vpalac_meter_type (
|
|
224
|
+
met_id int4 NOT NULL,
|
|
225
|
+
met_druh int4 NULL,
|
|
226
|
+
met_nazev varchar(150) NULL,
|
|
227
|
+
met_kod varchar(50) NULL,
|
|
228
|
+
met_ziv numeric NULL,
|
|
229
|
+
vyr_zkr varchar(50) NULL,
|
|
230
|
+
fir_id int4 NULL,
|
|
231
|
+
medium int4 NULL,
|
|
232
|
+
created_at timestamptz NULL DEFAULT now(),
|
|
233
|
+
updated_at timestamptz NULL,
|
|
234
|
+
CONSTRAINT vpalac_meter_type_pkey PRIMARY KEY (met_id)
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
CREATE TABLE vpalac_type_measuring_equipment (
|
|
238
|
+
cik_nazev varchar(150) NULL,
|
|
239
|
+
lt_key varchar(50) NOT NULL,
|
|
240
|
+
cik_fk int4 NULL,
|
|
241
|
+
cik_char varchar(50) NULL,
|
|
242
|
+
cik_cislo int4 NULL,
|
|
243
|
+
cik_double numeric NULL,
|
|
244
|
+
cik_pzn varchar(50) NULL,
|
|
245
|
+
cik_cislo2 int4 NULL,
|
|
246
|
+
cik_zprac varchar(50) NULL,
|
|
247
|
+
cik_akt bool NULL,
|
|
248
|
+
created_at timestamptz NULL DEFAULT now(),
|
|
249
|
+
updated_at timestamptz NULL,
|
|
250
|
+
CONSTRAINT vpalac_type_measuring_equipment_pkey PRIMARY KEY (lt_key)
|
|
251
|
+
);
|
|
252
|
+
|
|
253
|
+
CREATE TABLE vpalac_units (
|
|
254
|
+
pot_id int4 NULL,
|
|
255
|
+
lt_key varchar(50) NOT NULL,
|
|
256
|
+
jed_nazev varchar(150) NULL,
|
|
257
|
+
jed_zkr varchar(50) NULL,
|
|
258
|
+
pot_defcolor varchar(20) NULL,
|
|
259
|
+
pot_type int4 NULL,
|
|
260
|
+
jed_id int4 NULL,
|
|
261
|
+
ptv_id int4 NULL,
|
|
262
|
+
created_at timestamptz NULL DEFAULT now(),
|
|
263
|
+
updated_at timestamptz NULL,
|
|
264
|
+
CONSTRAINT vpalac_units_pkey PRIMARY KEY (lt_key)
|
|
265
|
+
);
|
|
266
|
+
|
|
267
|
+
-- pohledy
|
|
268
|
+
|
|
269
|
+
CREATE OR REPLACE VIEW v_consumption_energy_avg_consumption_min
|
|
270
|
+
AS SELECT za_minutu.addr,
|
|
271
|
+
za_minutu.var,
|
|
272
|
+
za_minutu.meter,
|
|
273
|
+
avg(za_minutu.spotreba_za_minutu) AS consumption_min
|
|
274
|
+
FROM ( SELECT consumption_energy_consumption.time_utc,
|
|
275
|
+
consumption_energy_consumption.addr,
|
|
276
|
+
consumption_energy_consumption.var,
|
|
277
|
+
consumption_energy_consumption.commodity,
|
|
278
|
+
consumption_energy_consumption.unit,
|
|
279
|
+
consumption_energy_consumption.value,
|
|
280
|
+
consumption_energy_consumption.meter,
|
|
281
|
+
CASE
|
|
282
|
+
WHEN ((consumption_energy_consumption.value - lag(consumption_energy_consumption.value) OVER (PARTITION BY consumption_energy_consumption.addr, consumption_energy_consumption.var, consumption_energy_consumption.meter ORDER BY consumption_energy_consumption.time_utc))::double precision / date_part('epoch'::text, consumption_energy_consumption.time_utc - lag(consumption_energy_consumption.time_utc) OVER (PARTITION BY consumption_energy_consumption.addr, consumption_energy_consumption.var, consumption_energy_consumption.meter ORDER BY consumption_energy_consumption.time_utc)) / 60::double precision) < 0::double precision THEN 0::double precision
|
|
283
|
+
ELSE (consumption_energy_consumption.value - lag(consumption_energy_consumption.value) OVER (PARTITION BY consumption_energy_consumption.addr, consumption_energy_consumption.var, consumption_energy_consumption.meter ORDER BY consumption_energy_consumption.time_utc))::double precision / (date_part('epoch'::text, consumption_energy_consumption.time_utc - lag(consumption_energy_consumption.time_utc) OVER (PARTITION BY consumption_energy_consumption.addr, consumption_energy_consumption.var, consumption_energy_consumption.meter ORDER BY consumption_energy_consumption.time_utc)) / 60::double precision)
|
|
284
|
+
END AS spotreba_za_minutu
|
|
285
|
+
FROM consumption_energy_consumption
|
|
286
|
+
WHERE consumption_energy_consumption.var::text = 'core'::text AND (consumption_energy_consumption.addr::text ~~ '%F%'::text OR consumption_energy_consumption.addr::text = '/2.1/VP2'::text) AND consumption_energy_consumption.value > 0::numeric) za_minutu
|
|
287
|
+
GROUP BY za_minutu.addr, za_minutu.var, za_minutu.meter;
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
CREATE OR REPLACE VIEW v_consumption_energy_alerts
|
|
291
|
+
AS WITH vymena_s AS (
|
|
292
|
+
SELECT es.time_utc,
|
|
293
|
+
es.addr,
|
|
294
|
+
es.var,
|
|
295
|
+
es.commodity,
|
|
296
|
+
es.unit,
|
|
297
|
+
es.value,
|
|
298
|
+
es.meter,
|
|
299
|
+
lag(es.value) OVER (PARTITION BY es.addr, es.var, es.meter ORDER BY es.time_utc) AS last_value,
|
|
300
|
+
lag(es.time_utc) OVER (PARTITION BY es.addr, es.var, es.meter ORDER BY es.time_utc) AS last_timeutc,
|
|
301
|
+
es.value - lag(es.value) OVER (PARTITION BY es.addr, es.var, es.meter ORDER BY es.time_utc) AS delta_value,
|
|
302
|
+
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,
|
|
303
|
+
min.consumption_min,
|
|
304
|
+
(es.value - lag(es.value) OVER (PARTITION BY es.addr, es.var, es.meter ORDER BY es.time_utc))::double precision / (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 za_minutu_ted,
|
|
305
|
+
CASE
|
|
306
|
+
WHEN (es.value - lag(es.value) OVER (PARTITION BY es.addr, es.var, es.meter ORDER BY es.time_utc)) < 0::numeric THEN 'pokles'::text
|
|
307
|
+
WHEN min.consumption_min > 0::double precision AND ((es.value - lag(es.value) OVER (PARTITION BY es.addr, es.var, es.meter ORDER BY es.time_utc))::double precision / (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)) > (1000::double precision * min.consumption_min) THEN 'narust'::text
|
|
308
|
+
ELSE NULL::text
|
|
309
|
+
END AS vymena
|
|
310
|
+
FROM consumption_energy_consumption es
|
|
311
|
+
JOIN 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
|
|
312
|
+
WHERE es.var::text = 'core'::text AND es.addr::text ~~ '%F%'::text AND es.value > 0::numeric
|
|
313
|
+
)
|
|
314
|
+
SELECT vymena_s.time_utc,
|
|
315
|
+
vymena_s.addr,
|
|
316
|
+
vymena_s.var,
|
|
317
|
+
vymena_s.commodity,
|
|
318
|
+
vymena_s.unit,
|
|
319
|
+
vymena_s.value,
|
|
320
|
+
vymena_s.meter,
|
|
321
|
+
vymena_s.last_value,
|
|
322
|
+
vymena_s.last_timeutc,
|
|
323
|
+
vymena_s.delta_value,
|
|
324
|
+
vymena_s.minut,
|
|
325
|
+
vymena_s.consumption_min,
|
|
326
|
+
vymena_s.za_minutu_ted,
|
|
327
|
+
vymena_s.vymena
|
|
328
|
+
FROM vymena_s
|
|
329
|
+
WHERE vymena_s.vymena IS NOT NULL;
|
|
330
|
+
|
|
331
|
+
CREATE OR REPLACE VIEW v_consumption_energy_change
|
|
332
|
+
AS SELECT a.time_utc,
|
|
333
|
+
a.addr,
|
|
334
|
+
a.var,
|
|
335
|
+
a.commodity,
|
|
336
|
+
a.unit,
|
|
337
|
+
a.value,
|
|
338
|
+
a.meter,
|
|
339
|
+
a.last_value,
|
|
340
|
+
a.last_timeutc,
|
|
341
|
+
a.delta_value,
|
|
342
|
+
a.minut,
|
|
343
|
+
a.consumption_min,
|
|
344
|
+
a.za_minutu_ted,
|
|
345
|
+
a.vymena
|
|
346
|
+
FROM ( SELECT es.time_utc,
|
|
347
|
+
es.addr,
|
|
348
|
+
es.var,
|
|
349
|
+
es.commodity,
|
|
350
|
+
es.unit,
|
|
351
|
+
es.value,
|
|
352
|
+
es.meter,
|
|
353
|
+
lag(es.value) OVER (PARTITION BY es.addr, es.var, es.meter ORDER BY es.time_utc) AS last_value,
|
|
354
|
+
lag(es.time_utc) OVER (PARTITION BY es.addr, es.var, es.meter ORDER BY es.time_utc) AS last_timeutc,
|
|
355
|
+
es.value - lag(es.value) OVER (PARTITION BY es.addr, es.var, es.meter ORDER BY es.time_utc) AS delta_value,
|
|
356
|
+
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,
|
|
357
|
+
min.consumption_min,
|
|
358
|
+
(es.value - lag(es.value) OVER (PARTITION BY es.addr, es.var, es.meter ORDER BY es.time_utc))::double precision / (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 za_minutu_ted,
|
|
359
|
+
CASE
|
|
360
|
+
WHEN (es.value - lag(es.value) OVER (PARTITION BY es.addr, es.var, es.meter ORDER BY es.time_utc)) < 0::numeric THEN 'pokles'::text
|
|
361
|
+
WHEN min.consumption_min > 0::double precision AND ((es.value - lag(es.value) OVER (PARTITION BY es.addr, es.var, es.meter ORDER BY es.time_utc))::double precision / (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)) > (1000::double precision * min.consumption_min) THEN 'narust'::text
|
|
362
|
+
ELSE NULL::text
|
|
363
|
+
END AS vymena
|
|
364
|
+
FROM consumption_energy_consumption es
|
|
365
|
+
JOIN 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
|
|
366
|
+
WHERE es.var::text = 'core'::text AND es.addr::text ~~ '%F%'::text AND es.value > 0::numeric) a
|
|
367
|
+
WHERE a.vymena IS NOT NULL;
|
|
368
|
+
|
|
369
|
+
CREATE OR REPLACE VIEW v_consumption_energy_delta
|
|
370
|
+
AS WITH delta AS (
|
|
371
|
+
SELECT es.time_utc,
|
|
372
|
+
es.addr,
|
|
373
|
+
es.var,
|
|
374
|
+
es.commodity,
|
|
375
|
+
es.unit,
|
|
376
|
+
es.value,
|
|
377
|
+
es.meter,
|
|
378
|
+
lag(es.value) OVER (PARTITION BY es.addr, es.var, es.meter ORDER BY es.time_utc) AS last_value,
|
|
379
|
+
lag(es.time_utc) OVER (PARTITION BY es.addr, es.var, es.meter ORDER BY es.time_utc) AS last_timeutc,
|
|
380
|
+
es.value - lag(es.value) OVER (PARTITION BY es.addr, es.var, es.meter ORDER BY es.time_utc) AS delta_value,
|
|
381
|
+
min.consumption_min AS prumerna_spotreba,
|
|
382
|
+
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
|
|
383
|
+
FROM consumption_energy_consumption es
|
|
384
|
+
JOIN 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
|
|
385
|
+
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
|
|
386
|
+
)
|
|
387
|
+
SELECT delta.time_utc,
|
|
388
|
+
delta.addr,
|
|
389
|
+
delta.var,
|
|
390
|
+
delta.commodity,
|
|
391
|
+
delta.unit,
|
|
392
|
+
delta.value,
|
|
393
|
+
delta.meter,
|
|
394
|
+
delta.last_value,
|
|
395
|
+
delta.last_timeutc,
|
|
396
|
+
CASE
|
|
397
|
+
WHEN abs(delta.delta_value::double precision / 60::double precision) > abs(1000::double precision * delta.prumerna_spotreba) THEN 0::numeric
|
|
398
|
+
ELSE delta.delta_value
|
|
399
|
+
END AS delta_value,
|
|
400
|
+
delta.minut_mereni
|
|
401
|
+
FROM delta;
|
|
402
|
+
|
|
403
|
+
CREATE OR REPLACE VIEW v_consumption_energy_deduct_month_ptv
|
|
404
|
+
AS SELECT date_part('year'::text, consumption_energy_consumption.time_utc) AS rok,
|
|
405
|
+
date_part('month'::text, consumption_energy_consumption.time_utc) AS mesic,
|
|
406
|
+
consumption_energy_consumption.addr,
|
|
407
|
+
consumption_energy_consumption.var,
|
|
408
|
+
consumption_energy_consumption.commodity,
|
|
409
|
+
consumption_energy_consumption.unit,
|
|
410
|
+
sum(consumption_energy_consumption.delta_value) AS value,
|
|
411
|
+
max(consumption_energy_consumption.time_utc::date) AS data_do,
|
|
412
|
+
count(*) AS count
|
|
413
|
+
FROM v_consumption_energy_delta consumption_energy_consumption
|
|
414
|
+
WHERE consumption_energy_consumption.meter::text <> '300066393'::text OR consumption_energy_consumption.time_utc::date <= '2021-04-01'::date
|
|
415
|
+
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;
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
CREATE OR REPLACE VIEW v_consumption_energy_consumption_month_ptv
|
|
419
|
+
AS SELECT v_consumption_energy_deduct_month_ptv.rok,
|
|
420
|
+
v_consumption_energy_deduct_month_ptv.mesic,
|
|
421
|
+
v_consumption_energy_deduct_month_ptv.addr,
|
|
422
|
+
v_consumption_energy_deduct_month_ptv.var,
|
|
423
|
+
v_consumption_energy_deduct_month_ptv.commodity,
|
|
424
|
+
v_consumption_energy_deduct_month_ptv.unit,
|
|
425
|
+
v_consumption_energy_deduct_month_ptv.value,
|
|
426
|
+
v_consumption_energy_deduct_month_ptv.data_do,
|
|
427
|
+
v_consumption_energy_deduct_month_ptv.count,
|
|
428
|
+
NULL::numeric AS previous_month_value,
|
|
429
|
+
v_consumption_energy_deduct_month_ptv.value AS mesicni_spotreba
|
|
430
|
+
FROM v_consumption_energy_deduct_month_ptv
|
|
431
|
+
WHERE v_consumption_energy_deduct_month_ptv.addr::text <> ALL (ARRAY['/2.1/TVF1'::character varying::text, '/2.1/VF1'::character varying::text, '/2.1/VP2'::character varying::text])
|
|
432
|
+
UNION
|
|
433
|
+
SELECT tvf1.rok,
|
|
434
|
+
tvf1.mesic,
|
|
435
|
+
tvf1.addr,
|
|
436
|
+
tvf1.var,
|
|
437
|
+
tvf1.commodity,
|
|
438
|
+
tvf1.unit,
|
|
439
|
+
vf1.value - vp2.value + tvf1.value AS value,
|
|
440
|
+
tvf1.data_do,
|
|
441
|
+
tvf1.count,
|
|
442
|
+
NULL::numeric AS previous_month_value,
|
|
443
|
+
vf1.value - vp2.value + tvf1.value AS mesicni_spotreba
|
|
444
|
+
FROM v_consumption_energy_deduct_month_ptv tvf1
|
|
445
|
+
LEFT JOIN v_consumption_energy_deduct_month_ptv vf1 ON vf1.addr::text = '/2.1/VF1'::text AND vf1.rok = tvf1.rok AND vf1.mesic = tvf1.mesic
|
|
446
|
+
LEFT JOIN v_consumption_energy_deduct_month_ptv vp2 ON vp2.addr::text = '/2.1/VP2'::text AND vp2.rok = tvf1.rok AND vp2.mesic = tvf1.mesic
|
|
447
|
+
WHERE tvf1.addr::text = '/2.1/TVF1'::text;
|
|
448
|
+
|
|
449
|
+
CREATE OR REPLACE VIEW v_consumption_energy_consumption_month_t_f
|
|
450
|
+
AS SELECT v_consumption_energy_consumption_month_ptv.rok,
|
|
451
|
+
v_consumption_energy_consumption_month_ptv.mesic,
|
|
452
|
+
v_consumption_energy_consumption_month_ptv.addr,
|
|
453
|
+
v_consumption_energy_consumption_month_ptv.var,
|
|
454
|
+
v_consumption_energy_consumption_month_ptv.commodity,
|
|
455
|
+
v_consumption_energy_consumption_month_ptv.unit,
|
|
456
|
+
v_consumption_energy_consumption_month_ptv.value,
|
|
457
|
+
v_consumption_energy_consumption_month_ptv.data_do,
|
|
458
|
+
v_consumption_energy_consumption_month_ptv.count,
|
|
459
|
+
v_consumption_energy_consumption_month_ptv.previous_month_value,
|
|
460
|
+
v_consumption_energy_consumption_month_ptv.mesicni_spotreba
|
|
461
|
+
FROM v_consumption_energy_consumption_month_ptv
|
|
462
|
+
WHERE v_consumption_energy_consumption_month_ptv.addr::text ~~ '%/TF%'::text AND v_consumption_energy_consumption_month_ptv.rok > 2018::double precision;
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
CREATE OR REPLACE VIEW v_consumption_gas_reserve
|
|
466
|
+
AS WITH kalendar AS (
|
|
467
|
+
SELECT den.den::date AS den
|
|
468
|
+
FROM generate_series('2019-01-01 00:00:00+01'::timestamp with time zone, now() - '1 day'::interval, '1 day'::interval) den(den)
|
|
469
|
+
), meraky AS (
|
|
470
|
+
SELECT DISTINCT consumption_energy_devices.addr
|
|
471
|
+
FROM consumption_energy_devices
|
|
472
|
+
WHERE consumption_energy_devices.meter_type::text = 'Plynoměr'::text
|
|
473
|
+
), daily_delta_core AS (
|
|
474
|
+
SELECT date_trunc('day'::text, v_consumption_energy_delta.time_utc - '06:00:00'::interval)::date AS measured_from,
|
|
475
|
+
v_consumption_energy_delta.addr,
|
|
476
|
+
v_consumption_energy_delta.var,
|
|
477
|
+
sum(v_consumption_energy_delta.delta_value) AS delta_value
|
|
478
|
+
FROM v_consumption_energy_delta
|
|
479
|
+
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
|
|
480
|
+
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
|
|
481
|
+
), daily_delta_core2 AS (
|
|
482
|
+
SELECT date_trunc('day'::text, consumption_energy_consumption.time_utc - '06:00:00'::interval)::date AS measured_from,
|
|
483
|
+
consumption_energy_consumption.addr,
|
|
484
|
+
consumption_energy_consumption.var,
|
|
485
|
+
sum(consumption_energy_consumption.value) AS delta_value
|
|
486
|
+
FROM consumption_energy_consumption
|
|
487
|
+
WHERE consumption_energy_consumption.var::text = 'core2'::text AND consumption_energy_consumption.time_utc::date > '2018-12-31'::date
|
|
488
|
+
GROUP BY (date_trunc('day'::text, consumption_energy_consumption.time_utc - '06:00:00'::interval)::date), consumption_energy_consumption.addr, consumption_energy_consumption.var
|
|
489
|
+
), delta_dates AS (
|
|
490
|
+
SELECT daily_delta_core.measured_from,
|
|
491
|
+
daily_delta_core.addr,
|
|
492
|
+
daily_delta_core.var,
|
|
493
|
+
daily_delta_core.delta_value,
|
|
494
|
+
lag(daily_delta_core.measured_from, 1) OVER (PARTITION BY daily_delta_core.addr ORDER BY daily_delta_core.measured_from) AS measured_before,
|
|
495
|
+
lead(daily_delta_core.measured_from, 1) OVER (PARTITION BY daily_delta_core.addr ORDER BY daily_delta_core.measured_from) AS measured_after,
|
|
496
|
+
lag(daily_delta_core.delta_value, 1) OVER (PARTITION BY daily_delta_core.addr ORDER BY daily_delta_core.measured_from) AS delta_before,
|
|
497
|
+
lead(daily_delta_core.delta_value, 1) OVER (PARTITION BY daily_delta_core.addr ORDER BY daily_delta_core.measured_from) AS delta_after
|
|
498
|
+
FROM daily_delta_core
|
|
499
|
+
), delta_date_diff AS (
|
|
500
|
+
SELECT delta_dates.measured_from,
|
|
501
|
+
delta_dates.addr,
|
|
502
|
+
delta_dates.var,
|
|
503
|
+
delta_dates.delta_value,
|
|
504
|
+
delta_dates.measured_before,
|
|
505
|
+
delta_dates.measured_after,
|
|
506
|
+
delta_dates.delta_before,
|
|
507
|
+
delta_dates.delta_after,
|
|
508
|
+
CASE
|
|
509
|
+
WHEN (delta_dates.measured_after - delta_dates.measured_from) > 1 AND (delta_dates.measured_from - delta_dates.measured_before) > 1 THEN 'mid'::text
|
|
510
|
+
WHEN (delta_dates.measured_after - delta_dates.measured_from) > 1 THEN 'begin'::text
|
|
511
|
+
WHEN (delta_dates.measured_from - delta_dates.measured_before) > 1 THEN 'end'::text
|
|
512
|
+
ELSE 'ok'::text
|
|
513
|
+
END AS value_type,
|
|
514
|
+
CASE
|
|
515
|
+
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
|
|
516
|
+
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
|
|
517
|
+
ELSE NULL::numeric
|
|
518
|
+
END AS fix
|
|
519
|
+
FROM delta_dates
|
|
520
|
+
), joined_table AS (
|
|
521
|
+
SELECT kalendar.den AS measured_from,
|
|
522
|
+
meraky.addr,
|
|
523
|
+
diff.delta_value,
|
|
524
|
+
diff.value_type,
|
|
525
|
+
diff.fix,
|
|
526
|
+
core2.delta_value AS core2_delta,
|
|
527
|
+
CASE
|
|
528
|
+
WHEN diff.value_type = 'ok'::text THEN COALESCE(core2.delta_value, diff.delta_value)
|
|
529
|
+
ELSE diff.fix
|
|
530
|
+
END AS final_fix,
|
|
531
|
+
CASE
|
|
532
|
+
WHEN diff.value_type = 'ok'::text THEN COALESCE(core2.var, diff.var)
|
|
533
|
+
ELSE 'core'::character varying
|
|
534
|
+
END AS final_var
|
|
535
|
+
FROM kalendar
|
|
536
|
+
LEFT JOIN meraky ON true
|
|
537
|
+
LEFT JOIN delta_date_diff diff ON diff.measured_from = kalendar.den AND diff.addr::text = meraky.addr::text
|
|
538
|
+
LEFT JOIN daily_delta_core2 core2 ON core2.measured_from = kalendar.den AND core2.addr::text = meraky.addr::text
|
|
539
|
+
ORDER BY meraky.addr, kalendar.den
|
|
540
|
+
), fixed_table AS (
|
|
541
|
+
SELECT q.measured_from,
|
|
542
|
+
q.addr,
|
|
543
|
+
q.delta_value,
|
|
544
|
+
q.value_type,
|
|
545
|
+
q.fix,
|
|
546
|
+
q.core2_delta,
|
|
547
|
+
q.final_fix,
|
|
548
|
+
q.final_var,
|
|
549
|
+
q.value_partition,
|
|
550
|
+
first_value(q.final_fix) OVER w AS value
|
|
551
|
+
FROM ( SELECT joined_table.measured_from,
|
|
552
|
+
joined_table.addr,
|
|
553
|
+
joined_table.delta_value,
|
|
554
|
+
joined_table.value_type,
|
|
555
|
+
joined_table.fix,
|
|
556
|
+
joined_table.core2_delta,
|
|
557
|
+
joined_table.final_fix,
|
|
558
|
+
joined_table.final_var,
|
|
559
|
+
sum(
|
|
560
|
+
CASE
|
|
561
|
+
WHEN joined_table.final_fix IS NULL THEN 0
|
|
562
|
+
ELSE 1
|
|
563
|
+
END) OVER (PARTITION BY joined_table.addr ORDER BY joined_table.measured_from) AS value_partition
|
|
564
|
+
FROM joined_table) q
|
|
565
|
+
WINDOW w AS (PARTITION BY q.addr, q.value_partition ORDER BY q.measured_from)
|
|
566
|
+
)
|
|
567
|
+
SELECT fixed_table.measured_from,
|
|
568
|
+
fixed_table.addr,
|
|
569
|
+
fixed_table.value AS delta_value,
|
|
570
|
+
fixed_table.final_var,
|
|
571
|
+
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
|
|
572
|
+
FROM fixed_table
|
|
573
|
+
WHERE fixed_table.value IS NOT NULL;
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
CREATE OR REPLACE VIEW v_consumption_energy_buildings_real
|
|
577
|
+
AS SELECT consumption_energy_buildings.id,
|
|
578
|
+
consumption_energy_buildings.building_name,
|
|
579
|
+
consumption_energy_buildings.description,
|
|
580
|
+
consumption_energy_buildings.building_address_code,
|
|
581
|
+
consumption_energy_buildings.building_label,
|
|
582
|
+
consumption_energy_buildings.current_note,
|
|
583
|
+
consumption_energy_buildings.main_use,
|
|
584
|
+
consumption_energy_buildings.secondary_use,
|
|
585
|
+
consumption_energy_buildings.year_of_construction,
|
|
586
|
+
consumption_energy_buildings.method_of_protection,
|
|
587
|
+
consumption_energy_buildings.built_up_area,
|
|
588
|
+
consumption_energy_buildings.heated_bulding_volume,
|
|
589
|
+
consumption_energy_buildings.students_count,
|
|
590
|
+
consumption_energy_buildings.employees_count,
|
|
591
|
+
consumption_energy_buildings.classrooms_count,
|
|
592
|
+
consumption_energy_buildings.beds_count,
|
|
593
|
+
consumption_energy_buildings.eno_id,
|
|
594
|
+
consumption_energy_buildings.csu_code,
|
|
595
|
+
consumption_energy_buildings.ku_code,
|
|
596
|
+
consumption_energy_buildings.allotment_number,
|
|
597
|
+
consumption_energy_buildings.registration_unit,
|
|
598
|
+
consumption_energy_buildings.gas_consumption_normatives,
|
|
599
|
+
consumption_energy_buildings.heat_consumption_normatives,
|
|
600
|
+
consumption_energy_buildings.water_consumption_normatives,
|
|
601
|
+
consumption_energy_buildings.electricity_consumption_normatives_per_person,
|
|
602
|
+
consumption_energy_buildings.electricity_consumption_normatives,
|
|
603
|
+
consumption_energy_buildings.energetic_management,
|
|
604
|
+
consumption_energy_buildings.opening_hours,
|
|
605
|
+
consumption_energy_buildings.weekend_opening_hours,
|
|
606
|
+
consumption_energy_buildings.latitude,
|
|
607
|
+
consumption_energy_buildings.longitude,
|
|
608
|
+
consumption_energy_buildings.address_street,
|
|
609
|
+
consumption_energy_buildings.address_house_number,
|
|
610
|
+
consumption_energy_buildings.address_city,
|
|
611
|
+
consumption_energy_buildings.address_country,
|
|
612
|
+
consumption_energy_buildings.address_mail,
|
|
613
|
+
consumption_energy_buildings.address_phone,
|
|
614
|
+
consumption_energy_buildings.address_web_address,
|
|
615
|
+
consumption_energy_buildings.penb_penbnumber,
|
|
616
|
+
consumption_energy_buildings.penb_issue_date,
|
|
617
|
+
consumption_energy_buildings.penb_total_building_envelope_area,
|
|
618
|
+
consumption_energy_buildings.penb_volume_factor_of_avshape,
|
|
619
|
+
consumption_energy_buildings.penb_total_energy_reference_area,
|
|
620
|
+
consumption_energy_buildings.penb_total_provided_energy,
|
|
621
|
+
consumption_energy_buildings.penb_total_provided_energy_category,
|
|
622
|
+
consumption_energy_buildings.penb_primary_non_renewable_energy,
|
|
623
|
+
consumption_energy_buildings.penb_primary_non_renewable_energy_category,
|
|
624
|
+
consumption_energy_buildings.penb_building_envelope,
|
|
625
|
+
consumption_energy_buildings.penb_building_envelope_category,
|
|
626
|
+
consumption_energy_buildings.penb_heating,
|
|
627
|
+
consumption_energy_buildings.penb_heating_category,
|
|
628
|
+
consumption_energy_buildings.penb_cooling,
|
|
629
|
+
consumption_energy_buildings.penb_cooling_category,
|
|
630
|
+
consumption_energy_buildings.penb_ventilation,
|
|
631
|
+
consumption_energy_buildings.penb_ventilation_category,
|
|
632
|
+
consumption_energy_buildings.penb_humidity_adjustment,
|
|
633
|
+
consumption_energy_buildings.penb_humidity_adjustment_category,
|
|
634
|
+
consumption_energy_buildings.penb_warm_water,
|
|
635
|
+
consumption_energy_buildings.penb_warm_water_category,
|
|
636
|
+
consumption_energy_buildings.penb_lighting,
|
|
637
|
+
consumption_energy_buildings.penb_lighting_category,
|
|
638
|
+
consumption_energy_buildings.energy_audits_energy_audit,
|
|
639
|
+
consumption_energy_buildings.energy_audits_earegistration_number,
|
|
640
|
+
consumption_energy_buildings.energy_audits_created_at,
|
|
641
|
+
consumption_energy_buildings.building_envelope_side_wall_prevailing_construction,
|
|
642
|
+
consumption_energy_buildings.building_envelope_side_wall_area,
|
|
643
|
+
consumption_energy_buildings.building_envelope_side_wall_heat_insulation,
|
|
644
|
+
consumption_energy_buildings.building_envelope_side_wall_year_of_adjustment,
|
|
645
|
+
consumption_energy_buildings.building_envelope_side_wall_technical_condition,
|
|
646
|
+
consumption_energy_buildings.building_envelope_filling_of_hole_construction,
|
|
647
|
+
consumption_energy_buildings.building_envelope_filling_of_hole_area,
|
|
648
|
+
consumption_energy_buildings.building_envelope_filling_of_hole_year_of_adjustment,
|
|
649
|
+
consumption_energy_buildings.building_envelope_filling_of_hole_technical_condition,
|
|
650
|
+
consumption_energy_buildings.building_envelope_roof_construction,
|
|
651
|
+
consumption_energy_buildings.building_envelope_roof_area,
|
|
652
|
+
consumption_energy_buildings.building_envelope_roof_thermal_insulation,
|
|
653
|
+
consumption_energy_buildings.building_envelope_roof_year_of_adjustment,
|
|
654
|
+
consumption_energy_buildings.building_envelope_roof_technical_condition,
|
|
655
|
+
consumption_energy_buildings.building_envelope_floor_of_the_lowest_heated_floor_construction,
|
|
656
|
+
consumption_energy_buildings.building_envelope_floor_of_the_lowest_heated_floor_area,
|
|
657
|
+
consumption_energy_buildings.floor_of_the_lowest_heated_floor_thermal_insulation,
|
|
658
|
+
consumption_energy_buildings.building_envelope_floor_of_the_lowest_heated_floor_year_of_adju,
|
|
659
|
+
consumption_energy_buildings.floor_of_the_lowest_heated_floor_technical_condition,
|
|
660
|
+
consumption_energy_buildings.fuel_and_energy_coal,
|
|
661
|
+
consumption_energy_buildings.fuel_and_energy_gas,
|
|
662
|
+
consumption_energy_buildings.fuel_and_energy_electricity,
|
|
663
|
+
consumption_energy_buildings.fuel_and_energy_czt,
|
|
664
|
+
consumption_energy_buildings.fuel_and_energy_oze,
|
|
665
|
+
consumption_energy_buildings.fuel_and_energy_other,
|
|
666
|
+
consumption_energy_buildings.technical_equipment_heating_main_source_of_heat,
|
|
667
|
+
consumption_energy_buildings.technical_equipment_heating_heat_percentage,
|
|
668
|
+
consumption_energy_buildings.technical_equipment_heating_secondary_source_of_heat,
|
|
669
|
+
consumption_energy_buildings.technical_equipment_heating_heating_system,
|
|
670
|
+
consumption_energy_buildings.technical_equipment_heating_year,
|
|
671
|
+
consumption_energy_buildings.technical_equipment_heating_technical_condition,
|
|
672
|
+
consumption_energy_buildings.technical_equipment_cooling_cooling_system,
|
|
673
|
+
consumption_energy_buildings.technical_equipment_cooling_cooling_area_percentage,
|
|
674
|
+
consumption_energy_buildings.technical_equipment_cooling_year,
|
|
675
|
+
consumption_energy_buildings.technical_equipment_cooling_technical_condition,
|
|
676
|
+
consumption_energy_buildings.technical_equipment_ventilation_ventilation,
|
|
677
|
+
consumption_energy_buildings.technical_equipment_ventilation_year,
|
|
678
|
+
consumption_energy_buildings.technical_equipment_ventilation_technical_condition,
|
|
679
|
+
consumption_energy_buildings.technical_equipment_humidity_adjustment_humidity_adjustment,
|
|
680
|
+
consumption_energy_buildings.technical_equipment_humidity_adjustment_year,
|
|
681
|
+
consumption_energy_buildings.technical_equipment_humidity_adjustment_technical_condition,
|
|
682
|
+
consumption_energy_buildings.technical_equipment_hot_water_predominant_way_of_heating_tv,
|
|
683
|
+
consumption_energy_buildings.technical_equipment_hot_water_hot_water_source,
|
|
684
|
+
consumption_energy_buildings.technical_equipment_hot_water_year,
|
|
685
|
+
consumption_energy_buildings.technical_equipment_hot_water_technical_condition,
|
|
686
|
+
consumption_energy_buildings.technical_equipment_lighting_lighting,
|
|
687
|
+
consumption_energy_buildings.technical_equipment_lighting_year,
|
|
688
|
+
consumption_energy_buildings.technical_equipment_lighting_technical_condition,
|
|
689
|
+
consumption_energy_buildings.technical_equipment_lighting_other_technological_elements,
|
|
690
|
+
consumption_energy_buildings.technical_equipment_lighting_measurement_method,
|
|
691
|
+
consumption_energy_buildings.oze_energy_production_solar_energy_photovoltaic,
|
|
692
|
+
consumption_energy_buildings.oze_energy_production_solar_energy_photothermal,
|
|
693
|
+
consumption_energy_buildings.oze_energy_production_integrated_turbines_wind_energy,
|
|
694
|
+
consumption_energy_buildings.oze_energy_production_heat_pump,
|
|
695
|
+
consumption_energy_buildings.waste_and_emissions_solid_waste_production,
|
|
696
|
+
consumption_energy_buildings.waste_and_emissions_tied_co2_emissions,
|
|
697
|
+
consumption_energy_buildings.waste_and_emissions_sox_emissions,
|
|
698
|
+
consumption_energy_buildings.waste_and_emissions_operating_co_2emissions,
|
|
699
|
+
consumption_energy_buildings.link
|
|
700
|
+
FROM consumption_energy_buildings
|
|
701
|
+
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]);
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
CREATE OR REPLACE VIEW v_consumption_energy_buildings_real_mc
|
|
705
|
+
AS SELECT consumption_energy_buildings.id,
|
|
706
|
+
consumption_energy_buildings.building_name,
|
|
707
|
+
consumption_energy_buildings.description,
|
|
708
|
+
consumption_energy_buildings.building_address_code,
|
|
709
|
+
consumption_energy_buildings.building_label,
|
|
710
|
+
consumption_energy_buildings.current_note,
|
|
711
|
+
consumption_energy_buildings.main_use,
|
|
712
|
+
consumption_energy_buildings.secondary_use,
|
|
713
|
+
consumption_energy_buildings.year_of_construction,
|
|
714
|
+
consumption_energy_buildings.method_of_protection,
|
|
715
|
+
consumption_energy_buildings.built_up_area,
|
|
716
|
+
consumption_energy_buildings.heated_bulding_volume,
|
|
717
|
+
consumption_energy_buildings.students_count,
|
|
718
|
+
consumption_energy_buildings.employees_count,
|
|
719
|
+
consumption_energy_buildings.classrooms_count,
|
|
720
|
+
consumption_energy_buildings.beds_count,
|
|
721
|
+
consumption_energy_buildings.eno_id,
|
|
722
|
+
consumption_energy_buildings.csu_code,
|
|
723
|
+
consumption_energy_buildings.ku_code,
|
|
724
|
+
consumption_energy_buildings.allotment_number,
|
|
725
|
+
consumption_energy_buildings.registration_unit,
|
|
726
|
+
consumption_energy_buildings.gas_consumption_normatives,
|
|
727
|
+
consumption_energy_buildings.heat_consumption_normatives,
|
|
728
|
+
consumption_energy_buildings.water_consumption_normatives,
|
|
729
|
+
consumption_energy_buildings.electricity_consumption_normatives_per_person,
|
|
730
|
+
consumption_energy_buildings.electricity_consumption_normatives,
|
|
731
|
+
consumption_energy_buildings.energetic_management,
|
|
732
|
+
consumption_energy_buildings.opening_hours,
|
|
733
|
+
consumption_energy_buildings.weekend_opening_hours,
|
|
734
|
+
consumption_energy_buildings.latitude,
|
|
735
|
+
consumption_energy_buildings.longitude,
|
|
736
|
+
public.st_setsrid(public.st_point(consumption_energy_buildings.longitude::double precision, consumption_energy_buildings.latitude::double precision), 4326) AS geom,
|
|
737
|
+
consumption_energy_buildings.address_street,
|
|
738
|
+
consumption_energy_buildings.address_house_number,
|
|
739
|
+
consumption_energy_buildings.address_city,
|
|
740
|
+
citydistricts.district_name,
|
|
741
|
+
citydistricts.geom AS district_geom,
|
|
742
|
+
consumption_energy_buildings.address_country,
|
|
743
|
+
consumption_energy_buildings.address_mail,
|
|
744
|
+
consumption_energy_buildings.address_phone,
|
|
745
|
+
consumption_energy_buildings.address_web_address,
|
|
746
|
+
consumption_energy_buildings.penb_penbnumber,
|
|
747
|
+
consumption_energy_buildings.penb_issue_date,
|
|
748
|
+
consumption_energy_buildings.penb_total_building_envelope_area,
|
|
749
|
+
consumption_energy_buildings.penb_volume_factor_of_avshape,
|
|
750
|
+
consumption_energy_buildings.penb_total_energy_reference_area,
|
|
751
|
+
consumption_energy_buildings.penb_total_provided_energy,
|
|
752
|
+
consumption_energy_buildings.penb_total_provided_energy_category,
|
|
753
|
+
consumption_energy_buildings.penb_primary_non_renewable_energy,
|
|
754
|
+
consumption_energy_buildings.penb_primary_non_renewable_energy_category,
|
|
755
|
+
consumption_energy_buildings.penb_building_envelope,
|
|
756
|
+
consumption_energy_buildings.penb_building_envelope_category,
|
|
757
|
+
consumption_energy_buildings.penb_heating,
|
|
758
|
+
consumption_energy_buildings.penb_heating_category,
|
|
759
|
+
consumption_energy_buildings.penb_cooling,
|
|
760
|
+
consumption_energy_buildings.penb_cooling_category,
|
|
761
|
+
consumption_energy_buildings.penb_ventilation,
|
|
762
|
+
consumption_energy_buildings.penb_ventilation_category,
|
|
763
|
+
consumption_energy_buildings.penb_humidity_adjustment,
|
|
764
|
+
consumption_energy_buildings.penb_humidity_adjustment_category,
|
|
765
|
+
consumption_energy_buildings.penb_warm_water,
|
|
766
|
+
consumption_energy_buildings.penb_warm_water_category,
|
|
767
|
+
consumption_energy_buildings.penb_lighting,
|
|
768
|
+
consumption_energy_buildings.penb_lighting_category,
|
|
769
|
+
consumption_energy_buildings.energy_audits_energy_audit,
|
|
770
|
+
consumption_energy_buildings.energy_audits_earegistration_number,
|
|
771
|
+
consumption_energy_buildings.energy_audits_created_at,
|
|
772
|
+
consumption_energy_buildings.building_envelope_side_wall_prevailing_construction,
|
|
773
|
+
consumption_energy_buildings.building_envelope_side_wall_area,
|
|
774
|
+
consumption_energy_buildings.building_envelope_side_wall_heat_insulation,
|
|
775
|
+
consumption_energy_buildings.building_envelope_side_wall_year_of_adjustment,
|
|
776
|
+
consumption_energy_buildings.building_envelope_side_wall_technical_condition,
|
|
777
|
+
consumption_energy_buildings.building_envelope_filling_of_hole_construction,
|
|
778
|
+
consumption_energy_buildings.building_envelope_filling_of_hole_area,
|
|
779
|
+
consumption_energy_buildings.building_envelope_filling_of_hole_year_of_adjustment,
|
|
780
|
+
consumption_energy_buildings.building_envelope_filling_of_hole_technical_condition,
|
|
781
|
+
consumption_energy_buildings.building_envelope_roof_construction,
|
|
782
|
+
consumption_energy_buildings.building_envelope_roof_area,
|
|
783
|
+
consumption_energy_buildings.building_envelope_roof_thermal_insulation,
|
|
784
|
+
consumption_energy_buildings.building_envelope_roof_year_of_adjustment,
|
|
785
|
+
consumption_energy_buildings.building_envelope_roof_technical_condition,
|
|
786
|
+
consumption_energy_buildings.building_envelope_floor_of_the_lowest_heated_floor_construction,
|
|
787
|
+
consumption_energy_buildings.building_envelope_floor_of_the_lowest_heated_floor_area,
|
|
788
|
+
consumption_energy_buildings.floor_of_the_lowest_heated_floor_thermal_insulation,
|
|
789
|
+
consumption_energy_buildings.building_envelope_floor_of_the_lowest_heated_floor_year_of_adju,
|
|
790
|
+
consumption_energy_buildings.floor_of_the_lowest_heated_floor_technical_condition,
|
|
791
|
+
consumption_energy_buildings.fuel_and_energy_coal,
|
|
792
|
+
consumption_energy_buildings.fuel_and_energy_gas,
|
|
793
|
+
consumption_energy_buildings.fuel_and_energy_electricity,
|
|
794
|
+
consumption_energy_buildings.fuel_and_energy_czt,
|
|
795
|
+
consumption_energy_buildings.fuel_and_energy_oze,
|
|
796
|
+
consumption_energy_buildings.fuel_and_energy_other,
|
|
797
|
+
consumption_energy_buildings.technical_equipment_heating_main_source_of_heat,
|
|
798
|
+
consumption_energy_buildings.technical_equipment_heating_heat_percentage,
|
|
799
|
+
consumption_energy_buildings.technical_equipment_heating_secondary_source_of_heat,
|
|
800
|
+
consumption_energy_buildings.technical_equipment_heating_heating_system,
|
|
801
|
+
consumption_energy_buildings.technical_equipment_heating_year,
|
|
802
|
+
consumption_energy_buildings.technical_equipment_heating_technical_condition,
|
|
803
|
+
consumption_energy_buildings.technical_equipment_cooling_cooling_system,
|
|
804
|
+
consumption_energy_buildings.technical_equipment_cooling_cooling_area_percentage,
|
|
805
|
+
consumption_energy_buildings.technical_equipment_cooling_year,
|
|
806
|
+
consumption_energy_buildings.technical_equipment_cooling_technical_condition,
|
|
807
|
+
consumption_energy_buildings.technical_equipment_ventilation_ventilation,
|
|
808
|
+
consumption_energy_buildings.technical_equipment_ventilation_year,
|
|
809
|
+
consumption_energy_buildings.technical_equipment_ventilation_technical_condition,
|
|
810
|
+
consumption_energy_buildings.technical_equipment_humidity_adjustment_humidity_adjustment,
|
|
811
|
+
consumption_energy_buildings.technical_equipment_humidity_adjustment_year,
|
|
812
|
+
consumption_energy_buildings.technical_equipment_humidity_adjustment_technical_condition,
|
|
813
|
+
consumption_energy_buildings.technical_equipment_hot_water_predominant_way_of_heating_tv,
|
|
814
|
+
consumption_energy_buildings.technical_equipment_hot_water_hot_water_source,
|
|
815
|
+
consumption_energy_buildings.technical_equipment_hot_water_year,
|
|
816
|
+
consumption_energy_buildings.technical_equipment_hot_water_technical_condition,
|
|
817
|
+
consumption_energy_buildings.technical_equipment_lighting_lighting,
|
|
818
|
+
consumption_energy_buildings.technical_equipment_lighting_year,
|
|
819
|
+
consumption_energy_buildings.technical_equipment_lighting_technical_condition,
|
|
820
|
+
consumption_energy_buildings.technical_equipment_lighting_other_technological_elements,
|
|
821
|
+
consumption_energy_buildings.technical_equipment_lighting_measurement_method,
|
|
822
|
+
consumption_energy_buildings.oze_energy_production_solar_energy_photovoltaic,
|
|
823
|
+
consumption_energy_buildings.oze_energy_production_solar_energy_photothermal,
|
|
824
|
+
consumption_energy_buildings.oze_energy_production_integrated_turbines_wind_energy,
|
|
825
|
+
consumption_energy_buildings.oze_energy_production_heat_pump,
|
|
826
|
+
consumption_energy_buildings.waste_and_emissions_solid_waste_production,
|
|
827
|
+
consumption_energy_buildings.waste_and_emissions_tied_co2_emissions,
|
|
828
|
+
consumption_energy_buildings.waste_and_emissions_sox_emissions,
|
|
829
|
+
consumption_energy_buildings.waste_and_emissions_operating_co_2emissions,
|
|
830
|
+
consumption_energy_buildings.link
|
|
831
|
+
FROM consumption_energy_buildings
|
|
832
|
+
JOIN common.citydistricts ON public.st_within(public.st_setsrid(public.st_point(consumption_energy_buildings.longitude::double precision, consumption_energy_buildings.latitude::double precision), 4326), citydistricts.geom)
|
|
833
|
+
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])) AND consumption_energy_buildings.longitude::text <> ''::text AND consumption_energy_buildings.latitude::text <> ''::text;
|
|
834
|
+
|
|
835
|
+
CREATE OR REPLACE VIEW v_consumption_energy_buildings_mimo_prahu
|
|
836
|
+
AS SELECT v_consumption_energy_buildings_real.id,
|
|
837
|
+
v_consumption_energy_buildings_real.building_name,
|
|
838
|
+
v_consumption_energy_buildings_real.description,
|
|
839
|
+
v_consumption_energy_buildings_real.building_address_code,
|
|
840
|
+
v_consumption_energy_buildings_real.building_label,
|
|
841
|
+
v_consumption_energy_buildings_real.current_note,
|
|
842
|
+
v_consumption_energy_buildings_real.main_use,
|
|
843
|
+
v_consumption_energy_buildings_real.secondary_use,
|
|
844
|
+
v_consumption_energy_buildings_real.year_of_construction,
|
|
845
|
+
v_consumption_energy_buildings_real.method_of_protection,
|
|
846
|
+
v_consumption_energy_buildings_real.built_up_area,
|
|
847
|
+
v_consumption_energy_buildings_real.heated_bulding_volume,
|
|
848
|
+
v_consumption_energy_buildings_real.students_count,
|
|
849
|
+
v_consumption_energy_buildings_real.employees_count,
|
|
850
|
+
v_consumption_energy_buildings_real.classrooms_count,
|
|
851
|
+
v_consumption_energy_buildings_real.beds_count,
|
|
852
|
+
v_consumption_energy_buildings_real.eno_id,
|
|
853
|
+
v_consumption_energy_buildings_real.csu_code,
|
|
854
|
+
v_consumption_energy_buildings_real.ku_code,
|
|
855
|
+
v_consumption_energy_buildings_real.allotment_number,
|
|
856
|
+
v_consumption_energy_buildings_real.registration_unit,
|
|
857
|
+
v_consumption_energy_buildings_real.gas_consumption_normatives,
|
|
858
|
+
v_consumption_energy_buildings_real.heat_consumption_normatives,
|
|
859
|
+
v_consumption_energy_buildings_real.water_consumption_normatives,
|
|
860
|
+
v_consumption_energy_buildings_real.electricity_consumption_normatives_per_person,
|
|
861
|
+
v_consumption_energy_buildings_real.electricity_consumption_normatives,
|
|
862
|
+
v_consumption_energy_buildings_real.energetic_management,
|
|
863
|
+
v_consumption_energy_buildings_real.opening_hours,
|
|
864
|
+
v_consumption_energy_buildings_real.weekend_opening_hours,
|
|
865
|
+
v_consumption_energy_buildings_real.latitude,
|
|
866
|
+
v_consumption_energy_buildings_real.longitude,
|
|
867
|
+
v_consumption_energy_buildings_real.address_street,
|
|
868
|
+
v_consumption_energy_buildings_real.address_house_number,
|
|
869
|
+
v_consumption_energy_buildings_real.address_city,
|
|
870
|
+
v_consumption_energy_buildings_real.address_country,
|
|
871
|
+
v_consumption_energy_buildings_real.address_mail,
|
|
872
|
+
v_consumption_energy_buildings_real.address_phone,
|
|
873
|
+
v_consumption_energy_buildings_real.address_web_address,
|
|
874
|
+
v_consumption_energy_buildings_real.penb_penbnumber,
|
|
875
|
+
v_consumption_energy_buildings_real.penb_issue_date,
|
|
876
|
+
v_consumption_energy_buildings_real.penb_total_building_envelope_area,
|
|
877
|
+
v_consumption_energy_buildings_real.penb_volume_factor_of_avshape,
|
|
878
|
+
v_consumption_energy_buildings_real.penb_total_energy_reference_area,
|
|
879
|
+
v_consumption_energy_buildings_real.penb_total_provided_energy,
|
|
880
|
+
v_consumption_energy_buildings_real.penb_total_provided_energy_category,
|
|
881
|
+
v_consumption_energy_buildings_real.penb_primary_non_renewable_energy,
|
|
882
|
+
v_consumption_energy_buildings_real.penb_primary_non_renewable_energy_category,
|
|
883
|
+
v_consumption_energy_buildings_real.penb_building_envelope,
|
|
884
|
+
v_consumption_energy_buildings_real.penb_building_envelope_category,
|
|
885
|
+
v_consumption_energy_buildings_real.penb_heating,
|
|
886
|
+
v_consumption_energy_buildings_real.penb_heating_category,
|
|
887
|
+
v_consumption_energy_buildings_real.penb_cooling,
|
|
888
|
+
v_consumption_energy_buildings_real.penb_cooling_category,
|
|
889
|
+
v_consumption_energy_buildings_real.penb_ventilation,
|
|
890
|
+
v_consumption_energy_buildings_real.penb_ventilation_category,
|
|
891
|
+
v_consumption_energy_buildings_real.penb_humidity_adjustment,
|
|
892
|
+
v_consumption_energy_buildings_real.penb_humidity_adjustment_category,
|
|
893
|
+
v_consumption_energy_buildings_real.penb_warm_water,
|
|
894
|
+
v_consumption_energy_buildings_real.penb_warm_water_category,
|
|
895
|
+
v_consumption_energy_buildings_real.penb_lighting,
|
|
896
|
+
v_consumption_energy_buildings_real.penb_lighting_category,
|
|
897
|
+
v_consumption_energy_buildings_real.energy_audits_energy_audit,
|
|
898
|
+
v_consumption_energy_buildings_real.energy_audits_earegistration_number,
|
|
899
|
+
v_consumption_energy_buildings_real.energy_audits_created_at,
|
|
900
|
+
v_consumption_energy_buildings_real.building_envelope_side_wall_prevailing_construction,
|
|
901
|
+
v_consumption_energy_buildings_real.building_envelope_side_wall_area,
|
|
902
|
+
v_consumption_energy_buildings_real.building_envelope_side_wall_heat_insulation,
|
|
903
|
+
v_consumption_energy_buildings_real.building_envelope_side_wall_year_of_adjustment,
|
|
904
|
+
v_consumption_energy_buildings_real.building_envelope_side_wall_technical_condition,
|
|
905
|
+
v_consumption_energy_buildings_real.building_envelope_filling_of_hole_construction,
|
|
906
|
+
v_consumption_energy_buildings_real.building_envelope_filling_of_hole_area,
|
|
907
|
+
v_consumption_energy_buildings_real.building_envelope_filling_of_hole_year_of_adjustment,
|
|
908
|
+
v_consumption_energy_buildings_real.building_envelope_filling_of_hole_technical_condition,
|
|
909
|
+
v_consumption_energy_buildings_real.building_envelope_roof_construction,
|
|
910
|
+
v_consumption_energy_buildings_real.building_envelope_roof_area,
|
|
911
|
+
v_consumption_energy_buildings_real.building_envelope_roof_thermal_insulation,
|
|
912
|
+
v_consumption_energy_buildings_real.building_envelope_roof_year_of_adjustment,
|
|
913
|
+
v_consumption_energy_buildings_real.building_envelope_roof_technical_condition,
|
|
914
|
+
v_consumption_energy_buildings_real.building_envelope_floor_of_the_lowest_heated_floor_construction,
|
|
915
|
+
v_consumption_energy_buildings_real.building_envelope_floor_of_the_lowest_heated_floor_area,
|
|
916
|
+
v_consumption_energy_buildings_real.floor_of_the_lowest_heated_floor_thermal_insulation,
|
|
917
|
+
v_consumption_energy_buildings_real.building_envelope_floor_of_the_lowest_heated_floor_year_of_adju,
|
|
918
|
+
v_consumption_energy_buildings_real.floor_of_the_lowest_heated_floor_technical_condition,
|
|
919
|
+
v_consumption_energy_buildings_real.fuel_and_energy_coal,
|
|
920
|
+
v_consumption_energy_buildings_real.fuel_and_energy_gas,
|
|
921
|
+
v_consumption_energy_buildings_real.fuel_and_energy_electricity,
|
|
922
|
+
v_consumption_energy_buildings_real.fuel_and_energy_czt,
|
|
923
|
+
v_consumption_energy_buildings_real.fuel_and_energy_oze,
|
|
924
|
+
v_consumption_energy_buildings_real.fuel_and_energy_other,
|
|
925
|
+
v_consumption_energy_buildings_real.technical_equipment_heating_main_source_of_heat,
|
|
926
|
+
v_consumption_energy_buildings_real.technical_equipment_heating_heat_percentage,
|
|
927
|
+
v_consumption_energy_buildings_real.technical_equipment_heating_secondary_source_of_heat,
|
|
928
|
+
v_consumption_energy_buildings_real.technical_equipment_heating_heating_system,
|
|
929
|
+
v_consumption_energy_buildings_real.technical_equipment_heating_year,
|
|
930
|
+
v_consumption_energy_buildings_real.technical_equipment_heating_technical_condition,
|
|
931
|
+
v_consumption_energy_buildings_real.technical_equipment_cooling_cooling_system,
|
|
932
|
+
v_consumption_energy_buildings_real.technical_equipment_cooling_cooling_area_percentage,
|
|
933
|
+
v_consumption_energy_buildings_real.technical_equipment_cooling_year,
|
|
934
|
+
v_consumption_energy_buildings_real.technical_equipment_cooling_technical_condition,
|
|
935
|
+
v_consumption_energy_buildings_real.technical_equipment_ventilation_ventilation,
|
|
936
|
+
v_consumption_energy_buildings_real.technical_equipment_ventilation_year,
|
|
937
|
+
v_consumption_energy_buildings_real.technical_equipment_ventilation_technical_condition,
|
|
938
|
+
v_consumption_energy_buildings_real.technical_equipment_humidity_adjustment_humidity_adjustment,
|
|
939
|
+
v_consumption_energy_buildings_real.technical_equipment_humidity_adjustment_year,
|
|
940
|
+
v_consumption_energy_buildings_real.technical_equipment_humidity_adjustment_technical_condition,
|
|
941
|
+
v_consumption_energy_buildings_real.technical_equipment_hot_water_predominant_way_of_heating_tv,
|
|
942
|
+
v_consumption_energy_buildings_real.technical_equipment_hot_water_hot_water_source,
|
|
943
|
+
v_consumption_energy_buildings_real.technical_equipment_hot_water_year,
|
|
944
|
+
v_consumption_energy_buildings_real.technical_equipment_hot_water_technical_condition,
|
|
945
|
+
v_consumption_energy_buildings_real.technical_equipment_lighting_lighting,
|
|
946
|
+
v_consumption_energy_buildings_real.technical_equipment_lighting_year,
|
|
947
|
+
v_consumption_energy_buildings_real.technical_equipment_lighting_technical_condition,
|
|
948
|
+
v_consumption_energy_buildings_real.technical_equipment_lighting_other_technological_elements,
|
|
949
|
+
v_consumption_energy_buildings_real.technical_equipment_lighting_measurement_method,
|
|
950
|
+
v_consumption_energy_buildings_real.oze_energy_production_solar_energy_photovoltaic,
|
|
951
|
+
v_consumption_energy_buildings_real.oze_energy_production_solar_energy_photothermal,
|
|
952
|
+
v_consumption_energy_buildings_real.oze_energy_production_integrated_turbines_wind_energy,
|
|
953
|
+
v_consumption_energy_buildings_real.oze_energy_production_heat_pump,
|
|
954
|
+
v_consumption_energy_buildings_real.waste_and_emissions_solid_waste_production,
|
|
955
|
+
v_consumption_energy_buildings_real.waste_and_emissions_tied_co2_emissions,
|
|
956
|
+
v_consumption_energy_buildings_real.waste_and_emissions_sox_emissions,
|
|
957
|
+
v_consumption_energy_buildings_real.waste_and_emissions_operating_co_2emissions,
|
|
958
|
+
v_consumption_energy_buildings_real.link
|
|
959
|
+
FROM v_consumption_energy_buildings_real
|
|
960
|
+
WHERE NOT (v_consumption_energy_buildings_real.building_name::text IN ( SELECT v_consumption_energy_buildings_real_mc.building_name
|
|
961
|
+
FROM v_consumption_energy_buildings_real_mc));
|
|
962
|
+
|
|
963
|
+
CREATE OR REPLACE VIEW v_consumption_energy_buildings_real_mc_nogeom
|
|
964
|
+
AS SELECT v_consumption_energy_buildings_real_mc.id,
|
|
965
|
+
v_consumption_energy_buildings_real_mc.building_name,
|
|
966
|
+
v_consumption_energy_buildings_real_mc.description,
|
|
967
|
+
v_consumption_energy_buildings_real_mc.building_address_code,
|
|
968
|
+
v_consumption_energy_buildings_real_mc.building_label,
|
|
969
|
+
v_consumption_energy_buildings_real_mc.current_note,
|
|
970
|
+
v_consumption_energy_buildings_real_mc.main_use,
|
|
971
|
+
v_consumption_energy_buildings_real_mc.secondary_use,
|
|
972
|
+
v_consumption_energy_buildings_real_mc.year_of_construction,
|
|
973
|
+
v_consumption_energy_buildings_real_mc.method_of_protection,
|
|
974
|
+
v_consumption_energy_buildings_real_mc.built_up_area,
|
|
975
|
+
v_consumption_energy_buildings_real_mc.heated_bulding_volume,
|
|
976
|
+
v_consumption_energy_buildings_real_mc.students_count,
|
|
977
|
+
v_consumption_energy_buildings_real_mc.employees_count,
|
|
978
|
+
v_consumption_energy_buildings_real_mc.classrooms_count,
|
|
979
|
+
v_consumption_energy_buildings_real_mc.beds_count,
|
|
980
|
+
v_consumption_energy_buildings_real_mc.eno_id,
|
|
981
|
+
v_consumption_energy_buildings_real_mc.csu_code,
|
|
982
|
+
v_consumption_energy_buildings_real_mc.ku_code,
|
|
983
|
+
v_consumption_energy_buildings_real_mc.allotment_number,
|
|
984
|
+
v_consumption_energy_buildings_real_mc.registration_unit,
|
|
985
|
+
v_consumption_energy_buildings_real_mc.gas_consumption_normatives,
|
|
986
|
+
v_consumption_energy_buildings_real_mc.heat_consumption_normatives,
|
|
987
|
+
v_consumption_energy_buildings_real_mc.water_consumption_normatives,
|
|
988
|
+
v_consumption_energy_buildings_real_mc.electricity_consumption_normatives_per_person,
|
|
989
|
+
v_consumption_energy_buildings_real_mc.electricity_consumption_normatives,
|
|
990
|
+
v_consumption_energy_buildings_real_mc.energetic_management,
|
|
991
|
+
v_consumption_energy_buildings_real_mc.opening_hours,
|
|
992
|
+
v_consumption_energy_buildings_real_mc.weekend_opening_hours,
|
|
993
|
+
v_consumption_energy_buildings_real_mc.latitude,
|
|
994
|
+
v_consumption_energy_buildings_real_mc.longitude,
|
|
995
|
+
v_consumption_energy_buildings_real_mc.address_street,
|
|
996
|
+
v_consumption_energy_buildings_real_mc.address_house_number,
|
|
997
|
+
v_consumption_energy_buildings_real_mc.address_city,
|
|
998
|
+
v_consumption_energy_buildings_real_mc.district_name,
|
|
999
|
+
v_consumption_energy_buildings_real_mc.address_country,
|
|
1000
|
+
v_consumption_energy_buildings_real_mc.address_mail,
|
|
1001
|
+
v_consumption_energy_buildings_real_mc.address_phone,
|
|
1002
|
+
v_consumption_energy_buildings_real_mc.address_web_address,
|
|
1003
|
+
v_consumption_energy_buildings_real_mc.penb_penbnumber,
|
|
1004
|
+
v_consumption_energy_buildings_real_mc.penb_issue_date,
|
|
1005
|
+
v_consumption_energy_buildings_real_mc.penb_total_building_envelope_area,
|
|
1006
|
+
v_consumption_energy_buildings_real_mc.penb_volume_factor_of_avshape,
|
|
1007
|
+
v_consumption_energy_buildings_real_mc.penb_total_energy_reference_area,
|
|
1008
|
+
v_consumption_energy_buildings_real_mc.penb_total_provided_energy,
|
|
1009
|
+
v_consumption_energy_buildings_real_mc.penb_total_provided_energy_category,
|
|
1010
|
+
v_consumption_energy_buildings_real_mc.penb_primary_non_renewable_energy,
|
|
1011
|
+
v_consumption_energy_buildings_real_mc.penb_primary_non_renewable_energy_category,
|
|
1012
|
+
v_consumption_energy_buildings_real_mc.penb_building_envelope,
|
|
1013
|
+
v_consumption_energy_buildings_real_mc.penb_building_envelope_category,
|
|
1014
|
+
v_consumption_energy_buildings_real_mc.penb_heating,
|
|
1015
|
+
v_consumption_energy_buildings_real_mc.penb_heating_category,
|
|
1016
|
+
v_consumption_energy_buildings_real_mc.penb_cooling,
|
|
1017
|
+
v_consumption_energy_buildings_real_mc.penb_cooling_category,
|
|
1018
|
+
v_consumption_energy_buildings_real_mc.penb_ventilation,
|
|
1019
|
+
v_consumption_energy_buildings_real_mc.penb_ventilation_category,
|
|
1020
|
+
v_consumption_energy_buildings_real_mc.penb_humidity_adjustment,
|
|
1021
|
+
v_consumption_energy_buildings_real_mc.penb_humidity_adjustment_category,
|
|
1022
|
+
v_consumption_energy_buildings_real_mc.penb_warm_water,
|
|
1023
|
+
v_consumption_energy_buildings_real_mc.penb_warm_water_category,
|
|
1024
|
+
v_consumption_energy_buildings_real_mc.penb_lighting,
|
|
1025
|
+
v_consumption_energy_buildings_real_mc.penb_lighting_category,
|
|
1026
|
+
v_consumption_energy_buildings_real_mc.energy_audits_energy_audit,
|
|
1027
|
+
v_consumption_energy_buildings_real_mc.energy_audits_earegistration_number,
|
|
1028
|
+
v_consumption_energy_buildings_real_mc.energy_audits_created_at,
|
|
1029
|
+
v_consumption_energy_buildings_real_mc.building_envelope_side_wall_prevailing_construction,
|
|
1030
|
+
v_consumption_energy_buildings_real_mc.building_envelope_side_wall_area,
|
|
1031
|
+
v_consumption_energy_buildings_real_mc.building_envelope_side_wall_heat_insulation,
|
|
1032
|
+
v_consumption_energy_buildings_real_mc.building_envelope_side_wall_year_of_adjustment,
|
|
1033
|
+
v_consumption_energy_buildings_real_mc.building_envelope_side_wall_technical_condition,
|
|
1034
|
+
v_consumption_energy_buildings_real_mc.building_envelope_filling_of_hole_construction,
|
|
1035
|
+
v_consumption_energy_buildings_real_mc.building_envelope_filling_of_hole_area,
|
|
1036
|
+
v_consumption_energy_buildings_real_mc.building_envelope_filling_of_hole_year_of_adjustment,
|
|
1037
|
+
v_consumption_energy_buildings_real_mc.building_envelope_filling_of_hole_technical_condition,
|
|
1038
|
+
v_consumption_energy_buildings_real_mc.building_envelope_roof_construction,
|
|
1039
|
+
v_consumption_energy_buildings_real_mc.building_envelope_roof_area,
|
|
1040
|
+
v_consumption_energy_buildings_real_mc.building_envelope_roof_thermal_insulation,
|
|
1041
|
+
v_consumption_energy_buildings_real_mc.building_envelope_roof_year_of_adjustment,
|
|
1042
|
+
v_consumption_energy_buildings_real_mc.building_envelope_roof_technical_condition,
|
|
1043
|
+
v_consumption_energy_buildings_real_mc.building_envelope_floor_of_the_lowest_heated_floor_construction,
|
|
1044
|
+
v_consumption_energy_buildings_real_mc.building_envelope_floor_of_the_lowest_heated_floor_area,
|
|
1045
|
+
v_consumption_energy_buildings_real_mc.floor_of_the_lowest_heated_floor_thermal_insulation,
|
|
1046
|
+
v_consumption_energy_buildings_real_mc.building_envelope_floor_of_the_lowest_heated_floor_year_of_adju,
|
|
1047
|
+
v_consumption_energy_buildings_real_mc.floor_of_the_lowest_heated_floor_technical_condition,
|
|
1048
|
+
v_consumption_energy_buildings_real_mc.fuel_and_energy_coal,
|
|
1049
|
+
v_consumption_energy_buildings_real_mc.fuel_and_energy_gas,
|
|
1050
|
+
v_consumption_energy_buildings_real_mc.fuel_and_energy_electricity,
|
|
1051
|
+
v_consumption_energy_buildings_real_mc.fuel_and_energy_czt,
|
|
1052
|
+
v_consumption_energy_buildings_real_mc.fuel_and_energy_oze,
|
|
1053
|
+
v_consumption_energy_buildings_real_mc.fuel_and_energy_other,
|
|
1054
|
+
v_consumption_energy_buildings_real_mc.technical_equipment_heating_main_source_of_heat,
|
|
1055
|
+
v_consumption_energy_buildings_real_mc.technical_equipment_heating_heat_percentage,
|
|
1056
|
+
v_consumption_energy_buildings_real_mc.technical_equipment_heating_secondary_source_of_heat,
|
|
1057
|
+
v_consumption_energy_buildings_real_mc.technical_equipment_heating_heating_system,
|
|
1058
|
+
v_consumption_energy_buildings_real_mc.technical_equipment_heating_year,
|
|
1059
|
+
v_consumption_energy_buildings_real_mc.technical_equipment_heating_technical_condition,
|
|
1060
|
+
v_consumption_energy_buildings_real_mc.technical_equipment_cooling_cooling_system,
|
|
1061
|
+
v_consumption_energy_buildings_real_mc.technical_equipment_cooling_cooling_area_percentage,
|
|
1062
|
+
v_consumption_energy_buildings_real_mc.technical_equipment_cooling_year,
|
|
1063
|
+
v_consumption_energy_buildings_real_mc.technical_equipment_cooling_technical_condition,
|
|
1064
|
+
v_consumption_energy_buildings_real_mc.technical_equipment_ventilation_ventilation,
|
|
1065
|
+
v_consumption_energy_buildings_real_mc.technical_equipment_ventilation_year,
|
|
1066
|
+
v_consumption_energy_buildings_real_mc.technical_equipment_ventilation_technical_condition,
|
|
1067
|
+
v_consumption_energy_buildings_real_mc.technical_equipment_humidity_adjustment_humidity_adjustment,
|
|
1068
|
+
v_consumption_energy_buildings_real_mc.technical_equipment_humidity_adjustment_year,
|
|
1069
|
+
v_consumption_energy_buildings_real_mc.technical_equipment_humidity_adjustment_technical_condition,
|
|
1070
|
+
v_consumption_energy_buildings_real_mc.technical_equipment_hot_water_predominant_way_of_heating_tv,
|
|
1071
|
+
v_consumption_energy_buildings_real_mc.technical_equipment_hot_water_hot_water_source,
|
|
1072
|
+
v_consumption_energy_buildings_real_mc.technical_equipment_hot_water_year,
|
|
1073
|
+
v_consumption_energy_buildings_real_mc.technical_equipment_hot_water_technical_condition,
|
|
1074
|
+
v_consumption_energy_buildings_real_mc.technical_equipment_lighting_lighting,
|
|
1075
|
+
v_consumption_energy_buildings_real_mc.technical_equipment_lighting_year,
|
|
1076
|
+
v_consumption_energy_buildings_real_mc.technical_equipment_lighting_technical_condition,
|
|
1077
|
+
v_consumption_energy_buildings_real_mc.technical_equipment_lighting_other_technological_elements,
|
|
1078
|
+
v_consumption_energy_buildings_real_mc.technical_equipment_lighting_measurement_method,
|
|
1079
|
+
v_consumption_energy_buildings_real_mc.oze_energy_production_solar_energy_photovoltaic,
|
|
1080
|
+
v_consumption_energy_buildings_real_mc.oze_energy_production_solar_energy_photothermal,
|
|
1081
|
+
v_consumption_energy_buildings_real_mc.oze_energy_production_integrated_turbines_wind_energy,
|
|
1082
|
+
v_consumption_energy_buildings_real_mc.oze_energy_production_heat_pump,
|
|
1083
|
+
v_consumption_energy_buildings_real_mc.waste_and_emissions_solid_waste_production,
|
|
1084
|
+
v_consumption_energy_buildings_real_mc.waste_and_emissions_tied_co2_emissions,
|
|
1085
|
+
v_consumption_energy_buildings_real_mc.waste_and_emissions_sox_emissions,
|
|
1086
|
+
v_consumption_energy_buildings_real_mc.waste_and_emissions_operating_co_2emissions,
|
|
1087
|
+
v_consumption_energy_buildings_real_mc.link
|
|
1088
|
+
FROM v_consumption_energy_buildings_real_mc;
|
|
1089
|
+
|
|
1090
|
+
CREATE OR REPLACE VIEW v_consumption_energy_consumption
|
|
1091
|
+
AS SELECT "substring"(consumption_energy_consumption.addr::text, 2, "position"(btrim(consumption_energy_consumption.addr::text, '/'::text), '/'::text) - 1)::character varying(255) AS building_address_code,
|
|
1092
|
+
"right"(consumption_energy_consumption.addr::text, char_length(consumption_energy_consumption.addr::text) - "position"(btrim(consumption_energy_consumption.addr::text, '/'::text), '/'::text) - 1)::character varying(255) AS devicetype,
|
|
1093
|
+
consumption_energy_consumption.time_utc,
|
|
1094
|
+
consumption_energy_consumption.value,
|
|
1095
|
+
consumption_energy_consumption.addr,
|
|
1096
|
+
consumption_energy_consumption.var,
|
|
1097
|
+
consumption_energy_consumption.type,
|
|
1098
|
+
consumption_energy_consumption.commodity,
|
|
1099
|
+
consumption_energy_consumption.unit,
|
|
1100
|
+
consumption_energy_consumption.meter
|
|
1101
|
+
FROM consumption_energy_consumption
|
|
1102
|
+
UNION ALL
|
|
1103
|
+
SELECT ((( SELECT btrim(consumption_energy_buildings.building_address_code::text) AS btrim
|
|
1104
|
+
FROM consumption_energy_buildings
|
|
1105
|
+
WHERE consumption_energy_buildings.building_name::text = 'Vrtbovský palác'::text)))::character varying(255) AS building_address_code,
|
|
1106
|
+
mt.met_nazev::character varying(255) AS devicetype,
|
|
1107
|
+
to_timestamp((m.time_measurement / 1000)::double precision)::timestamp without time zone AS time_utc,
|
|
1108
|
+
m.value::numeric(30,15) AS value,
|
|
1109
|
+
NULL::character varying(255) AS addr,
|
|
1110
|
+
me.var_id::character varying(255) AS var,
|
|
1111
|
+
NULL::character varying(255) AS type,
|
|
1112
|
+
NULL::character varying(255) AS commodity,
|
|
1113
|
+
NULL::character varying(255) AS unit,
|
|
1114
|
+
NULL::character varying(255) AS meter
|
|
1115
|
+
FROM vpalac_measurement m
|
|
1116
|
+
JOIN vpalac_measuring_equipment me ON me.var_id = m.var_id
|
|
1117
|
+
JOIN vpalac_meter_type mt ON mt.met_id = me.met_id;
|
|
1118
|
+
|
|
1119
|
+
|
|
1120
|
+
CREATE OR REPLACE VIEW v_consumption_energy_buildings_w_data
|
|
1121
|
+
AS SELECT consumption_energy_buildings.id,
|
|
1122
|
+
consumption_energy_buildings.building_name,
|
|
1123
|
+
consumption_energy_buildings.description,
|
|
1124
|
+
consumption_energy_buildings.building_address_code,
|
|
1125
|
+
consumption_energy_buildings.building_label,
|
|
1126
|
+
consumption_energy_buildings.current_note,
|
|
1127
|
+
consumption_energy_buildings.main_use,
|
|
1128
|
+
consumption_energy_buildings.secondary_use,
|
|
1129
|
+
consumption_energy_buildings.year_of_construction,
|
|
1130
|
+
consumption_energy_buildings.method_of_protection,
|
|
1131
|
+
consumption_energy_buildings.built_up_area,
|
|
1132
|
+
consumption_energy_buildings.heated_bulding_volume,
|
|
1133
|
+
consumption_energy_buildings.students_count,
|
|
1134
|
+
consumption_energy_buildings.employees_count,
|
|
1135
|
+
consumption_energy_buildings.classrooms_count,
|
|
1136
|
+
consumption_energy_buildings.beds_count,
|
|
1137
|
+
consumption_energy_buildings.eno_id,
|
|
1138
|
+
consumption_energy_buildings.csu_code,
|
|
1139
|
+
consumption_energy_buildings.ku_code,
|
|
1140
|
+
consumption_energy_buildings.allotment_number,
|
|
1141
|
+
consumption_energy_buildings.registration_unit,
|
|
1142
|
+
consumption_energy_buildings.gas_consumption_normatives,
|
|
1143
|
+
consumption_energy_buildings.heat_consumption_normatives,
|
|
1144
|
+
consumption_energy_buildings.water_consumption_normatives,
|
|
1145
|
+
consumption_energy_buildings.electricity_consumption_normatives_per_person,
|
|
1146
|
+
consumption_energy_buildings.electricity_consumption_normatives,
|
|
1147
|
+
consumption_energy_buildings.energetic_management,
|
|
1148
|
+
consumption_energy_buildings.opening_hours,
|
|
1149
|
+
consumption_energy_buildings.weekend_opening_hours,
|
|
1150
|
+
consumption_energy_buildings.latitude,
|
|
1151
|
+
consumption_energy_buildings.longitude,
|
|
1152
|
+
consumption_energy_buildings.address_street,
|
|
1153
|
+
consumption_energy_buildings.address_house_number,
|
|
1154
|
+
consumption_energy_buildings.address_city,
|
|
1155
|
+
consumption_energy_buildings.address_country,
|
|
1156
|
+
consumption_energy_buildings.address_mail,
|
|
1157
|
+
consumption_energy_buildings.address_phone,
|
|
1158
|
+
consumption_energy_buildings.address_web_address,
|
|
1159
|
+
consumption_energy_buildings.penb_penbnumber,
|
|
1160
|
+
consumption_energy_buildings.penb_issue_date,
|
|
1161
|
+
consumption_energy_buildings.penb_total_building_envelope_area,
|
|
1162
|
+
consumption_energy_buildings.penb_volume_factor_of_avshape,
|
|
1163
|
+
consumption_energy_buildings.penb_total_energy_reference_area,
|
|
1164
|
+
consumption_energy_buildings.penb_total_provided_energy,
|
|
1165
|
+
consumption_energy_buildings.penb_total_provided_energy_category,
|
|
1166
|
+
consumption_energy_buildings.penb_primary_non_renewable_energy,
|
|
1167
|
+
consumption_energy_buildings.penb_primary_non_renewable_energy_category,
|
|
1168
|
+
consumption_energy_buildings.penb_building_envelope,
|
|
1169
|
+
consumption_energy_buildings.penb_building_envelope_category,
|
|
1170
|
+
consumption_energy_buildings.penb_heating,
|
|
1171
|
+
consumption_energy_buildings.penb_heating_category,
|
|
1172
|
+
consumption_energy_buildings.penb_cooling,
|
|
1173
|
+
consumption_energy_buildings.penb_cooling_category,
|
|
1174
|
+
consumption_energy_buildings.penb_ventilation,
|
|
1175
|
+
consumption_energy_buildings.penb_ventilation_category,
|
|
1176
|
+
consumption_energy_buildings.penb_humidity_adjustment,
|
|
1177
|
+
consumption_energy_buildings.penb_humidity_adjustment_category,
|
|
1178
|
+
consumption_energy_buildings.penb_warm_water,
|
|
1179
|
+
consumption_energy_buildings.penb_warm_water_category,
|
|
1180
|
+
consumption_energy_buildings.penb_lighting,
|
|
1181
|
+
consumption_energy_buildings.penb_lighting_category,
|
|
1182
|
+
consumption_energy_buildings.energy_audits_energy_audit,
|
|
1183
|
+
consumption_energy_buildings.energy_audits_earegistration_number,
|
|
1184
|
+
consumption_energy_buildings.energy_audits_created_at,
|
|
1185
|
+
consumption_energy_buildings.building_envelope_side_wall_prevailing_construction,
|
|
1186
|
+
consumption_energy_buildings.building_envelope_side_wall_area,
|
|
1187
|
+
consumption_energy_buildings.building_envelope_side_wall_heat_insulation,
|
|
1188
|
+
consumption_energy_buildings.building_envelope_side_wall_year_of_adjustment,
|
|
1189
|
+
consumption_energy_buildings.building_envelope_side_wall_technical_condition,
|
|
1190
|
+
consumption_energy_buildings.building_envelope_filling_of_hole_construction,
|
|
1191
|
+
consumption_energy_buildings.building_envelope_filling_of_hole_area,
|
|
1192
|
+
consumption_energy_buildings.building_envelope_filling_of_hole_year_of_adjustment,
|
|
1193
|
+
consumption_energy_buildings.building_envelope_filling_of_hole_technical_condition,
|
|
1194
|
+
consumption_energy_buildings.building_envelope_roof_construction,
|
|
1195
|
+
consumption_energy_buildings.building_envelope_roof_area,
|
|
1196
|
+
consumption_energy_buildings.building_envelope_roof_thermal_insulation,
|
|
1197
|
+
consumption_energy_buildings.building_envelope_roof_year_of_adjustment,
|
|
1198
|
+
consumption_energy_buildings.building_envelope_roof_technical_condition,
|
|
1199
|
+
consumption_energy_buildings.building_envelope_floor_of_the_lowest_heated_floor_construction,
|
|
1200
|
+
consumption_energy_buildings.building_envelope_floor_of_the_lowest_heated_floor_area,
|
|
1201
|
+
consumption_energy_buildings.floor_of_the_lowest_heated_floor_thermal_insulation,
|
|
1202
|
+
consumption_energy_buildings.building_envelope_floor_of_the_lowest_heated_floor_year_of_adju,
|
|
1203
|
+
consumption_energy_buildings.floor_of_the_lowest_heated_floor_technical_condition,
|
|
1204
|
+
consumption_energy_buildings.fuel_and_energy_coal,
|
|
1205
|
+
consumption_energy_buildings.fuel_and_energy_gas,
|
|
1206
|
+
consumption_energy_buildings.fuel_and_energy_electricity,
|
|
1207
|
+
consumption_energy_buildings.fuel_and_energy_czt,
|
|
1208
|
+
consumption_energy_buildings.fuel_and_energy_oze,
|
|
1209
|
+
consumption_energy_buildings.fuel_and_energy_other,
|
|
1210
|
+
consumption_energy_buildings.technical_equipment_heating_main_source_of_heat,
|
|
1211
|
+
consumption_energy_buildings.technical_equipment_heating_heat_percentage,
|
|
1212
|
+
consumption_energy_buildings.technical_equipment_heating_secondary_source_of_heat,
|
|
1213
|
+
consumption_energy_buildings.technical_equipment_heating_heating_system,
|
|
1214
|
+
consumption_energy_buildings.technical_equipment_heating_year,
|
|
1215
|
+
consumption_energy_buildings.technical_equipment_heating_technical_condition,
|
|
1216
|
+
consumption_energy_buildings.technical_equipment_cooling_cooling_system,
|
|
1217
|
+
consumption_energy_buildings.technical_equipment_cooling_cooling_area_percentage,
|
|
1218
|
+
consumption_energy_buildings.technical_equipment_cooling_year,
|
|
1219
|
+
consumption_energy_buildings.technical_equipment_cooling_technical_condition,
|
|
1220
|
+
consumption_energy_buildings.technical_equipment_ventilation_ventilation,
|
|
1221
|
+
consumption_energy_buildings.technical_equipment_ventilation_year,
|
|
1222
|
+
consumption_energy_buildings.technical_equipment_ventilation_technical_condition,
|
|
1223
|
+
consumption_energy_buildings.technical_equipment_humidity_adjustment_humidity_adjustment,
|
|
1224
|
+
consumption_energy_buildings.technical_equipment_humidity_adjustment_year,
|
|
1225
|
+
consumption_energy_buildings.technical_equipment_humidity_adjustment_technical_condition,
|
|
1226
|
+
consumption_energy_buildings.technical_equipment_hot_water_predominant_way_of_heating_tv,
|
|
1227
|
+
consumption_energy_buildings.technical_equipment_hot_water_hot_water_source,
|
|
1228
|
+
consumption_energy_buildings.technical_equipment_hot_water_year,
|
|
1229
|
+
consumption_energy_buildings.technical_equipment_hot_water_technical_condition,
|
|
1230
|
+
consumption_energy_buildings.technical_equipment_lighting_lighting,
|
|
1231
|
+
consumption_energy_buildings.technical_equipment_lighting_year,
|
|
1232
|
+
consumption_energy_buildings.technical_equipment_lighting_technical_condition,
|
|
1233
|
+
consumption_energy_buildings.technical_equipment_lighting_other_technological_elements,
|
|
1234
|
+
consumption_energy_buildings.technical_equipment_lighting_measurement_method,
|
|
1235
|
+
consumption_energy_buildings.oze_energy_production_solar_energy_photovoltaic,
|
|
1236
|
+
consumption_energy_buildings.oze_energy_production_solar_energy_photothermal,
|
|
1237
|
+
consumption_energy_buildings.oze_energy_production_integrated_turbines_wind_energy,
|
|
1238
|
+
consumption_energy_buildings.oze_energy_production_heat_pump,
|
|
1239
|
+
consumption_energy_buildings.waste_and_emissions_solid_waste_production,
|
|
1240
|
+
consumption_energy_buildings.waste_and_emissions_tied_co2_emissions,
|
|
1241
|
+
consumption_energy_buildings.waste_and_emissions_sox_emissions,
|
|
1242
|
+
consumption_energy_buildings.waste_and_emissions_operating_co_2emissions,
|
|
1243
|
+
consumption_energy_buildings.link
|
|
1244
|
+
FROM consumption_energy_buildings
|
|
1245
|
+
WHERE (btrim(consumption_energy_buildings.building_address_code::text) IN ( SELECT DISTINCT v_consumption_energy_consumption.building_address_code
|
|
1246
|
+
FROM v_consumption_energy_consumption));
|
|
1247
|
+
|
|
1248
|
+
CREATE OR REPLACE VIEW v_consumption_vrtbovsky_palac
|
|
1249
|
+
AS WITH daily_status AS (
|
|
1250
|
+
SELECT date_part('year'::text, to_timestamp((m.time_measurement / 1000)::double precision)::timestamp without time zone) AS measure_year,
|
|
1251
|
+
date_part('month'::text, to_timestamp((m.time_measurement / 1000)::double precision)::timestamp without time zone) AS measure_month,
|
|
1252
|
+
me.me_id::text AS addr,
|
|
1253
|
+
m.var_id AS var,
|
|
1254
|
+
CASE
|
|
1255
|
+
WHEN mt.met_nazev::text = 'Senzor'::text THEN 'heat'::text
|
|
1256
|
+
WHEN mt.met_nazev::text = 'Elektroměr'::text THEN 'electricity'::text
|
|
1257
|
+
WHEN mt.met_nazev::text = 'Plynoměr'::text THEN 'gas'::text
|
|
1258
|
+
WHEN mt.met_nazev::text = 'Vodoměr'::text THEN 'water'::text
|
|
1259
|
+
ELSE NULL::text
|
|
1260
|
+
END AS commodity,
|
|
1261
|
+
NULL::text AS unit,
|
|
1262
|
+
CASE
|
|
1263
|
+
WHEN mt.met_nazev::text = 'Senzor'::text AND date_part('month'::text, to_timestamp((m.time_measurement / 1000)::double precision)::timestamp without time zone) = 12::double precision THEN 0::numeric
|
|
1264
|
+
ELSE min(m.value)
|
|
1265
|
+
END AS start_value,
|
|
1266
|
+
me.mis_nazev,
|
|
1267
|
+
date_trunc('month'::text, to_timestamp((m.time_measurement / 1000)::double precision)::timestamp without time zone) AS data_do
|
|
1268
|
+
FROM vpalac_measuring_equipment me
|
|
1269
|
+
JOIN vpalac_measurement m ON me.var_id = m.var_id
|
|
1270
|
+
JOIN vpalac_meter_type mt ON me.met_id = mt.met_id
|
|
1271
|
+
GROUP BY me.me_id, (date_part('year'::text, to_timestamp((m.time_measurement / 1000)::double precision)::timestamp without time zone)), (date_part('month'::text, to_timestamp((m.time_measurement / 1000)::double precision)::timestamp without time zone)), mt.met_nazev, m.var_id, me.mis_nazev, me.umisteni, (date_trunc('month'::text, to_timestamp((m.time_measurement / 1000)::double precision)::timestamp without time zone))
|
|
1272
|
+
)
|
|
1273
|
+
SELECT daily_status.measure_year,
|
|
1274
|
+
daily_status.measure_month,
|
|
1275
|
+
daily_status.addr,
|
|
1276
|
+
daily_status.var,
|
|
1277
|
+
daily_status.commodity,
|
|
1278
|
+
daily_status.unit,
|
|
1279
|
+
lead(daily_status.start_value) OVER (PARTITION BY daily_status.var ORDER BY daily_status.data_do) - daily_status.start_value AS consumption,
|
|
1280
|
+
daily_status.data_do
|
|
1281
|
+
FROM daily_status;
|
|
1282
|
+
|
|
1283
|
+
|
|
1284
|
+
CREATE OR REPLACE VIEW v_consumption_energy_consumption_month_p_f
|
|
1285
|
+
AS SELECT v_consumption_energy_consumption_month_ptv.rok,
|
|
1286
|
+
v_consumption_energy_consumption_month_ptv.mesic,
|
|
1287
|
+
v_consumption_energy_consumption_month_ptv.addr,
|
|
1288
|
+
v_consumption_energy_consumption_month_ptv.var,
|
|
1289
|
+
v_consumption_energy_consumption_month_ptv.commodity,
|
|
1290
|
+
v_consumption_energy_consumption_month_ptv.unit,
|
|
1291
|
+
v_consumption_energy_consumption_month_ptv.value,
|
|
1292
|
+
v_consumption_energy_consumption_month_ptv.data_do,
|
|
1293
|
+
v_consumption_energy_consumption_month_ptv.count,
|
|
1294
|
+
v_consumption_energy_consumption_month_ptv.previous_month_value,
|
|
1295
|
+
v_consumption_energy_consumption_month_ptv.mesicni_spotreba
|
|
1296
|
+
FROM v_consumption_energy_consumption_month_ptv
|
|
1297
|
+
WHERE v_consumption_energy_consumption_month_ptv.addr::text ~~ '%/PF%'::text AND v_consumption_energy_consumption_month_ptv.rok > 2018::double precision
|
|
1298
|
+
UNION
|
|
1299
|
+
SELECT v_consumption_vrtbovsky_palac.measure_year AS rok,
|
|
1300
|
+
v_consumption_vrtbovsky_palac.measure_month AS mesic,
|
|
1301
|
+
v_consumption_vrtbovsky_palac.addr::character varying(255) AS addr,
|
|
1302
|
+
v_consumption_vrtbovsky_palac.var::character varying(255) AS var,
|
|
1303
|
+
v_consumption_vrtbovsky_palac.commodity::character varying(255) AS commodity,
|
|
1304
|
+
v_consumption_vrtbovsky_palac.unit::character varying(255) AS unit,
|
|
1305
|
+
sum(v_consumption_vrtbovsky_palac.consumption) AS value,
|
|
1306
|
+
v_consumption_vrtbovsky_palac.data_do::date AS data_do,
|
|
1307
|
+
count(*) AS count,
|
|
1308
|
+
NULL::numeric AS previous_month_value,
|
|
1309
|
+
sum(v_consumption_vrtbovsky_palac.consumption) AS mesicni_spotreba
|
|
1310
|
+
FROM v_consumption_vrtbovsky_palac
|
|
1311
|
+
WHERE v_consumption_vrtbovsky_palac.commodity = 'gas'::text
|
|
1312
|
+
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;
|
|
1313
|
+
|
|
1314
|
+
|
|
1315
|
+
CREATE OR REPLACE VIEW v_consumption_energy_consumption_month_el_f
|
|
1316
|
+
AS SELECT date_part('year'::text, consumption_energy_consumption.time_utc) AS rok,
|
|
1317
|
+
date_part('month'::text, consumption_energy_consumption.time_utc) AS mesic,
|
|
1318
|
+
consumption_energy_consumption.addr,
|
|
1319
|
+
consumption_energy_consumption.var,
|
|
1320
|
+
consumption_energy_consumption.commodity,
|
|
1321
|
+
consumption_energy_consumption.unit,
|
|
1322
|
+
sum(consumption_energy_consumption.value::numeric(10,2)) / 4::numeric AS value,
|
|
1323
|
+
max(consumption_energy_consumption.time_utc::date) AS data_do,
|
|
1324
|
+
count(*) AS count
|
|
1325
|
+
FROM consumption_energy_consumption
|
|
1326
|
+
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
|
|
1327
|
+
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
|
|
1328
|
+
UNION
|
|
1329
|
+
SELECT v_consumption_vrtbovsky_palac.measure_year AS rok,
|
|
1330
|
+
v_consumption_vrtbovsky_palac.measure_month AS mesic,
|
|
1331
|
+
v_consumption_vrtbovsky_palac.addr::character varying(255) AS addr,
|
|
1332
|
+
v_consumption_vrtbovsky_palac.var::character varying(255) AS var,
|
|
1333
|
+
v_consumption_vrtbovsky_palac.commodity::character varying(255) AS commodity,
|
|
1334
|
+
v_consumption_vrtbovsky_palac.unit::character varying(255) AS unit,
|
|
1335
|
+
sum(v_consumption_vrtbovsky_palac.consumption) AS value,
|
|
1336
|
+
v_consumption_vrtbovsky_palac.data_do::date AS data_do,
|
|
1337
|
+
count(*) AS count
|
|
1338
|
+
FROM v_consumption_vrtbovsky_palac
|
|
1339
|
+
WHERE v_consumption_vrtbovsky_palac.commodity = 'electricity'::text
|
|
1340
|
+
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;
|
|
1341
|
+
|
|
1342
|
+
|
|
1343
|
+
CREATE OR REPLACE VIEW v_consumption_energy_consumption_month_v_f
|
|
1344
|
+
AS SELECT v_consumption_energy_consumption_month_ptv.rok,
|
|
1345
|
+
v_consumption_energy_consumption_month_ptv.mesic,
|
|
1346
|
+
v_consumption_energy_consumption_month_ptv.addr,
|
|
1347
|
+
v_consumption_energy_consumption_month_ptv.var,
|
|
1348
|
+
v_consumption_energy_consumption_month_ptv.commodity,
|
|
1349
|
+
v_consumption_energy_consumption_month_ptv.unit,
|
|
1350
|
+
v_consumption_energy_consumption_month_ptv.value,
|
|
1351
|
+
v_consumption_energy_consumption_month_ptv.data_do,
|
|
1352
|
+
v_consumption_energy_consumption_month_ptv.count,
|
|
1353
|
+
v_consumption_energy_consumption_month_ptv.previous_month_value,
|
|
1354
|
+
v_consumption_energy_consumption_month_ptv.mesicni_spotreba
|
|
1355
|
+
FROM v_consumption_energy_consumption_month_ptv
|
|
1356
|
+
WHERE v_consumption_energy_consumption_month_ptv.addr::text ~~ '%VF%'::text AND v_consumption_energy_consumption_month_ptv.rok > 2018::double precision
|
|
1357
|
+
UNION
|
|
1358
|
+
SELECT v_consumption_vrtbovsky_palac.measure_year AS rok,
|
|
1359
|
+
v_consumption_vrtbovsky_palac.measure_month AS mesic,
|
|
1360
|
+
v_consumption_vrtbovsky_palac.addr::character varying(255) AS addr,
|
|
1361
|
+
v_consumption_vrtbovsky_palac.var::character varying(255) AS var,
|
|
1362
|
+
v_consumption_vrtbovsky_palac.commodity::character varying(255) AS commodity,
|
|
1363
|
+
v_consumption_vrtbovsky_palac.unit::character varying(255) AS unit,
|
|
1364
|
+
sum(v_consumption_vrtbovsky_palac.consumption) AS value,
|
|
1365
|
+
v_consumption_vrtbovsky_palac.data_do::date AS data_do,
|
|
1366
|
+
count(*) AS count,
|
|
1367
|
+
NULL::numeric AS previous_month_value,
|
|
1368
|
+
sum(v_consumption_vrtbovsky_palac.consumption) AS mesicni_spotreba
|
|
1369
|
+
FROM v_consumption_vrtbovsky_palac
|
|
1370
|
+
WHERE v_consumption_vrtbovsky_palac.commodity = 'water'::text
|
|
1371
|
+
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;
|
|
1372
|
+
|
|
1373
|
+
CREATE OR REPLACE VIEW v_consumption_energy_devices_active
|
|
1374
|
+
AS SELECT consumption_energy_devices.id,
|
|
1375
|
+
consumption_energy_devices.addr,
|
|
1376
|
+
consumption_energy_devices.description,
|
|
1377
|
+
consumption_energy_devices.meter_number,
|
|
1378
|
+
consumption_energy_devices.meter_index,
|
|
1379
|
+
consumption_energy_devices.location_number,
|
|
1380
|
+
consumption_energy_devices.location_description,
|
|
1381
|
+
consumption_energy_devices.include_in_evaluation,
|
|
1382
|
+
consumption_energy_devices.meter_type,
|
|
1383
|
+
consumption_energy_devices.category,
|
|
1384
|
+
consumption_energy_devices.unit,
|
|
1385
|
+
consumption_energy_devices.replaced_meter_id,
|
|
1386
|
+
consumption_energy_devices.deleted,
|
|
1387
|
+
consumption_energy_devices.building_id
|
|
1388
|
+
FROM consumption_energy_devices
|
|
1389
|
+
WHERE NOT (consumption_energy_devices.id IN ( SELECT consumption_energy_devices_1.replaced_meter_id::integer AS replaced_meter_id
|
|
1390
|
+
FROM consumption_energy_devices consumption_energy_devices_1
|
|
1391
|
+
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
|
|
1392
|
+
UNION
|
|
1393
|
+
SELECT me.me_id AS id,
|
|
1394
|
+
me.me_id::character varying(255) AS addr,
|
|
1395
|
+
NULL::character varying(255) AS description,
|
|
1396
|
+
NULL::character varying(255) AS meter_number,
|
|
1397
|
+
NULL::character varying(255) AS meter_index,
|
|
1398
|
+
NULL::character varying(255) AS location_number,
|
|
1399
|
+
NULL::character varying(255) AS location_description,
|
|
1400
|
+
NULL::character varying(255) AS include_in_evaluation,
|
|
1401
|
+
NULL::character varying(255) AS meter_type,
|
|
1402
|
+
NULL::character varying(255) AS category,
|
|
1403
|
+
NULL::character varying(255) AS unit,
|
|
1404
|
+
NULL::character varying(255) AS replaced_meter_id,
|
|
1405
|
+
NULL::character varying(255) AS deleted,
|
|
1406
|
+
111 AS building_id
|
|
1407
|
+
FROM vpalac_measuring_equipment me;
|
|
1408
|
+
|
|
1409
|
+
|
|
1410
|
+
CREATE OR REPLACE VIEW v_consumption_energy_last_update
|
|
1411
|
+
AS WITH last_update AS (
|
|
1412
|
+
SELECT b.building_name,
|
|
1413
|
+
c.addr,
|
|
1414
|
+
max(c.time_utc) AS last_update
|
|
1415
|
+
FROM consumption_energy_consumption c
|
|
1416
|
+
JOIN consumption_energy_devices d ON c.addr::text = d.addr::text
|
|
1417
|
+
JOIN consumption_energy_buildings b ON d.building_id = b.id
|
|
1418
|
+
GROUP BY b.building_name, c.addr
|
|
1419
|
+
), last_not_zero AS (
|
|
1420
|
+
SELECT consumption_energy_consumption.addr,
|
|
1421
|
+
max(consumption_energy_consumption.time_utc) AS last_not_zero_value
|
|
1422
|
+
FROM consumption_energy_consumption
|
|
1423
|
+
WHERE consumption_energy_consumption.value > 0::numeric
|
|
1424
|
+
GROUP BY consumption_energy_consumption.addr
|
|
1425
|
+
)
|
|
1426
|
+
SELECT lu.building_name,
|
|
1427
|
+
lu.last_update,
|
|
1428
|
+
lu.addr,
|
|
1429
|
+
CASE
|
|
1430
|
+
WHEN lnz.last_not_zero_value = lu.last_update THEN NULL::timestamp without time zone
|
|
1431
|
+
ELSE lnz.last_not_zero_value
|
|
1432
|
+
END AS zero_values_after
|
|
1433
|
+
FROM last_update lu
|
|
1434
|
+
LEFT JOIN last_not_zero lnz ON lu.addr::text = lnz.addr::text;
|
|
1435
|
+
|
|
1436
|
+
|
|
1437
|
+
CREATE OR REPLACE VIEW v_consumption_energy_missing_devices_last_update
|
|
1438
|
+
AS WITH missing_devices_last_update AS (
|
|
1439
|
+
SELECT consumption_energy_consumption.addr,
|
|
1440
|
+
"left"(consumption_energy_consumption.addr::text, "position"("right"(consumption_energy_consumption.addr::text, length(consumption_energy_consumption.addr::text) - 1), '/'::text)) AS building_code,
|
|
1441
|
+
max(consumption_energy_consumption.time_utc) AS last_update
|
|
1442
|
+
FROM consumption_energy_consumption
|
|
1443
|
+
WHERE NOT (consumption_energy_consumption.addr::text IN ( SELECT consumption_energy_devices.addr
|
|
1444
|
+
FROM consumption_energy_devices))
|
|
1445
|
+
GROUP BY consumption_energy_consumption.addr
|
|
1446
|
+
), missing_devices_last_not_zero AS (
|
|
1447
|
+
SELECT consumption_energy_consumption.addr,
|
|
1448
|
+
max(consumption_energy_consumption.time_utc) AS last_not_zero_value
|
|
1449
|
+
FROM consumption_energy_consumption
|
|
1450
|
+
WHERE consumption_energy_consumption.value > 0::numeric AND NOT (consumption_energy_consumption.addr::text IN ( SELECT consumption_energy_devices.addr
|
|
1451
|
+
FROM consumption_energy_devices))
|
|
1452
|
+
GROUP BY consumption_energy_consumption.addr
|
|
1453
|
+
), buildings_mapping AS (
|
|
1454
|
+
SELECT "left"(d.addr::text, "position"("right"(d.addr::text, length(d.addr::text) - 1), '/'::text)) AS building_code,
|
|
1455
|
+
b.building_name
|
|
1456
|
+
FROM consumption_energy_devices d
|
|
1457
|
+
JOIN consumption_energy_buildings b ON d.building_id = b.id
|
|
1458
|
+
)
|
|
1459
|
+
SELECT bm.building_name,
|
|
1460
|
+
lu.last_update,
|
|
1461
|
+
lu.addr,
|
|
1462
|
+
CASE
|
|
1463
|
+
WHEN lnz.last_not_zero_value = lu.last_update THEN NULL::timestamp without time zone
|
|
1464
|
+
ELSE lnz.last_not_zero_value
|
|
1465
|
+
END AS zero_values_after
|
|
1466
|
+
FROM missing_devices_last_update lu
|
|
1467
|
+
JOIN buildings_mapping bm ON lu.building_code = bm.building_code
|
|
1468
|
+
LEFT JOIN missing_devices_last_not_zero lnz ON lu.addr::text = lnz.addr::text;
|
|
1469
|
+
|
|
1470
|
+
CREATE OR REPLACE VIEW v_consumption_energy_outside_temperature
|
|
1471
|
+
AS SELECT c.time_utc,
|
|
1472
|
+
c.value,
|
|
1473
|
+
c.addr,
|
|
1474
|
+
b.longitude,
|
|
1475
|
+
b.latitude,
|
|
1476
|
+
b.building_name
|
|
1477
|
+
FROM consumption_energy_consumption c
|
|
1478
|
+
JOIN ( SELECT max(consumption_energy_consumption.time_utc) AS last_measure_date,
|
|
1479
|
+
consumption_energy_consumption.addr
|
|
1480
|
+
FROM consumption_energy_consumption
|
|
1481
|
+
GROUP BY consumption_energy_consumption.addr) last_measure ON last_measure.addr::text = c.addr::text AND last_measure.last_measure_date = c.time_utc
|
|
1482
|
+
JOIN ( SELECT DISTINCT "left"(d.addr::text, "position"("right"(d.addr::text, length(d.addr::text) - 1), '/'::text)) AS building_code,
|
|
1483
|
+
b_1.latitude,
|
|
1484
|
+
b_1.longitude,
|
|
1485
|
+
b_1.building_name
|
|
1486
|
+
FROM consumption_energy_devices d
|
|
1487
|
+
JOIN consumption_energy_buildings b_1 ON d.building_id = b_1.id
|
|
1488
|
+
WHERE b_1.address_city::text ~~ 'Praha%'::text) b ON b.building_code = "left"(c.addr::text, "position"("right"(c.addr::text, length(c.addr::text) - 1), '/'::text))
|
|
1489
|
+
WHERE c.addr::text ~~ '%Text%'::text AND c.commodity::text = 'temperature'::text AND c.time_utc >= (now() - '1 year'::interval) AND (c.addr::text <> ALL (ARRAY['/2.8/Text'::text, '/2.5/Text'::text]));
|
|
1490
|
+
|
|
1491
|
+
|
|
1492
|
+
CREATE OR REPLACE VIEW v_consumption_energy_vrtbovsky_palac_last_update
|
|
1493
|
+
AS WITH last_update AS (
|
|
1494
|
+
SELECT m.var_id,
|
|
1495
|
+
me.umisteni,
|
|
1496
|
+
me.me_serial,
|
|
1497
|
+
max(to_timestamp((m.time_measurement / 1000)::double precision)::timestamp without time zone) AS last_update
|
|
1498
|
+
FROM vpalac_measurement m
|
|
1499
|
+
JOIN vpalac_measuring_equipment me ON m.var_id = me.var_id
|
|
1500
|
+
GROUP BY m.var_id, me.umisteni, me.me_serial
|
|
1501
|
+
), last_not_zero_value AS (
|
|
1502
|
+
SELECT vpalac_measurement.var_id,
|
|
1503
|
+
max(to_timestamp((vpalac_measurement.time_measurement / 1000)::double precision)::timestamp without time zone) AS last_not_zero_value
|
|
1504
|
+
FROM vpalac_measurement
|
|
1505
|
+
WHERE vpalac_measurement.value > 0::numeric
|
|
1506
|
+
GROUP BY vpalac_measurement.var_id
|
|
1507
|
+
)
|
|
1508
|
+
SELECT lu.var_id,
|
|
1509
|
+
lu.me_serial,
|
|
1510
|
+
lu.umisteni,
|
|
1511
|
+
lu.last_update,
|
|
1512
|
+
lnz.last_not_zero_value,
|
|
1513
|
+
CASE
|
|
1514
|
+
WHEN lnz.last_not_zero_value = lu.last_update THEN NULL::timestamp without time zone
|
|
1515
|
+
ELSE lnz.last_not_zero_value
|
|
1516
|
+
END AS zero_values_after
|
|
1517
|
+
FROM last_update lu
|
|
1518
|
+
LEFT JOIN last_not_zero_value lnz ON lu.var_id = lnz.var_id;
|
|
1519
|
+
|
|
1520
|
+
CREATE OR REPLACE VIEW v_consumption_gas_reserve
|
|
1521
|
+
AS WITH kalendar AS (
|
|
1522
|
+
SELECT den.den::date AS den
|
|
1523
|
+
FROM generate_series('2019-01-01 00:00:00+01'::timestamp with time zone, now() - '1 day'::interval, '1 day'::interval) den(den)
|
|
1524
|
+
), meraky AS (
|
|
1525
|
+
SELECT DISTINCT consumption_energy_devices.addr
|
|
1526
|
+
FROM consumption_energy_devices
|
|
1527
|
+
WHERE consumption_energy_devices.meter_type::text = 'Plynoměr'::text
|
|
1528
|
+
), daily_delta_core AS (
|
|
1529
|
+
SELECT date_trunc('day'::text, v_consumption_energy_delta.time_utc - '06:00:00'::interval)::date AS measured_from,
|
|
1530
|
+
v_consumption_energy_delta.addr,
|
|
1531
|
+
v_consumption_energy_delta.var,
|
|
1532
|
+
sum(v_consumption_energy_delta.delta_value) AS delta_value
|
|
1533
|
+
FROM v_consumption_energy_delta
|
|
1534
|
+
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
|
|
1535
|
+
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
|
|
1536
|
+
), daily_delta_core2 AS (
|
|
1537
|
+
SELECT date_trunc('day'::text, consumption_energy_consumption.time_utc - '06:00:00'::interval)::date AS measured_from,
|
|
1538
|
+
consumption_energy_consumption.addr,
|
|
1539
|
+
consumption_energy_consumption.var,
|
|
1540
|
+
sum(consumption_energy_consumption.value) AS delta_value
|
|
1541
|
+
FROM consumption_energy_consumption
|
|
1542
|
+
WHERE consumption_energy_consumption.var::text = 'core2'::text AND consumption_energy_consumption.time_utc::date > '2018-12-31'::date
|
|
1543
|
+
GROUP BY (date_trunc('day'::text, consumption_energy_consumption.time_utc - '06:00:00'::interval)::date), consumption_energy_consumption.addr, consumption_energy_consumption.var
|
|
1544
|
+
), delta_dates AS (
|
|
1545
|
+
SELECT daily_delta_core.measured_from,
|
|
1546
|
+
daily_delta_core.addr,
|
|
1547
|
+
daily_delta_core.var,
|
|
1548
|
+
daily_delta_core.delta_value,
|
|
1549
|
+
lag(daily_delta_core.measured_from, 1) OVER (PARTITION BY daily_delta_core.addr ORDER BY daily_delta_core.measured_from) AS measured_before,
|
|
1550
|
+
lead(daily_delta_core.measured_from, 1) OVER (PARTITION BY daily_delta_core.addr ORDER BY daily_delta_core.measured_from) AS measured_after,
|
|
1551
|
+
lag(daily_delta_core.delta_value, 1) OVER (PARTITION BY daily_delta_core.addr ORDER BY daily_delta_core.measured_from) AS delta_before,
|
|
1552
|
+
lead(daily_delta_core.delta_value, 1) OVER (PARTITION BY daily_delta_core.addr ORDER BY daily_delta_core.measured_from) AS delta_after
|
|
1553
|
+
FROM daily_delta_core
|
|
1554
|
+
), delta_date_diff AS (
|
|
1555
|
+
SELECT delta_dates.measured_from,
|
|
1556
|
+
delta_dates.addr,
|
|
1557
|
+
delta_dates.var,
|
|
1558
|
+
delta_dates.delta_value,
|
|
1559
|
+
delta_dates.measured_before,
|
|
1560
|
+
delta_dates.measured_after,
|
|
1561
|
+
delta_dates.delta_before,
|
|
1562
|
+
delta_dates.delta_after,
|
|
1563
|
+
CASE
|
|
1564
|
+
WHEN (delta_dates.measured_after - delta_dates.measured_from) > 1 AND (delta_dates.measured_from - delta_dates.measured_before) > 1 THEN 'mid'::text
|
|
1565
|
+
WHEN (delta_dates.measured_after - delta_dates.measured_from) > 1 THEN 'begin'::text
|
|
1566
|
+
WHEN (delta_dates.measured_from - delta_dates.measured_before) > 1 THEN 'end'::text
|
|
1567
|
+
ELSE 'ok'::text
|
|
1568
|
+
END AS value_type,
|
|
1569
|
+
CASE
|
|
1570
|
+
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
|
|
1571
|
+
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
|
|
1572
|
+
ELSE NULL::numeric
|
|
1573
|
+
END AS fix
|
|
1574
|
+
FROM delta_dates
|
|
1575
|
+
), joined_table AS (
|
|
1576
|
+
SELECT kalendar.den AS measured_from,
|
|
1577
|
+
meraky.addr,
|
|
1578
|
+
diff.delta_value,
|
|
1579
|
+
diff.value_type,
|
|
1580
|
+
diff.fix,
|
|
1581
|
+
core2.delta_value AS core2_delta,
|
|
1582
|
+
CASE
|
|
1583
|
+
WHEN diff.value_type = 'ok'::text THEN COALESCE(core2.delta_value, diff.delta_value)
|
|
1584
|
+
ELSE diff.fix
|
|
1585
|
+
END AS final_fix,
|
|
1586
|
+
CASE
|
|
1587
|
+
WHEN diff.value_type = 'ok'::text THEN COALESCE(core2.var, diff.var)
|
|
1588
|
+
ELSE 'core'::character varying
|
|
1589
|
+
END AS final_var
|
|
1590
|
+
FROM kalendar
|
|
1591
|
+
LEFT JOIN meraky ON true
|
|
1592
|
+
LEFT JOIN delta_date_diff diff ON diff.measured_from = kalendar.den AND diff.addr::text = meraky.addr::text
|
|
1593
|
+
LEFT JOIN daily_delta_core2 core2 ON core2.measured_from = kalendar.den AND core2.addr::text = meraky.addr::text
|
|
1594
|
+
ORDER BY meraky.addr, kalendar.den
|
|
1595
|
+
), fixed_table AS (
|
|
1596
|
+
SELECT q.measured_from,
|
|
1597
|
+
q.addr,
|
|
1598
|
+
q.delta_value,
|
|
1599
|
+
q.value_type,
|
|
1600
|
+
q.fix,
|
|
1601
|
+
q.core2_delta,
|
|
1602
|
+
q.final_fix,
|
|
1603
|
+
q.final_var,
|
|
1604
|
+
q.value_partition,
|
|
1605
|
+
first_value(q.final_fix) OVER w AS value
|
|
1606
|
+
FROM ( SELECT joined_table.measured_from,
|
|
1607
|
+
joined_table.addr,
|
|
1608
|
+
joined_table.delta_value,
|
|
1609
|
+
joined_table.value_type,
|
|
1610
|
+
joined_table.fix,
|
|
1611
|
+
joined_table.core2_delta,
|
|
1612
|
+
joined_table.final_fix,
|
|
1613
|
+
joined_table.final_var,
|
|
1614
|
+
sum(
|
|
1615
|
+
CASE
|
|
1616
|
+
WHEN joined_table.final_fix IS NULL THEN 0
|
|
1617
|
+
ELSE 1
|
|
1618
|
+
END) OVER (PARTITION BY joined_table.addr ORDER BY joined_table.measured_from) AS value_partition
|
|
1619
|
+
FROM joined_table) q
|
|
1620
|
+
WINDOW w AS (PARTITION BY q.addr, q.value_partition ORDER BY q.measured_from)
|
|
1621
|
+
)
|
|
1622
|
+
SELECT fixed_table.measured_from,
|
|
1623
|
+
fixed_table.addr,
|
|
1624
|
+
fixed_table.value AS delta_value,
|
|
1625
|
+
fixed_table.final_var,
|
|
1626
|
+
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
|
|
1627
|
+
FROM fixed_table
|
|
1628
|
+
WHERE fixed_table.value IS NOT NULL;
|
|
1629
|
+
|
|
1630
|
+
|
|
1631
|
+
CREATE OR REPLACE VIEW v_vpalac_apartments_daily_consumption
|
|
1632
|
+
AS WITH last_measurement AS (
|
|
1633
|
+
SELECT date_part('year'::text, to_timestamp((m.time_measurement / 1000)::double precision)::timestamp without time zone) AS measure_year,
|
|
1634
|
+
date_trunc('day'::text, max(to_timestamp((m.time_measurement / 1000)::double precision)::timestamp without time zone)) AS last_measurement,
|
|
1635
|
+
m.var_id
|
|
1636
|
+
FROM vpalac_measurement m
|
|
1637
|
+
GROUP BY (date_part('year'::text, to_timestamp((m.time_measurement / 1000)::double precision)::timestamp without time zone)), m.var_id
|
|
1638
|
+
), daily_status AS (
|
|
1639
|
+
SELECT
|
|
1640
|
+
CASE
|
|
1641
|
+
WHEN me.me_serial::text = '5640201'::text THEN 'Prostor 109,111'::text
|
|
1642
|
+
WHEN mm.location_name IS NOT NULL THEN mm.location_name::text
|
|
1643
|
+
WHEN me.umisteni::text ~~ '%Byt%'::text THEN "right"(me.umisteni::text, length(me.umisteni::text) - "position"(me.umisteni::text, 'Byt'::text) + 1)
|
|
1644
|
+
ELSE "right"(me.umisteni::text, length(me.umisteni::text) - "position"(me.umisteni::text, 'Prostor'::text) + 1)
|
|
1645
|
+
END AS apartment,
|
|
1646
|
+
CASE
|
|
1647
|
+
WHEN mt.met_nazev::text = 'Sensor'::text THEN 'Teplo'::character varying
|
|
1648
|
+
ELSE mt.met_nazev
|
|
1649
|
+
END AS met_nazev,
|
|
1650
|
+
me.mis_nazev,
|
|
1651
|
+
me.var_id,
|
|
1652
|
+
u.jed_nazev,
|
|
1653
|
+
date_trunc('hour'::text, to_timestamp((m.time_measurement / 1000)::double precision)::timestamp without time zone) AS measure_date,
|
|
1654
|
+
min(m.value) AS start_value
|
|
1655
|
+
FROM vpalac_measuring_equipment me
|
|
1656
|
+
JOIN vpalac_measurement m ON me.var_id = m.var_id
|
|
1657
|
+
LEFT JOIN vpalac_meter_type mt ON me.met_id = mt.met_id
|
|
1658
|
+
LEFT JOIN vpalac_units u ON me.pot_id = u.pot_id
|
|
1659
|
+
LEFT JOIN vpalac_meter_mapping mm ON mm.var_id = me.var_id
|
|
1660
|
+
WHERE to_timestamp((m.time_measurement / 1000)::double precision)::timestamp without time zone >= (now() - '3 years'::interval)
|
|
1661
|
+
GROUP BY mm.location_name, me.umisteni, me.me_serial, (date_part('month'::text, to_timestamp((m.time_measurement / 1000)::double precision)::timestamp without time zone)), me.var_id, ("right"(me.umisteni::text, 6)), mt.met_nazev, me.mis_nazev, (date_trunc('hour'::text, to_timestamp((m.time_measurement / 1000)::double precision)::timestamp without time zone)), u.jed_nazev
|
|
1662
|
+
)
|
|
1663
|
+
SELECT ds.apartment,
|
|
1664
|
+
ds.met_nazev AS measure_type,
|
|
1665
|
+
ds.mis_nazev AS measure_detail,
|
|
1666
|
+
ds.jed_nazev,
|
|
1667
|
+
ds.measure_date,
|
|
1668
|
+
lm.last_measurement,
|
|
1669
|
+
CASE
|
|
1670
|
+
WHEN ds.met_nazev::text = 'Teplo'::text AND ds.measure_date = lm.last_measurement THEN lead(ds.start_value) OVER (PARTITION BY ds.var_id ORDER BY ds.measure_date)
|
|
1671
|
+
ELSE ds.start_value - lag(ds.start_value) OVER (PARTITION BY ds.var_id ORDER BY ds.measure_date)
|
|
1672
|
+
END AS consumption,
|
|
1673
|
+
ds.var_id
|
|
1674
|
+
FROM daily_status ds
|
|
1675
|
+
JOIN last_measurement lm ON ds.var_id = lm.var_id AND date_part('year'::text, ds.measure_date) = lm.measure_year;
|