worker-automate-hub 0.5.815__tar.gz → 0.5.817__tar.gz
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.
Potentially problematic release.
This version of worker-automate-hub might be problematic. Click here for more details.
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/PKG-INFO +1 -1
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/pyproject.toml +1 -1
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/api/client.py +2 -0
- worker_automate_hub-0.5.817/worker_automate_hub/tasks/jobs/geracao_balancetes_filial.py +330 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/task_definitions.py +5 -1
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/README.md +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/__init__.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/api/__init__.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/api/ahead_service.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/api/datalake_service.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/api/helpers/__init__.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/api/helpers/api_helpers.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/api/rdp_service.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/api/rpa_fila_service.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/api/rpa_historico_service.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/api/webhook_service.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/cli.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/config/__init__.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/config/settings.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/config.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/core/so_manipulation.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/decorators/__init__.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/decorators/deprecation.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/decorators/rate_limit.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/decorators/repeat.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/decorators/retry.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/decorators/singleton.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/decorators/timeit.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/models/__init__.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/models/dao/__init__.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/models/dao/rpa_configuracao.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/models/dao/rpa_fila.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/models/dao/rpa_historico.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/models/dao/rpa_processo.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/models/dao/rpa_robo.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/models/dto/__init__.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/models/dto/rpa_historico_request_dto.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/models/dto/rpa_processo_entrada_dto.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/models/dto/rpa_processo_rdp_dto.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/models/dto/rpa_sap_dto.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/models/dto/rpa_sistema_dto.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/__init__.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/__init__.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/abertura_livros_fiscais.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/coleta_dje_process.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/conexao_rdp.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/cte_manual.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/cte_xml.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/descartes.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/devolucao_ctf.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/devolucao_ctf_35.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/devolucao_prazo_a_faturar.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/ecac_estadual_go.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/ecac_estadual_main.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/ecac_estadual_mt.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/ecac_estadual_sc.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/ecac_estadual_sp.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/ecac_federal.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/entrada_cte_1353.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/entrada_cte_333.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/entrada_de_notas_15.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/entrada_de_notas_16.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/entrada_de_notas_207.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/entrada_de_notas_22.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/entrada_de_notas_32.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/entrada_de_notas_33.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/entrada_de_notas_34.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/entrada_de_notas_36.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/entrada_de_notas_37.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/entrada_de_notas_39.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/entrada_de_notas_500.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/entrada_de_notas_503.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/entrada_de_notas_505.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/entrada_de_notas_7139.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/entrada_de_notas_9.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/entrada_de_notas_9000.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/exemplo_processo.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/extracao_fechamento_contabil.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/extracao_fechamento_emsys.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/extracao_saldo_estoque.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/extracao_saldo_estoque_fiscal.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/fechar_conexao_rdp.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/fidc_exportacao_docs_portal_b2b.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/fidc_gerar_nosso_numero.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/fidc_remessa_cobranca_cnab240.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/fidc_retorno_cobranca.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/geracao_aprovacao_pedidos.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/geracao_aprovacao_pedidos_novo.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/integracao_contabil.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/integracao_contabil_generica.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/lancamento_pis_cofins.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/lancamento_rateio.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/login_emsys.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/login_emsys_versao_especifica.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/notas_faturamento_sap.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/opex_capex.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/playground.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/sped_fiscal.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/jobs/transferencias.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/task_executor.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/utils/__init__.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/utils/env.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/utils/get_creds_gworkspace.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/utils/logger.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/utils/toast.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/utils/updater.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/utils/util.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/utils/utils_nfe_entrada.py +0 -0
- {worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/worker.py +0 -0
{worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/api/client.py
RENAMED
|
@@ -744,6 +744,8 @@ async def send_file(
|
|
|
744
744
|
elif file_extension == "xlsx":
|
|
745
745
|
filename = desArquivo
|
|
746
746
|
content_type = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
747
|
+
elif file_extension == "csv":
|
|
748
|
+
content_type = "text/csv"
|
|
747
749
|
else:
|
|
748
750
|
raise ValueError(f"Extensão de arquivo não suportada: {file_extension}")
|
|
749
751
|
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import numpy
|
|
2
|
+
import asyncio
|
|
3
|
+
import sys
|
|
4
|
+
import os
|
|
5
|
+
import io
|
|
6
|
+
from pywinauto.keyboard import send_keys
|
|
7
|
+
|
|
8
|
+
# sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..')))
|
|
9
|
+
from worker_automate_hub.models.dto.rpa_historico_request_dto import (
|
|
10
|
+
RpaHistoricoStatusEnum,
|
|
11
|
+
RpaRetornoProcessoDTO,
|
|
12
|
+
RpaTagDTO,
|
|
13
|
+
RpaTagEnum,
|
|
14
|
+
)
|
|
15
|
+
from worker_automate_hub.models.dto.rpa_processo_entrada_dto import (
|
|
16
|
+
RpaProcessoEntradaDTO,
|
|
17
|
+
)
|
|
18
|
+
from worker_automate_hub.utils.util import (
|
|
19
|
+
kill_all_emsys,
|
|
20
|
+
worker_sleep,
|
|
21
|
+
)
|
|
22
|
+
from rich.console import Console
|
|
23
|
+
import pyautogui
|
|
24
|
+
from datetime import datetime
|
|
25
|
+
|
|
26
|
+
# from dateutil.relativedelta import relativedelta
|
|
27
|
+
from PIL import ImageFilter, ImageEnhance
|
|
28
|
+
from pytesseract import image_to_string
|
|
29
|
+
from pywinauto import Application, Desktop
|
|
30
|
+
import subprocess
|
|
31
|
+
import os
|
|
32
|
+
from worker_automate_hub.api.client import get_config_by_name, send_file
|
|
33
|
+
from worker_automate_hub.utils.utils_nfe_entrada import EMSys
|
|
34
|
+
import psutil
|
|
35
|
+
from time import sleep
|
|
36
|
+
|
|
37
|
+
pyautogui.PAUSE = 0.5
|
|
38
|
+
console = Console()
|
|
39
|
+
emsys = EMSys()
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def get_text_from_window(window, relative_coords, value=None):
|
|
43
|
+
try:
|
|
44
|
+
screenshot = window.capture_as_image()
|
|
45
|
+
imagem = screenshot.convert("L")
|
|
46
|
+
imagem = imagem.filter(ImageFilter.SHARPEN)
|
|
47
|
+
imagem = ImageEnhance.Contrast(imagem).enhance(2)
|
|
48
|
+
cropped_screenshot = imagem.crop(relative_coords)
|
|
49
|
+
texto = image_to_string(cropped_screenshot, lang="por")
|
|
50
|
+
return (value.upper() in texto.upper()) if value != None else texto.lower()
|
|
51
|
+
except Exception as error:
|
|
52
|
+
console.print(f"Error: {error}")
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
async def open_contabil_processes():
|
|
56
|
+
try:
|
|
57
|
+
console.print("Abrindo EMSys Contabil...")
|
|
58
|
+
os.startfile("C:\\Users\\automatehub\\Desktop\\Contabil\\contabil1.lnk")
|
|
59
|
+
await worker_sleep(3)
|
|
60
|
+
os.startfile("C:\\Users\\automatehub\\Desktop\\Contabil\\contabil2.lnk")
|
|
61
|
+
await worker_sleep(30)
|
|
62
|
+
os.startfile("C:\\Users\\automatehub\\Desktop\\Contabil\\contabil3.lnk")
|
|
63
|
+
await worker_sleep(20)
|
|
64
|
+
pyautogui.hotkey("win", "d")
|
|
65
|
+
await worker_sleep(4)
|
|
66
|
+
os.startfile("C:\\Users\\automatehub\\Desktop\\Contabil\\contabil4.lnk")
|
|
67
|
+
await worker_sleep(2)
|
|
68
|
+
except Exception as error:
|
|
69
|
+
console.print(f"Error: {error}")
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
async def geracao_balancetes_filial(
|
|
73
|
+
task: RpaProcessoEntradaDTO,
|
|
74
|
+
) -> RpaRetornoProcessoDTO:
|
|
75
|
+
try:
|
|
76
|
+
await kill_all_emsys()
|
|
77
|
+
await open_contabil_processes()
|
|
78
|
+
config = await get_config_by_name("login_emsys_contabil")
|
|
79
|
+
filial = task.configEntrada.get("filialEmpresaOrigem")
|
|
80
|
+
periodo_inicial = task.configEntrada.get("periodoInicial")
|
|
81
|
+
periodo_final = task.configEntrada.get("periodoFinal")
|
|
82
|
+
historico_id = task.historico_id
|
|
83
|
+
if historico_id:
|
|
84
|
+
console.print("Historico ID recuperado com sucesso...\n")
|
|
85
|
+
app = None
|
|
86
|
+
max_attempts = 30
|
|
87
|
+
console.print("Tentando encontrar janela de login...")
|
|
88
|
+
for attempt in range(max_attempts):
|
|
89
|
+
try:
|
|
90
|
+
app = Application(backend="win32").connect(
|
|
91
|
+
title="Selecione o Usuário para autenticação"
|
|
92
|
+
)
|
|
93
|
+
console.print("Janela encontrada!")
|
|
94
|
+
break
|
|
95
|
+
except:
|
|
96
|
+
console.print("Janela ainda nao encontrada...")
|
|
97
|
+
await worker_sleep(1)
|
|
98
|
+
if not app:
|
|
99
|
+
console.print("Nao foi possivel encontrar a janela de login...")
|
|
100
|
+
return RpaRetornoProcessoDTO(
|
|
101
|
+
sucesso=False,
|
|
102
|
+
retorno="Erro durante tentativa localizacao de janelas...",
|
|
103
|
+
status=RpaHistoricoStatusEnum.Falha,
|
|
104
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
|
105
|
+
)
|
|
106
|
+
await emsys.verify_warning_and_error("Erro", "&Ok")
|
|
107
|
+
await worker_sleep(4)
|
|
108
|
+
pyautogui.click(x=1021, y=127)
|
|
109
|
+
console.print("Logando...")
|
|
110
|
+
await emsys.verify_warning_and_error("Erro", "&Ok")
|
|
111
|
+
pyautogui.write(config.conConfiguracao.get("user"))
|
|
112
|
+
pyautogui.press("enter")
|
|
113
|
+
|
|
114
|
+
await worker_sleep(4)
|
|
115
|
+
pyautogui.write(config.conConfiguracao.get("pass"))
|
|
116
|
+
pyautogui.press("enter")
|
|
117
|
+
|
|
118
|
+
await worker_sleep(10)
|
|
119
|
+
|
|
120
|
+
main_window = None
|
|
121
|
+
for attempt in range(max_attempts):
|
|
122
|
+
main_window = Application().connect(title="EMSys [Contabil]")
|
|
123
|
+
main_window = main_window.top_window()
|
|
124
|
+
if main_window.exists():
|
|
125
|
+
console.print("Janela encontrada!")
|
|
126
|
+
break
|
|
127
|
+
console.print("Janela ainda nao encontrada...")
|
|
128
|
+
await worker_sleep(1)
|
|
129
|
+
|
|
130
|
+
if not main_window:
|
|
131
|
+
return RpaRetornoProcessoDTO(
|
|
132
|
+
sucesso=False,
|
|
133
|
+
retorno="Erro durante tentativa localizacao de janelas....",
|
|
134
|
+
status=RpaHistoricoStatusEnum.Falha,
|
|
135
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
# Adicionando foco
|
|
139
|
+
try:
|
|
140
|
+
main_window.set_focus()
|
|
141
|
+
console.print(f"Ativando janela: {main_window}")
|
|
142
|
+
except Exception as error:
|
|
143
|
+
console.print(f"Erro ao setar foco na janela: {main_window}")
|
|
144
|
+
|
|
145
|
+
await worker_sleep(4)
|
|
146
|
+
console.print("Cicar em BAL")
|
|
147
|
+
pyautogui.click(x=453, y=96)
|
|
148
|
+
await worker_sleep(4)
|
|
149
|
+
|
|
150
|
+
console.print("Preenchendo campo periodo...")
|
|
151
|
+
|
|
152
|
+
app = Application(backend="win32").connect(class_name="TFrmBalancete")
|
|
153
|
+
win = app.window(class_name="TFrmBalancete")
|
|
154
|
+
|
|
155
|
+
# Seus índices: inicial = found_index=1, final = found_index=0
|
|
156
|
+
ctrl_inicial = win.child_window(
|
|
157
|
+
class_name="TRzEditDate", found_index=1
|
|
158
|
+
).wrapper_object()
|
|
159
|
+
ctrl_final = win.child_window(
|
|
160
|
+
class_name="TRzEditDate", found_index=0
|
|
161
|
+
).wrapper_object()
|
|
162
|
+
|
|
163
|
+
# ---- Inicial ----
|
|
164
|
+
try:
|
|
165
|
+
ctrl_inicial.set_edit_text(periodo_inicial) # tenta via WM_SETTEXT
|
|
166
|
+
except Exception:
|
|
167
|
+
ctrl_inicial.set_focus()
|
|
168
|
+
ctrl_inicial.click_input()
|
|
169
|
+
send_keys("^a{DELETE}")
|
|
170
|
+
send_keys(
|
|
171
|
+
periodo_inicial.replace("/", "")
|
|
172
|
+
) # fallback: digita só dígitos (máscara)
|
|
173
|
+
|
|
174
|
+
# ---- Final ----
|
|
175
|
+
try:
|
|
176
|
+
ctrl_final.set_edit_text(periodo_final)
|
|
177
|
+
except Exception:
|
|
178
|
+
ctrl_final.set_focus()
|
|
179
|
+
ctrl_final.click_input()
|
|
180
|
+
send_keys("^a{DELETE}")
|
|
181
|
+
send_keys(periodo_final.replace("/", ""))
|
|
182
|
+
|
|
183
|
+
await worker_sleep(2)
|
|
184
|
+
|
|
185
|
+
console.print("Selecionar detalhada por centro de custo..")
|
|
186
|
+
detalhada = win.child_window(class_name="TRzComboBox", found_index=0)
|
|
187
|
+
detalhada.select("Centro de Custo")
|
|
188
|
+
|
|
189
|
+
await worker_sleep(6)
|
|
190
|
+
|
|
191
|
+
console.print("Selecionar considerar contas analíticas zerada")
|
|
192
|
+
contas_analit_zeradas = win.child_window(
|
|
193
|
+
class_name="TRzCheckBox", found_index=2
|
|
194
|
+
).click()
|
|
195
|
+
|
|
196
|
+
await worker_sleep(2)
|
|
197
|
+
|
|
198
|
+
console.print("Selecionar considerar contas sintéticas zerada")
|
|
199
|
+
contas_sint_zeradas = win.child_window(
|
|
200
|
+
class_name="TRzCheckBox", found_index=0
|
|
201
|
+
).click()
|
|
202
|
+
|
|
203
|
+
await worker_sleep(2)
|
|
204
|
+
|
|
205
|
+
console.print("Selecionar por filiais")
|
|
206
|
+
selec_filiais = win.child_window(
|
|
207
|
+
class_name="TRzCheckBox", found_index=3
|
|
208
|
+
).click()
|
|
209
|
+
|
|
210
|
+
await worker_sleep(2)
|
|
211
|
+
|
|
212
|
+
console.print("Selecionar CSV")
|
|
213
|
+
selec_csv = win.child_window(class_name="TRzComboBox", found_index=1)
|
|
214
|
+
selec_csv.select("Arquivo CSV")
|
|
215
|
+
|
|
216
|
+
await worker_sleep(2)
|
|
217
|
+
|
|
218
|
+
console.print("Clicar em gerar relatório")
|
|
219
|
+
btn_gerar_relatorio = win.child_window(
|
|
220
|
+
class_name="TBitBtn", found_index=0
|
|
221
|
+
).click()
|
|
222
|
+
|
|
223
|
+
# Selecionar filial
|
|
224
|
+
app = Application(backend="win32").connect(
|
|
225
|
+
title="Seleção de Empresas", timeout=10
|
|
226
|
+
)
|
|
227
|
+
dlg = app.window(title="Seleção de Empresas")
|
|
228
|
+
edit = dlg.child_window(class_name="TEdit", found_index=0).wrapper_object()
|
|
229
|
+
|
|
230
|
+
# Tenta via WM_SETTEXT
|
|
231
|
+
try:
|
|
232
|
+
edit.set_focus()
|
|
233
|
+
edit.set_edit_text("") # limpa
|
|
234
|
+
edit.set_edit_text("3") # escreve
|
|
235
|
+
except Exception:
|
|
236
|
+
# Fallback: digita como teclado
|
|
237
|
+
edit.set_focus()
|
|
238
|
+
edit.click_input()
|
|
239
|
+
send_keys("^a{DELETE}")
|
|
240
|
+
send_keys("3", with_spaces=True)
|
|
241
|
+
|
|
242
|
+
await worker_sleep(3)
|
|
243
|
+
|
|
244
|
+
# Marcar filial
|
|
245
|
+
imagem_alvo = "assets\\geracao_bal_filial\\btn_selec_uma_filial.png"
|
|
246
|
+
|
|
247
|
+
btn_sect_uma = pyautogui.locateCenterOnScreen(
|
|
248
|
+
imagem_alvo, confidence=0.9
|
|
249
|
+
) # requer opencv-python
|
|
250
|
+
if btn_sect_uma: # se achou, clica
|
|
251
|
+
pyautogui.click(btn_sect_uma)
|
|
252
|
+
|
|
253
|
+
btn_ok = dlg.child_window(class_name="TBitBtn", title="&OK").click()
|
|
254
|
+
|
|
255
|
+
# aguarda até a janela "Gera Arquivo CSV (Excel)" existir (ou ficar visível)
|
|
256
|
+
csv_win = Desktop(backend="win32").window(title="Gera Arquivo CSV (Excel)")
|
|
257
|
+
csv_win.wait("exists", timeout=3600)
|
|
258
|
+
|
|
259
|
+
app_csv = Application(backend="win32").connect(title="Gera Arquivo CSV (Excel)")
|
|
260
|
+
dlg_csv = app_csv.window(title="Gera Arquivo CSV (Excel)")
|
|
261
|
+
edit = dlg_csv.child_window(class_name="Edit", found_index=0)
|
|
262
|
+
# Tenta via WM_SETTEXT (mais estável)
|
|
263
|
+
try:
|
|
264
|
+
periodo_inicial = periodo_inicial.replace("/", "")
|
|
265
|
+
periodo_final = periodo_final.replace("/", "")
|
|
266
|
+
edit.set_focus()
|
|
267
|
+
edit.set_edit_text("") # limpa
|
|
268
|
+
edit.set_edit_text(
|
|
269
|
+
rf"C:\Users\automatehub\Downloads\balancete_{periodo_inicial}_{periodo_final}_{filial}"
|
|
270
|
+
)
|
|
271
|
+
except Exception:
|
|
272
|
+
# Fallback: digita como teclado
|
|
273
|
+
edit.set_focus()
|
|
274
|
+
edit.click_input()
|
|
275
|
+
send_keys("^a{DELETE}")
|
|
276
|
+
send_keys(
|
|
277
|
+
rf"C:\Users\automatehub\Downloads\balancete_{periodo_inicial}_{periodo_final}_{filial}",
|
|
278
|
+
with_spaces=True,
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
# Clicar em salvar
|
|
282
|
+
app = Application(backend="win32").connect(
|
|
283
|
+
title="Gera Arquivo CSV (Excel)", timeout=10
|
|
284
|
+
)
|
|
285
|
+
dlg = app.window(title="Gera Arquivo CSV (Excel)")
|
|
286
|
+
btn_salvar = dlg.child_window(class_name="Button", found_index=0).click()
|
|
287
|
+
|
|
288
|
+
await worker_sleep(3)
|
|
289
|
+
|
|
290
|
+
# Janela confirmação clicar em OK
|
|
291
|
+
app = Application(backend="win32").connect(title="Informação", timeout=10)
|
|
292
|
+
dlg = app.window(title="Informação")
|
|
293
|
+
btn_ok = dlg.child_window(class_name="Button", found_index=0).click()
|
|
294
|
+
|
|
295
|
+
console.print("Arquivo salvo com sucesso...\n")
|
|
296
|
+
await worker_sleep(3)
|
|
297
|
+
path_to_txt = rf"C:\Users\automatehub\Downloads\balancete_{periodo_inicial}_{periodo_final}_{filial}"
|
|
298
|
+
|
|
299
|
+
with open(f"{path_to_txt}.csv", "rb") as file:
|
|
300
|
+
file_bytes = io.BytesIO(file.read())
|
|
301
|
+
|
|
302
|
+
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
|
303
|
+
desArquivo = f"balancete_{periodo_inicial}_{periodo_final}_{filial}.csv"
|
|
304
|
+
try:
|
|
305
|
+
await send_file(
|
|
306
|
+
historico_id, desArquivo, "csv", file_bytes, file_extension="csv"
|
|
307
|
+
)
|
|
308
|
+
os.remove(path_to_txt + ".csv")
|
|
309
|
+
return RpaRetornoProcessoDTO(
|
|
310
|
+
sucesso=True,
|
|
311
|
+
retorno="Balancete gerado com sucesso",
|
|
312
|
+
status=RpaHistoricoStatusEnum.Sucesso,
|
|
313
|
+
)
|
|
314
|
+
except Exception as e:
|
|
315
|
+
result = f"Arquivo balancete gerado com sucesso, porém gerou erro ao realizar o envio para o backoffice {e} - Arquivo ainda salvo na dispositivo utilizado no diretório {path_to_txt}!"
|
|
316
|
+
console.print(result, style="bold red")
|
|
317
|
+
return RpaRetornoProcessoDTO(
|
|
318
|
+
sucesso=False,
|
|
319
|
+
retorno=result,
|
|
320
|
+
status=RpaHistoricoStatusEnum.Falha,
|
|
321
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
|
322
|
+
)
|
|
323
|
+
|
|
324
|
+
except Exception as erro:
|
|
325
|
+
return RpaRetornoProcessoDTO(
|
|
326
|
+
sucesso=False,
|
|
327
|
+
retorno=f"Erro durante o processo integração contabil, erro : {erro}",
|
|
328
|
+
status=RpaHistoricoStatusEnum.Falha,
|
|
329
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
|
330
|
+
)
|
|
@@ -105,6 +105,9 @@ from worker_automate_hub.tasks.jobs.opex_capex import (
|
|
|
105
105
|
from worker_automate_hub.tasks.jobs.entrada_de_notas_22 import (
|
|
106
106
|
entrada_de_notas_22,
|
|
107
107
|
)
|
|
108
|
+
from worker_automate_hub.tasks.jobs.geracao_balancetes_filial import (
|
|
109
|
+
geracao_balancetes_filial,
|
|
110
|
+
)
|
|
108
111
|
|
|
109
112
|
|
|
110
113
|
task_definitions = {
|
|
@@ -212,7 +215,8 @@ task_definitions = {
|
|
|
212
215
|
"16debe45-3520-4f63-acfe-ef0e8784fcab": extracao_saldo_estoque,
|
|
213
216
|
"9cbc6016-7c0e-4a3a-8ee9-fb9dc4b35e33": extracao_saldo_estoque_fiscal,
|
|
214
217
|
"07072711-c9d0-49e4-b180-530cecbe0728": opex_capex,
|
|
215
|
-
"98bc6679-2e6b-4757-9fdc-b27eebd98f54": entrada_de_notas_22
|
|
218
|
+
"98bc6679-2e6b-4757-9fdc-b27eebd98f54": entrada_de_notas_22,
|
|
219
|
+
"d7794924-0330-453c-b79b-74f3c8991562": geracao_balancetes_filial
|
|
216
220
|
}
|
|
217
221
|
|
|
218
222
|
|
|
File without changes
|
|
File without changes
|
{worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/api/__init__.py
RENAMED
|
File without changes
|
{worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/api/ahead_service.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/api/rdp_service.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/config/__init__.py
RENAMED
|
File without changes
|
{worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/config/settings.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/decorators/repeat.py
RENAMED
|
File without changes
|
{worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/decorators/retry.py
RENAMED
|
File without changes
|
|
File without changes
|
{worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/decorators/timeit.py
RENAMED
|
File without changes
|
{worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/models/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/tasks/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/utils/__init__.py
RENAMED
|
File without changes
|
{worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/utils/env.py
RENAMED
|
File without changes
|
|
File without changes
|
{worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/utils/logger.py
RENAMED
|
File without changes
|
{worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/utils/toast.py
RENAMED
|
File without changes
|
{worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/utils/updater.py
RENAMED
|
File without changes
|
{worker_automate_hub-0.5.815 → worker_automate_hub-0.5.817}/worker_automate_hub/utils/util.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|