order_operations.py 4.16 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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
from pot_libs.sanic_api import summary
from unify_api.modules.zhiwei_u.components.warning_operations_cps import \
    SelectUserResp, Success, SuccessResp, FileSuccess
from unify_api.modules.zhiwei_u.components.order_operations_cps import \
    ReceiveOrderReq, ReceiveOrderResp, FlowOrderReq, WorkOrderReq, \
    AddOrderReq, SidToOrderReq, SidToOrderResp, PidToSidReq, \
    DeleteOrderFileReq
from unify_api.modules.zhiwei_u.service.order_operations_service import \
    receive_order_service, flow_order_user_service, flow_order_service, \
    work_order_service, close_order_service, add_order_service, \
    sid_to_order_service, pid_to_sid_service, search_all_user_service, \
    order_detail_service, order_detail_flow_service, w_origin_service, \
    delete_order_file_service, download_file_service, upload_file_service

# 运维工单


@summary('来源')
async def get_w_origin(req) -> SelectUserResp:
    return await w_origin_service()


@summary('获取所有用户')
async def get_search_all_user(req) -> SelectUserResp:
    return await search_all_user_service()


@summary('接单')
async def post_receive_order(req, body: ReceiveOrderReq) -> ReceiveOrderResp:
    id = body.id
    try:
        user_id = req.ctx.user_id
    except:
        user_id = req.json.get("user_id")
    return await receive_order_service(id, user_id)


@summary('转单  获取名单')
async def get_flow_order_user(req) -> SelectUserResp:
    return await flow_order_user_service()


@summary('转单')
async def post_flow_order(req, body: FlowOrderReq) -> FileSuccess:
    try:
        myself_id = req.ctx.user_id
    except:
        myself_id = req.json.get("myself_id")
    id = body.id
    user_id = body.user_id
    explain = body.explain
    doc_ids = body.doc_ids
    return await flow_order_service(myself_id, id, user_id, explain, doc_ids)


@summary('处理  工单')
async def post_work_order(req, body: WorkOrderReq) -> FileSuccess:
    try:
        user_id = req.ctx.user_id
    except:
        user_id = req.json.get("user_id")
    id = body.id
    explain = body.explain
    doc_ids = body.doc_ids
    return await work_order_service(id, user_id, explain, doc_ids)


@summary('关闭 工单')
async def post_close_order(req, body: WorkOrderReq) -> FileSuccess:
    try:
        user_id = req.ctx.user_id
    except:
        user_id = req.json.get("user_id")
    id = body.id
    explain = body.explain
    doc_ids = body.doc_ids
    return await close_order_service(id, user_id, explain, doc_ids)


@summary('录入工单  传入硬件编号sid 返回 cid、pid')
async def post_sid_to_order(req, body: SidToOrderReq) \
        -> SidToOrderResp:
    sid = body.sid
    return await sid_to_order_service(sid)


@summary('录入工单  根据cid、监测点pid返回硬件编号')
async def post_pid_to_sid(req, body: PidToSidReq) -> SidToOrderResp:
    pid = body.pid
    return await pid_to_sid_service(pid)


@summary('录入工单 或修改工单 传id')
async def post_add_order(req, body: AddOrderReq) -> Success:
    try:
        user_id = req.ctx.user_id
    except:
        user_id = req.json.get("user_id")
    id = body.id
    prod_id = body.prod_id
    cid = body.cid
    point_id = body.point_id
    check_dt = body.check_dt
    sid = body.sid
    doc_ids = body.doc_ids
    return await add_order_service(req.json, id, user_id, prod_id, cid,
                                   check_dt, sid, point_id, doc_ids)


@summary('工单详情')
async def post_order_detail(req, body: ReceiveOrderResp) -> SidToOrderResp:
    id = body.id
    return await order_detail_service(id)


@summary('工单详情-流程')
async def post_order_detail_flow(req, body: ReceiveOrderResp) -> \
        SidToOrderResp:
    id = body.id
    return await order_detail_flow_service(id)


@summary('附件上传')
async def post_upload_file(req):
    cid = req.form.get("cid")
    return await upload_file_service(req, cid)


@summary('运维工单-附件删除')
async def post_delte_order_file(req, body: DeleteOrderFileReq) -> \
        SuccessResp:
    id = body.id
    return await delete_order_file_service(id)


@summary('运维工单-附件下载')
async def get_download_file(req):
    id = req.args.get("id")
    return await download_file_service(id)