Commit 46311c41 authored by lcn's avatar lcn

BUG修复

parent 4fbf8ca1
......@@ -260,14 +260,14 @@ async def list_alarm_service_new15(cid, point_id, start, end, importance,
if len(importance) == 1:
li.append(f"importance={importance[0]}")
else:
li.append(f"importance in {tuple(importance)}")
li.append(f"importance in {str(tuple(importance)).strip(',')}")
else:
li.append("importance in (1, 2, 3)")
if alarm_type:
if len(alarm_type) == 1:
li.append(f"event_type='{alarm_type[0]}'")
else:
li.append(f"event_type in {tuple(alarm_type)}")
li.append(f"event_type in {str(tuple(alarm_type)).strip(',')}")
mid_sql = " and ".join(li)
total = await get_total_list_alarm_dao(mid_sql)
mid_sql2 = " and ".join(["point_1min_event."+i for i in li])
......
......@@ -32,15 +32,26 @@ from unify_api.modules.alarm_manager.components.list_alarm import (
@summary("返回报警信息列表")
@description("筛选字段:监测点")
# @examples(list_alarm_example)
async def post_list_alarm(req, body: ListAlarmReq) -> ListAlarmResponse:
cid = body.cid
point_id = body.point_id
start = body.start
end = body.end
importance = body.importance
async def post_list_alarm(req, body: PageRequest) -> ListAlarmResponse:
cid = req.json.get("cid")
page_size = body.page_size
page_num = body.page_num
alarm_type = body.alarm_type
start, end = '', ''
point_id = None
alarm_type = []
importance = []
if body.filter.ranges:
_range = body.filter.ranges[0]
_, start, end = _range.field, _range.start, _range.end
if body.filter.equals:
_equal = body.filter.equals[0]
point_id = _equal.value
if body.filter.in_groups:
for in_group in body.filter.in_groups:
if in_group.field == 'type':
alarm_type = in_group.group
elif in_group.field == 'importance':
importance = in_group.group
return await list_alarm_service_new15(cid, point_id, start, end,
importance, page_size, page_num,
alarm_type)
......
......@@ -4,7 +4,7 @@ from pot_libs.mysql_util.mysql_util import MysqlUtil
async def get_annual_sunshine_hours(cid):
sql = "SELECT pv.annual_effective_hours FROM " \
"`algorithm_distributed_pv_quick_check_list` pv " \
"`algo_distributed_pv_quick_check_list` pv " \
"LEFT JOIN company c on c.city =pv.city where c.cid=%s"
async with MysqlUtil() as conn:
hours = await conn.fetchone(sql, args=(cid,))
......@@ -12,7 +12,7 @@ async def get_annual_sunshine_hours(cid):
async def get_p(cid):
sql = "SELECT pv.hour, pv.p FROM `algorithm_distributed_pv` pv " \
sql = "SELECT pv.hour, pv.p FROM `algo_distributed_pv` pv " \
"LEFT JOIN company c on c.city =pv.city where c.cid=%s"
async with MysqlUtil() as conn:
datas = await conn.fetchall(sql, args=(cid,))
......@@ -29,8 +29,8 @@ async def get_elec_price_dao(cid):
async def get_max_demand_by_inlid(inlids):
sql = """SELECT a.has_space,b.related_inlids FROM
`algorithm_md_space_analysis_result` a
LEFT JOIN algorithm_md_space_analysis_unit b on a.space_analysis_id=b.id
`algo_md_space_analysis_result` a
LEFT JOIN algo_md_space_analysis_unit b on a.space_analysis_id=b.id
WHERE b.related_inlids in %s ORDER BY a.create_time DESC LIMIT %s"""
async with MysqlUtil() as conn:
spaces = await conn.fetchall(sql, args=(inlids, len(inlids)))
......@@ -52,7 +52,7 @@ async def insert_price_policy_data_dao(cid, inline_id, start_month, quarters,
async def inset_algorithm_power_factor_dao(inline_id, start_time, std_cos):
sql = """INSERT INTO `algorithm_power_factor` (`inlid`, `start_time`,
sql = """INSERT INTO `algo_power_factor` (`inlid`, `start_time`,
`valid`, `std_cos`) VALUES ( %s, %s, %s, %s); """
async with MysqlUtil() as conn:
await conn.execute(sql, args=(inline_id, start_time, 1, std_cos))
......@@ -60,7 +60,7 @@ async def inset_algorithm_power_factor_dao(inline_id, start_time, std_cos):
async def get_algorithm_power_factor_dao(cid):
sql = "select a.std_cos from algorithm_power_factor a " \
sql = "select a.std_cos from algo_power_factor a " \
"LEFT JOIN inline_zdu line on line.inlid =a.inlid " \
"WHERE line.cid_belongedto = %s ORDER BY a.start_time desc limit 1"
async with MysqlUtil() as conn:
......
......@@ -12,4 +12,4 @@ async def get_co2_price():
await aredis_utils.RedisUtils().set("co2_price", co2_price)
except:
co2_price = await aredis_utils.RedisUtils().get("co2_price")
return co2_price
return co2_price or 0
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