temp['ratio_target_no'] = (temp['accumulated_no'] /
                                               temp['target_no']) * 100
            else:
                temp['ratio_target_no'] = 0

            if temp['start_os_bl'] != 0:
                temp['ratio_start_os_bl'] = (temp['accumulated_os_bl'] /
                                             temp['start_os_bl']) * 100
            else:
                temp['ratio_start_os_bl'] = 0

            if temp['start_no'] != 0:
                temp['ratio_start_no'] = (temp['accumulated_no'] /
                                          temp['start_no']) * 100
            else:
                temp['ratio_start_no'] = 0

            mongodb.insert(MONGO_COLLECTION=collection, insert_data=temp)
            mongodb.update(MONGO_COLLECTION=collection,
                           WHERE={
                               'created_at': {
                                   '$gte': yesterdayTimeStamp,
                                   '$lte': (yesterdayTimeStamp + 86399)
                               },
                               'debt_group_name': group
                           },
                           VALUE=tempYesterday)
        # pprint(insertData)
except Exception as e:
    log.write(now.strftime("%d/%m/%Y, %H:%M:%S") + ': ' + str(e) + '\n')
示例#2
0
    if day == 1:
        mongodb.create_db(DB_NAME=logDbName)
        mongodbresult = Mongodb(logDbName)
    else:
        mongodbresult = Mongodb(logDbName)

    ftpLocalUrl = common.getDownloadFolder() + fileName

    try:
        sys.argv[1]
        importLogId = str(sys.argv[1])
        mongodb.update(MONGO_COLLECTION=common.getSubUser(
            subUserType, 'Import'),
                       WHERE={'_id': ObjectId(sys.argv[1])},
                       VALUE={
                           'command':
                           '/usr/local/bin/python3.6 ' + base_url +
                           "cronjob/python/Loan/importAppointment_cron.py " +
                           importLogId + " > /dev/null &"
                       })
        importLogInfo = mongodb.getOne(MONGO_COLLECTION=common.getSubUser(
            subUserType, 'Import'),
                                       WHERE={'_id': ObjectId(sys.argv[1])})
    except Exception as SysArgvError:
        if not os.path.isfile(ftpLocalUrl):
            sys.exit()

        importLogInfo = {
            'collection': collection,
            'begin_import': time.time(),
            'file_name': fileName,
示例#3
0
                            group = 'C' + debt_group
                        if int(sbv['delinquency_group']) == 4:
                            group = 'D' + debt_group
                        if int(sbv['delinquency_group']) == 5:
                            group = 'E' + debt_group

                        temp['account_number'] = row['account_number']
                        temp['due_date'] = row['overdue_date']
                        temp['group'] = group
                        temp['group_number'] = sbv['delinquency_group']
                        temp['created_at'] = int(time.time())
                        temp['created_by'] = 'system'
                        insertData.append(temp)
                        tempSbv['first_due_group'] = sbv['delinquency_group']
                        mongodb.update(
                            MONGO_COLLECTION=sbv_collection,
                            WHERE={'contract_no': str(row['account_number'])},
                            VALUE=tempSbv)
                #       print(temp)

        if mod > 0:
            result = mongodb.get(MONGO_COLLECTION=account_collection,
                                 SELECT=['account_number', 'overdue_date'],
                                 SORT=([('_id', -1)]),
                                 SKIP=int(int(quotient) * limit),
                                 TAKE=int(mod))
            for idx, row in enumerate(result):
                temp = {}
                tempSbv = {}
                group = ''
                if row['overdue_date'] != 0:
                    date_time = datetime.fromtimestamp(row['overdue_date'])
示例#4
0
                        value['updatedAt'])) if 'updatedAt' in value.keys(
                        ) and value['updatedAt'] != '' else ''
                worksheet.write(key + 1, header_key, cell_value)
                # worksheet.set_column(key + 1, header_key, len(str(cell_value)))
                continue

            cell_value = str(
                value[header_value]) if header_value in value.keys() else ''
            worksheet.write(key + 1, header_key, cell_value)
    workbook.close()
    now_end = datetime.now()
    if 'exportLogId' in locals():
        mongodb.update(MONGO_COLLECTION=common.getSubUser(
            subUserType, 'Export'),
                       WHERE={'_id': ObjectId(exportLogId)},
                       VALUE={
                           'status': 1,
                           'end': time.time()
                       }),
    # notification = {
    #     'title'         : f'Export Calling list success',
    #     'active'        : True,
    #     'icon'          : 'fa fa-info-circle',
    #     'color'         : 'text-success',
    #     'content'       : f'Xuất excel thành công. Nhấn vào thông báo để tải về.',
    #     'link'          : '/upload/telesales/export/Calling_list'+ today.strftime("%d%m%Y") +'.xlsx',
    #     'to'            : exportLogInfo['created_by'],
    #     'notifyDate'    : datetime.utcnow(),
    #     'is_download'   : True,
    #     'createdBy'     : 'System',
    #     'createdAt'     : time.time()
示例#5
0
                    MONGO_COLLECTION=collection,
                    WHERE={'CONTRACTNR': temp['CONTRACTNR']})
                if checkInfo is not None:
                    updateDate.append(temp)
                else:
                    insertData.append(temp)
                result = True

    if (len(errorData) > 0):
        mongodb.batch_insert(
            common.getSubUser(subUserType, 'Cus_assigned_partner_result'),
            errorData)
        mongodb.update(MONGO_COLLECTION=common.getSubUser(
            subUserType, 'Import'),
                       WHERE={'_id': importLogId},
                       VALUE={
                           'status': 0,
                           'complete_import': time.time()
                       })
    else:
        if len(insertData) > 0:
            mongodb.batch_insert(MONGO_COLLECTION=collection,
                                 insert_data=insertData)
            mongodb.batch_insert(common.getSubUser(
                subUserType, 'Cus_assigned_partner_result'),
                                 insert_data=insertData)

        if len(updateDate) > 0:
            for updateD in updateDate:
                mongodb.update(MONGO_COLLECTION=collection,
                               WHERE={'CONTRACTNR': temp['CONTRACTNR']},
示例#6
0
try:
   importLogId = sys.argv[1]
   random      = sys.argv[2]
   extensions   = sys.argv[3]
   insertData  = []
   resultData  = []
   errorData   = []

   randoms = random.split(',')
   extensions = extensions.split(',')
   # log.write(str(extensions))
   now         = datetime.now()
   log.write(now.strftime("%d/%m/%Y, %H:%M:%S") + ': Start Log' + '\n')

   mongodb.update(MONGO_COLLECTION='TS_Import', WHERE={'_id': ObjectId(importLogId)}, VALUE={'assign': int(-1)})
   assign_log = mongodb.getOne(MONGO_COLLECTION='TS_Assign_log')
   if assign_log == None:
      users = _mongodb.get(MONGO_COLLECTION='TS_User', WHERE=None, SELECT=['extension', 'agentname'], SORT=([('id', 1)]))
      users = list(users)
      # log.write(str(users))
      arrayCMND = {}
      assign_log = {}
      for user in users:
         arrayCMND[user['extension']] = []
         assign_log[user['extension']] = []
      assign_log['_id'] = mongodb.insert('TS_Assign_log', arrayCMND)
      array_cmnd = []
 
   for u,extension in enumerate(extensions):
      user = _mongodb.getOne(MONGO_COLLECTION='TS_User', WHERE={'extension': str(extension)}, SELECT=['extension', 'agentname'])
            
                  temp['account_number']   = row['account_number']
                  temp['due_date']     = due_date
                  temp['group']        = group
                  temp['group_number'] = sbv['delinquency_group']
                  temp['created_at']   = todayTimeStamp
                  temp['created_by']   = 'system'
                  checkDataInDB = mongodb.getOne(MONGO_COLLECTION=collection, WHERE={'account_number': temp['account_number']})
                  if checkDataInDB is not None:
                     updateDate.append(temp)
                  else:
                     insertData.append(temp)

                  # tempSbv['first_due_group'] = sbv['delinquency_group']
                  # mongodb.update(MONGO_COLLECTION=sbv_collection, WHERE={'contract_no': str(row['account_number'])}, VALUE=tempSbv)

   if len(insertData) > 0:
      mongodb.batch_insert(MONGO_COLLECTION=collection, insert_data=insertData)

   if len(updateDate) > 0:
      for updateD in updateDate:
          mongodb.update(MONGO_COLLECTION=collection, WHERE={'account_number': updateD['account_number']}, VALUE=updateD)

      
   now_end         = datetime.now()
   log.write(now_end.strftime("%d/%m/%Y, %H:%M:%S") + ': End Log' + '\n')
   print('DONE')
   
except Exception as e:
   print(e)
   log.write(now.strftime("%d/%m/%Y, %H:%M:%S") + ': ' + str(e) + '\n')
            temp['created_at'] = time.time()
            temp['import_id'] = str(importLogId)
            if(result == False):
                errorData.append(temp)
            else:
                temp['result'] = 'success'
                checkDataInDB = mongodb.getOne(MONGO_COLLECTION=collection, WHERE={'account_number': temp['account_number']})
                if checkDataInDB is not None:
                    updateDate.append(temp)
                else:
                    insertData.append(temp)
                result = True
            # break
    if(len(errorData) > 0):
        mongodb.batch_insert(common.getSubUser(subUserType, 'LNJC05_result'), errorData)
    else:
        if len(insertData) > 0:
            mongodb.remove_document(MONGO_COLLECTION=collection)
            mongodb.batch_insert(MONGO_COLLECTION=collection, insert_data=insertData)
            mongodb.batch_insert(common.getSubUser(subUserType, 'LNJC05_result'), insert_data=insertData)

        if len(updateDate) > 0:
            for updateD in updateDate:
                mongodb.update(MONGO_COLLECTION=collection, WHERE={'account_number': updateD['account_number']}, VALUE=updateD)
            mongodb.batch_insert(common.getSubUser(subUserType, 'LNJC05_result'), insert_data=updateDate)

    mongodb.update(MONGO_COLLECTION=common.getSubUser(subUserType, 'Import'), WHERE={'_id': importLogId}, VALUE={'status': 1, 'complete_import': time.time(),'error': errorData})
    print(111)
except Exception as e:
    log.write(now.strftime("%d/%m/%Y, %H:%M:%S") + ': ' + str(e) + '\n')
示例#9
0
                                        })
                if checkdata is not None:
                    updateDate.append(temp)
                else:
                    insertData.append(temp)

    # mongodb.remove_document(MONGO_COLLECTION=collection)

    if (len(errorData) > 0):
        mongodb.batch_insert(
            common.getSubUser(subUserType, 'WO_monthly_result'), errorData)
        mongodb.update(MONGO_COLLECTION=common.getSubUser(
            subUserType, 'Import'),
                       WHERE={'_id': importLogId},
                       VALUE={
                           'status': 0,
                           'complete_import': time.time(),
                           'total': total,
                           'complete': complete
                       })
    else:
        if len(insertData) > 0:
            mongodb.batch_insert(MONGO_COLLECTION=collection,
                                 insert_data=insertData)
            mongodb.batch_insert(common.getSubUser(subUserType,
                                                   'WO_monthly_result'),
                                 insert_data=insertData)
        if len(updateDate) > 0:
            for updateD in updateDate:
                mongodb.update(MONGO_COLLECTION=collection,
                               WHERE={
# except Exception as e:
#     log.write(traceback.format_exc())
#     print(traceback.format_exc())

# UPDATE LAST CALL CALLING LIST
# try:
#     listCallingList = mongodb.get(MONGO_COLLECTION=collection)
#     for callingList in listCallingList:
#         if 'phone' in callingList.keys():
#             cdrInfo = list(mongodb.get(MONGO_COLLECTION='TS_worldfonepbxmanager', WHERE={'customernumber': callingList['phone']}, SELECT={'starttime'}, SORT=[('starttime', -1)], TAKE=1))
#             if len(cdrInfo) > 0:
#                 mongodb.update(MONGO_COLLECTION=collection, WHERE={'_id': ObjectId(callingList['_id'])}, VALUE={'starttime_call': cdrInfo[0]['starttime']})
#                 pprint(cdrInfo)
# except Exception as e:
#     pprint(traceback.format_exc())

# Update last_modified
try:
    listAppointment = mongodb.get("TS_Appointment")
    for appointment in listAppointment:
        if 'updated_at' not in appointment.keys():
            mongodb.update(MONGO_COLLECTION='TS_Appointment',
                           WHERE={'_id': appointment['_id']},
                           VALUE={'last_modified': appointment['created_at']})
        else:
            mongodb.update(MONGO_COLLECTION='TS_Appointment',
                           WHERE={'_id': appointment['_id']},
                           VALUE={'last_modified': appointment['updated_at']})

except Exception as e:
    pprint(traceback.format_exc())
示例#11
0
    }]

    for product in products:
        if product['group_code'] != '300':
            list_prod_code = list(
                common.array_column(product['product_code'], 'code'))
            rows = []
            listCoumn = {
                'for_year': reportDate[str(todayTimeStamp)]['for_year'],
                'prod_group_code': product['group_code'],
            }
            mongodb.update(
                MONGO_COLLECTION=common.getSubUser(
                    subUserType, 'First_time_payment_delinqunecy_columns'),
                WHERE={
                    'for_year':
                    str(reportDate[str(todayTimeStamp)]['for_year']),
                    'prod_group_code': product['group_code']
                },
                VALUE=listCoumn)
            temp_column = []
            for rowValue in rowsValue:
                if rowValue['value'] == 'payday':
                    temp = {
                        'for_month':
                        str(reportDate[str(todayTimeStamp)]['for_month']),
                        'for_year':
                        str(reportDate[str(todayTimeStamp)]['for_year']),
                        'prod_group_code':
                        product['group_code'],
                        'prod_group_name':
示例#12
0
                value = str(listDataLibrary[key][idx])
                temp['createdBy'] = 'Byfixed-Import'
            if header['field'] == 'assign' and value == '':
                temp['createdBy'] = ''

            temp[header['field']] = value
            temp['id_import'] = importLogId

            temp['createdAt'] = int(time.time())
            temp['updatedAt'] = int(time.time())
            temp['updatedBy'] = 'system'

        if checkErr == False:
            try:
                mongodb.update(MONGO_COLLECTION=collection,
                               WHERE={'cif': temp['cif']},
                               VALUE=temp)
            except Exception as e:
                now_log = datetime.now()
                # log.write(now_log.strftime("%d/%m/%Y, %H:%M:%S") + ': ' + str(err) + '\n')

    if len(errorData) <= 0:
        status = 1
    else:
        status = 0
        # log.write( str(errorData) + '\n')

    mongodb.update(MONGO_COLLECTION='TS_Import',
                   WHERE={'_id': ObjectId(importLogId)},
                   VALUE={
                       'complete_import': time.time(),
                complete += 1

    if (len(errorData) > 0):
        mongodbresult.remove_document(
            MONGO_COLLECTION=common.getSubUser(subUserType, (
                'Cus_assigned_partner_' + str(year) + str(month) + str(day))))
        mongodbresult.batch_insert(
            common.getSubUser(
                subUserType,
                ('Cus_assigned_partner_' + str(year) + str(month) + str(day))),
            errorData)
        mongodb.update(MONGO_COLLECTION=common.getSubUser(
            subUserType, 'Import'),
                       WHERE={'_id': importLogId},
                       VALUE={
                           'status': 0,
                           'complete_import': time.time(),
                           'total': total,
                           'complete': complete
                       })
    else:
        if len(insertData) > 0:
            mongodb.batch_insert(MONGO_COLLECTION=collection,
                                 insert_data=insertData)
        if len(updateDate) > 0:
            for updateD in updateDate:
                mongodb.update(MONGO_COLLECTION=collection,
                               WHERE={'CONTRACTNR': updateD['CONTRACTNR']},
                               VALUE=updateD)
        mongodb.update(MONGO_COLLECTION=common.getSubUser(
            subUserType, 'Import'),
                temp['kendoGridField'] = scField
                temp['result'] = 'success'
                temp['from_date'] = int(
                    time.mktime(time.strptime(ngayTrucs[idx], "%d/%m/%Y")))
                insertData.append(temp)
                resultData.append(temp)
            else:
                errorData.append(temp)
                resultData.append(temp)
    if len(errorData) > 0:
        resultImport = mongodb.batch_insert(
            common.getSubUser(subUserType, 'Sc_schedule_result'), errorData)
        mongodb.update(MONGO_COLLECTION=common.getSubUser(
            subUserType, 'Import'),
                       WHERE={'_id': ObjectId(importLogId)},
                       VALUE={
                           'status': 0,
                           'complete_import': time.time()
                       })
    else:
        resultImport = mongodb.batch_insert(collection, insertData)
        resultImport = mongodb.batch_insert(
            common.getSubUser(subUserType, 'Sc_schedule_result'), resultData)
        mongodb.update(MONGO_COLLECTION=common.getSubUser(
            subUserType, 'Import'),
                       WHERE={'_id': ObjectId(importLogId)},
                       VALUE={
                           'status': 1,
                           'complete_import': time.time()
                       })
except Exception as e:
示例#15
0
                                        total_overdue_outstanding_bal += no_overdue_amt

                                    if key == '6':
                                        temp['index_' + str(todayIndex)] = yesterdayInfo['index_' + str(todayIndex - 1)] - no_overdue_amt if yesterdayInfo is not None and yesterdayInfo['index_' + str(todayIndex - 1)] is not None else 0
                                        total_collected_amt_and_day += temp['index_' + str(todayIndex)]

                                    if key == '7':
                                        temp['index_' + str(todayIndex)] = yesterdayInfo['start_amt'] - no_overdue_amt if yesterdayInfo is not None and yesterdayInfo['start_amt'] is not None else 0
                                        total_collected_amt_accumulated += temp['index_' + str(todayIndex)]

                                    if key == '8':
                                        temp['index_' + str(todayIndex)] = (yesterdayInfo['index_' + str(todayIndex - 1)] - no_overdue_amt) / yesterdayInfo['start_amt'] if yesterdayInfo is not None and yesterdayInfo['start_amt'] is not None and yesterdayInfo['index_' + str(todayIndex - 1)] is not None else 0
                                        total_collected_ratio_amt += temp['index_' + str(todayIndex)]

                                    if yesterdayInfo is not None:
                                        mongodb.update(MONGO_COLLECTION=common.getSubUser(subUserType, 'Daily_prod_working_day'), WHERE={'team_id': str(groupCell['_id']), 'day_code': key, 'updated_at': {'$gte': yesterday_starttime, '$lte': yesterday_endtime}}, VALUE=temp)
                                    else:
                                        temp['group']       = debtGroupCell[0:1] + ' GROUP'
                                        temp['month']       = today.strftime("%b-%y")
                                        temp['due']         = due[debtGroupCell[1:3]]
                                        temp['product']     = groupProductCell['value']
                                        if todayTimeStamp > dueDayOfMonth['due_date_add_1']:
                                            temp['due_date']= dueDayOfMonth['due_date_add_1']
                                        else:
                                            temp['due_date']= dueDayLastMonth['due_date_add_1']
                                        temp['due_date']    = todayTimeStamp - 86400
                                        temp['day']         = dpWorkingdaysdaycol[key]
                                        temp['day_code']    = key
                                        temp['team_name']   = groupCell['name']
                                        temp['team_id']     = str(groupCell['_id'])
                                        temp['created_at']  = time.time()
            temp_card_10_days = {}
            lnjc05_aggregate = [{
                '$match': {
                    'group_id': 'A' + report_day['debt_group'],
                }
            }]
            lnjc05_info = list(
                mongodb.aggregate_pipeline(
                    MONGO_COLLECTION=common.getSubUser(subUserType,
                                                       lnjc05_today),
                    aggregate_pipeline=lnjc05_aggregate))
            temp_sibs_10_days['group_2_tran_no'] = len(lnjc05_info)
            mongodb.update(MONGO_COLLECTION=collection,
                           WHERE={
                               'for_month': str(report_day['for_month']),
                               'for_year': str(report_day['for_year']),
                               'debt_group': 'A' + report_day['debt_group'],
                               'prod_name': 'Bike/PL'
                           },
                           VALUE=temp_sibs_10_days)

            list_acc_info_temp = list(
                mongodb.get(MONGO_COLLECTION=common.getSubUser(
                    subUserType, list_of_acc_today),
                            SELECT=['account_number']))
            list_acc_info = list(
                common.array_column(list_acc_info_temp, 'account_number'))
            check_with_store = list(
                mongodb.get(MONGO_COLLECTION=common.getSubUser(
                    subUserType, sbv_store),
                            WHERE={
                                'contract_no': {
            if header['field'] == 'assign' and value == '':
                temp['createdBy'] = ''
                temp['assign_name'] = ''

            temp[header['field']] = value
            temp['id_import'] = importLogId

            temp['createdAt'] = int(time.time())
            temp['updatedAt'] = int(time.time())
            temp['updatedBy'] = 'system'
            header_index += 1

        if checkErr == False:
            try:
                mongodb.update(MONGO_COLLECTION=collection,
                               WHERE={'id_no': temp['id_no']},
                               VALUE=temp)
            except Exception as e:
                now_log = datetime.now()
                # log.write(now_log.strftime("%d/%m/%Y, %H:%M:%S") + ': ' + str(e) + '\n')

    if len(errorData) <= 0:
        # mongodb.insert('2_Assign_log', arrayCMND)
        status = 1
    else:
        status = 0
        # print(errorData)
        # log.write( str(errorData) + '\n')

    mongodb.update(MONGO_COLLECTION='TS_Import',
                   WHERE={'_id': ObjectId(importLogId)},
               }
            },
            {
               "$group":
               {
                  "_id": '$DPD',
                  "sum_acc": {'$sum': 1},
                  "sum_amount": {'$sum': '$amount'},
               }
            }
         ]
         data = mongodb.aggregate_pipeline(MONGO_COLLECTION=collection_temp,aggregate_pipeline=aggregate_pipeline)
         if data != None:
            for row_result in data:
               if(row_result['_id'] == '<30'):
                  modified = mongodb.update(MONGO_COLLECTION=collection_amount_report,WHERE=where,VALUE={'outsoucing.account.before.l30.T'+str(lastMonth) :row_result['sum_acc'], 'outsoucing.amount.before.l30.T'+str(lastMonth) : row_result['sum_amount']})
               elif(row_result['_id'] == '30+'):
                  modified = mongodb.update(MONGO_COLLECTION=collection_amount_report,WHERE=where,VALUE={'outsoucing.account.before.l30.T'+str(lastMonth) :row_result['sum_acc'], 'outsoucing.amount.before.l30.T'+str(lastMonth) : row_result['sum_amount']})
               elif(row_result['_id'] == '60+'):
                  modified = mongodb.update(MONGO_COLLECTION=collection_amount_report,WHERE=where,VALUE={'outsoucing.account.before.p60.T'+str(lastMonth) :row_result['sum_acc'], 'outsoucing.amount.before.p60.T'+str(lastMonth) : row_result['sum_amount']})
               elif(row_result['_id'] == '90+'):
                  modified = mongodb.update(MONGO_COLLECTION=collection_amount_report,WHERE=where,VALUE={'outsoucing.account.before.p90.T'+str(lastMonth) :row_result['sum_acc'], 'outsoucing.amount.before.p90.T'+str(lastMonth) : row_result['sum_amount']})
               elif(row_result['_id'] == '180+'):
                  modified = mongodb.update(MONGO_COLLECTION=collection_amount_report,WHERE=where,VALUE={'outsoucing.account.before.p180.T'+str(lastMonth):row_result['sum_acc'], 'outsoucing.amount.before.p180.T'+str(lastMonth) : row_result['sum_amount']})
               else: continue


         # tinh subtotal
         aggregate_pipeline = [
            {
               '$match' : {
示例#19
0
                zaccf['error_mesg'] = 'Sai kiểu dữ liệu nhập'
                zaccf['result'] = 'error'
                result = False
            
            if(result == False):
                errorData.append(zaccf)
            else:
                if(checkSibs is None):
                    insertData.append(zaccf)
                else:
                    updateData.append(zaccf)
                zaccf['result'] = 'success'
                result = True
        else:
            continue

    if(len(errorData) > 0):
        mongodb.batch_insert(common.getSubUser(subUserType, 'Sibs_result'), errorData)
    else:
        if len(updateData) > 0:
            for upData in updateData:
                mongodb.update(MONGO_COLLECTION=collection, WHERE={'account_no': upData['account_no']}, VALUE=upData)
            mongodb.batch_insert(common.getSubUser(subUserType, 'Sibs_result'), updateData)
        if len(insertData) > 0:
            mongodb.batch_insert(MONGO_COLLECTION=collection, insert_data=insertData)
            mongodb.batch_insert(common.getSubUser(subUserType, 'Sibs_result'), insert_data=insertData)
    
    mongodb.update(MONGO_COLLECTION=common.getSubUser(subUserType, 'Import'), WHERE={'_id': ObjectId(importLogId)}, VALUE={'status': 1, 'complete_import': time.time()})
    pprint({'status': 1})
except Exception as e:
    log.write(now.strftime("%d/%m/%Y, %H:%M:%S") + ': ' + str(e) + '\n')
示例#20
0
            temp['daily_no'] = temp['start_no']

            checkYesterDay = mongodb.count(MONGO_COLLECTION=collection,
                                           WHERE={
                                               'createdAt':
                                               dueDayOfMonth['due_date'],
                                               'debt_group':
                                               duedate_type,
                                               'type':
                                               targetGroup['debt_type']
                                           })
            if len(temp_final) > 0:
                mongodb.update(MONGO_COLLECTION=collection,
                               WHERE={
                                   'createdAt': dueDayOfMonth['due_date'],
                                   'debt_group': duedate_type,
                                   'type': targetGroup['debt_type']
                               },
                               VALUE=temp_final)

        # if todayTimeStamp > dueDayOfMonth['due_date_add_1']:
        # temp['due_date'] = dueDayOfMonth['due_date']
        else:
            if targetGroup['debt_type'] == 'SIBS':
                aggregate_lnjc05 = [{
                    "$match": {
                        "group_id": duedate_type,
                    }
                }, {
                    "$group": {
                        "_id": 'null',
示例#21
0
             '_' + str(report_year)] = sum(
                 map(
                     lambda x: float(x),
                     zaccf['group_3_over_w_org']
                     if 'group_3_over_w_org'
                     in zaccf.keys() else 0))
 temp_detail['group_3_over_acc_count_' + str(
     report_month
 ) + '_' + str(report_year)] = zaccf[
     'group_3_over_acc_count'] if 'group_3_over_acc_count' in zaccf.keys(
     ) else 0
 # pprint(temp_detail)
 mongodb.update(MONGO_COLLECTION=collection,
                WHERE={
                    'group_code': product['group_code'],
                    'int_rate': zaccf['_id'],
                    'year': year
                },
                VALUE=temp_detail)
 temp_total['total_w_org_' + str(report_month) + '_' +
            str(report_year)] += temp_detail[
                'total_w_org_' + str(report_month) + '_' +
                str(report_year)]
 temp_total['total_acc_count_' + str(report_month) + '_' +
            str(report_year)] += temp_detail[
                'total_acc_count_' + str(report_month) +
                '_' + str(report_year)]
 temp_total['group_2_w_org_' + str(report_month) + '_' +
            str(report_year)] += temp_detail[
                'group_2_w_org_' + str(report_month) + '_' +
                str(report_year)]
示例#22
0
                        result = True
                        complete += 1

    if (len(errorData) > 0):
        mongodbresult.remove_document(
            MONGO_COLLECTION=common.getSubUser(subUserType, (
                'Lawsuit_' + str(year) + str(month) + str(day))))
        mongodbresult.batch_insert(
            common.getSubUser(
                subUserType, ('Lawsuit_' + str(year) + str(month) + str(day))),
            errorData)
        mongodb.update(MONGO_COLLECTION=common.getSubUser(
            subUserType, 'Import'),
                       WHERE={'_id': importLogId},
                       VALUE={
                           'status': 0,
                           'complete_import': time.time(),
                           'total': total,
                           'complete': complete
                       })
    else:
        if len(insertData) > 0:
            mongodb.batch_insert(MONGO_COLLECTION=collection,
                                 insert_data=insertData)
            pprint("TEST")
        mongodb.update(MONGO_COLLECTION=common.getSubUser(
            subUserType, 'Import'),
                       WHERE={'_id': importLogId},
                       VALUE={
                           'status': 1,
                           'complete_import': time.time(),
                                    'tar_acc'] - temp_old['col']
                                temp_old['ratio_acc'] = 1 - (
                                    temp_old['paid_acc'] / temp_old['tar_acc']
                                    if temp_old['tar_acc'] != 0 else 0)
                                temp_old['paid_amt'] = temp_old[
                                    'tar_amt'] - temp_old['total_amt']
                                temp_old['ratio_amt'] = 1 - (
                                    temp_old['paid_amt'] / temp_old['tar_amt']
                                    if temp_old['tar_amt'] != 0 else 0)

                                oldReport['col_end_day'] = oldReport[
                                    'col'] - temp_old['col']
                                oldReport['amt_end_day'] = oldReport[
                                    'total_amt'] - temp_old['total_amt']
                                mongodb.update(
                                    MONGO_COLLECTION=collection,
                                    WHERE={'_id': ObjectId(oldReport['_id'])},
                                    VALUE=oldReport)

                                oldReportData = mongodb.get(
                                    MONGO_COLLECTION=collection,
                                    WHERE={
                                        'team_id': str(groupCell['_id']),
                                        'due_date_code': debtGroupCell[1:3],
                                        'month': str(oldMonth)
                                    })
                                if oldReportData != None:
                                    for oldReportDt in oldReportData:
                                        temp_old['pay_amt'] += oldReportDt[
                                            'pay_amt']

                                temp_old['createdAt'] = time.time()