worker-automate-hub 0.5.749__py3-none-any.whl → 0.5.912__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/api/client.py +186 -68
- worker_automate_hub/api/rpa_historico_service.py +1 -0
- worker_automate_hub/cli.py +91 -111
- worker_automate_hub/tasks/jobs/abertura_livros_fiscais.py +112 -229
- worker_automate_hub/tasks/jobs/descartes.py +91 -77
- worker_automate_hub/tasks/jobs/devolucao_produtos.py +1386 -0
- worker_automate_hub/tasks/jobs/entrada_de_notas_15.py +3 -46
- worker_automate_hub/tasks/jobs/entrada_de_notas_22.py +833 -0
- worker_automate_hub/tasks/jobs/entrada_de_notas_36.py +29 -9
- worker_automate_hub/tasks/jobs/entrada_de_notas_37.py +619 -0
- worker_automate_hub/tasks/jobs/entrada_de_notas_39.py +1 -1
- worker_automate_hub/tasks/jobs/entrada_de_notas_9.py +63 -16
- worker_automate_hub/tasks/jobs/extracao_dados_nielsen.py +504 -0
- worker_automate_hub/tasks/jobs/extracao_saldo_estoque.py +242 -108
- worker_automate_hub/tasks/jobs/extracao_saldo_estoque_fiscal.py +688 -0
- worker_automate_hub/tasks/jobs/fidc_gerar_nosso_numero.py +2 -2
- worker_automate_hub/tasks/jobs/fidc_remessa_cobranca_cnab240.py +25 -16
- worker_automate_hub/tasks/jobs/geracao_balancetes_filial.py +330 -0
- worker_automate_hub/tasks/jobs/importacao_extratos.py +538 -0
- worker_automate_hub/tasks/jobs/importacao_extratos_748.py +800 -0
- worker_automate_hub/tasks/jobs/inclusao_pedidos_ipiranga.py +222 -0
- worker_automate_hub/tasks/jobs/inclusao_pedidos_raizen.py +174 -0
- worker_automate_hub/tasks/jobs/inclusao_pedidos_vibra.py +327 -0
- worker_automate_hub/tasks/jobs/notas_faturamento_sap.py +438 -157
- worker_automate_hub/tasks/jobs/opex_capex.py +540 -326
- worker_automate_hub/tasks/jobs/sped_fiscal.py +8 -8
- worker_automate_hub/tasks/jobs/transferencias.py +52 -41
- worker_automate_hub/tasks/task_definitions.py +46 -1
- worker_automate_hub/tasks/task_executor.py +11 -0
- worker_automate_hub/utils/util.py +252 -215
- worker_automate_hub/utils/utils_nfe_entrada.py +1 -1
- worker_automate_hub/worker.py +1 -9
- {worker_automate_hub-0.5.749.dist-info → worker_automate_hub-0.5.912.dist-info}/METADATA +4 -2
- {worker_automate_hub-0.5.749.dist-info → worker_automate_hub-0.5.912.dist-info}/RECORD +36 -25
- {worker_automate_hub-0.5.749.dist-info → worker_automate_hub-0.5.912.dist-info}/WHEEL +1 -1
- {worker_automate_hub-0.5.749.dist-info → worker_automate_hub-0.5.912.dist-info}/entry_points.txt +0 -0
|
@@ -8,9 +8,7 @@ import os
|
|
|
8
8
|
from pywinauto.findwindows import ElementNotFoundError
|
|
9
9
|
from pywinauto.keyboard import send_keys
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..')))
|
|
14
12
|
from worker_automate_hub.utils.logger import logger
|
|
15
13
|
from worker_automate_hub.models.dto.rpa_historico_request_dto import (
|
|
16
14
|
RpaHistoricoStatusEnum,
|
|
@@ -47,6 +45,8 @@ console = Console()
|
|
|
47
45
|
|
|
48
46
|
emsys = EMSys()
|
|
49
47
|
|
|
48
|
+
# ASSETS_PATH = r"C:\Users\automatehub\Documents\GitHub\worker-automate-hub\assets\abertura_livros"
|
|
49
|
+
ASSETS_PATH = r"assets\abertura_livros"
|
|
50
50
|
|
|
51
51
|
@repeat(times=10, delay=5)
|
|
52
52
|
async def wait_aguarde_window_closed(app, timeout=60):
|
|
@@ -69,17 +69,6 @@ async def wait_aguarde_window_closed(app, timeout=60):
|
|
|
69
69
|
console.log("Timeout esperando a janela Aguarde...")
|
|
70
70
|
|
|
71
71
|
|
|
72
|
-
def click_desconfirmar():
|
|
73
|
-
cords = (675, 748)
|
|
74
|
-
pyautogui.click(x=cords[0], y=cords[1])
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
def ctrl_c():
|
|
78
|
-
pyautogui.press("tab", presses=12) # verificar
|
|
79
|
-
pyautogui.hotkey("ctrl", "c")
|
|
80
|
-
return pyperclip.paste()
|
|
81
|
-
|
|
82
|
-
|
|
83
72
|
async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
84
73
|
try:
|
|
85
74
|
config = await get_config_by_name("login_emsys_fiscal")
|
|
@@ -94,11 +83,11 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
|
94
83
|
message="32-bit application should be automated using 32-bit Python",
|
|
95
84
|
)
|
|
96
85
|
|
|
97
|
-
await worker_sleep(
|
|
86
|
+
await worker_sleep(8)
|
|
98
87
|
|
|
99
88
|
try:
|
|
100
89
|
app = Application(backend="win32").connect(
|
|
101
|
-
class_name="TFrmLoginModulo", timeout=
|
|
90
|
+
class_name="TFrmLoginModulo", timeout=120
|
|
102
91
|
)
|
|
103
92
|
except:
|
|
104
93
|
return RpaRetornoProcessoDTO(
|
|
@@ -149,7 +138,7 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
|
149
138
|
console.print("Aguardando janela 'Movimento de Livro Fiscal' aparecer...")
|
|
150
139
|
|
|
151
140
|
# Tempo limite de espera (em segundos)
|
|
152
|
-
timeout =
|
|
141
|
+
timeout = 3600
|
|
153
142
|
inicio = time.time()
|
|
154
143
|
|
|
155
144
|
# Espera até a janela aparecer
|
|
@@ -205,7 +194,7 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
|
205
194
|
saida_checkbox.click_input()
|
|
206
195
|
|
|
207
196
|
console.print("Aguardar marcar caixa de saida")
|
|
208
|
-
imagem = "
|
|
197
|
+
imagem = fr"{ASSETS_PATH}\saida_marcada.png"
|
|
209
198
|
|
|
210
199
|
tempo_limite = 600 # 10 minutos
|
|
211
200
|
intervalo = 2 # segundos entre verificações
|
|
@@ -242,7 +231,7 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
|
242
231
|
# Clicando em incluir livro
|
|
243
232
|
try:
|
|
244
233
|
console.print("Clicando em incluir livro")
|
|
245
|
-
cords = (
|
|
234
|
+
cords = (698, 728)
|
|
246
235
|
pyautogui.click(x=cords[0], y=cords[1])
|
|
247
236
|
await worker_sleep(5)
|
|
248
237
|
except:
|
|
@@ -341,9 +330,9 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
|
341
330
|
await worker_sleep(5)
|
|
342
331
|
|
|
343
332
|
console.print("Aguardar o término de carregar")
|
|
344
|
-
imagem = "
|
|
333
|
+
imagem = fr"{ASSETS_PATH}\livros_incluidos.png"
|
|
345
334
|
|
|
346
|
-
tempo_limite =
|
|
335
|
+
tempo_limite = 6600 # 1h
|
|
347
336
|
intervalo = 2 # segundos entre as verificações
|
|
348
337
|
|
|
349
338
|
inicio = time.time()
|
|
@@ -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,65 @@ 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 = fr"{ASSETS_PATH}\notas_rejeitadas.png"
|
|
376
|
+
if os.path.exists(img_dialog):
|
|
377
|
+
caixa = pyautogui.locateOnScreen(
|
|
378
|
+
img_dialog, confidence=0.9, grayscale=True
|
|
379
|
+
)
|
|
380
|
+
if caixa:
|
|
381
|
+
print("Janela 'notas rejeitadas' detectada por imagem.")
|
|
382
|
+
region = (caixa.left, caixa.top, caixa.width, caixa.height)
|
|
383
|
+
|
|
384
|
+
app_msg = Application().connect(
|
|
385
|
+
class_name="TMessageForm", timeout=2
|
|
386
|
+
)
|
|
387
|
+
form = app_msg["TMessageForm"]
|
|
388
|
+
console.print(
|
|
389
|
+
"Janela de confirmação 'TMessageForm' encontrada."
|
|
390
|
+
)
|
|
391
|
+
form.set_focus()
|
|
392
|
+
form.child_window(
|
|
393
|
+
class_name="TButton", found_index=1
|
|
394
|
+
).click_input()
|
|
395
|
+
print("Clicou no botão de sim.")
|
|
396
|
+
|
|
397
|
+
await worker_sleep(5)
|
|
398
|
+
|
|
399
|
+
img_dialog = fr"{ASSETS_PATH}\gerar_rel_notas_rejeitadas.png"
|
|
400
|
+
if os.path.exists(img_dialog):
|
|
401
|
+
caixa = pyautogui.locateOnScreen(
|
|
402
|
+
img_dialog, confidence=0.9, grayscale=True
|
|
403
|
+
)
|
|
404
|
+
if caixa:
|
|
405
|
+
print(
|
|
406
|
+
"Janela 'notas relatorios rejeitadas' detectada por imagem."
|
|
407
|
+
)
|
|
408
|
+
region = (
|
|
409
|
+
caixa.left,
|
|
410
|
+
caixa.top,
|
|
411
|
+
caixa.width,
|
|
412
|
+
caixa.height,
|
|
413
|
+
)
|
|
414
|
+
|
|
415
|
+
app_msg = Application().connect(
|
|
416
|
+
class_name="TMessageForm", timeout=2
|
|
417
|
+
)
|
|
418
|
+
form = app_msg["TMessageForm"]
|
|
419
|
+
console.print(
|
|
420
|
+
"Janela de confirmação 'TMessageForm' encontrada."
|
|
421
|
+
)
|
|
422
|
+
form.set_focus()
|
|
423
|
+
form.child_window(
|
|
424
|
+
class_name="TButton", found_index=0
|
|
425
|
+
).click_input()
|
|
426
|
+
print("Clicou no botão de não.")
|
|
427
|
+
except:
|
|
397
428
|
pass
|
|
398
|
-
except Exception as e:
|
|
399
|
-
print(f"[Erro ao procurar/clicar na TMessageForm]: {e}")
|
|
400
429
|
|
|
401
430
|
# 3. Verifica se a janela do relatório está aberta
|
|
402
431
|
try:
|
|
@@ -406,10 +435,8 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
|
406
435
|
janela = app_report["TFrmPreviewRelatorio"]
|
|
407
436
|
print("Janela 'TFrmPreviewRelatorio' encontrada.")
|
|
408
437
|
janela_aberta = True
|
|
409
|
-
except
|
|
438
|
+
except:
|
|
410
439
|
pass
|
|
411
|
-
except Exception as e:
|
|
412
|
-
print(f"[Erro ao procurar TFrmPreviewRelatorio]: {e}")
|
|
413
440
|
|
|
414
441
|
# Se encontrou a janela de relatório, sai
|
|
415
442
|
if janela_aberta:
|
|
@@ -444,9 +471,26 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
|
444
471
|
main_window = app["TFrmPreviewRelatorio"]
|
|
445
472
|
main_window.set_focus()
|
|
446
473
|
|
|
474
|
+
# Verificando se a foi confirmado os livres
|
|
475
|
+
console.print("Verificando se os livros foram confirmados")
|
|
476
|
+
|
|
477
|
+
imagem = fr"{ASSETS_PATH}\confirmado_livros.png"
|
|
478
|
+
if os.path.exists(imagem):
|
|
479
|
+
caixa = pyautogui.locateOnScreen(imagem, confidence=0.9, grayscale=True)
|
|
480
|
+
else:
|
|
481
|
+
console.print("Imagem confirmada não encontrada")
|
|
482
|
+
return RpaRetornoProcessoDTO(
|
|
483
|
+
sucesso=False,
|
|
484
|
+
retorno=f"Erro na Abertura de Livro Fiscal: Imagem confirmada não encontrada",
|
|
485
|
+
status=RpaHistoricoStatusEnum.Falha,
|
|
486
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
|
487
|
+
)
|
|
488
|
+
|
|
447
489
|
# Clicar em fechar
|
|
448
490
|
main_window.close()
|
|
449
491
|
|
|
492
|
+
console.print("Livros confirmados")
|
|
493
|
+
|
|
450
494
|
await worker_sleep(5)
|
|
451
495
|
|
|
452
496
|
# Conecta na janela principal
|
|
@@ -502,181 +546,8 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
|
502
546
|
|
|
503
547
|
main_window.close()
|
|
504
548
|
|
|
505
|
-
await worker_sleep(
|
|
506
|
-
|
|
507
|
-
console.print("Selecionar Livro Saída aberto")
|
|
508
|
-
|
|
509
|
-
# Selecionar linha livro de saída aberto
|
|
510
|
-
# imagem = "assets\\abertura_livros\\livro_saida_aberto.png"
|
|
511
|
-
imagem = "assets\\abertura_livros\\livro_saida_aberto.png"
|
|
512
|
-
|
|
513
|
-
# Tenta localizar a imagem na tela
|
|
514
|
-
localizacao = pyautogui.locateCenterOnScreen(imagem, confidence=0.9)
|
|
515
|
-
|
|
516
|
-
if localizacao:
|
|
517
|
-
print(f"Imagem livro de saída aberto encontrado em: {localizacao}")
|
|
518
|
-
pyautogui.moveTo(localizacao)
|
|
519
|
-
pyautogui.click()
|
|
520
|
-
else:
|
|
521
|
-
console.print("Imagem livro de saída aberto não encontrado na tela.")
|
|
522
|
-
|
|
523
|
-
# Clicar em alterar livro
|
|
524
|
-
# imagem = "assets\\abertura_livros\\alterar_livro.png"
|
|
525
|
-
imagem = "assets\\abertura_livros\\alterar_livro.png"
|
|
526
|
-
# Tenta localizar a imagem na tela
|
|
527
|
-
localizacao = pyautogui.locateCenterOnScreen(
|
|
528
|
-
imagem, confidence=0.9
|
|
529
|
-
) # você pode ajustar o confidence
|
|
530
|
-
|
|
531
|
-
if localizacao:
|
|
532
|
-
print(f"Imagem alterar livro encontrado em: {localizacao}")
|
|
533
|
-
pyautogui.moveTo(localizacao)
|
|
534
|
-
pyautogui.click()
|
|
535
|
-
else:
|
|
536
|
-
console.print("Imagem alterar livro não encontrada na tela.")
|
|
537
|
-
|
|
538
|
-
await worker_sleep(8)
|
|
539
|
-
|
|
540
|
-
# Clicar em Livro fiscal
|
|
541
|
-
# imagem = "assets\\abertura_livros\\livro_fiscal.png"
|
|
542
|
-
imagem = "assets\\abertura_livros\\livro_fiscal.png"
|
|
543
|
-
# Tenta localizar a imagem na tela
|
|
544
|
-
localizacao = pyautogui.locateCenterOnScreen(
|
|
545
|
-
imagem, confidence=0.9
|
|
546
|
-
) # você pode ajustar o confidence
|
|
547
|
-
|
|
548
|
-
if localizacao:
|
|
549
|
-
print(f"Imagem Livro fiscal encontrado em: {localizacao}")
|
|
550
|
-
pyautogui.moveTo(localizacao)
|
|
551
|
-
pyautogui.click()
|
|
552
|
-
else:
|
|
553
|
-
console.print("Imagem Livro fiscal não encontrada na tela.")
|
|
554
|
-
|
|
555
|
-
await worker_sleep(4)
|
|
556
|
-
|
|
557
|
-
# Clicar em Gerar Relatório
|
|
558
|
-
# imagem = "assets\\abertura_livros\\gerar_registros.png"
|
|
559
|
-
imagem = "assets\\abertura_livros\\gerar_registros.png"
|
|
560
|
-
|
|
561
|
-
# Tenta localizar a imagem na tela
|
|
562
|
-
localizacao = pyautogui.locateCenterOnScreen(
|
|
563
|
-
imagem, confidence=0.9
|
|
564
|
-
) # você pode ajustar o confidence
|
|
565
|
-
|
|
566
|
-
if localizacao:
|
|
567
|
-
print(f"Imagem gerar relatório encontrado em: {localizacao}")
|
|
568
|
-
pyautogui.moveTo(localizacao)
|
|
569
|
-
pyautogui.click()
|
|
570
|
-
else:
|
|
571
|
-
console.print("Imagem gerar relatório não encontrada na tela.")
|
|
572
|
-
|
|
573
|
-
await worker_sleep(4)
|
|
574
|
-
|
|
575
|
-
##### Janela Gerar Registro ####
|
|
576
|
-
console.print("Confirmar Registro")
|
|
577
|
-
app = Application().connect(class_name="TMsgBox", timeout=60)
|
|
578
|
-
main_window = app["TMsgBox"]
|
|
579
|
-
main_window.set_focus()
|
|
580
|
-
|
|
581
|
-
# Clicar em Sim
|
|
582
|
-
main_window.child_window(class_name="TBitBtn", found_index=1).click_input()
|
|
583
|
-
|
|
584
|
-
await worker_sleep(4)
|
|
585
|
-
|
|
586
|
-
console.print("Clicar em confirmar")
|
|
587
|
-
app = Application().connect(
|
|
588
|
-
class_name="TPerguntasLivrosFiscaisForm", timeout=60
|
|
589
|
-
)
|
|
590
|
-
main_window = app["TPerguntasLivrosFiscaisForm"]
|
|
591
|
-
main_window.set_focus()
|
|
592
|
-
main_window.child_window(class_name="TButton", found_index=1).click_input()
|
|
593
|
-
|
|
594
|
-
await worker_sleep(60)
|
|
595
|
-
|
|
596
|
-
# Clicar no aviso
|
|
597
|
-
try:
|
|
598
|
-
app_msgbox = Application().connect(class_name="TMsgBox", timeout=10)
|
|
599
|
-
box = app_msgbox["TMsgBox"]
|
|
600
|
-
print("Janela 'TMsgBox' encontrada.")
|
|
601
|
-
box.set_focus()
|
|
602
|
-
box.child_window(class_name="TBitBtn", found_index=0).click_input()
|
|
603
|
-
print("1Clicou no botão 'TBitBtn'.")
|
|
604
|
-
await worker_sleep(5)
|
|
605
|
-
except:
|
|
606
|
-
pass
|
|
607
|
-
await worker_sleep(5)
|
|
608
|
-
try:
|
|
609
|
-
app_msg = Application().connect(class_name="TMessageForm", timeout=10)
|
|
610
|
-
form = app_msg["TMessageForm"]
|
|
611
|
-
console.print("Janela de confirmação 'TMessageForm' encontrada.")
|
|
612
|
-
form.set_focus()
|
|
613
|
-
form.child_window(class_name="TButton", found_index=1).click_input()
|
|
614
|
-
print("2Clicou no botão de confirmação.")
|
|
615
|
-
await worker_sleep(5)
|
|
616
|
-
except:
|
|
617
|
-
pass
|
|
618
|
-
await worker_sleep(5)
|
|
619
|
-
try:
|
|
620
|
-
app_msg = Application().connect(class_name="TMessageForm", timeout=10)
|
|
621
|
-
form = app_msg["TMessageForm"]
|
|
622
|
-
console.print("Janela de confirmação 'TMessageForm' encontrada.")
|
|
623
|
-
form.set_focus()
|
|
624
|
-
form.child_window(class_name="TButton", found_index=0).click_input()
|
|
625
|
-
print("3Clicou no botão de confirmação.")
|
|
626
|
-
await worker_sleep(5)
|
|
627
|
-
except:
|
|
628
|
-
pass
|
|
629
|
-
await worker_sleep(5)
|
|
630
|
-
try:
|
|
631
|
-
app_msg = Application().connect(class_name="TMessageForm", timeout=10)
|
|
632
|
-
form = app_msg["TMessageForm"]
|
|
633
|
-
console.print("Janela de confirmação 'TMessageForm' encontrada.")
|
|
634
|
-
form.set_focus()
|
|
635
|
-
form.child_window(class_name="TButton", found_index=1).click_input()
|
|
636
|
-
print("4Clicou no botão de confirmação.")
|
|
637
|
-
await worker_sleep(5)
|
|
638
|
-
except:
|
|
639
|
-
pass
|
|
640
|
-
await worker_sleep(5)
|
|
641
|
-
try:
|
|
642
|
-
app_msg = Application().connect(class_name="TMessageForm", timeout=10)
|
|
643
|
-
form = app_msg["TMessageForm"]
|
|
644
|
-
console.print("Janela de confirmação 'TMessageForm' encontrada.")
|
|
645
|
-
form.set_focus()
|
|
646
|
-
form.child_window(class_name="TButton", found_index=0).click_input()
|
|
647
|
-
print("5Clicou no botão de confirmação.")
|
|
648
|
-
await worker_sleep(5)
|
|
649
|
-
except:
|
|
650
|
-
pass
|
|
651
|
-
await worker_sleep(5)
|
|
652
|
-
try:
|
|
653
|
-
# Caminho da imagem que deve desaparecer
|
|
654
|
-
console.print("Aguardar carregar dados")
|
|
655
|
-
# imagem = "assets\\abertura_livros\\janela_carregada.png"
|
|
656
|
-
imagem = "assets\\abertura_livros\\janela_carregada.png"
|
|
657
|
-
|
|
658
|
-
# Tempo máximo de espera (em segundos)
|
|
659
|
-
tempo_limite = 600 # 10 minutos
|
|
660
|
-
intervalo = 2 # segundos entre as verificações
|
|
661
|
-
|
|
662
|
-
inicio = time.time()
|
|
663
|
-
|
|
664
|
-
while True:
|
|
665
|
-
localizacao = pyautogui.locateOnScreen(imagem, confidence=0.9)
|
|
666
|
-
|
|
667
|
-
if localizacao:
|
|
668
|
-
print("Imagem ainda presente... aguardando")
|
|
669
|
-
else:
|
|
670
|
-
print("Imagem desapareceu da tela.")
|
|
671
|
-
break # A imagem sumiu, podemos seguir
|
|
672
|
-
|
|
673
|
-
if time.time() - inicio > tempo_limite:
|
|
674
|
-
print("Tempo esgotado. A imagem não desapareceu.")
|
|
675
|
-
break
|
|
549
|
+
await worker_sleep(3)
|
|
676
550
|
|
|
677
|
-
time.sleep(intervalo)
|
|
678
|
-
except:
|
|
679
|
-
pass
|
|
680
551
|
# Conecta na janela principal
|
|
681
552
|
console.print("Janela Livro de Apuração ICMS 2ª Etapa")
|
|
682
553
|
app = Application().connect(class_name="TFrmPrincipalFiscal", timeout=60)
|
|
@@ -712,7 +583,7 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
|
712
583
|
await worker_sleep(2)
|
|
713
584
|
send_keys("{ENTER}")
|
|
714
585
|
|
|
715
|
-
await worker_sleep(5)
|
|
586
|
+
# await worker_sleep(5)
|
|
716
587
|
console.print("Inserindo competência...")
|
|
717
588
|
|
|
718
589
|
# Conecta na janela
|
|
@@ -725,7 +596,9 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
|
725
596
|
class_name="TDBIEditDate", found_index=0
|
|
726
597
|
)
|
|
727
598
|
data_input.click_input()
|
|
728
|
-
|
|
599
|
+
|
|
600
|
+
await worker_sleep(5)
|
|
601
|
+
|
|
729
602
|
data_input.set_edit_text("") # Limpa o campo
|
|
730
603
|
|
|
731
604
|
# Define a competência
|
|
@@ -734,27 +607,36 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
|
734
607
|
|
|
735
608
|
console.print("Clicando no botão incluir apuração")
|
|
736
609
|
# Clicar em incluir apuração
|
|
737
|
-
|
|
738
|
-
imagem = "assets\\abertura_livros\\btn_incluir_apuracao.png"
|
|
610
|
+
imagem = fr"{ASSETS_PATH}\btn_incluir_apuracao.png"
|
|
739
611
|
|
|
740
612
|
# Tenta localizar a imagem na tela
|
|
741
|
-
localizacao = pyautogui.locateCenterOnScreen(
|
|
742
|
-
imagem, confidence=0.9
|
|
743
|
-
) # você pode ajustar o confidence
|
|
613
|
+
localizacao = pyautogui.locateCenterOnScreen(imagem, confidence=0.9)
|
|
744
614
|
|
|
745
615
|
if localizacao:
|
|
746
|
-
print(f"Imagem incluir apuração encontrado em: {localizacao}")
|
|
616
|
+
console.print(f"Imagem incluir apuração encontrado em: {localizacao}")
|
|
747
617
|
pyautogui.moveTo(localizacao)
|
|
748
618
|
pyautogui.click()
|
|
749
|
-
console.print("
|
|
750
|
-
|
|
619
|
+
console.print("Botão incluir clicado com sucesso")
|
|
620
|
+
|
|
621
|
+
await worker_sleep(2)
|
|
622
|
+
|
|
623
|
+
# === 5) Se não houve 'Aviso' com erro mapeado, considera sucesso ===
|
|
624
|
+
console.print("Nenhum erro confirmado. Fluxo OK.")
|
|
625
|
+
try:
|
|
626
|
+
main_window.close()
|
|
627
|
+
console.print("Janela principal fechada.")
|
|
628
|
+
except Exception as e:
|
|
629
|
+
console.print(f"Falha ao fechar janela principal (ignorado): {e}")
|
|
630
|
+
|
|
631
|
+
retorno = "Apuração incluída com sucesso"
|
|
751
632
|
return RpaRetornoProcessoDTO(
|
|
752
|
-
sucesso=True,
|
|
633
|
+
sucesso=True,
|
|
634
|
+
retorno=retorno,
|
|
635
|
+
status=RpaHistoricoStatusEnum.Sucesso,
|
|
753
636
|
)
|
|
754
|
-
else:
|
|
755
|
-
console.print("Imagem incluir apuração não encontrada na tela.")
|
|
756
637
|
|
|
757
638
|
except Exception as erro:
|
|
639
|
+
|
|
758
640
|
console.print(f"Erro ao executar abertura de livros fiscais, erro : {erro}")
|
|
759
641
|
return RpaRetornoProcessoDTO(
|
|
760
642
|
sucesso=False,
|
|
@@ -762,3 +644,4 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
|
762
644
|
status=RpaHistoricoStatusEnum.Falha,
|
|
763
645
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
|
764
646
|
)
|
|
647
|
+
|