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,
#
# if product == Product.RecognitionElectric.value: # 识电u
alarm_list = SDU_ALARM_LIST
query_body = {
"from": (page_num - 1) * page_size,
"size": page_size,
......@@ -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):
"""小程序消息列表, 取当前范围最新40条"""
# alarm_list = list(EVENT_TYPE_MAP.keys()) # 安电u
#
# if product == Product.RecognitionElectric.value: # 识电u
alarm_list = SDU_ALARM_LIST
query_body = {
"size": 40,
"query": {
......@@ -171,7 +171,7 @@ async def wx_list_alarm_dao(cids, product, start, end):
}
}
)
log.info(f"index:{index}--query_body:{query_body}")
async with EsUtil() as es:
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):
async def list_alarm_zdu_dao(cid, points, page_num, page_size, start, end,
importance, event_type):
"""智电u, es报警信息分页列表, 可根据报警等级筛选"""
query_body = {
"from": (page_num - 1) * page_size,
"size": page_size,
......@@ -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):
"""智电u, wx小程序, 取当前范围最新100条"""
query_body = {
"size": 100,
"query": {
......@@ -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:
mid_li.append(f"event_datetime BETWEEN '{start}' and '{end}'")
sql = f"""
SELECT
event_type,
......
......@@ -66,7 +66,10 @@ async def post_list_alarm(req, body: PageRequest) -> ListAlarmResponse:
# cids = await get_cids(user_id, product)
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,
Product.IntelligentU.value]:
......
......@@ -14,7 +14,11 @@ async def post_elec_count_info(req, body: ProxyRankingReq) -> ProxyRankingResp:
product = body.product
# sql = "SELECT cid,safe_exp,health_exp,ele_quan,ele_charge " \
# "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 " \
"left join company on shsc.cid=company.cid where " \
"shsc.cid in %s and shsc.cal_month = %s"
......
......@@ -63,7 +63,7 @@ async def other_info(company_id):
# 获取到工厂安装时间create_time
async with MysqlUtil() as conn:
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,))
create_time_timestamp = company["create_time"]
create_time = datetime.fromtimestamp(create_time_timestamp)
......
......@@ -79,7 +79,7 @@ async def post_count_info_proxy(req) -> CountInfoProxyResp:
safe_operation_days += safe_run_days
total_alarm += alarm_count
# 4. 累计监测用电
total_power = await proxy_power(cid_list)
total_power = await proxy_power15(cid_list)
return CountInfoProxyResp(
total_cid=total_cid,
total_monitor=total_monitor,
......
......@@ -120,7 +120,7 @@ async def post_alarm_content_distribution(
date_type = body.date_type
if product == Product.AndianUManage.value:
user_id = request.ctx.user_id
user_id = jwt_user(request)
# cids = await get_cids(user_id, product)
proxy_id = body.proxy_id
cids = await get_proxy_cids(user_id, product, proxy_id)
......@@ -129,7 +129,7 @@ async def post_alarm_content_distribution(
else:
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 = (
alarm_info_map["temperature"],
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