try: data = [] insertData = [] PaymentData = [] now = datetime.now() # log.write(now.strftime("%d/%m/%Y, %H:%M:%S") + ': Start Import' + '\n') lawsuit_fields = _mongodb.getOne(MONGO_COLLECTION=jsonData_collection, SELECT=['data'], WHERE={'name': 'lawsuit fields'}) raa_fields = _mongodb.getOne(MONGO_COLLECTION=jsonData_collection, SELECT=['data'], WHERE={'name': 'Raa fields'}) users = _mongodb.get(MONGO_COLLECTION=user_collection, SELECT=['extension', 'agentname'], WHERE={'active': 'true'}) i = 1 # LNJC05 aggregate_pipeline = [{ "$lookup": { "from": action_code_collection, "localField": "account_number", "foreignField": "account_number", "as": "detail" } }] data = mongodb.aggregate_pipeline(MONGO_COLLECTION=lnjc05_collection, aggregate_pipeline=aggregate_pipeline) for idx, row in enumerate(data):
else: mongodbresult = Mongodb(logDbName, wff_env) ftpLocalUrl = common.getDownloadFolder() + 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() }
"acc_arr": { '$push': '$account_number' }, } }] data_acc = mongodb.aggregate_pipeline(MONGO_COLLECTION=account_collection, aggregate_pipeline=aggregate_acc) account_number_arr = [] for row in data_acc: account_number_arr = row['acc_arr'] accountInfo = mongodb.get(MONGO_COLLECTION=account_collection, WHERE={ 'account_number': { '$in': account_number_arr, '$nin': blockCard_arr } }) if accountInfo != None: for acc_row in accountInfo: temp = { 'index': i, 'account_number': acc_row['account_number'], 'customer_name': acc_row['cus_name'], 'block': 'true', 'acll': '', 'sibs': '', 'group_3_over_other_bank': '', 'createdBy': 'system', 'report_date': todayTimeStamp,
ftp.connect(host=ftpConfig['host'], username=ftpConfig['username'], password=ftpConfig['password']) ftp.downLoadFile(ftpLocalUrl, ftpInfo['filename']) ftp.close() importLogInfo = { 'collection' : collection, 'begin_import' : time.time(), 'file_name' : ftpInfo['filename'], 'file_path' : ftpLocalUrl, 'source' : 'ftp', 'status' : 2, 'created_by' : 'system' } importLogId = mongodb.insert(MONGO_COLLECTION=common.getSubUser(subUserType, 'Import'), insert_data=importLogInfo) modelInfo = _mongodb.get(MONGO_COLLECTION='Model', WHERE={'collection': collection, 'sub_type': {'$ne': None}}, SORT=[('index', 1)]) for model in modelInfo: modelColumns.append(model['field']) if(model['type'] == 'timestamp'): modelFormat[model['field']] = "%d/%m/%Y" else: modelFormat[model['field']] = "" modelConverters[model['field']] = model['type'] with open(file=importLogInfo['file_path'], mode='r', newline='\n', encoding='ISO-8859-1') as fin: for line in fin: row = line.split(',') if len(row) > 1: if isinstance(row[1], str) and len(row[1]) > 12 and row[1].isdigit(): temp = {}
time.strptime(str(todayString + " 23:59:59"), "%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.get( MONGO_COLLECTION=common.getSubUser(subUserType, 'Report_off_sys')) listHoliday = map(lambda offDateRow: {offDateRow['off_date']}, holidayOfMonth) if todayTimeStamp in listHoliday: sys.exit() mongodb.remove_document(MONGO_COLLECTION=collection, WHERE={ 'createdAt': { '$gte': todayTimeStamp, '$lte': endTodayTimeStamp } }) debtGroup = _mongodb.getOne(MONGO_COLLECTION=jsonData_collection,
# ftp.downLoadFile(ftpLocalUrl, ftpInfo['filename']) # ftp.close() importLogInfo = { 'collection' : collection, 'begin_import' : time.time(), 'file_name' : ftpInfo['filename'], 'file_path' : ftpLocalUrl, 'source' : 'ftp', 'status' : 2, 'command' : 'python3.6 ' + base_url + "cronjob/python/Loan/importLN3206F.py > /dev/null &", 'created_by' : 'system' } importLogId = mongodb.insert(MONGO_COLLECTION=common.getSubUser(subUserType, 'Import'), insert_data=importLogInfo) models = _mongodb.get(MONGO_COLLECTION='Model', WHERE={'collection': collection,'sub_type':{'$exists': 'true'}}, SORT=[('index', 1)], SELECT=['index', 'collection', 'field', 'type', 'sub_type'], TAKE=1000) for model in models: modelColumns.append(model['field']) modelConverters[model['field']] = model['type'] subtype = json.loads(model['sub_type']) if 'format' in subtype.keys(): modelFormat[model['field']] = subtype['format'] else: modelFormat[model['field']] = '' if 'update_key' in subtype.keys() and subtype['update_key'] == 1: updateKey.append(model['field']) if 'check_null_key' in subtype.keys():
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.get( MONGO_COLLECTION=common.getSubUser(subUserType, 'Report_off_sys')) listHoliday = map(lambda offDateRow: {offDateRow['off_date']}, holidayOfMonth) # if todayTimeStamp in listHoliday or (weekday == 5) or weekday == 6: # sys.exit() todayString = today.strftime("%d/%m/%Y") starttime = int( time.mktime( time.strptime(str(todayString + " 00:00:00"), "%d/%m/%Y %H:%M:%S"))) endtime = int( time.mktime( time.strptime(str(todayString + " 23:59:59"), "%d/%m/%Y %H:%M:%S")))
subUserType = 'TS' collection = common.getSubUser(subUserType, 'Telesalelist') try: total = 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, [], "[]"]:
insertData = [] PaymentData = [] now = datetime.now() # log.write(now.strftime("%d/%m/%Y, %H:%M:%S") + ': Start Import' + '\n') # SIBS count = mongodb.count(MONGO_COLLECTION=lnjc05_collection) quotient = int(count) / 10000 mod = int(count) % 10000 if quotient != 0: for x in range(int(quotient)): result = mongodb.get(MONGO_COLLECTION=lnjc05_collection, SELECT=[ 'overdue_amount_this_month', 'advance_balance', 'installment_type', 'group_id', 'account_number', 'mobile_num', 'cus_name' ], SORT=([('_id', -1)]), SKIP=int(x * 10000), TAKE=int(10000)) for idx, row in enumerate(result): if (float(row['overdue_amount_this_month']) - float(row['advance_balance']) > 40000) or (float(row['overdue_amount_this_month']) - float(row['advance_balance']) < 40000 and row['installment_type'] == 'n'): data.append(row) if int(mod) > 0: result = mongodb.get(MONGO_COLLECTION=lnjc05_collection, SELECT=[
try: data = [] insertData = [] PaymentData = [] now = datetime.now() # log.write(now.strftime("%d/%m/%Y, %H:%M:%S") + ': Start Import' + '\n') # LN3206F count = mongodb.count(MONGO_COLLECTION=ln3206_collection) quotient = int(count) / 10000 mod = int(count) % 10000 if quotient != 0: for x in range(int(quotient)): result = mongodb.get(MONGO_COLLECTION=ln3206_collection, SELECT=['account_number', 'amt', 'date'], SORT=([('_id', -1)]), SKIP=int(x * 10000), TAKE=int(10000)) for idx, row in enumerate(result): data.append(row) if int(mod) > 0: result = mongodb.get(MONGO_COLLECTION=ln3206_collection, SELECT=['account_number', 'amt', 'date'], SORT=([('_id', -1)]), SKIP=int(int(quotient) * 10000), TAKE=int(mod)) for idx, row in enumerate(result): data.append(row) for row in data:
} },{ "$group": { "_id": 'null', "acc_arr": {'$push': '$account_number'}, } } ] data_acc = mongodb.aggregate_pipeline(MONGO_COLLECTION=account_collection,aggregate_pipeline=aggregate_acc) account_number_arr = [] for row in data_acc: account_number_arr = row['acc_arr'] accountInfo = mongodb.get(MONGO_COLLECTION=account_collection,WHERE={'account_number': {'$in' : account_number_arr}}) if accountInfo != None: i = 1 for acc_row in accountInfo: temp = { 'index' : i, 'account_number' : acc_row['account_number'], 'name' : acc_row['cus_name'], 'block' : 'true', 'accl' : '', 'sibs' : '', 'group' : '', 'createdBy' : 'system', 'createdAt' : time.time() } groupInfo = mongodb.getOne(MONGO_COLLECTION=group_collection,WHERE={'account_number': acc_row['account_number']})
time.strptime(str(todayString + " 23:59:59"), "%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.get( MONGO_COLLECTION=common.getSubUser(subUserType, 'Report_off_sys')) listHoliday = map(lambda offDateRow: {offDateRow['off_date']}, holidayOfMonth) if todayTimeStamp in listHoliday: sys.exit() mongodb.remove_document(MONGO_COLLECTION=collection, WHERE={ 'createdAt': { '$gte': todayTimeStamp, '$lte': endTodayTimeStamp } }) price = mongodb.getOne(MONGO_COLLECTION=config_collection,
# today = datetime.strptime('12/10/2019', "%d/%m/%Y").date() day = today.day 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"))) endTodayTimeStamp = int(time.mktime(time.strptime(str(todayString + " 23:59:59"), "%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.get(MONGO_COLLECTION=common.getSubUser(subUserType, 'Report_off_sys')) listHoliday = map(lambda offDateRow: {offDateRow['off_date']}, holidayOfMonth) if todayTimeStamp in listHoliday: sys.exit() mongodb.remove_document(MONGO_COLLECTION=collection, WHERE={'createdAt': {'$gte': todayTimeStamp, '$lte': endTodayTimeStamp} }) users = _mongodb.get(MONGO_COLLECTION=user_collection, SELECT=['extension','agentname'],SORT=([('_id', -1)]),SKIP=0, TAKE=200) # writeOf aggregate_pipeline = [ {
endtime = int( time.mktime( time.strptime(str(todayString + " 23:59:59"), "%d/%m/%Y %H:%M:%S"))) # Check hom nay co phai la ngay cuoi thang if day != 1: pprint('khong phai ngay 1') sys.exit() report_month = lastMonthMonth report_year = lastMonthYear products = list( mongodb.get(MONGO_COLLECTION=common.getSubUser(subUserType, 'Product_group'), SORT=[("group_code", 1)])) total = { 'group': 'total', 'int_rate': 'total', 'int_rate_name': 'JIVF TOTAL', 'year': year, } total['total_w_org_' + str(report_month) + '_' + str(report_year)] = 0 total['total_acc_count_' + str(report_month) + '_' + str(report_year)] = 0 total['group_2_w_org_' + str(report_month) + '_' + str(report_year)] = 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
# today = date.today() today = datetime.strptime('20/11/2019', "%d/%m/%Y").date() day = today.day 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.get(MONGO_COLLECTION=common.getSubUser(subUserType, 'Report_off_sys')) listHoliday = map(lambda offDateRow: {offDateRow['off_date']}, holidayOfMonth) # if todayTimeStamp in listHoliday or (weekday == 5) or weekday == 6: # sys.exit() todayString = today.strftime("%d/%m/%Y") starttime = int(time.mktime(time.strptime(str(todayString + " 00:00:00"), "%d/%m/%Y %H:%M:%S"))) endtime = int(time.mktime(time.strptime(str(todayString + " 23:59:59"), "%d/%m/%Y %H:%M:%S"))) mainProduct = {} mainProductRaw = mongodb.get(MONGO_COLLECTION=common.getSubUser(subUserType, 'Product')) for prod in mainProductRaw: mainProduct[prod['code']] = prod['name'] debtGroup = _mongodb.getOne(MONGO_COLLECTION=common.getSubUser(subUserType, 'Jsondata'), WHERE={'tags': ['debt', 'group']})
time.strptime(str(todayString + " 23:59:59"), "%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.get( MONGO_COLLECTION=common.getSubUser(subUserType, 'Report_off_sys')) listHoliday = map(lambda offDateRow: {offDateRow['off_date']}, holidayOfMonth) if todayTimeStamp in listHoliday or (weekday == 5) or weekday == 6: sys.exit() checkYesterday = False days = 1 while checkYesterday is False: yesterday = today - timedelta(days=days) yesterdayString = yesterday.strftime("%d/%m/%Y") yesterdayTimeStamp = int( time.mktime( time.strptime(str(yesterdayString + " 00:00:00"), "%d/%m/%Y %H:%M:%S")))
modelColumns = [] modelConverters = {} modelConverters1 = [] modelPosition = {} modelPosition1 = [] modelFormat = {} modelFormat1 = [] converters = {} insertData = [] errorData = [] total = 0 complete = 0 models = _mongodb.get( MONGO_COLLECTION='Model', WHERE={'collection': common.getSubUser(subUserType, 'ZACCF')}, SORT=[('index', 1)], SELECT=['index', 'collection', 'field', 'type', 'sub_type'], TAKE=1000) for model in models: modelColumns.append(model['field']) modelConverters[model['field']] = model['type'] modelConverters1.append(model['type']) if 'sub_type' in model.keys(): subtype = json.loads(model['sub_type']) if 'format' in subtype.keys(): modelFormat[model['field']] = subtype['format'] modelFormat1.append(subtype['format']) else: modelFormat[model['field']] = '' modelFormat1.append('')
'begin_import': time.time(), 'file_name': fileName, 'file_path': ftpLocalUrl, 'source': 'ftp', 'status': 2, 'command': '/usr/local/bin/python3.6 ' + base_url + "cronjob/python/Telesales/importAppointment_cron.py > /dev/null &", 'created_by': 'system' } importLogId = mongodb.insert(MONGO_COLLECTION=common.getSubUser( subUserType, 'Import'), insert_data=importLogInfo) models = _mongodb.get( MONGO_COLLECTION='Model', WHERE={'collection': collection}, SORT=[('index', 1)], SELECT=['index', 'collection', 'field', 'type', 'sub_type']) for model in models: if 'sub_type' in model.keys(): modelColumns.append(model['field']) modelConverters[model['field']] = model['type'] modelConverters1.append(model['type']) subtype = json.loads(model['sub_type']) if 'format' in subtype.keys(): modelFormat[model['field']] = subtype['format'] modelFormat1.append(subtype['format']) else: modelFormat[model['field']] = ''
todayTimeStamp = int( time.mktime( time.strptime(str(todayString + " 00:00:00"), "%d/%m/%Y %H:%M:%S"))) # 86,399 exportPath = f"/data/upload_file/export/{tomorrowString}" Path(exportPath).mkdir(parents=True, exist_ok=True) fileOutput = exportPath + '/CDR_' + today.strftime("%d%m%Y") + '.xlsx' workbook = xlsxwriter.Workbook(fileOutput) worksheet = workbook.add_worksheet() cell_format = workbook.add_format() cell_format.set_border() reportModelRaw = list( _mongodb.get( MONGO_COLLECTION="Model", WHERE={'collection': common.getSubUser(subUserType, 'Cdr_report')}, SORT=[('index', 1)])) reportModel = {} for modelKey, modelValue in enumerate(reportModelRaw): if modelValue['field'].find('customer.') != -1: continue worksheet.write(0, modelKey, modelValue['title'], cell_format) worksheet.set_column(0, modelKey, 30) cdrInfo = list( mongodb.get(WHERE={ 'starttime': { '$gte': todayTimeStamp, '$lte': (todayTimeStamp + 86399) }
time.mktime( time.strptime(str(todayString + " 23:59:59"), "%d/%m/%Y %H:%M:%S"))) yesterday_starttime = int( time.mktime( time.strptime(str(yesterdayString + " 00:00:00"), "%d/%m/%Y %H:%M:%S"))) yesterday_endtime = int( time.mktime( time.strptime(str(yesterdayString + " 23:59:59"), "%d/%m/%Y %H:%M:%S"))) products = list( _mongodb.get(MONGO_COLLECTION=common.getSubUser( subUserType, 'Jsondata'), WHERE={'tags': ['product', 'group']}, SORT=[("code", 1)])) dueDates = list( mongodb.get(MONGO_COLLECTION=common.getSubUser(subUserType, 'Report_due_date'), WHERE={ 'for_month': { '$in': [str(lastMonthMonth), str(month)] }, 'for_year': { '$in': [str(year), str(lastMonthYear)] } }))
time.strptime(str(yesterdayString + " 00:00:00"), "%d/%m/%Y %H:%M:%S"))) endYesterdayTimeStamp = int( time.mktime( time.strptime(str(yesterdayString + " 23:59:59"), "%d/%m/%Y %H:%M:%S"))) mongodb.remove_document(MONGO_COLLECTION=collection, WHERE={ 'createdAt': { '$gte': todayTimeStamp, '$lte': endTodayTimeStamp } }) targetInfo = mongodb.get(MONGO_COLLECTION=target_collection) for targetGroup in targetInfo: if targetGroup['show_B_plus_duedate_type'] == False: duedate_type = targetGroup['duedate_type'] else: duedate_type = targetGroup['B_plus_duedate_type'] if duedate_type[1:3] == '03': if month == 1: lastmonth = 12 else: lastmonth = month - 1 else: lastmonth = month dueDayOfMonth = mongodb.getOne( MONGO_COLLECTION=report_due_date_collection,
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']) assign_name = user['agentname'] random = randoms[u] if extension in assign_log.keys():
log = open(base_url + "cronjob/python/Loan/log/exportMasterData_log.txt", "a") fileOutput = base_url + 'upload/loan/export/MasterData.xlsx' try: data = [] insertData = [] resultData = [] errorData = [] count = mongodb.count(MONGO_COLLECTION=collection) quotient = int(count) / 10000 mod = int(count) % 10000 dem = 0 if quotient != 0: for x in range(int(quotient)): result = mongodb.get(MONGO_COLLECTION=collection, SORT=([('_id', -1)]), SKIP=int(x * 10000), TAKE=int(10000)) for idx, row in enumerate(result): # if row['due_date'] != '': # due_date = datetime.fromtimestamp(row['due_date']) # row['due_date'] = due_date.strftime("%d-%m-%Y") data.append(row) if int(mod) > 0: result = mongodb.get(MONGO_COLLECTION=collection, SORT=([('_id', -1)]), SKIP=int(int(quotient) * 10000), TAKE=int(mod)) for idx, row in enumerate(result): # if row['due_date'] != '':
# today = datetime.strptime('25/03/2020', "%d/%m/%Y").date() day = today.day 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"))) endTodayTimeStamp = int(time.mktime(time.strptime(str(todayString + " 23:59:59"), "%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.get(MONGO_COLLECTION=common.getSubUser(subUserType, 'Report_off_sys')) listHoliday = map(lambda offDateRow: {offDateRow['off_date']}, holidayOfMonth) if todayTimeStamp in listHoliday: sys.exit() lawsuit_fields = _mongodb.getOne(MONGO_COLLECTION=jsonData_collection,SELECT=['data'],WHERE={'tags': ['LAWSUIT', 'fields']}) raa_fields = _mongodb.getOne(MONGO_COLLECTION=jsonData_collection,SELECT=['data'],WHERE={'tags': ['RAA', 'fields']}) users = _mongodb.get(MONGO_COLLECTION=user_collection,SELECT=['extension','agentname'],WHERE={'active': 'true'}) i = 1 # LNJC05 aggregate_pipeline = [ { "$match":
temp = { 'due_date': todayTimeStamp - 86400, 'due_date_one': todayTimeStamp, 'product': groupProduct['value'], 'debt_group': debtGroupCell[0:1], 'due_date_code': debtGroupCell[1:3], 'for_month': str(lastmonth), 'debt_acc_no': 0, 'current_balance_total': 0, 'ob_principal_total': 0, 'acc_arr': [] } if groupProduct['value'] == 'SIBS': lnjc05Info = list( mongodb.get(MONGO_COLLECTION=lnjc05_collection, WHERE={'group_id': debtGroupCell})) for lnjc05 in lnjc05Info: temp['debt_acc_no'] += 1 temp['current_balance_total'] += float( lnjc05['current_balance']) temp['ob_principal_total'] += float( lnjc05['outstanding_principal']) temp['acc_arr'].append(lnjc05['account_number']) if groupProduct['value'] == 'Card': aggregate_stored = [{ "$match": { "overdue_indicator": debtGroupCell[0:1], "kydue": debtGroupCell[1:3] } }, {
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()
year = today.year weekday = today.weekday() # todayString = time.strftime("%d/%m/%Y") todayString = '11/10/2019' todayTimeStamp = int(time.mktime(time.strptime(str(todayString + " 00:00:00"), "%d/%m/%Y %H:%M:%S"))) lastDayOfMonth = calendar.monthrange(year, month)[1] starttime = int(time.mktime(time.strptime(str(todayString + " 00:00:00"), "%d/%m/%Y %H:%M:%S"))) endtime = int(time.mktime(time.strptime(str(todayString + " 23:59:59"), "%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"))) listDueDate = mongodb.get(MONGO_COLLECTION=common.getSubUser(subUserType, 'Report_due_date'), WHERE={'due_date': {'$gte': startMonth, '$lte': endMonth}}) # lastDayOfMonth = calendar.monthrange(year, month)[1] # # todayString = time.strftime("%d/%m/%Y") # todayString = '11/10/2019' # todayTimeStamp = int(time.mktime(time.strptime(str(todayString + " 00:00:00"), "%d/%m/%Y %H:%M:%S"))) # starttime = int(time.mktime(time.strptime(str(todayString + " 00:00:00"), "%d/%m/%Y %H:%M:%S"))) # endtime = int(time.mktime(time.strptime(str(todayString + " 23:59:59"), "%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.get(MONGO_COLLECTION=common.getSubUser(subUserType, 'Report_off_sys'), WHERE={'off_date': {'$gte': startMonth, '$lte': endMonth}}) # listHoliday = map(lambda offDateRow: {offDateRow['off_date']}, holidayOfMonth)
'begin_import': time.time(), 'file_name': fileName, 'file_path': ftpLocalUrl, 'source': 'ftp', 'status': 2, 'command': '/usr/local/bin/python3.6 ' + base_url + "cronjob/python/Loan/importLawsuit.py > /dev/null &", 'created_by': 'system' } importLogId = mongodb.insert(MONGO_COLLECTION=common.getSubUser( subUserType, 'Import'), insert_data=importLogInfo) models = _mongodb.get( MONGO_COLLECTION='Model', WHERE={'collection': collection}, SORT=[('index', 1)], SELECT=['index', 'collection', 'field', 'type', 'sub_type']) for model in models: if 'sub_type' in model.keys() and model['sub_type'] not in ['', ' ']: modelColumns.append(model['field']) modelConverters[model['field']] = model['type'] modelConverters1.append(model['type']) subtype = json.loads(model['sub_type']) if 'format' in subtype.keys(): modelFormat[model['field']] = subtype['format'] modelFormat1.append(subtype['format']) else: modelFormat[model['field']] = '' modelFormat1.append('')
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.get( MONGO_COLLECTION=common.getSubUser(subUserType, 'Report_off_sys')) listHoliday = map(lambda offDateRow: {offDateRow['off_date']}, holidayOfMonth) if todayTimeStamp in listHoliday or (weekday == 5) or weekday == 6: sys.exit() todayString = today.strftime("%d/%m/%Y") starttime = int( time.mktime( time.strptime(str(todayString + " 00:00:00"), "%d/%m/%Y %H:%M:%S"))) endtime = int( time.mktime( time.strptime(str(todayString + " 23:59:59"), "%d/%m/%Y %H:%M:%S")))