worker-automate-hub 0.4.415__py3-none-any.whl → 0.4.417__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.
@@ -521,36 +521,36 @@ async def entrada_de_notas_39(task: RpaProcessoEntradaDTO) -> RpaRetornoProcesso
521
521
 
522
522
  select_box_nop_select = main_window.child_window(class_name="TDBIComboBox", found_index=0)
523
523
  select_box_nop_select.click()
524
- nop_value = "1152 - ENTRADAS P/ TRANSFERENCIAS DE MERCADORIA- 1.152"
524
+ pyautogui.write("1152")
525
+ await worker_sleep(2)
526
+ pyautogui.hotkey("enter")
525
527
  await worker_sleep(2)
526
- set_combobox("||List", nop_value)
527
- await worker_sleep(1)
528
- pyautogui.press('down')
529
528
 
530
- nop_selected = select_box_nop_select.window_text()
531
- if '1152' in nop_selected:
532
- console.print(f"NOP selecionada corretamente, {nop_selected} ...\n")
533
- else:
534
- select_box_nop_select.click()
535
- console.print(f"Inserindo a informação da NOP: {nop_value} ...\n")
536
- await worker_sleep(2)
537
- set_combobox("||List", nop_value)
538
- await worker_sleep(2)
539
- pyautogui.hotkey("enter")
540
- await worker_sleep(2)
541
- console.print(f"Confirmando a NOP selecionada...\n")
542
- main_window.set_focus()
543
- await worker_sleep(1)
529
+ max_try = 10
530
+ i = 0
531
+ first_nop = False
532
+ while i <= max_try:
544
533
  select_box_nop_select = main_window.child_window(class_name="TDBIComboBox", found_index=0)
545
534
  nop_selected = select_box_nop_select.window_text()
546
- if '1152' in nop_selected:
547
- console.print(f"NOP selecionada corretamente, {nop_selected} ...\n")
535
+ if '1152 - ENTRADAS P/ TRANSFERENCIA DE MERCADORIAS- 1.152' == nop_selected and first_nop == False:
536
+ first_nop = True
548
537
  else:
549
- return RpaRetornoProcessoDTO(
550
- sucesso=False,
551
- retorno=f"Erro não foi possivel selecionar NOP correta, NOP selecionada: {nop_selected}",
552
- status=RpaHistoricoStatusEnum.Falha,
553
- )
538
+ if '1152 - ENTRADAS P/ TRANSFERENCIA DE MERCADORIAS- 1.152' == nop_selected:
539
+ break
540
+
541
+ pyautogui.press('down')
542
+ await worker_sleep(2)
543
+ i = i + 1
544
+
545
+
546
+ if i <= max_try and first_nop:
547
+ console.print(f"A segunda correspondência '1152 - ENTRADAS P/ TRANSFERENCIA DE MERCADORIAS- 1.152' foi encontrada e selecionada.")
548
+ else:
549
+ return RpaRetornoProcessoDTO(
550
+ sucesso=False,
551
+ retorno=f"Erro não foi encontrada a segunda correspondência dentro do número máximo de tentativas ({max_try})",
552
+ status=RpaHistoricoStatusEnum.Falha,
553
+ )
554
554
 
555
555
  await emsys.incluir_registro()
556
556
  await worker_sleep(10)
@@ -589,8 +589,7 @@ async def entrada_de_notas_39(task: RpaProcessoEntradaDTO) -> RpaRetornoProcesso
589
589
  sucesso=True,
590
590
  retorno="Nota Lançada com sucesso!",
591
591
  status=RpaHistoricoStatusEnum.Sucesso,
592
- )
593
-
592
+ )
594
593
  except Exception as e:
595
594
  select_box_nop_select.click()
596
595
  return RpaRetornoProcessoDTO(
@@ -709,7 +708,17 @@ async def entrada_de_notas_39(task: RpaProcessoEntradaDTO) -> RpaRetornoProcesso
709
708
  app = Application().connect(class_name="TFrmTelaSelecao")
710
709
  main_window = app["TFrmTelaSelecao"]
711
710
  send_keys("%o")
712
- await worker_sleep(3)
711
+ await worker_sleep(7)
712
+
713
+ # VERIFICANDO A EXISTENCIA DE ERRO
714
+ erro_pop_up = await is_window_open("Erro")
715
+ if erro_pop_up["IsOpened"] == True:
716
+ error_work = await error_after_xml_imported()
717
+ return RpaRetornoProcessoDTO(
718
+ sucesso=False,
719
+ retorno=error_work.retorno,
720
+ status=RpaHistoricoStatusEnum.Falha,
721
+ )
713
722
 
714
723
  max_attempts = 50
715
724
  i = 0
@@ -523,8 +523,121 @@ async def entrada_de_notas_500(task: RpaProcessoEntradaDTO) -> RpaRetornoProcess
523
523
  app = Application().connect(class_name="TFrmTelaSelecao")
524
524
  main_window = app["TFrmTelaSelecao"]
525
525
  send_keys("%o")
526
-
527
526
 
527
+
528
+ await worker_sleep(7)
529
+ aviso_pop_up = await is_window_open("Aviso")
530
+ if aviso_pop_up["IsOpened"] == True:
531
+ app = Application().connect(title="Aviso")
532
+ main_window = app["Aviso"]
533
+ main_window.set_focus()
534
+
535
+ console.print(f"Clicando em Aviso, para andamento do processo...\n")
536
+ btn_no = main_window.child_window(title="OK")
537
+ if btn_no.exists(timeout=5) and btn_no.is_enabled():
538
+ btn_no.set_focus()
539
+ btn_no.click()
540
+ await worker_sleep(2)
541
+
542
+ try:
543
+ pyautogui.click(623, 374)
544
+ await worker_sleep(1)
545
+ pyautogui.press('home')
546
+ console.print("Alterando a NOP...\n")
547
+
548
+ app = Application().connect(class_name="TFrmNotaFiscalEntrada", timeout=30)
549
+ main_window = app["TFrmNotaFiscalEntrada"]
550
+ main_window.set_focus()
551
+
552
+ select_box_nop_select = main_window.child_window(class_name="TDBIComboBox", found_index=0)
553
+ select_box_nop_select.click()
554
+ pyautogui.write("1152")
555
+ await worker_sleep(2)
556
+ pyautogui.hotkey("enter")
557
+ await worker_sleep(2)
558
+
559
+ max_try = 10
560
+ i = 0
561
+ first_nop = False
562
+ while i <= max_try:
563
+ select_box_nop_select = main_window.child_window(class_name="TDBIComboBox", found_index=0)
564
+ nop_selected = select_box_nop_select.window_text()
565
+ if '1152 - ENTRADAS P/ TRANSFERENCIA DE MERCADORIAS- 1.152' == nop_selected and first_nop == False:
566
+ first_nop = True
567
+ else:
568
+ if '1152 - ENTRADAS P/ TRANSFERENCIA DE MERCADORIAS- 1.152' == nop_selected:
569
+ break
570
+
571
+ pyautogui.press('down')
572
+ await worker_sleep(2)
573
+ i = i + 1
574
+
575
+
576
+ if i <= max_try and first_nop:
577
+ console.print(f"A segunda correspondência '1152 - ENTRADAS P/ TRANSFERENCIA DE MERCADORIAS- 1.152' foi encontrada e selecionada.")
578
+ else:
579
+ return RpaRetornoProcessoDTO(
580
+ sucesso=False,
581
+ retorno=f"Erro não foi encontrada a segunda correspondência dentro do número máximo de tentativas ({max_try})",
582
+ status=RpaHistoricoStatusEnum.Falha,
583
+ )
584
+
585
+ try:
586
+ ASSETS_PATH = "assets"
587
+ inserir_registro = pyautogui.locateOnScreen(
588
+ ASSETS_PATH + "\\entrada_notas\\IncluirRegistro.png", confidence=0.8
589
+ )
590
+ pyautogui.click(inserir_registro)
591
+ except Exception as e:
592
+ console.print(
593
+ f"Não foi possivel incluir o registro utilizando reconhecimento de imagem, Error: {e}...\n tentando inserir via posição...\n"
594
+ )
595
+ await incluir_registro()
596
+ await worker_sleep(10)
597
+
598
+ console.print("Verificando a existencia de POP-UP de Itens que Ultrapassam a Variação Máxima de Custo ...\n")
599
+ itens_variacao_maxima = await is_window_open_by_class("TFrmTelaSelecao", "TFrmTelaSelecao")
600
+ if itens_variacao_maxima["IsOpened"] == True:
601
+ app = Application().connect(class_name="TFrmTelaSelecao")
602
+ main_window = app["TFrmTelaSelecao"]
603
+ send_keys("%o")
604
+ await worker_sleep(7)
605
+
606
+ aviso_pop_up = await is_window_open("Aviso")
607
+ if aviso_pop_up["IsOpened"] == True:
608
+ return RpaRetornoProcessoDTO(
609
+ sucesso=False,
610
+ retorno=f"Erro na validação de CFOP, foi encontrado mais de uma opção com a mesma informação",
611
+ status=RpaHistoricoStatusEnum.Falha,
612
+ )
613
+
614
+ console.print("Verificando a existencia de Warning informando que a Soma dos pagamentos não bate com o valor da nota. ...\n")
615
+ warning_pop_up_pagamentos = await is_window_open("Warning")
616
+ if warning_pop_up_pagamentos["IsOpened"] == True:
617
+ return RpaRetornoProcessoDTO(
618
+ sucesso=False,
619
+ retorno=f"A soma dos pagamentos não bate com o valor da nota.",
620
+ status=RpaHistoricoStatusEnum.Falha,
621
+ )
622
+
623
+ await worker_sleep(60)
624
+ console.print("\nVerifica se a nota ja foi lançada...")
625
+ nf_chave_acesso = int(nota.get("nfe"))
626
+ status_nf_emsys = await get_status_nf_emsys(nf_chave_acesso)
627
+ if status_nf_emsys.get("status") == "Lançada":
628
+ return RpaRetornoProcessoDTO(
629
+ sucesso=True,
630
+ retorno="Nota Lançada com sucesso!",
631
+ status=RpaHistoricoStatusEnum.Sucesso,
632
+ )
633
+ except Exception as e:
634
+ select_box_nop_select.click()
635
+ return RpaRetornoProcessoDTO(
636
+ sucesso=False,
637
+ retorno=f"Erro ao alterar o NOP, erro {e}",
638
+ status=RpaHistoricoStatusEnum.Falha,
639
+ )
640
+
528
641
  # Verificando se possui pop-up de Warning
529
642
  await worker_sleep(6)
530
643
  warning_pop_up = await is_window_open("Warning")
@@ -7,7 +7,7 @@ import pyautogui
7
7
  import pytesseract
8
8
  from datetime import datetime, timedelta
9
9
  from pywinauto.application import Application
10
- from PIL import Image, ImageEnhance
10
+ from PIL import Image, ImageEnhance, ImageFilter
11
11
  from pywinauto.keyboard import send_keys
12
12
  import win32clipboard
13
13
  from pywinauto_recorder.player import set_combobox
@@ -461,39 +461,50 @@ async def entrada_de_notas_9(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoD
461
461
  if distribuiu_algo:
462
462
  console.print(f"Extraindo informação da Janela de Distribuir Itens para realização do OCR...\n")
463
463
 
464
- main_window.set_focus()
465
- window_rect = main_window.rectangle()
466
- screenshot = pyautogui.screenshot(
467
- region=(
468
- window_rect.left,
469
- window_rect.top,
470
- window_rect.width(),
471
- window_rect.height(),
464
+ max_attempts = 3
465
+ attempts = 0
466
+ resultado = None
467
+ while attempts < max_attempts:
468
+ main_window.set_focus()
469
+ window_rect = main_window.rectangle()
470
+ screenshot = pyautogui.screenshot(
471
+ region=(
472
+ window_rect.left,
473
+ window_rect.top,
474
+ window_rect.width(),
475
+ window_rect.height(),
476
+ )
472
477
  )
473
- )
474
- username = getpass.getuser()
475
- path_to_png = f"C:\\Users\\{username}\\Downloads\\distribuir_iten_{nota.get("nfe")}.png"
476
- screenshot.save(path_to_png)
477
- console.print(f"Print salvo em {path_to_png}...\n")
478
+ username = getpass.getuser()
479
+ path_to_png = f"C:\\Users\\{username}\\Downloads\\distribuir_iten_{nota.get("nfe")}.png"
480
+ screenshot.save(path_to_png)
481
+ console.print(f"Print salvo em {path_to_png}...\n")
478
482
 
479
- console.print(
480
- f"Preparando a imagem para maior resolução e assertividade no OCR...\n"
481
- )
482
- image = Image.open(path_to_png)
483
- image = image.convert("L")
484
- enhancer = ImageEnhance.Contrast(image)
485
- image = enhancer.enhance(2.0)
486
- image.save(path_to_png)
487
- console.print(f"Imagem preparada com sucesso...\n")
488
- console.print(f"Realizando OCR...\n")
489
- captured_text = pytesseract.image_to_string(Image.open(path_to_png))
490
- console.print(
491
- f"Texto Full capturado {captured_text}...\n"
492
- )
493
- os.remove(path_to_png)
483
+ console.print(
484
+ f"Preparando a imagem para maior resolução e assertividade no OCR...\n"
485
+ )
486
+ image = Image.open(path_to_png)
487
+ image = image.filter(ImageFilter.SHARPEN)
488
+ image = image.convert("L")
489
+ enhancer = ImageEnhance.Contrast(image)
490
+ image = enhancer.enhance(2.0)
491
+ image.save(path_to_png)
492
+ console.print(f"Imagem preparada com sucesso...\n")
493
+ console.print(f"Realizando OCR...\n")
494
+ await worker_sleep(1)
495
+ captured_text = pytesseract.image_to_string(Image.open(path_to_png))
496
+ console.print(
497
+ f"Texto Full capturado {captured_text}...\n"
498
+ )
499
+ os.remove(path_to_png)
494
500
 
495
- pattern_qtd_restante = r"Quantidade restante:\s([\d,]+)"
496
- resultado = re.search(pattern_qtd_restante, captured_text)
501
+ pattern_qtd_restante = r"Quantidade restante:\s([\d,]+)"
502
+ resultado = re.search(pattern_qtd_restante, captured_text)
503
+ if resultado:
504
+ break
505
+ else:
506
+ await worker_sleep(2)
507
+ attempts += 1
497
508
 
498
509
  try:
499
510
  if resultado:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: worker-automate-hub
3
- Version: 0.4.415
3
+ Version: 0.4.417
4
4
  Summary: Worker Automate HUB é uma aplicação para automatizar rotinas de RPA nos ambientes Argenta.
5
5
  Author: Joel Paim
6
6
  Requires-Python: >=3.12,<4.0
@@ -44,11 +44,11 @@ worker_automate_hub/tasks/jobs/entrada_de_notas_32.py,sha256=0cneKY6bQU5neo3TKlG
44
44
  worker_automate_hub/tasks/jobs/entrada_de_notas_33.py,sha256=ktXc_kdMhlz9cbb7XjfMJhME29mgMFd_FnatxSZZU_s,31457
45
45
  worker_automate_hub/tasks/jobs/entrada_de_notas_34.py,sha256=iaSmtWTWlazHDtGp22yTV5J5rHDhUCbEaCAnpU7UWyM,31808
46
46
  worker_automate_hub/tasks/jobs/entrada_de_notas_36.py,sha256=vFkDcgJ9uxrMMLYdeONCMxh6_evnhgF1Sun5HEHAWa4,22716
47
- worker_automate_hub/tasks/jobs/entrada_de_notas_39.py,sha256=j_QE5v4t_D6jKWWaeSCCmIelPWc5vjGbC_gb13ovwLg,32579
48
- worker_automate_hub/tasks/jobs/entrada_de_notas_500.py,sha256=ryl5AZ2617aROSVcS-N5wQIBlFQ1Bp0khUH9fP4DOzU,26542
47
+ worker_automate_hub/tasks/jobs/entrada_de_notas_39.py,sha256=5WkmAOp18NlPfx0Cn28Lo1ldqOZACAss5dxQCm6VjiE,32767
48
+ worker_automate_hub/tasks/jobs/entrada_de_notas_500.py,sha256=MYPaYAP2iwdBYDZUf39f7yGibTME9uObEash_QTCmFA,32231
49
49
  worker_automate_hub/tasks/jobs/entrada_de_notas_505.py,sha256=jIml8gjXPdI6_x7S9VVV8IrKZRF7_PTNOMnhNmYMDTU,14490
50
50
  worker_automate_hub/tasks/jobs/entrada_de_notas_7139.py,sha256=8XP9G3n0PUeshbRWkWKOMnyUGRWspIolPZVqQTR3SMI,14184
51
- worker_automate_hub/tasks/jobs/entrada_de_notas_9.py,sha256=OPOE43iMTUg3uNf2ZxqENV_NWn-g7HXBavHHgPN7RoA,47796
51
+ worker_automate_hub/tasks/jobs/entrada_de_notas_9.py,sha256=DBzP8O-m7OvuBOmWGfmC7JwCQ29IkKFAWD6JnJI7BLE,48452
52
52
  worker_automate_hub/tasks/jobs/exemplo_processo.py,sha256=3-zxbb-9YHPmSA_K1Qgxp_FwSqg2QDjGBRCLxDZ8QoQ,3451
53
53
  worker_automate_hub/tasks/jobs/fidc_gerar_nosso_numero.py,sha256=iXIKBMNFPj3L6G5Iq5nyDKiZT3NAP5sIhRSzYdURpNw,9571
54
54
  worker_automate_hub/tasks/jobs/fidc_remessa_cobranca_cnab240.py,sha256=QBGm6eS5JghgNWNqZlk1g2a2iV8LnBLiOTBBL3Giet0,4181
@@ -67,7 +67,7 @@ worker_automate_hub/utils/updater.py,sha256=en2FCGhI8aZ-JNP3LQm64NJDc4awCNW7UhbV
67
67
  worker_automate_hub/utils/util.py,sha256=YQkdPMCgrwuCJG_069p1cIG7xTg8VgvSHlGnIQrlyHo,119625
68
68
  worker_automate_hub/utils/utils_nfe_entrada.py,sha256=yQFyDzvXPSO-UYV1m38WLJ3AWQgZYcyUkHZdCKE1jG4,28360
69
69
  worker_automate_hub/worker.py,sha256=KDBU3L2kVobndrnN5coRZFTwVmBLKmPJjRv20sCo5Hc,4697
70
- worker_automate_hub-0.4.415.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
71
- worker_automate_hub-0.4.415.dist-info/METADATA,sha256=XFOGIS4PxbIOY-zB5FJ4iRakPcsf83rtUcR4RXBgBKA,2895
72
- worker_automate_hub-0.4.415.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
73
- worker_automate_hub-0.4.415.dist-info/RECORD,,
70
+ worker_automate_hub-0.4.417.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
71
+ worker_automate_hub-0.4.417.dist-info/METADATA,sha256=LHx1gr8Grvvbo4E1tstlbhrnbCh56AgV68a6onv6JPA,2895
72
+ worker_automate_hub-0.4.417.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
73
+ worker_automate_hub-0.4.417.dist-info/RECORD,,