# -*- coding: utf-8 -*- #!/usr/bin/env python """ 从事件表里恢复线下投币数据 """ import os import sys # : current_dir - 2 PROJECT_ROOT = os.path.join(os.path.abspath(os.path.split(os.path.realpath(__file__))[0] + "/.."), '..') sys.path.insert(0, PROJECT_ROOT) from script.base import init_env, get_logger logger = get_logger(__name__) init_env(interactive = True) from apps.web.device.models import DeviceEvent from apps.web.constant import Const from apilib.utils_datetime import date_to_datetime_floor, date_to_datetime_ceiling, dt_to_timestamp DATE_FMT = Const.DATE_FMT start_time_timestamp = dt_to_timestamp(date_to_datetime_floor('2018-09-30')) end_time_timestamp = dt_to_timestamp(date_to_datetime_ceiling('2018-10-03')) all_offline_coin_events = DeviceEvent.get_collection().find({ 'cmd': 205, 'time': {'$gte': start_time_timestamp, '$lte': end_time_timestamp} })