Commit b6ad8620 by Javier

Anyado un caso especial para facturar un número 900 de esencial pool a l numero generlal e ellos

parent 6cf85f24
...@@ -252,7 +252,8 @@ def cdr_insert_update_cdr_fijos(path_filenames: list, cursor_wifi): ...@@ -252,7 +252,8 @@ def cdr_insert_update_cdr_fijos(path_filenames: list, cursor_wifi):
cursor_wifi (Cursor): Cursor DB_wifi cursor_wifi (Cursor): Cursor DB_wifi
""" """
try: try:
#print(f'Ficheros a procesar: {path_filenames}') print(f'Ficheros a procesar: {path_filenames}')
logging.info('Inicializa proceso de insertar o actualizar registros en [TB_Cdr_Fibra]')
for path_file in path_filenames: for path_file in path_filenames:
if os.path.exists(path_file): if os.path.exists(path_file):
...@@ -283,8 +284,13 @@ def cdr_insert_update_cdr_fijos(path_filenames: list, cursor_wifi): ...@@ -283,8 +284,13 @@ def cdr_insert_update_cdr_fijos(path_filenames: list, cursor_wifi):
if line_parse is not None: if line_parse is not None:
try: try:
#TODO Si existe lo actualiza si no lo inserta # Si existe lo actualiza si no lo inserta
# Definir los campos clave para identificar si el registro ya existe # Definir los campos clave para identificar si el registro ya existe
# Normalizar num_origen ESTO ES UNA EXCEPCION PAR UN DESVIO DE ESENCIL POOL
if line_parse["num_origen"] == '900920902':
line_parse["num_origen"] = '856032903'
campos_clave = ( campos_clave = (
line_parse["num_origen"], line_parse["num_origen"],
line_parse["num_destino"], line_parse["num_destino"],
...@@ -328,8 +334,8 @@ def cdr_insert_update_cdr_fijos(path_filenames: list, cursor_wifi): ...@@ -328,8 +334,8 @@ def cdr_insert_update_cdr_fijos(path_filenames: list, cursor_wifi):
line_parse["campo13"], line_parse["campo14"], line_parse["fecha_inicio"], line_parse["fecha_fin"], line_parse["campo13"], line_parse["campo14"], line_parse["fecha_inicio"], line_parse["fecha_fin"],
line_parse["otra_fecha"], line_parse["campo18"])) line_parse["otra_fecha"], line_parse["campo18"]))
# Confirmar los cambios en la base de datos # Confirmar los cambios en la base de datos
cursor_wifi.commit() cursor_wifi.commit()
lineas_save += 1 lineas_save += 1
except Exception as e: except Exception as e:
...@@ -340,6 +346,7 @@ def cdr_insert_update_cdr_fijos(path_filenames: list, cursor_wifi): ...@@ -340,6 +346,7 @@ def cdr_insert_update_cdr_fijos(path_filenames: list, cursor_wifi):
time_procesado = time_final - time_init time_procesado = time_final - time_init
time_procesado_fin = str(time_procesado) time_procesado_fin = str(time_procesado)
message = f'Total registros procesados con costes: {lineas_save}.' message = f'Total registros procesados con costes: {lineas_save}.'
logging.info(f'Total registros procesados con costes: {lineas_save}.')
cursor_wifi.execute( cursor_wifi.execute(
"UPDATE TB_CDR_Ficheros SET processed_at=?, Num_Reg_Pro=?, Time_Procesado=?,Observaciones=? WHERE filename=?", "UPDATE TB_CDR_Ficheros SET processed_at=?, Num_Reg_Pro=?, Time_Procesado=?,Observaciones=? WHERE filename=?",
...@@ -358,6 +365,7 @@ def cdr_insert_update_cdr_fijos(path_filenames: list, cursor_wifi): ...@@ -358,6 +365,7 @@ def cdr_insert_update_cdr_fijos(path_filenames: list, cursor_wifi):
os.remove(path_file) os.remove(path_file)
else: else:
print(f'⚠️ El fichero no existe: {path_file}') print(f'⚠️ El fichero no existe: {path_file}')
logging.warning(f'⚠️ El fichero no existe: {path_file}')
except Exception as e: except Exception as e:
message = f'Total registros procesados con costes: {lineas_save}.' message = f'Total registros procesados con costes: {lineas_save}.'
......
...@@ -16,6 +16,7 @@ if __name__ == '__main__': ...@@ -16,6 +16,7 @@ if __name__ == '__main__':
# PROCESA ficheros de fijos y los inserta o actualiza en tb_CDR_fijos # PROCESA ficheros de fijos y los inserta o actualiza en tb_CDR_fijos
x.save_cdr_fijos_into_database() """ x.save_cdr_fijos_into_database() """
# Se ejecuta con un crontab
### -- Accede al SFTP de fibra y descarga el fichero que le toca y crea registro en tb_cdr_ficheros -- ### ### -- Accede al SFTP de fibra y descarga el fichero que le toca y crea registro en tb_cdr_ficheros -- ###
manager = ManagerCdrFijosFibra() manager = ManagerCdrFijosFibra()
manager.get_cdr_filename_download_fijos_fibra() manager.get_cdr_filename_download_fijos_fibra()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment