load_forecast.py 809 Bytes
Newer Older
lcn's avatar
lcn committed
1 2
from pot_libs.sanic_api import summary
from unify_api.modules.load_analysis.components.load_forecast_cps import (
ZZH's avatar
ZZH committed
3
    ForecastReq, ForecastResp,
lcn's avatar
lcn committed
4 5
)
from unify_api.modules.load_analysis.service.load_forecast_service import \
ZZH's avatar
ZZH committed
6
    load_forecast_srv
lcn's avatar
lcn committed
7
from unify_api.utils.time_format import time_pick_transf_new
lcn's avatar
lcn committed
8 9 10 11 12 13 14 15 16 17 18


@summary("负荷预测")
async def post_load_forecast(req, body: ForecastReq) -> ForecastResp:
    """负荷预测"""
    # 1.获取参数
    cid = body.cid
    start = body.start
    end = body.end
    # 管理版本多个工厂的情况, 兼容能力最强的参数cids, 保留旧有的cid:
    cids = body.cids
lcn's avatar
lcn committed
19 20 21
    terms = cids if cids else [cid]
    # 获取时间差
    interval, slots = time_pick_transf_new(start, end)
ZZH's avatar
ZZH committed
22
    return await load_forecast_srv(terms, start, end, interval, slots)