Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MyEMS
MyEMS能源管理系统
提交
84943879
M
MyEMS能源管理系统
项目概览
MyEMS
/
MyEMS能源管理系统
通知
46
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
MyEMS能源管理系统
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
84943879
编写于
4月 23, 2024
作者:
nengyuangzhang
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop'
上级
53535a27
4dc03487
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
33 addition
and
31 deletion
+33
-31
myems-api/reports/energystoragepowerstationdetails.py
myems-api/reports/energystoragepowerstationdetails.py
+33
-31
未找到文件。
myems-api/reports/energystoragepowerstationdetails.py
浏览文件 @
84943879
import
re
from
datetime
import
datetime
,
timedelta
,
timezone
from
decimal
import
Decimal
import
falcon
import
mysql.connector
import
simplejson
as
json
...
...
@@ -167,10 +168,10 @@ class Reporting:
# todo: query multiple energy storage containers
container_list
=
list
()
cursor_system
.
execute
(
" SELECT c.id, c.name, c.uuid "
" FROM tbl_energy_storage_power_stations_containers sc, "
" FROM tbl_energy_storage_power_stations_containers
esp
sc, "
" tbl_energy_storage_containers c "
" WHERE sc.energy_storage_power_station_id = %s "
" AND sc.energy_storage_container_id = c.id"
" WHERE
esp
sc.energy_storage_power_station_id = %s "
" AND
esp
sc.energy_storage_container_id = c.id"
" LIMIT 1 "
,
(
energy_storage_power_station_id
,))
row_container
=
cursor_system
.
fetchone
()
...
...
@@ -179,12 +180,13 @@ class Reporting:
"name"
:
row_container
[
1
],
"uuid"
:
row_container
[
2
]})
# todo: if len(container_list) == 0
print
(
'container_list:'
+
str
(
container_list
))
################################################################################################################
# Step 4: query associated batteries in containers
################################################################################################################
cursor_system
.
execute
(
" SELECT p.id,
m
b.name, p.units, p.object_type "
" FROM tbl_energy_storage_containers_batteries
m
b, tbl_points p "
" WHERE
mb.id = %s AND m
b.soc_point_id = p.id "
,
cursor_system
.
execute
(
" SELECT p.id,
c
b.name, p.units, p.object_type "
" FROM tbl_energy_storage_containers_batteries
c
b, tbl_points p "
" WHERE
cb.energy_storage_container_id = %s AND c
b.soc_point_id = p.id "
,
(
container_list
[
0
][
'id'
],))
row_point
=
cursor_system
.
fetchone
()
if
row_point
is
not
None
:
...
...
@@ -193,9 +195,9 @@ class Reporting:
"units"
:
row_point
[
2
],
"object_type"
:
row_point
[
3
]})
cursor_system
.
execute
(
" SELECT p.id,
m
b.name, p.units, p.object_type "
" FROM tbl_energy_storage_containers_batteries
m
b, tbl_points p "
" WHERE
mb.id = %s AND m
b.power_point_id = p.id "
,
cursor_system
.
execute
(
" SELECT p.id,
c
b.name, p.units, p.object_type "
" FROM tbl_energy_storage_containers_batteries
c
b, tbl_points p "
" WHERE
cb.energy_storage_container_id = %s AND c
b.power_point_id = p.id "
,
(
container_list
[
0
][
'id'
],))
row_point
=
cursor_system
.
fetchone
()
if
row_point
is
not
None
:
...
...
@@ -204,9 +206,9 @@ class Reporting:
"units"
:
row_point
[
2
],
"object_type"
:
row_point
[
3
]})
cursor_system
.
execute
(
" SELECT m.id,
m
b.name, m.energy_category_id "
" FROM tbl_energy_storage_containers_batteries
m
b, tbl_meters m "
" WHERE
mb.id = %s AND m
b.charge_meter_id = m.id "
,
cursor_system
.
execute
(
" SELECT m.id,
c
b.name, m.energy_category_id "
" FROM tbl_energy_storage_containers_batteries
c
b, tbl_meters m "
" WHERE
cb.energy_storage_container_id = %s AND c
b.charge_meter_id = m.id "
,
(
container_list
[
0
][
'id'
],))
row_meter
=
cursor_system
.
fetchone
()
if
row_meter
is
not
None
:
...
...
@@ -214,9 +216,9 @@ class Reporting:
"name"
:
row_meter
[
1
]
+
'.Charge'
,
"energy_category_id"
:
row_meter
[
2
]})
cursor_system
.
execute
(
" SELECT m.id,
m
b.name, m.energy_category_id "
" FROM tbl_energy_storage_containers_batteries
m
b, tbl_meters m "
" WHERE
mb.id = %s AND m
b.discharge_meter_id = m.id "
,
cursor_system
.
execute
(
" SELECT m.id,
c
b.name, m.energy_category_id "
" FROM tbl_energy_storage_containers_batteries
c
b, tbl_meters m "
" WHERE
cb.energy_storage_container_id = %s AND c
b.discharge_meter_id = m.id "
,
(
container_list
[
0
][
'id'
],))
row_meter
=
cursor_system
.
fetchone
()
if
row_meter
is
not
None
:
...
...
@@ -227,9 +229,9 @@ class Reporting:
################################################################################################################
# Step 5: query associated grids in containers
################################################################################################################
cursor_system
.
execute
(
" SELECT p.id,
m
g.name, p.units, p.object_type "
" FROM tbl_energy_storage_containers_grids
m
g, tbl_points p "
" WHERE
mg.id = %s AND m
g.power_point_id = p.id "
,
cursor_system
.
execute
(
" SELECT p.id,
c
g.name, p.units, p.object_type "
" FROM tbl_energy_storage_containers_grids
c
g, tbl_points p "
" WHERE
cg.energy_storage_container_id = %s AND c
g.power_point_id = p.id "
,
(
container_list
[
0
][
'id'
],))
row_point
=
cursor_system
.
fetchone
()
if
row_point
is
not
None
:
...
...
@@ -238,9 +240,9 @@ class Reporting:
"units"
:
row_point
[
2
],
"object_type"
:
row_point
[
3
]})
cursor_system
.
execute
(
" SELECT m.id,
m
g.name, m.energy_category_id "
" FROM tbl_energy_storage_containers_grids
m
g, tbl_meters m "
" WHERE
mg.id = %s AND m
g.buy_meter_id = m.id "
,
cursor_system
.
execute
(
" SELECT m.id,
c
g.name, m.energy_category_id "
" FROM tbl_energy_storage_containers_grids
c
g, tbl_meters m "
" WHERE
cg.energy_storage_container_id = %s AND c
g.buy_meter_id = m.id "
,
(
container_list
[
0
][
'id'
],))
row_meter
=
cursor_system
.
fetchone
()
if
row_meter
is
not
None
:
...
...
@@ -248,9 +250,9 @@ class Reporting:
"name"
:
row_meter
[
1
]
+
'.Buy'
,
"energy_category_id"
:
row_meter
[
2
]})
cursor_system
.
execute
(
" SELECT m.id,
m
g.name, m.energy_category_id "
" FROM tbl_energy_storage_containers_grids
m
g, tbl_meters m "
" WHERE
mg.id = %s AND m
g.sell_meter_id = m.id "
,
cursor_system
.
execute
(
" SELECT m.id,
c
g.name, m.energy_category_id "
" FROM tbl_energy_storage_containers_grids
c
g, tbl_meters m "
" WHERE
cg.energy_storage_container_id = %s AND c
g.sell_meter_id = m.id "
,
(
container_list
[
0
][
'id'
],))
row_meter
=
cursor_system
.
fetchone
()
if
row_meter
is
not
None
:
...
...
@@ -261,9 +263,9 @@ class Reporting:
################################################################################################################
# Step 6: query associated loads in containers
################################################################################################################
cursor_system
.
execute
(
" SELECT p.id,
m
l.name, p.units, p.object_type "
" FROM tbl_energy_storage_containers_loads
m
l, tbl_points p "
" WHERE
ml.id = %s AND m
l.power_point_id = p.id "
,
cursor_system
.
execute
(
" SELECT p.id,
c
l.name, p.units, p.object_type "
" FROM tbl_energy_storage_containers_loads
c
l, tbl_points p "
" WHERE
cl.energy_storage_container_id = %s AND c
l.power_point_id = p.id "
,
(
container_list
[
0
][
'id'
],))
row_point
=
cursor_system
.
fetchone
()
if
row_point
is
not
None
:
...
...
@@ -272,9 +274,9 @@ class Reporting:
"units"
:
row_point
[
2
],
"object_type"
:
row_point
[
3
]})
cursor_system
.
execute
(
" SELECT m.id,
m
l.name, m.energy_category_id "
" FROM tbl_energy_storage_containers_loads
m
l, tbl_meters m "
" WHERE
ml.id = %s AND m
l.meter_id = m.id "
,
cursor_system
.
execute
(
" SELECT m.id,
c
l.name, m.energy_category_id "
" FROM tbl_energy_storage_containers_loads
c
l, tbl_meters m "
" WHERE
cl.energy_storage_container_id = %s AND c
l.meter_id = m.id "
,
(
container_list
[
0
][
'id'
],))
row_meter
=
cursor_system
.
fetchone
()
if
row_meter
is
not
None
:
...
...
@@ -535,7 +537,7 @@ class Reporting:
parameters_data
[
'names'
]
=
list
()
parameters_data
[
'timestamps'
]
=
list
()
parameters_data
[
'values'
]
=
list
()
print
(
'point_list:'
+
str
(
point_list
))
for
point
in
point_list
:
point_values
=
[]
point_timestamps
=
[]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录