health_index.py 1.77 KB
Newer Older
lcn's avatar
lcn committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
# -*- coding:utf-8 -*-
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, Int, Str, Opt
from pot_libs.common.components.fields import DateTime


@dataclass
class QueryDetails(Model):
    cid: Cid


@dataclass
class ProductReq(Model):
    product: int = Int("产品类型").eg("6-智电U")
    cid: int = Opt(Int("工厂id").eg(66))
    proxy_id: int = Opt(Int("代理id").eg(66))


@dataclass
class HealthIndexResp(Model):
    health_index: float = Float("用电健康指数").eg(94)


@dataclass
class HealthRadarResp(Model):
    """健康指数雷达(评分)"""

    v_dev: int = Int("电压偏差评分")
    freq_dev: int = Int("频率偏差评分")
    ubl: int = Int("三相[电压]不平衡评分")
    costtl: int = Int("功率因数评分")
    thdu: int = Int("谐波畸变评分")
    lf: int = Int("负载率评分")


@dataclass
class HealthCtlRateRes(Model):
    """健康参数达标率"""

    real_time: DateTime = DateTime
    lf: float = Float("负载率达标率")
    costtl: float = Float("功率因数达标率")
    thdu: float = Float("谐波畸变达标率")
    v_dev: float = Float("电压偏差达标率")
    freq_dev: float = Float("频率偏差达标率")
    ubl: float = Float("三相[电压]不平衡达标率")


@dataclass
class ManageHealthIndexReq(Model):
    product: int = Int("产品类别1-知电 2-安电 3-安电U管理版").eg(3)
    proxy_id: int = Opt(Int("代理id").eg(1))


@dataclass
class ManageHealthIndexResp(Model):
    excellent_cnt: int = Int("优秀级别的工厂个数").eg(4)
    good_cnt: int = Int("良好的工厂个数").eg(3)
    fair_cnt: int = Int("及格的工厂个数").eg(5)
    bad_cnt: int = Int("差的工厂个数").eg(1)