Commit 49f61cbc authored by wang.wenrong's avatar wang.wenrong

安电u+

parent 884ef9e5
......@@ -3,7 +3,7 @@ from dataclasses import dataclass
from pot_libs.common.components.fields import Cid
from pot_libs.sanic_api import Model
from pot_libs.sanic_api.column import Float, List, Str, Opt, Int, Dict
from unify_api.utils.response_code import DbErr
from unify_api.utils.response_code import DbErr, ServerErr
@dataclass
......@@ -186,3 +186,14 @@ class KclReq(Model):
class ProductProxyReq(Model):
product: int = Opt(Int("项目id"))
proxy_id: int = Opt(Int("代理id, 当product是管理版3,5时 必传"))
@dataclass
class LoadInfoReq(Model):
product: int = Opt(Int("项目id"))
proxy_id: int = Opt(Int("代理id, 当product是管理版3,5时 必传"))
@dataclass
class LoadInfoResp(Model, DbErr, ServerErr):
current_load: float = Opt(Float("今日实时负荷, 单位kW").eg(8263.2))
yesterday_load: float = Opt(Float("昨日同时负荷, 单位kW").eg(8000))
load_percent: float = Opt(Float("对比昨日,百分比").eg(1))
......@@ -888,7 +888,7 @@ async def elec_current_service_new15(point_id):
url = f"{SETTING.stb_url}db_electric?tz=Asia/Shanghai"
sql = f"select last_row(*) from mt{mtid}_ele where pid={point_id}"
is_succ, results = await get_td_engine_data(url, sql)
if not is_succ:
if not is_succ or not results:
return '', {}
head = parse_td_columns(results)
if not results["data"]:
......
......@@ -58,6 +58,7 @@ from unify_api.modules.electric.components.electric import (
from unify_api.utils.request_util import filed_value_from_list
from unify_api.modules.electric.dao.electric_dao import get_qual_history_dao,\
get_elec_history_dao
from unify_api.utils.taos_new import parse_td_columns
METERDATA_CURRENT_KEY = "meterdata_current"
METERDATA_CURRENT_HR_KEY = "meterdata_hr_current"
......
......@@ -118,6 +118,8 @@ def td3_tbl_compate(td_tables):
def parse_td_columns(rsp_data):
head = []
if not rsp_data.get("column_meta"):
return []
for col in rsp_data["column_meta"]:
r = re.findall(r'last_row\((.*)\)', col[0])
tbl_field = r[0] if r else col[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