month = today.month
   year = today.year
   weekday = today.weekday()
   lastDayOfMonth = calendar.monthrange(year, month)[1]

   todayString = today.strftime("%d/%m/%Y")
   todayTimeStamp = int(time.mktime(time.strptime(str(todayString + " 00:00:00"), "%d/%m/%Y %H:%M:%S")))

   startMonth = int(time.mktime(time.strptime(str('01/' + str(month) + '/' + str(year) + " 00:00:00"), "%d/%m/%Y %H:%M:%S")))
   endMonth = int(time.mktime(time.strptime(str(str(lastDayOfMonth) + '/' + str(month) + '/' + str(year) + " 23:59:59"), "%d/%m/%Y %H:%M:%S")))

   holidayOfMonth = mongodb.getOne(MONGO_COLLECTION=common.getSubUser(subUserType, 'Report_off_sys'), WHERE={'off_date': todayTimeStamp})
   if holidayOfMonth != None:
      sys.exit()

   dayStamp = common.convertTimestamp(value=today.strftime("%d/%m/%Y"))
   result_due_date = mongodb.getOne(MONGO_COLLECTION=due_date_collection,WHERE={'due_date_add_1':todayTimeStamp})

   count = mongodb.count(MONGO_COLLECTION=account_collection)
   limit = 10000
   quotient = int(count)/limit
   mod = int(count)%limit

   checkGroup = mongodb.count(MONGO_COLLECTION=collection)
   if checkGroup <= 0:
      for x in range(int(quotient)):
         result = mongodb.get(MONGO_COLLECTION=account_collection, SELECT=['account_number','overdue_date','due_date'],SORT=([('_id', -1)]),SKIP=int(x*limit), TAKE=int(limit))
         for idx,row in enumerate(result):
            temp = {}
            tempSbv = {}
            group = ''
            # break

    # Wo
    data_wo = mongodb.aggregate_pipeline(MONGO_COLLECTION=wo_collection,
                                         aggregate_pipeline=aggregate_pipeline)
    for idx, row in enumerate(data_wo):
        for detail in row['detail']:
            temp = {}
            temp['export_date'] = now.strftime("%d/%m/%Y")
            temp['index'] = i
            temp['account_number'] = row['ACCTNO']
            temp['phone'] = row['PHONE']
            temp['name'] = row['CUS_NM']
            if row['NGAY_QUA_HAN'] != '':
                try:
                    temp['overdue_date'] = common.convertTimestamp(
                        row['NGAY_QUA_HAN'], formatString='%m/%d/%Y')
                except Exception as e:
                    temp['overdue_date'] = common.convertTimestamp(
                        row['NGAY_QUA_HAN'], formatString='%d/%m/%Y')
            else:
                temp['overdue_date'] = ''

            temp['loan_overdue_amount'] = float(row['WO9711']) + float(
                row['WO9713']) + float(row['WO9713'])
            temp['current_balance'] = float(row['WO9711']) + float(
                row['WO9713']) + float(row['WO9713'])
            temp['product_id'] = str(row['PROD_ID'])
            temp['outstanding_principal'] = float(row['WO9711'])

            temp['group_id'] = 'F'
            temp['contacted'] = mongodb.count(
Esempio n. 3
0
now = datetime.now()
subUserType = 'LO'
account_collection = common.getSubUser(subUserType,
                                       'List_of_account_in_collection')
sbv_collection = common.getSubUser(subUserType, 'SBV')
collection = common.getSubUser(subUserType, 'Group_card')
due_date_collection = common.getSubUser(subUserType, 'Report_due_date')
log = open(base_url + "cronjob/python/Loan/log/groupCard_log.txt", "a")

try:
    data = []
    insertData = []
    updateDate = []

    day = now.strftime("%d/%m/%Y")
    day = common.convertTimestamp(value=day)
    result_due_date = mongodb.getOne(MONGO_COLLECTION=due_date_collection,
                                     WHERE={'due_date_add_1': day})
    # log.write(now.strftime("%d/%m/%Y, %H:%M:%S") + ': Start Log' + '\n')
    count = mongodb.count(MONGO_COLLECTION=account_collection)
    limit = 10000
    quotient = int(count) / limit
    mod = int(count) % limit

    checkGroup = mongodb.count(MONGO_COLLECTION=collection)
    if checkGroup <= 0:
        for x in range(int(quotient)):
            result = mongodb.get(MONGO_COLLECTION=account_collection,
                                 SELECT=['account_number', 'overdue_date'],
                                 SORT=([('_id', -1)]),
                                 SKIP=int(x * limit),