import json
if 82 - 82: Iii1i
from flask import Blueprint , render_template , request , g , redirect , url_for , flash
from sqlalchemy import or_ , and_
if 87 - 87: Ii % i1i1i1111I . Oo / OooOoo * I1Ii1I1 - I1I
from forms . wgcommform import *
from exts import db
from decorators import login_required
from forms . wgcommform import extern_peripheral_control_setup_form , extern_inter_lock_setup_form
from models . iccard import *
import vwAppConfig
from sqlalchemy import text
if 81 - 81: i1 + ooOOO / oOo0O00 * i1iiIII111 * IiIIii11Ii
__all__ = [
 "bp" ,
 "web_extern_anti_back_list" ,
"web_extern_anti_back_edit" ,
]
bp = Blueprint ( 'wgcomm_extern_anti_back' , __name__ , url_prefix = '/' )
if 84 - 84: ooo000 - Ooo0Ooo + iI1iII1I1I1i . IIiIIiIi11I1
if 98 - 98: I11iiIi11i1I % oOO
@ bp . route ( '/extern_anti_back_list' , methods = [ 'GET' , 'POST' ] )
@ login_required
def web_extern_anti_back_list ( ) :
 i1ii1 = TBController . query . filter_by ( )
 ooo0O0oO00 = i1ii1 . all ( )
 if 55 - 55: I11II1Ii % iIi
 if 76 - 76: I11II1Ii / Iii1i / Ii . i1i1i1111I / Ii
 if 43 - 43: I11iiIi11i1I
 IIi1i111IiII = [ ]
 i1I = {
 "objlist" : ooo0O0oO00 ,

 "interlockdesc" : IIi1i111IiII
 }
 return render_template ( "wgcomm/extern-anti-back-list.html" , ** i1I )
 if 46 - 46: iI1iII1I1I1i - Ii * Oo * Ii
 if 52 - 52: Oo + I1I / oOO / OooOoo - I1Ii1I1 - ooOOO
@ bp . route ( '/extern_anti_back_edit' , methods = [ 'POST' ] )
@ login_required
def web_extern_anti_back_edit ( ) :
 oO0 = "wgcomm/extern-anti-back-edit.html"
 i1iiiiIIIiIi = "wgcomm_extern_anti_back.web_extern_anti_back_list"
 if request . form . get ( 'conID' ) :
  II = request . form . get ( 'conID' )
  OO0000 = AddControllerForm ( )
  OO0000 . f_ControllerNO . data = 1
  oOoo0 = TBController . query . get ( II )
  if oOoo0 :
   OO0000 . f_ControllerID . data = II
   OO0000 . f_ControllerNO . data = oOoo0 . f_ControllerNO
   OO0000 . f_ControllerSN . data = oOoo0 . f_ControllerSN
   OO0000 . f_ForceWarn . data = oOoo0 . f_ForceWarn
   OO0000 . f_InvalidCardWarn . data = oOoo0 . f_InvalidCardWarn
   OO0000 . f_DoorInvalidOpen . data = oOoo0 . f_DoorInvalidOpen
   OO0000 . f_DoorOpenTooLong . data = oOoo0 . f_DoorOpenTooLong
   OO0000 . producttype . data = vwAppConfig . getProductType ( oOoo0 . f_ControllerSN )
   oOoo0 . f_AntiBack_option = oOoo0 . f_AntiBack % 10
   oOoo0 . f_AntiBack_IndoorPersonsMax = ( int ) ( ( oOoo0 . f_AntiBack - oOoo0 . f_AntiBack_option ) / 10 )
   if 95 - 95: i1iiIII111 . Ii . IIiIIiIi11I1 % I11iiIi11i1I % I1Ii1I1
   OO0000 . f_AntiBack . data = oOoo0 . f_AntiBack & 0xff
   OO0000 . f_AntiBack_option . data = oOoo0 . f_AntiBack_option
   OO0000 . f_AntiBack_IndoorPersonsMax . data = oOoo0 . f_AntiBack_IndoorPersonsMax
   if 8 - 8: I1Ii1I1 . iIi . i1 . Oo - I11II1Ii
  return render_template ( oO0 , wgform = OO0000 )
 if request . form . get ( 'f_ControllerID' ) :
  OO0000 = AddControllerForm ( request . form )
  if OO0000 . submitcancel . data :
   return redirect ( url_for ( i1iiiiIIIiIi ) )
  if OO0000 . submitsaveandadd . data :
   II = OO0000 . f_ControllerID . data
   OO0000 = AddControllerForm ( )
   OO0000 . f_ControllerNO . data = 1
   oOoo0 = TBController . query . get ( II )
   if oOoo0 :
    OO0000 . f_ControllerID . data = II
    OO0000 . f_ControllerNO . data = oOoo0 . f_ControllerNO
    OO0000 . f_ControllerSN . data = oOoo0 . f_ControllerSN
    OO0000 . producttype . data = vwAppConfig . getProductType ( oOoo0 . f_ControllerSN )
   return render_template ( oO0 , wgform = OO0000 )
  if OO0000 . validate ( ) :
   iiI1111IIi1 = OO0000 . f_ControllerNO . data
   oOo00O = OO0000 . f_ControllerSN . data
   OoO = OO0000 . f_ControllerID . data
   if 80 - 80: i1i1i1111I . I1I % ooOOO % IiIIii11Ii / i1i1i1111I
   if 32 - 32: I1Ii1I1 + oOO - oOo0O00
   IiiIii11iII1 = OO0000 . f_AntiBack_IndoorPersonsMax . data * 10
   IiiIii11iII1 += OO0000 . f_AntiBack_option . data
   if 27 - 27: I1I + ooOOO * IIiIIiIi11I1 % Ii + Ooo0Ooo . ooOOO
   TBController . query . filter_by ( f_ControllerID = OoO ) . update (
 { "f_AntiBack" : IiiIii11iII1 } , synchronize_session = False )
   if 6 - 6: i1iiIII111
   try :
    db . session . commit ( )
    vwAppConfig . setcontrollerdoorChangeTime ( )
    flash ( "Controller {} modified successfully! Takes effect only after uploading settings in the main console!!!" . format ( oOo00O ) )
    vwAppConfig . vwlog ( '{}--{}' . format ( g . user . f_OperatorName , "Controller {} modified successfully! Takes effect only after uploading settings in the main console!!!" . format (
 oOo00O ) ) )
    return redirect ( url_for ( i1iiiiIIIiIi ) )
   except Exception as I1I1 :
    print ( I1I1 )
    if 91 - 91: Iii1i % i1i1i1111I . OooOoo * oOO
    db . session . rollback ( )
    flash ( "Controller Edit Failed！" )
    return render_template ( oO0 , wgform = OO0000 )
  else :
   for I1iIiiIIiIi in OO0000 . messages :
    flash ( I1iIiiIIiIi )
   return render_template ( oO0 , wgform = OO0000 )
   if 88 - 88: Oo * IiIIii11Ii
   if 100 - 100: iIi - OooOoo * I1Ii1I1 / Ooo0Ooo / Iii1i
   if 23 - 23: Ooo0Ooo + i1 * I1Ii1I1 + Oo * Ii - IIiIIiIi11I1
   if 29 - 29: IiIIii11Ii - oOo0O00
   if 30 - 30: I1I . ooo000
   if 43 - 43: ooOOO . I11iiIi11i1I + ooo000
   if 87 - 87: Iii1i + ooOOO . I11II1Ii / Ii + Oo
   if 77 - 77: i1iiIII111 + iIi - Oo % ooo000
   if 74 - 74: Ii + Ooo0Ooo
   if 1 - 1: I1I % Ooo0Ooo + i1iiIII111 . i1iiIII111 % Oo
   if 93 - 93: oOo0O00 % Ooo0Ooo * i1iiIII111
   if 52 - 52: oOO + I1I / ooo000 - I1Ii1I1 * I11II1Ii % oOo0O00
   if 52 - 52: oOo0O00 . I1I + I11II1Ii - i1iiIII111 % iI1iII1I1I1i
   if 57 - 57: I1I * IIiIIiIi11I1 % I1Ii1I1 * i1i1i1111I
   if 37 - 37: iIi * i1i1i1111I + oOo0O00 / I1I / OooOoo
   if 4 - 4: i1
   if 61 - 61: iI1iII1I1I1i . I11II1Ii - ooo000 / ooo000 - i1
   if 19 - 19: Iii1i * Ooo0Ooo . I1Ii1I1 / I11iiIi11i1I * Ii - oOO
   if 32 - 32: iI1iII1I1I1i
   if 18 - 18: I11iiIi11i1I * iIi % iI1iII1I1I1i + iIi
   if 93 - 93: oOO - I1Ii1I1 - IIiIIiIi11I1 * ooOOO - i1
   if 82 - 82: IIiIIiIi11I1 % i1 * ooOOO
   if 57 - 57: oOo0O00
   if 31 - 31: i1iiIII111 + i1i1i1111I % OooOoo
   if 20 - 20: OooOoo - I1I
   if 9 - 9: i1iiIII111 - iI1iII1I1I1i % Ii - I1I
   if 54 - 54: Iii1i % ooo000 % Iii1i - IiIIii11Ii
   if 39 - 39: oOO - oOO * i1 % IIiIIiIi11I1
   if 29 - 29: IIiIIiIi11I1 - ooo000 . i1iiIII111
   if 86 - 86: I1Ii1I1 - OooOoo - oOO % ooo000 . I11II1Ii % Iii1i
   if 11 - 11: OooOoo - I1Ii1I1 - ooOOO . i1iiIII111 - iI1iII1I1I1i / i1iiIII111
   if 44 - 44: Ooo0Ooo + i1i1i1111I + Iii1i - oOO
   if 7 - 7: i1i1i1111I / Ii * Iii1i
   if 32 - 32: iIi . OooOoo
   if 31 - 31: Oo - I11II1Ii
   if 28 - 28: ooOOO * I1Ii1I1 + iIi % Oo
   if 100 - 100: Oo + I11II1Ii
   if 4 - 4: ooo000 % I1I - i1i1i1111I
   if 76 - 76: i1 * oOo0O00 . iIi * I11II1Ii . IiIIii11Ii . oOO
   if 55 - 55: i1i1i1111I + i1iiIII111 % Ooo0Ooo . Oo - IiIIii11Ii - iI1iII1I1I1i
   if 91 - 91: I1Ii1I1 - I11iiIi11i1I
   if 84 - 84: oOO % iI1iII1I1I1i - Ooo0Ooo
   if 94 - 94: i1iiIII111 + i1i1i1111I / iI1iII1I1I1i + iI1iII1I1I1i / I11II1Ii
   if 79 - 79: i1iiIII111 - IIiIIiIi11I1 . I1Ii1I1 + I1I - ooOOO + i1iiIII111
# dd678faae9ac167bc83abf78e5cb2f3f0688d3a3
