Commit 95140e9a authored by lcn's avatar lcn

bug修复

parent fd3450a0
...@@ -16,7 +16,7 @@ async def new_list_alarm_dao(cid, points, page_num, page_size, start, end, ...@@ -16,7 +16,7 @@ async def new_list_alarm_dao(cid, points, page_num, page_size, start, end,
# #
# if product == Product.RecognitionElectric.value: # 识电u # if product == Product.RecognitionElectric.value: # 识电u
alarm_list = SDU_ALARM_LIST alarm_list = SDU_ALARM_LIST
query_body = { query_body = {
"from": (page_num - 1) * page_size, "from": (page_num - 1) * page_size,
"size": page_size, "size": page_size,
...@@ -126,12 +126,12 @@ async def new_list_alarm_dao_new15(cid, points, start, end, importance, offset, ...@@ -126,12 +126,12 @@ async def new_list_alarm_dao_new15(cid, points, start, end, importance, offset,
async def wx_list_alarm_dao(cids, product, start, end): async def wx_list_alarm_dao(cids, product, start, end):
"""小程序消息列表, 取当前范围最新40条""" """小程序消息列表, 取当前范围最新40条"""
# alarm_list = list(EVENT_TYPE_MAP.keys()) # 安电u # alarm_list = list(EVENT_TYPE_MAP.keys()) # 安电u
# #
# if product == Product.RecognitionElectric.value: # 识电u # if product == Product.RecognitionElectric.value: # 识电u
alarm_list = SDU_ALARM_LIST alarm_list = SDU_ALARM_LIST
query_body = { query_body = {
"size": 40, "size": 40,
"query": { "query": {
...@@ -171,7 +171,7 @@ async def wx_list_alarm_dao(cids, product, start, end): ...@@ -171,7 +171,7 @@ async def wx_list_alarm_dao(cids, product, start, end):
} }
} }
) )
log.info(f"index:{index}--query_body:{query_body}") log.info(f"index:{index}--query_body:{query_body}")
async with EsUtil() as es: async with EsUtil() as es:
es_re = await es.search_origin(body=query_body, index=index) es_re = await es.search_origin(body=query_body, index=index)
...@@ -181,7 +181,7 @@ async def wx_list_alarm_dao(cids, product, start, end): ...@@ -181,7 +181,7 @@ async def wx_list_alarm_dao(cids, product, start, end):
async def list_alarm_zdu_dao(cid, points, page_num, page_size, start, end, async def list_alarm_zdu_dao(cid, points, page_num, page_size, start, end,
importance, event_type): importance, event_type):
"""智电u, es报警信息分页列表, 可根据报警等级筛选""" """智电u, es报警信息分页列表, 可根据报警等级筛选"""
query_body = { query_body = {
"from": (page_num - 1) * page_size, "from": (page_num - 1) * page_size,
"size": page_size, "size": page_size,
...@@ -268,7 +268,7 @@ async def list_alarm_zdu_dao_new15(cid, points, start, ...@@ -268,7 +268,7 @@ async def list_alarm_zdu_dao_new15(cid, points, start,
async def wx_list_alarm_zdu_dao(cid, points, start, end): async def wx_list_alarm_zdu_dao(cid, points, start, end):
"""智电u, wx小程序, 取当前范围最新100条""" """智电u, wx小程序, 取当前范围最新100条"""
query_body = { query_body = {
"size": 100, "size": 100,
"query": { "query": {
...@@ -350,10 +350,13 @@ async def alarm_content_time_distribution_dao(cid, start, end, ): ...@@ -350,10 +350,13 @@ async def alarm_content_time_distribution_dao(cid, start, end, ):
""" """
智电温度漏电流电参数分布 智电温度漏电流电参数分布
""" """
mid_li = [f"cid={cid}"] if isinstance(cid, list):
mid_li = [f"cid in {str(tuple(cid)).replace(',)', ')')}"]
else:
mid_li = [f"cid={cid}"]
if start and end: if start and end:
mid_li.append(f"event_datetime BETWEEN '{start}' and '{end}'") mid_li.append(f"event_datetime BETWEEN '{start}' and '{end}'")
sql = f""" sql = f"""
SELECT SELECT
event_type, event_type,
......
...@@ -66,7 +66,10 @@ async def post_list_alarm(req, body: PageRequest) -> ListAlarmResponse: ...@@ -66,7 +66,10 @@ async def post_list_alarm(req, body: PageRequest) -> ListAlarmResponse:
# cids = await get_cids(user_id, product) # cids = await get_cids(user_id, product)
proxy_cids = await get_proxy_cids(user_id, product, proxy_id) proxy_cids = await get_proxy_cids(user_id, product, proxy_id)
cids = list(set(req_cids) & set(proxy_cids)) if req_cids and proxy_cids:
cids = list(set(req_cids) & set(proxy_cids))
else:
cids = proxy_cids
if req.json.get("product") in [Product.RecognitionElectric.value, if req.json.get("product") in [Product.RecognitionElectric.value,
Product.IntelligentU.value]: Product.IntelligentU.value]:
......
...@@ -14,7 +14,11 @@ async def post_elec_count_info(req, body: ProxyRankingReq) -> ProxyRankingResp: ...@@ -14,7 +14,11 @@ async def post_elec_count_info(req, body: ProxyRankingReq) -> ProxyRankingResp:
product = body.product product = body.product
# sql = "SELECT cid,safe_exp,health_exp,ele_quan,ele_charge " \ # sql = "SELECT cid,safe_exp,health_exp,ele_quan,ele_charge " \
# "FROM safe_health_stats_cid where cid in %s and cal_month = %s" # "FROM safe_health_stats_cid where cid in %s and cal_month = %s"
sql = "SELECT safe_exp,health_exp,ele_quan,ele_charge,shsc.cid," \ sql = "SELECT ifnull(safe_exp,0) safe_exp," \
"ifnull(health_exp,0) health_exp," \
"ifnull(ele_quan,0) ele_quan," \
"ifnull(ele_charge,0) ele_charge," \
"shsc.cid," \
"company.shortname FROM safe_health_stats_cid shsc " \ "company.shortname FROM safe_health_stats_cid shsc " \
"left join company on shsc.cid=company.cid where " \ "left join company on shsc.cid=company.cid where " \
"shsc.cid in %s and shsc.cal_month = %s" "shsc.cid in %s and shsc.cal_month = %s"
......
...@@ -63,7 +63,7 @@ async def other_info(company_id): ...@@ -63,7 +63,7 @@ async def other_info(company_id):
# 获取到工厂安装时间create_time # 获取到工厂安装时间create_time
async with MysqlUtil() as conn: async with MysqlUtil() as conn:
company_sql = "select create_time from company where cid = %s" company_sql = "select create_time from company where cid = %s"
alarm_data = await conn.fetchone(alarm_sql, (company_id,)) alarm_data = await conn.fetchall(alarm_sql, (company_id,))
company = await conn.fetchone(company_sql, (company_id,)) company = await conn.fetchone(company_sql, (company_id,))
create_time_timestamp = company["create_time"] create_time_timestamp = company["create_time"]
create_time = datetime.fromtimestamp(create_time_timestamp) create_time = datetime.fromtimestamp(create_time_timestamp)
......
...@@ -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_power(cid_list) total_power = await proxy_power15(cid_list)
return CountInfoProxyResp( return CountInfoProxyResp(
total_cid=total_cid, total_cid=total_cid,
total_monitor=total_monitor, total_monitor=total_monitor,
......
...@@ -120,7 +120,7 @@ async def post_alarm_content_distribution( ...@@ -120,7 +120,7 @@ async def post_alarm_content_distribution(
date_type = body.date_type date_type = body.date_type
if product == Product.AndianUManage.value: if product == Product.AndianUManage.value:
user_id = request.ctx.user_id user_id = jwt_user(request)
# cids = await get_cids(user_id, product) # cids = await get_cids(user_id, product)
proxy_id = body.proxy_id proxy_id = body.proxy_id
cids = await get_proxy_cids(user_id, product, proxy_id) cids = await get_proxy_cids(user_id, product, proxy_id)
...@@ -129,7 +129,7 @@ async def post_alarm_content_distribution( ...@@ -129,7 +129,7 @@ async def post_alarm_content_distribution(
else: else:
raise BusinessException(message=f"暂时不支持其他产品") raise BusinessException(message=f"暂时不支持其他产品")
alarm_info_map = await alarm_content_time_distribution_pds(req_cids, start, end, date_type) alarm_info_map = await alarm_content_time_distribution_pds(req_cids, start, end)
temperature, residual_current, electric_param, electric_param_detail = ( temperature, residual_current, electric_param, electric_param_detail = (
alarm_info_map["temperature"], alarm_info_map["temperature"],
alarm_info_map["residual_current"], alarm_info_map["residual_current"],
......
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