analysis_result.py 1.37 KB
Newer Older
lcn's avatar
lcn committed
1 2 3 4 5 6
from pot_libs.sanic_api import summary, description
from unify_api.modules.shidianu.components.algorithm_cps import (
    AlgorithmOutput,
    AlgorithmInput, WcReq, WcResp, AbcResp, AbcReq,
)
from unify_api.modules.shidianu.procedures.analysis_result_service import \
ZZH's avatar
ZZH committed
7
    wave_curve_srv, alarm_behavior_curve_service
lcn's avatar
lcn committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
from unify_api.modules.shidianu.procedures.output_result import algorithm_result_to_front
from unify_api.utils.time_format import srv_time


@summary("识电U识别结果输出接口")
@description("识电U")
async def post_algorithm_output(req, body: AlgorithmInput) -> AlgorithmOutput:
    point_id = body.point_id
    req_date = body.req_date
    product_id = 4  # PRODUCT.get(req.host)
    user_id = req.ctx.user_id
    detail = body.detail
    return await algorithm_result_to_front(point_id, req_date, user_id, product_id, detail)


@summary("识电u-行为曲线")
async def post_wave_curve(req, body: WcReq) -> WcResp:
    point_id = body.point_id
    req_date = body.req_date
    product = body.product
ZZH's avatar
ZZH committed
28
    return await wave_curve_srv(point_id, req_date, product)
lcn's avatar
lcn committed
29 30 31 32 33 34 35 36 37 38 39


@summary("识电u-用电行为-近30天统计")
async def post_alarm_behavior_curve(req, body: AbcReq) -> AbcResp:
    point_id = body.point_id
    product = body.product
    now_date, timestamp = srv_time()
    req_date = now_date[:10]
    return await alarm_behavior_curve_service(point_id, req_date, product)