当前位置: 首页>>代码示例>>Python>>正文


Python QueryHelper.get_login_time_by_tid方法代码示例

本文整理汇总了Python中helpers.queryhelper.QueryHelper.get_login_time_by_tid方法的典型用法代码示例。如果您正苦于以下问题:Python QueryHelper.get_login_time_by_tid方法的具体用法?Python QueryHelper.get_login_time_by_tid怎么用?Python QueryHelper.get_login_time_by_tid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在helpers.queryhelper.QueryHelper的用法示例。


在下文中一共展示了QueryHelper.get_login_time_by_tid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle_location

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_login_time_by_tid [as 别名]

#.........这里部分代码省略.........
        #    if (current_time - last_location.timestamp) > 600:
        #        location.gps_time = current_time 
        #        logging.info("Tid:%s, current_time - last_location.timestamp  > 600s, so use current time:%s", location.dev_id, current_time)
        #    else:
        #        logging.info("Tid:%s, current_time - last_location.timestamp  <= 600s, so use last location time:%s", location.dev_id, last_location.timestamp)
        #        location.gps_time = last_location.timestamp
        #    location.lat = last_location.latitude
        #    location.lon = last_location.longitude
        #    location.cLat = last_location.clatitude
        #    location.cLon = last_location.clongitude
        #    location.type = 0 
        #    location.gps = 0
        #else:
        #    location.lat = 0
        #    location.lon = 0
        #    location.cLat = 0
        #    location.cLon = 0
        #    location.type = 0
        #    location.gps_time = int(time.time()) 
        #    location.degree = 0.00
        #    location.gps = 0
        #    #if cellid:
        #    #    location = issue_cellid(location, db, redis)
    elif location.valid == GATEWAY.LOCATION_STATUS.MOVE: # 6
        logging.info("[LBMPHELPER] tid:%s gps locate flag :%s", location.dev_id, location.valid)
        location.lat = 0
        location.lon = 0
        location.cLat = 0
        location.cLon = 0
        location.type = 0
        location.gps_time = int(time.time()) 
        location.degree = 0.00
        location.gps = 0
        if cellid:
            location = issue_cellid(location, db, redis)
    else: # 0,2,5
        logging.info("[LBMPHELPER] tid:%s gps locate flag :%s", location.dev_id, location.valid)
        location.lat = 0
        location.lon = 0
        location.cLat = 0
        location.cLon = 0
        location.type = 0
        location.gps_time = int(time.time()) 
        location.degree = 0.00
        #if db:
        #    location.degree = get_last_degree(location, redis, db)
        location.gps = 0
        if cellid:
            # 1: issue cellid
            location = issue_cellid(location, db, redis)
            if location.lon and location.lat:
                # 2: check the location whether is odd 
                last_location = QueryHelper.get_location_info(location.dev_id, db, redis)
                if last_location:
                    distance = get_distance(location.lon,
                                            location.lat,
                                            last_location.longitude,
                                            last_location.latitude)
                    if distance > 5000: 
                        login_time = QueryHelper.get_login_time_by_tid(location.dev_id, db, redis)
                        if last_location.timestamp < login_time:
                            logging.info("[LBMPHELPER] tid: %s distance:%s > 5000m, and last login time: %s, after last location timestamp: %s, use cellid location.",
                                         location.dev_id, distance, login_time, last_location.timestamp) 
                        else:
                            location.lat, location.lon = (last_location.latitude, last_location.longitude)
                            logging.info("[LBMPHELPER] tid:%s, distance:%s > 5000m, use last location: %s ",
                                         location.dev_id, distance, last_location)
                    elif distance < 2000:
                        location.lat, location.lon = (last_location.latitude, last_location.longitude)
                        logging.info("[LBMPHELPER] tid:%s distance:%s < 2000m, use last location:%s", location.dev_id, distance, last_location)
                    else:
                        logging.info("[LBMPHELPER] tid:%s 2000m < distance:%s < 5000m, use cellid location", location.dev_id, distance)
                else:
                    logging.info("[LBMPHELPER] tid:%s last location is none, use cellid location", location.dev_id)

    if location and location.lat and location.lon:
        clats, clons = get_clocation_from_ge([location.lat,], [location.lon,])
        location.cLat, location.cLon = clats[0], clons[0] 
        # drop some odd cellid location
        if location.type == 1 and location.cLat and location.cLon:
            if PtInPolygon(location, DM_ZJGS_POLYGON):
                location.lat = 0
                location.lon = 0
                location.cLat = 0
                location.cLon = 0

        #if (location['t'] == EVENTER.INFO_TYPE.REPORT or
        #    location['command'] == GATEWAY.T_MESSAGE_TYPE.LOCATIONDESC):
        # NOTE: change it temporarily: in platform get loction name of all
        if location.cLat and location.cLon:
            location.name = get_location_name(location.cLat, location.cLon, redis)

    if location['t'] == EVENTER.INFO_TYPE.POSITION:
        location.category = EVENTER.CATEGORY.REALTIME
    elif location['t'] == EVENTER.INFO_TYPE.REPORT:
        location.category = EVENTER.CATEGORY[location.rName]
    else:
        location.category = EVENTER.CATEGORY.UNKNOWN

    return location
开发者ID:jcsy521,项目名称:ydws,代码行数:104,代码来源:lbmphelper.py


注:本文中的helpers.queryhelper.QueryHelper.get_login_time_by_tid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。