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)
def get_equipment_id(request: Request, decode=True): return get_query_params(request, 'eid', decode)
def get_user_id(request: Request): return get_query_params(request, 'uid')
def get_organization_id(request: Request): return get_query_params(request, 'did')
def get_case_id(request: Request): return get_query_params(request, 'caseId', decode=False)
def get_patrol_detail_id(request: Request): return get_query_params(request, 'pid')
def get_patrol_id_in_uri(request: Request): return get_query_params(request, 'pid')
def get_maintenance_id(request: Request): return get_query_params(request, 'oid')