import json
if 82 - 82: Iii1i
from flask import Blueprint , render_template , request
from sqlalchemy import or_ , and_
if 87 - 87: Ii % i1i1i1111I . Oo / OooOoo * I1Ii1I1 - I1I
from vwAppConfigParam import vwAppConfigParam
from exts import db
from decorators import login_required
from models . iccard import *
import vwAppConfig
__all__ = [
 "bp" ,
 "web_swipe_list" ,
 "web_swipe_listpage"
 ]
bp = Blueprint ( 'wgcomm_swipe' , __name__ , url_prefix = '/' )
if 81 - 81: i1 + ooOOO / oOo0O00 * i1iiIII111 * IiIIii11Ii
if 84 - 84: ooo000 - Ooo0Ooo + iI1iII1I1I1i . IIiIIiIi11I1
@ bp . route ( '/swipe_list' , methods = [ 'GET' , 'POST' ] )
@ login_required
def web_swipe_list ( ) :
# # query_obj = TDSwiperecord2022.query
# # 限制 2000
# strSqlBaseInfo = """SELECT a.f_RecID, a.f_CardNO,  b.f_ConsumerNO, b.f_ConsumerName,  t_b_Group.f_GroupName,
#  a.f_ReadDate, t_b_Door.f_DoorName,
#   case when a.f_InOut=1 THEN "In" ELSE "--Out" END as  f_InOut,
#   case when a.f_Character=1 THEN "√" ELSE "-" END as  f_Character,
#   a.f_Desc
#   FROM   t_d_SwipeRecord2022 a
# left outer join t_b_Door on t_b_door.f_DoorID = a.f_DoorID
# LEFT OUTER JOIN t_b_Consumer b ON a.f_ConsumerID = b.f_ConsumerID
# LEFT OUTER JOIN t_b_Group ON t_b_Group.f_GroupID = b.f_GroupID
#   """
#
# strSqlBaseInfo += " ORDER BY f_RecID DESC "
# strSqlBaseInfo += " LIMIT 2000 "
# # objlist = query_obj.all()
# objlist = db.session.execute(text(strSqlBaseInfo)).all()
# context = {
#     "objlist": objlist
# }
 iI111iiIi11i = {
 "objlist" : [ ]
 }
 if vwAppConfigParam . extfunc5678_queryswipe_byusername > 0 and vwAppConfigParam . extfunc5678_queryswipe_byusername_name is not None :
  return render_template ( "wgcomm/swipe-list-noleft.html" , ** iI111iiIi11i )
 return render_template ( "wgcomm/swipe-list.html" , ** iI111iiIi11i )
 if 77 - 77: iIiii1i - ooo0O0oO00 . o00o0OO00O
 if 57 - 57: iiIi1 - i1 % i1 % i1i1i1111I . Ii
@ bp . route ( '/swipe_listpage' , methods = [ 'GET' , 'POST' ] )
@ login_required
def web_swipe_listpage ( ) :
 if vwAppConfigParam . extfunc5678_queryswipe_byusername > 0 and vwAppConfigParam . extfunc5678_queryswipe_byusername_name is not None :
  return iI ( request )
  if 10 - 10: ooOOO / IIiIIiIi11I1 * ooo0O0oO00 / o00o0OO00O / o00o0OO00O
 if request . method == 'GET' :
  oOooo0OOO = int ( request . args . get ( 'draw' ) )
  Oo000ooO0Oooo = int ( request . args . get ( 'length' ) )
  IIiI = int ( request . args . get ( 'start' ) )
  oO0 = request . args . get ( 'search[value]' )
 else :
  oOooo0OOO = int ( request . form . get ( 'draw' ) )
  Oo000ooO0Oooo = int ( request . form . get ( 'length' ) )
  IIiI = int ( request . form . get ( 'start' ) )
  oO0 = request . form . get ( 'search[value]' )
 i1iiiiIIIiIi = [ ]
 if 22 - 22: ooo000 . iI1iII1I1I1i + Ooo0Ooo + ooo0O0oO00
 if 85 - 85: OooOoo - oOo0O00 / Ii / ooo0O0oO00 % i1iiIII111 . Ii
 if 7 - 7: iIiii1i - I1Ii1I1 % iIiii1i . I1Ii1I1 . i1i1i1111I
 if 77 - 77: i1
 if 52 - 52: o00o0OO00O
 if 32 - 32: Ii % i1i1i1111I % o00o0OO00O - iIiii1i % i1iiIII111
 if 34 - 34: i1iiIII111 * i1
 if 34 - 34: oOo0O00 / i1iiIII111 - Iii1i . iI1iII1I1I1i
 if 80 - 80: i1i1i1111I . I1I % ooOOO % IiIIii11Ii / i1i1i1111I
 if 32 - 32: I1Ii1I1 + ooo0O0oO00 - oOo0O00
 if 79 - 79: Iii1i % ooo0O0oO00 * Oo + ooOOO / Oo . ooo0O0oO00
 if 20 - 20: iiIi1 + i1iiIII111 / I1I
 Ooo0OO = db . session . query ( TDSwiperecord2022 . f_RecID , TDSwiperecord2022 . f_CardNO ,
 TBConsumer . f_ConsumerNO , TBConsumer . f_ConsumerName ,
 TBGroup . f_GroupName , TDSwiperecord2022 . f_ReadDate , TBDoor . f_DoorName ,
 TDSwiperecord2022 . f_InOut , TDSwiperecord2022 . f_Character , TDSwiperecord2022 . f_Desc ) . join ( TBDoor ,
 TBDoor . f_DoorID == TDSwiperecord2022 . f_DoorID ,
 isouter = True ) . join ( TBConsumer ,
 TBConsumer . f_ConsumerID == TDSwiperecord2022 . f_ConsumerID ,
 isouter = True ) . join ( TBGroup ,
 TBConsumer . f_GroupID == TBGroup . f_GroupID ,
 isouter = True )
 if 6 - 6: i1iiIII111
 if oO0 :
  oO0 = oO0 . strip ( )
  I1I1 = oO0 . split ( ' ' )
  if len ( I1I1 ) >= 1 :
   oo0 = and_ ( 1 > 0 )
   for i11iIii in I1I1 :
    OO = or_ ( TBConsumer . f_ConsumerNO . like ( "%%%s%%" % i11iIii ) ,
 TBConsumer . f_ConsumerName . like ( "%%%s%%" % i11iIii ) ,
 TBGroup . f_GroupName . like ( "%%%s%%" % i11iIii ) ,
 TBDoor . f_DoorName . like ( "%%%s%%" % i11iIii ) ,
 TDSwiperecord2022 . f_ReadDate . like ( "%%%s%%" % i11iIii ) ,
    TDSwiperecord2022 . f_Desc . like ( "%%%s%%" % i11iIii ) , )
    if vwAppConfig . parseInt ( i11iIii ) > 0 :
     iiI1I11iiiiI = vwAppConfig . parseInt ( i11iIii )
     OO = or_ ( TDSwiperecord2022 . f_CardNO == iiI1I11iiiiI , OO )
    oo0 = and_ ( oo0 , OO )
   OO = oo0
   Ooo0OO = Ooo0OO . filter ( OO )
   iII11iIi1iIiI = Ooo0OO . count ( )
  else :
   iII11iIi1iIiI = TDSwiperecord2022 . query . count ( )
 else :
  iII11iIi1iIiI = TDSwiperecord2022 . query . count ( )
 iIIiii1iI = Ooo0OO . order_by ( TDSwiperecord2022 . f_RecID . desc ( ) ) . offset ( IIiI ) . limit ( Oo000ooO0Oooo ) . all ( )
 if 43 - 43: ooOOO . iIiii1i + ooo000
 if 87 - 87: Iii1i + ooOOO . o00o0OO00O / Ii + Oo
 if 77 - 77: i1iiIII111 + iiIi1 - Oo % ooo000
 if 74 - 74: Ii + Ooo0Ooo
 if 1 - 1: I1I % Ooo0Ooo + i1iiIII111 . i1iiIII111 % Oo
 for OOOO0O0ooO0O in iIIiii1iI :
  I1iIIiI1 = OOOO0O0ooO0O . f_InOut
  if I1iIIiI1 == 1 :
   I1iIIiI1 = 'In'
  else :
   I1iIIiI1 = '--Out'
   if 78 - 78: iI1iII1I1I1i + iI1iII1I1I1i - I1I * IIiIIiIi11I1 % I1Ii1I1 * i1i1i1111I
  Oo0 = OOOO0O0ooO0O . f_Character
  if Oo0 == 1 :
   Oo0 = '√'
  else :
   Oo0 = '-'
  ooooo = vwAppConfig . getStrNoneToSpace ( OOOO0O0ooO0O . f_ConsumerNO )
  oO00o00OO = vwAppConfig . getStrNoneToSpace ( OOOO0O0ooO0O . f_ConsumerName )
  o00o = vwAppConfig . getStrNoneToSpace ( OOOO0O0ooO0O . f_GroupName )
  if 97 - 97: Ooo0Ooo
  if 29 - 29: iIiii1i * iI1iII1I1I1i
  if 7 - 7: Oo / OooOoo - iIiii1i - iiIi1 % i1iiIII111
  OOo0OOOo0O = [ OOOO0O0ooO0O . f_RecID , OOOO0O0ooO0O . f_CardNO , ooooo , oO00o00OO ,
 o00o , vwAppConfig . getStrOfDatetime ( OOOO0O0ooO0O . f_ReadDate ) ,
 OOOO0O0ooO0O . f_DoorName , I1iIIiI1 , Oo0 , OOOO0O0ooO0O . f_Desc ]
  i1iiiiIIIiIi . append ( OOo0OOOo0O )
 oOo0Oo = {
 "draw" : oOooo0OOO ,
 "recordsTotal" : iII11iIi1iIiI ,
 "recordsFiltered" : iII11iIi1iIiI ,
 "data" : i1iiiiIIIiIi
 }
 return json . dumps ( oOo0Oo )
 if 35 - 35: ooo0O0oO00 + OooOoo . OooOoo
@ login_required
def iI ( request ) :
 if request . method == 'GET' :
  oOooo0OOO = int ( request . args . get ( 'draw' ) )
  Oo000ooO0Oooo = int ( request . args . get ( 'length' ) )
  IIiI = int ( request . args . get ( 'start' ) )
  oO0 = request . args . get ( 'search[value]' )
 else :
  oOooo0OOO = int ( request . form . get ( 'draw' ) )
  Oo000ooO0Oooo = int ( request . form . get ( 'length' ) )
  IIiI = int ( request . form . get ( 'start' ) )
  oO0 = request . form . get ( 'search[value]' )
 i1iiiiIIIiIi = [ ]
 if 30 - 30: OooOoo * I1I * Ooo0Ooo . Ooo0Ooo
 Ooo0OO = db . session . query ( TDSwiperecord2022 . f_RecID , TDSwiperecord2022 . f_CardNO ,
 TBConsumer . f_ConsumerNO , TBConsumer . f_ConsumerName ,
 TBGroup . f_GroupName , TDSwiperecord2022 . f_ReadDate , TBDoor . f_DoorName ,
 TDSwiperecord2022 . f_InOut , TDSwiperecord2022 . f_Character , TDSwiperecord2022 . f_Desc ) . join ( TBDoor ,
 TBDoor . f_DoorID == TDSwiperecord2022 . f_DoorID ,
 isouter = True ) . join ( TBConsumer ,
 TBConsumer . f_ConsumerID == TDSwiperecord2022 . f_ConsumerID ,
 isouter = True ) . join ( TBGroup ,
 TBConsumer . f_GroupID == TBGroup . f_GroupID ,
 isouter = True )
 if 43 - 43: Ooo0Ooo - I1I . ooo000 - Iii1i % o00o0OO00O
 if oO0 :
  oO0 = oO0 . strip ( )
  I1I1 = oO0 . split ( ' ' )
  if len ( I1I1 ) >= 1 :
   oo0 = and_ ( TBConsumer . f_ConsumerName . __eq__ ( vwAppConfigParam . extfunc5678_queryswipe_byusername_name ) )
   for i11iIii in I1I1 :
    OO = or_ ( TBConsumer . f_ConsumerNO . like ( "%%%s%%" % i11iIii ) ,
 TBConsumer . f_ConsumerName . like ( "%%%s%%" % i11iIii ) ,
 TBGroup . f_GroupName . like ( "%%%s%%" % i11iIii ) ,
 TBDoor . f_DoorName . like ( "%%%s%%" % i11iIii ) ,
 TDSwiperecord2022 . f_ReadDate . like ( "%%%s%%" % i11iIii ) ,
    TDSwiperecord2022 . f_Desc . like ( "%%%s%%" % i11iIii ) , )
    if vwAppConfig . parseInt ( i11iIii ) > 0 :
     iiI1I11iiiiI = vwAppConfig . parseInt ( i11iIii )
     OO = or_ ( TDSwiperecord2022 . f_CardNO == iiI1I11iiiiI , OO )
    oo0 = and_ ( oo0 , OO )
   OO = oo0
   Ooo0OO = Ooo0OO . filter ( OO )
   iII11iIi1iIiI = Ooo0OO . count ( )
  else :
   oo0 = and_ ( TBConsumer . f_ConsumerName . __eq__ ( vwAppConfigParam . extfunc5678_queryswipe_byusername_name ) )
   OO = oo0
   Ooo0OO = Ooo0OO . filter ( OO )
   iII11iIi1iIiI = Ooo0OO . count ( )
   if 49 - 49: IiIIii11Ii . ooo000 + ooo0O0oO00 - ooo0O0oO00
 else :
  if 78 - 78: i1 - ooOOO
  oo0 = and_ ( TBConsumer . f_ConsumerName . __eq__ ( vwAppConfigParam . extfunc5678_queryswipe_byusername_name ) )
  OO = oo0
  Ooo0OO = Ooo0OO . filter ( OO )
  iII11iIi1iIiI = Ooo0OO . count ( )
 iIIiii1iI = Ooo0OO . order_by ( TDSwiperecord2022 . f_RecID . desc ( ) ) . offset ( IIiI ) . limit ( Oo000ooO0Oooo ) . all ( )
 if 56 - 56: ooo000 . ooo000 + I1Ii1I1 * iI1iII1I1I1i
 if 17 - 17: Iii1i % o00o0OO00O - Iii1i % Ooo0Ooo . OooOoo
 if 60 - 60: ooOOO . ooo000
 if 42 - 42: i1iiIII111 - i1iiIII111
 if 98 - 98: Ooo0Ooo + i1i1i1111I + Iii1i - ooo0O0oO00
 for OOOO0O0ooO0O in iIIiii1iI :
  I1iIIiI1 = OOOO0O0ooO0O . f_InOut
  if I1iIIiI1 == 1 :
   I1iIIiI1 = 'In'
  else :
   I1iIIiI1 = '--Out'
   if 7 - 7: i1i1i1111I / Ii * Iii1i
  Oo0 = OOOO0O0ooO0O . f_Character
  if Oo0 == 1 :
   Oo0 = '√'
  else :
   Oo0 = '-'
  ooooo = vwAppConfig . getStrNoneToSpace ( OOOO0O0ooO0O . f_ConsumerNO )
  oO00o00OO = vwAppConfig . getStrNoneToSpace ( OOOO0O0ooO0O . f_ConsumerName )
  o00o = vwAppConfig . getStrNoneToSpace ( OOOO0O0ooO0O . f_GroupName )
  if 32 - 32: iiIi1 . OooOoo
  if 31 - 31: Oo - o00o0OO00O
  if 28 - 28: ooOOO * I1Ii1I1 + iiIi1 % Oo
  if 100 - 100: Oo + o00o0OO00O
  if 4 - 4: ooo000 % I1I - i1i1i1111I
  if 76 - 76: i1 * oOo0O00 . iiIi1 * o00o0OO00O . IiIIii11Ii . ooo0O0oO00
  if 55 - 55: i1i1i1111I + i1iiIII111 % Ooo0Ooo . Oo - IiIIii11Ii - iI1iII1I1I1i
  OOo0OOOo0O = [ OOOO0O0ooO0O . f_RecID , vwAppConfig . getStrOfDatetime ( OOOO0O0ooO0O . f_ReadDate ) , OOOO0O0ooO0O . f_Desc , OOOO0O0ooO0O . f_DoorName , OOOO0O0ooO0O . f_CardNO , ooooo , oO00o00OO ,
 o00o ,
 I1iIIiI1 , Oo0 ]
  i1iiiiIIIiIi . append ( OOo0OOOo0O )
 oOo0Oo = {
 "draw" : oOooo0OOO ,
 "recordsTotal" : iII11iIi1iIiI ,
 "recordsFiltered" : iII11iIi1iIiI ,
 "data" : i1iiiiIIIiIi
 }
 return json . dumps ( oOo0Oo )
# dd678faae9ac167bc83abf78e5cb2f3f0688d3a3
