1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- # -*- coding: utf-8 -*-
- #!/usr/bin/env python
- import os, sys
- import threading
- import uuid
- # import xlrd
- # from xlrd import xldate_as_tuple
- import simplejson as json
- import datetime
- from django.conf import settings
- PROJECT_ROOT = os.path.join(os.path.abspath(os.path.split(os.path.realpath(__file__))[0] + "/.."), '..')
- sys.path.insert(0, PROJECT_ROOT)
- os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'configs.production')
- from script.base import init_env
- init_env(interactive = False)
- from apps.web.device.models import SIMCard,Device
- from apps.web.constant import Const
- from apilib.utils_datetime import to_datetime
- from apps.web.user.models import RechargeRecord
- # 从SIM卡平台上导出来的excel,导入到数据库中,便于流量结算。
- # 1、月末:根据用户的充值情况,把SIM卡数据全部导出来,发给卡商,进行充值。
- # 2、月头:卡商充值后,我们利用import_sim_card脚本,把excel导出来,然后导入到数据库,并执行另外一个脚本update_device_sim_info_from_simdb更新设备的超时时间
- # devices = Device.get_sim_expire_notify_devices()
- #
- #
- # from cytoolz import groupby
- # devMap = groupby('ownerId', devices)
- #
- # dealerMap = {} # type: Dict[ObjectId, dict]
- # for id_,devs in devMap.items():
- # try:
- # print len(devs)
- # if len(devs) <= 1000:
- # for dev in devs:
- # try:
- # devObj = Device.objects.get(logicalCode = dev['logicalCode'])
- # devObj.simChargeAuto = True
- # devObj.save()
- # Device.invalid_device_cache(devObj.devNo)
- # print devObj.devNo
- # except Exception,e:
- # print e
- # continue
- # except:
- # continue
- # 打印数据
- from apps.web.dealer.tasks import dealer_auto_charge_sim_card
- print 'start charege auto card'
- dealer_auto_charge_sim_card()
- print 'end charge card'
|