worker-automate-hub 0.5.807__py3-none-any.whl → 0.5.808__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- worker_automate_hub/tasks/jobs/abertura_livros_fiscais.py +63 -112
- worker_automate_hub/utils/util.py +21 -3
- {worker_automate_hub-0.5.807.dist-info → worker_automate_hub-0.5.808.dist-info}/METADATA +1 -1
- {worker_automate_hub-0.5.807.dist-info → worker_automate_hub-0.5.808.dist-info}/RECORD +6 -6
- {worker_automate_hub-0.5.807.dist-info → worker_automate_hub-0.5.808.dist-info}/WHEEL +0 -0
- {worker_automate_hub-0.5.807.dist-info → worker_automate_hub-0.5.808.dist-info}/entry_points.txt +0 -0
@@ -67,17 +67,6 @@ async def wait_aguarde_window_closed(app, timeout=60):
|
|
67
67
|
console.log("Timeout esperando a janela Aguarde...")
|
68
68
|
|
69
69
|
|
70
|
-
def click_desconfirmar():
|
71
|
-
cords = (675, 748)
|
72
|
-
pyautogui.click(x=cords[0], y=cords[1])
|
73
|
-
|
74
|
-
|
75
|
-
def ctrl_c():
|
76
|
-
pyautogui.press("tab", presses=12) # verificar
|
77
|
-
pyautogui.hotkey("ctrl", "c")
|
78
|
-
return pyperclip.paste()
|
79
|
-
|
80
|
-
|
81
70
|
async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
82
71
|
try:
|
83
72
|
config = await get_config_by_name("login_emsys_fiscal")
|
@@ -365,10 +354,10 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
365
354
|
info_window.child_window(
|
366
355
|
class_name="Button", found_index=0
|
367
356
|
).click_input()
|
368
|
-
except
|
369
|
-
|
370
|
-
except
|
371
|
-
|
357
|
+
except:
|
358
|
+
pass
|
359
|
+
except:
|
360
|
+
pass
|
372
361
|
|
373
362
|
# Verifica se a janela TMsgBox de aviso está aberta
|
374
363
|
try:
|
@@ -378,25 +367,49 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
378
367
|
box.set_focus()
|
379
368
|
box.child_window(class_name="TBitBtn", found_index=0).click_input()
|
380
369
|
print("Clicou no botão 'TBitBtn'.")
|
381
|
-
except
|
370
|
+
except:
|
382
371
|
pass
|
383
|
-
except Exception as e:
|
384
|
-
print(f"[Erro ao procurar/clicar na TMessageForm]: {e}")
|
385
372
|
|
386
373
|
# 2. Verifica e trata janela de confirmação TMessageForm
|
387
374
|
try:
|
388
|
-
|
389
|
-
|
390
|
-
)
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
375
|
+
# img_dialog = r"C:\Users\automatehub\Documents\GitHub\worker-automate-hub\assets\abertura_livros\notas_rejeitadas.png"
|
376
|
+
img_dialog = "assets\\abertura_livros\\notas_rejeitadas.png"
|
377
|
+
if os.path.exists(img_dialog):
|
378
|
+
caixa = pyautogui.locateOnScreen(img_dialog, confidence=0.86, grayscale=True)
|
379
|
+
if caixa:
|
380
|
+
print("Janela 'notas rejeitadas' detectada por imagem.")
|
381
|
+
region = (caixa.left, caixa.top, caixa.width, caixa.height)
|
382
|
+
|
383
|
+
app_msg = Application().connect(
|
384
|
+
class_name="TMessageForm", timeout=2
|
385
|
+
)
|
386
|
+
form = app_msg["TMessageForm"]
|
387
|
+
console.print("Janela de confirmação 'TMessageForm' encontrada.")
|
388
|
+
form.set_focus()
|
389
|
+
form.child_window(class_name="TButton", found_index=1).click_input()
|
390
|
+
print("Clicou no botão de confirmação.")
|
391
|
+
|
392
|
+
await worker_sleep(5)
|
393
|
+
|
394
|
+
# img_dialog = r"C:\Users\automatehub\Documents\GitHub\worker-automate-hub\assets\abertura_livros\gerar_rel_notas_rejeitadas.png"
|
395
|
+
img_dialog = "assets\\abertura_livros\\gerar_rel_notas_rejeitadas.png"
|
396
|
+
if os.path.exists(img_dialog):
|
397
|
+
caixa = pyautogui.locateOnScreen(img_dialog, confidence=0.86, grayscale=True)
|
398
|
+
if caixa:
|
399
|
+
print("Janela 'notas rejeitadas' detectada por imagem.")
|
400
|
+
region = (caixa.left, caixa.top, caixa.width, caixa.height)
|
401
|
+
|
402
|
+
app_msg = Application().connect(
|
403
|
+
class_name="TMessageForm", timeout=2
|
404
|
+
)
|
405
|
+
form = app_msg["TMessageForm"]
|
406
|
+
console.print("Janela de confirmação 'TMessageForm' encontrada.")
|
407
|
+
form.set_focus()
|
408
|
+
form.child_window(class_name="TButton", found_index=0).click_input()
|
409
|
+
print("Clicou no botão de confirmação.")
|
410
|
+
except:
|
397
411
|
pass
|
398
|
-
|
399
|
-
print(f"[Erro ao procurar/clicar na TMessageForm]: {e}")
|
412
|
+
|
400
413
|
|
401
414
|
# 3. Verifica se a janela do relatório está aberta
|
402
415
|
try:
|
@@ -406,10 +419,9 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
406
419
|
janela = app_report["TFrmPreviewRelatorio"]
|
407
420
|
print("Janela 'TFrmPreviewRelatorio' encontrada.")
|
408
421
|
janela_aberta = True
|
409
|
-
except
|
422
|
+
except:
|
410
423
|
pass
|
411
|
-
|
412
|
-
print(f"[Erro ao procurar TFrmPreviewRelatorio]: {e}")
|
424
|
+
|
413
425
|
|
414
426
|
# Se encontrou a janela de relatório, sai
|
415
427
|
if janela_aberta:
|
@@ -444,9 +456,27 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
444
456
|
main_window = app["TFrmPreviewRelatorio"]
|
445
457
|
main_window.set_focus()
|
446
458
|
|
459
|
+
# Verificando se a foi confirmado os livres
|
460
|
+
console.print("Verificando se os livros foram confirmados")
|
461
|
+
|
462
|
+
# imagem = r"C:\Users\automatehub\Documents\GitHub\worker-automate-hub\assets\abertura_livros\confirmado_livros.png"
|
463
|
+
imagem = "assets\\abertura_livros\\confirmado_livros.png"
|
464
|
+
if os.path.exists(imagem):
|
465
|
+
caixa = pyautogui.locateOnScreen(imagem, confidence=0.9, grayscale=True)
|
466
|
+
else:
|
467
|
+
console.print("Imagem confirmada não encontrada")
|
468
|
+
return RpaRetornoProcessoDTO(
|
469
|
+
sucesso=False,
|
470
|
+
retorno=f"Erro na Abertura de Livro Fiscal: Imagem confirmada não encontrada",
|
471
|
+
status=RpaHistoricoStatusEnum.Falha,
|
472
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
473
|
+
)
|
474
|
+
|
447
475
|
# Clicar em fechar
|
448
476
|
main_window.close()
|
449
477
|
|
478
|
+
console.print("Livros confirmados")
|
479
|
+
|
450
480
|
await worker_sleep(5)
|
451
481
|
|
452
482
|
# Conecta na janela principal
|
@@ -577,86 +607,6 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
577
607
|
|
578
608
|
await worker_sleep(2)
|
579
609
|
|
580
|
-
# flag para controlar se é a primeira vez
|
581
|
-
primeira_confirmacao = True
|
582
|
-
|
583
|
-
while True:
|
584
|
-
janela_aberta = False
|
585
|
-
|
586
|
-
# 1. Verifica se a imagem apareceu e clica em 'Sim' na janela "Informação"
|
587
|
-
try:
|
588
|
-
if pyautogui.locateOnScreen(imagem, confidence=0.9):
|
589
|
-
print("Imagem 'livros_incluidos' apareceu na tela.")
|
590
|
-
try:
|
591
|
-
app_info = Application().connect(title="Informação", timeout=5)
|
592
|
-
info_window = app_info["Informação"]
|
593
|
-
info_window.set_focus()
|
594
|
-
console.print("Clicando em 'Sim' na janela Informação...")
|
595
|
-
info_window.child_window(class_name="Button", found_index=0).click_input()
|
596
|
-
except Exception as e:
|
597
|
-
print(f"Erro ao clicar em 'Sim' na janela Informação: {e}")
|
598
|
-
except Exception as e:
|
599
|
-
print(f"[Erro ao procurar imagem]: {e}")
|
600
|
-
|
601
|
-
# Verifica se a janela TMsgBox de aviso está aberta
|
602
|
-
try:
|
603
|
-
app_msgbox = Application().connect(class_name="TMsgBox", timeout=10)
|
604
|
-
box = app_msgbox["TMsgBox"]
|
605
|
-
print("Janela 'TMsgBox' encontrada.")
|
606
|
-
box.set_focus()
|
607
|
-
box.child_window(class_name="TBitBtn", found_index=0).click_input()
|
608
|
-
print("Clicou no botão 'TBitBtn'.")
|
609
|
-
except ElementNotFoundError:
|
610
|
-
pass
|
611
|
-
except Exception as e:
|
612
|
-
print(f"[Erro ao procurar/clicar na TMsgBox]: {e}")
|
613
|
-
|
614
|
-
# 2. Verifica e trata janela de confirmação TMessageForm
|
615
|
-
try:
|
616
|
-
app_msg = Application().connect(class_name="TMessageForm", timeout=2)
|
617
|
-
form = app_msg["TMessageForm"]
|
618
|
-
console.print("Janela de confirmação 'TMessageForm' encontrada.")
|
619
|
-
form.set_focus()
|
620
|
-
|
621
|
-
idx = 1 if primeira_confirmacao else 0
|
622
|
-
try:
|
623
|
-
form.child_window(class_name="TButton", found_index=idx).click_input()
|
624
|
-
print(f"Clicou no botão de confirmação (found_index={idx}).")
|
625
|
-
primeira_confirmacao = False # nas próximas vezes será 0
|
626
|
-
except Exception as e:
|
627
|
-
print(f"[Falha ao clicar no botão found_index={idx}]: {e}")
|
628
|
-
|
629
|
-
except ElementNotFoundError:
|
630
|
-
pass
|
631
|
-
except Exception as e:
|
632
|
-
print(f"[Erro ao procurar/clicar na TMessageForm]: {e}")
|
633
|
-
|
634
|
-
await worker_sleep(5)
|
635
|
-
|
636
|
-
# 3. Verifica se a janela do relatório está aberta
|
637
|
-
try:
|
638
|
-
app_report = Application().connect(class_name="TFrmPreviewRelatorio", timeout=2)
|
639
|
-
janela = app_report["TFrmPreviewRelatorio"]
|
640
|
-
print("Janela 'TFrmPreviewRelatorio' encontrada.")
|
641
|
-
janela_aberta = True
|
642
|
-
except ElementNotFoundError:
|
643
|
-
pass
|
644
|
-
except Exception as e:
|
645
|
-
print(f"[Erro ao procurar TFrmPreviewRelatorio]: {e}")
|
646
|
-
|
647
|
-
# Se encontrou a janela de relatório, sai
|
648
|
-
if janela_aberta:
|
649
|
-
print("Relatório carregado. Saindo do loop.")
|
650
|
-
break
|
651
|
-
|
652
|
-
# Verifica tempo limite
|
653
|
-
if time.time() - inicio > tempo_limite:
|
654
|
-
print("Tempo esgotado. Relatório não carregado.")
|
655
|
-
break
|
656
|
-
|
657
|
-
print("Aguardando janela de relatório... (verificando novas confirmações se houver)")
|
658
|
-
time.sleep(intervalo)
|
659
|
-
|
660
610
|
|
661
611
|
# === 5) Se não houve 'Aviso' com erro mapeado, considera sucesso ===
|
662
612
|
console.print("Nenhum erro confirmado. Fluxo OK.")
|
@@ -682,3 +632,4 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
682
632
|
status=RpaHistoricoStatusEnum.Falha,
|
683
633
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
684
634
|
)
|
635
|
+
|
@@ -339,9 +339,27 @@ async def login_emsys_fiscal(
|
|
339
339
|
message="32-bit application should be automated using 32-bit Python",
|
340
340
|
)
|
341
341
|
await worker_sleep(2)
|
342
|
-
filial_cod =
|
343
|
-
|
344
|
-
|
342
|
+
filial_cod = (
|
343
|
+
task.configEntrada.get("empresa")
|
344
|
+
or task.configEntrada.get("filialEmpresaOrigem")
|
345
|
+
or task.configEntrada.get("descricaoFilial")
|
346
|
+
)
|
347
|
+
|
348
|
+
# Extrai apenas os dígitos iniciais da string
|
349
|
+
num = None
|
350
|
+
if filial_cod is not None:
|
351
|
+
s = str(filial_cod).strip()
|
352
|
+
m = re.match(r'^(\d+)', s) # pega o número do INÍCIO
|
353
|
+
if not m:
|
354
|
+
m = re.search(r'\d+', s) # fallback: primeiro número que aparecer
|
355
|
+
if m:
|
356
|
+
num = m.group(1)
|
357
|
+
|
358
|
+
if num is None:
|
359
|
+
raise ValueError(f"Não foi possível extrair número de: {filial_cod!r}")
|
360
|
+
|
361
|
+
filial_cod = num
|
362
|
+
|
345
363
|
console.print(f"Empresa a ser processada: {filial_cod}")
|
346
364
|
|
347
365
|
try:
|
@@ -36,7 +36,7 @@ worker_automate_hub/models/dto/rpa_sap_dto.py,sha256=eovdvKCtVIhRct3PL98KjsdlngL
|
|
36
36
|
worker_automate_hub/models/dto/rpa_sistema_dto.py,sha256=sLkmJei8x6sl-1-IXUKDmYQuKx0sotYQREPyhQqPmRg,161
|
37
37
|
worker_automate_hub/tasks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
38
38
|
worker_automate_hub/tasks/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
39
|
-
worker_automate_hub/tasks/jobs/abertura_livros_fiscais.py,sha256=
|
39
|
+
worker_automate_hub/tasks/jobs/abertura_livros_fiscais.py,sha256=HYIp3eYyMc2JsMw9VGlgjxSeuQB3400_LLTyxJi9VYE,25203
|
40
40
|
worker_automate_hub/tasks/jobs/coleta_dje_process.py,sha256=UkLWTC5Ub2qBb0yY-8IZ0DLLOVJOfNTq_z9krx_t25Q,29476
|
41
41
|
worker_automate_hub/tasks/jobs/conexao_rdp.py,sha256=S6QC4xhuo0pB5FjaUJZNMm1LIgEjpjifReCTBDqxH-U,11719
|
42
42
|
worker_automate_hub/tasks/jobs/cte_manual.py,sha256=JucHpRMjMiy-QEJ0wtFnytLpN53tKXgCDI05nGLGclU,603
|
@@ -100,10 +100,10 @@ worker_automate_hub/utils/get_creds_gworkspace.py,sha256=ZJ0IIEjM4IXIV9rwfbOZ1V1
|
|
100
100
|
worker_automate_hub/utils/logger.py,sha256=FYV9fg0_RAYJF_ZOCJEbqQAiCXlXk2gMpvUU1rzT_xs,671
|
101
101
|
worker_automate_hub/utils/toast.py,sha256=xPHc5r5uOxB_cZlCzm13Kt2qSKLLFZALncU6Qg3Ft68,1162
|
102
102
|
worker_automate_hub/utils/updater.py,sha256=en2FCGhI8aZ-JNP3LQm64NJDc4awCNW7UhbVlwDl49Y,7972
|
103
|
-
worker_automate_hub/utils/util.py,sha256=
|
103
|
+
worker_automate_hub/utils/util.py,sha256=HXXGEEeGQd-gD_u8W0_aPYVDiMB9bKF-rJBl-m6RiRM,210781
|
104
104
|
worker_automate_hub/utils/utils_nfe_entrada.py,sha256=F7jk95LpDwl5WfaQXahCA5yDdnySnWdctDqczHXwGqE,38195
|
105
105
|
worker_automate_hub/worker.py,sha256=zEnYUrm5kY2cHbbee15QJkwkx4euD2SB2zRvUIbjS90,6850
|
106
|
-
worker_automate_hub-0.5.
|
107
|
-
worker_automate_hub-0.5.
|
108
|
-
worker_automate_hub-0.5.
|
109
|
-
worker_automate_hub-0.5.
|
106
|
+
worker_automate_hub-0.5.808.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
|
107
|
+
worker_automate_hub-0.5.808.dist-info/METADATA,sha256=KRbybp0DZrAekkD5tpiMu3ZjLifTcxe1myhczvqeqMY,3100
|
108
|
+
worker_automate_hub-0.5.808.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
109
|
+
worker_automate_hub-0.5.808.dist-info/RECORD,,
|
File without changes
|
{worker_automate_hub-0.5.807.dist-info → worker_automate_hub-0.5.808.dist-info}/entry_points.txt
RENAMED
File without changes
|