edoc serv
This commit is contained in:
@@ -73,22 +73,22 @@ def _get_file_name(**kwargs) -> str:
|
||||
# --- FUNCIONES DE SERVICIO ---
|
||||
|
||||
async def obtener_edoc(**kwargs):
|
||||
|
||||
credencial = kwargs.get('credencial', {})
|
||||
usuario = credencial.get('user', '')
|
||||
password = credencial.get('password', '')
|
||||
doc = kwargs.get('edoc', {})
|
||||
numero_documento = kwargs['edoc'].get('numero_edocument', '')
|
||||
soap_headers = {
|
||||
'Content-Type': 'text/xml; charset=utf-8',
|
||||
'SOAPAction': 'http://tempuri.org/IServicioEdocument/GetDocumento'
|
||||
}
|
||||
soap_xml = edocs_vu_controller.generate_edocument_template(username=usuario, password=password, idEDocument=numero_documento)
|
||||
print(soap_xml)
|
||||
response = await edocs_vu_controller.make_request_async(
|
||||
"Ventanilla-HA/ServicioEdocument/ServicioEdocument.svc",
|
||||
data=soap_xml,
|
||||
headers=soap_headers
|
||||
)
|
||||
print(response.text)
|
||||
if response is None:
|
||||
raise Exception("No se obtuvo respuesta del servicio SOAP.")
|
||||
|
||||
@@ -139,10 +139,12 @@ async def obtener_edoc(**kwargs):
|
||||
logger.info("Documento enviado, actualizando status de Edoc")
|
||||
|
||||
edoc_status_response = await change_edocument_status(
|
||||
edoc=kwargs.get('edoc'),
|
||||
edoc=doc,
|
||||
status=True,
|
||||
pedimento=pedimento
|
||||
)
|
||||
|
||||
print(edoc_status_response)
|
||||
|
||||
return {
|
||||
"document_response": rest_response,
|
||||
@@ -155,7 +157,7 @@ async def obtener_edoc(**kwargs):
|
||||
async def change_edocument_status(edoc: dict, status: bool, pedimento: dict):
|
||||
data = {
|
||||
"id": edoc.get("id"),
|
||||
"edocument_descargado": status,
|
||||
"acuse_descargado": status,
|
||||
"numero_edocument": edoc.get("numero_edocument"),
|
||||
"pedimento": pedimento.get("id"),
|
||||
"organizacion": pedimento.get("organizacion"),
|
||||
@@ -165,31 +167,7 @@ async def change_edocument_status(edoc: dict, status: bool, pedimento: dict):
|
||||
|
||||
return response
|
||||
|
||||
async def obtener_edocs_masivo(**kwargs):
|
||||
logger.info("Iniciando la orquestación de descarga masiva de Edocs.")
|
||||
numeros_documentos = kwargs.get("edocs", [])
|
||||
if not numeros_documentos:
|
||||
return {"status": "warning", "message": "No se encontraron números de documento para procesar."}
|
||||
|
||||
for edoc in numeros_documentos:
|
||||
try:
|
||||
logger.info(f"Procesando Edoc: {edoc.get('numero_edocument', 'N/A')}")
|
||||
edoc = {
|
||||
"edoc": edoc,
|
||||
"pedimento": kwargs.get("pedimento"),
|
||||
"credencial": kwargs.get("credencial")
|
||||
}
|
||||
await obtener_edoc(**edoc)
|
||||
logger.info(f"Edoc {edoc.get('numero_edocument', 'N/A')} procesado exitosamente.")
|
||||
except Exception as e:
|
||||
logger.error(f"Error procesando Edoc {edoc.get('numero_edocument', 'N/A')}: {str(e)}", exc_info=True)
|
||||
continue # Continuar con el siguiente edoc en caso de error
|
||||
|
||||
return {
|
||||
"status": "pending",
|
||||
"total_documentos": len(numeros_documentos),
|
||||
"message": "La orquestación de descarga masiva ha sido registrada."
|
||||
}
|
||||
|
||||
|
||||
def extract_pdf_bytes_from_xml_content(xml_content: str):
|
||||
|
||||
Reference in New Issue
Block a user