Example #1
0
                        WHERE={'cmnd': temp['cmnd']})
                    if (checkAppointment.count() > 0):
                        temp['updated_at'] = time.time()
                        temp['updated_by'] = 'system'
                        temp['update_import_id'] = str(importLogId)
                        updateData.append(temp)
                    else:
                        temp['created_at'] = time.time()
                        temp['created_by'] = 'system'
                        temp['import_id'] = str(importLogId)
                        insertData.append(temp)
                    result = True
                    complete += 1

                mongodb.batch_update(MONGO_COLLECTION=common.getSubUser(
                    subUserType, 'Telesalelist'),
                                     WHERE={'id_no': temp['cmnd']},
                                     VALUE={'app_status': temp['status']})
    else:
        with open(importLogInfo['file_path'],
                  'r',
                  newline='\n',
                  encoding='utf-16') as fin:
            csv_reader = csv.reader(fin, delimiter=';', quotechar='"')
            for idx, row in enumerate(csv_reader):
                if row['cmnd'] not in ['', None]:
                    total += 1
                    result = True
                    temp = {}
                    for keyCell, cell in enumerate(row):
                        if keyCell <= len(modelColumns) - 1:
                            try:
            lnjc05Data = mongodb.getOne(
                MONGO_COLLECTION=lnjc05_collection,
                WHERE={'account_number': str(row['account_number'])})
            if lnjc05Data != None:
                accountYes.append(row['account_number'])
            else:
                accountNo.append(row['account_number'])

    print(len(accountYes))
    temp['coNoHayKhong'] = 'Y'
    mongodb.batch_update(MONGO_COLLECTION=ln3206_collection,
                         WHERE={
                             'account_number': {
                                 '$in': accountYes
                             },
                             "created_at": {
                                 '$gte': todayTimeStamp,
                                 '$lte': endTodayTimeStamp
                             }
                         },
                         VALUE=temp)
    temp['coNoHayKhong'] = 'N'
    mongodb.batch_update(MONGO_COLLECTION=ln3206_collection,
                         WHERE={
                             'account_number': {
                                 '$in': accountNo
                             },
                             "created_at": {
                                 '$gte': todayTimeStamp,
                                 '$lte': endTodayTimeStamp
                             }