Exemple #1
0
async def patrol_check(request: Request):
    pid = get_query_params(request, 'pid')
    pd_id = get_query_params(request, 'pdId')
    eid = get_query_params(request, 'eid')
    async with request.app['mysql'].acquire() as conn:
        async with conn.cursor() as cur:
            await cur.execute(
                "UPDATE `patrol_detail` SET `check`=1 WHERE `id`=%s AND `pid`=%s AND `eid`=%s",
                (pd_id, pid, eid))
            if cur.rowcount == 0:
                return code_response(EquipmentNotInPlanResponse)
            await cur.execute(
                "SELECT COUNT(*) FROM `patrol_detail` WHERE `pid`=%s AND `check`=0",
                pid)
            row = await cur.fetchone()
            if row:
                if row[0] == 0:  # 如果全部check了则更新plan
                    await cur.execute(
                        "UPDATE `patrol_meta` SET `status`=1, `unfinished`=0 WHERE `id`=%s",
                        pid)
                else:
                    await cur.execute(
                        "UPDATE `patrol_meta` SET `unfinished`=%s WHERE `id`=%s",
                        (row[0], pid))
            await conn.commit()
    return code_response(ResponseOk)
Exemple #2
0
def get_equipment_id(request: Request, decode=True):
    return get_query_params(request, 'eid', decode)
Exemple #3
0
def get_user_id(request: Request):
    return get_query_params(request, 'uid')
Exemple #4
0
def get_organization_id(request: Request):
    return get_query_params(request, 'did')
Exemple #5
0
def get_case_id(request: Request):
    return get_query_params(request, 'caseId', decode=False)
Exemple #6
0
def get_patrol_detail_id(request: Request):
    return get_query_params(request, 'pid')
Exemple #7
0
def get_patrol_id_in_uri(request: Request):
    return get_query_params(request, 'pid')
Exemple #8
0
def get_maintenance_id(request: Request):
    return get_query_params(request, 'oid')