if day == 1:
        mongodb.create_db(DB_NAME=logDbName)
        mongodbresult = Mongodb(logDbName, WFF_ENV=wff_env)
    else:
        mongodbresult = Mongodb(logDbName, WFF_ENV=wff_env)
    
    ftpLocalUrl = common.getDownloadFolderByDate(yesterday.strftime("%Y%m%d")) + fileName

    try:
        sys.argv[1]
        importLogId = str(sys.argv[1])
        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):
            user_info = list(_mongodb.get(MONGO_COLLECTION=common.getSubUser(subUserType, 'User'), SELECT={'extension'}))
            user = common.array_column(user_info, 'extension')
            notification = {
                'title'     : f'Import {fileName} error',
                'active'    : True,
                'icon'      : 'fa fa-exclamation-triangle',
                'color'     : 'text-warning',
                'content'   : f'Không có file import đầu ngày <b style="font-size: 15px">{ftpLocalUrl}</b>. Xin vui lòng thông báo cho bộ phận IT',
                'link'      : '/manage/data/import_file',
                'to'        : list(user),
                'notifyDate': datetime.utcnow(),
                'createdBy' : 'System',
                'createdAt' : time.time()
            }
            mongodb.insert(MONGO_COLLECTION=common.getSubUser(subUserType, 'Notification'), insert_data=notification)
            sys.exit()
Example #2
0
    complete = 0
    today = date.today()

    fileOutput = base_url + 'upload/telesales/export/Calling_list_' + today.strftime(
        "%d%m%Y") + '.xlsx'
    model = list(
        _mongodb.get(MONGO_COLLECTION='Model',
                     WHERE={
                         'collection':
                         common.getSubUser(subUserType, 'Telesalelist'),
                         'sub_type': {
                             '$ne': None
                         }
                     },
                     SORT=[('index', 1)]))
    model_field = list(common.array_column(model, 'field'))
    model_field.insert(0, 'starttime_call')
    model_title = list(common.array_column(model, 'title'))
    model_title.insert(0, 'Nearest Call')
    try:
        sys.argv[1]
        exportLogId = str(sys.argv[1])
        exportLogInfo = mongodb.getOne(MONGO_COLLECTION=common.getSubUser(
            subUserType, 'Export'),
                                       WHERE={'_id': ObjectId(exportLogId)})
        if exportLogInfo['filter'] not in [None, [], "[]"]:
            filter_value = json.loads(exportLogInfo['filter'])
            report_data = list(
                mongodb.get(MONGO_COLLECTION=collection,
                            WHERE=filter_value[0]['$match']))
        else:
            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': {
                                    '$in': list_acc_info
                                },
                                'overdue_indicator': 'A',
                                'kydue': report_day['debt_group']
                            }))
            temp_card_10_days['group_2_tran_no'] = len(check_with_store)
            mongodb.update(MONGO_COLLECTION=collection,
                           WHERE={
                               'for_month': str(report_day['for_month']),
                               'for_year': str(report_day['for_year']),
Example #4
0
    total['group_2_acc_count_' + str(report_month) + '_' +
          str(report_year)] = 0
    total['group_2_overdue_ratio_' + str(report_month) + '_' +
          str(report_year)] = 0
    total['group_3_over_w_org_' + str(report_month) + '_' +
          str(report_year)] = 0
    total['group_3_over_acc_count_' + str(report_month) + '_' +
          str(report_year)] = 0
    total['group_3_over_overdue_ratio_' + str(report_month) + '_' +
          str(report_year)] = 0

    for product in products:
        # pprint(product['code'])
        if product['group_code'] not in ['300']:
            list_product_code = list(
                common.array_column(product['product_code'], 'code'))
            temp_total = {
                'group_code': product['group_code'],
                'int_rate': product['group_code'] + ' Total',
                'int_rate_name': product['group_name'] + ' Total',
                'year': year,
            }
            temp_total['total_w_org_' + str(report_month) + '_' +
                       str(report_year)] = 0
            temp_total['total_acc_count_' + str(report_month) + '_' +
                       str(report_year)] = 0
            temp_total['group_2_w_org_' + str(report_month) + '_' +
                       str(report_year)] = 0
            temp_total['group_2_acc_count_' + str(report_month) + '_' +
                       str(report_year)] = 0
            temp_total['group_2_overdue_ratio_' + str(report_month) + '_' +