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


Python QueryHelper.get_acc_status_info_by_tid方法代码示例

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


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

示例1: _on_finish

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

#.........这里部分代码省略.........

                    res[tid] = {'car_info':{},
                                'track_info':[]}

                    # 0: get group info
                    group_info = get_group_info_by_tid(self.db, tid)

                    # 1: get terminal info 
                    terminal = QueryHelper.get_terminal_info(tid, self.db, self.redis) 
                    mobile = terminal['mobile']
                    if terminal['login'] == GATEWAY.TERMINAL_LOGIN.SLEEP:
                        terminal['login'] = GATEWAY.TERMINAL_LOGIN.ONLINE

                    # 2: get location 
                    location = QueryHelper.get_location_info(tid, self.db, self.redis)
                    if location and not (location.clatitude or location.clongitude):
                        location_key = get_location_key(str(tid))
                        locations = [location,] 
                        #locations = get_locations_with_clatlon(locations, self.db) 
                        location = locations[0]
                        if location.clatitude and location.clongitude:
                            self.redis.setvalue(location_key, location, EVENTER.LOCATION_EXPIRY)

                    if location and location['name'] is None:
                        location['name'] = location['name'] if location['name'] else ''


                    if location and location['type'] == 1: # cellid
                        location['locate_error'] = 500  # mile

                    avatar_full_path, avatar_path, avatar_name, avatar_time = self.get_avatar_info(mobile)
                    service_status = QueryHelper.get_service_status_by_tmobile(self.db, mobile)

                    acc_status_info = QueryHelper.get_acc_status_info_by_tid(self.client_id, tid, self.db, self.redis)
                    acc_message = acc_status_info['acc_message']

                    car_info=dict(defend_status=terminal['defend_status'] if terminal.get('defend_status', None) is not None else 1,
                                  service_status=service_status,
                                  mannual_status=terminal['mannual_status'] if terminal.get('mannual_status', None) is not None else 1,
                                  acc_message=acc_message,
                                  fob_status=terminal['fob_status'] if terminal.get('fob_status', None) is not None else 0,
                                  timestamp=location['timestamp'] if location else 0,
                                  speed=location.speed if location else 0,
                                  # NOTE: degree's type is Decimal, float() it before json_encode
                                  degree=float(location.degree) if location else 0.00,
                                  locate_error=location.get('locate_error', 20) if location else 20,
                                  name=location.name if location else '',
                                  type=location.type if location else 1,
                                  latitude=location['latitude'] if location else 0,
                                  longitude=location['longitude'] if location else 0, 
                                  clatitude=location['clatitude'] if location else 0,
                                  clongitude=location['clongitude'] if location else 0, 
                                  login=terminal['login'] if terminal['login'] is not None else 0,
                                  bt_name=terminal.get('bt_name', '') if terminal else '',
                                  bt_mac=terminal.get('bt_mac', '') if terminal else '',
                                  dev_type=terminal['dev_type'] if terminal.get('dev_type', None) is not None else 'A',
                                  gps=terminal['gps'] if terminal['gps'] is not None else 0,
                                  gsm=terminal['gsm'] if terminal['gsm'] is not None else 0,
                                  pbat=terminal['pbat'] if terminal['pbat'] is not None else 0,
                                  mobile=terminal['mobile'],
                                  owner_mobile = terminal['owner_mobile'],
                                  alias=terminal['alias'] if terminal['alias'] else terminal['mobile'],
                                  #keys_num=terminal['keys_num'] if terminal['keys_num'] is not None else 0,
                                  keys_num=0,
                                  group_id=group_info['group_id'],
                                  group_name=group_info['group_name'],
开发者ID:jcsy521,项目名称:ydws,代码行数:70,代码来源:lastposition.py

示例2: _on_finish

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

#.........这里部分代码省略.........
                            logging.info(
                                "[UWEB] Inclastinfo step2 used time: %s > 5s, cid: %s",
                                _now_time - _start_time,
                                self.current_user.cid,
                            )

                        group["trackers"][tid] = {}
                        # 1: get terminal info
                        terminal = QueryHelper.get_terminal_info(tid, self.db, self.redis)
                        if terminal["login"] == GATEWAY.TERMINAL_LOGIN.SLEEP:
                            terminal["login"] = GATEWAY.TERMINAL_LOGIN.ONLINE

                        if terminal["login"] == GATEWAY.TERMINAL_LOGIN.ONLINE:
                            res["online"] += 1
                        else:
                            res["offline"] += 1

                        # 2: get location
                        location = QueryHelper.get_location_info(tid, self.db, self.redis)
                        if location and not (location.clatitude or location.clongitude):
                            location_key = get_location_key(str(tid))
                            locations = [location]
                            # NOTE: offset latlon
                            # locations = get_locations_with_clatlon(locations, self.db)
                            location = locations[0]
                            self.redis.setvalue(location_key, location, EVENTER.LOCATION_EXPIRY)

                        if location and location["name"] is None:
                            location["name"] = ""

                        if location and location["type"] == 1:  # cellid
                            location["locate_error"] = 500  # mile

                        acc_status_info = QueryHelper.get_acc_status_info_by_tid(
                            self.client_id, tid, self.db, self.redis
                        )
                        acc_message = acc_status_info["acc_message"]
                        op_status = acc_status_info["op_status"]

                        # 1: build the basic_info
                        basic_info = dict(
                            defend_status=terminal["defend_status"] if terminal["defend_status"] is not None else 1,
                            mannual_status=terminal["mannual_status"] if terminal["mannual_status"] is not None else 1,
                            acc_message=acc_message,
                            op_status=op_status,
                            fob_status=terminal["fob_status"] if terminal["fob_status"] is not None else 0,
                            timestamp=location["timestamp"] if location else 0,
                            speed=location.speed if location else 0,
                            # NOTE: degree's type is Decimal,
                            # float() it before json_encode
                            degree=float(location.degree) if location else 0.00,
                            locate_error=location.get("locate_error", 20) if location else 20,
                            name=location.name if location else "",
                            type=location.type if location else 1,
                            latitude=location["latitude"] if location else 0,
                            longitude=location["longitude"] if location else 0,
                            clatitude=location["clatitude"] if location else 0,
                            clongitude=location["clongitude"] if location else 0,
                            login=terminal["login"] if terminal["login"] is not None else 0,
                            bt_name=terminal.get("bt_name", "") if terminal else "",
                            bt_mac=terminal.get("bt_mac", "") if terminal else "",
                            dev_type=terminal["dev_type"] if terminal.get("dev_type", None) is not None else "A",
                            gps=terminal["gps"] if terminal["gps"] is not None else 0,
                            gsm=terminal["gsm"] if terminal["gsm"] is not None else 0,
                            pbat=terminal["pbat"] if terminal["pbat"] is not None else 0,
                            mobile=terminal["mobile"],
开发者ID:jcsy521,项目名称:ydws,代码行数:70,代码来源:inclastinfo.py


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