Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
U
unify_api2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chaonan
unify_api2
Commits
13285235
Commit
13285235
authored
Apr 25, 2023
by
wang.wenrong
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'wwr' into 'develop'
fix_shiduanu See merge request
!30
parents
7ef9a0de
9d4a6d83
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
488 additions
and
345 deletions
+488
-345
common_dao.py
unify_api/modules/common/dao/common_dao.py
+2
-2
health_score_dao.py
unify_api/modules/common/dao/health_score_dao.py
+23
-75
health_score.py
unify_api/modules/common/procedures/health_score.py
+12
-12
electric_util.py
unify_api/modules/electric/procedures/electric_util.py
+6
-15
IntergratePipe.py
unify_api/modules/shidianu/service/IntergratePipe.py
+0
-2
aircondAnalysis.py
unify_api/modules/shidianu/service/aircondAnalysis.py
+34
-20
componentStage.py
unify_api/modules/shidianu/service/componentStage.py
+66
-44
decomp_main.py
unify_api/modules/shidianu/service/decomp_main.py
+32
-8
electricProportion.py
unify_api/modules/shidianu/service/electricProportion.py
+153
-83
electroAnalysis.py
unify_api/modules/shidianu/service/electroAnalysis.py
+38
-20
heaterAnalysis.py
unify_api/modules/shidianu/service/heaterAnalysis.py
+38
-19
highPower.py
unify_api/modules/shidianu/service/highPower.py
+2
-3
open_data_service.py
unify_api/modules/shidianu/service/open_data_service.py
+4
-3
paramAnaly.py
unify_api/modules/shidianu/service/paramAnaly.py
+1
-1
pieceClassify.py
unify_api/modules/shidianu/service/pieceClassify.py
+28
-14
refrigAnalysis.py
unify_api/modules/shidianu/service/refrigAnalysis.py
+49
-24
No files found.
unify_api/modules/common/dao/common_dao.py
View file @
13285235
...
@@ -63,8 +63,8 @@ async def points_monitor_by_cid(cids):
...
@@ -63,8 +63,8 @@ async def points_monitor_by_cid(cids):
async
def
mid_by_pid
(
pid
):
async
def
mid_by_pid
(
pid
):
"""根据pid查询mid"""
"""根据pid查询mid"""
sql
=
"select m
id from change_meter_record
where pid=
%
s "
\
sql
=
"select m
tid from point
where pid=
%
s "
\
"order by
start
_time desc limit 1 "
"order by
create
_time desc limit 1 "
async
with
MysqlUtil
()
as
conn
:
async
with
MysqlUtil
()
as
conn
:
mid_dic
=
await
conn
.
fetchone
(
sql
,
args
=
(
pid
,))
mid_dic
=
await
conn
.
fetchone
(
sql
,
args
=
(
pid
,))
return
mid_dic
return
mid_dic
...
...
unify_api/modules/common/dao/health_score_dao.py
View file @
13285235
...
@@ -30,78 +30,26 @@ async def get_mean_datas_dao(pids, words, start, end):
...
@@ -30,78 +30,26 @@ async def get_mean_datas_dao(pids, words, start, end):
async
def
health_score_points_aggs
(
start
,
end
,
point_list
):
async
def
health_score_points_aggs
(
start
,
end
,
point_list
):
"""根据points分组, 再求平均值"""
"""根据points分组, 再求平均值"""
# start_es = convert_es_str(start)
# end_es = convert_es_str(end)
sql
=
f
"""
# 所有报警类型
SELECT
query_body
=
{
pid,
"query"
:
{
avg( uab_mean ) uab_mean_avg,
"bool"
:
{
avg( costtl_mean ) costtl_mean_avg,
"filter"
:
[
avg( lf_mean ) lf_mean_avg,
{
avg( thduab_mean ) thduab_mean_avg,
"terms"
:
{
avg( ubl_mean ) ubl_mean_avg,
"pid"
:
point_list
avg( freq_mean ) freq_mean_avg,
}
avg( ua_mean ) ua_mean_avg
},
FROM
{
point_15min_electric
"range"
:
{
WHERE
"quarter_time"
:
{
create_time > "{start}"
"gte"
:
start
,
AND create_time < "{end}"
"lte"
:
end
AND pid in
%
s
}
GROUP BY
}
pid
}
"""
]
async
with
MysqlUtil
()
as
conn
:
}
datas
=
await
conn
.
fetchall
(
sql
,
args
=
(
tuple
(
point_list
),))
if
point_list
else
[]
},
return
datas
"size"
:
0
,
"aggs"
:
{
"points"
:
{
"terms"
:
{
"field"
:
"pid"
,
"size"
:
1000
},
"aggs"
:
{
"ua_mean_avg"
:
{
"avg"
:
{
"field"
:
"ua_mean"
}
},
"freq_mean_avg"
:
{
"avg"
:
{
"field"
:
"freq_mean"
}
},
"ubl_mean_avg"
:
{
"avg"
:
{
"field"
:
"ubl_mean"
}
},
"costtl_mean_avg"
:
{
"avg"
:
{
"field"
:
"costtl_mean"
}
},
"thdua_mean_avg"
:
{
"avg"
:
{
"field"
:
"thdua_mean"
}
},
"lf_mean_avg"
:
{
"avg"
:
{
"field"
:
"lf_mean"
}
},
"uab_mean_avg"
:
{
"avg"
:
{
"field"
:
"ua_mean"
}
}
}
}
}
}
log
.
info
(
"query_body={}"
.
format
(
query_body
))
async
with
EsUtil
()
as
es
:
es_result
=
await
es
.
search_origin
(
body
=
query_body
,
index
=
constants
.
POINT_15MIN_INDEX
)
return
es_result
[
"aggregations"
][
"points"
][
"buckets"
]
unify_api/modules/common/procedures/health_score.py
View file @
13285235
...
@@ -55,7 +55,7 @@ async def load_health_radar(cid, param_point_id=None):
...
@@ -55,7 +55,7 @@ async def load_health_radar(cid, param_point_id=None):
es_health
=
await
health_score_points_aggs
(
es_health
=
await
health_score_points_aggs
(
start_time
,
end_time
,
inline_point_ids
+
point_ids
start_time
,
end_time
,
inline_point_ids
+
point_ids
)
)
es_dic
=
{
i
[
"
key"
]:
i
for
i
in
es_health
}
es_dic
=
{
i
[
"
pid"
]:
i
for
i
in
es_health
if
es_health
}
# 统计所有点所有平均值
# 统计所有点所有平均值
for
point_id
in
inline_point_ids
+
point_ids
:
for
point_id
in
inline_point_ids
+
point_ids
:
ctnum
=
point_info_map
[
point_id
][
"ctnum"
]
ctnum
=
point_info_map
[
point_id
][
"ctnum"
]
...
@@ -71,7 +71,7 @@ async def load_health_radar(cid, param_point_id=None):
...
@@ -71,7 +71,7 @@ async def load_health_radar(cid, param_point_id=None):
if
not
point_v
:
if
not
point_v
:
stats
[
point_id
][
item
]
=
None
stats
[
point_id
][
item
]
=
None
else
:
else
:
stats
[
point_id
][
item
]
=
point_v
[
item
+
'_avg'
]
.
get
(
"value"
)
stats
[
point_id
][
item
]
=
point_v
[
item
+
'_avg'
]
'''
'''
range = Range(field="quarter_time", start=start_time, end=end_time)
range = Range(field="quarter_time", start=start_time, end=end_time)
stats = {point_id: {} for point_id in inline_point_ids + point_ids}
stats = {point_id: {} for point_id in inline_point_ids + point_ids}
...
@@ -109,17 +109,17 @@ async def load_health_radar(cid, param_point_id=None):
...
@@ -109,17 +109,17 @@ async def load_health_radar(cid, param_point_id=None):
avg = aggregations.get("
%
s_avg"
%
item, {}).get("value")
avg = aggregations.get("
%
s_avg"
%
item, {}).get("value")
stats[point_id][item] = avg
stats[point_id][item] = avg
'''
'''
# 获取所有poin_id和mid对应关系
# 获取所有poin_id和m
t
id对应关系
all_point_ids
=
inline_point_ids
+
point_ids
all_point_ids
=
inline_point_ids
+
point_ids
point_mid_map
=
{}
point_mid_map
=
{}
if
all_point_ids
:
if
all_point_ids
:
sql
=
(
sql
=
(
"SELECT pid, m
id FROM change_meter_record WHERE pid IN
%
s order by pid, start
_time asc"
"SELECT pid, m
tid FROM point WHERE pid IN
%
s order by pid, create
_time asc"
)
)
async
with
MysqlUtil
()
as
conn
:
async
with
MysqlUtil
()
as
conn
:
change_meter_records
=
await
conn
.
fetchall
(
sql
,
args
=
(
tuple
(
all_point_ids
),))
change_meter_records
=
await
conn
.
fetchall
(
sql
,
args
=
(
tuple
(
all_point_ids
),))
point_mid_map
=
{
point_mid_map
=
{
i
[
"pid"
]:
i
[
"m
id"
]
for
i
in
change_meter_records
if
i
[
"m
id"
]
is
not
None
i
[
"pid"
]:
i
[
"m
tid"
]
for
i
in
change_meter_records
if
i
[
"mt
id"
]
is
not
None
}
}
# 获取meter_param_record中的标准电压
# 获取meter_param_record中的标准电压
...
@@ -127,9 +127,9 @@ async def load_health_radar(cid, param_point_id=None):
...
@@ -127,9 +127,9 @@ async def load_health_radar(cid, param_point_id=None):
meter_param_map
=
{}
meter_param_map
=
{}
if
all_mids
:
if
all_mids
:
async
with
MysqlUtil
()
as
conn
:
async
with
MysqlUtil
()
as
conn
:
sql
=
"SELECT m
id, vc, voltage_side, ctnum FROM meter_param_record WHERE mid IN
%
s order by mid, start
_time asc"
sql
=
"SELECT m
tid, vc, voltage_side, ctnum FROM point WHERE mtid IN
%
s order by mtid, create
_time asc"
meter_param_records
=
await
conn
.
fetchall
(
sql
,
args
=
(
tuple
(
all_mids
),))
meter_param_records
=
await
conn
.
fetchall
(
sql
,
args
=
(
tuple
(
all_mids
),))
meter_param_map
=
{
i
[
"mid"
]:
i
for
i
in
meter_param_records
}
meter_param_map
=
{
i
[
"m
t
id"
]:
i
for
i
in
meter_param_records
}
log
.
info
(
f
"all_mids={all_mids}"
)
log
.
info
(
f
"all_mids={all_mids}"
)
# 电压偏差评分
# 电压偏差评分
...
@@ -139,14 +139,14 @@ async def load_health_radar(cid, param_point_id=None):
...
@@ -139,14 +139,14 @@ async def load_health_radar(cid, param_point_id=None):
if
ua_mean
is
None
:
if
ua_mean
is
None
:
continue
continue
mid
=
point_mid_map
.
get
(
point_id
)
m
t
id
=
point_mid_map
.
get
(
point_id
)
if
not
mid
:
if
not
m
t
id
:
# pid没有mid,拆了
# pid没有mid,拆了
log
.
warning
(
f
"pid={point_id} m
id={m
id} mid无效"
)
log
.
warning
(
f
"pid={point_id} m
tid={mt
id} mid无效"
)
continue
continue
meter_param
=
meter_param_map
.
get
(
mid
)
meter_param
=
meter_param_map
.
get
(
m
t
id
)
if
not
meter_param
:
if
not
meter_param
:
log
.
warning
(
f
"pid={point_id} m
id={m
id} 没有表参数"
)
log
.
warning
(
f
"pid={point_id} m
tid={mt
id} 没有表参数"
)
continue
continue
meter_vc
,
ctnum
=
meter_param
.
get
(
"vc"
),
meter_param
.
get
(
"ctnum"
)
or
3
meter_vc
,
ctnum
=
meter_param
.
get
(
"vc"
),
meter_param
.
get
(
"ctnum"
)
or
3
if
meter_vc
:
if
meter_vc
:
...
...
unify_api/modules/electric/procedures/electric_util.py
View file @
13285235
...
@@ -45,25 +45,16 @@ async def batch_get_wiring_type(point_ids):
...
@@ -45,25 +45,16 @@ async def batch_get_wiring_type(point_ids):
:return: ctnum, mid
:return: ctnum, mid
"""
"""
# 根据point_id去change_meter_record查询最新的mid
# 根据point_id去change_meter_record查询最新的mid
sql
=
"SELECT pid, m
id FROM change_meter_record
WHERE "
\
sql
=
"SELECT pid, m
tid, ctnum FROM point
WHERE "
\
"pid in
%
s ORDER BY pid,
start
_time"
"pid in
%
s ORDER BY pid,
create
_time"
async
with
MysqlUtil
()
as
conn
:
async
with
MysqlUtil
()
as
conn
:
change_meter_records
=
await
conn
.
fetchall
(
sql
,
args
=
(
point_ids
,))
if
point_ids
else
[]
change_meter_records
=
await
conn
.
fetchall
(
sql
,
args
=
(
new_meter_id_map
=
{
i
[
"pid"
]:
i
[
"mid"
]
for
i
in
change_meter_records
}
point_ids
,))
if
point_ids
else
[]
newest_mids
=
[
i
for
i
in
new_meter_id_map
.
values
()
if
i
]
point_info_map
=
{
# 2. 根据mid去meter_param_record查最新ctnum
i
[
"pid"
]:
i
for
i
in
change_meter_records
if
i
.
get
(
"pid"
)}
sql
=
"SELECT mid, ctnum FROM meter_param_record "
\
"WHERE mid in
%
s ORDER BY mid, start_time"
async
with
MysqlUtil
()
as
conn
:
meter_param_records
=
await
conn
.
fetchall
(
sql
,
args
=
(
newest_mids
,))
if
newest_mids
else
[]
meter_param_map
=
{
i
[
"mid"
]:
i
[
"ctnum"
]
for
i
in
meter_param_records
}
point_info_map
=
defaultdict
(
dict
)
for
pid
,
mid
in
new_meter_id_map
.
items
():
point_info_map
[
pid
]
=
{
"mid"
:
mid
,
"ctnum"
:
meter_param_map
.
get
(
mid
)}
return
point_info_map
return
point_info_map
...
...
unify_api/modules/shidianu/service/IntergratePipe.py
View file @
13285235
...
@@ -7,7 +7,6 @@ import os
...
@@ -7,7 +7,6 @@ import os
import
pandas
as
pd
import
pandas
as
pd
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
plt
.
rcParams
[
'font.sans-serif'
]
=
[
'SimHei'
]
plt
.
rcParams
[
'font.sans-serif'
]
=
[
'SimHei'
]
plt
.
rcParams
[
'axes.unicode_minus'
]
=
False
plt
.
rcParams
[
'axes.unicode_minus'
]
=
False
illegalConfig_hold
=
2500
illegalConfig_hold
=
2500
...
@@ -100,4 +99,3 @@ def addLabels(sid="sid", aircondRunStages="", electroRunStages="",
...
@@ -100,4 +99,3 @@ def addLabels(sid="sid", aircondRunStages="", electroRunStages="",
x
=
[
each
.
split
(
" "
)[
1
][:
-
3
]
for
each
in
timeAll
]
x
=
[
each
.
split
(
" "
)[
1
][:
-
3
]
for
each
in
timeAll
]
plt
.
show
()
plt
.
show
()
return
0
return
0
unify_api/modules/shidianu/service/aircondAnalysis.py
View file @
13285235
...
@@ -2,42 +2,56 @@ import time
...
@@ -2,42 +2,56 @@ import time
def
findStart
(
timeaircond
=
"timeaircond"
,
timeaircond_last
=
""
,
ahead
=
0
):
def
findStart
(
timeaircond
=
"timeaircond"
,
timeaircond_last
=
""
,
ahead
=
0
):
timeaircond_last_stemp
=
int
(
timeaircond_last_stemp
=
int
(
time
.
mktime
(
time
.
strptime
(
timeaircond_last
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)))
time
.
mktime
(
time
.
strptime
(
timeaircond_last
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)))
timeaircond_stemp
=
[
int
(
time
.
mktime
(
time
.
strptime
(
each_time
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)))
for
each_time
in
timeaircond
]
timeaircond_stemp
=
[
int
(
time
.
mktime
(
time
.
strptime
(
each_time
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)))
for
each_time
in
timeaircond
]
if
ahead
<
len
(
timeaircond
)
-
1
:
if
ahead
<
len
(
timeaircond
)
-
1
:
time_substruct
=
[
1000000
if
timeaircond_stemp
[
time_substruct
=
[
1000000
if
timeaircond_stemp
[
each_timeaircond_stemp
]
-
timeaircond_last_stemp
<=
0
or
each_timeaircond_stemp
<
ahead
else
each_timeaircond_stemp
]
-
timeaircond_last_stemp
<=
0
or
each_timeaircond_stemp
<
ahead
else
timeaircond_stemp
[
each_timeaircond_stemp
]
-
timeaircond_last_stemp
for
each_timeaircond_stemp
timeaircond_stemp
[
each_timeaircond_stemp
]
-
timeaircond_last_stemp
for
each_timeaircond_stemp
in
range
(
len
(
timeaircond_stemp
))]
in
range
(
len
(
timeaircond_stemp
))]
else
:
else
:
time_substruct
=
[
1000000
if
timeaircond_last_stemp
-
timeaircond_stemp
[
time_substruct
=
[
each_timeaircond_stemp
]
<=
0
or
each_timeaircond_stemp
<
ahead
else
timeaircond_last_stemp
-
1000000
if
timeaircond_last_stemp
-
timeaircond_stemp
[
timeaircond_stemp
[
each_timeaircond_stemp
]
<=
0
or
each_timeaircond_stemp
<
ahead
else
timeaircond_last_stemp
-
each_timeaircond_stemp
]
for
timeaircond_stemp
[
each_timeaircond_stemp
in
range
(
len
(
timeaircond_stemp
))]
each_timeaircond_stemp
]
for
each_timeaircond_stemp
in
range
(
len
(
timeaircond_stemp
))]
index
=
time_substruct
.
index
(
min
(
time_substruct
))
index
=
time_substruct
.
index
(
min
(
time_substruct
))
return
index
return
index
def
aircondAnalysis
(
statesaircond
=
""
,
statesaircond_off
=
""
,
timeaircond
=
""
,
timeaircond_off
=
""
,
eachdata_pow
=
""
,
eachdata_cur
=
""
,
timer
=
""
):
timeaircond_off_chang
=
[
each
.
split
(
" "
)[
1
][:
-
3
]
.
split
(
":"
)
for
each
in
timeaircond_off
]
def
aircondAnalysis
(
statesaircond
=
""
,
statesaircond_off
=
""
,
timeaircond
=
""
,
timeaircond_off_hour
=
[
each
[
0
]
for
each
in
timeaircond_off_chang
]
timeaircond_off
=
""
,
eachdata_pow
=
""
,
eachdata_cur
=
""
,
timer
=
""
):
timeaircond_off_chang
=
[
each
.
split
(
" "
)[
1
][:
-
3
]
.
split
(
":"
)
for
each
in
timeaircond_off
]
timeaircond_off_hour
=
[
each
[
0
]
for
each
in
timeaircond_off_chang
]
aircondRunStages
=
[]
aircondRunStages
=
[]
aircondRunStages
.
append
(
timeaircond
[
0
])
aircondRunStages
.
append
(
timeaircond
[
0
])
for
each_off
in
range
(
1
,
len
(
timeaircond_off
)):
for
each_off
in
range
(
1
,
len
(
timeaircond_off
)):
if
int
(
timeaircond_off_hour
[
-
1
])
-
int
(
timeaircond_off_hour
[
-
2
])
<=
2
and
each_off
==
len
(
timeaircond_off_hour
)
-
1
:
if
int
(
timeaircond_off_hour
[
-
1
])
-
int
(
timeaircond_off_hour
[
-
2
])
<=
2
and
each_off
==
len
(
timeaircond_off_hour
)
-
1
:
aircondRunStages
.
append
(
timeaircond_off
[
each_off
])
aircondRunStages
.
append
(
timeaircond_off
[
each_off
])
if
int
(
timeaircond_off_hour
[
each_off
])
-
int
(
timeaircond_off_hour
[
each_off
-
1
])
<=
2
:
if
int
(
timeaircond_off_hour
[
each_off
])
-
int
(
timeaircond_off_hour
[
each_off
-
1
])
<=
2
:
continue
continue
else
:
else
:
if
each_off
<
len
(
timeaircond
)
-
1
:
if
each_off
<
len
(
timeaircond
)
-
1
:
aircondRunStages
.
append
(
timeaircond_off
[
each_off
-
1
])
aircondRunStages
.
append
(
timeaircond_off
[
each_off
-
1
])
findStart1
=
findStart
(
timeaircond
=
timeaircond
,
timeaircond_last
=
timeaircond_off
[
each_off
-
1
],
ahead
=
each_off
)
findStart1
=
findStart
(
timeaircond
=
timeaircond
,
timeaircond_last
=
timeaircond_off
[
each_off
-
1
],
ahead
=
each_off
)
aircondRunStages
.
append
(
timeaircond
[
findStart1
])
aircondRunStages
.
append
(
timeaircond
[
findStart1
])
else
:
else
:
aircondRunStages
.
append
(
timeaircond_off
[
each_off
])
aircondRunStages
.
append
(
timeaircond_off
[
each_off
])
return
aircondRunStages
return
aircondRunStages
\ No newline at end of file
unify_api/modules/shidianu/service/componentStage.py
View file @
13285235
import
time
import
time
def
componentStage
(
aircondRunStages
=
""
,
electroRunStages
=
""
,
heaterRunStages
=
""
,
refrigRunStages
=
""
):
def
componentStage
(
aircondRunStages
=
""
,
electroRunStages
=
""
,
heaterRunStages
=
""
,
refrigRunStages
=
""
):
stageComponent
=
[]
stageComponent
=
[]
stampDict
=
{}
stampDict
=
{}
if
len
(
aircondRunStages
)
>
1
:
if
len
(
aircondRunStages
)
>
1
:
aircondRunStages_stemp
=
[
int
(
time
.
mktime
(
time
.
strptime
(
each
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)))
for
each
in
aircondRunStages_stemp
=
[
aircondRunStages
]
int
(
time
.
mktime
(
time
.
strptime
(
each
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)))
for
each
in
aircondRunStages
]
for
each_i
in
range
(
len
(
aircondRunStages_stemp
)):
for
each_i
in
range
(
len
(
aircondRunStages_stemp
)):
if
each_i
%
2
==
0
:
if
each_i
%
2
==
0
:
stampDict
[
aircondRunStages_stemp
[
each_i
]]
=
"开启空调"
stampDict
[
aircondRunStages_stemp
[
each_i
]]
=
"开启空调"
else
:
else
:
stampDict
[
aircondRunStages_stemp
[
each_i
]]
=
"关闭空调"
stampDict
[
aircondRunStages_stemp
[
each_i
]]
=
"关闭空调"
if
len
(
electroRunStages
)
>
1
:
if
len
(
electroRunStages
)
>
1
:
electroRunStages_stemp
=
[
int
(
time
.
mktime
(
time
.
strptime
(
each
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)))
for
each
in
electroRunStages_stemp
=
[
electroRunStages
]
int
(
time
.
mktime
(
time
.
strptime
(
each
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)))
for
each
in
electroRunStages
]
for
each_i
in
range
(
len
(
electroRunStages_stemp
)):
for
each_i
in
range
(
len
(
electroRunStages_stemp
)):
if
each_i
%
2
==
0
:
if
each_i
%
2
==
0
:
stampDict
[
electroRunStages_stemp
[
each_i
]]
=
"开启电磁炉"
stampDict
[
electroRunStages_stemp
[
each_i
]]
=
"开启电磁炉"
else
:
else
:
stampDict
[
electroRunStages_stemp
[
each_i
]]
=
"关闭电磁炉"
stampDict
[
electroRunStages_stemp
[
each_i
]]
=
"关闭电磁炉"
if
len
(
heaterRunStages
)
>
1
:
if
len
(
heaterRunStages
)
>
1
:
heaterRunStages_stemp
=
[
int
(
time
.
mktime
(
time
.
strptime
(
each
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)))
for
each
in
heaterRunStages
]
heaterRunStages_stemp
=
[
int
(
time
.
mktime
(
time
.
strptime
(
each
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)))
for
each
in
heaterRunStages
]
for
each_i
in
range
(
len
(
heaterRunStages_stemp
)):
for
each_i
in
range
(
len
(
heaterRunStages_stemp
)):
if
each_i
%
2
==
0
:
if
each_i
%
2
==
0
:
stampDict
[
heaterRunStages_stemp
[
each_i
]]
=
"开启热水器"
stampDict
[
heaterRunStages_stemp
[
each_i
]]
=
"开启热水器"
else
:
else
:
stampDict
[
heaterRunStages_stemp
[
each_i
]]
=
"关闭热水器"
stampDict
[
heaterRunStages_stemp
[
each_i
]]
=
"关闭热水器"
if
len
(
refrigRunStages
)
>
1
:
if
len
(
refrigRunStages
)
>
1
:
refrigRunStages_stemp
=
[
int
(
time
.
mktime
(
time
.
strptime
(
each
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)))
for
each
in
refrigRunStages
]
refrigRunStages_stemp
=
[
int
(
time
.
mktime
(
time
.
strptime
(
each
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)))
for
each
in
refrigRunStages
]
for
each_i
in
range
(
len
(
refrigRunStages_stemp
)):
for
each_i
in
range
(
len
(
refrigRunStages_stemp
)):
if
each_i
%
2
==
0
:
if
each_i
%
2
==
0
:
stampDict
[
refrigRunStages_stemp
[
each_i
]]
=
"开启电冰箱"
stampDict
[
refrigRunStages_stemp
[
each_i
]]
=
"开启电冰箱"
else
:
else
:
stampDict
[
refrigRunStages_stemp
[
each_i
]]
=
"关闭电冰箱"
stampDict
[
refrigRunStages_stemp
[
each_i
]]
=
"关闭电冰箱"
stampDict
=
sorted
(
stampDict
.
items
(),
key
=
lambda
d
:
d
[
0
])
stampDict
=
sorted
(
stampDict
.
items
(),
key
=
lambda
d
:
d
[
0
])
timeOrder
=
[
each
[
0
]
for
each
in
stampDict
]
timeOrder
=
[
each
[
0
]
for
each
in
stampDict
]
actionOrder
=
[
each
[
1
]
for
each
in
stampDict
]
actionOrder
=
[
each
[
1
]
for
each
in
stampDict
]
timeOrder
=
[
time
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
,
time
.
localtime
(
each
))
for
each
in
timeOrder
]
timeOrder
=
[
time
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
,
time
.
localtime
(
each
))
for
timestage
=
[]
each
in
timeOrder
]
timestage
=
[]
for
each_i
in
range
(
len
(
actionOrder
)):
for
each_i
in
range
(
len
(
actionOrder
)):
stageComponent
.
append
([])
stageComponent
.
append
([])
if
each_i
==
0
and
actionOrder
[
0
][:
2
]
==
"开启"
:
if
each_i
==
0
and
actionOrder
[
0
][:
2
]
==
"开启"
:
if
stageComponent
[
-
1
]
==
[]:
if
stageComponent
[
-
1
]
==
[]:
stageComponent
.
pop
(
-
1
)
stageComponent
.
pop
(
-
1
)
continue
continue
else
:
else
:
if
actionOrder
[
each_i
-
1
][:
2
]
==
"开启"
:
if
actionOrder
[
each_i
-
1
][:
2
]
==
"开启"
:
stageComponent
[
-
1
]
.
append
(
actionOrder
[
each_i
-
1
][
2
:]
+
"运行"
)
stageComponent
[
-
1
]
.
append
(
actionOrder
[
each_i
-
1
][
2
:]
+
"运行"
)
timestage
.
append
([
timeOrder
[
each_i
-
1
],
timeOrder
[
each_i
]])
timestage
.
append
([
timeOrder
[
each_i
-
1
],
timeOrder
[
each_i
]])
if
len
(
timestage
)
>
1
and
timestage
[
-
2
]
==
timestage
[
-
1
]:
if
len
(
timestage
)
>
1
and
timestage
[
-
2
]
==
timestage
[
-
1
]:
timestage
.
pop
(
-
1
)
timestage
.
pop
(
-
1
)
if
actionOrder
[:
each_i
]
.
count
(
"开启电冰箱"
)
>
actionOrder
[:
each_i
]
.
count
(
"关闭电冰箱"
)
and
actionOrder
[
each_i
-
1
]
!=
"开启电冰箱"
and
"电冰箱运行"
not
in
stageComponent
:
if
actionOrder
[:
each_i
]
.
count
(
"开启电冰箱"
)
>
actionOrder
[
:
each_i
]
.
count
(
"关闭电冰箱"
)
and
actionOrder
[
each_i
-
1
]
!=
"开启电冰箱"
and
"电冰箱运行"
not
in
stageComponent
:
stageComponent
[
-
1
]
.
append
(
"电冰箱运行"
)
stageComponent
[
-
1
]
.
append
(
"电冰箱运行"
)
timestage
.
append
([
timeOrder
[
each_i
-
1
],
timeOrder
[
each_i
]])
timestage
.
append
([
timeOrder
[
each_i
-
1
],
timeOrder
[
each_i
]])
if
len
(
timestage
)
>
1
and
timestage
[
-
2
]
==
timestage
[
-
1
]:
if
len
(
timestage
)
>
1
and
timestage
[
-
2
]
==
timestage
[
-
1
]:
timestage
.
pop
(
-
1
)
timestage
.
pop
(
-
1
)
if
actionOrder
[:
each_i
]
.
count
(
"开启电磁炉"
)
>
actionOrder
[:
each_i
]
.
count
(
"关闭电磁炉"
)
and
actionOrder
[
each_i
-
1
]
!=
"开启电磁炉"
and
"电磁炉运行"
not
in
stageComponent
:
if
actionOrder
[:
each_i
]
.
count
(
"开启电磁炉"
)
>
actionOrder
[
:
each_i
]
.
count
(
"关闭电磁炉"
)
and
actionOrder
[
each_i
-
1
]
!=
"开启电磁炉"
and
"电磁炉运行"
not
in
stageComponent
:
stageComponent
[
-
1
]
.
append
(
"电磁炉运行"
)
stageComponent
[
-
1
]
.
append
(
"电磁炉运行"
)
timestage
.
append
([
timeOrder
[
each_i
-
1
],
timeOrder
[
each_i
]])
timestage
.
append
([
timeOrder
[
each_i
-
1
],
timeOrder
[
each_i
]])
if
len
(
timestage
)
>
1
and
timestage
[
-
2
]
==
timestage
[
-
1
]:
if
len
(
timestage
)
>
1
and
timestage
[
-
2
]
==
timestage
[
-
1
]:
timestage
.
pop
(
-
1
)
timestage
.
pop
(
-
1
)
if
actionOrder
[:
each_i
]
.
count
(
"开启热水器"
)
>
actionOrder
[:
each_i
]
.
count
(
"关闭热水器"
)
and
actionOrder
[
each_i
-
1
]
!=
"开启热水器"
and
"热水器运行"
not
in
stageComponent
:
if
actionOrder
[:
each_i
]
.
count
(
"开启热水器"
)
>
actionOrder
[
:
each_i
]
.
count
(
"关闭热水器"
)
and
actionOrder
[
each_i
-
1
]
!=
"开启热水器"
and
"热水器运行"
not
in
stageComponent
:
stageComponent
[
-
1
]
.
append
(
"热水器运行"
)
stageComponent
[
-
1
]
.
append
(
"热水器运行"
)
timestage
.
append
([
timeOrder
[
each_i
-
1
],
timeOrder
[
each_i
]])
timestage
.
append
([
timeOrder
[
each_i
-
1
],
timeOrder
[
each_i
]])
if
len
(
timestage
)
>
1
and
timestage
[
-
2
]
==
timestage
[
-
1
]:
if
len
(
timestage
)
>
1
and
timestage
[
-
2
]
==
timestage
[
-
1
]:
timestage
.
pop
(
-
1
)
timestage
.
pop
(
-
1
)
if
actionOrder
[:
each_i
]
.
count
(
"开启空调"
)
>
actionOrder
[:
each_i
]
.
count
(
"关闭空调"
)
and
actionOrder
[
each_i
-
1
]
!=
"开启空调"
and
"空调运行"
not
in
stageComponent
:
if
actionOrder
[:
each_i
]
.
count
(
"开启空调"
)
>
actionOrder
[:
each_i
]
.
count
(
"关闭空调"
)
and
actionOrder
[
each_i
-
1
]
!=
"开启空调"
and
"空调运行"
not
in
stageComponent
:
stageComponent
[
-
1
]
.
append
(
"空调运行"
)
stageComponent
[
-
1
]
.
append
(
"空调运行"
)
timestage
.
append
([
timeOrder
[
each_i
-
1
],
timeOrder
[
each_i
]])
timestage
.
append
([
timeOrder
[
each_i
-
1
],
timeOrder
[
each_i
]])
if
len
(
timestage
)
>
1
and
timestage
[
-
2
]
==
timestage
[
-
1
]:
if
len
(
timestage
)
>
1
and
timestage
[
-
2
]
==
timestage
[
-
1
]:
timestage
.
pop
(
-
1
)
timestage
.
pop
(
-
1
)
if
stageComponent
[
-
1
]
==
[]:
if
stageComponent
[
-
1
]
==
[]:
stageComponent
.
pop
(
-
1
)
stageComponent
.
pop
(
-
1
)
return
stageComponent
,
timestage
,
timeOrder
,
actionOrder
return
stageComponent
,
timestage
,
timeOrder
,
actionOrder
unify_api/modules/shidianu/service/decomp_main.py
View file @
13285235
...
@@ -23,16 +23,40 @@ def pieceWise(eachdata, params="params"):
...
@@ -23,16 +23,40 @@ def pieceWise(eachdata, params="params"):
heaterRunStages
=
[]
heaterRunStages
=
[]
statesaircond
,
statesrefrig
,
stateselectro
,
statesricecook
,
statesheater
,
timeaircond
,
timerefrig
,
timericecook
,
timeelectro
,
timeheater
,
statesaircond_off
,
statesrefrig_off
,
stateselectro_off
,
statesricecook_off
,
statesheater_off
,
timeaircond_off
,
timerefrig_off
,
timericecook_off
,
timeelectro_off
,
timeheater_off
=
piececlassfy
(
statesaircond
,
statesrefrig
,
stateselectro
,
statesricecook
,
statesheater
,
timeaircond
,
timerefrig
,
timericecook
,
timeelectro
,
timeheater
,
statesaircond_off
,
statesrefrig_off
,
stateselectro_off
,
statesricecook_off
,
statesheater_off
,
timeaircond_off
,
timerefrig_off
,
timericecook_off
,
timeelectro_off
,
timeheater_off
=
piececlassfy
(
current
=
eachdata_cur
,
power
=
eachdata_pow
,
timer
=
timer
,
params
=
params
)
current
=
eachdata_cur
,
power
=
eachdata_pow
,
timer
=
timer
,
params
=
params
)
if
len
(
statesaircond_off
)
>
0
:
if
len
(
statesaircond_off
)
>
0
:
aircondRunStages
=
aircondAnalysis
(
statesaircond
=
statesaircond
,
statesaircond_off
=
statesaircond_off
,
timeaircond
=
timeaircond
,
timeaircond_off
=
timeaircond_off
,
eachdata_pow
=
eachdata_pow
,
eachdata_cur
=
eachdata_cur
,
timer
=
timer
)
aircondRunStages
=
aircondAnalysis
(
statesaircond
=
statesaircond
,
statesaircond_off
=
statesaircond_off
,
timeaircond
=
timeaircond
,
timeaircond_off
=
timeaircond_off
,
eachdata_pow
=
eachdata_pow
,
eachdata_cur
=
eachdata_cur
,
timer
=
timer
)
#
#
if
len
(
stateselectro
)
>
0
:
if
len
(
stateselectro
)
>
0
:
electroRunStages
=
electroAnalysis
(
stateselectro
=
stateselectro
,
stateselectro_off
=
stateselectro_off
,
timeelectro
=
timeelectro
,
timeelectro_off
=
timeelectro_off
,
eachdata_pow
=
eachdata_pow
,
eachdata_cur
=
eachdata_cur
,
timer
=
timer
)
electroRunStages
=
electroAnalysis
(
stateselectro
=
stateselectro
,
stateselectro_off
=
stateselectro_off
,
timeelectro
=
timeelectro
,
timeelectro_off
=
timeelectro_off
,
eachdata_pow
=
eachdata_pow
,
eachdata_cur
=
eachdata_cur
,
timer
=
timer
)
if
len
(
statesheater
)
>
0
:
if
len
(
statesheater
)
>
0
:
heaterRunStages
=
heaterAnalysis
(
statesheater
=
statesheater
,
statesheater_off
=
statesheater_off
,
timeheater
=
timeheater
,
timeheater_off
=
timeheater_off
,
eachdata_pow
=
eachdata_pow
,
eachdata_cur
=
eachdata_cur
,
timer
=
timer
)
heaterRunStages
=
heaterAnalysis
(
statesheater
=
statesheater
,
statesheater_off
=
statesheater_off
,
timeheater
=
timeheater
,
timeheater_off
=
timeheater_off
,
eachdata_pow
=
eachdata_pow
,
eachdata_cur
=
eachdata_cur
,
timer
=
timer
)
if
len
(
statesrefrig
)
>
0
:
if
len
(
statesrefrig
)
>
0
:
refrigRunStages
=
refrigAnalysis
(
statesrefrig
=
statesrefrig
,
statesrefrig_off
=
statesrefrig_off
,
timerefrig
=
timerefrig
,
timerefrig_off
=
timerefrig_off
,
eachdata_pow
=
eachdata_pow
,
eachdata_cur
=
eachdata_cur
,
timer
=
timer
)
refrigRunStages
=
refrigAnalysis
(
statesrefrig
=
statesrefrig
,
statesrefrig_off
=
statesrefrig_off
,
timerefrig
=
timerefrig
,
timerefrig_off
=
timerefrig_off
,
eachdata_pow
=
eachdata_pow
,
eachdata_cur
=
eachdata_cur
,
timer
=
timer
)
return
aircondRunStages
,
electroRunStages
,
heaterRunStages
,
refrigRunStages
return
aircondRunStages
,
electroRunStages
,
heaterRunStages
,
refrigRunStages
unify_api/modules/shidianu/service/electricProportion.py
View file @
13285235
This diff is collapsed.
Click to expand it.
unify_api/modules/shidianu/service/electroAnalysis.py
View file @
13285235
...
@@ -2,36 +2,46 @@ import time
...
@@ -2,36 +2,46 @@ import time
def
findStart
(
timeelectro
=
"timeelectro"
,
timeelectro_last
=
""
,
ahead
=
0
):
def
findStart
(
timeelectro
=
"timeelectro"
,
timeelectro_last
=
""
,
ahead
=
0
):
timeelectro_last_stemp
=
int
(
timeelectro_last_stemp
=
int
(
time
.
mktime
(
time
.
strptime
(
timeelectro_last
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)))
time
.
mktime
(
time
.
strptime
(
timeelectro_last
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)))
timeelectro_stemp
=
[
int
(
time
.
mktime
(
time
.
strptime
(
each_time
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)))
for
each_time
in
timeelectro
]
timeelectro_stemp
=
[
int
(
time
.
mktime
(
time
.
strptime
(
each_time
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)))
for
each_time
in
timeelectro
]
if
ahead
<
len
(
timeelectro
)
-
1
:
if
ahead
<
len
(
timeelectro
)
-
1
:
time_substruct
=
[
1000000
if
timeelectro_stemp
[
time_substruct
=
[
1000000
if
timeelectro_stemp
[
each_timeelectro_stemp
]
-
timeelectro_last_stemp
<=
0
or
each_timeelectro_stemp
<
ahead
else
each_timeelectro_stemp
]
-
timeelectro_last_stemp
<=
0
or
each_timeelectro_stemp
<
ahead
else
timeelectro_stemp
[
each_timeelectro_stemp
]
-
timeelectro_last_stemp
for
each_timeelectro_stemp
timeelectro_stemp
[
each_timeelectro_stemp
]
-
timeelectro_last_stemp
for
each_timeelectro_stemp
in
range
(
len
(
timeelectro_stemp
))]
in
range
(
len
(
timeelectro_stemp
))]
else
:
else
:
time_substruct
=
[
1000000
if
timeelectro_last_stemp
-
timeelectro_stemp
[
time_substruct
=
[
each_timeelectro_stemp
]
<=
0
or
each_timeelectro_stemp
<
ahead
else
timeelectro_last_stemp
-
1000000
if
timeelectro_last_stemp
-
timeelectro_stemp
[
timeelectro_stemp
[
each_timeelectro_stemp
]
<=
0
or
each_timeelectro_stemp
<
ahead
else
timeelectro_last_stemp
-
each_timeelectro_stemp
]
for
timeelectro_stemp
[
each_timeelectro_stemp
in
range
(
len
(
timeelectro_stemp
))]
each_timeelectro_stemp
]
for
each_timeelectro_stemp
in
range
(
len
(
timeelectro_stemp
))]
index
=
time_substruct
.
index
(
min
(
time_substruct
))
index
=
time_substruct
.
index
(
min
(
time_substruct
))
return
index
return
index
def
electroAnalysis
(
stateselectro
=
"stateselectro"
,
stateselectro_off
=
"stateselectro_off"
def
electroAnalysis
(
stateselectro
=
"stateselectro"
,
,
timeelectro
=
"timeelectro"
,
timeelectro_off
=
"timeelectro_off"
,
eachdata_pow
=
"eachdata_pow"
stateselectro_off
=
"stateselectro_off"
,
timeelectro
=
"timeelectro"
,
timeelectro_off
=
"timeelectro_off"
,
eachdata_pow
=
"eachdata_pow"
,
eachdata_cur
=
"eachdata_cur"
,
timer
=
"timer"
):
,
eachdata_cur
=
"eachdata_cur"
,
timer
=
"timer"
):
electroRunStages
=
[]
electroRunStages
=
[]
timeelectro_chang
=
[
each
.
split
(
" "
)[
1
][:
-
3
]
.
split
(
":"
)
for
each
in
timeelectro_chang
=
[
each
.
split
(
" "
)[
1
][:
-
3
]
.
split
(
":"
)
for
each
in
timeelectro
]
timeelectro
]
timeelectro_hour
=
[
each
[
0
]
for
each
in
timeelectro_chang
]
timeelectro_hour
=
[
each
[
0
]
for
each
in
timeelectro_chang
]
timeelectro_minute
=
[
each
[
1
]
for
each
in
timeelectro_chang
]
timeelectro_minute
=
[
each
[
1
]
for
each
in
timeelectro_chang
]
timeelectro_off_chang
=
[
each
.
split
(
" "
)[
1
][:
-
3
]
.
split
(
":"
)
for
each
in
timeelectro_off
]
timeelectro_off_chang
=
[
each
.
split
(
" "
)[
1
][:
-
3
]
.
split
(
":"
)
for
each
in
timeelectro_off
]
timeelectro_off_hour
=
[
each
[
0
]
for
each
in
timeelectro_off_chang
]
timeelectro_off_hour
=
[
each
[
0
]
for
each
in
timeelectro_off_chang
]
timeelectro_off_minute
=
[
each
[
1
]
for
each
in
timeelectro_off_chang
]
timeelectro_off_minute
=
[
each
[
1
]
for
each
in
timeelectro_off_chang
]
...
@@ -40,22 +50,30 @@ def electroAnalysis(stateselectro="stateselectro", stateselectro_off="stateselec
...
@@ -40,22 +50,30 @@ def electroAnalysis(stateselectro="stateselectro", stateselectro_off="stateselec
electroRunStages
.
append
(
timeelectro
[
0
])
electroRunStages
.
append
(
timeelectro
[
0
])
for
each_off
in
range
(
1
,
len
(
timeelectro_off
)):
for
each_off
in
range
(
1
,
len
(
timeelectro_off
)):
# if each_off==len(timeaircond_off)-1:
# if each_off==len(timeaircond_off)-1:
if
int
(
timeelectro_off_hour
[
-
1
])
-
int
(
timeelectro_off_hour
[
-
2
])
>
2
and
each_off
==
len
(
if
int
(
timeelectro_off_hour
[
-
1
])
-
int
(
timeelectro_off_hour
[
-
2
])
>
2
and
each_off
==
len
(
timeelectro_off_hour
)
-
1
:
timeelectro_off_hour
)
-
1
:
if
flag
==
1
:
if
flag
==
1
:
index
=
findStart
(
timeelectro
=
timeelectro
,
timeelectro_last
=
timeelectro_off
[
each_off
],
ahead
=
each_off
)
index
=
findStart
(
timeelectro
=
timeelectro
,
timeelectro_last
=
timeelectro_off
[
each_off
],
ahead
=
each_off
)
electroRunStages
.
append
(
timeelectro
[
index
])
electroRunStages
.
append
(
timeelectro
[
index
])
electroRunStages
.
append
(
timeelectro_off
[
each_off
])
electroRunStages
.
append
(
timeelectro_off
[
each_off
])
elif
int
(
timeelectro_off_hour
[
each_off
])
-
int
(
timeelectro_off_hour
[
each_off
-
1
])
<=
1
:
elif
int
(
timeelectro_off_hour
[
each_off
])
-
int
(
timeelectro_off_hour
[
each_off
-
1
])
<=
1
:
continue
continue
else
:
else
:
if
each_off
<
len
(
timeelectro_off_hour
)
-
1
:
if
each_off
<
len
(
timeelectro_off_hour
)
-
1
:
electroRunStages
.
append
(
timeelectro_off
[
each_off
-
1
])
electroRunStages
.
append
(
timeelectro_off
[
each_off
-
1
])
index
=
findStart
(
timeelectro
=
timeelectro
,
timeelectro_last
=
timeelectro_off
[
each_off
-
1
],
index
=
findStart
(
timeelectro
=
timeelectro
,
timeelectro_last
=
timeelectro_off
[
each_off
-
1
],
ahead
=
each_off
)
ahead
=
each_off
)
electroRunStages
.
append
(
timeelectro
[
index
])
electroRunStages
.
append
(
timeelectro
[
index
])
if
int
(
timeelectro_off_hour
[
each_off
])
-
int
(
timeelectro_hour
[
index
])
<=
1
and
int
(
if
int
(
timeelectro_off_hour
[
each_off
])
-
int
(
timeelectro_off_hour
[
each_off
])
-
int
(
timeelectro_off_hour
[
each_off
+
1
])
<
-
1
:
timeelectro_hour
[
index
])
<=
1
and
int
(
timeelectro_off_hour
[
each_off
])
-
int
(
timeelectro_off_hour
[
each_off
+
1
])
<
-
1
:
electroRunStages
.
append
(
timeelectro_off
[
each_off
])
electroRunStages
.
append
(
timeelectro_off
[
each_off
])
flag
=
1
flag
=
1
...
...
unify_api/modules/shidianu/service/heaterAnalysis.py
View file @
13285235
import
time
import
time
def
findStart
(
timeheater
=
"timeheater"
,
timeheater_last
=
""
,
ahead
=
0
):
timeelectro_last_stemp
=
int
(
time
.
mktime
(
time
.
strptime
(
timeheater_last
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)))
def
findStart
(
timeheater
=
"timeheater"
,
timeheater_last
=
""
,
ahead
=
0
):
timeelectro_stemp
=
[
int
(
time
.
mktime
(
time
.
strptime
(
each_time
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)))
for
each_time
in
timeheater
]
timeelectro_last_stemp
=
int
(
time
.
mktime
(
time
.
strptime
(
timeheater_last
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)))
timeelectro_stemp
=
[
int
(
time
.
mktime
(
time
.
strptime
(
each_time
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)))
for
each_time
in
timeheater
]
if
ahead
<
len
(
timeheater
)
-
1
:
if
ahead
<
len
(
timeheater
)
-
1
:
time_substruct
=
[
1000000
if
timeelectro_stemp
[
time_substruct
=
[
1000000
if
timeelectro_stemp
[
each_timeelectro_stemp
]
-
timeelectro_last_stemp
<=
0
or
each_timeelectro_stemp
<
ahead
else
each_timeelectro_stemp
]
-
timeelectro_last_stemp
<=
0
or
each_timeelectro_stemp
<
ahead
else
timeelectro_stemp
[
each_timeelectro_stemp
]
-
timeelectro_last_stemp
for
each_timeelectro_stemp
timeelectro_stemp
[
each_timeelectro_stemp
]
-
timeelectro_last_stemp
for
each_timeelectro_stemp
in
range
(
len
(
timeelectro_stemp
))]
in
range
(
len
(
timeelectro_stemp
))]
else
:
else
:
time_substruct
=
[
1000000
if
timeelectro_last_stemp
-
timeelectro_stemp
[
time_substruct
=
[
each_timeelectro_stemp
]
<=
0
or
each_timeelectro_stemp
<
ahead
else
timeelectro_last_stemp
-
1000000
if
timeelectro_last_stemp
-
timeelectro_stemp
[
timeelectro_stemp
[
each_timeelectro_stemp
]
<=
0
or
each_timeelectro_stemp
<
ahead
else
timeelectro_last_stemp
-
each_timeelectro_stemp
]
for
timeelectro_stemp
[
each_timeelectro_stemp
in
range
(
len
(
timeelectro_stemp
))]
each_timeelectro_stemp
]
for
each_timeelectro_stemp
in
range
(
len
(
timeelectro_stemp
))]
index
=
time_substruct
.
index
(
min
(
time_substruct
))
index
=
time_substruct
.
index
(
min
(
time_substruct
))
return
index
return
index
def
heaterAnalysis
(
statesheater
=
"statesheater"
,
statesheater_off
=
""
,
timeheater
=
"timeheater"
,
def
heaterAnalysis
(
statesheater
=
"statesheater"
,
statesheater_off
=
""
,
timeheater_off
=
"timeheater_off"
,
eachdata_pow
=
"eachdata_pow"
,
eachdata_cur
=
"eachdata_cur"
,
timeheater
=
"timeheater"
,
timeheater_off
=
"timeheater_off"
,
eachdata_pow
=
"eachdata_pow"
,
eachdata_cur
=
"eachdata_cur"
,
timer
=
"timer"
):
timer
=
"timer"
):
heaterRunStages
=
[]
heaterRunStages
=
[]
timeheater_chang
=
[
each
.
split
(
" "
)[
1
][:
-
3
]
.
split
(
":"
)
for
each
in
timeheater
]
timeheater_chang
=
[
each
.
split
(
" "
)[
1
][:
-
3
]
.
split
(
":"
)
for
each
in
timeheater
]
timeheater_hour
=
[
each
[
0
]
for
each
in
timeheater_chang
]
timeheater_hour
=
[
each
[
0
]
for
each
in
timeheater_chang
]
timeheater_minute
=
[
each
[
1
]
for
each
in
timeheater_chang
]
timeheater_minute
=
[
each
[
1
]
for
each
in
timeheater_chang
]
timeheater_off_chang
=
[
each
.
split
(
" "
)[
1
][:
-
3
]
.
split
(
":"
)
for
each
in
timeheater_off
]
timeheater_off_chang
=
[
each
.
split
(
" "
)[
1
][:
-
3
]
.
split
(
":"
)
for
each
in
timeheater_off
]
timeheater_off_hour
=
[
each
[
0
]
for
each
in
timeheater_off_chang
]
timeheater_off_hour
=
[
each
[
0
]
for
each
in
timeheater_off_chang
]
timeheater_off_minute
=
[
each
[
1
]
for
each
in
timeheater_off_chang
]
timeheater_off_minute
=
[
each
[
1
]
for
each
in
timeheater_off_chang
]
...
@@ -39,22 +50,30 @@ def heaterAnalysis(statesheater="statesheater", statesheater_off="", timeheater=
...
@@ -39,22 +50,30 @@ def heaterAnalysis(statesheater="statesheater", statesheater_off="", timeheater=
for
each_off
in
range
(
1
,
len
(
timeheater_off
)):
for
each_off
in
range
(
1
,
len
(
timeheater_off
)):
# if each_off==len(timeaircond_off)-1:
# if each_off==len(timeaircond_off)-1:
if
int
(
timeheater_off_hour
[
-
1
])
-
int
(
timeheater_off_hour
[
-
2
])
>
2
and
each_off
==
len
(
if
int
(
timeheater_off_hour
[
-
1
])
-
int
(
timeheater_off_hour
[
-
2
])
>
2
and
each_off
==
len
(
timeheater_off_hour
)
-
1
:
timeheater_off_hour
)
-
1
:
if
flag
==
1
:
if
flag
==
1
:
index
=
findStart
(
timeheater
=
timeheater
,
timeheater_last
=
timeheater_off
[
each_off
],
ahead
=
each_off
)
index
=
findStart
(
timeheater
=
timeheater
,
timeheater_last
=
timeheater_off
[
each_off
],
ahead
=
each_off
)
heaterRunStages
.
append
(
timeheater
[
index
])
heaterRunStages
.
append
(
timeheater
[
index
])
heaterRunStages
.
append
(
timeheater_off
[
each_off
])
heaterRunStages
.
append
(
timeheater_off
[
each_off
])
elif
int
(
timeheater_off_hour
[
each_off
])
-
int
(
timeheater_off_hour
[
each_off
-
1
])
<=
1
:
elif
int
(
timeheater_off_hour
[
each_off
])
-
int
(
timeheater_off_hour
[
each_off
-
1
])
<=
1
:
continue
continue
else
:
else
:
if
each_off
<
len
(
timeheater
)
-
1
:
if
each_off
<
len
(
timeheater
)
-
1
:
heaterRunStages
.
append
(
timeheater_off
[
each_off
-
1
])
heaterRunStages
.
append
(
timeheater_off
[
each_off
-
1
])
index
=
findStart
(
timeheater
=
timeheater
,
timeheater_last
=
timeheater_off
[
each_off
-
1
],
index
=
findStart
(
timeheater
=
timeheater
,
timeheater_last
=
timeheater_off
[
each_off
-
1
],
ahead
=
each_off
)
ahead
=
each_off
)
heaterRunStages
.
append
(
timeheater
[
index
])
heaterRunStages
.
append
(
timeheater
[
index
])
if
int
(
timeheater_off_hour
[
each_off
])
-
int
(
timeheater_hour
[
index
])
<=
1
and
int
(
if
int
(
timeheater_off_hour
[
each_off
])
-
int
(
timeheater_off_hour
[
each_off
])
-
int
(
timeheater_off_hour
[
each_off
+
1
])
<
-
1
:
timeheater_hour
[
index
])
<=
1
and
int
(
timeheater_off_hour
[
each_off
])
-
int
(
timeheater_off_hour
[
each_off
+
1
])
<
-
1
:
heaterRunStages
.
append
(
timeheater_off
[
each_off
])
heaterRunStages
.
append
(
timeheater_off
[
each_off
])
flag
=
1
flag
=
1
...
...
unify_api/modules/shidianu/service/highPower.py
View file @
13285235
...
@@ -94,7 +94,7 @@ def bigPowerReg(eachdata="powerdata", key="a"):
...
@@ -94,7 +94,7 @@ def bigPowerReg(eachdata="powerdata", key="a"):
timethr
=
timethr
+
1
timethr
=
timethr
+
1
flag3
=
1
flag3
=
1
equips
=
likesEquip
(
time
=
res
[
0
::
2
])
equips
=
likesEquip
(
time
=
res
[
0
::
2
])
timer
=
[
str
(
each
)
for
each
in
res
[
0
::
2
]]
timer
=
[
str
(
each
)
for
each
in
res
[
0
::
2
]]
return
timer
,
equips
return
timer
,
equips
...
@@ -199,10 +199,9 @@ def vioPowerReg(eachdata="powerdata", key="a"):
...
@@ -199,10 +199,9 @@ def vioPowerReg(eachdata="powerdata", key="a"):
if
flag1
==
1
and
powerdata
[
i
]
*
1000
>
viopowerone
[
1
]:
if
flag1
==
1
and
powerdata
[
i
]
*
1000
>
viopowerone
[
1
]:
timeone
=
timeone
+
1
timeone
=
timeone
+
1
continue
continue
timer
=
[
str
(
each
)
for
each
in
res
]
timer
=
[
str
(
each
)
for
each
in
res
]
return
timer
,
equips
return
timer
,
equips
# plt.rcParams['font.sans-serif'] = ['SimHei']
# plt.rcParams['font.sans-serif'] = ['SimHei']
# plt.rcParams['axes.unicode_minus'] = False
# plt.rcParams['axes.unicode_minus'] = False
#
#
...
...
unify_api/modules/shidianu/service/open_data_service.py
View file @
13285235
...
@@ -21,7 +21,7 @@ from pot_libs.aredis_util.aredis_utils import RedisUtils
...
@@ -21,7 +21,7 @@ from pot_libs.aredis_util.aredis_utils import RedisUtils
from
unify_api.utils
import
time_format
from
unify_api.utils
import
time_format
async
def
basic_info_longgang_service
(
user_id
,
page_size
,
page_num
):
async
def
basic_info_longgang_service
(
user_id
,
page_size
,
page_num
):
# 1.验证权限
# 1.验证权限
cids
=
[
223
]
cids
=
[
223
]
is_auth
=
await
get_power
(
user_id
,
cids
)
is_auth
=
await
get_power
(
user_id
,
cids
)
...
@@ -236,7 +236,8 @@ async def result_longgang_service(user_id, importance, page_size, page_num):
...
@@ -236,7 +236,8 @@ async def result_longgang_service(user_id, importance, page_size, page_num):
is_auth
=
await
get_power
(
user_id
,
cids
)
is_auth
=
await
get_power
(
user_id
,
cids
)
if
not
is_auth
:
if
not
is_auth
:
return
success_res
(
code
=
4001
,
msg
=
"您没有权限访问"
)
return
success_res
(
code
=
4001
,
msg
=
"您没有权限访问"
)
es_res
=
await
result_longgang_by_cid
(
cids
,
page_num
,
page_size
,
importance
)
es_res
=
await
result_longgang_by_cid
(
cids
,
page_num
,
page_size
,
importance
)
if
not
es_res
[
"hits"
][
"hits"
]:
if
not
es_res
[
"hits"
][
"hits"
]:
return
ListAlarmResponse
(
total
=
0
,
rows
=
[])
return
ListAlarmResponse
(
total
=
0
,
rows
=
[])
# 2. 构建返回数据
# 2. 构建返回数据
...
@@ -247,7 +248,7 @@ async def result_longgang_service(user_id, importance, page_size, page_num):
...
@@ -247,7 +248,7 @@ async def result_longgang_service(user_id, importance, page_size, page_num):
mp_map
[
mp_list
[
"pid"
]]
=
{
mp_map
[
mp_list
[
"pid"
]]
=
{
"sid"
:
mp_list
[
"sid"
],
"mtid"
:
mp_list
[
"mtid"
],
"sid"
:
mp_list
[
"sid"
],
"mtid"
:
mp_list
[
"mtid"
],
"storey_name"
:
mp_list
[
"storey_name"
],
"storey_name"
:
mp_list
[
"storey_name"
],
"room_name"
:
mp_list
[
"room_name"
],
"room_name"
:
mp_list
[
"room_name"
],
"fullname"
:
mp_list
[
"fullname"
],
"fullname"
:
mp_list
[
"fullname"
],
}
}
...
...
unify_api/modules/shidianu/service/paramAnaly.py
View file @
13285235
...
@@ -198,7 +198,7 @@ async def params_mining(date_time_list, sid, sn):
...
@@ -198,7 +198,7 @@ async def params_mining(date_time_list, sid, sn):
pd
.
to_datetime
(
day_time_all
[
i
],
format
=
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
for
pd
.
to_datetime
(
day_time_all
[
i
],
format
=
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
for
i
in
range
(
len
(
day_time_all
))]
i
in
range
(
len
(
day_time_all
))]
power_pa_Series
=
pd
.
Series
(
power_pa
,
index
=
day_time_all
)
power_pa_Series
=
pd
.
Series
(
power_pa
,
index
=
day_time_all
)
power_pa_Series
=
power_pa_Series
.
interpolate
(
method
=
'nearest'
)
power_pa_Series
=
power_pa_Series
.
interpolate
(
method
=
'nearest'
)
# power_pb_Series = pd.Series(power_pb, index=day_time_all)
# power_pb_Series = pd.Series(power_pb, index=day_time_all)
# power_pc_Series = pd.Series(power_pc, index=day_time_all)
# power_pc_Series = pd.Series(power_pc, index=day_time_all)
...
...
unify_api/modules/shidianu/service/pieceClassify.py
View file @
13285235
...
@@ -2,7 +2,8 @@ import numpy as np
...
@@ -2,7 +2,8 @@ import numpy as np
import
re
import
re
def
piececlassfy
(
current
=
"eachnode_cur"
,
power
=
"eachnode_pow"
,
timer
=
"timer"
,
params
=
"params"
):
def
piececlassfy
(
current
=
"eachnode_cur"
,
power
=
"eachnode_pow"
,
timer
=
"timer"
,
params
=
"params"
):
month
=
timer
[
0
]
.
split
(
" "
)[
0
]
.
split
(
"-"
)[
1
]
month
=
timer
[
0
]
.
split
(
" "
)[
0
]
.
split
(
"-"
)[
1
]
day
=
timer
[
0
]
.
split
(
" "
)[
0
]
.
split
(
"-"
)[
2
]
day
=
timer
[
0
]
.
split
(
" "
)[
0
]
.
split
(
"-"
)[
2
]
hours
=
[
each
.
split
(
" "
)[
1
]
.
split
(
":"
)[
0
]
for
each
in
timer
]
hours
=
[
each
.
split
(
" "
)[
1
]
.
split
(
":"
)[
0
]
for
each
in
timer
]
...
@@ -35,7 +36,8 @@ def piececlassfy(current="eachnode_cur", power="eachnode_pow", timer="timer", pa
...
@@ -35,7 +36,8 @@ def piececlassfy(current="eachnode_cur", power="eachnode_pow", timer="timer", pa
timeelectro_off
=
[]
timeelectro_off
=
[]
timeheater_off
=
[]
timeheater_off
=
[]
quannums
=
[
.01
,
.03
,
.05
,
.1
,
.2
,
.3
,
.4
,
.5
,
.6
,
.7
,
.8
,
.9
,
.95
,
.98
,
.99
]
quannums
=
[
.01
,
.03
,
.05
,
.1
,
.2
,
.3
,
.4
,
.5
,
.6
,
.7
,
.8
,
.9
,
.95
,
.98
,
.99
]
opernumstate
=
[]
opernumstate
=
[]
for
i
in
range
(
dataLen
):
for
i
in
range
(
dataLen
):
if
i
==
0
:
if
i
==
0
:
...
@@ -55,48 +57,60 @@ def piececlassfy(current="eachnode_cur", power="eachnode_pow", timer="timer", pa
...
@@ -55,48 +57,60 @@ def piececlassfy(current="eachnode_cur", power="eachnode_pow", timer="timer", pa
his_p
.
append
(
now_p
[
0
])
his_p
.
append
(
now_p
[
0
])
now_p
=
now_p
[
-
5
:]
now_p
=
now_p
[
-
5
:]
now_i
=
now_i
[
-
5
:]
now_i
=
now_i
[
-
5
:]
if
1000
*
(
now_p
[
0
]
-
his_p
[
-
1
])
>
params
[
0
]
-
50
and
1000
*
(
now_p
[
0
]
-
his_p
[
-
1
])
<
min
(
params
[
1
:])
+
50
:
if
1000
*
(
now_p
[
0
]
-
his_p
[
-
1
])
>
params
[
0
]
-
50
and
1000
*
(
now_p
[
0
]
-
his_p
[
-
1
])
<
min
(
params
[
1
:])
+
50
:
statesrefrig
.
append
(
"电冰箱运行"
)
statesrefrig
.
append
(
"电冰箱运行"
)
timerefrig
.
append
(
timer
[
i
])
timerefrig
.
append
(
timer
[
i
])
if
1000
*
(
now_p
[
0
]
-
his_p
[
-
1
])
>
params
[
1
]
-
50
and
1000
*
(
now_p
[
0
]
-
his_p
[
-
1
])
<
min
(
params
[
2
:])
+
50
:
if
1000
*
(
now_p
[
0
]
-
his_p
[
-
1
])
>
params
[
1
]
-
50
and
1000
*
(
now_p
[
0
]
-
his_p
[
-
1
])
<
min
(
params
[
2
:])
+
50
:
statesaircond
.
append
(
"空调运行"
)
statesaircond
.
append
(
"空调运行"
)
timeaircond
.
append
(
timer
[
i
])
timeaircond
.
append
(
timer
[
i
])
if
1000
*
(
now_p
[
0
]
-
his_p
[
-
1
])
>
min
(
params
[
2
:])
-
50
and
(
if
1000
*
(
now_p
[
0
]
-
his_p
[
-
1
])
>
min
(
params
[
2
:])
-
50
and
(
int
(
hours
[
i
])
>=
22
or
int
(
hours
[
i
])
<
5
or
int
(
hours
[
i
])
>=
19
):
int
(
hours
[
i
])
>=
22
or
int
(
hours
[
i
])
<
5
or
int
(
hours
[
i
])
>=
19
):
statesheater
.
append
(
"热水器启动"
)
statesheater
.
append
(
"热水器启动"
)
timeheater
.
append
(
timer
[
i
])
timeheater
.
append
(
timer
[
i
])
if
1000
*
(
now_p
[
0
]
-
his_p
[
-
1
])
>
min
(
params
[
3
:])
-
50
and
1000
*
(
now_p
[
0
]
-
his_p
[
-
1
])
<
max
(
if
1000
*
(
now_p
[
0
]
-
his_p
[
-
1
])
>
min
(
params
[
3
:])
-
50
and
1000
*
(
now_p
[
0
]
-
his_p
[
-
1
])
<
max
(
params
[
3
:])
+
50
and
(
params
[
3
:])
+
50
and
(
int
(
hours
[
i
])
>=
10
and
int
(
hours
[
i
])
<
14
or
int
(
hours
[
i
])
>=
17
and
int
(
hours
[
i
])
<
20
or
int
(
int
(
hours
[
i
])
>=
10
and
int
(
hours
[
i
])
<
14
or
int
(
hours
[
i
])
>=
17
and
int
(
hours
[
i
])
<
20
or
int
(
hours
[
i
])
>=
5
and
int
(
hours
[
i
])
<
10
):
hours
[
i
])
>=
5
and
int
(
hours
[
i
])
<
10
):
statesricecook
.
append
(
"电饭煲启动"
)
statesricecook
.
append
(
"电饭煲启动"
)
timericecook
.
append
(
timer
[
i
])
timericecook
.
append
(
timer
[
i
])
if
1000
*
(
now_p
[
0
]
-
his_p
[
-
1
])
>
max
(
params
[
3
:])
-
50
and
(
if
1000
*
(
now_p
[
0
]
-
his_p
[
-
1
])
>
max
(
params
[
3
:])
-
50
and
(
int
(
hours
[
i
])
>=
10
and
int
(
hours
[
i
])
<
14
or
int
(
hours
[
i
])
>=
17
and
int
(
hours
[
i
])
<
20
or
int
(
int
(
hours
[
i
])
>=
10
and
int
(
hours
[
i
])
<
14
or
int
(
hours
[
i
])
>=
17
and
int
(
hours
[
i
])
<
20
or
int
(
hours
[
i
])
>=
5
and
int
(
hours
[
i
])
<
10
):
hours
[
i
])
>=
5
and
int
(
hours
[
i
])
<
10
):
stateselectro
.
append
(
"电磁炉运行"
)
stateselectro
.
append
(
"电磁炉运行"
)
timeelectro
.
append
(
timer
[
i
])
timeelectro
.
append
(
timer
[
i
])
# return 0
# return 0
if
1000
*
(
his_p
[
-
1
]
-
now_p
[
0
])
>
params
[
0
]
-
50
and
1000
*
(
his_p
[
-
1
]
-
now_p
[
0
])
<
min
(
params
[
1
:])
+
50
:
if
1000
*
(
his_p
[
-
1
]
-
now_p
[
0
])
>
params
[
0
]
-
50
and
1000
*
(
his_p
[
-
1
]
-
now_p
[
0
])
<
min
(
params
[
1
:])
+
50
:
statesrefrig_off
.
append
(
"电冰箱关闭"
)
statesrefrig_off
.
append
(
"电冰箱关闭"
)
timerefrig_off
.
append
(
timer
[
i
])
timerefrig_off
.
append
(
timer
[
i
])
if
1000
*
(
his_p
[
-
1
]
-
now_p
[
0
])
>
params
[
1
]
-
50
and
1000
*
(
his_p
[
-
1
]
-
now_p
[
0
])
<
min
(
params
[
2
:])
+
50
:
if
1000
*
(
his_p
[
-
1
]
-
now_p
[
0
])
>
params
[
1
]
-
50
and
1000
*
(
his_p
[
-
1
]
-
now_p
[
0
])
<
min
(
params
[
2
:])
+
50
:
statesaircond_off
.
append
(
"空调关闭"
)
statesaircond_off
.
append
(
"空调关闭"
)
timeaircond_off
.
append
(
timer
[
i
])
timeaircond_off
.
append
(
timer
[
i
])
if
1000
*
(
his_p
[
-
1
]
-
now_p
[
0
])
>
min
(
params
[
2
:])
-
50
and
(
if
1000
*
(
his_p
[
-
1
]
-
now_p
[
0
])
>
min
(
params
[
2
:])
-
50
and
(
int
(
hours
[
i
])
>=
22
or
int
(
hours
[
i
])
<
5
or
int
(
hours
[
i
])
>=
19
):
int
(
hours
[
i
])
>=
22
or
int
(
hours
[
i
])
<
5
or
int
(
hours
[
i
])
>=
19
):
statesheater_off
.
append
(
"热水器关闭"
)
statesheater_off
.
append
(
"热水器关闭"
)
timeheater_off
.
append
(
timer
[
i
])
timeheater_off
.
append
(
timer
[
i
])
if
1000
*
(
his_p
[
-
1
]
-
now_p
[
0
])
>
min
(
params
[
3
:])
-
50
and
1000
*
(
his_p
[
-
1
]
-
now_p
[
0
])
<
max
(
if
1000
*
(
his_p
[
-
1
]
-
now_p
[
0
])
>
min
(
params
[
3
:])
-
50
and
1000
*
(
his_p
[
-
1
]
-
now_p
[
0
])
<
max
(
params
[
3
:])
+
50
and
(
params
[
3
:])
+
50
and
(
int
(
hours
[
i
])
>=
10
and
int
(
hours
[
i
])
<
14
or
int
(
hours
[
i
])
>=
17
and
int
(
hours
[
i
])
<
20
or
int
(
int
(
hours
[
i
])
>=
10
and
int
(
hours
[
i
])
<
14
or
int
(
hours
[
i
])
>=
17
and
int
(
hours
[
i
])
<
20
or
int
(
hours
[
i
])
>=
5
and
int
(
hours
[
i
])
<
10
):
hours
[
i
])
>=
5
and
int
(
hours
[
i
])
<
10
):
statesricecook_off
.
append
(
"电饭煲关闭"
)
statesricecook_off
.
append
(
"电饭煲关闭"
)
timericecook_off
.
append
(
timer
[
i
])
timericecook_off
.
append
(
timer
[
i
])
if
1000
*
(
his_p
[
-
1
]
-
now_p
[
0
])
>
max
(
params
[
3
:])
-
50
and
(
if
1000
*
(
his_p
[
-
1
]
-
now_p
[
0
])
>
max
(
params
[
3
:])
-
50
and
(
int
(
hours
[
i
])
>=
10
and
int
(
hours
[
i
])
<
14
or
int
(
hours
[
i
])
>=
17
and
int
(
hours
[
i
])
<
20
or
int
(
int
(
hours
[
i
])
>=
10
and
int
(
hours
[
i
])
<
14
or
int
(
hours
[
i
])
>=
17
and
int
(
hours
[
i
])
<
20
or
int
(
hours
[
i
])
>=
5
and
int
(
hours
[
i
])
<
10
):
hours
[
i
])
>=
5
and
int
(
hours
[
i
])
<
10
):
stateselectro_off
.
append
(
"电磁炉关闭"
)
stateselectro_off
.
append
(
"电磁炉关闭"
)
timeelectro_off
.
append
(
timer
[
i
])
timeelectro_off
.
append
(
timer
[
i
])
...
...
unify_api/modules/shidianu/service/refrigAnalysis.py
View file @
13285235
...
@@ -2,53 +2,78 @@ import time
...
@@ -2,53 +2,78 @@ import time
def
findStart
(
timerefrig
=
"timerefrig"
,
timerefrig_last
=
""
,
ahead
=
0
):
def
findStart
(
timerefrig
=
"timerefrig"
,
timerefrig_last
=
""
,
ahead
=
0
):
timerefrig_last_stemp
=
int
(
time
.
mktime
(
time
.
strptime
(
timerefrig_last
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)))
timerefrig_last_stemp
=
int
(
timerefrig_stemp
=
[
int
(
time
.
mktime
(
time
.
strptime
(
each_time
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)))
for
each_time
in
timerefrig
]
time
.
mktime
(
time
.
strptime
(
timerefrig_last
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)))
timerefrig_stemp
=
[
int
(
time
.
mktime
(
time
.
strptime
(
each_time
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)))
for
each_time
in
timerefrig
]
if
ahead
<
len
(
timerefrig
)
-
1
:
if
ahead
<
len
(
timerefrig
)
-
1
:
time_substruct
=
[
1000000
if
timerefrig_stemp
[
time_substruct
=
[
1000000
if
timerefrig_stemp
[
each_timerefrig_stemp
]
-
timerefrig_last_stemp
<=
0
or
each_timerefrig_stemp
<
ahead
else
each_timerefrig_stemp
]
-
timerefrig_last_stemp
<=
0
or
each_timerefrig_stemp
<
ahead
else
timerefrig_stemp
[
each_timerefrig_stemp
]
-
timerefrig_last_stemp
for
each_timerefrig_stemp
timerefrig_stemp
[
each_timerefrig_stemp
]
-
timerefrig_last_stemp
for
each_timerefrig_stemp
in
range
(
len
(
timerefrig_stemp
))]
in
range
(
len
(
timerefrig_stemp
))]
else
:
else
:
time_substruct
=
[
1000000
if
timerefrig_last_stemp
-
timerefrig_stemp
[
time_substruct
=
[
1000000
if
timerefrig_last_stemp
-
timerefrig_stemp
[
each_timerefrig_stemp
]
<=
0
or
each_timerefrig_stemp
<
ahead
else
timerefrig_last_stemp
-
each_timerefrig_stemp
]
<=
0
or
each_timerefrig_stemp
<
ahead
else
timerefrig_last_stemp
-
timerefrig_stemp
[
timerefrig_stemp
[
each_timerefrig_stemp
]
for
each_timerefrig_stemp
]
each_timerefrig_stemp
in
range
(
len
(
timerefrig_stemp
))]
for
each_timerefrig_stemp
in
range
(
len
(
timerefrig_stemp
))]
index
=
time_substruct
.
index
(
min
(
time_substruct
))
index
=
time_substruct
.
index
(
min
(
time_substruct
))
return
index
return
index
def
refrigAnalysis
(
statesrefrig
=
""
,
statesrefrig_off
=
""
,
timerefrig
=
""
,
timerefrig_off
=
""
,
eachdata_pow
=
""
,
eachdata_cur
=
""
,
timer
=
""
):
timerefrig_chang
=
[
each
.
split
(
" "
)[
1
][:
-
3
]
.
split
(
":"
)
for
each
in
timerefrig
]
def
refrigAnalysis
(
statesrefrig
=
""
,
statesrefrig_off
=
""
,
timerefrig
=
""
,
timerefrig_hour
=
[
each
[
0
]
for
each
in
timerefrig_chang
]
timerefrig_off
=
""
,
eachdata_pow
=
""
,
eachdata_cur
=
""
,
timerefrig_minute
=
[
each
[
1
]
for
each
in
timerefrig_chang
]
timer
=
""
):
timerefrig_off_chang
=
[
each
.
split
(
" "
)[
1
][:
-
3
]
.
split
(
":"
)
for
each
in
timerefrig_off
]
timerefrig_chang
=
[
each
.
split
(
" "
)[
1
][:
-
3
]
.
split
(
":"
)
for
each
in
timerefrig_off_hour
=
[
each
[
0
]
for
each
in
timerefrig_off_chang
]
timerefrig
]
timerefrig_off_minute
=
[
each
[
1
]
for
each
in
timerefrig_off_chang
]
timerefrig_hour
=
[
each
[
0
]
for
each
in
timerefrig_chang
]
refrigRunStages
=
[]
timerefrig_minute
=
[
each
[
1
]
for
each
in
timerefrig_chang
]
if
int
(
timerefrig_off_hour
[
-
1
])
>=
22
and
int
(
timerefrig_off_hour
[
0
])
<=
2
:
timerefrig_off_chang
=
[
each
.
split
(
" "
)[
1
][:
-
3
]
.
split
(
":"
)
for
each
in
timerefrig_off
]
timerefrig_off_hour
=
[
each
[
0
]
for
each
in
timerefrig_off_chang
]
timerefrig_off_minute
=
[
each
[
1
]
for
each
in
timerefrig_off_chang
]
refrigRunStages
=
[]
if
int
(
timerefrig_off_hour
[
-
1
])
>=
22
and
int
(
timerefrig_off_hour
[
0
])
<=
2
:
refrigRunStages
.
append
(
timerefrig
[
0
])
refrigRunStages
.
append
(
timerefrig
[
0
])
refrigRunStages
.
append
(
timerefrig_off
[
-
1
])
refrigRunStages
.
append
(
timerefrig_off
[
-
1
])
else
:
else
:
refrigRunStages
.
append
(
timerefrig
[
0
])
refrigRunStages
.
append
(
timerefrig
[
0
])
for
each_off
in
range
(
1
,
len
(
timerefrig_off
)):
for
each_off
in
range
(
1
,
len
(
timerefrig_off
)):
# if each_off==len(timerefrig_off)-1:
# if each_off==len(timerefrig_off)-1:
print
(
"timerefrig_off_hour"
,
timerefrig_off_hour
)
print
(
"timerefrig_off_hour"
,
timerefrig_off_hour
)
if
len
(
timerefrig_off_hour
)
>=
3
and
int
(
timerefrig_off_hour
[
-
1
])
-
int
(
timerefrig_off_hour
[
-
2
])
<=
2
and
int
(
timerefrig_off_hour
[
-
2
])
-
int
(
timerefrig_off_hour
[
-
3
])
<=
2
and
each_off
==
len
(
timerefrig_off_hour
)
-
1
:
if
len
(
timerefrig_off_hour
)
>=
3
and
int
(
timerefrig_off_hour
[
-
1
])
-
int
(
timerefrig_off_hour
[
-
2
])
<=
2
and
int
(
timerefrig_off_hour
[
-
2
])
-
int
(
timerefrig_off_hour
[
-
3
])
<=
2
and
each_off
==
len
(
timerefrig_off_hour
)
-
1
:
refrigRunStages
.
append
(
timerefrig_off
[
each_off
])
refrigRunStages
.
append
(
timerefrig_off
[
each_off
])
if
len
(
timerefrig_off_hour
)
>=
2
and
int
(
timerefrig_off_hour
[
-
1
])
-
int
(
timerefrig_off_hour
[
-
2
])
<=
2
and
each_off
==
len
(
timerefrig_off_hour
)
-
1
:
if
len
(
timerefrig_off_hour
)
>=
2
and
int
(
timerefrig_off_hour
[
-
1
])
-
int
(
timerefrig_off_hour
[
-
2
])
<=
2
and
each_off
==
len
(
timerefrig_off_hour
)
-
1
:
refrigRunStages
.
append
(
timerefrig_off
[
each_off
])
refrigRunStages
.
append
(
timerefrig_off
[
each_off
])
if
int
(
timerefrig_off_hour
[
each_off
])
-
int
(
timerefrig_off_hour
[
each_off
-
1
])
<=
2
or
int
(
timerefrig_off_hour
[
each_off
])
<
6
or
int
(
timerefrig_off_hour
[
each_off
])
>
21
:
if
int
(
timerefrig_off_hour
[
each_off
])
-
int
(
timerefrig_off_hour
[
each_off
-
1
])
<=
2
or
int
(
timerefrig_off_hour
[
each_off
])
<
6
or
int
(
timerefrig_off_hour
[
each_off
])
>
21
:
continue
continue
else
:
else
:
if
each_off
<
len
(
timerefrig
)
-
1
:
if
each_off
<
len
(
timerefrig
)
-
1
:
refrigRunStages
.
append
(
timerefrig_off
[
each_off
-
1
])
refrigRunStages
.
append
(
timerefrig_off
[
each_off
-
1
])
findStart1
=
findStart
(
timerefrig
=
timerefrig
,
timerefrig_last
=
timerefrig_off
[
each_off
-
1
],
ahead
=
each_off
)
findStart1
=
findStart
(
timerefrig
=
timerefrig
,
timerefrig_last
=
timerefrig_off
[
each_off
-
1
],
ahead
=
each_off
)
refrigRunStages
.
append
(
timerefrig
[
findStart1
])
refrigRunStages
.
append
(
timerefrig
[
findStart1
])
else
:
else
:
refrigRunStages
.
append
(
timerefrig_off
[
each_off
])
refrigRunStages
.
append
(
timerefrig_off
[
each_off
])
return
refrigRunStages
return
refrigRunStages
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment