worker-automate-hub 0.5.740__py3-none-any.whl → 0.5.742__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/extracao_saldo_estoque.py +232 -0
- worker_automate_hub/tasks/jobs/fidc_gerar_nosso_numero.py +4 -2
- worker_automate_hub/tasks/task_definitions.py +2 -0
- {worker_automate_hub-0.5.740.dist-info → worker_automate_hub-0.5.742.dist-info}/METADATA +1 -1
- {worker_automate_hub-0.5.740.dist-info → worker_automate_hub-0.5.742.dist-info}/RECORD +7 -6
- {worker_automate_hub-0.5.740.dist-info → worker_automate_hub-0.5.742.dist-info}/WHEEL +0 -0
- {worker_automate_hub-0.5.740.dist-info → worker_automate_hub-0.5.742.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,232 @@
|
|
1
|
+
import asyncio
|
2
|
+
import os
|
3
|
+
from datetime import datetime
|
4
|
+
from pywinauto import Application, timings, findwindows
|
5
|
+
import sys
|
6
|
+
import io
|
7
|
+
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..')))
|
8
|
+
|
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 rich.console import Console
|
19
|
+
import re
|
20
|
+
from pywinauto.keyboard import send_keys
|
21
|
+
import warnings
|
22
|
+
from pywinauto.application import Application
|
23
|
+
from worker_automate_hub.api.client import get_config_by_name, send_file
|
24
|
+
from worker_automate_hub.utils.util import (
|
25
|
+
kill_all_emsys,
|
26
|
+
login_emsys,
|
27
|
+
set_variable,
|
28
|
+
type_text_into_field,
|
29
|
+
worker_sleep,
|
30
|
+
)
|
31
|
+
from pywinauto_recorder.player import set_combobox
|
32
|
+
|
33
|
+
from datetime import timedelta
|
34
|
+
import pyautogui
|
35
|
+
from worker_automate_hub.utils.logger import logger
|
36
|
+
from worker_automate_hub.utils.utils_nfe_entrada import EMSys
|
37
|
+
|
38
|
+
emsys = EMSys()
|
39
|
+
|
40
|
+
console = Console()
|
41
|
+
pyautogui.PAUSE = 0.5
|
42
|
+
pyautogui.FAILSAFE = False
|
43
|
+
|
44
|
+
|
45
|
+
async def extracao_saldo_estoque(task: RpaProcessoEntradaDTO):
|
46
|
+
try:
|
47
|
+
config = await get_config_by_name("login_emsys")
|
48
|
+
periodo = task.configEntrada['periodo']
|
49
|
+
periodo_format = periodo.replace("/","")
|
50
|
+
filial = task.configEntrada['filialEmpresaOrigem']
|
51
|
+
historico_id = task.historico_id
|
52
|
+
await kill_all_emsys()
|
53
|
+
|
54
|
+
app = Application(backend="win32").start("C:\\Rezende\\EMSys3\\EMSys3_35.exe")
|
55
|
+
warnings.filterwarnings(
|
56
|
+
"ignore",
|
57
|
+
category=UserWarning,
|
58
|
+
message="32-bit application should be automated using 32-bit Python",
|
59
|
+
)
|
60
|
+
console.print("\nEMSys iniciando...", style="bold green")
|
61
|
+
return_login = await login_emsys(
|
62
|
+
config.conConfiguracao, app, task, filial_origem=filial
|
63
|
+
)
|
64
|
+
|
65
|
+
if return_login.sucesso == True:
|
66
|
+
type_text_into_field(
|
67
|
+
"Rel. Saldo Estoque ", app["TFrmMenuPrincipal"]["Edit"], True, "50"
|
68
|
+
)
|
69
|
+
pyautogui.press("enter")
|
70
|
+
await worker_sleep(2)
|
71
|
+
pyautogui.press("enter")
|
72
|
+
|
73
|
+
else:
|
74
|
+
logger.info(f"\nError Message: {return_login.retorno}")
|
75
|
+
console.print(f"\nError Message: {return_login.retorno}", style="bold red")
|
76
|
+
return return_login
|
77
|
+
|
78
|
+
await worker_sleep(2)
|
79
|
+
|
80
|
+
##### Janela Relatório Saldos do Estoque #####
|
81
|
+
# Marcar check box data
|
82
|
+
app = Application().connect(class_name="TFrmRelSaldoEstoque", timeout=60)
|
83
|
+
main_window = app["TFrmRelSaldoEstoque"]
|
84
|
+
main_window.set_focus()
|
85
|
+
|
86
|
+
# Captura o campo de data
|
87
|
+
data_chk = main_window.child_window(
|
88
|
+
class_name="TCheckBox", found_index=3
|
89
|
+
).click_input()
|
90
|
+
|
91
|
+
await worker_sleep(2)
|
92
|
+
# Insere a data
|
93
|
+
data_input = main_window.child_window(
|
94
|
+
class_name="TDBIEditDate", found_index=0
|
95
|
+
)
|
96
|
+
|
97
|
+
data_input.set_edit_text(periodo)
|
98
|
+
|
99
|
+
# Clicar em gerar relatório
|
100
|
+
btn_gerar = main_window.child_window(
|
101
|
+
class_name="TBitBtn", found_index=0
|
102
|
+
).click_input()
|
103
|
+
|
104
|
+
# Aguarda até 60 segundos para a janela aparecer
|
105
|
+
timings.wait_until_passes(
|
106
|
+
timeout=1800,
|
107
|
+
retry_interval=1,
|
108
|
+
func=lambda: Application().connect(class_name="TFrmPreviewRelatorio")
|
109
|
+
)
|
110
|
+
|
111
|
+
await worker_sleep(2)
|
112
|
+
|
113
|
+
# Conecta à janela Preview Relatorio
|
114
|
+
app = Application().connect(class_name="TFrmPreviewRelatorio")
|
115
|
+
main_window = app["TFrmPreviewRelatorio"]
|
116
|
+
main_window.set_focus()
|
117
|
+
|
118
|
+
# Clicar em salvar
|
119
|
+
caminho = r"assets\\extracao_realtorios\\btn_salvar.png"
|
120
|
+
# Verifica se o arquivo existe
|
121
|
+
if os.path.isfile(caminho):
|
122
|
+
print("A imagem existe:", caminho)
|
123
|
+
|
124
|
+
# Procura a imagem na tela
|
125
|
+
pos = pyautogui.locateCenterOnScreen(caminho, confidence=0.9) # ajuste o confidence se necessário
|
126
|
+
if pos:
|
127
|
+
pyautogui.click(pos) # clica no centro da imagem
|
128
|
+
print("Clique realizado na imagem.")
|
129
|
+
else:
|
130
|
+
print("Imagem encontrada no disco, mas não está visível na tela.")
|
131
|
+
else:
|
132
|
+
print("A imagem NÃO existe:", caminho)
|
133
|
+
|
134
|
+
await worker_sleep(2)
|
135
|
+
|
136
|
+
# Conecta na janela Configuração para Salvar Arquivo
|
137
|
+
app = Application().connect(class_name="TFrmRelatorioFormato")
|
138
|
+
main_window = app["TFrmRelatorioFormato"]
|
139
|
+
main_window.set_focus()
|
140
|
+
# Acessa o ComboBox pelo identificador conhecido
|
141
|
+
combo = main_window.ComboBox
|
142
|
+
|
143
|
+
# Garante que existe "Excel" na lista
|
144
|
+
itens = combo.texts()
|
145
|
+
print("Itens do ComboBox:", itens)
|
146
|
+
|
147
|
+
# Seleciona o Excel correto (o segundo da lista, índice 8)
|
148
|
+
combo.select(8)
|
149
|
+
|
150
|
+
await worker_sleep(2)
|
151
|
+
|
152
|
+
# Clicar em Salvar
|
153
|
+
btn_salvar = main_window.child_window(
|
154
|
+
class_name="TBitBtn", found_index=1
|
155
|
+
).click_input()
|
156
|
+
|
157
|
+
await worker_sleep(5)
|
158
|
+
|
159
|
+
# Conecta na janela "Salvar para arquivo"
|
160
|
+
app = Application().connect(title_re="Salvar para arquivo", timeout=30)
|
161
|
+
main_window = app.window(title_re="Salvar para arquivo")
|
162
|
+
|
163
|
+
# Campo Nome (Edit) - use set_edit_text para evitar problemas de escape
|
164
|
+
campo_nome = main_window.child_window(class_name="Edit", control_id=1148).wrapper_object()
|
165
|
+
caminho_arquivo = rf"C:\Users\automatehub\Downloads\saldo_estoque_{periodo_format}_{filial}.xlsx"
|
166
|
+
campo_nome.set_focus()
|
167
|
+
campo_nome.set_edit_text(caminho_arquivo)
|
168
|
+
|
169
|
+
print("✅ Texto inserido no campo Nome")
|
170
|
+
|
171
|
+
await worker_sleep(2)
|
172
|
+
|
173
|
+
# Clicar em ok para salvar
|
174
|
+
btn_ok = main_window.child_window(
|
175
|
+
class_name="Button", found_index=0
|
176
|
+
).click_input()
|
177
|
+
|
178
|
+
await worker_sleep(5)
|
179
|
+
|
180
|
+
caminho_img = r"assets\\extracao_realtorios\\janela_printing.png"
|
181
|
+
|
182
|
+
# Aguarda até a janela com título "Printing" (ou "Salvando...") fechar
|
183
|
+
try:
|
184
|
+
app = Application().connect(title_re="Printing") # conecta se existir
|
185
|
+
janela = app.window(title_re="Printing")
|
186
|
+
|
187
|
+
print("⏳ Aguardando a janela 'Printing' sumir...")
|
188
|
+
janela.wait_not("visible", timeout=60) # espera até 60 segundos
|
189
|
+
print("✅ Janela 'Printing' fechada.")
|
190
|
+
|
191
|
+
except findwindows.ElementNotFoundError:
|
192
|
+
print("⚠️ Janela 'Printing' não estava aberta.")
|
193
|
+
|
194
|
+
nome_com_extensao = f'saldo_estoque_{periodo_format}_{filial}.xlsx'
|
195
|
+
# lê o arquivo
|
196
|
+
with open(f"{caminho_arquivo}", "rb") as file:
|
197
|
+
file_bytes = io.BytesIO(file.read())
|
198
|
+
|
199
|
+
console.print("Enviar Excel para o BOF")
|
200
|
+
try:
|
201
|
+
await send_file(
|
202
|
+
historico_id,
|
203
|
+
nome_com_extensao,
|
204
|
+
"xlsx",
|
205
|
+
file_bytes,
|
206
|
+
file_extension="xlsx",
|
207
|
+
)
|
208
|
+
console.print("Removendo arquivo XLS da pasta downloads")
|
209
|
+
os.remove(f"{caminho_arquivo}")
|
210
|
+
|
211
|
+
except Exception as e:
|
212
|
+
console.print(f"Erro ao enviar o arquivo: {e}", style="bold red")
|
213
|
+
return RpaRetornoProcessoDTO(
|
214
|
+
sucesso=False,
|
215
|
+
retorno=f"Erro ao enviar o arquivo: {e}",
|
216
|
+
status=RpaHistoricoStatusEnum.Falha,
|
217
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
218
|
+
)
|
219
|
+
|
220
|
+
print("")
|
221
|
+
|
222
|
+
except Exception as ex:
|
223
|
+
retorno = f"Erro Processo Fechamento Balancete: {str(ex)}"
|
224
|
+
logger.error(retorno)
|
225
|
+
console.print(retorno, style="bold red")
|
226
|
+
return RpaRetornoProcessoDTO(
|
227
|
+
sucesso=False,
|
228
|
+
retorno=retorno,
|
229
|
+
status=RpaHistoricoStatusEnum.Falha,
|
230
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
231
|
+
)
|
232
|
+
|
@@ -220,10 +220,12 @@ async def gerar_nosso_numero(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoD
|
|
220
220
|
else: #Banco do Brasil Fidc
|
221
221
|
code.type_keys("4")
|
222
222
|
pyautogui.hotkey("tab")
|
223
|
-
|
223
|
+
|
224
|
+
await worker_sleep(3)
|
224
225
|
button_ok = main_window.child_window(class_name="TBitBtn", found_index=0)
|
225
226
|
button_ok.click()
|
226
|
-
|
227
|
+
pyautogui.click(855, 740)
|
228
|
+
|
227
229
|
await worker_sleep(80)
|
228
230
|
boleto_argenta = None
|
229
231
|
max_trys = 5
|
@@ -31,6 +31,7 @@ from worker_automate_hub.tasks.jobs.entrada_de_notas_9000 import entrada_de_nota
|
|
31
31
|
from worker_automate_hub.tasks.jobs.entrada_de_notas_7139 import entrada_de_notas_7139
|
32
32
|
from worker_automate_hub.tasks.jobs.entrada_de_notas_36 import entrada_de_notas_36
|
33
33
|
from worker_automate_hub.tasks.jobs.entrada_de_notas_503 import entrada_de_notas_503
|
34
|
+
from worker_automate_hub.tasks.jobs.extracao_saldo_estoque import extracao_saldo_estoque
|
34
35
|
from worker_automate_hub.tasks.jobs.fidc_remessa_cobranca_cnab240 import (
|
35
36
|
remessa_cobranca_cnab240,
|
36
37
|
)
|
@@ -198,6 +199,7 @@ task_definitions = {
|
|
198
199
|
"58de6a65-68cd-4e68-ab28-31b543b6de02": transferencias, # Logistica reverse
|
199
200
|
"ca7ac373-e8e7-4ac2-aa7e-298070e0d9a0": extracao_fechamento_contabil,
|
200
201
|
"8c28726d-458d-4119-afa0-202695b79a8f": extracao_fechamento_emsys,
|
202
|
+
"16debe45-3520-4f63-acfe-ef0e8784fcab": extracao_saldo_estoque
|
201
203
|
}
|
202
204
|
|
203
205
|
|
@@ -70,9 +70,10 @@ worker_automate_hub/tasks/jobs/entrada_de_notas_9000.py,sha256=cDMzDGcylhg9pwtCP
|
|
70
70
|
worker_automate_hub/tasks/jobs/exemplo_processo.py,sha256=nV0iLoip2FH2-FhLmhX3nPqsfl_MPufZ3E5Q5krJvdc,3544
|
71
71
|
worker_automate_hub/tasks/jobs/extracao_fechamento_contabil.py,sha256=6Kr5DKjKLqtFvGzyiXtt7xrQsuU898l8pQXDq9C6AX8,19567
|
72
72
|
worker_automate_hub/tasks/jobs/extracao_fechamento_emsys.py,sha256=-T2nZUDiFrUGm_KLxJd_4qcrageDxVpWW3KAAniLFC4,21448
|
73
|
+
worker_automate_hub/tasks/jobs/extracao_saldo_estoque.py,sha256=EIPmA73cOaiw3hGQ6ZG4BGfGzV_InufAMZUZuXBuIq8,8219
|
73
74
|
worker_automate_hub/tasks/jobs/fechar_conexao_rdp.py,sha256=UWAKCS2dbfgDlSQOBdjmVJXfD1MMuUrOi3weDgB0CAc,5718
|
74
75
|
worker_automate_hub/tasks/jobs/fidc_exportacao_docs_portal_b2b.py,sha256=tWUmYy3Zhi3JEt8AoqTsWpU-wbf5-OxhCrTOooh1WH4,15616
|
75
|
-
worker_automate_hub/tasks/jobs/fidc_gerar_nosso_numero.py,sha256=
|
76
|
+
worker_automate_hub/tasks/jobs/fidc_gerar_nosso_numero.py,sha256=FAmcCqKVjedf7wIped8XRLIZ9S3oWc6fakF-r1Zm0kg,12637
|
76
77
|
worker_automate_hub/tasks/jobs/fidc_remessa_cobranca_cnab240.py,sha256=XCbIZG1y7eTrBFF8ArVbOij_FbkFkIXNpwZusILmiVo,15701
|
77
78
|
worker_automate_hub/tasks/jobs/fidc_retorno_cobranca.py,sha256=mmBW7KetUeRjiZkjnrxMKGX32io3YLZ8KGaY5_o7new,11891
|
78
79
|
worker_automate_hub/tasks/jobs/geracao_aprovacao_pedidos.py,sha256=QzK2aG5d9pmFbb8cTaNm3LWf5NMkmCvBkgo70gcLu0c,14781
|
@@ -88,7 +89,7 @@ worker_automate_hub/tasks/jobs/opex_capex.py,sha256=8iOhWY0BUXugitJa-a0jtsPh656L
|
|
88
89
|
worker_automate_hub/tasks/jobs/playground.py,sha256=7vWDg9DwToHwGJ6_XOa8TQ6LmfRV5Qz2TaOV3q3P9sA,1918
|
89
90
|
worker_automate_hub/tasks/jobs/sped_fiscal.py,sha256=Zsq-IwKxA0b2tikO6Rri4WXVj10jK-Jd0-gxk8yVBH0,31064
|
90
91
|
worker_automate_hub/tasks/jobs/transferencias.py,sha256=X-hbz0GSsdeUHOZlz_wZ1XvNfWiQI0Ms2bD7VP-mcbE,45539
|
91
|
-
worker_automate_hub/tasks/task_definitions.py,sha256=
|
92
|
+
worker_automate_hub/tasks/task_definitions.py,sha256=BKDgrkN0z6gq5V6R5pku6tIZeHQhNlDggNH3faunRH0,12115
|
92
93
|
worker_automate_hub/tasks/task_executor.py,sha256=9dmLUlMpJOI7FhbaFE593TcWnDxBvuXbGVecs1aaJxE,5728
|
93
94
|
worker_automate_hub/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
94
95
|
worker_automate_hub/utils/env.py,sha256=TacQjGRO7PUNpttrhTAc5Gnegaiysl2Knsv1P8qfkfs,57
|
@@ -99,7 +100,7 @@ worker_automate_hub/utils/updater.py,sha256=en2FCGhI8aZ-JNP3LQm64NJDc4awCNW7UhbV
|
|
99
100
|
worker_automate_hub/utils/util.py,sha256=nV09AF8lu5poiMzWMAAgVS_VWvEuIRfNDmx46V7Nvzk,207279
|
100
101
|
worker_automate_hub/utils/utils_nfe_entrada.py,sha256=TOXKSHOPxy8N3-ROpTGjNIHstX0i2b8qekcj1tRvjG8,38174
|
101
102
|
worker_automate_hub/worker.py,sha256=uhZ3f-iaQ1i8cANbljp50vkYl-Xm0_sHtjwwF_2y72o,7191
|
102
|
-
worker_automate_hub-0.5.
|
103
|
-
worker_automate_hub-0.5.
|
104
|
-
worker_automate_hub-0.5.
|
105
|
-
worker_automate_hub-0.5.
|
103
|
+
worker_automate_hub-0.5.742.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
|
104
|
+
worker_automate_hub-0.5.742.dist-info/METADATA,sha256=ULkTf6SLRSNXS-W1q9H3Xu_byRFzQl_BMATU_TUa77A,3049
|
105
|
+
worker_automate_hub-0.5.742.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
106
|
+
worker_automate_hub-0.5.742.dist-info/RECORD,,
|
File without changes
|
{worker_automate_hub-0.5.740.dist-info → worker_automate_hub-0.5.742.dist-info}/entry_points.txt
RENAMED
File without changes
|