示例#1
0
def add_user():
    u = User()
    user = json.loads('{"UserName": "******"}')
    new_user = u.add(user)
    data = utils.obj_to_dict(new_user)
    resp = jsonify(data)
    return resp, 200
    def login(self, sUserCode, sPassword):
        '''查询数据'''
        objUser = User().query.filter(User.UserCode == sUserCode).first()
        # print User().Password.property.doc
        if not objUser:
            return FuncResult(msg='用户名错误!')

        # dictUser = obj_to_dict(objUser)
        # del dictUser['UserDataRoleList'], \
        #     dictUser['Password'], dictUser['CreateTime']
        # dictUser['StateName'] = dict_to_name(dictUser['State'], 'user_state')
        #
        # # 保存用户信息到session
        # web.ctx.session.user = dictUser

        sUserPassword = objUser.Password
        # sUserPassword = aes_decrypt(objUser.Password)
        if sUserPassword == sPassword:
            dictUser = obj_to_dict(objUser)
            del dictUser['UserDataRoleList'], \
                dictUser['Password'], dictUser['CreateTime']
            dictUser['StateName'] = dict_to_name(dictUser['State'],
                                                 'user_state')

            # 保存用户信息到session
            web.ctx.session.user = dictUser
            web.ctx.session.login = True
            return FuncResult(success=True, msg='登录成功!', data=dictUser)
        else:
            return FuncResult(msg='密码错误!')
示例#3
0
def add_channel():
    c = Channel()
    name = request.form['channelName']
    parent = request.form['parent']
    new_channel = c.add_channel(name, parent)
    data = utils.obj_to_dict(new_channel)
    resp = jsonify(data)
    return resp, 200
示例#4
0
    def get_product_diff(self, old_cond, new_cond):
        """ This method should generate diff info between old product condition
            and new product condition """

        old_cond_dict = obj_to_dict(old_cond)
        new_cond_dict = obj_to_dict(new_cond)

        diff = ''

        for key in old_cond_dict.keys():
            old_val = old_cond_dict.get(key)
            new_val = new_cond_dict.get(key)

            if old_val != new_val:
                get_info_method = 'get_%s_change_info' % ( key )

                if hasattr(new_cond, get_info_method ):
                    diff += getattr(new_cond, get_info_method )(
                                                        old_val, new_val)

        return diff
    def get_checkin_log_list(self, nHotelGuestID):
        lsCheckin = RelationCheckIn().query.filter(
            RelationCheckIn.HotelGuestID == nHotelGuestID).all()

        lsLog = []
        for objCheckIn in lsCheckin:
            objLog = CheckIn().query.filter(
                CheckIn.CheckInID == objCheckIn.CheckInID,
                CheckIn.IsNew == 1).first()
            if (objLog):
                dictData = obj_to_dict(objLog)
                del dictData['CheckInID'], dictData['HotelID'], dictData['FolioCode'], \
                    dictData['FolioState'], dictData['IsNew'], dictData['TableID'], \
                    dictData['ArrivalTime'], dictData['DepartTime']

                lsLog.append(obj_to_dict(objLog))

        if not len(lsLog):
            return FuncResult(msg='无查询结果!')

        return FuncResult(success=True, data=lsLog)
    def get_dict(self, nCodeType):
        lsData = []
        dictData = {}
        if nCodeType == '0':
            lsDicType = Dictionary().query.group_by(Dictionary.TypeName).all()

            for objDictType in lsDicType:
                lsDict = []
                # lsDictionary = web.ctx.cur_dbsession. \
                #     query(Dictionary.CodeID, Dictionary.CodeName,
                #           Dictionary.CodeNo, Dictionary.Flag). \
                #     filter(Dictionary.TypeName == objDictType.TypeName,
                #            Dictionary.Flag != 0).\
                #     all()

                lsDictionary = Dictionary().query. \
                    filter(Dictionary.TypeName == objDictType.TypeName,
                           Dictionary.Flag != 0). \
                    all()

                for objDict in lsDictionary:
                    lsDict.append(obj_to_dict(objDict))
                dictData[objDictType.TypeName] = lsDict
            return FuncResult(success=True, data=dictData)

        else:
            lsDict = Dictionary().query.\
                filter(Dictionary.CodeType == nCodeType).\
                all()

            for objDict in lsDict:
                dictCode = {
                    'CodeID': objDict.CodeID,
                    'CodeNo': objDict.CodeNo,
                    'CodeName': objDict.CodeName,
                    'Flag': objDict.Flag
                }
                lsData.append(obj_to_dict(objDict))

            return FuncResult(success=True, data=lsData)
示例#7
0
    def get_checkin_log(self, nCheckInID):
        objLog = CheckIn().query.filter(CheckIn.CheckInID == nCheckInID,
                                        CheckIn.IsNew == 1).first()

        if not objLog:
            return FuncResult(msg='无查询结果!')

        dictData = obj_to_dict(objLog)
        del dictData['CheckInID'], dictData['HotelID'], dictData['FolioCode'],\
            dictData['FolioState'], dictData['IsNew'], dictData['TableID'],\
            dictData['ArrivalTime'], dictData['DepartTime']

        return FuncResult(success=True, data=dictData)
示例#8
0
def check_empty_record(clsname, attr):
    """检查并删除一天内意外生成的空数据。用于定时云函数。"""
    Cls = leancloud.Object.extend(clsname)
    objs = Cls.query\
        .greater_than_or_equal_to('createdAt', datetime.now() - timedelta(days=1))\
        .find()

    # 重要:一定要确保没有 pid 的对象!
    empty_objs = [obj for obj in objs if not obj.get(attr)]
    obj_dicts = [obj_to_dict(obj) for obj in empty_objs]
    obj_cnt = len(obj_dicts)
    obj_json = json.dumps(obj_dicts)

    if obj_cnt == 0:
        print('Checked {}. No empty record found.'.format(clsname))

    # 少于5行,直接删除。
    elif obj_cnt > 0 and obj_cnt < 5:
        leancloud.Object.destroy_all(empty_objs)

        title = 'LC-APP <huayejian>: DELETED {0} EMPTY RECORD(s) of {1}.'.format(
            obj_cnt, clsname)
        text = ''' There is {0} empty record(s) of {1}.
Records were deleted, as follow:
{2}'''.format(obj_cnt, clsname, obj_json)

        email = Email(title=title, text=text)
        email.send()
        print(text)

    # 大于等于5行, 手动删除。
    else:
        title = 'IMPORTANT! LC-APP <huayejian>: FOUND {0} EMPTY RECORDS of {1}!'.format(
            obj_cnt, clsname)
        text = '''I have found {0} empty record in {1} table of the database.
Please check up the database immediately!
Delete the empty lines manually as soon as possible.
Records found as follow:
{2}'''.format(obj_cnt, clsname, obj_json)

        email = Email(title=title, text=text)
        email.send()
        print(text)

    return obj_json
示例#9
0
    def get_foreigner_guest_detail(self, nCheckInID):
        objForeigner = Foreigner().query.\
            filter(Foreigner.GuestDocID == nCheckInID).\
            first()

        if not objForeigner:
            return FuncResult(msg='无查询结果!')

        dictData = obj_to_dict(objForeigner)
        del dictData['GuestDocID']
        del dictData['CreateTime']

        # 签证类型
        dictData['VisaTypeName'] = dict_to_name(dictData['VisaType'],
                                                'visa_type')
        # 国籍
        dictData['NationalityName'] = dict_to_name(dictData['Nationality'],
                                                   'gres_country')

        return FuncResult(success=True, msg='', data=dictData)
示例#10
0
 def __init__(self, fields=None):
     self.fields = fields or self.fields
     self.to_dict = obj_to_dict(self.fields)
示例#11
0
def get_all_channels():
    c = Channel()
    cl = utils.obj_to_dict(c.get_all())
    data = [ v for k, v in cl.iteritems()]
    resp = jsonify(channels=data)
    return resp, 200
示例#12
0
def get_all_acls(channel_id):
    a = ACL()
    data = utils.obj_to_dict(a.get_all(channel_id))
    resp = jsonify(acls=data)
    return resp, 200
示例#13
0
    def search_foreign_checkin(self, objCondition, objPage):
        lsParams = []
        dictParamsValue = {}

        if objCondition.has_key('nGuestState') and objCondition['nGuestState']:
            nGuestState = objCondition['nGuestState']
            lsParams.append('h_relation_checkin.GuestState = :nGuestState')
            dictParamsValue['nGuestState'] = nGuestState

        # 入住出示证件信息
        if objCondition.has_key(
                'sGuestDocNameLike') and objCondition['sGuestDocNameLike']:
            sGuestDocName = '%' + objCondition['sGuestDocNameLike'] + '%'
            lsParams.append('g_guest_checkin.HotelDocName Like :sGuestDocName')
            dictParamsValue['sGuestDocName'] = sGuestDocName

        if objCondition.has_key('sDocNoLikeL') and objCondition['sDocNoLikeL']:
            sDocNo = objCondition['sDocNoLikeL'] + '%'
            lsParams.append('g_guest_checkin.HotelDocNo Like :sDocNo ')
            dictParamsValue['sDocNo'] = sDocNo

        if objCondition.has_key('nDocType') and objCondition['nDocType']:
            nDocType = objCondition['sDocNoLikeL'] + '%'
            lsParams.append('g_guest_checkin.HotelDocType Like :nDocType ')
            dictParamsValue['nDocType'] = nDocType

        if objCondition.has_key('nSex') and objCondition['nSex']:
            nSex = objCondition['nSex']
            lsParams.append('g_guest_checkin.HotelSex = :nSex')
            dictParamsValue['nSex'] = nSex

        if objCondition.has_key(
                'sBornDateStart') and objCondition['sBornDateStart']:
            dtBornDateStart = to_datetime(objCondition['sBornDateStart'])
            lsParams.append('g_guest_checkin.HotelBornDate >= :sBornDateStart')
            dictParamsValue['sBornDateStart'] = dtBornDateStart

        if objCondition.has_key(
                'sBornDateEnd') and objCondition['sBornDateEnd']:
            dtBornDateEnd = to_datetime(objCondition['sBornDateEnd'])
            lsParams.append('g_guest_checkin.HotelBornDate <= :sBornDateEnd')
            dictParamsValue['sBornDateEnd'] = dtBornDateEnd

        if objCondition.has_key(
                'nMatchResult') and objCondition['nMatchResult']:
            nMatchResult = objCondition['nMatchResult']
            lsParams.append('g_guest_checkin.MatchResult = :nMatchResult')
            dictParamsValue['nMatchResult'] = nMatchResult

        # 入住酒店信息
        if objCondition.has_key(
                'sHotelNameLike') and objCondition['sHotelNameLike']:
            sHotelName = '%' + objCondition['sHotelNameLike'] + '%'
            lsParams.append('h_hotel.HotelName Like :sHotelName')
            dictParamsValue['sHotelName'] = sHotelName

        if objCondition.has_key('nProvinceID') and objCondition['nProvinceID']:
            nProvinceID = objCondition['nProvinceID']
            lsParams.append('h_hotel.ProvinceID = :nProvinceID')
            dictParamsValue['nProvinceID'] = nProvinceID

        if objCondition.has_key('nCityID') and objCondition['nCityID']:
            nCityID = objCondition['nCityID']
            lsParams.append('h_hotel.CityID = :nCityID')
            dictParamsValue['nCityID'] = nCityID

        if objCondition.has_key('nDistrictID') and objCondition['nDistrictID']:
            nDistrictID = objCondition['nDistrictID']
            lsParams.append('h_hotel.DistrictID = :nDistrictID')
            dictParamsValue['nDistrictID'] = nDistrictID

        if objCondition.has_key('sRoomNo') and objCondition['sRoomNo']:
            sRoomNo = objCondition['sRoomNo']
            lsParams.append('h_hotel.RoomNo = :sRoomNo')
            dictParamsValue['sRoomNo'] = sRoomNo

        if objCondition.has_key('sCheckInDateTimeStart'
                                ) and objCondition['sCheckInDateTimeStart']:
            dtCheckInDateTimeStart = to_datetime(
                objCondition['sCheckInDateTimeStart'])
            lsParams.append('h_checkin.CheckInTime >= :dtCheckInDateTimeStart')
            dictParamsValue['dtCheckInDateTimeStart'] = dtCheckInDateTimeStart

        if objCondition.has_key(
                'sCheckInDateTimeEnd') and objCondition['sCheckInDateTimeEnd']:
            dtCheckInDateTimeEnd = to_datetime(
                objCondition['sCheckInDateTimeEnd'])
            lsParams.append('h_checkin.CheckInTime <= :dtCheckInDateTimeEnd')
            dictParamsValue['dtCheckInDateTimeEnd'] = dtCheckInDateTimeEnd

        # 外籍旅客信息
        if objCondition.has_key(
                'sNationality') and objCondition['sNationality']:
            sNationality = objCondition['Nationality']
            lsParams.append('g_foreigner.Nationality = :sNationality')
            dictParamsValue['sNationality'] = sNationality

        if objCondition.has_key(
                'sDepartureTimeStart') and objCondition['sDepartureTimeStart']:
            dtDepartureTimeStart = to_datetime(
                objCondition['sDepartureTimeStart'])
            lsParams.append(
                'g_foreigner.DepartureTime > :dtDepartureTimeStart')
            dictParamsValue['dtDepartureTimeStart'] = dtDepartureTimeStart

        if objCondition.has_key(
                'sDepartureTimeEnd') and objCondition['sDepartureTimeEnd']:
            dtDepartureTimeEnd = to_datetime(objCondition['sDepartureTimeEnd'])
            lsParams.append('g_foreigner.DepartureTime <= :dtDepartureTimeEnd')
            dictParamsValue['dtDepartureTimeEnd'] = dtDepartureTimeEnd

        if objCondition.has_key(
                'sEntryTimeStart') and objCondition['sEntryTimeStart']:
            dtEntryTimeStart = to_datetime(objCondition['sEntryTimeStart'])
            lsParams.append('g_foreigner.EntryTime >= :dtEntryTimeStart')
            dictParamsValue['dtEntryTimeStart'] = dtEntryTimeStart

        if objCondition.has_key(
                'sEntryTimeEnd') and objCondition['sEntryTimeEnd']:
            dtEntryTimeEnd = to_datetime(objCondition['sDepartureTimeEnd'])
            lsParams.append('g_foreigner.EntryTime <= :dtEntryTimeEnd')
            dictParamsValue['dtEntryTimeEnd'] = dtEntryTimeEnd

        if objCondition.has_key('sEntryPlace') and objCondition['sEntryPlace']:
            sEntryPlace = objCondition['sEntryPlace']
            lsParams.append('g_foreigner.EntryPlace = :sEntryPlace')
            dictParamsValue['sEntryPlace'] = sEntryPlace

        if objCondition.has_key(
                'sDeparturePlace') and objCondition['sDeparturePlace']:
            sDeparturePlace = objCondition['sDeparturePlace']
            lsParams.append('g_foreigner.DeparturePlace = :sDeparturePlace')
            dictParamsValue['sDeparturePlace'] = sDeparturePlace

        if objCondition.has_key('sVisaType') and objCondition['sVisaType']:
            sVisaType = objCondition['sVisaType']
            lsParams.append('g_foreigner.VisaType = :sVisaType')
            dictParamsValue['sVisaType'] = sVisaType

        if objCondition.has_key(
                'sVisaDeadline') and objCondition['sVisaDeadline']:
            dtVisaDeadline = to_datetime(objCondition['sVisaDeadline'])
            lsParams.append('g_foreigner.VisaDeadline = :dtVisaDeadline')
            dictParamsValue['dtVisaDeadline'] = dtVisaDeadline

        objSql = web.ctx.cur_dbsession.query(CheckIn, RelationCheckIn, GuestCheckIn, Foreigner, Hotel). \
            filter(CheckIn.HotelID == Hotel.HotelID,
                        RelationCheckIn.CheckInID == CheckIn.CheckInID,
                        RelationCheckIn.HotelGuestID == GuestCheckIn.HotelGuestID,
                        RelationCheckIn.GuestDocID == Foreigner.GuestDocID)

        objResult = get_data(objSql, lsParams, dictParamsValue, objPage)

        nPageCount = 0
        nRowCount = 0
        if objResult:
            if objResult.success:
                lsQueryData = objResult.data['DataList']
                nPageCount = objResult.data['PageCount']
                nRowCount = objResult.data['RowCount']

            lsData = []
            for objData in lsQueryData:
                dictCheckIn = obj_to_dict(objData[0])
                dictRelationCheckIn = obj_to_dict(objData[1])
                dictGuestCheckIn = obj_to_dict(objData[2])
                dictForeigner = obj_to_dict(objData[3])
                dictHotel = obj_to_dict(objData[4])

                del dictCheckIn['IsNew'], dictCheckIn['TableID'], \
                    dictForeigner['GuestDocID'], dictForeigner['CreateTime'], \
                    dictForeigner['TableID'], dictGuestCheckIn['TableID']
                dictGuestCheckIn['CheckInTime'] = dictRelationCheckIn[
                    'CheckInTime']
                dictGuestCheckIn['CheckOutTime'] = dictRelationCheckIn[
                    'CheckOutTime']
                dictGuestCheckIn['GuestState'] = dictRelationCheckIn[
                    'GuestState']
                dictCheckIn['HotelName'] = dictHotel['HotelName']
                dictCheckIn['HotelAddr'] = dictHotel['HotelAddr']

                # 返回字典类型字段对应名称
                # 客人状态名
                dictGuestCheckIn['GuestStateName'] = dict_to_name(
                    dictRelationCheckIn['GuestState'], 'checkin_state')
                # 性别
                dictGuestCheckIn['HotelSexName'] = dict_to_name(
                    dictGuestCheckIn['HotelSex'], 'sex')
                # 民族
                dictGuestCheckIn['HotelNationName'] = dict_to_name(
                    dictGuestCheckIn['HotelNation'], 'gres_nation')
                # 证件类型
                dictGuestCheckIn['HotelDocTypeName'] = dict_to_name(
                    dictGuestCheckIn['HotelDocType'], 'doc_type')

                # 签证类型
                dictForeigner['VisaTypeName'] = dict_to_name(
                    dictForeigner['VisaType'], 'visa_type')
                # 国籍
                dictForeigner['NationalityName'] = dict_to_name(
                    dictForeigner['Nationality'], 'gres_country')

                dictData = {
                    'GuestCheckIn': dictGuestCheckIn,
                    'Foreigner': dictForeigner,
                    'CheckinInfo': dictCheckIn
                }
                lsData.append(dictData)

            return FuncResult(success=True,
                              data={
                                  'PageNo': objPage['nPageNo'],
                                  'PageSize': objPage['nPageSize'],
                                  'PageCount': nPageCount,
                                  'RowCount': nRowCount,
                                  'DataSet': lsData
                              })
        return FuncResult(data='', msg='无查询结果!')
示例#14
0
def get_all_groups(channel_id):
    g = Group()
    data = utils.obj_to_dict(g.get_all(channel_id))
    resp = jsonify(groups=data)
    return resp, 200
示例#15
0
 def get_City(self):
     lsDataSet = District().query.filter(District.IsFlag != 0).all()
     lsData = []
     for objData in lsDataSet:
         lsData.append(web.storage(**obj_to_dict(objData.copy(bind=False))))
     return FuncResult(success=True, msg='操作成功!', data=lsData)
示例#16
0
 def to_dict(self):
     return utils.obj_to_dict(self)
示例#17
0
def get_all_users():
    u = User()
    ul = utils.obj_to_dict(u.get_all())
    data = [{'UserId': k, 'UserName': v} for k, v in ul.iteritems()]
    resp = jsonify(users=data)
    return resp, 200
    def get_checkin_detail(self, nCheckInID):
        objCheckIn = CheckIn().query.filter(
            CheckIn.CheckInID == nCheckInID).first()
        dictCheckIn = obj_to_dict(objCheckIn)
        del dictCheckIn['TableID'], dictCheckIn['IsNew']

        objHotel = Hotel().query.filter(
            Hotel.HotelID == dictCheckIn['HotelID']).first()
        # dictHotel = obj_to_dict(objHotel)
        dictCheckIn['HotelName'] = objHotel.HotelName

        lsGuestCheckIn = web.ctx.cur_dbsession.query(GuestCheckIn, RelationCheckIn, GuestDoc).\
            filter(RelationCheckIn.CheckInID == nCheckInID,
                   RelationCheckIn.HotelGuestID == GuestCheckIn.HotelGuestID,
                   RelationCheckIn.GuestDocID == GuestDoc.GuestDocID).all()

        if not objCheckIn and len(lsGuestCheckIn) <= 0:
            return FuncResult(success=True, msg='')

        lsData = []
        for tupData in lsGuestCheckIn:
            dictGuestCheckin = obj_to_dict(tupData[0])
            dictRelationCheckIn = obj_to_dict(tupData[1])
            dictGuestDoc = obj_to_dict(tupData[2])

            del dictGuestCheckin['TableID'], dictGuestDoc['TableID']
            dictGuestCheckin['CheckInTime'] = dictRelationCheckIn[
                'CheckInTime']
            dictGuestCheckin['CheckOutTime'] = dictRelationCheckIn[
                'CheckOutTime']
            dictGuestCheckin['GuestState'] = dictRelationCheckIn['GuestState']

            # 返回字典类型字段对应名称
            # 客人状态名
            dictGuestCheckin['GuestStateName'] = dict_to_name(
                dictRelationCheckIn['GuestState'], 'checkin_state')
            # 性别
            dictGuestCheckin['HotelSexName'] = dict_to_name(
                dictGuestCheckin['HotelSex'], 'sex')
            # 民族
            dictGuestCheckin['HotelNationName'] = dict_to_name(
                dictGuestCheckin['HotelNation'], 'gres_nation')
            # 证件类型
            dictGuestCheckin['HotelDocTypeName'] = dict_to_name(
                dictGuestCheckin['HotelDocType'], 'doc_type')

            # 证件类型
            dictGuestDoc['DocTypeName'] = dict_to_name(dictGuestDoc['DocType'],
                                                       'doc_type')
            # 性别
            dictGuestDoc['SexName'] = dict_to_name(dictGuestDoc['Sex'], 'sex')
            # 民族
            dictGuestDoc['NationName'] = dict_to_name(dictGuestDoc['Nation'],
                                                      'gres_nation')
            # 客人状态
            dictGuestDoc['StateName'] = dict_to_name(dictGuestDoc['State'],
                                                     'checkin_state')

            dictData = {
                'GuestCheckIn': dictGuestCheckin,
                'GuestDoc': dictGuestDoc
            }
            lsData.append(dictData)

        return FuncResult(success=True,
                          msg='',
                          data={
                              'CheckinInfo': dictCheckIn,
                              'GuestInfo': lsData
                          })
示例#19
0
def get_user(id):
    u = User()
    data = utils.obj_to_dict(u.get(id))
    resp = jsonify(data)
    return resp, 200
示例#20
0
def test():
    prod_objs = Prod.query.find()
    prods = [obj_to_dict(obj) for obj in prod_objs]
    return json.dumps(prods)
    def search_all_checkin(self, objCondition, objPage):
        lsParams = []
        dictParamsValue = {}
        try:
            if objCondition.has_key(
                    'sHotelNameLike') and objCondition['sHotelNameLike']:
                sHotelName = '%' + objCondition['sHotelNameLike'] + '%'
                lsParams.append('h_hotel.HotelName Like :sHotelName')
                dictParamsValue['sHotelName'] = sHotelName

            if objCondition.has_key(
                    'nProvinceID') and objCondition['nProvinceID']:
                nProvinceID = objCondition['nProvinceID']
                lsParams.append('h_hotel.ProvinceID = :nProvinceID')
                dictParamsValue['nProvinceID'] = nProvinceID

            if objCondition.has_key('nCityID') and objCondition['nCityID']:
                nCityID = objCondition['nCityID']
                lsParams.append('h_hotel.CityID = :nCityID')
                dictParamsValue['nCityID'] = nCityID

            if objCondition.has_key(
                    'nDistrictID') and objCondition['nDistrictID']:
                nDistrictID = objCondition['nDistrictID']
                lsParams.append('h_hotel.DistrictID = :nDistrictID')
                dictParamsValue['nDistrictID'] = nDistrictID

            if objCondition.has_key('sRoomNo') and objCondition['sRoomNo']:
                sRoomNo = objCondition['sRoomNo']
                lsParams.append('h_hotel.RoomNo = :sRoomNo')
                dictParamsValue['sRoomNo'] = sRoomNo

            dictCheckInParams = {}
            if objCondition.has_key('sCheckInDateTimeStart') and objCondition[
                    'sCheckInDateTimeStart']:
                dtCheckinDatetimeStart = to_datetime(
                    objCondition['sCheckInDateTimeStart'])
                lsParams.append(
                    'h_checkin.CheckInTime >= :dtCheckinDatetimeStart')
                dictParamsValue[
                    'dtCheckinDatetimeStart'] = dtCheckinDatetimeStart
                dictCheckInParams['CheckInTime'] = dtCheckinDatetimeStart

            if objCondition.has_key('sCheckInDateTimeEnd'
                                    ) and objCondition['sCheckInDateTimeEnd']:
                dtCheckinDatetimeEnd = to_datetime(
                    objCondition['sCheckInDateTimeEnd'])
                lsParams.append(
                    'h_checkin.CheckInTime <= :dtCheckinDatetimeEnd')
                dictParamsValue['dtCheckinDatetimeEnd'] = dtCheckinDatetimeEnd

            if objCondition.has_key(
                    'sNationality') and objCondition['sNationality']:
                sNationality = objCondition['sNationality']
                lsParams.append('g_foreigner.Nationality = :sNationality')
                dictParamsValue['sNationality'] = sNationality
                dictCheckInParams['Nationality'] = sNationality

            if objCondition.has_key(
                    'nGuestState') and objCondition['nGuestState']:
                nGuestState = objCondition['nGuestState']
                lsParams.append('h_relation_checkin.GuestState = :nGuestState')
                dictParamsValue['nGuestState'] = nGuestState

            # 证件信息
            # dictParams = {}
            if objCondition.has_key('sHotelGuestNameLike'
                                    ) and objCondition['sHotelGuestNameLike']:
                sHotelGuestName = '%' + objCondition[
                    'sHotelGuestNameLike'] + '%'
                lsParams.append('g_guest_doc.GuestName Like :sHotelGuestName')
                dictParamsValue['sHotelGuestName'] = sHotelGuestName
                # dictParams['GuestName'] = sHotelGuestName

            if objCondition.has_key(
                    'nHotelDocType') and objCondition['nHotelDocType']:
                nHotelDocType = objCondition['nHotelDocType']
                lsParams.append('g_guest_doc.DocType = :nHotelDocType')
                dictParamsValue['nHotelDocType'] = nHotelDocType

            if objCondition.has_key(
                    'sHotelDocNoLikeL') and objCondition['sHotelDocNoLikeL']:
                sHotelDocNo = objCondition['sHotelDocNoLikeL'] + '%'
                lsParams.append('g_guest_doc.DocNo Like :sHotelDocNo')
                dictParamsValue['sHotelDocNo'] = sHotelDocNo

            if objCondition.has_key('nHotelSex') and objCondition['nHotelSex']:
                nHotelSex = objCondition['nHotelSex']
                lsParams.append('g_guest_doc.Sex = :nHotelSex')
                dictParamsValue['nHotelSex'] = nHotelSex

            if objCondition.has_key(
                    'nHotelNation') and objCondition['nHotelNation']:
                nHotelNation = objCondition['nHotelNation']
                lsParams.append('g_guest_doc.Nation = :nHotelNation')
                dictParamsValue['nHotelNation'] = nHotelNation

            if objCondition.has_key(
                    'nHotelNationality') and objCondition['nHotelNationality']:
                nHotelNationality = objCondition['nHotelNationality']
                lsParams.append('g_guest_doc.Nationality = :nHotelNationality')
                dictParamsValue['nHotelNationality'] = nHotelNationality

            if objCondition.has_key('sHotelBornDateStart'
                                    ) and objCondition['sHotelBornDateStart']:
                dtHotelBornDateStart = to_datetime(
                    objCondition['sHotelBornDateStart'])
                lsParams.append(
                    'g_guest_doc.BornDate >= :dtHotelBornDateStart')
                dictParamsValue['dtHotelBornDateStart'] = dtHotelBornDateStart

            if objCondition.has_key(
                    'sHotelBornDateEnd') and objCondition['sHotelBornDateEnd']:
                dtHotelBornDateEnd = to_datetime(
                    objCondition['sHotelBornDateEnd'])
                lsParams.append('g_guest_doc.BornDate <= :dtHotelBornDateEnd')
                dictParamsValue['dtHotelBornDateEnd'] = dtHotelBornDateEnd

            # 入住出示证件信息
            if objCondition.has_key(
                    'sGuestDocNameLike') and objCondition['sGuestDocNameLike']:
                sGuestDocName = '%' + objCondition['sGuestDocNameLike'] + '%'
                lsParams.append(
                    'g_guest_checkin.HotelGuestName Like :sGuestDocName')
                dictParamsValue['sGuestDocName'] = sGuestDocName

            if objCondition.has_key('nDocType') and objCondition['nDocType']:
                nDocType = objCondition['nDocType']
                lsParams.append('g_guest_checkin.HotelDocType = :nDocType')
                dictParamsValue['nDocType'] = nDocType

            if objCondition.has_key(
                    'sDocNoLikeL') and objCondition['sDocNoLikeL']:
                sDocNo = objCondition['sDocNoLikeL'] + '%'
                lsParams.append('g_guest_checkin.HotelDocNo Like :sDocNo')
                dictParamsValue['sDocNo'] = sDocNo

            if objCondition.has_key('nSex') and objCondition['nSex']:
                nSex = objCondition['nSex']
                lsParams.append('g_guest_checkin.HotelSex = :nSex')
                dictParamsValue['nSex'] = nSex

            if objCondition.has_key('nNation') and objCondition['nNation']:
                nNation = objCondition['nNation']
                lsParams.append('g_guest_checkin.HotelNation = :nNation')
                dictParamsValue['nNation'] = nNation

            if objCondition.has_key(
                    'nNationality') and objCondition['nNationality']:
                nNationality = objCondition['nNationality']
                lsParams.append(
                    'g_guest_checkin.HotelNationality = :nNationality')
                dictParamsValue['nNationality'] = nNationality

            if objCondition.has_key(
                    'nMatchResult') and objCondition['nMatchResult']:
                nMatchResult = objCondition['nMatchResult']
                lsParams.append('g_guest_checkin.MatchResult = :nMatchResult')
                dictParamsValue['nMatchResult'] = nMatchResult

            if objCondition.has_key(
                    'sBornDateStart') and objCondition['sBornDateStart']:
                dtBornDateStart = to_datetime(objCondition['sBornDateStart'])
                lsParams.append(
                    'g_guest_checkin.HotelBornDate >= :dtBornDateStart')
                dictParamsValue['dtBornDateStart'] = dtBornDateStart

            if objCondition.has_key(
                    'sBornDateEnd') and objCondition['sBornDateEnd']:
                dtBornDateEnd = to_datetime(objCondition['sBornDateEnd'])
                lsParams.append(
                    'g_guest_checkin.HotelBornDate <= :dtBornDateEnd')
                dictParamsValue['dtBornDateEnd'] = dtBornDateEnd

            objSql = web.ctx.cur_dbsession.query(CheckIn, RelationCheckIn, GuestCheckIn, GuestDoc, Foreigner, Hotel).\
                filter(and_(CheckIn.HotelID == Hotel.HotelID,
                            RelationCheckIn.CheckInID == CheckIn.CheckInID,
                            RelationCheckIn.HotelGuestID == GuestCheckIn.HotelGuestID,
                            RelationCheckIn.GuestDocID == GuestDoc.GuestDocID,
                            RelationCheckIn.GuestDocID == Foreigner.GuestDocID))

            lsQueryData = []
            nPageCount = 0
            nRowCount = 0
            objResult = get_data(objSql, lsParams, dictParamsValue, objPage)

            if objResult:
                if objResult.success and objResult.data is not None:
                    lsQueryData = objResult.data['DataList']
                    nPageCount = objResult.data['PageCount']
                    nRowCount = objResult.data['RowCount']

                lsData = []
                if len(lsQueryData) > 0:
                    for objData in lsQueryData:
                        dictCheckIn = obj_to_dict(objData[0])
                        dictRelationCheckIn = obj_to_dict(objData[1])
                        dictGuestCheckIn = obj_to_dict(objData[2])
                        dictGuestDoc = obj_to_dict(objData[3])
                        dictForeigner = obj_to_dict(objData[4])
                        dictHotel = obj_to_dict(objData[5])

                        del dictCheckIn['IsNew'], dictCheckIn['TableID'],\
                            dictForeigner['GuestDocID'], dictForeigner['CreateTime'], \
                            dictForeigner['TableID'], dictGuestCheckIn['TableID'], \
                            dictGuestDoc['TableID']
                        dictGuestCheckIn['CheckInTime'] = dictRelationCheckIn[
                            'CheckInTime']
                        dictGuestCheckIn['CheckOutTime'] = dictRelationCheckIn[
                            'CheckOutTime']
                        dictGuestCheckIn['GuestState'] = dictRelationCheckIn[
                            'GuestState']
                        dictCheckIn['HotelName'] = dictHotel['HotelName']
                        dictCheckIn['HotelAddr'] = dictHotel['HotelAddr']

                        # 返回字典类型字段对应名称
                        # 客人状态名
                        dictGuestCheckIn['GuestStateName'] = dict_to_name(
                            dictRelationCheckIn['GuestState'], 'checkin_state')
                        # 性别
                        dictGuestCheckIn['HotelSexName'] = dict_to_name(
                            dictGuestCheckIn['HotelSex'], 'sex')
                        # 民族
                        dictGuestCheckIn['HotelNationName'] = dict_to_name(
                            dictGuestCheckIn['HotelNation'], 'gres_nation')
                        # 证件类型
                        dictGuestCheckIn['HotelDocTypeName'] = dict_to_name(
                            dictGuestCheckIn['HotelDocType'], 'doc_type')
                        # 国籍
                        dictGuestCheckIn[
                            'HotelNationalityName'] = dict_to_name(
                                dictGuestCheckIn['HotelNationality'],
                                'gres_country')

                        # 证件类型
                        dictGuestDoc['DocTypeName'] = dict_to_name(
                            dictGuestDoc['DocType'], 'doc_type')
                        # 性别
                        dictGuestDoc['SexName'] = dict_to_name(
                            dictGuestDoc['Sex'], 'sex')
                        # 民族
                        dictGuestDoc['NationName'] = dict_to_name(
                            dictGuestDoc['Nation'], 'gres_nation')
                        # 客人状态
                        dictGuestDoc['StateName'] = dict_to_name(
                            dictGuestDoc['State'], 'checkin_state')

                        # 签证类型
                        dictForeigner['VisaTypeName'] = dict_to_name(
                            dictForeigner['VisaType'], 'visa_type')
                        # 外国人国籍
                        dictForeigner['NationalityName'] = dict_to_name(
                            dictForeigner['Nationality'], 'gres_country')

                        dictData = {
                            'GuestCheckIn': dictGuestCheckIn,
                            'GuestDoc': dictGuestDoc,
                            'Foreigner': dictForeigner,
                            'CheckinInfo': dictCheckIn
                        }
                        lsData.append(dictData)

                    return FuncResult(success=True,
                                      data={
                                          'PageNo': objPage['nPageNo'],
                                          'PageSize': objPage['nPageSize'],
                                          'PageCount': nPageCount,
                                          'RowCount': nRowCount,
                                          'DataSet': lsData
                                      })

        except Exception, ce:
            return FuncResult(fail=ce)