Commit 7e380ceb authored by ZZH's avatar ZZH

remove es 2023-5-29

parent 95140e9a
...@@ -36,35 +36,10 @@ async def alarm_count(company_ids): ...@@ -36,35 +36,10 @@ async def alarm_count(company_ids):
return total_alarm_cnt return total_alarm_cnt
async def alarm_count_sdu_new15(cids): async def load_alarm_cnt_sdu(cids):
sql = f"select count(1) doc_count from point_1min_event " \ sql = f"select count(1) doc_count from point_1min_event " \
f"where cid in %s and importance in (1, 2, 3) " \ f"where cid in %s and importance in (1, 2, 3) " \
f"and event_type in {tuple(SDU_ALARM_LIST)}" f"and event_type in {tuple(SDU_ALARM_LIST)}"
async with MysqlUtil() as conn: async with MysqlUtil() as conn:
data = await conn.fetchone(sql, args=(cids,)) data = await conn.fetchone(sql, args=(cids,))
return data["doc_count"] or 0 return data["doc_count"] or 0
async def alarm_count_sdu_new(company_ids):
"""新版识电u报警类型只包含3种"""
query_body = {
"query": {
"bool": {
"filter": [
{"terms": {"cid": company_ids}},
{"terms": {"type.keyword": SDU_ALARM_LIST}}
]
}
},
"size": 0,
"aggs": {"cid_alarm_aggs": {"terms": {"field": "cid", "size": 10000}}},
}
async with EsUtil() as es:
es_result = await es.search_origin(body=query_body,
index=constants.POINT_1MIN_EVENT)
cid_alarm_buckets = (
es_result.get("aggregations", {}).get("cid_alarm_aggs", {}).get(
"buckets", [])
)
total_alarm_cnt = sum([i["doc_count"] for i in cid_alarm_buckets])
return total_alarm_cnt
...@@ -5,19 +5,21 @@ from unify_api import constants ...@@ -5,19 +5,21 @@ from unify_api import constants
async def power_use_count(company_ids): async def power_use_count(company_ids):
query_body = { query_body = {
"query": {"bool": {"filter": [{"terms": {"cid": company_ids}},]}}, "query": {"bool": {"filter": [{"terms": {"cid": company_ids}}, ]}},
"size": 0, "size": 0,
"aggs": {"kwh": {"sum": {"field": "kwh"}}}, "aggs": {"kwh": {"sum": {"field": "kwh"}}},
} }
async with EsUtil() as es: async with EsUtil() as es:
es_result = await es.search_origin(body=query_body, index=constants.COMPANY_15MIN_POWER) es_result = await es.search_origin(body=query_body,
index=constants.COMPANY_15MIN_POWER)
total_power = round(es_result.get("aggregations", {}).get("kwh", {}).get("value") or 0, 2) total_power = round(
es_result.get("aggregations", {}).get("kwh", {}).get("value") or 0, 2)
return total_power return total_power
async def power_use_count_new15(cids): async def load_cmpy_power(cids):
sql = "SELECT COUNT(kwh) kwh FROM `company_1day_power` where cid in %s" sql = "SELECT COUNT(kwh) kwh FROM `company_1day_power` where cid in %s"
async with MysqlUtil() as conn: async with MysqlUtil() as conn:
data = await conn.fetchone(sql, args=(cids,)) data = await conn.fetchone(sql, args=(cids,))
...@@ -26,43 +28,11 @@ async def power_use_count_new15(cids): ...@@ -26,43 +28,11 @@ async def power_use_count_new15(cids):
async def inline_power_use_info(inline_ids, month_str): async def inline_power_use_info(inline_ids, month_str):
"""
获取进线用电信息
:param inline_id:
:param es_start_time:
:param es_end_time:
:return:
"""
async with EsUtil() as es:
filters = [
{"terms": {"inlid": inline_ids}},
{"term": {"month": f"{month_str}-01T00:00:00+08:00"}},
]
query_body = {
"query": {"bool": {"filter": filters}},
"size": 10000,
}
es_result = await es.search_origin(body=query_body, index=constants.INLINE_1MONTH_POWER)
power_infos = es_result["hits"]["hits"]
inline_power_info_map = {
i["_source"]["inlid"]: {
"kwh": i["_source"]["kwh"],
"charge": i["_source"]["charge"],
"p": i["_source"]["p"],
}
for i in power_infos
}
return inline_power_info_map
async def inline_power_use_info_new15(inline_ids, month_str):
sql = "SELECT inlid, sum(kwh) kwh, sum(charge) charge, sum(p) p FROM " \ sql = "SELECT inlid, sum(kwh) kwh, sum(charge) charge, sum(p) p FROM " \
"`inline_1day_power` where inlid in %s and " \ "`inline_1day_power` where inlid in %s and " \
f"DATE_FORMAT(create_time, '%%Y-%%m')='{month_str}' GROUP BY inlid" f"DATE_FORMAT(create_time, '%%Y-%%m')='{month_str}' GROUP BY inlid"
async with MysqlUtil() as conn: async with MysqlUtil() as conn:
datas = await conn.fetchall(sql, args=(inline_ids, )) datas = await conn.fetchall(sql, args=(inline_ids,))
inline_power_info_map = { inline_power_info_map = {
i["inlid"]: { i["inlid"]: {
"kwh": i["kwh"], "kwh": i["kwh"],
......
...@@ -180,83 +180,7 @@ async def power_charge_p_cid_aggs(date_start, date_end, cid_list, interval): ...@@ -180,83 +180,7 @@ async def power_charge_p_cid_aggs(date_start, date_end, cid_list, interval):
return results or [] return results or []
async def query_charge_aggs_points(date_start, date_end, point_list): async def query_charge_aggs_points(start, end, point_list):
"""
返回: [
{
"key" : 32,
"doc_count" : 44,
"charge" : {
"value" : 8658.496337890625
},
"kwh" : {
"value" : 25314.447940826416
}
},
{
"key" : 44,
"doc_count" : 43,
"charge" : {
"value" : 13868.499267578125
},
"kwh" : {
"value" : 31743.359497070312
}
}
]
"""
start_es = convert_es_str(date_start)
end_es = convert_es_str(date_end)
query_body = {
"size": 0,
"query": {
"bool": {
"must": [
{
"terms": {
"pid": point_list
}
},
{
"range": {
"quarter_time": {
"gte": start_es,
"lte": end_es
}
}
}
]
}
},
"aggs": {
"points": {
"terms": {
"field": "pid",
"size": 10000
},
"aggs": {
"kwh": {
"sum": {
"field": "kwh"
}
},
"charge": {
"sum": {
"field": "charge"
}
}
}
}
}
}
log.info(query_body)
async with EsUtil() as es:
es_re = await es.search_origin(body=query_body, index=index_point)
return es_re["aggregations"]["points"]["buckets"]
async def query_charge_aggs_points_new15(start, end, point_list):
sql = f"SELECT pid,sum(kwh) kwh,SUM(charge) charge " \ sql = f"SELECT pid,sum(kwh) kwh,SUM(charge) charge " \
f"FROM `point_15min_power` " \ f"FROM `point_15min_power` " \
f"where pid in %s and create_time BETWEEN '{start}' and '{end}' " \ f"where pid in %s and create_time BETWEEN '{start}' and '{end}' " \
......
...@@ -57,25 +57,7 @@ def quarters_trans(quarters): ...@@ -57,25 +57,7 @@ def quarters_trans(quarters):
return dic2 return dic2
async def proxy_power(cid_list): async def load_proxy_power(cid_list):
"""渠道版累计用电"""
index = COMPANY_1DAY_POWER
# 2.构造query_body
query = agg_statistics(terms={"cid": cid_list},
aggs_key=["kwh"],
date_key="day")
# 3.返回数据
async with EsUtil() as es:
re = await es.search_origin(body=query, index=index)
re = re["aggregations"]["kwh"]["value"]
if re:
# 需求是万kwh
return round(re, 2)
else:
return 0
async def proxy_power15(cid_list):
"""渠道版累计用电""" """渠道版累计用电"""
sql = f""" sql = f"""
select sum(kwh) kwh from company_1day_power where cid in %s select sum(kwh) kwh from company_1day_power where cid in %s
...@@ -87,87 +69,6 @@ async def proxy_power15(cid_list): ...@@ -87,87 +69,6 @@ async def proxy_power15(cid_list):
async def power_overview_proxy(date_start, date_end, cid_list): async def power_overview_proxy(date_start, date_end, cid_list):
"""渠道版, 抽离电量电费信息,供调用"""
pv1 = {} # 电量
pv2 = {} # 电费
start_es = convert_es_str(date_start)
end_es = convert_es_str(date_end)
index = COMPANY_15MIN_POWER
# 2. 获取query_body # es时间查询字段:quarter_time
query_body = {
"query": {
"bool": {
"filter": [
{
"terms": {
"cid": cid_list
}
},
{
"range": {
"quarter_time": {
"gte": start_es,
"lte": end_es
}
}
}
]
}
},
"size": 0,
"aggs": {
"spfvs": {
"terms": {
"field": "spfv.keyword"
},
"aggs": {
"kwh": {
"sum": {
"field": "kwh"
}
},
"charge": {
"sum": {
"field": "charge"
}
},
"p": {
"sum": {
"field": "p"
}
}
}
}
}
}
log.info(query_body)
# 3. 查询es
async with EsUtil() as es:
es_re = await es.search_origin(body=query_body, index=index)
es_re = es_re["aggregations"]["spfvs"]["buckets"]
if not es_re:
log.info(
f"未查询到es数据, cid_list:{cid_list}, start:{start_es}, end:{end_es}")
return pv1, pv2
# 4. 构造返回
for info in es_re:
if info.get("key") == "s":
pv1["s"] = round_2(info.get("kwh")["value"])
pv2["s"] = round_2(info.get("charge")["value"])
elif info.get("key") == "p":
pv1["p"] = round_2(info.get("kwh")["value"])
pv2["p"] = round_2(info.get("charge")["value"])
elif info.get("key") == "f":
pv1["f"] = round_2(info.get("kwh")["value"])
pv2["f"] = round_2(info.get("charge")["value"])
elif info.get("key") == "v":
pv1["v"] = round_2(info.get("kwh")["value"])
pv2["v"] = round_2(info.get("charge")["value"])
return pv1, pv2
async def power_overview_proxy15(date_start, date_end, cid_list):
"""渠道版, 抽离电量电费信息,供调用""" """渠道版, 抽离电量电费信息,供调用"""
pv1 = {} # 电量 pv1 = {} # 电量
pv2 = {} # 电费 pv2 = {} # 电费
...@@ -195,69 +96,6 @@ def total_value(dict_total): ...@@ -195,69 +96,6 @@ def total_value(dict_total):
async def power_aggs_cid_proxy(start, end, cid_list, date_type): async def power_aggs_cid_proxy(start, end, cid_list, date_type):
"""渠道版,电量电费信息,根据cid聚合,再聚合求出sum电量/电费"""
# 1. 求出上周期时间
start_last, end_last = last_time_str(start, end, date_type)
# 2. 获取es结果
es_re_this = await query_charge_aggs(start, end, cid_list)
es_re_last = await query_charge_aggs(start_last, end_last, cid_list)
if not es_re_this:
log.info(
f"未查询到es数据, cid_list:{cid_list}, start:{start}, end:{end}")
return [], [], []
es_re_last_dic = process_es_data(es_re_last)
# 3. 构造返回
kwh_list = []
charge_list = []
price_list = []
# 3.1 查询出cid和工厂名对应关系
company_list = await company_by_cids(cid_list)
# 把cid提出来
com_dic = process_es_data(company_list, key="cid")
for info in es_re_this:
cid = info.get("key")
cid_name = com_dic[cid]["shortname"]
kwh = round_2(info.get("kwh")["value"])
if kwh == 0:
continue
# 上一周期如果没有数据, 此数据不参与统计
try:
kwh_last = es_re_last_dic[cid]["kwh"]["value"]
kwh_rate = round_4((kwh - kwh_last) / kwh_last)
if kwh_last == 0:
continue
except Exception as e:
log.error(e)
log.info(
f"本次有电量数据, 上周期没有电量数据, cid:{cid}, start:{start}, end:{end}")
continue
charge = round_2(info.get("charge")["value"])
try:
charge_last = es_re_last_dic[cid]["charge"]["value"]
charge_rate = round_4((charge - charge_last) / charge_last)
if charge_last == 0:
continue
except Exception as e:
log.error(e)
log.info("本次有数据, 上周期没有数据")
log.info(
f"本次有电费数据, 上周期没有电费数据, cid:{cid}, start:{start}, end:{end}")
continue
price = round_2(charge / kwh)
price_last = round_2(charge_last / kwh_last)
price_rate = round_4((price - price_last) / price_last)
# 构造kwh
kwh_list.append({"name": cid_name, "value": kwh, "rate": kwh_rate})
charge_list.append(
{"name": cid_name, "value": charge, "rate": charge_rate})
price_list.append(
{"name": cid_name, "value": price, "rate": price_rate})
return kwh_list, charge_list, price_list
async def power_aggs_cid_proxy_new15(start, end, cid_list, date_type):
"""渠道版,电量电费信息,根据cid聚合,再聚合求出sum电量/电费""" """渠道版,电量电费信息,根据cid聚合,再聚合求出sum电量/电费"""
# 1. 求出上周期时间 # 1. 求出上周期时间
start_last, end_last = last_time_str(start, end, date_type) start_last, end_last = last_time_str(start, end, date_type)
...@@ -265,8 +103,7 @@ async def power_aggs_cid_proxy_new15(start, end, cid_list, date_type): ...@@ -265,8 +103,7 @@ async def power_aggs_cid_proxy_new15(start, end, cid_list, date_type):
re_this = await query_charge_new15(start, end, cid_list) re_this = await query_charge_new15(start, end, cid_list)
re_last = await query_charge_new15(start_last, end_last, cid_list) re_last = await query_charge_new15(start_last, end_last, cid_list)
if not re_this: if not re_this:
log.info( log.info(f"未查询到数据, cid_list:{cid_list}, start:{start}, end:{end}")
f"未查询到数据, cid_list:{cid_list}, start:{start}, end:{end}")
return [], [], [] return [], [], []
re_last_dic = process_es_data(re_last, key="cid") re_last_dic = process_es_data(re_last, key="cid")
# 3. 构造返回 # 3. 构造返回
...@@ -320,40 +157,7 @@ async def power_aggs_cid_proxy_new15(start, end, cid_list, date_type): ...@@ -320,40 +157,7 @@ async def power_aggs_cid_proxy_new15(start, end, cid_list, date_type):
return kwh_list, charge_list, price_list return kwh_list, charge_list, price_list
async def power_index_aggs_cid_proxy(start, end, cid_list, date_type): async def power_index_cid_proxy(start, end, cid_list, date_type):
"""power_aggs_cid_proxy缩减版, 没有增长率"""
# 1. 获取es结果
es_re_this = await query_charge_aggs(start, end, cid_list)
if not es_re_this:
log.info(
f"未查询到es数据, cid_list:{cid_list}, start:{start}, end:{end}")
return [], [], []
# 3. 构造返回
kwh_list = []
charge_list = []
price_list = []
# 3.1 查询出cid和工厂名对应关系
company_list = await company_by_cids(cid_list)
# 把cid提出来
com_dic = process_es_data(company_list, key="cid")
for info in es_re_this:
cid = info.get("key")
cid_name = com_dic[cid]["shortname"]
kwh = round_2(info.get("kwh")["value"])
charge = round_2(info.get("charge")["value"])
# 值为0不参与排名统计
if kwh == 0:
continue
price = round_2(charge / kwh)
# 构造kwh
kwh_list.append({"name": cid_name, "value": kwh})
charge_list.append({"name": cid_name, "value": charge})
price_list.append({"name": cid_name, "value": price})
return kwh_list, charge_list, price_list
async def power_index_cid_proxy_new15(start, end, cid_list, date_type):
"""power_aggs_cid_proxy缩减版, 没有增长率""" """power_aggs_cid_proxy缩减版, 没有增长率"""
# 1. 获取es结果 # 1. 获取es结果
res = await query_charge_new15(start, end, cid_list) res = await query_charge_new15(start, end, cid_list)
......
...@@ -5,7 +5,7 @@ from unify_api.modules.common.components.common_cps import LevelResp ...@@ -5,7 +5,7 @@ from unify_api.modules.common.components.common_cps import LevelResp
from unify_api.modules.common.procedures.points import points_by_storeys from unify_api.modules.common.procedures.points import points_by_storeys
from unify_api.modules.elec_charge.components.elec_charge_cps import KpResp from unify_api.modules.elec_charge.components.elec_charge_cps import KpResp
from unify_api.modules.elec_charge.dao.elec_charge_dao import \ from unify_api.modules.elec_charge.dao.elec_charge_dao import \
query_charge_aggs_points, query_charge_aggs_points_new15 query_charge_aggs_points
from unify_api.modules.electric.dao.electric_dao import \ from unify_api.modules.electric.dao.electric_dao import \
monitor_point_join_by_points monitor_point_join_by_points
from unify_api.modules.home_page.procedures.count_info_pds import current_load, \ from unify_api.modules.home_page.procedures.count_info_pds import current_load, \
...@@ -20,7 +20,7 @@ async def kwh_points_service(cid, start, end, storeys): ...@@ -20,7 +20,7 @@ async def kwh_points_service(cid, start, end, storeys):
# 获取point_id列表 # 获取point_id列表
points = [i.get("point_id") for i in point_list] points = [i.get("point_id") for i in point_list]
# 2. es查询数据 # 2. es查询数据
es_res = await query_charge_aggs_points_new15(start, end, points) es_res = await query_charge_aggs_points(start, end, points)
es_res = {i["pid"]: i for i in es_res if es_res} es_res = {i["pid"]: i for i in es_res if es_res}
# 3. 构造返回 # 3. 构造返回
kwh_data = {} kwh_data = {}
...@@ -64,7 +64,7 @@ async def kwh_card_level_service(cid, point_list, start, end): ...@@ -64,7 +64,7 @@ async def kwh_card_level_service(cid, point_list, start, end):
# 1. 获取每个point_id的详细信息 # 1. 获取每个point_id的详细信息
monitor_point_list = await monitor_point_join_by_points(point_list) monitor_point_list = await monitor_point_join_by_points(point_list)
# 2. es查询数据 # 2. es查询数据
es_res = await query_charge_aggs_points_new15(start, end, point_list) es_res = await query_charge_aggs_points(start, end, point_list)
es_res = {i["pid"]: i for i in es_res if es_res} es_res = {i["pid"]: i for i in es_res if es_res}
# 3. 返回数据 # 3. 返回数据
ret_data = { ret_data = {
......
...@@ -18,11 +18,10 @@ from unify_api.modules.elec_charge.components.elec_charge_cps import \ ...@@ -18,11 +18,10 @@ from unify_api.modules.elec_charge.components.elec_charge_cps import \
IndexChargeReq, IndexChargeResp, PopReq, PopResp, MtpResp, PspResp, \ IndexChargeReq, IndexChargeResp, PopReq, PopResp, MtpResp, PspResp, \
IpspResp, KpReq, KpResp, KclReq, ProductProxyReq, LoadInfoReq, LoadInfoResp IpspResp, KpReq, KpResp, KclReq, ProductProxyReq, LoadInfoReq, LoadInfoResp
from unify_api.modules.elec_charge.dao.elec_charge_dao import \ from unify_api.modules.elec_charge.dao.elec_charge_dao import \
query_charge_aggs_points, get_kwh_charge, query_charge_aggs_points_new15 get_kwh_charge, query_charge_aggs_points
from unify_api.modules.elec_charge.procedures.elec_charge_pds import \ from unify_api.modules.elec_charge.procedures.elec_charge_pds import \
quarters_trans, power_overview_proxy, total_value, \ quarters_trans, total_value, \
power_aggs_cid_proxy_new15, \ power_aggs_cid_proxy, power_index_cid_proxy, power_overview_proxy
power_index_cid_proxy_new15, power_overview_proxy15
from unify_api.modules.elec_charge.service.elec_charge_service import \ from unify_api.modules.elec_charge.service.elec_charge_service import \
kwh_points_service, kwh_card_level_service, load_info_service kwh_points_service, kwh_card_level_service, load_info_service
from unify_api.modules.users.procedures.jwt_user import jwt_user from unify_api.modules.users.procedures.jwt_user import jwt_user
...@@ -315,8 +314,8 @@ async def post_power_overview_proxy(req, body: PopReq) -> PopResp: ...@@ -315,8 +314,8 @@ async def post_power_overview_proxy(req, body: PopReq) -> PopResp:
end = now_date end = now_date
# 获取上一周期开始结束时间 # 获取上一周期开始结束时间
start_last, end_last = last_time_str(start, end, date_type) start_last, end_last = last_time_str(start, end, date_type)
power, charge = await power_overview_proxy15(start, end, cid_list) power, charge = await power_overview_proxy(start, end, cid_list)
power_last, charge_last = await power_overview_proxy15(start_last, power_last, charge_last = await power_overview_proxy(start_last,
end_last, end_last,
cid_list) cid_list)
if not all([power, charge, power_last, charge_last]): if not all([power, charge, power_last, charge_last]):
...@@ -368,9 +367,9 @@ async def post_month_today_proxy(req, body: ProductProxyReq) -> MtpResp: ...@@ -368,9 +367,9 @@ async def post_month_today_proxy(req, body: ProductProxyReq) -> MtpResp:
# 2. 本月/上月数据 # 2. 本月/上月数据
last_month_start, last_month_end = last_time_str(month_start, month_end, last_month_start, last_month_end = last_time_str(month_start, month_end,
"month", True) "month", True)
this_month_p, this_month_charge = await power_overview_proxy15( this_month_p, this_month_charge = await power_overview_proxy(
month_start, month_end, cid_list) month_start, month_end, cid_list)
last_month_p, last_month_charge = await power_overview_proxy15( last_month_p, last_month_charge = await power_overview_proxy(
last_month_start, last_month_end, cid_list) last_month_start, last_month_end, cid_list)
if not all([this_month_p, this_month_charge, last_month_p, if not all([this_month_p, this_month_charge, last_month_p,
...@@ -383,10 +382,10 @@ async def post_month_today_proxy(req, body: ProductProxyReq) -> MtpResp: ...@@ -383,10 +382,10 @@ async def post_month_today_proxy(req, body: ProductProxyReq) -> MtpResp:
last_month_total_power) / last_month_total_power last_month_total_power) / last_month_total_power
# 2. 今日/昨日数据 # 2. 今日/昨日数据
last_day_start, last_day_end = last_time_str(today_start, today_end, "day") last_day_start, last_day_end = last_time_str(today_start, today_end, "day")
this_day_p, this_day_charge = await power_overview_proxy15(today_start, this_day_p, this_day_charge = await power_overview_proxy(today_start,
today_end, today_end,
cid_list) cid_list)
last_day_p, last_day_charge = await power_overview_proxy15( last_day_p, last_day_charge = await power_overview_proxy(
last_day_start, last_day_end, cid_list) last_day_start, last_day_end, cid_list)
if not all([this_day_p, this_day_charge, last_day_p, last_day_charge]): if not all([this_day_p, this_day_charge, last_day_p, last_day_charge]):
...@@ -429,7 +428,7 @@ async def post_power_sort_proxy(req, body: PopReq) -> PspResp: ...@@ -429,7 +428,7 @@ async def post_power_sort_proxy(req, body: PopReq) -> PspResp:
end = now_date end = now_date
# 2. 查询工厂电量电费信息 # 2. 查询工厂电量电费信息
kwh_list, charge_list, price_list = await power_aggs_cid_proxy_new15( kwh_list, charge_list, price_list = await power_aggs_cid_proxy(
start, end, cid_list, date_type) start, end, cid_list, date_type)
kwh_list_st = sorted(kwh_list, key=lambda i: i['value'], reverse=True) kwh_list_st = sorted(kwh_list, key=lambda i: i['value'], reverse=True)
charge_list_st = sorted(charge_list, key=lambda i: i['value'], charge_list_st = sorted(charge_list, key=lambda i: i['value'],
...@@ -453,7 +452,7 @@ async def post_index_power_sort_proxy(req) -> IpspResp: ...@@ -453,7 +452,7 @@ async def post_index_power_sort_proxy(req) -> IpspResp:
return IpspResp() return IpspResp()
today_start, today_end, month_start, month_end = today_month_date() today_start, today_end, month_start, month_end = today_month_date()
# 2. 获取今日数据 # 2. 获取今日数据
kwh_list_d, charge_list_d, price_list_d = await power_index_cid_proxy_new15( kwh_list_d, charge_list_d, price_list_d = await power_index_cid_proxy(
today_start, today_end, cid_list, "day") today_start, today_end, cid_list, "day")
kwh_list_d_st = sorted(kwh_list_d, key=lambda i: i['value'], kwh_list_d_st = sorted(kwh_list_d, key=lambda i: i['value'],
reverse=True)[:5] reverse=True)[:5]
...@@ -462,7 +461,7 @@ async def post_index_power_sort_proxy(req) -> IpspResp: ...@@ -462,7 +461,7 @@ async def post_index_power_sort_proxy(req) -> IpspResp:
price_list_d_st = sorted(price_list_d, key=lambda i: i['value'], price_list_d_st = sorted(price_list_d, key=lambda i: i['value'],
reverse=True)[:5] reverse=True)[:5]
# 2. 获取本月数据 # 2. 获取本月数据
kwh_list_m, charge_list_m, price_list_m = await power_index_cid_proxy_new15( kwh_list_m, charge_list_m, price_list_m = await power_index_cid_proxy(
month_start, month_end, cid_list, "month") month_start, month_end, cid_list, "month")
kwh_list_m_st = sorted(kwh_list_m, key=lambda i: i['value'], kwh_list_m_st = sorted(kwh_list_m, key=lambda i: i['value'],
reverse=True)[:5] reverse=True)[:5]
...@@ -501,7 +500,7 @@ async def get_kwh_points_download(req): ...@@ -501,7 +500,7 @@ async def get_kwh_points_download(req):
# 获取point_id列表 # 获取point_id列表
points = [i.get("point_id") for i in point_list] points = [i.get("point_id") for i in point_list]
# 3. es查询数据 # 3. es查询数据
es_res = await query_charge_aggs_points_new15(start, end, points) es_res = await query_charge_aggs_points(start, end, points)
es_res = {i["pid"]: i for i in es_res if es_res} es_res = {i["pid"]: i for i in es_res if es_res}
# 4.返回数据 # 4.返回数据
storey_name_list = [] storey_name_list = []
......
...@@ -48,33 +48,7 @@ async def month_power_loadrate(inline_id: int, month_list: list): ...@@ -48,33 +48,7 @@ async def month_power_loadrate(inline_id: int, month_list: list):
return power_loadrate return power_loadrate
async def inline_power_use_info(inline_id, es_start_time, es_end_time): async def load_inline_power(inline_id, start, end):
"""
获取进线用电信息
:param inline_id:
:param es_start_time:
:param es_end_time:
:return:
"""
async with EsUtil() as es:
filters = [
{"term": {"inlid": inline_id}},
{"range": {"quarter_time": {"gte": es_start_time, "lt": es_end_time,}}},
]
query_body = {
"query": {"bool": {"filter": filters}},
"size": 0,
"aggs": {"kwh": {"sum": {"field": "kwh"}}, "charge": {"sum": {"field": "charge"}},},
}
es_result = await es.search_origin(body=query_body,
index=constants.INLINE_15MIN_POWER)
return {
"charge": es_result["aggregations"]["charge"]["value"],
"kwh": es_result["aggregations"]["kwh"]["value"],
}
async def inline_power_use_info_new15(inline_id, start, end):
""" """
1.5版本获取进线用电信息 1.5版本获取进线用电信息
:param inline_id: :param inline_id:
...@@ -85,5 +59,5 @@ async def inline_power_use_info_new15(inline_id, start, end): ...@@ -85,5 +59,5 @@ async def inline_power_use_info_new15(inline_id, start, end):
sql = f"SELECT sum(kwh) kwh, sum(charge) charge FROM inline_15min_power" \ sql = f"SELECT sum(kwh) kwh, sum(charge) charge FROM inline_15min_power" \
f" where inlid=%s and create_time BETWEEN '{start}' and '{end}'" f" where inlid=%s and create_time BETWEEN '{start}' and '{end}'"
async with MysqlUtil() as conn: async with MysqlUtil() as conn:
datas = await conn.fetchone(sql, args=(inline_id, )) datas = await conn.fetchone(sql, args=(inline_id,))
return datas return datas
from pot_libs.logger import log from pot_libs.logger import log
from pot_libs.mysql_util.mysql_util import MysqlUtil from pot_libs.mysql_util.mysql_util import MysqlUtil
from unify_api.modules.common.procedures.cids import get_cid_info from unify_api.modules.common.procedures.cids import get_cid_info
from unify_api.modules.common.procedures.power_cps import \ from unify_api.modules.common.procedures.power_cps import inline_power_use_info
inline_power_use_info, inline_power_use_info_new15
async def get_inline_datas_dao(cids): async def get_inline_datas_dao(cids):
...@@ -22,7 +21,8 @@ async def get_power_factor_results(inline_ids, month_str): ...@@ -22,7 +21,8 @@ async def get_power_factor_results(inline_ids, month_str):
f" from algo_power_factor_result where inlid in %s " \ f" from algo_power_factor_result where inlid in %s " \
f"and month = %s" f"and month = %s"
power_factors = ( power_factors = (
await conn.fetchall(pf_sql, args=(inline_ids, month_str)) if inline_ids else [] await conn.fetchall(pf_sql, args=(
inline_ids, month_str)) if inline_ids else []
) )
return power_factors return power_factors
...@@ -45,7 +45,8 @@ async def proxy_power_factor_summary(cids, month_str, inline_map=None): ...@@ -45,7 +45,8 @@ async def proxy_power_factor_summary(cids, month_str, inline_map=None):
[ [
round(i["save_charge"], 2) round(i["save_charge"], 2)
for i in power_factors for i in power_factors
if type(i["save_charge"]) in [int, float] and i["save_charge"] >= 0 if type(i["save_charge"]) in [int, float] and i[
"save_charge"] >= 0
] ]
), ),
2, 2,
...@@ -107,15 +108,17 @@ async def proxy_power_factor_list( ...@@ -107,15 +108,17 @@ async def proxy_power_factor_list(
"inline_name": inline_map[inline_id]["name"], "inline_name": inline_map[inline_id]["name"],
"power_factor": pf_res["kpi_x"], "power_factor": pf_res["kpi_x"],
"status": "奖励" if pf_res["kpi_x"] >= 0.9 else "罚款", "status": "奖励" if pf_res["kpi_x"] >= 0.9 else "罚款",
"save_charge": pf_res["save_charge"] if pf_res["save_charge"] > 0 else 0, "save_charge": pf_res["save_charge"] if pf_res[
"save_charge"] > 0 else 0,
} }
) )
if sort_field in ["company_name", "power_factor", "save_charge"]: if sort_field in ["company_name", "power_factor", "save_charge"]:
all_list.sort( all_list.sort(
key=lambda x: x[sort_field], reverse=True if sort_direction == "desc" else False, key=lambda x: x[sort_field],
reverse=True if sort_direction == "desc" else False,
) )
return { return {
"rows": all_list[page_size * (page_num - 1) : page_size * page_num], "rows": all_list[page_size * (page_num - 1): page_size * page_num],
"total": len(all_list), "total": len(all_list),
} }
...@@ -169,12 +172,14 @@ async def proxy_md_space_list( ...@@ -169,12 +172,14 @@ async def proxy_md_space_list(
"inline_tc": inline_map[inline_id]["inline_tc"], "inline_tc": inline_map[inline_id]["inline_tc"],
"tc_runtime": inline_map[inline_id]["tc_runtime"], "tc_runtime": inline_map[inline_id]["tc_runtime"],
"status": desc, "status": desc,
"save_charge": mdp_res["save_charge"] if mdp_res["save_charge"] > 0 else 0, "save_charge": mdp_res["save_charge"] if mdp_res[
"save_charge"] > 0 else 0,
} }
) )
if sort_field in ["company_name", "save_charge"]: if sort_field in ["company_name", "save_charge"]:
all_list.sort( all_list.sort(
key=lambda x: x[sort_field], reverse=True if sort_direction == "desc" else False, key=lambda x: x[sort_field],
reverse=True if sort_direction == "desc" else False,
) )
return { return {
"rows": all_list[page_size * (page_num - 1): page_size * page_num], "rows": all_list[page_size * (page_num - 1): page_size * page_num],
...@@ -199,7 +204,8 @@ async def proxy_md_space_summary(cids, month_str, inline_map=None): ...@@ -199,7 +204,8 @@ async def proxy_md_space_summary(cids, month_str, inline_map=None):
[ [
round(i["save_charge"], 2) round(i["save_charge"], 2)
for i in md_spaces for i in md_spaces
if type(i["save_charge"]) in [int, float] and i["save_charge"] >= 0 if type(i["save_charge"]) in [int, float] and i[
"save_charge"] >= 0
] ]
), ),
2, 2,
...@@ -238,12 +244,14 @@ async def get_power_save_result(inline_ids, month_str): ...@@ -238,12 +244,14 @@ async def get_power_save_result(inline_ids, month_str):
sql = "select `inlid`, `cost_loss_percent`, `mean_load_factor`, " \ sql = "select `inlid`, `cost_loss_percent`, `mean_load_factor`, " \
"`kpi_x`, `save_charge` from `algo_economic_operation_result` " \ "`kpi_x`, `save_charge` from `algo_economic_operation_result` " \
"where `inlid` in %s and `month` = %s" "where `inlid` in %s and `month` = %s"
power_save_res_list = await conn.fetchall(sql, args=(inline_ids, month_str)) power_save_res_list = await conn.fetchall(sql,
args=(inline_ids, month_str))
return power_save_res_list return power_save_res_list
async def proxy_power_save_list( async def proxy_power_save_list(
cids, month_str, page_size=10, page_num=1, sort_field="company_name", sort_direction="asc", cids, month_str, page_size=10, page_num=1, sort_field="company_name",
sort_direction="asc",
): ):
async with MysqlUtil() as conn: async with MysqlUtil() as conn:
inline_sql = f"select `inlid`, `name`,cid cid, " \ inline_sql = f"select `inlid`, `name`,cid cid, " \
...@@ -279,10 +287,11 @@ async def proxy_power_save_list( ...@@ -279,10 +287,11 @@ async def proxy_power_save_list(
) )
if sort_field in ["company_name", "avg_load_rate", "save_charge"]: if sort_field in ["company_name", "avg_load_rate", "save_charge"]:
all_list.sort( all_list.sort(
key=lambda x: x[sort_field], reverse=True if sort_direction == "desc" else False, key=lambda x: x[sort_field],
reverse=True if sort_direction == "desc" else False,
) )
return { return {
"rows": all_list[page_size * (page_num - 1) : page_size * page_num], "rows": all_list[page_size * (page_num - 1): page_size * page_num],
"total": len(all_list), "total": len(all_list),
} }
...@@ -296,7 +305,8 @@ async def proxy_power_save_summary( ...@@ -296,7 +305,8 @@ async def proxy_power_save_summary(
inline_sql = f"select `inlid`, `name`, cid `cid`, " \ inline_sql = f"select `inlid`, `name`, cid `cid`, " \
f"`inline_tc`, `tc_runtime` from `inline` " \ f"`inline_tc`, `tc_runtime` from `inline` " \
f"where cid in %s order by cid" f"where cid in %s order by cid"
inlines = await conn.fetchall(inline_sql, args=(cids,)) if cids else [] inlines = await conn.fetchall(inline_sql,
args=(cids,)) if cids else []
inline_map = {i["inlid"]: i for i in inlines} inline_map = {i["inlid"]: i for i in inlines}
inline_ids = list(inline_map.keys()) inline_ids = list(inline_map.keys())
...@@ -312,7 +322,8 @@ async def proxy_power_save_summary( ...@@ -312,7 +322,8 @@ async def proxy_power_save_summary(
[ [
round(i["save_charge"], 2) round(i["save_charge"], 2)
for i in power_save_res_list for i in power_save_res_list
if type(i["save_charge"]) in [int, float] and i["save_charge"] >= 0 if type(i["save_charge"]) in [int, float] and i[
"save_charge"] >= 0
] ]
), ),
2, 2,
...@@ -332,7 +343,8 @@ async def proxy_power_save_summary( ...@@ -332,7 +343,8 @@ async def proxy_power_save_summary(
big_space_cnt += 1 big_space_cnt += 1
exits_space_cnt += 1 exits_space_cnt += 1
else: else:
log.error(f"power_save_res = {power_save_res} kpi_x={kpi_x}无法评价经济运行空间") log.error(
f"power_save_res = {power_save_res} kpi_x={kpi_x}无法评价经济运行空间")
return { return {
"total_cnt": len(power_save_res_list), "total_cnt": len(power_save_res_list),
...@@ -385,7 +397,8 @@ async def proxy_pcvf_list( ...@@ -385,7 +397,8 @@ async def proxy_pcvf_list(
"inline_id": inline_id, "inline_id": inline_id,
"inline_name": inline_map[inline_id]["name"], "inline_name": inline_map[inline_id]["name"],
"pcvf_index": power_pcvf["score"], "pcvf_index": power_pcvf["score"],
"save_charge": power_pcvf["cost_save"] if power_pcvf["cost_save"] > 0 else 0, "save_charge": power_pcvf["cost_save"] if power_pcvf[
"cost_save"] > 0 else 0,
} }
) )
...@@ -393,7 +406,7 @@ async def proxy_pcvf_list( ...@@ -393,7 +406,7 @@ async def proxy_pcvf_list(
if not all_inline_ids: if not all_inline_ids:
return {"rows": [], "total": 0} return {"rows": [], "total": 0}
# power_info_map = await inline_power_use_info(all_inline_ids, month_str) # power_info_map = await inline_power_use_info(all_inline_ids, month_str)
power_info_map = await inline_power_use_info_new15(all_inline_ids, month_str) power_info_map = await inline_power_use_info(all_inline_ids, month_str)
for i in all_list: for i in all_list:
power = 0 power = 0
charge = 0 charge = 0
...@@ -407,9 +420,11 @@ async def proxy_pcvf_list( ...@@ -407,9 +420,11 @@ async def proxy_pcvf_list(
i["power"] = power i["power"] = power
i["charge"] = charge i["charge"] = charge
if sort_field in ["company_name", "avg_price", "pcvf_index", "save_charge"]: if sort_field in ["company_name", "avg_price", "pcvf_index",
"save_charge"]:
all_list.sort( all_list.sort(
key=lambda x: x[sort_field], reverse=True if sort_direction == "desc" else False, key=lambda x: x[sort_field],
reverse=True if sort_direction == "desc" else False,
) )
page_rows = all_list[page_size * (page_num - 1): page_size * page_num] page_rows = all_list[page_size * (page_num - 1): page_size * page_num]
return { return {
...@@ -456,7 +471,8 @@ async def proxy_pcvf_summary( ...@@ -456,7 +471,8 @@ async def proxy_pcvf_summary(
big_space_cnt += 1 big_space_cnt += 1
exits_space_cnt += 1 exits_space_cnt += 1
else: else:
log.error(f"power_save_res = {power_pcvf_res} score={score}无法评价移峰填谷空间") log.error(
f"power_save_res = {power_pcvf_res} score={score}无法评价移峰填谷空间")
return { return {
"total_cnt": len(power_pcvf_res_list), "total_cnt": len(power_pcvf_res_list),
...@@ -486,7 +502,8 @@ async def proxy_electric_optimization_summary(cids, month_str): ...@@ -486,7 +502,8 @@ async def proxy_electric_optimization_summary(cids, month_str):
power_save_summary_map = await proxy_power_save_summary( power_save_summary_map = await proxy_power_save_summary(
inline_ids, month_str, inline_map=inline_map inline_ids, month_str, inline_map=inline_map
) )
power_pcvf_summary_map = await proxy_pcvf_summary(inline_ids, month_str, inline_map=inline_map) power_pcvf_summary_map = await proxy_pcvf_summary(inline_ids, month_str,
inline_map=inline_map)
return { return {
"power_factor": { "power_factor": {
......
...@@ -9,8 +9,8 @@ from unify_api.modules.electric_optimization.procedures.optimization_pds import ...@@ -9,8 +9,8 @@ from unify_api.modules.electric_optimization.procedures.optimization_pds import
month_md_space month_md_space
) )
from unify_api.modules.electric_optimization.procedures.optimization_pds import ( from unify_api.modules.electric_optimization.procedures.optimization_pds import (
inline_power_use_info, month_power_pcvf, month_power_factors, month_power_pcvf, month_power_factors, month_power_loadrate,
month_power_loadrate, inline_power_use_info_new15 load_inline_power
) )
from unify_api.constants import ADD_ELE_PRICE from unify_api.constants import ADD_ELE_PRICE
from unify_api.modules.elec_charge.dao.elec_charge_dao import ( from unify_api.modules.elec_charge.dao.elec_charge_dao import (
...@@ -142,8 +142,7 @@ async def power_peakcut_service(inline_id): ...@@ -142,8 +142,7 @@ async def power_peakcut_service(inline_id):
) )
end_time = pendulum.datetime(now.year, now.month, 1).strftime( end_time = pendulum.datetime(now.year, now.month, 1).strftime(
"%Y-%m-%d %H:%M:%S") "%Y-%m-%d %H:%M:%S")
power_use_info = await inline_power_use_info_new15(inline_id, start_time, power_use_info = await load_inline_power(inline_id, start_time, end_time)
end_time)
month_kwh = power_use_info.get("kwh") or 0 month_kwh = power_use_info.get("kwh") or 0
month_charge = power_use_info.get("charge") or 0 month_charge = power_use_info.get("charge") or 0
avg_price = month_kwh / month_charge if month_charge else "" avg_price = month_kwh / month_charge if month_charge else ""
......
...@@ -13,7 +13,7 @@ from unify_api.modules.common.procedures.points import proxy_points, list_point ...@@ -13,7 +13,7 @@ from unify_api.modules.common.procedures.points import proxy_points, list_point
from unify_api.modules.elec_charge.dao.elec_charge_dao import \ from unify_api.modules.elec_charge.dao.elec_charge_dao import \
query_charge_aggs_points, point_aggs_kwh query_charge_aggs_points, point_aggs_kwh
from unify_api.modules.elec_charge.procedures.elec_charge_pds import \ from unify_api.modules.elec_charge.procedures.elec_charge_pds import \
proxy_power, proxy_power15 load_proxy_power
from unify_api.modules.home_page.components.count_info_proxy_cps import \ from unify_api.modules.home_page.components.count_info_proxy_cps import \
IycResp, IycmResp, RtrResp, AlarmLevelCnt, AlarmContentCnt, CmResp, \ IycResp, IycmResp, RtrResp, AlarmLevelCnt, AlarmContentCnt, CmResp, \
ApcResp, AsiResp, HsiResp, AiiResp ApcResp, AsiResp, HsiResp, AiiResp
...@@ -51,7 +51,7 @@ async def post_zd_info_factory_service(cid_list): ...@@ -51,7 +51,7 @@ async def post_zd_info_factory_service(cid_list):
safe_operation_days += safe_run_days safe_operation_days += safe_run_days
total_alarm += alarm_count total_alarm += alarm_count
# 4. 累计监测用电 # 4. 累计监测用电
total_power = await proxy_power15(cid_list) total_power = await load_proxy_power(cid_list)
# 5. 日均碳排放 = 累计用电 * 0.754 / 总运行天数 # 5. 日均碳排放 = 累计用电 * 0.754 / 总运行天数
# 运行天数 # 运行天数
sql = "select create_time from company where cid = %s" sql = "select create_time from company where cid = %s"
...@@ -127,28 +127,6 @@ async def risk_cost_service(cid): ...@@ -127,28 +127,6 @@ async def risk_cost_service(cid):
async def safe_run_sdu(cid, total_tenant): async def safe_run_sdu(cid, total_tenant):
"""sdu安全运行天数"""
# 1. 每一个point总安装天数
# 安装时间create_time
async with MysqlUtil() as conn:
company_sql = "select create_time from company where cid = %s"
company = await conn.fetchone(company_sql, (cid,))
create_time_timestamp = company["create_time"]
create_time = datetime.fromtimestamp(create_time_timestamp)
now_time = datetime.now()
# +2表示包过其实日期
total_days = (now_time - create_time).days + 2
# 2. 根据每日聚合结果
es_res = await sdu_alarm_aggs_date(cid)
for buckets in es_res:
doc_count = buckets["doc_count"]
# 当工厂某天I级、II级报警总数小于总户数 * 5 % 时,即为安全运行
if doc_count > total_tenant * 0.05:
total_days -= 1
return total_days
async def safe_run_sdu_new15(cid, total_tenant):
# 1. 每一个point总安装天数 # 1. 每一个point总安装天数
# 安装时间create_time # 安装时间create_time
company_sql = "select create_time from company where cid = %s" company_sql = "select create_time from company where cid = %s"
......
...@@ -5,15 +5,15 @@ from pot_libs.sanic_api import summary ...@@ -5,15 +5,15 @@ from pot_libs.sanic_api import summary
from unify_api.constants import Product, PRODUCT from unify_api.constants import Product, PRODUCT
from unify_api.modules.common.dao.common_dao import monitor_by_cid from unify_api.modules.common.dao.common_dao import monitor_by_cid
from unify_api.modules.common.procedures.alarm_cps import alarm_count, \ from unify_api.modules.common.procedures.alarm_cps import alarm_count, \
alarm_count_sdu_new, alarm_count_sdu_new15 load_alarm_cnt_sdu
from unify_api.modules.common.procedures.cids import get_cids, get_cid_info, \ from unify_api.modules.common.procedures.cids import get_cids, get_cid_info, \
get_proxy_cids get_proxy_cids
from unify_api.modules.common.procedures.common_cps import proxy_safe_run_info from unify_api.modules.common.procedures.common_cps import proxy_safe_run_info
from unify_api.modules.common.procedures.points import proxy_points, get_points from unify_api.modules.common.procedures.points import proxy_points, get_points
from unify_api.modules.common.procedures.power_cps import power_use_count, \ from unify_api.modules.common.procedures.power_cps import power_use_count, \
power_use_count_new15 load_cmpy_power
from unify_api.modules.elec_charge.procedures.elec_charge_pds import \ from unify_api.modules.elec_charge.procedures.elec_charge_pds import \
proxy_power, proxy_power15 load_proxy_power
from unify_api.modules.home_page.components.count_info_proxy_cps import ( from unify_api.modules.home_page.components.count_info_proxy_cps import (
CountInfoProxyResp, CountInfoProxyResp,
ProxySecurityLevelCntResp, ProxySecurityLevelCntResp,
...@@ -45,7 +45,7 @@ from unify_api.modules.home_page.procedures.count_info_proxy_pds import ( ...@@ -45,7 +45,7 @@ from unify_api.modules.home_page.procedures.count_info_proxy_pds import (
from unify_api.modules.home_page.procedures.security_info_pds import \ from unify_api.modules.home_page.procedures.security_info_pds import \
alarm_count_info_new15 alarm_count_info_new15
from unify_api.modules.home_page.service.count_info_service import \ from unify_api.modules.home_page.service.count_info_service import \
safe_run_sdu, safe_run_sdu_new15 safe_run_sdu
from unify_api.modules.elec_charge.components.elec_charge_cps import \ from unify_api.modules.elec_charge.components.elec_charge_cps import \
ProductProxyReq ProductProxyReq
from unify_api.modules.users.procedures.jwt_user import jwt_user from unify_api.modules.users.procedures.jwt_user import jwt_user
...@@ -79,7 +79,7 @@ async def post_count_info_proxy(req) -> CountInfoProxyResp: ...@@ -79,7 +79,7 @@ async def post_count_info_proxy(req) -> CountInfoProxyResp:
safe_operation_days += safe_run_days safe_operation_days += safe_run_days
total_alarm += alarm_count total_alarm += alarm_count
# 4. 累计监测用电 # 4. 累计监测用电
total_power = await proxy_power15(cid_list) total_power = await load_proxy_power(cid_list)
return CountInfoProxyResp( return CountInfoProxyResp(
total_cid=total_cid, total_cid=total_cid,
total_monitor=total_monitor, total_monitor=total_monitor,
...@@ -278,7 +278,7 @@ async def post_zhidian_info_proxy(req, body: ProductProxyReq) -> AipResp: ...@@ -278,7 +278,7 @@ async def post_zhidian_info_proxy(req, body: ProductProxyReq) -> AipResp:
# 2. 监测点位 # 2. 监测点位
total_monitor = await proxy_points(cid_list) total_monitor = await proxy_points(cid_list)
# 3. 累计监测用电 # 3. 累计监测用电
total_power = await proxy_power15(cid_list) total_power = await load_proxy_power(cid_list)
# 4. 用户接入总时长, 每个工厂接入时长总和 # 4. 用户接入总时长, 每个工厂接入时长总和
total_run_day = await total_run_day_proxy(cid_list) total_run_day = await total_run_day_proxy(cid_list)
return AipResp( return AipResp(
...@@ -298,13 +298,13 @@ async def post_count_info_sdu_new(req, body: CisReq) -> CisResp: ...@@ -298,13 +298,13 @@ async def post_count_info_sdu_new(req, body: CisReq) -> CisResp:
total_tenant = len(monitor_list) total_tenant = len(monitor_list)
# 2. 安全运行天数: 以天计,当工厂某天I级、II级报警总数小于总户数*5%时,即为安全运行, # 2. 安全运行天数: 以天计,当工厂某天I级、II级报警总数小于总户数*5%时,即为安全运行,
# 展示自接入累加安全运行天数 # 展示自接入累加安全运行天数
safe_day = await safe_run_sdu_new15(cid, total_tenant) safe_day = await safe_run_sdu(cid, total_tenant)
# 3. 在线率 # 3. 在线率
online_rate = 88 + random.choice([1, 1.5, 2, 2.5, 3, 3.5, 4]) online_rate = 88 + random.choice([1, 1.5, 2, 2.5, 3, 3.5, 4])
# 4.累计用电 # 4.累计用电
total_power = await power_use_count_new15(cids) total_power = await load_cmpy_power(cids)
# 5. 累计报警 # 5. 累计报警
total_alarm = await alarm_count_sdu_new15(cids) total_alarm = await load_alarm_cnt_sdu(cids)
return CisResp( return CisResp(
total_tenant=total_tenant, total_tenant=total_tenant,
online_rate=online_rate, online_rate=online_rate,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment