import json
import os
import platform
import time
import threading
import http
import json
import threading
if 82 - 82: Iii1i
import rsa
from flask import Blueprint , render_template , request , flash , redirect , url_for , session , g , Response
from sqlalchemy import or_ , and_ , text
if 87 - 87: Ii % i1i1i1111I . Oo / OooOoo * I1Ii1I1 - I1I
from exts import db
from blueprints . wgcomm_pri import uploadDeletePrivilegeByThread
from decorators import login_required
from forms . wgcommform import *
from forms . wgcommform import AddControllerWifiConfigureForm , EditOperatorForm , Addextern_elevatorForm
from models . iccard import *
from models . iccardext import OperatorModel
import vwAppConfig
from vwAppConfigParam import vwAppConfigParam
import binascii
if 81 - 81: i1 + ooOOO / oOo0O00 * i1iiIII111 * IiIIii11Ii
if 84 - 84: ooo000 - Ooo0Ooo + iI1iII1I1I1i . IIiIIiIi11I1
from flask import Blueprint , render_template , request , g
from sqlalchemy import text , or_ , and_ , distinct
from exts import db
from decorators import login_required
from forms . wgcommform import AddControllerForm
from models . iccard import *
from vwAppConfig import WGTools , wgMjControllerConfigure
from vwAppConfigParam import vwAppConfigParam
import vwAppConfig
if 98 - 98: I11iiIi11i1I % oOO
if 31 - 31: i1I
__all__ = [
 "bp" ,
 "web_extern_elevator_add" ,
 "web_extern_elevator_del" ,
 "web_extern_elevator_edit" ,
 "web_extern_elevator_list" ,
 "web_extern_elevator_listpage" ,
 "web_extern_elevator_pri_edit" ,
 "web_extern_elevator_pri_allowselected" ,
 "web_extern_elevator_pri_disallowselected" ,
 "web_extern_elevator_pri_list" ,
 "web_extern_elevator_pri_listpage" ,
 "web_extern_elevator_remoteopen" ,
 "web_extern_elevator_pri_edit" ,

# iI1iI11Ii111
# oOo0O00 * ooo000
]
bp = Blueprint ( 'wgcomm_extern_elevator' , __name__ , url_prefix = '/' )
if 86 - 86: iI1iII1I1I1i + iI1iII1I1I1i % i1 . i1i1i1111I / Iii1i + i1I
class ii :
 def __init__ ( self ) :
  if 91 - 91: i1 . Ii . i1i1i1111I + i1 % IIiIIiIi11I1 + I1I
  if 70 - 70: i1I * i1I
  if 61 - 61: Ooo0Ooo - I1I
  self . uploadedSNOK = [ ]
  self . uploadedSNFailed = [ ]
  self . uploadedSN = [ ]
  self . uploadedSNConnectedOK = [ ]
  if 13 - 13: Ooo0Ooo
  self . uploadedIdConnectedOK = [ ]
  self . uploadedSNOK_Delete = [ ]
  if 46 - 46: iI1iII1I1I1i - Ii * Oo * Ii
  self . uploadedSNFailed_Delete = [ ]
  self . uploadedSN_Delete = [ ]
  self . recvsnpri = [ ]
  self . uploadedSNReply = [ ]
  if 52 - 52: Oo + I1I / oOO / OooOoo - I1Ii1I1 - ooOOO
  self . selectedUser4Face = None
  self . faceOpertateMode = 0
  if 60 - 60: iI1iII1I1I1i . oOO
  if 13 - 13: oOO
@ bp . route ( '/extern_elevator_list' , methods = [ 'GET' , 'POST' ] )
@ login_required
def web_extern_elevator_list ( ) :
 iiIII = TBController . query
 IioOOOO000 = iiIII . all ( )
 IioOOOO000 = [ ]
 oOoo0 = {
 "objlist" : IioOOOO000 ,
 "deleteUrl" : "/extern_elevator_del"
 }
 return render_template ( 'wgcomm/extern-elevator-list.html' , ** oOoo0 )
 if 95 - 95: i1iiIII111 . Ii . IIiIIiIi11I1 % I11iiIi11i1I % I1Ii1I1
 if 8 - 8: I1Ii1I1 . iI1iI11Ii111 . i1 . Oo - i1I
@ bp . route ( '/extern_elevator_listpage' , methods = [ 'GET' , 'POST' ] )
@ login_required
def web_extern_elevator_listpage ( ) :
 iiI1111IIi1 = ''
 if request . method == 'GET' :
  oOo00O = int ( request . args . get ( 'draw' ) )
  OoO = int ( request . args . get ( 'length' ) )
  ii1IiIiiII = int ( request . args . get ( 'start' ) )
  I1I111i11I = request . args . get ( 'search[value]' )
 else :
  oOo00O = int ( request . form . get ( 'draw' ) )
  OoO = int ( request . form . get ( 'length' ) )
  ii1IiIiiII = int ( request . form . get ( 'start' ) )
  I1I111i11I = request . form . get ( 'search[value]' )
  iiI1111IIi1 = request . form . get ( 'csrf_token' )
 iii11i = [ ]
 if 35 - 35: I1I % i1iiIII111 * I1I
 iiIII = db . session . query ( TBDoor . f_DoorID , TBDoor . f_DoorName , TBFloor . f_FloorNO , TBFloor . f_FloorName , TBFloor . f_FloorId
 ) . join ( TBFloor ,
 TBFloor . f_DoorID == TBDoor . f_DoorID ,
 isouter = False ) . order_by ( TBDoor . f_DoorName ) . order_by ( TBFloor . f_FloorNO )
 if 88 - 88: I11iiIi11i1I + ooOOO - i1i1i1111I . Ooo0Ooo * Ii + Iii1i
 if 43 - 43: ooOOO * I1Ii1I1
 if OoO == - 1 :
  ii1IiIiiII = 0
  OoO = 2147483647
  if 95 - 95: Ooo0Ooo % Iii1i % i1i1i1111I . OooOoo
 if I1I111i11I :
  I1I111i11I = I1I111i11I . strip ( )
  if '.' in I1I111i11I :
   I1iIiiIIiIi = I1I111i11I . split ( '.' )
   if len ( I1iIiiIIiIi ) >= 1 :
    i1I11ii = and_ ( 1 > 0 )
    for iii1II11 in I1iIiiIIiIi :
     if 32 - 32: Oo / Ii - IIiIIiIi11I1
     if 29 - 29: IiIIii11Ii - oOo0O00
     if 30 - 30: I1I . ooo000
     if 43 - 43: ooOOO . I11iiIi11i1I + ooo000
     if 87 - 87: Iii1i + ooOOO . i1I / Ii + Oo
     if '_' in iii1II11 :
      iii1II11 = iii1II11 . replace ( '_' , '\\_' )
     OOO00oO0oOo0O = or_ (

     # I11iiIi11i1I
     # I1I * Ooo0Ooo + i1iiIII111 . i1iiIII111 % Oo
     TBFloor . f_FloorName . like ( "{0}%" . format ( iii1II11 ) , escape = '\\' ) ,
     TBDoor . f_DoorName . like ( "%{0}" . format ( iii1II11 ) , escape = '\\' )
     )
     if 93 - 93: oOo0O00 % Ooo0Ooo * i1iiIII111
     if 52 - 52: oOO + I1I / ooo000 - I1Ii1I1 * i1I % oOo0O00
     if 52 - 52: oOo0O00 . I1I + i1I - i1iiIII111 % iI1iII1I1I1i
     i1I11ii = and_ ( i1I11ii , OOO00oO0oOo0O )
    OOO00oO0oOo0O = i1I11ii
    iiIII = iiIII . filter ( OOO00oO0oOo0O )
    if 57 - 57: I1I * IIiIIiIi11I1 % I1Ii1I1 * i1i1i1111I
    if 37 - 37: iI1iI11Ii111 * i1i1i1111I + oOo0O00 / I1I / OooOoo
    if 4 - 4: i1
  else :
   I1iIiiIIiIi = I1I111i11I . split ( ' ' )
   if len ( I1iIiiIIiIi ) == 1 :
    I1iIiiIIiIi = I1I111i11I . split ( '.' )
   if len ( I1iIiiIIiIi ) >= 1 :
    i1I11ii = and_ ( 1 > 0 )
    for iii1II11 in I1iIiiIIiIi :
     if '_' in iii1II11 :
      iii1II11 = iii1II11 . replace ( '_' , '\\_' )
     OOO00oO0oOo0O = or_ (
 TBFloor . f_FloorName . like ( "%{0}%" . format ( iii1II11 ) , escape = '\\' ) ,
 TBDoor . f_DoorName . like ( "%{0}%" . format ( iii1II11 ) , escape = '\\' )
 )
     if 61 - 61: iI1iII1I1I1i . i1I - ooo000 / ooo000 - i1
     if 19 - 19: Iii1i * Ooo0Ooo . I1Ii1I1 / I11iiIi11i1I * Ii - oOO
     i1I11ii = and_ ( i1I11ii , OOO00oO0oOo0O )
    OOO00oO0oOo0O = i1I11ii
    iiIII = iiIII . filter ( OOO00oO0oOo0O )
    if 32 - 32: iI1iII1I1I1i
    if 18 - 18: I11iiIi11i1I * iI1iI11Ii111 % iI1iII1I1I1i + iI1iI11Ii111
    if 93 - 93: oOO - I1Ii1I1 - IIiIIiIi11I1 * ooOOO - i1
    if 82 - 82: IIiIIiIi11I1 % i1 * ooOOO
    if 57 - 57: oOo0O00
    if 31 - 31: i1iiIII111 + i1i1i1111I % OooOoo
 i1i1iiII = iiIII . count ( )
 if 43 - 43: Ooo0Ooo - I1I . ooo000 - Iii1i % i1I
 OO = ii1IiIiiII
 if ii1IiIiiII <= i1i1iiII :
  IioOOOO000 = iiIII . offset ( ii1IiIiiII ) . limit ( OoO ) . all ( )
  OO = ii1IiIiiII + OoO
 else :
  IioOOOO000 = iiIII . offset ( 0 ) . limit ( OoO ) . all ( )
  OO = 1
  if 39 - 39: oOO - oOO * i1 % IIiIIiIi11I1
  if 29 - 29: IIiIIiIi11I1 - ooo000 . i1iiIII111
  if 86 - 86: I1Ii1I1 - OooOoo - oOO % ooo000 . i1I % Iii1i
  if 11 - 11: OooOoo - I1Ii1I1 - ooOOO . i1iiIII111 - iI1iII1I1I1i / i1iiIII111
 for OOOoOo in IioOOOO000 :
  I1i1i = '<div class="d-flex align-items-stretch">'
  I1i1i += '<form action="/extern_elevator_edit" method="post">  '
  I1i1i += '<input type="hidden" name="csrf_token"              '
  if 97 - 97: i1
  I1i1i += 'value="{}">                         ' . format ( iiI1111IIi1 )
  I1i1i += '<input type="hidden" name="conID"                   '
  I1i1i += 'value="{}"> ' . format ( OOOoOo . f_FloorId )
  I1i1i += '<button class="btn btn-icon btn-primary-light me-2" '
  I1i1i += 'data-id="{}"' . format ( OOOoOo . f_FloorId )
  if 26 - 26: iI1iI11Ii111
  I1i1i += 'data-bs-toggle="tooltip" title="Edit"'
  I1i1i += 'data-bs-original-title="Edit">'
  I1i1i += '<i class="fe fe-edit"></i></button> '
  I1i1i += '</form>'
  if 20 - 20: IIiIIiIi11I1 / Oo
  I1i1i += '<button href="#"'
  I1i1i += 'class="btn btn-icon btn-warning-light me-2 active-btn"'
  I1i1i += 'data-id="' + str ( OOOoOo . f_FloorId ) + '"'
  I1i1i += 'data-name="' + "{0}.{1}" . format ( OOOoOo . f_DoorName , OOOoOo . f_FloorName ) + '"'
  if 73 - 73: ooOOO - IiIIii11Ii
  if 22 - 22: Oo % oOo0O00 / i1I . oOo0O00 . i1I
  Ooo000oo0O00o = '/extern_elevator_del'
  I1i1i += 'data-url="{}"' . format ( Ooo000oo0O00o )
  I1i1i += 'data-bs-toggle="tooltip" title="Delete"'
  I1i1i += 'data-op="delete"'
  I1i1i += 'data-bs-original-title="Delete">'
  I1i1i += '<i class="fe fe-trash"></i>'
  I1i1i += '</button>'
  if 73 - 73: IiIIii11Ii
  I1i1i += '<button href="#"'
  if 69 - 69: IiIIii11Ii * I11iiIi11i1I . i1iiIII111 * Iii1i
  I1i1i += 'class="btn btn-icon btn-primary-light me-2 active-btn"'
  I1i1i += 'data-id="' + str ( OOOoOo . f_FloorId ) + '"'
  I1i1i += 'data-name="' + "{0}.{1}" . format ( OOOoOo . f_DoorName , OOOoOo . f_FloorName ) + '"'
  OOO = '/extern_elevator_remoteopen'
  I1i1i += 'data-url="{}"' . format ( OOO )
  I1i1i += 'data-bs-toggle="tooltip" title="remote open"'
  I1i1i += 'data-op="remoteopen"'
  I1i1i += 'data-bs-original-title="remote open">'
  I1i1i += '<i class="fe fe-unlock"></i>'
  I1i1i += '</button>'
  if 82 - 82: OooOoo * I1Ii1I1 - I11iiIi11i1I * ooOOO
  if 79 - 79: iI1iII1I1I1i - i1I - i1iiIII111 + i1i1i1111I / ooOOO
  if 58 - 58: i1I - iI1iI11Ii111
  if 86 - 86: Iii1i + i1iiIII111 - IIiIIiIi11I1 / I1I
  if 46 - 46: ooOOO + ooOOO % oOO
  if 2 - 2: i1i1i1111I / Ooo0Ooo / oOO - IIiIIiIi11I1 / IIiIIiIi11I1
  if 58 - 58: i1i1i1111I
  if 38 - 38: i1 - oOo0O00
  if 85 - 85: IIiIIiIi11I1 + I11iiIi11i1I % Ooo0Ooo + oOO * i1iiIII111
  if 46 - 46: ooOOO - ooOOO + Oo / I1I * Oo + oOO
  if 98 - 98: I1I / IIiIIiIi11I1 / i1I + iI1iI11Ii111 % Oo + I1I
  if 38 - 38: I1Ii1I1 + oOo0O00
  if 2 - 2: OooOoo % Ii + oOO . OooOoo + IIiIIiIi11I1 * Oo
  I1i1i += '  </div>'
  if 2 - 2: IIiIIiIi11I1 + iI1iII1I1I1i - I1Ii1I1 + ooOOO . IIiIIiIi11I1
  if 15 - 15: ooo000
  if 63 - 63: i1I
  if 81 - 81: OooOoo . i1I / i1i1i1111I + Oo / Ooo0Ooo % iI1iI11Ii111
  if 77 - 77: I11iiIi11i1I / iI1iII1I1I1i - oOo0O00 - Ooo0Ooo % oOo0O00
  if 73 - 73: iI1iI11Ii111 . Oo * I1I / i1i1i1111I + I1Ii1I1
  if 31 - 31: i1i1i1111I % I1Ii1I1
  I11IIiiI1 = [ "{0}.{1}" . format ( OOOoOo . f_DoorName , OOOoOo . f_FloorName ) , OOOoOo . f_DoorName ,
 OOOoOo . f_FloorNO , I1i1i ]
  iii11i . append ( I11IIiiI1 )
  if 37 - 37: i1i1i1111I - i1 * i1I + I1I * Oo - oOO
 iiiiiI = {
 "draw" : oOo00O ,
 "recordsTotal" : i1i1iiII ,
 "recordsFiltered" : i1i1iiII ,
 "data" : iii11i ,
 'start' : OO
 }
 return json . dumps ( iiiiiI )
 if 77 - 77: oOo0O00 % Oo - oOo0O00 - ooo000 * I11iiIi11i1I + oOO
@ bp . route ( '/extern_elevator_del' , methods = [ 'POST' ] )
@ login_required
def web_extern_elevator_del ( ) :
 O0o = request . form . get ( "primaryID" )
 if O0o :
  OOooo000o0O = "wgcomm_extern_elevator.web_extern_elevator_list"
  if 74 - 74: I1Ii1I1
  TBFloor . query . filter_by ( f_FloorId = O0o ) . delete ( )
  db . session . commit ( )
  vwAppConfig . setcontrollerdoorChangeTime ( )
  Oo0O0O = O0o
  flash ( "Delete Controller SN={} Successfully" . format ( Oo0O0O ) )
  vwAppConfig . vwlog ( '{}--{}' . format ( g . user . f_OperatorName ,
 "Controller {} Delete Successfully！" . format ( Oo0O0O ) ) )
  if 12 - 12: Ooo0Ooo + i1iiIII111 + Oo * I1Ii1I1
  return redirect ( url_for ( OOooo000o0O ) )
  if 43 - 43: IIiIIiIi11I1 * ooo000 + Ii % iI1iII1I1I1i
  if 12 - 12: i1iiIII111 + ooo000 . I11iiIi11i1I
@ bp . route ( '/extern_elevator_add' , methods = [ 'GET' , 'POST' ] )
@ login_required
def web_extern_elevator_add ( ) :
 Iii1I1I1 = "wgcomm/extern-elevator-add.html"
 OOooo000o0O = "wgcomm_extern_elevator.web_extern_elevator_list"
 if 57 - 57: I1I
 if 35 - 35: oOo0O00 / IIiIIiIi11I1 - Iii1i . iI1iI11Ii111 * i1
 iiIII = db . session . query ( TBDoor . f_DoorID , TBDoor . f_DoorName , TBDoor . f_DoorNO ,
 TBController . f_ControllerSN ) . join ( TBController ,
 TBController . f_ControllerID == TBDoor . f_ControllerID ,
 isouter = False ) . filter (
 TBController . f_ControllerSN >= 170000000 , TBController . f_ControllerSN <= 176000000 ) . order_by ( TBDoor . f_DoorName )
 Ii1IiiiIi1 = iiIII . all ( )
 if 20 - 20: oOo0O00 * ooOOO % IIiIIiIi11I1 - IIiIIiIi11I1
 IiIi111iiI = { }
 if 99 - 99: I11iiIi11i1I + Iii1i + oOo0O00 + i1I
 o0OOO00OO = [ ]
 for oo0OoOoO0O0OO in Ii1IiiiIi1 :
  Iioo0Oo0oO0 = TBFloor . query . filter_by ( f_DoorID = oo0OoOoO0O0OO . f_DoorID ) . all ( )
  iII11I1iI = [ x for x in range ( 1 , 41 ) ]
  if Iioo0Oo0oO0 :
   for O0O0o0oo00Oo in Iioo0Oo0oO0 :
    iII11I1iI . remove ( O0O0o0oo00Oo . f_FloorNO )
  if len ( iII11I1iI ) > 0 :
   IiIi111iiI [ oo0OoOoO0O0OO . f_DoorID ] = iII11I1iI
  else :
   o0OOO00OO . append ( oo0OoOoO0O0OO . f_DoorID )
 if len ( o0OOO00OO ) :
  Ii1IiiiIi1 = [ oo0OoOoO0O0OO for oo0OoOoO0O0OO in Ii1IiiiIi1 if oo0OoOoO0O0OO [ 0 ] not in o0OOO00OO ]
  if 96 - 96: Ooo0Ooo
 if request . method == 'GET' :
  ii1IiiIiI = Addextern_elevatorForm ( )
  if 46 - 46: OooOoo - I11iiIi11i1I / Ooo0Ooo
  if 73 - 73: I1Ii1I1 / i1i1i1111I / ooo000 % i1 % i1I - OooOoo
  if 30 - 30: ooOOO * ooOOO - Iii1i * iI1iII1I1I1i
  if 37 - 37: I1Ii1I1 % iI1iII1I1I1i . i1I + Ooo0Ooo + ooOOO * iI1iII1I1I1i
  if 39 - 39: IIiIIiIi11I1 - Oo
  if 31 - 31: IiIIii11Ii % oOo0O00 % oOo0O00 * Iii1i
  if 85 - 85: Iii1i + Ii % IIiIIiIi11I1 % oOo0O00
  if 100 - 100: IiIIii11Ii % i1
  if 82 - 82: ooOOO % OooOoo
  if 81 - 81: Ii
  if 40 - 40: i1I . OooOoo + oOo0O00 . i1iiIII111
  if 96 - 96: I1I / oOO / I11iiIi11i1I + I11iiIi11i1I
  if 35 - 35: IIiIIiIi11I1 + oOo0O00
  if 96 - 96: iI1iII1I1I1i . OooOoo . i1
  if 87 - 87: ooo000 * IiIIii11Ii % ooo000 . ooOOO . Oo % iI1iII1I1I1i
  if 48 - 48: ooOOO * ooo000 % IiIIii11Ii * i1 . Iii1i - iI1iI11Ii111
  if 72 - 72: i1 % i1i1i1111I * iI1iII1I1I1i
  if 90 - 90: Ooo0Ooo * OooOoo . Ii
  if 5 - 5: Oo - i1 . oOO
  if 18 - 18: IiIIii11Ii - oOO * i1I - OooOoo
  if 54 - 54: IIiIIiIi11I1 . Ooo0Ooo % Ii + IiIIii11Ii * iI1iII1I1I1i / iI1iII1I1I1i
  if 31 - 31: IiIIii11Ii . IiIIii11Ii % Ii
  if 51 - 51: Oo / i1i1i1111I - I1I
  ii1IiiIiI . f_DoorID . data = Ii1IiiiIi1 [ 0 ] [ 0 ]
  iii1ii1 = IiIi111iiI [ ii1IiiIiI . f_DoorID . data ] [ 0 ]
  if iii1ii1 < 10 :
   ii1IiiIiI . f_FloorName . data = "_{0}F" . format ( iii1ii1 )
  else :
   ii1IiiIiI . f_FloorName . data = "{0}F" . format ( iii1ii1 )
   if 27 - 27: i1 / OooOoo + Iii1i % OooOoo + OooOoo
  return render_template ( Iii1I1I1 , wgform = ii1IiiIiI , elevators = Ii1IiiiIi1 , arr_allow_floorno = IiIi111iiI )
 else :
  if 70 - 70: Oo / Iii1i * OooOoo
  ii1IiiIiI = Addextern_elevatorForm ( request . form )
  if 2 - 2: i1I / Iii1i + I1Ii1I1
  if ii1IiiIiI . submitcancel . data :
   return redirect ( url_for ( OOooo000o0O ) )
  if ii1IiiIiI . validate ( ) :
   o0O0 = ii1IiiIiI . f_FloorName . data
   iII11iI1i = ii1IiiIiI . f_FloorNO . data
   I1iiIII1i = ii1IiiIiI . f_DoorID . data
   if 63 - 63: i1i1i1111I - i1iiIII111 . OooOoo % OooOoo . iI1iI11Ii111 + i1I
   if 71 - 71: ooo000 + I11iiIi11i1I % iI1iII1I1I1i + iI1iI11Ii111 % Oo - Oo
   if 84 - 84: I1I % iI1iII1I1I1i - Ooo0Ooo / iI1iII1I1I1i + Ooo0Ooo - Oo
   if 41 - 41: ooOOO + OooOoo + IIiIIiIi11I1 * i1i1i1111I
   if 12 - 12: i1i1i1111I
   if 56 - 56: IiIIii11Ii
   i11I1iII1I1 = TBFloor . query . filter_by ( f_DoorID = I1iiIII1i ) . filter_by ( f_FloorName = o0O0 ) . first ( )
   if i11I1iII1I1 :
    flash ( "floor name Duplicated" )
    return render_template ( Iii1I1I1 , wgform = ii1IiiIiI )
    if 7 - 7: oOo0O00 % Oo + i1I
    if 65 - 65: IIiIIiIi11I1 / i1
    if 14 - 14: IiIIii11Ii % ooOOO . i1I
    if 29 - 29: iI1iI11Ii111 % oOO % iI1iI11Ii111 . ooOOO
    if 4 - 4: oOo0O00 + i1iiIII111
    if 45 - 45: I1Ii1I1
    if 19 - 19: ooo000 * OooOoo . Iii1i * I11iiIi11i1I . I1I
    if 49 - 49: i1iiIII111 - IiIIii11Ii / i1iiIII111 + i1I
    if 77 - 77: Ii
    if 20 - 20: Ii % i1i1i1111I
    if 35 - 35: Ooo0Ooo * iI1iI11Ii111 - Ooo0Ooo - ooOOO
    if 28 - 28: IiIIii11Ii . Oo - i1I + I11iiIi11i1I - oOo0O00
    if 6 - 6: iI1iI11Ii111 - Ii
    if 1 - 1: I1I + OooOoo
    if 98 - 98: i1iiIII111 + Iii1i . IIiIIiIi11I1
    if 96 - 96: OooOoo / oOO - i1 * I11iiIi11i1I
    if 72 - 72: i1i1i1111I + Ii - Iii1i - i1i1i1111I - i1I + Ooo0Ooo
    if 74 - 74: Ooo0Ooo * Oo + Iii1i - i1iiIII111
   oo0OoOoO0O0OO = TBDoor . query . filter_by ( f_DoorID = I1iiIII1i ) . first ( )
   IIiIiiI1I1iII = 0
   if oo0OoOoO0O0OO :
    IIiIiiI1I1iII = oo0OoOoO0O0OO . f_ControllerID
   ooo00o0 = TBFloor ( f_DoorID = I1iiIII1i , f_ControllerID = IIiIiiI1I1iII ,
 f_FloorNO = iII11iI1i ,
 f_FloorName = o0O0 )
   if 66 - 66: IiIIii11Ii + OooOoo
   if 31 - 31: OooOoo
   try :
    db . session . add ( ooo00o0 )
    db . session . commit ( )
    vwAppConfig . setcontrollerdoorChangeTime ( )
    flash ( "Floor {} Add Successfully！" . format ( o0O0 ) )
    vwAppConfig . vwlog ( '{}--{}' . format ( g . user . f_OperatorName , " {}  Add Successfully ！" . format (
 o0O0 ) ) )
    if 33 - 33: iI1iI11Ii111 / OooOoo
    if ii1IiiIiI . submitsaveandadd . data :
     iiIII = db . session . query ( TBDoor . f_DoorID , TBDoor . f_DoorName , TBDoor . f_DoorNO ,
 TBController . f_ControllerSN ) . join ( TBController ,
 TBController . f_ControllerID == TBDoor . f_ControllerID ,
 isouter = False ) . filter (
 TBController . f_ControllerSN >= 170000000 , TBController . f_ControllerSN <= 176000000 ) . order_by (
 TBDoor . f_DoorName )
     Ii1IiiiIi1 = iiIII . all ( )
     if 98 - 98: I1Ii1I1 . IIiIIiIi11I1 * i1I - iI1iII1I1I1i % i1I * iI1iI11Ii111
     IiIi111iiI = { }
     if 42 - 42: OooOoo + i1i1i1111I - iI1iII1I1I1i - oOo0O00 * i1I + Ii
     o0OOO00OO = [ ]
     for oo0OoOoO0O0OO in Ii1IiiiIi1 :
      Iioo0Oo0oO0 = TBFloor . query . filter_by ( f_DoorID = oo0OoOoO0O0OO . f_DoorID ) . all ( )
      iII11I1iI = [ x for x in range ( 1 , 41 ) ]
      if Iioo0Oo0oO0 :
       for O0O0o0oo00Oo in Iioo0Oo0oO0 :
        iII11I1iI . remove ( O0O0o0oo00Oo . f_FloorNO )
      if len ( iII11I1iI ) > 0 :
       IiIi111iiI [ oo0OoOoO0O0OO . f_DoorID ] = iII11I1iI
      else :
       o0OOO00OO . append ( oo0OoOoO0O0OO . f_DoorID )
     if len ( o0OOO00OO ) :
      Ii1IiiiIi1 = [ oo0OoOoO0O0OO for oo0OoOoO0O0OO in Ii1IiiiIi1 if oo0OoOoO0O0OO [ 0 ] in o0OOO00OO ]
      if 46 - 46: oOo0O00 . iI1iII1I1I1i - Ii . oOo0O00 + i1i1i1111I
     if ii1IiiIiI . f_DoorID . data not in IiIi111iiI :
      ii1IiiIiI . f_DoorID . data = Ii1IiiiIi1 [ 0 ] [ 0 ]
     iii1ii1 = IiIi111iiI [ ii1IiiIiI . f_DoorID . data ] [ 0 ]
     if iii1ii1 < 10 :
      ii1IiiIiI . f_FloorName . data = "_{0}F" . format ( iii1ii1 )
     else :
      ii1IiiIiI . f_FloorName . data = "{0}F" . format ( iii1ii1 )
      if 83 - 83: iI1iI11Ii111
     return render_template ( Iii1I1I1 , wgform = ii1IiiIiI , elevators = Ii1IiiiIi1 ,
 arr_allow_floorno = IiIi111iiI )
     if 77 - 77: iI1iII1I1I1i - oOO % Ii * i1I - I1I
    return redirect ( url_for ( OOooo000o0O ) )
   except Exception as OooOoO0o00 :
    print ( OooOoO0o00 )
    vwAppConfig . vwlog ( '{}--{}[{}]' . format ( g . user . f_OperatorName , " Floor {} Add Failed ！" . format (
 o0O0 ) , OooOoO0o00 ) )
    if 23 - 23: i1
    db . session . rollback ( )
    flash ( " Floor Add Failed ！" )
    if 91 - 91: I11iiIi11i1I - iI1iI11Ii111 % IiIIii11Ii / IiIIii11Ii
    return render_template ( Iii1I1I1 , wgform = ii1IiiIiI , elevators = Ii1IiiiIi1 , arr_allow_floorno = IiIi111iiI )
  else :
   for iii11i in ii1IiiIiI . messages :
    flash ( iii11i )
    if 37 - 37: i1iiIII111 - iI1iI11Ii111 * i1iiIII111 . i1i1i1111I
    if 43 - 43: oOO
    if 87 - 87: ooOOO + iI1iI11Ii111 * i1iiIII111 / i1i1i1111I
    if 75 - 75: IiIIii11Ii / ooo000 + iI1iI11Ii111 / i1i1i1111I * oOO + ooo000
    if 83 - 83: I11iiIi11i1I / Ooo0Ooo . I11iiIi11i1I
    if 47 - 47: IiIIii11Ii
    if 40 - 40: i1iiIII111 / IIiIIiIi11I1
   return render_template ( Iii1I1I1 , wgform = ii1IiiIiI , elevators = Ii1IiiiIi1 , arr_allow_floorno = IiIi111iiI )
   if 25 - 25: OooOoo / i1i1i1111I
   if 38 - 38: I11iiIi11i1I
   if 99 - 99: I11iiIi11i1I * i1iiIII111 . OooOoo % ooo000 % OooOoo
   if 21 - 21: iI1iI11Ii111 * I1Ii1I1
@ bp . route ( '/extern_elevator_edit' , methods = [ 'POST' ] )
@ login_required
def web_extern_elevator_edit ( ) :
 Iii1I1I1 = "wgcomm/extern-elevator-edit.html"
 OOooo000o0O = "wgcomm_extern_elevator.web_extern_elevator_list"
 if 93 - 93: Ooo0Ooo . i1 + iI1iI11Ii111 - oOo0O00
 iiIII = db . session . query ( TBDoor . f_DoorID , TBDoor . f_DoorName , TBDoor . f_DoorNO ,
 TBController . f_ControllerSN ) . join ( TBController ,
 TBController . f_ControllerID == TBDoor . f_ControllerID ,
 isouter = False ) . filter (
 TBController . f_ControllerSN >= 170000000 , TBController . f_ControllerSN <= 176000000 ) . order_by ( TBDoor . f_DoorName )
 Ii1IiiiIi1 = iiIII . all ( )
 if request . form . get ( 'conID' ) :
  ooOOoO00OO = request . form . get ( 'conID' )
  ii1IiiIiI = Addextern_elevatorForm ( )
  ii1IiiIiI . f_DoorID . data = 1
  O0Ooo0oOo0 = TBFloor . query . get ( ooOOoO00OO )
  if O0Ooo0oOo0 :
   ii1IiiIiI . f_FloorId . data = ooOOoO00OO
   ii1IiiIiI . f_DoorID . data = O0Ooo0oOo0 . f_DoorID
   ii1IiiIiI . f_FloorNO . data = O0Ooo0oOo0 . f_FloorNO
   ii1IiiIiI . f_FloorName . data = O0Ooo0oOo0 . f_FloorName
  return render_template ( Iii1I1I1 , wgform = ii1IiiIiI , elevators = Ii1IiiiIi1 )
 if request . form . get ( 'f_FloorName' ) :
  ii1IiiIiI = Addextern_elevatorForm ( request . form )
  if ii1IiiIiI . submitcancel . data :
   return redirect ( url_for ( OOooo000o0O ) )
  if ii1IiiIiI . validate ( ) :
   o0O0 = ii1IiiIiI . f_FloorName . data
   Oo00oOooOO = ii1IiiIiI . f_FloorId . data
   I1iiIII1i = ii1IiiIiI . f_DoorID . data
   if 66 - 66: i1i1i1111I - i1
   i11I1iII1I1 = TBFloor . query . filter_by ( f_DoorID = I1iiIII1i ) . filter_by ( f_FloorName = o0O0 ) . first ( )
   if i11I1iII1I1 :
    if i11I1iII1I1 [ 'f_FloorId' ] != Oo00oOooOO :
     flash ( "floor name Duplicated" )
     return render_template ( Iii1I1I1 , wgform = ii1IiiIiI , elevators = Ii1IiiiIi1 )
     if 58 - 58: Ooo0Ooo . ooo000 . I11iiIi11i1I
     if 48 - 48: i1i1i1111I - IiIIii11Ii
   TBFloor . query . filter_by ( f_FloorId = Oo00oOooOO ) . update (
 { 'f_FloorName' : o0O0 } , synchronize_session = False )
   if 29 - 29: i1iiIII111
   try :
    db . session . commit ( )
    vwAppConfig . setcontrollerdoorChangeTime ( )
    flash ( " Floor {} Edit Successfully ！" . format ( o0O0 ) )
    vwAppConfig . vwlog ( '{}--{}' . format ( g . user . f_OperatorName , " {}  Edit Successfully ！" . format (
 o0O0 ) ) )
    return redirect ( url_for ( OOooo000o0O ) )
   except Exception as OooOoO0o00 :
    print ( OooOoO0o00 )
    if 13 - 13: i1iiIII111 * OooOoo / oOo0O00 . OooOoo - IIiIIiIi11I1 * iI1iII1I1I1i
    db . session . rollback ( )
    flash ( " Floor Edit Failed ！" )
    return render_template ( Iii1I1I1 , wgform = ii1IiiIiI )
  else :
   for iii11i in ii1IiiIiI . messages :
    flash ( iii11i )
   return render_template ( Iii1I1I1 , wgform = ii1IiiIiI )
   if 79 - 79: i1i1i1111I
   if 3 - 3: OooOoo / iI1iI11Ii111 % I11iiIi11i1I
@ bp . route ( '/extern_elevator_remoteopen' , methods = [ 'POST' ] )
@ login_required
def web_extern_elevator_remoteopen ( ) :
 Oo00oOooOO = request . form . get ( "primaryID" )
 if 55 - 55: oOo0O00
 if 31 - 31: Ii . Ooo0Ooo / iI1iI11Ii111
 if 59 - 59: Oo
 if 64 - 64: Iii1i % I11iiIi11i1I * i1 % OooOoo * oOo0O00
 iiIII = db . session . query ( TBFloor . f_FloorNO , TBController . f_ControllerSN ) . join ( TBFloor , TBDoor . f_DoorID == TBFloor . f_DoorID ) . join ( TBDoor ,
 TBDoor . f_ControllerID == TBController . f_ControllerID ) . filter (
 TBFloor . f_FloorId == Oo00oOooOO )
 oOo0Oo00o0O = iiIII . first ( )
 if 9 - 9: I11iiIi11i1I % oOO % ooo000 . Ii - ooo000
 if 48 - 48: Iii1i * i1i1i1111I + IiIIii11Ii
 Oo0O0O = oOo0Oo00o0O . f_ControllerSN
 i1IiiI1I1i1 = ( {
 "jsonrpc" : "2.0" ,
 "method" : "RemoteOpenDoor" ,
 "params" : [ { "ControllerSN" : Oo0O0O , "DirectToFloorNO" : oOo0Oo00o0O . f_FloorNO } ] ,
 "id" : 1002
 } )
 Oooo0OoOoooo = OO0OOo0oOO ( i1IiiI1I1i1 )
 IiIII1 = "{0}F" . format ( oOo0Oo00o0O . f_FloorNO )
 if Oooo0OoOoooo == "OK" :
  vwAppConfig . vwlog ( '{}--{}' . format ( g . user . f_OperatorName , "{}-Remote Open Successfully" . format ( IiIII1 )
 ) )
  return "OK"
 else :
  vwAppConfig . vwlog ( '{}--{}' . format ( g . user . f_OperatorName , "{}-Remote Open Failed" . format ( IiIII1 )
 ) )
  return "{}-Remote Open Failed" . format ( IiIII1 )
  if 57 - 57: I1Ii1I1 + IIiIIiIi11I1 - I11iiIi11i1I + ooOOO
  if 11 - 11: i1i1i1111I - iI1iI11Ii111 - oOO / i1iiIII111 + i1i1i1111I . i1iiIII111
  if 85 - 85: iI1iII1I1I1i + Ooo0Ooo % I1Ii1I1
  if 89 - 89: iI1iII1I1I1i + IiIIii11Ii . Ooo0Ooo % ooOOO
  if 82 - 82: i1i1i1111I
  if 86 - 86: IiIIii11Ii - I1Ii1I1 % OooOoo . iI1iII1I1I1i % OooOoo . i1i1i1111I
@ bp . route ( '/extern_elevator_pri_edit' , methods = [ 'GET' , 'POST' ] )
@ login_required
def web_extern_elevator_pri_edit ( ) :
 if 31 - 31: IiIIii11Ii + i1I - iI1iI11Ii111 . iI1iII1I1I1i / IiIIii11Ii + iI1iII1I1I1i
 if 98 - 98: i1I
 if 18 - 18: ooo000 + ooOOO + Oo / I1Ii1I1 . IIiIIiIi11I1
 if 67 - 67: Oo % ooOOO + iI1iII1I1I1i * I1I
 if 79 - 79: IIiIIiIi11I1 * Oo / OooOoo
 if 10 - 10: iI1iII1I1I1i / i1iiIII111 . IiIIii11Ii * i1i1i1111I
 if 71 - 71: oOo0O00 + I1Ii1I1 / I11iiIi11i1I + Oo / I1I
 if 18 - 18: Iii1i - IiIIii11Ii
 IioOOOO000 = [ ]
 iiIII = db . session . query ( TBDoor . f_DoorID , TBDoor . f_DoorName , TBFloor . f_FloorNO , TBFloor . f_FloorName , TBFloor . f_FloorId
 ) . join ( TBFloor ,
 TBFloor . f_DoorID == TBDoor . f_DoorID ,
 isouter = False ) . order_by ( TBDoor . f_DoorName ) . order_by ( TBFloor . f_FloorNO )
 Oo0ooOO00O = iiIII . all ( )
 if 68 - 68: i1I - OooOoo . i1i1i1111I + iI1iII1I1I1i
 iiIII = db . session . query ( TBControlseg . f_ControlSegID , TBControlseg . f_ControlSegName ) . order_by (
 TBControlseg . f_ControlSegID )
 O000 = iiIII . all ( )
 if 24 - 24: I11iiIi11i1I - Ii
 if 16 - 16: oOo0O00 / I1Ii1I1 / i1 + I11iiIi11i1I + oOo0O00
 if 11 - 11: oOO / OooOoo + oOo0O00
 oOoo0 = {
 "objlist" : IioOOOO000 ,
 "objlistDoor" : Oo0ooOO00O ,
 "deleteUrl" : "/user_del" ,
 "losecardUrl" : "/user_losecard" ,
 "timeprofiles" : O000
 }
 return render_template ( "wgcomm/extern-elevator-pri-edit.html" , ** oOoo0 )
 if 79 - 79: I11iiIi11i1I . I1Ii1I1 * i1I % I1Ii1I1 / iI1iI11Ii111
@ bp . route ( '/extern_elevator_pri_edit_page' , methods = [ 'GET' , 'POST' ] )
@ login_required
def oo ( ) :
 iiI1111IIi1 = ''
 if request . method == 'GET' :
  oOo00O = int ( request . args . get ( 'draw' ) )
  OoO = int ( request . args . get ( 'length' ) )
  ii1IiIiiII = int ( request . args . get ( 'start' ) )
  I1I111i11I = request . args . get ( 'search[value]' )
 else :
  oOo00O = int ( request . form . get ( 'draw' ) )
  OoO = int ( request . form . get ( 'length' ) )
  ii1IiIiiII = int ( request . form . get ( 'start' ) )
  I1I111i11I = request . form . get ( 'search[value]' )
  iiI1111IIi1 = request . form . get ( 'csrf_token' )
 iii11i = [ ]
 if 6 - 6: ooOOO % I1I * Ooo0Ooo % Iii1i % oOO - oOo0O00
 if 83 - 83: i1 - ooo000 * oOo0O00
 if 59 - 59: Ii
 if 21 - 21: IIiIIiIi11I1 - I1I - iI1iI11Ii111 + OooOoo
 if 41 - 41: IiIIii11Ii + OooOoo - I11iiIi11i1I + Oo % i1 + iI1iII1I1I1i
 if 16 - 16: i1 - Oo / Ii
 iiIII = db . session . query ( TBConsumer . f_ConsumerID , TBConsumer . f_ConsumerNO , TBConsumer . f_ConsumerName ,
 TBConsumer . f_CardNO , TBConsumer . f_BeginYMD ,
 TBConsumer . f_EndYMD , TBGroup . f_GroupName ) . join ( TBGroup ,
 TBConsumer . f_GroupID == TBGroup . f_GroupID ,
 isouter = True ) . order_by (
 TBConsumer . f_ConsumerNO )
 if 38 - 38: Ooo0Ooo % I1Ii1I1 / i1I + i1iiIII111
 if OoO == - 1 :
  ii1IiIiiII = 0
  OoO = 2147483647
  if 25 - 25: I11iiIi11i1I - iI1iII1I1I1i
 if I1I111i11I :
  I1I111i11I = I1I111i11I . strip ( )
  I1iIiiIIiIi = I1I111i11I . split ( ' ' )
  if len ( I1iIiiIIiIi ) >= 1 :
   i1I11ii = and_ ( 1 > 0 )
   for iii1II11 in I1iIiiIIiIi :
    OOO00oO0oOo0O = or_ ( TBConsumer . f_ConsumerNO . like ( "%%%s%%" % iii1II11 ) ,
 TBConsumer . f_ConsumerName . like ( "%%%s%%" % iii1II11 ) ,
 TBGroup . f_GroupName . like ( "%%%s%%" % iii1II11 ) )
    if vwAppConfig . parseInt ( iii1II11 ) > 0 :
     OooO0Ooo0 = vwAppConfig . parseInt ( iii1II11 )
     OOO00oO0oOo0O = or_ ( TBConsumer . f_CardNO == OooO0Ooo0 , OOO00oO0oOo0O )
    i1I11ii = and_ ( i1I11ii , OOO00oO0oOo0O )
   OOO00oO0oOo0O = i1I11ii
   iiIII = iiIII . filter ( OOO00oO0oOo0O )
   i1i1iiII = iiIII . count ( )
  else :
   i1i1iiII = TBConsumer . query . count ( )
 else :
  i1i1iiII = TBConsumer . query . count ( )
  if 46 - 46: Ii
  if 37 - 37: IIiIIiIi11I1 % oOO + Oo . Ooo0Ooo
 OO = ii1IiIiiII
 if ii1IiIiiII <= i1i1iiII :
  IioOOOO000 = iiIII . order_by ( TBConsumer . f_ConsumerNO ) . offset ( ii1IiIiiII ) . limit ( OoO ) . all ( )
  OO = ii1IiIiiII + OoO
 else :
  IioOOOO000 = iiIII . order_by ( TBConsumer . f_ConsumerNO ) . offset ( 0 ) . limit ( OoO ) . all ( )
  OO = 1
  if 18 - 18: IiIIii11Ii * IiIIii11Ii - Ii
 for OOOoOo in IioOOOO000 :
  o0oO0OoO0O0 = """                                                                            <div class="custom-checkbox custom-control">
                                                                                <input type="checkbox"
                                                                                       data-bs-checkboxes="mygroup"
                                                                                       class="custom-control-input call-checkbox"
                                                                                       id="chk{0}">
                                                                                <label for="chk{1}"
                                                                                       class="custom-control-label"></label>
                                                                            </div>""" . format ( OOOoOo . f_ConsumerID , OOOoOo . f_ConsumerID )
  if 36 - 36: iI1iI11Ii111 * OooOoo . ooo000 . i1iiIII111 + oOO
  o00O0 = OOOoOo . f_CardNO
  if o00O0 is None or o00O0 == 0 :
   o00O0 = ''
  else :
   if 6 - 6: Ii
   o00O0 = '<text id="cardno-{}" >{}</text>' . format ( OOOoOo . f_ConsumerID , o00O0 )
  I1Ii11iI1 = OOOoOo . f_GroupName
  if I1Ii11iI1 is None :
   I1Ii11iI1 = ''
   if 41 - 41: iI1iI11Ii111 - oOo0O00
   if 76 - 76: I11iiIi11i1I % IIiIIiIi11I1 % i1I
   if 39 - 39: IiIIii11Ii . Oo + i1I - oOo0O00
  I11IIiiI1 = [ o0oO0OoO0O0 , OOOoOo . f_ConsumerNO , OOOoOo . f_ConsumerName ,
 o00O0 , I1Ii11iI1 ]
  iii11i . append ( I11IIiiI1 )
  if 93 - 93: Iii1i * IIiIIiIi11I1 % i1I + i1 % Ii * i1I
 iiiiiI = {
 "draw" : oOo00O ,
 "recordsTotal" : i1i1iiII ,
 "recordsFiltered" : i1i1iiII ,
 "data" : iii11i ,
 'start' : OO
 }
 return json . dumps ( iiiiiI )
 if 62 - 62: iI1iI11Ii111 % ooo000
@ bp . route ( '/extern_elevator_pri_allowselected' , methods = [ 'POST' ] )
@ login_required
def web_extern_elevator_pri_allowselected ( ) :
 if 19 - 19: Ii / Oo % Iii1i / i1iiIII111 - OooOoo - Ooo0Ooo
 if 89 - 89: I11iiIi11i1I - iI1iI11Ii111
 if 61 - 61: Ii * OooOoo * I1I % i1iiIII111 % IIiIIiIi11I1 * I11iiIi11i1I
 Ii1IiiiIi1 = request . form . get ( "selecteddoor" )
 if 49 - 49: iI1iII1I1I1i / i1iiIII111 % oOO
 OOooO0OoOO0 = request . form . get ( "selecteduser" )
 if 27 - 27: IIiIIiIi11I1 * IIiIIiIi11I1 + oOO + ooOOO * Oo + i1I
 OoOoO0o = request . form . get ( "timeprofileid" )
 if 45 - 45: ooOOO * IIiIIiIi11I1 * I1I / oOO
 if 35 - 35: ooOOO * Oo / i1I % i1 / Ii
 if len ( Ii1IiiiIi1 ) == 0 or len ( OOooO0OoOO0 ) == 0 :
  return "OK"
  if 86 - 86: i1 / Oo . i1iiIII111 - IIiIIiIi11I1 * Oo
 Ii1IiiiIi1 = Ii1IiiiIi1 . split ( "," )
 Ii1IiiiIi1 = [ int ( x ) for x in Ii1IiiiIi1 ]
 Ii1IiiiIi1 . sort ( )
 OOooO0OoOO0 = OOooO0OoOO0 . split ( "," )
 OOooO0OoOO0 = [ int ( x ) for x in OOooO0OoOO0 ]
 OOooO0OoOO0 . sort ( )
 if 88 - 88: oOO . I1Ii1I1
 if 53 - 53: IIiIIiIi11I1 - I1I * i1iiIII111 + Ii + i1I . i1
 vwAppConfig . vwlog ( '{}--{}' . format ( g . user . f_OperatorName ,
 "Allowed to pass Floors count={}-Users count={}" . format ( len ( Ii1IiiiIi1 ) ,
 len ( OOooO0OoOO0 ) ) ) )
 if 69 - 69: Ii * Ooo0Ooo / Ii / IIiIIiIi11I1 - oOo0O00 / Ii
 if 2 - 2: iI1iI11Ii111 % i1iiIII111 . oOo0O00
 O0OO ( doorDst = Ii1IiiiIi1 , userDst = OOooO0OoOO0 , opMode = 'btnAddPass_Click' , opMessage = 'Allow' ,
 controltimeseg = OoOoO0o )
 Oooo0OoOoooo = ii1I1I1 ( doorDst = Ii1IiiiIi1 , userDst = OOooO0OoOO0 , opMode = 'btnAddPass_Click' )
 if 24 - 24: i1iiIII111
 if Oooo0OoOoooo [ "updateConFailed" ] :
  o00O = """Permissions modification completed,
but this upload update was unsuccessful [due to communication failure with some controllers].
Please re-upload from the main console later."""
  vwAppConfig . vwlog ( '{}--{}[{}]' . format ( g . user . f_OperatorName ,
 o00O , Oooo0OoOoooo [ "updateConFailed" ] ) )
  return o00O
  if 55 - 55: i1i1i1111I + Oo - OooOoo / i1iiIII111 - i1
 return "OK"
 if 1 - 1: i1 - ooOOO - i1iiIII111
@ bp . route ( '/extern_elevator_pri_allowselected_all' , methods = [ 'POST' ] )
@ login_required
def o0O0oo ( ) :
 if 86 - 86: iI1iII1I1I1i
 Ii1IiiiIi1 = request . form . get ( "selecteddoor" )
 I1I111i11I = OOooO0OoOO0 = request . form . get ( "selecteduser" )
 OoOoO0o = request . form . get ( "timeprofileid" )
 if len ( Ii1IiiiIi1 ) == 0 :
  return "OK"
 iiIII = db . session . query ( TBConsumer . f_ConsumerID ) . join ( TBGroup , TBConsumer . f_GroupID == TBGroup . f_GroupID ,
 isouter = True )
 o000O0o0 = True
 if I1I111i11I :
  I1I111i11I = I1I111i11I . strip ( )
  I1iIiiIIiIi = I1I111i11I . split ( ' ' )
  if len ( I1iIiiIIiIi ) >= 1 :
   i1I11ii = and_ ( 1 > 0 )
   for iii1II11 in I1iIiiIIiIi :
    OOO00oO0oOo0O = or_ ( TBConsumer . f_ConsumerNO . like ( "%%%s%%" % iii1II11 ) ,
 TBConsumer . f_ConsumerName . like ( "%%%s%%" % iii1II11 ) ,
 TBGroup . f_GroupName . like ( "%%%s%%" % iii1II11 ) )
    if vwAppConfig . parseInt ( iii1II11 ) > 0 :
     OooO0Ooo0 = vwAppConfig . parseInt ( iii1II11 )
     OOO00oO0oOo0O = or_ ( TBConsumer . f_CardNO == OooO0Ooo0 , OOO00oO0oOo0O )
    i1I11ii = and_ ( i1I11ii , OOO00oO0oOo0O )
    o000O0o0 = False
   OOO00oO0oOo0O = i1I11ii
   iiIII = iiIII . filter ( OOO00oO0oOo0O )
 if o000O0o0 :
  Ii1IiiiIi1 = Ii1IiiiIi1 . split ( "," )
  Ii1IiiiIi1 = [ int ( x ) for x in Ii1IiiiIi1 ]
  Ii1IiiiIi1 . sort ( )
  OoooOoO00OO = TBConsumer . query . count ( )
  if 90 - 90: oOO - I1I * iI1iI11Ii111 / I11iiIi11i1I . iI1iII1I1I1i
  vwAppConfig . vwlog ( '{}--{}' . format ( g . user . f_OperatorName ,
 "Allowed to pass Floors count={}-Users count={}" . format ( len ( Ii1IiiiIi1 ) ,
 OoooOoO00OO ) ) )
  if 68 - 68: i1i1i1111I + Oo % oOO . I1I % oOO % OooOoo
  if 22 - 22: iI1iII1I1I1i % I1I . i1I
  O0OO ( doorDst = Ii1IiiiIi1 , userDst = OOooO0OoOO0 , opMode = 'btnAddPass_Click' , opMessage = 'Allow' ,
 controltimeseg = OoOoO0o )
  Oooo0OoOoooo = ii1I1I1 ( doorDst = Ii1IiiiIi1 , userDst = OOooO0OoOO0 , bUploadAllUser = True , opMode = 'btnAddPass_Click' )
 else :
  IioOOOO000 = iiIII . all ( )
  if 63 - 63: I11iiIi11i1I
  if 58 - 58: iI1iII1I1I1i
  Ii1IiiiIi1 = Ii1IiiiIi1 . split ( "," )
  Ii1IiiiIi1 = [ int ( x ) for x in Ii1IiiiIi1 ]
  Ii1IiiiIi1 . sort ( )
  if 17 - 17: iI1iII1I1I1i - Ii % iI1iII1I1I1i % oOo0O00 * Iii1i
  OOooO0OoOO0 = [ x [ 0 ] for x in IioOOOO000 ]
  OOooO0OoOO0 . sort ( )
  if 51 - 51: I1I . i1i1i1111I % Ii
  if 55 - 55: i1i1i1111I * Ii % i1i1i1111I
  vwAppConfig . vwlog ( '{}--{}' . format ( g . user . f_OperatorName ,
 "Allowed to pass Floors count={}-Users count={}" . format ( len ( Ii1IiiiIi1 ) ,
 len ( OOooO0OoOO0 ) ) ) )
  if 61 - 61: oOo0O00
  if 53 - 53: Ooo0Ooo / IiIIii11Ii
  O0OO ( doorDst = Ii1IiiiIi1 , userDst = OOooO0OoOO0 , opMode = 'btnAddPass_Click' , opMessage = 'Allow' ,
 controltimeseg = OoOoO0o )
  Oooo0OoOoooo = ii1I1I1 ( doorDst = Ii1IiiiIi1 , userDst = OOooO0OoOO0 , opMode = 'btnAddPass_Click' )
  if 49 - 49: ooo000 - oOO . IiIIii11Ii / Oo
 if Oooo0OoOoooo [ "updateConFailed" ] :
  o00O = """Permissions modification completed,
but this upload update was unsuccessful [due to communication failure with some controllers].
Please re-upload from the main console later."""
  vwAppConfig . vwlog ( '{}--{}[{}]' . format ( g . user . f_OperatorName ,
 o00O , Oooo0OoOoooo [ "updateConFailed" ] ) )
  return o00O
  if 23 - 23: I11iiIi11i1I - i1 / Iii1i . iI1iII1I1I1i + oOO
 vwAppConfig . vwlog ( '{}--{}[{}]' . format ( g . user . f_OperatorName ,
 "OK" , "Allowed to pass" ) )
 if 55 - 55: i1 - iI1iII1I1I1i / OooOoo + I1I + Oo
 return "OK"
 if 5 - 5: iI1iI11Ii111 - i1 . i1i1i1111I / iI1iI11Ii111 . iI1iII1I1I1i . iI1iI11Ii111
@ bp . route ( '/extern_elevator_pri_disallowselected' , methods = [ 'POST' ] )
@ login_required
def web_extern_elevator_pri_disallowselected ( ) :
 Ii1IiiiIi1 = request . form . get ( "selecteddoor" )
 OOooO0OoOO0 = request . form . get ( "selecteduser" )
 if 87 - 87: i1 . Ii * iI1iII1I1I1i - oOO / Ii / OooOoo
 if 65 - 65: i1I / i1I + iI1iI11Ii111
 if len ( Ii1IiiiIi1 ) == 0 or len ( OOooO0OoOO0 ) == 0 :
  return "OK"
  if 99 - 99: i1 + OooOoo + I11iiIi11i1I * Ooo0Ooo / ooOOO + Ii
 Ii1IiiiIi1 = Ii1IiiiIi1 . split ( "," )
 Ii1IiiiIi1 = [ int ( x ) for x in Ii1IiiiIi1 ]
 Ii1IiiiIi1 . sort ( )
 OOooO0OoOO0 = OOooO0OoOO0 . split ( "," )
 OOooO0OoOO0 = [ int ( x ) for x in OOooO0OoOO0 ]
 OOooO0OoOO0 . sort ( )
 vwAppConfig . vwlog ( '{}--{}' . format ( g . user . f_OperatorName ,
 "Prohibited from passing Floors count={}-Users count={}" . format ( len ( Ii1IiiiIi1 ) ,
 len ( OOooO0OoOO0 ) ) ) )
 if 72 - 72: I1Ii1I1 * Ooo0Ooo * IIiIIiIi11I1 % IiIIii11Ii . ooo000
 O0OO ( doorDst = Ii1IiiiIi1 , userDst = OOooO0OoOO0 , opMode = 'disallowselected_Click' , opMessage = 'Forbidden' )
 Oooo0OoOoooo = ii1I1I1 ( doorDst = Ii1IiiiIi1 , userDst = OOooO0OoOO0 , opMode = 'disallowselected_Click' )
 if Oooo0OoOoooo [ "updateConFailed" ] :
  o00O = """Permissions modification completed,
but this upload update was unsuccessful [due to communication failure with some controllers].
Please re-upload from the main console later."""
  vwAppConfig . vwlog ( '{}--{}[{}]' . format ( g . user . f_OperatorName ,
 o00O , Oooo0OoOoooo [ "updateConFailed" ] ) )
  return o00O
 return "OK"
 if 68 - 68: Ooo0Ooo * OooOoo - oOo0O00
@ bp . route ( '/extern_elevator_pri_disallowselected_all' , methods = [ 'POST' ] )
@ login_required
def oOooO0oOo0 ( ) :
 Ii1IiiiIi1 = request . form . get ( "selecteddoor" )
 I1I111i11I = OOooO0OoOO0 = request . form . get ( "selecteduser" )
 if len ( Ii1IiiiIi1 ) == 0 :
  return "OK"
 iiIII = db . session . query ( TBConsumer . f_ConsumerID ) . join ( TBGroup , TBConsumer . f_GroupID == TBGroup . f_GroupID ,
 isouter = True )
 o000O0o0 = True
 if I1I111i11I :
  I1I111i11I = I1I111i11I . strip ( )
  I1iIiiIIiIi = I1I111i11I . split ( ' ' )
  if len ( I1iIiiIIiIi ) >= 1 :
   i1I11ii = and_ ( 1 > 0 )
   for iii1II11 in I1iIiiIIiIi :
    OOO00oO0oOo0O = or_ ( TBConsumer . f_ConsumerNO . like ( "%%%s%%" % iii1II11 ) ,
 TBConsumer . f_ConsumerName . like ( "%%%s%%" % iii1II11 ) ,
 TBGroup . f_GroupName . like ( "%%%s%%" % iii1II11 ) )
    if vwAppConfig . parseInt ( iii1II11 ) > 0 :
     OooO0Ooo0 = vwAppConfig . parseInt ( iii1II11 )
     OOO00oO0oOo0O = or_ ( TBConsumer . f_CardNO == OooO0Ooo0 , OOO00oO0oOo0O )
    i1I11ii = and_ ( i1I11ii , OOO00oO0oOo0O )
    o000O0o0 = False
   OOO00oO0oOo0O = i1I11ii
   iiIII = iiIII . filter ( OOO00oO0oOo0O )
 if o000O0o0 :
  Ii1IiiiIi1 = Ii1IiiiIi1 . split ( "," )
  Ii1IiiiIi1 = [ int ( x ) for x in Ii1IiiiIi1 ]
  Ii1IiiiIi1 . sort ( )
  OoooOoO00OO = TBConsumer . query . count ( )
  if 53 - 53: I11iiIi11i1I % ooo000 / ooOOO / I1I
  vwAppConfig . vwlog ( '{}--{}' . format ( g . user . f_OperatorName ,
 "Prohibited from passing Floors count={}-Users count={}" . format ( len ( Ii1IiiiIi1 ) ,
 OoooOoO00OO ) ) )
  if 43 - 43: iI1iII1I1I1i . i1i1i1111I + I1I % ooOOO . iI1iI11Ii111 - iI1iI11Ii111
  if 6 - 6: I1I
  O0OO ( doorDst = Ii1IiiiIi1 , userDst = OOooO0OoOO0 , opMode = 'disallowselected_Click' , opMessage = 'Forbidden' )
  Oooo0OoOoooo = ii1I1I1 ( doorDst = Ii1IiiiIi1 , userDst = OOooO0OoOO0 , bUploadAllUser = True , opMode = 'disallowselected_Click' )
 else :
  IioOOOO000 = iiIII . all ( )
  Ii1IiiiIi1 = Ii1IiiiIi1 . split ( "," )
  Ii1IiiiIi1 = [ int ( x ) for x in Ii1IiiiIi1 ]
  Ii1IiiiIi1 . sort ( )
  if 98 - 98: oOO * IIiIIiIi11I1 / i1iiIII111 / Iii1i + I1I
  OOooO0OoOO0 = [ x [ 0 ] for x in IioOOOO000 ]
  OOooO0OoOO0 . sort ( )
  vwAppConfig . vwlog ( '{}--{}' . format ( g . user . f_OperatorName ,
 "Prohibited from passing Floors count={}-Users count={}" . format ( len ( Ii1IiiiIi1 ) ,
 len ( OOooO0OoOO0 ) ) ) )
  O0OO ( doorDst = Ii1IiiiIi1 , userDst = OOooO0OoOO0 , opMode = 'disallowselected_Click' , opMessage = 'Forbidden' )
  Oooo0OoOoooo = ii1I1I1 ( doorDst = Ii1IiiiIi1 , userDst = OOooO0OoOO0 , opMode = 'disallowselected_Click' )
 if Oooo0OoOoooo [ "updateConFailed" ] :
  o00O = """Permissions modification completed,
but this upload update was unsuccessful [due to communication failure with some controllers].
Please re-upload from the main console later."""
  vwAppConfig . vwlog ( '{}--{}[{}]' . format ( g . user . f_OperatorName ,
 o00O , Oooo0OoOoooo [ "updateConFailed" ] ) )
  return o00O
 vwAppConfig . vwlog ( '{}--{}[{}]' . format ( g . user . f_OperatorName ,
 "OK" , "Prohibited from passing" ) )
 return "OK"
def O0OO ( doorDst , userDst , opMode , opMessage , controltimeseg = 1 ) :
 vwAppConfig . WriteLine ( "{}:  {} Start" . format ( opMode , opMessage ) )
 iIi111iIi1III = vwAppConfig . getStrFromArray ( doorDst )
 OOO0OO = vwAppConfig . getStrFromArray ( userDst )
 IiIIIi1 = TBFloor . query . count ( )
 OoooOoO00OO = TBConsumer . query . count ( )
 iI = ( IiIIIi1 == len ( doorDst ) )
 OoOo = ( OoooOoO00OO == len ( userDst ) )
 if len ( userDst ) == 0 :
  OoOo = True
  if 49 - 49: IIiIIiIi11I1 / i1iiIII111 % IIiIIiIi11I1 + IIiIIiIi11I1 * iI1iII1I1I1i
 if iI and OoOo :
  if 22 - 22: I1Ii1I1 + oOO / I1Ii1I1 - Ii % Ii % i1i1i1111I
  ii1ii1ii = vwAppConfig . cleartable ( "t_b_UserFloor" )
 else :
  if iI :
   ii1ii1ii = "DELETE FROM  t_b_UserFloor  WHERE f_ConsumerID IN ({})" . format ( OOO0OO )
  elif OoOo :
   ii1ii1ii = "DELETE FROM  t_b_UserFloor  WHERE f_FloorId in ({})  " . format ( iIi111iIi1III )
  else :
   ii1ii1ii = "DELETE FROM  t_b_UserFloor  WHERE f_ConsumerID IN ({}) and  f_FloorId in ({})  " . format ( OOO0OO , iIi111iIi1III )
   if 28 - 28: IiIIii11Ii - iI1iI11Ii111 . iI1iI11Ii111 * IIiIIiIi11I1 - Iii1i
   if 1 - 1: Ooo0Ooo % Iii1i . ooOOO % oOo0O00 % Iii1i
 db . session . execute ( text ( ii1ii1ii ) )
 db . session . commit ( )
 vwAppConfig . WriteLine ( "DELETE FROM  t_b_UserFloor End" )
 if 65 - 65: Ooo0Ooo * Oo / I11iiIi11i1I . i1 / iI1iI11Ii111 / I11iiIi11i1I
 if opMode in ( 'btnAddPassAndUpload_Click' , 'btnAddPass_Click' ) :
  vwAppConfig . WriteLine ( "INSERT INTO t_b_UserFloor Start" )
  ii1ii1ii = "INSERT INTO t_b_UserFloor (f_ConsumerID, f_FloorID , f_ControlSegID, f_MoreFloorNum)"
  ii1ii1ii += " SELECT t_b_Consumer.f_ConsumerID, t_b_Floor.f_FloorId,  " + str ( controltimeseg ) + " AS f_ControlSegID  "
  if 33 - 33: ooo000 + IiIIii11Ii . ooo000
  ii1ii1ii += " , 1 as f_MoreFloorNum "
  ii1ii1ii += " FROM t_b_Consumer, t_b_Floor "
  ii1ii1ii += " WHERE  t_b_Consumer.f_DoorEnabled=1 "
  if 59 - 59: i1 / i1i1i1111I + Ii * ooo000 . ooo000
  if not OoOo :
   ii1ii1ii += " AND f_ConsumerID IN (" + OOO0OO + " ) " ;
  if not iI :
   ii1ii1ii += " AND   " + " f_FloorId IN (" + iIi111iIi1III + " ) " + " " ;
  db . session . execute ( text ( ii1ii1ii ) )
  db . session . commit ( )
  if 49 - 49: Ii - Iii1i * I1Ii1I1 * IIiIIiIi11I1 . Ooo0Ooo
  vwAppConfig . WriteLine ( "INSERT INTO t_b_UserFloor End" )
  if 83 - 83: Oo % Ii % i1
  if 28 - 28: IIiIIiIi11I1 % Ii + ooOOO . i1I % Ii * I1Ii1I1
  if 41 - 41: I1I
 if opMode not in ( 'btnAddPassAndUpload_Click' , 'btnDeletePassAndUpload_Click' ) :
  return True
 pass
 return True
 if 76 - 76: ooo000 * i1i1i1111I
def oo0O00OO0o0 ( userDst ) :
 if 93 - 93: I11iiIi11i1I
 if 96 - 96: Oo . i1 - i1i1i1111I
 Oo0OOOo = [ ]
 try :
  if 46 - 46: Ooo0Ooo - i1I / ooo000 * iI1iI11Ii111 . oOo0O00
  if 32 - 32: i1i1i1111I . OooOoo + OooOoo - ooo000 * IiIIii11Ii + Oo
  if 12 - 12: oOo0O00
  if 57 - 57: Oo + i1i1i1111I / I1Ii1I1
  O00OoooO0o = [ ]
  if 77 - 77: ooo000 + oOo0O00 . ooo000 - oOO . i1
  if 74 - 74: ooo000 / OooOoo / oOo0O00 + IIiIIiIi11I1 + OooOoo
  if 9 - 9: ooOOO - Ooo0Ooo
  OOOI1iIiiIiII1 = userDst
  OOO00oOO0 = vwAppConfigParam . sql_in_batch_size
  if 89 - 89: i1iiIII111 - I1Ii1I1
  for O000O0 in range ( 0 , len ( OOOI1iIiiIiII1 ) , OOO00oOO0 ) :
   IIIIi1i1 = OOOI1iIiiIiII1 [ O000O0 : O000O0 + OOO00oOO0 ]
   iiIII = db . session . query ( TBConsumer . f_CardNO ) . filter ( TBConsumer . f_CardNO . isnot ( None ) ) . filter (
 TBConsumer . f_ConsumerID . in_ ( IIIIi1i1 ) )
   iI1iII1iI1Ii1 = iiIII . all ( )
   O00OoooO0o . extend ( iI1iII1iI1Ii1 )
  Oo0OOOo = O00OoooO0o
 except Exception as o0o0OO :
  print ( o0o0OO )
  pass
 return Oo0OOOo
 if 10 - 10: IIiIIiIi11I1 % ooo000 % I11iiIi11i1I % Ooo0Ooo
 if 70 - 70: IiIIii11Ii
def ii1I1I1 ( doorDst , userDst , opMode , bUploadAllUser = False ) :
 print ( "uploadSelectedPrivilege" )
 i11Ii = ii ( )
 if 83 - 83: i1I . ooo000 * Ooo0Ooo + Iii1i . Oo
 if 34 - 34: I11iiIi11i1I % oOO
 iIi111iIi1III = ""
 for OOOoOo in doorDst :
  iIi111iIi1III += str ( OOOoOo ) + ","
 iIi111iIi1III += '0'
 if 75 - 75: i1 % IiIIii11Ii - iI1iII1I1I1i - i1I * I11iiIi11i1I * OooOoo
 if 45 - 45: IIiIIiIi11I1
 if 14 - 14: i1i1i1111I - OooOoo . IiIIii11Ii
 if 40 - 40: I1I - IIiIIiIi11I1 % IiIIii11Ii
 OoOo = False
 if bUploadAllUser :
  OoOo = True
 else :
  OoooOoO00OO = TBConsumer . query . count ( )
  OoOo = ( OoooOoO00OO == len ( userDst ) )
  if 61 - 61: iI1iII1I1I1i
  if 93 - 93: i1iiIII111 - oOo0O00 . Oo . i1iiIII111 . Oo * I1Ii1I1
 if OoOo :
  Oo0OOOo = [ ]
 else :
  Oo0OOOo = oo0O00OO0o0 ( userDst )
  if 95 - 95: I1Ii1I1 % oOO
  if 21 - 21: Ooo0Ooo % i1 - ooo000
  if 81 - 81: Ooo0Ooo / ooo000
  if 4 - 4: I1I % i1I - ooo000 - I1I . ooOOO / i1i1i1111I
  if 74 - 74: oOO
 iiIII = db . session . query ( TBController . f_ControllerID , TBController . f_ControllerSN ) . join ( TBDoor ,
 TBDoor . f_ControllerID == TBController . f_ControllerID ) . join ( TBFloor ,
 TBDoor . f_DoorID == TBFloor . f_DoorID ) . filter (
 TBFloor . f_FloorId . in_ ( doorDst ) )
 IioOOOO000 = iiIII . all ( )
 for OOOoOo in IioOOOO000 :
  Oo0O0O = OOOoOo . f_ControllerSN
  if Oo0O0O not in i11Ii . uploadedSN :
   IiIiI1I = OOOoOo . f_ControllerID
   i11Ii . uploadedSN . append ( Oo0O0O )
   OO0oOOO0o00 = threading . Thread ( target = ooOooOooO0o0 , args = ( Oo0O0O , IiIiI1I , i11Ii ) )
   OO0oOOO0o00 . start ( )
 Oo0OOoO0000 = time . time ( )
 while time . time ( ) < Oo0OOoO0000 + 10 :
  if len ( i11Ii . uploadedSNConnectedOK ) + len ( i11Ii . uploadedSNFailed ) == len ( i11Ii . uploadedSN ) :
   break
  time . sleep ( 0.1 )
 print ( "uploadedSNConnectedOK" )
 print ( i11Ii . uploadedSNConnectedOK )
 iIiiII1iI = 0
 IiI1 = False
 if len ( userDst ) > 10 :
  IiI1 = True
 if bUploadAllUser :
  IiI1 = True
 if len ( i11Ii . uploadedSNConnectedOK ) > 0 :
  for OOO0OOoo0ooO in range ( len ( i11Ii . uploadedSNConnectedOK ) ) :
   IiIiI1I = i11Ii . uploadedIdConnectedOK [ OOO0OOoo0ooO ]
   Oo0O0O = i11Ii . uploadedSNConnectedOK [ OOO0OOoo0ooO ]
   if IiI1 :
    iiIII = db . session . query ( TBConsumer . f_CardNO , TBFloor . f_FloorNO ,
 TBUserfloor . f_ControlSegID ,
 TBConsumer . f_BeginYMD , TBConsumer . f_EndYMD ,
 TBConsumer . f_PIN , TBConsumer . f_ConsumerID , TBDoor . f_DoorID , TBController . f_ControllerID ) . join (
 TBFloor , TBUserfloor . f_FloorId == TBFloor . f_FloorId ) . join (
 TBDoor , TBFloor . f_DoorID == TBDoor . f_DoorID ) . join (
 TBController , TBController . f_ControllerID == TBDoor . f_ControllerID ) . join (
 TBConsumer , TBUserfloor . f_ConsumerID == TBConsumer . f_ConsumerID ) . filter (
 TBConsumer . f_CardNO . isnot ( None ) ) . filter ( TBController . f_ControllerID == IiIiI1I ) . order_by (
 TBConsumer . f_CardNO )
    if 5 - 5: oOO / I1Ii1I1 + iI1iII1I1I1i
    if 73 - 73: oOO - Oo % Oo % oOO + oOO + Ii
    if 98 - 98: oOO - Ooo0Ooo / i1 . Ii + ooOOO - IiIIii11Ii
    if 12 - 12: i1 . i1I / IiIIii11Ii * iI1iI11Ii111
    if 81 - 81: iI1iI11Ii111 / I1I / Ii / i1I
    if 45 - 45: iI1iI11Ii111 + I1Ii1I1 % oOo0O00 + i1I + ooOOO
    if 66 - 66: OooOoo . Ii - OooOoo + OooOoo * OooOoo / i1iiIII111
    if 32 - 32: IIiIIiIi11I1 - i1I / ooOOO * Ooo0Ooo * iI1iII1I1I1i - i1i1i1111I
    if 82 - 82: ooo000
    if 66 - 66: IiIIii11Ii + IIiIIiIi11I1 - i1I + i1i1i1111I . iI1iII1I1I1i * IiIIii11Ii
    IioOOOO000 = iiIII . all ( )
   else :
    if 9 - 9: I1I - I1I - ooOOO - oOo0O00 + i1iiIII111
    if 71 - 71: i1I / i1iiIII111 - Ii * Oo . iI1iII1I1I1i
    if 3 - 3: I1Ii1I1
    if 57 - 57: Ooo0Ooo . OooOoo / oOo0O00 * I1Ii1I1
    if 36 - 36: IiIIii11Ii
    if 33 - 33: IiIIii11Ii
    if 86 - 86: Ii / oOo0O00 - i1 * i1i1i1111I - Oo * Iii1i
    if 28 - 28: OooOoo . i1 % iI1iII1I1I1i % Iii1i
    if 2 - 2: Oo + OooOoo - i1i1i1111I - ooo000 / Oo . Oo
    if 41 - 41: OooOoo + OooOoo - OooOoo
    if 9 - 9: Iii1i % I1Ii1I1 % IiIIii11Ii - I1I * OooOoo
    if 53 - 53: iI1iII1I1I1i * i1i1i1111I / OooOoo . i1I . ooo000
    if 45 - 45: OooOoo + ooOOO / i1i1i1111I * i1
    if 71 - 71: iI1iI11Ii111 % Iii1i + oOo0O00 * I11iiIi11i1I / iI1iI11Ii111
    if 66 - 66: ooo000 * oOo0O00
    if 83 - 83: i1
    if 64 - 64: i1 . iI1iI11Ii111 - I11iiIi11i1I . Iii1i
    if 47 - 47: ooo000 / Ooo0Ooo % IiIIii11Ii
    if 70 - 70: IIiIIiIi11I1 / Iii1i . i1i1i1111I % ooOOO . Ii / Ii
    if 51 - 51: I11iiIi11i1I + Ooo0Ooo - ooo000 * oOO . oOO
    if 79 - 79: i1i1i1111I + oOo0O00
    if 11 - 11: OooOoo / i1iiIII111 % i1I - i1i1i1111I * oOo0O00
    if 90 - 90: i1 * i1 . Ooo0Ooo . Oo
    if 59 - 59: Ii % I1Ii1I1 + Iii1i . OooOoo * Iii1i
    if 21 - 21: I11iiIi11i1I + ooOOO % IiIIii11Ii / OooOoo
    if 96 - 96: Oo * i1iiIII111 . Ooo0Ooo
    O00OoooO0o = [ ]
    if 35 - 35: ooOOO . i1I * i1i1i1111I * iI1iII1I1I1i - I11iiIi11i1I
    if 47 - 47: IIiIIiIi11I1
    if 73 - 73: I1Ii1I1 + ooOOO
    OOOI1iIiiIiII1 = userDst
    OOO00oOO0 = vwAppConfigParam . sql_in_batch_size
    if 99 - 99: i1I
    for O000O0 in range ( 0 , len ( OOOI1iIiiIiII1 ) , OOO00oOO0 ) :
     IIIIi1i1 = OOOI1iIiiIiII1 [ O000O0 : O000O0 + OOO00oOO0 ]
     iiIII = db . session . query ( TBConsumer . f_CardNO , TBFloor . f_FloorNO ,
 TBUserfloor . f_ControlSegID ,
 TBConsumer . f_BeginYMD , TBConsumer . f_EndYMD ,
 TBConsumer . f_PIN , TBConsumer . f_ConsumerID , TBDoor . f_DoorID ,
 TBController . f_ControllerID ) . filter (
 TBUserfloor . f_ConsumerID . in_ ( IIIIi1i1 ) ) . join (
 TBFloor , TBUserfloor . f_FloorId == TBFloor . f_FloorId ) . join (
 TBDoor , TBFloor . f_DoorID == TBDoor . f_DoorID ) . join (
 TBController , TBController . f_ControllerID == TBDoor . f_ControllerID ) . join (
 TBConsumer , TBUserfloor . f_ConsumerID == TBConsumer . f_ConsumerID ) . filter (
 TBConsumer . f_CardNO . isnot ( None ) ) . filter ( TBController . f_ControllerID == IiIiI1I ) . order_by (
 TBConsumer . f_CardNO )
     iI1iII1iI1Ii1 = iiIII . all ( )
     O00OoooO0o . extend ( iI1iII1iI1Ii1 )
    IioOOOO000 = O00OoooO0o
    if 87 - 87: i1 . I11iiIi11i1I * Ii . i1 . IIiIIiIi11I1 . IiIIii11Ii
    if 50 - 50: Ii / oOO
   I1i1i = "uploadEditPrivilege"
   if 92 - 92: Ooo0Ooo * i1iiIII111 / Ooo0Ooo / i1iiIII111 * i1i1i1111I + i1I
   o0ooo0oOoO = [ ]
   Oo0OoOo = [ ]
   O0oOO0Oo00ooo , o0O00 , I1 = 0 , None , None
   Oo0 = [ 0 , 0 , 0 , 0 ]
   Iii1Iiii1 = [ 0 , 0 , 0 , 0 ]
   if 53 - 53: iI1iII1I1I1i + i1i1i1111I * Oo % OooOoo % ooo000 * i1i1i1111I
   if 76 - 76: Ooo0Ooo . OooOoo * oOo0O00 / i1iiIII111 + ooo000
   OOoooo0oo = 0
   iIIIi1IiI = 1
   Oooo0O = [ ]
   if len ( IioOOOO000 ) > 0 :
    for O0Ooo0oOo0 in IioOOOO000 :
     if O0oOO0Oo00ooo != O0Ooo0oOo0 . f_CardNO :
      if O0oOO0Oo00ooo > 0 :
       Oo0OoOo . append ( O0oOO0Oo00ooo )
       iii1iII = {
 "CardNO" : [
 O0oOO0Oo00ooo
 ] ,
 "BeginDateTime" : o0O00 ,
 "EndDateTime" : I1 ,
 "Door1TimeProfileID" : iIIIi1IiI ,
 "AllowFloorsNO" : Oooo0O ,
 "UserPassword" : OOoooo0oo
 }
       if 66 - 66: oOo0O00
       if 34 - 34: ooo000 . iI1iII1I1I1i
       o0ooo0oOoO . append ( iii1iII )
       Oooo0O . clear ( )
       if 72 - 72: i1 % iI1iII1I1I1i . OooOoo . Iii1i . i1 . OooOoo
      O0oOO0Oo00ooo = O0Ooo0oOo0 . f_CardNO
      OOoooo0oo = O0Ooo0oOo0 . f_PIN
      if 26 - 26: i1i1i1111I + i1I % i1i1i1111I + Iii1i
      if 9 - 9: iI1iII1I1I1i * OooOoo
      if 12 - 12: Ii . Ii - I1Ii1I1
      if 74 - 74: ooo000 * Iii1i - Ooo0Ooo - I1Ii1I1
      o0O00 = vwAppConfig . getStrOfDatetime ( vwAppConfig . strtotime ( O0Ooo0oOo0 . f_BeginYMD ) )
      I1 = vwAppConfig . getStrOfDatetime ( vwAppConfig . strtotime ( O0Ooo0oOo0 . f_EndYMD ) )
      if 46 - 46: ooOOO / ooOOO
      if 58 - 58: iI1iI11Ii111 . iI1iI11Ii111
     iIIIi1IiI = O0Ooo0oOo0 . f_ControlSegID
     Oooo0O . append ( O0Ooo0oOo0 . f_FloorNO )
     if not vwAppConfigParam . extfunc5678_timeprofile > 0 :
      if iIIIi1IiI > 1 :
       iIIIi1IiI = 1
       if 79 - 79: oOo0O00 * IIiIIiIi11I1
       if 53 - 53: Ii - ooOOO . OooOoo - I1I - I11iiIi11i1I
       if 32 - 32: Iii1i % IiIIii11Ii - oOO - IiIIii11Ii - I11iiIi11i1I % i1iiIII111
       if 50 - 50: Iii1i / iI1iI11Ii111 + i1
       if 4 - 4: IIiIIiIi11I1 . IiIIii11Ii % i1I
       if 30 - 30: i1 . i1
       if 35 - 35: Ii * i1I / IiIIii11Ii - I1Ii1I1 / i1
       if 76 - 76: IiIIii11Ii * Iii1i % IiIIii11Ii
       if 73 - 73: i1I / IIiIIiIi11I1 / oOo0O00 % IIiIIiIi11I1 / Ii
    if Oo0O0O > 0 :
     Oo0OoOo . append ( O0oOO0Oo00ooo )
     iii1iII = {
 "CardNO" : [
 O0oOO0Oo00ooo
 ] ,
 "BeginDateTime" : o0O00 ,
 "EndDateTime" : I1 ,
 "Door1TimeProfileID" : iIIIi1IiI ,
 "AllowFloorsNO" : Oooo0O ,
 "UserPassword" : OOoooo0oo
 }
     if 12 - 12: i1
     if 78 - 78: I11iiIi11i1I . IIiIIiIi11I1
     o0ooo0oOoO . append ( iii1iII )
     if 1 - 1: I1I % i1iiIII111 / I1Ii1I1
     if IiI1 :
      i1IiiI1I1i1 = ( {
 "jsonrpc" : "2.0" ,
 "method" : "UploadAllPrivileges" ,
 "params" : [
 {
 "ControllerSN" : Oo0O0O ,
 "Privilege" : o0ooo0oOoO
 }
 ] ,
 "id" : 4004
 } )
     else :
      i1IiiI1I1i1 = ( {
 "jsonrpc" : "2.0" ,
 "method" : "AddEditPrivilege" ,
 "params" : [
 {
 "ControllerSN" : Oo0O0O ,
 "Privilege" : o0ooo0oOoO
 }
 ] ,
 "id" : 4001
 } )
     if iIiiII1iI < len ( o0ooo0oOoO ) :
      iIiiII1iI = len ( o0ooo0oOoO )
      if 42 - 42: Iii1i
     OO0oOOO0o00 = threading . Thread ( target = i1II1I1iIIIii1I1 ,
 args = ( Oo0O0O , i1IiiI1I1i1 , len ( o0ooo0oOoO ) , i11Ii ) )
     OO0oOOO0o00 . start ( )
     if 63 - 63: I1Ii1I1 + oOO * iI1iI11Ii111 * i1 + i1I * I1Ii1I1
     if 49 - 49: oOo0O00 * I1Ii1I1 / Iii1i
     if len ( Oo0OOOo ) > len ( Oo0OoOo ) and not IiI1 :
      if 90 - 90: i1I - I1Ii1I1 . i1iiIII111 % i1 % i1I
      o0ooo0oOoO . clear ( )
      if 14 - 14: i1iiIII111 / i1i1i1111I * IiIIii11Ii / i1iiIII111
      for OOOoOo in Oo0OOOo :
       if OOOoOo . f_CardNO not in Oo0OoOo :
        o0ooo0oOoO . append ( {
 "CardNO" : [
 OOOoOo . f_CardNO
 ] ,
 } )
      i1IiiI1I1i1 = ( {
 "jsonrpc" : "2.0" ,
 "method" : "DeletePrivilege" ,
 "params" : [
 {
 "ControllerSN" : Oo0O0O ,
 "Privilege" : o0ooo0oOoO
 }
 ] ,
 "id" : 4002
 } )
      i11Ii . uploadedSN_Delete . append ( Oo0O0O )
      if iIiiII1iI < len ( o0ooo0oOoO ) :
       iIiiII1iI = len ( o0ooo0oOoO )
      OO0oOOO0o00 = threading . Thread ( target = i111IIiIii1iI ,
 args = ( Oo0O0O , i1IiiI1I1i1 , len ( o0ooo0oOoO ) , i11Ii ) )
      OO0oOOO0o00 . start ( )
   else :
    i11Ii . uploadedSNOK . append ( Oo0O0O )
    if ( IiI1 ) :
     i1IiiI1I1i1 = ( {
 "jsonrpc" : "2.0" ,
 "method" : "PrivilegeClear" ,
 "params" : [
 {
 "ControllerSN" : Oo0O0O
 }
 ] ,
 "id" : 4004
 } )
     i11Ii . uploadedSN_Delete . append ( Oo0O0O )
     if iIiiII1iI < len ( o0ooo0oOoO ) :
      iIiiII1iI = len ( o0ooo0oOoO )
     OO0oOOO0o00 = threading . Thread ( target = i111IIiIii1iI ,
 args = ( Oo0O0O , i1IiiI1I1i1 , len ( o0ooo0oOoO ) , i11Ii ) )
     OO0oOOO0o00 . start ( )
    if len ( Oo0OOOo ) > 0 and not IiI1 :
     if 33 - 33: Iii1i
     o0ooo0oOoO . clear ( )
     for OOOoOo in Oo0OOOo :
      o0ooo0oOoO . append ( {
 "CardNO" : [
 OOOoOo . f_CardNO
 ] ,
 } )
     i1IiiI1I1i1 = ( {
 "jsonrpc" : "2.0" ,
 "method" : "DeletePrivilege" ,
 "params" : [
 {
 "ControllerSN" : Oo0O0O ,
 "Privilege" : o0ooo0oOoO
 }
 ] ,
 "id" : 4002
 } )
     i11Ii . uploadedSN_Delete . append ( Oo0O0O )
     if iIiiII1iI < len ( o0ooo0oOoO ) :
      iIiiII1iI = len ( o0ooo0oOoO )
     OO0oOOO0o00 = threading . Thread ( target = i111IIiIii1iI ,
 args = ( Oo0O0O , i1IiiI1I1i1 , len ( o0ooo0oOoO ) , i11Ii ) )
     OO0oOOO0o00 . start ( )
     if 7 - 7: Ooo0Ooo - Ooo0Ooo / ooo000 - IiIIii11Ii
     if 70 - 70: IIiIIiIi11I1 . i1 % iI1iII1I1I1i / i1i1i1111I
     if 5 - 5: i1iiIII111 . Oo + i1i1i1111I
     if 44 - 44: I1Ii1I1 - i1i1i1111I
     if 71 - 71: i1iiIII111
     if 77 - 77: Iii1i - I1Ii1I1 - Ooo0Ooo % Ii / Oo
     if 43 - 43: Ooo0Ooo / oOO
     if 93 - 93: ooOOO % oOo0O00 * i1 + Ii . i1I - oOO
     if 63 - 63: IiIIii11Ii . Iii1i
 o000Oo = time . time ( ) + vwAppConfigParam . uploadpri_timeout_second + ( iIiiII1iI / 1000 ) * 2
 while time . time ( ) < o000Oo :
  if len ( i11Ii . recvsnpri ) > 0 :
   i11Ii . recvsnpri . clear ( )
   if 13 - 13: I1I
   IIi = time . time ( ) + vwAppConfigParam . uploadpri_timeout_second
   if IIi > o000Oo :
    o000Oo = IIi
  if len ( i11Ii . uploadedSNOK ) + len ( i11Ii . uploadedSNFailed ) == len ( i11Ii . uploadedSN ) and len (
 i11Ii . uploadedSNOK_Delete ) + len (
 i11Ii . uploadedSNFailed_Delete ) == len ( i11Ii . uploadedSN_Delete ) :
   break
   if 40 - 40: IIiIIiIi11I1 - ooOOO * oOO . ooo000
 iiIII = db . session . query ( TBController . f_ControllerID , TBController . f_ControllerSN , TBDoor . f_DoorNO ,
 TBDoor . f_DoorID ) . join ( TBDoor ,
 TBDoor . f_ControllerID == TBController . f_ControllerID )
 IIiIiIII = iiIII . all ( )
 if 34 - 34: i1I + Ii
 i1IooO0O00O0o = [ ]
 OO0 = [ ]
 iIi = [ ]
 iiiIi = [ ]
 for oo0OO0ooO0O0 in doorDst :
  iIi111iIi1III += str ( oo0OO0ooO0O0 ) + ","
  for OOOoOo in IIiIiIII :
   Oo0O0O = OOOoOo . f_ControllerSN
   if 42 - 42: iI1iII1I1I1i % iI1iI11Ii111 . i1I
   if 67 - 67: Ooo0Ooo . OooOoo / i1I % i1I
   if oo0OO0ooO0O0 == OOOoOo . f_DoorID :
    iiI1IIII1I1 = - 1
    try :
     iiI1IIII1I1 = i11Ii . uploadedSNOK . index ( Oo0O0O )
    except :
     iiI1IIII1I1 = - 1
     if 78 - 78: I1Ii1I1 . ooo000 + iI1iI11Ii111 / iI1iI11Ii111
    if iiI1IIII1I1 >= 0 :
     i1IooO0O00O0o . append ( oo0OO0ooO0O0 )
     if 88 - 88: Ii - i1iiIII111 - i1 * IIiIIiIi11I1 . IiIIii11Ii + Iii1i
    else :
     try :
      iiI1IIII1I1 = i11Ii . uploadedSNConnectedOK . index ( Oo0O0O )
     except :
      iiI1IIII1I1 = - 1
     if iiI1IIII1I1 < 0 :
      iIi . append ( oo0OO0ooO0O0 )
     else :
      iiiIi . append ( oo0OO0ooO0O0 )
      if 44 - 44: ooOOO + Oo - i1
 return { "updateConOK" : i11Ii . uploadedSNOK , "updateConFailed" : i11Ii . uploadedSNFailed ,
 "doorID_OK" : i1IooO0O00O0o ,
 "doorID_NotConnected" : iIi , "doorID_Fail" : iiiIi }
 if 18 - 18: iI1iII1I1I1i * ooOOO + Ooo0Ooo
 if 78 - 78: I1I . I1I - IIiIIiIi11I1 - IiIIii11Ii % I11iiIi11i1I . I1Ii1I1
def ooOooOooO0o0 ( sn , conid , wgcondata ) :
 i1IiiI1I1i1 = ( {
 "jsonrpc" : "2.0" ,
 "method" : "QueryControllerStatus" ,
 "params" : [ { "ControllerSN" : sn } ] ,
 "id" : 1002
 } )
 if OO0OOo0oOO ( i1IiiI1I1i1 ) == "OK" :
  wgcondata . uploadedSNConnectedOK . append ( sn )
  wgcondata . uploadedIdConnectedOK . append ( conid )
  wgcondata . recvsnpri . append ( conid )
 else :
  wgcondata . uploadedSNFailed . append ( sn )
  if 9 - 9: I11iiIi11i1I * OooOoo - I11iiIi11i1I
  if 73 - 73: I1Ii1I1
def OO0OOo0oOO ( arrinfo , timeoutSec = 3 ) :
 iiII = None
 try :
  II1I1i1 = vwAppConfigParam . server1001_ip
  iI1IiI1 = vwAppConfigParam . server1001_webport
  OO00 = http . client . HTTPConnection ( host = II1I1i1 , port = iI1IiI1 , timeout = 3 )
  if 12 - 12: ooo000 . I1Ii1I1 . i1I
  ii1iI1I1i1iI = bytes ( json . dumps ( arrinfo , sort_keys = False , indent = 4 ) , encoding = 'utf8' )
  if 17 - 17: iI1iI11Ii111 / i1 . iI1iI11Ii111 + ooOOO + ooo000 - IiIIii11Ii
  if 59 - 59: iI1iII1I1I1i / I11iiIi11i1I + iI1iI11Ii111
  o0 = { "Content-type" : "application/json" , "Accept" : "application/json" }
  OO00 . timeout = timeoutSec
  if 85 - 85: iI1iI11Ii111 % oOo0O00 % oOo0O00
  OO00 . request ( "POST" , II1I1i1 , ii1iI1I1i1iI , o0 )
  III = OO00 . getresponse ( )
  if 82 - 82: ooOOO + oOo0O00 * I1I
  i1Oo0o0OOOOOO0 = III . read ( )
  if 5 - 5: i1I * i1iiIII111 / i1 * oOO * IIiIIiIi11I1
  if 86 - 86: oOo0O00 % oOO / I1Ii1I1
  if 38 - 38: IIiIIiIi11I1
  OO00 . close ( )
  try :
   if 17 - 17: oOO + i1iiIII111 / i1i1i1111I * IiIIii11Ii / oOo0O00 / Ooo0Ooo
   if 43 - 43: i1I + iI1iII1I1I1i + Oo
   o000oOo0o0O0 = json . loads ( i1Oo0o0OOOOOO0 . decode ( "utf-8" ) )
   if 39 - 39: OooOoo . I1I / Ooo0Ooo + i1I
   if o000oOo0o0O0 [ 'result' ] [ 'success' ] :
    iiII = "OK"
   else :
    iiII = o000oOo0o0O0 [ 'result' ] [ 'msg' ]
    if 59 - 59: I1Ii1I1 + i1i1i1111I
  except :
   if 63 - 63: I1Ii1I1 * Ii + Iii1i
   if 58 - 58: I1Ii1I1 / I1Ii1I1 % IIiIIiIi11I1
   if 98 - 98: OooOoo
   iiII = None
   return iiII
   if 79 - 79: Ooo0Ooo * Ooo0Ooo - ooo000 - Iii1i
   if 5 - 5: IiIIii11Ii / i1iiIII111 . I1I % Iii1i . i1
  return iiII
 except Exception as OooOoO0o00 :
  pass
  print ( OooOoO0o00 )
  if 29 - 29: oOo0O00 + Oo / I11iiIi11i1I - oOo0O00 % i1i1i1111I / Ii
  if 39 - 39: I11iiIi11i1I - I11iiIi11i1I % i1iiIII111
 return None
 if 56 - 56: i1iiIII111 / IiIIii11Ii - I1Ii1I1 / Iii1i - i1 / OooOoo
 if 28 - 28: i1I . I1Ii1I1 % IiIIii11Ii . Ii * ooOOO - oOO
def i1II1I1iIIIii1I1 ( sn , cmdjson , privlen , wgcondata ) :
 vwAppConfig . wglog ( "uploadSingleController privileges sn={}  privlen={} start" . format ( sn , privlen ) )
 if 80 - 80: iI1iI11Ii111
 iii1iIIIi1II = 10
 if privlen > 100 :
  iii1iIIIi1II = iii1iIIIi1II + privlen / 100
 if OO0OOo0oOO ( cmdjson , iii1iIIIi1II ) == "OK" :
  wgcondata . uploadedSNOK . append ( sn )
  vwAppConfig . wglog ( "uploadSingleController privileges {} end OK" . format ( sn ) )
  wgcondata . recvsnpri . append ( sn )
 else :
  wgcondata . uploadedSNFailed . append ( sn )
  vwAppConfig . wglog ( "uploadSingleController privileges {} end Failed" . format ( sn ) )
  if 90 - 90: Iii1i / oOo0O00
def i111IIiIii1iI ( sn , cmdjson , privlen , wgcondata ) :
 vwAppConfig . wglog ( "uploadSingleDelete privileges sn={}  privlen={} start" . format ( sn , privlen ) )
 iii1iIIIi1II = 10
 if privlen > 100 :
  iii1iIIIi1II = iii1iIIIi1II + privlen / 100
 Oooo0OoOoooo = OO0OOo0oOO ( cmdjson , iii1iIIIi1II )
 if Oooo0OoOoooo == "OK" :
  wgcondata . uploadedSNOK_Delete . append ( sn )
  vwAppConfig . wglog ( "uploadSingleController privileges {} end OK" . format ( sn ) )
  wgcondata . recvsnpri . append ( sn )
 else :
  if 54 - 54: I11iiIi11i1I . iI1iI11Ii111 + OooOoo % Oo - iI1iI11Ii111 % Oo
  wgcondata . uploadedSNFailed_Delete . append ( sn )
  vwAppConfig . wglog ( "uploadSingleController privileges {} end Failed" . format ( sn ) )
  if 37 - 37: Oo
  if 64 - 64: I1I % ooOOO
  if 67 - 67: Ooo0Ooo + oOo0O00
@ bp . route ( '/extern_elevator_pri_list' , methods = [ 'GET' , 'POST' ] )
@ login_required
def web_extern_elevator_pri_list ( ) :
 oOoo0 = {
 "objlist" : [ ] ,
 }
 return render_template ( "wgcomm/extern-elevator-pri-list.html" , ** oOoo0 )
 if 21 - 21: oOO
 if 64 - 64: IIiIIiIi11I1 * i1iiIII111
@ bp . route ( '/extern_elevator_pri_listpage' , methods = [ 'GET' , 'POST' ] )
@ login_required
def web_extern_elevator_pri_listpage ( ) :
 if request . method == 'GET' :
  oOo00O = int ( request . args . get ( 'draw' ) )
  OoO = int ( request . args . get ( 'length' ) )
  ii1IiIiiII = int ( request . args . get ( 'start' ) )
  I1I111i11I = request . args . get ( 'search[value]' )
 else :
  oOo00O = int ( request . form . get ( 'draw' ) )
  OoO = int ( request . form . get ( 'length' ) )
  ii1IiIiiII = int ( request . form . get ( 'start' ) )
  I1I111i11I = request . form . get ( 'search[value]' )
 iii11i = [ ]
 vwAppConfig . wglog ( 'pagesize={},start={},search={}' . format ( OoO , ii1IiIiiII , I1I111i11I ) )
 if not vwAppConfigParam . extfunc5678_timeprofile > 0 :
  iiIII = db . session . query ( TBUserfloor . f_RecId ,
 TBDoor . f_DoorName , TBFloor . f_FloorName , TBFloor . f_FloorNO , TBConsumer . f_ConsumerNO , TBConsumer . f_ConsumerName ,
 TBConsumer . f_CardNO , TBGroup . f_GroupName ) . join ( TBFloor ,
 TBUserfloor . f_FloorId == TBFloor . f_FloorId ) . join ( TBDoor ,
 TBFloor . f_DoorID == TBDoor . f_DoorID ) . join (
 TBConsumer , TBUserfloor . f_ConsumerID == TBConsumer . f_ConsumerID ) . join ( TBGroup ,
 TBConsumer . f_GroupID == TBGroup . f_GroupID ,
 isouter = True )
 else :
  iiIII = db . session . query ( TBUserfloor . f_RecId ,
 TBDoor . f_DoorName , TBFloor . f_FloorName , TBFloor . f_FloorNO , TBConsumer . f_ConsumerNO , TBConsumer . f_ConsumerName ,
 TBConsumer . f_CardNO , TBGroup . f_GroupName , TBUserfloor . f_ControlSegID ,
 TBControlseg . f_ControlSegName ) . join ( TBFloor ,
 TBUserfloor . f_FloorId == TBFloor . f_FloorId ) . join ( TBDoor ,
 TBFloor . f_DoorID == TBDoor . f_DoorID ) . join (
 TBConsumer , TBUserfloor . f_ConsumerID == TBConsumer . f_ConsumerID ) . join ( TBGroup ,
 TBConsumer . f_GroupID == TBGroup . f_GroupID ,
 isouter = True ) . join ( TBControlseg ,
 TBUserfloor . f_ControlSegID == TBControlseg . f_ControlSegID ,
 isouter = True )
  if 31 - 31: Iii1i
 if I1I111i11I :
  I1I111i11I = I1I111i11I . strip ( )
  if '.' in I1I111i11I :
   I1iIiiIIiIi = I1I111i11I . split ( '.' )
   if len ( I1iIiiIIiIi ) >= 1 :
    i1I11ii = and_ ( 1 > 0 )
    for iii1II11 in I1iIiiIIiIi :
     if 86 - 86: Oo
     if 74 - 74: OooOoo - I11iiIi11i1I . Oo . i1 + oOo0O00 - ooOOO
     if 60 - 60: Oo
     if 23 - 23: oOo0O00
     if 47 - 47: Ooo0Ooo + Oo * Ii . OooOoo . I1Ii1I1 * i1iiIII111
     if '_' in iii1II11 :
      iii1II11 = iii1II11 . replace ( '_' , '\\_' )
     OOO00oO0oOo0O = or_ (

     # iI1iI11Ii111 - i1i1i1111I + IiIIii11Ii
     # Oo / ooo000 - iI1iII1I1I1i
     TBFloor . f_FloorName . like ( "{0}%" . format ( iii1II11 ) , escape = '\\' ) ,
     TBDoor . f_DoorName . like ( "%{0}" . format ( iii1II11 ) , escape = '\\' )
     )
     if 35 - 35: IIiIIiIi11I1 * I1Ii1I1 - OooOoo . Ii
     if 21 - 21: Ooo0Ooo
     if 76 - 76: iI1iII1I1I1i % iI1iI11Ii111 / IiIIii11Ii - iI1iI11Ii111
     i1I11ii = and_ ( i1I11ii , OOO00oO0oOo0O )
    OOO00oO0oOo0O = i1I11ii
    iiIII = iiIII . filter ( OOO00oO0oOo0O )
  else :
   I1iIiiIIiIi = I1I111i11I . split ( ' ' )
   if len ( I1iIiiIIiIi ) >= 1 :
    i1I11ii = and_ ( 1 > 0 )
    for iii1II11 in I1iIiiIIiIi :
     if 4 - 4: OooOoo * IIiIIiIi11I1 - Ooo0Ooo . Ii - ooOOO . i1iiIII111
     if 2 - 2: I11iiIi11i1I * i1I * i1I * i1iiIII111 / I11iiIi11i1I % iI1iI11Ii111
     if 13 - 13: i1 * IiIIii11Ii - ooo000 * OooOoo
     if 72 - 72: Iii1i . I1Ii1I1 * IIiIIiIi11I1 % I1Ii1I1 - i1i1i1111I
     if 97 - 97: i1 + ooOOO + I11iiIi11i1I . i1
     if '_' in iii1II11 :
      iii1II11 = iii1II11 . replace ( '_' , '\\_' )
     OOO00oO0oOo0O = or_ (
 TBConsumer . f_ConsumerNO . like ( "%{0}%" . format ( iii1II11 ) , escape = '\\' ) ,
 TBConsumer . f_ConsumerName . like ( "%{0}%" . format ( iii1II11 ) , escape = '\\' ) ,
 TBGroup . f_GroupName . like ( "%{0}%" . format ( iii1II11 ) , escape = '\\' ) ,
 TBFloor . f_FloorName . like ( "%{0}%" . format ( iii1II11 ) , escape = '\\' ) ,
 TBDoor . f_DoorName . like ( "%{0}%" . format ( iii1II11 ) , escape = '\\' )
 )
     if vwAppConfig . parseInt ( iii1II11 ) > 0 :
      OooO0Ooo0 = vwAppConfig . parseInt ( iii1II11 )
      OOO00oO0oOo0O = or_ ( TBConsumer . f_CardNO == OooO0Ooo0 , OOO00oO0oOo0O )
     i1I11ii = and_ ( i1I11ii , OOO00oO0oOo0O )
    OOO00oO0oOo0O = i1I11ii
    iiIII = iiIII . filter ( OOO00oO0oOo0O )
    if 71 - 71: ooo000 - i1i1i1111I / iI1iII1I1I1i - iI1iII1I1I1i % IIiIIiIi11I1 . iI1iII1I1I1i
 i1i1iiII = iiIII . count ( )
 IioOOOO000 = iiIII . order_by ( TBConsumer . f_ConsumerNO ) . order_by ( TBDoor . f_DoorName ) . order_by ( TBFloor . f_FloorNO ) . offset ( ii1IiIiiII ) . limit ( OoO ) . all ( )
 if 41 - 41: IIiIIiIi11I1
 for OOOoOo in IioOOOO000 :
  iIi11ii1 = vwAppConfig . getStrNoneToSpace ( OOOoOo . f_ConsumerNO )
  o0OOOooOO000 = vwAppConfig . getStrNoneToSpace ( OOOoOo . f_ConsumerName )
  I1Ii11iI1 = vwAppConfig . getStrNoneToSpace ( OOOoOo . f_GroupName )
  if not vwAppConfigParam . extfunc5678_timeprofile > 0 :
   I11IIiiI1 = [ "{0}.{1}" . format ( OOOoOo . f_DoorName , OOOoOo . f_FloorName ) , iIi11ii1 , o0OOOooOO000 , OOOoOo . f_CardNO , I1Ii11iI1 ]
  else :
   if OOOoOo . f_ControlSegID == 1 :
    OOoo0ooOO0O00 = "Time Profile#{}-{}" . format ( '1' , 'Free Time' )
   else :
    OOoo0ooOO0O00 = "Time Profile#{}-{}" . format ( vwAppConfig . getStrNoneToSpace ( OOOoOo . f_ControlSegID ) ,
 vwAppConfig . getStrNoneToSpace ( OOOoOo . f_ControlSegName ) )
   I11IIiiI1 = [ "{0}.{1}" . format ( OOOoOo . f_DoorName , OOOoOo . f_FloorName ) , iIi11ii1 , o0OOOooOO000 , OOOoOo . f_CardNO , I1Ii11iI1 , OOoo0ooOO0O00 ]
  iii11i . append ( I11IIiiI1 )
 iiiiiI = {
 "draw" : oOo00O ,
 "recordsTotal" : i1i1iiII ,
 "recordsFiltered" : i1i1iiII ,
 "data" : iii11i
 }
 return json . dumps ( iiiiiI )
# dd678faae9ac167bc83abf78e5cb2f3f0688d3a3
