@golemio/energetics 1.4.1-dev.1382853974 → 1.4.1-dev.1388903132
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/example/04_measurements.sql +2 -1
- package/db/migrations/postgresql/sqls/20240719110034-add-monthly-report-function-up.sql +52 -22
- package/dist/integration-engine/commodity-providers/datasources/ppas-ave-api/helpers/PpasAveApiHelper.js +3 -1
- package/dist/integration-engine/commodity-providers/datasources/ppas-ave-api/helpers/PpasAveApiHelper.js.map +1 -1
- package/docs/openapi-output.yaml +1 -1
- package/package.json +1 -1
|
@@ -24,4 +24,5 @@ INSERT INTO consumption_energy_measurements ("timestamp", value, addr, var, "typ
|
|
|
24
24
|
('2023-05-01 04:00:00.000+02', 2709691.000000000000000, '/2.9/PF1', 'core', 'provider_value', '27ZG100Z0000521V', NULL, NULL, NULL, '2023-05-02 00:30:44.263', NULL, NULL, '2023-05-02 00:30:44.263', NULL),
|
|
25
25
|
('2023-05-01 04:00:00.001+02', 18.000000000000000, '/2.9/PF1', 'core2', 'provider_value', '27ZG100Z0000521V', NULL, NULL, NULL, '2023-05-02 00:30:44.263', NULL, NULL, '2023-05-02 00:30:44.263', NULL),
|
|
26
26
|
('2023-05-01 03:00:00.000+02', 2709680.000000000000000, '/2.9/PF1', 'core', 'provider_value', '27ZG100Z0000521V', NULL, NULL, NULL, '2023-05-02 00:30:44.263', NULL, NULL, '2023-05-02 00:30:44.263', NULL),
|
|
27
|
-
('2023-05-01 03:00:00.001+02', 14.000000000000000, '/2.9/PF1', 'core2', 'provider_value', '27ZG100Z0000521V', NULL, NULL, NULL, '2023-05-02 00:30:44.263', NULL, NULL, '2023-05-02 00:30:44.263', NULL)
|
|
27
|
+
('2023-05-01 03:00:00.001+02', 14.000000000000000, '/2.9/PF1', 'core2', 'provider_value', '27ZG100Z0000521V', NULL, NULL, NULL, '2023-05-02 00:30:44.263', NULL, NULL, '2023-05-02 00:30:44.263', NULL),
|
|
28
|
+
('2023-04-30 23:45:00.001+02', 0.000000000000000, '/2.9/PF1', 'core2', 'provider_value', '27ZG100Z0000521V', NULL, NULL, NULL, '2023-05-02 00:30:44.263', NULL, NULL, '2023-05-02 00:30:44.263', NULL);
|
|
@@ -8,39 +8,69 @@ RETURNS TABLE (
|
|
|
8
8
|
)
|
|
9
9
|
SET search_path FROM CURRENT
|
|
10
10
|
AS $func$
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
with previousMonth as (
|
|
12
|
+
select
|
|
13
|
+
max("value") as maxPrevious
|
|
14
|
+
from
|
|
15
|
+
"consumption_energy_measurements" as "consumption_energy_measurements"
|
|
16
|
+
where
|
|
17
|
+
("consumption_energy_measurements"."var" = $2
|
|
18
|
+
and "consumption_energy_measurements"."addr" = $1
|
|
19
|
+
and "consumption_energy_measurements"."timestamp" > ($3::timestamptz - interval '1 month') and "consumption_energy_measurements"."timestamp" < $3
|
|
20
|
+
) and
|
|
21
|
+
case -- limit access according to allowed organizations for the role
|
|
22
|
+
when $5 is null then 1
|
|
23
|
+
when
|
|
24
|
+
"consumption_energy_measurements"."addr" in (
|
|
25
|
+
select distinct
|
|
26
|
+
d.addr
|
|
27
|
+
from organizations_buildings b
|
|
28
|
+
inner join consumption_energy_devices d on b.building_id = d.building_id
|
|
29
|
+
where b.organization_id = any(('{' || $5 || '}')::integer[])
|
|
30
|
+
) then 1
|
|
31
|
+
else 0
|
|
32
|
+
end = 1
|
|
33
|
+
), currentMonth as (
|
|
34
|
+
select
|
|
17
35
|
"meter",
|
|
18
36
|
"type",
|
|
19
37
|
"addr",
|
|
20
|
-
"var"
|
|
38
|
+
"var",
|
|
39
|
+
max("value") as maxValue
|
|
21
40
|
from
|
|
22
41
|
"consumption_energy_measurements" as "consumption_energy_measurements"
|
|
23
42
|
where
|
|
24
43
|
("consumption_energy_measurements"."var" = $2
|
|
25
44
|
and "consumption_energy_measurements"."addr" = $1
|
|
26
45
|
and "consumption_energy_measurements"."timestamp" between $3 and $4
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
)
|
|
46
|
+
) and
|
|
47
|
+
case -- limit access according to allowed organizations for the role
|
|
48
|
+
when $5 is null then 1
|
|
49
|
+
when
|
|
50
|
+
"consumption_energy_measurements"."addr" in (
|
|
51
|
+
select distinct
|
|
52
|
+
d.addr
|
|
53
|
+
from organizations_buildings b
|
|
54
|
+
inner join consumption_energy_devices d on b.building_id = d.building_id
|
|
55
|
+
where b.organization_id = any(('{' || $5 || '}')::integer[])
|
|
56
|
+
) then 1
|
|
57
|
+
else 0
|
|
58
|
+
end = 1
|
|
41
59
|
group by
|
|
42
60
|
"meter",
|
|
43
61
|
"type",
|
|
44
62
|
"addr",
|
|
45
|
-
"var"
|
|
63
|
+
"var"
|
|
64
|
+
) select
|
|
65
|
+
case when var in ('EFwActi','EFwActiVT','EFwActiNT') then -- special handling for "činná energie"
|
|
66
|
+
((maxValue/4) - (maxPrevious/4))
|
|
67
|
+
else
|
|
68
|
+
maxValue - maxPrevious
|
|
69
|
+
end as "value",
|
|
70
|
+
"meter",
|
|
71
|
+
"type",
|
|
72
|
+
"addr",
|
|
73
|
+
"var"
|
|
74
|
+
from
|
|
75
|
+
previousMonth, currentMonth;
|
|
46
76
|
$func$ LANGUAGE sql;
|
|
@@ -82,5 +82,7 @@ class PpasAveApiHelper {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
exports.PpasAveApiHelper = PpasAveApiHelper;
|
|
85
|
-
|
|
85
|
+
// based on analysis it seems API PPAS is handling timezones incorrectly, we deciced to follow PPAS UI approach to timezones.
|
|
86
|
+
// https://gitlab.com/operator-ict/golemio/projekty/energetika/p0262.prevzeti-energeticke-databaze/-/issues/37#note_2010344938
|
|
87
|
+
PpasAveApiHelper.API_DATE_TZ = "UTC+1";
|
|
86
88
|
//# sourceMappingURL=PpasAveApiHelper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PpasAveApiHelper.js","sourceRoot":"","sources":["../../../../../../src/integration-engine/commodity-providers/datasources/ppas-ave-api/helpers/PpasAveApiHelper.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6EAA8F;AAM9F;;GAEG;AACH,MAAM,gBAAgB;
|
|
1
|
+
{"version":3,"file":"PpasAveApiHelper.js","sourceRoot":"","sources":["../../../../../../src/integration-engine/commodity-providers/datasources/ppas-ave-api/helpers/PpasAveApiHelper.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6EAA8F;AAM9F;;GAEG;AACH,MAAM,gBAAgB;IAKlB,YAAoB,OAAe,EAAU,MAAkB;QAA3C,YAAO,GAAP,OAAO,CAAQ;QAAU,WAAM,GAAN,MAAM,CAAY;QAC/D;;WAEG;QACI,kBAAa,GAAG,GAA0B,EAAE;YAC/C,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC;YAEnC,IAAI;gBACA,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBAClC,GAAG,CAAC,QAAQ,IAAI,GAAG,GAAG,gBAAgB,CAAC,YAAY,CAAC,KAAK,CAAC;gBAE1D,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE;oBACvC,MAAM,EAAE,MAAM;oBACd,OAAO,EAAE,IAAI,OAAO,CAAC;wBACjB,MAAM,EAAE,kBAAkB;wBAC1B,cAAc,EAAE,mCAAmC;qBACtD,CAAC;oBACF,IAAI,EAAE,IAAI,eAAe,CAAC;wBACtB,IAAI,EAAE,IAAI;wBACV,QAAQ,EAAE,IAAI;qBACjB,CAAC;oBACF,MAAM,EAAE,WAAW,CAAC,OAAO,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