elec_statistics_cps.py 2.18 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 64 65 66 67 68 69 70
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 Int, Str, List, Opt, Dict


@dataclass
class PcStatiReq(Model):
    cid: Cid
    point_id: int = Int("point_id").eg(-1)
    date_type: str = Str("时间类型->day/month/year/range").eg("day")
    start: str = Str("开始时间").eg("2020-07-30 00:00:00")
    end: str = Str("结束时间").eg("2020-07-30 23:59:59")


@dataclass
class SlotValue(Model):
    slots: list = List("slots").eg(["00:00", "00:15", "00:30"])
    value: list = List("时间段对应的值").eg([0.1, 0.2, 0.3])


@dataclass
class PcStatiResp(Model):
    kwh: SlotValue = Opt(SlotValue)
    charge: SlotValue = Opt(SlotValue)
    today_p: SlotValue = Opt(SlotValue)
    yesterday_p: SlotValue = Opt(SlotValue)
    this_aver_price: SlotValue = Opt(SlotValue)
    last_aver_price: SlotValue = Opt(SlotValue)
    kwh_15min: SlotValue = Opt(SlotValue)
    charge_15min: SlotValue = Opt(SlotValue)
    co2: SlotValue = Opt(SlotValue)  # 智电U加co2


@dataclass
class MaxpReq(Model):
    cid: Cid
    point_id: int = Int("point_id").eg(-1)
    start: str = Str("开始时间").eg("2020-07-30 00:00:00")
    end: str = Str("结束时间").eg("2020-07-30 23:59:59")


@dataclass
class MaxpResp(Model):
    maxp: int = Int("最大需量").eg(380)
    date_time: str = Str("时间点").eg("2020-05-07 18:30")


@dataclass
class PcDownloadReq(Model):
    cid: Cid
    point_id: int = Int("point_id").eg(-1)
    start: str = Str("开始时间").eg("2020-07-30 00:00:00")
    end: str = Str("结束时间").eg("2020-07-30 23:59:59")


@dataclass
class PcDownloadResp(Model):
    kwh: SlotValue = Opt(SlotValue)
    charge: SlotValue = Opt(SlotValue)


@dataclass
class PcmResp(Model):
    max_p: dict = Dict("最大需量").eg({"value": 100.1, "time": "11:00-12:00"})
    max_kwh: dict = Dict("电量最多").eg({"value": 100.1, "time": "11:00-12:00"})
    min_kwh: dict = Dict("电量最少").eg({"value": 10.1, "time": "11:00-12:00"})
    max_charge: dict = Dict("电费最多").eg({"value": 100.1, "time": "11:00-12:00"})
    min_charge: dict = Dict("电费最少").eg({"value": 100.1, "time": "11:00-12:00"})