worker-automate-hub 0.5.756__py3-none-any.whl → 0.5.757__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_fiscal.py +57 -30
- {worker_automate_hub-0.5.756.dist-info → worker_automate_hub-0.5.757.dist-info}/METADATA +1 -1
- {worker_automate_hub-0.5.756.dist-info → worker_automate_hub-0.5.757.dist-info}/RECORD +5 -5
- {worker_automate_hub-0.5.756.dist-info → worker_automate_hub-0.5.757.dist-info}/WHEEL +0 -0
- {worker_automate_hub-0.5.756.dist-info → worker_automate_hub-0.5.757.dist-info}/entry_points.txt +0 -0
@@ -4,6 +4,7 @@ from datetime import datetime
|
|
4
4
|
from pywinauto import Application, timings, findwindows, keyboard
|
5
5
|
import sys
|
6
6
|
import io
|
7
|
+
|
7
8
|
# sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..')))
|
8
9
|
|
9
10
|
from worker_automate_hub.models.dto.rpa_historico_request_dto import (
|
@@ -42,12 +43,14 @@ pyautogui.PAUSE = 0.5
|
|
42
43
|
pyautogui.FAILSAFE = False
|
43
44
|
|
44
45
|
|
45
|
-
async def extracao_saldo_estoque_fiscal(
|
46
|
+
async def extracao_saldo_estoque_fiscal(
|
47
|
+
task: RpaProcessoEntradaDTO,
|
48
|
+
) -> RpaRetornoProcessoDTO:
|
46
49
|
try:
|
47
50
|
config = await get_config_by_name("login_emsys_fiscal")
|
48
|
-
periodo = task.configEntrada[
|
49
|
-
periodo_format = periodo.replace("/","")
|
50
|
-
filial = task.configEntrada[
|
51
|
+
periodo = task.configEntrada["periodo"]
|
52
|
+
periodo_format = periodo.replace("/", "")
|
53
|
+
filial = task.configEntrada["filialEmpresaOrigem"]
|
51
54
|
historico_id = task.historico_id
|
52
55
|
await kill_all_emsys()
|
53
56
|
|
@@ -56,7 +59,7 @@ async def extracao_saldo_estoque_fiscal(task: RpaProcessoEntradaDTO) -> RpaRetor
|
|
56
59
|
# Fecha a instancia do emsys - caso esteja aberta
|
57
60
|
await kill_all_emsys()
|
58
61
|
|
59
|
-
app = Application(backend="win32").start("C:\\Rezende\\EMSys3\\
|
62
|
+
app = Application(backend="win32").start("C:\\Rezende\\EMSys3\\EMSysFiscal.exe")
|
60
63
|
warnings.filterwarnings(
|
61
64
|
"ignore",
|
62
65
|
category=UserWarning,
|
@@ -100,7 +103,7 @@ async def extracao_saldo_estoque_fiscal(task: RpaProcessoEntradaDTO) -> RpaRetor
|
|
100
103
|
await worker_sleep(7)
|
101
104
|
|
102
105
|
##### Janela Movimento Livros Fiscais #####
|
103
|
-
|
106
|
+
# Conecta na janela principal
|
104
107
|
app = Application().connect(class_name="TFrmMovtoLivroFiscal")
|
105
108
|
main_window = app.window(class_name="TFrmMovtoLivroFiscal")
|
106
109
|
main_window.wait("exists enabled visible ready", timeout=20)
|
@@ -116,11 +119,11 @@ async def extracao_saldo_estoque_fiscal(task: RpaProcessoEntradaDTO) -> RpaRetor
|
|
116
119
|
|
117
120
|
# Limpa e digita
|
118
121
|
keyboard.send_keys("^a{BACKSPACE}07/2025")
|
119
|
-
|
122
|
+
|
120
123
|
# Seleciona inventário
|
121
124
|
chk_inventario = main_window.child_window(
|
122
125
|
class_name="TcxCheckBox", found_index=6
|
123
|
-
).click_input()
|
126
|
+
).click_input()
|
124
127
|
|
125
128
|
await worker_sleep(2)
|
126
129
|
|
@@ -130,7 +133,9 @@ async def extracao_saldo_estoque_fiscal(task: RpaProcessoEntradaDTO) -> RpaRetor
|
|
130
133
|
if os.path.exists(imagem_botao):
|
131
134
|
try:
|
132
135
|
# Localiza a imagem na tela
|
133
|
-
botao = pyautogui.locateCenterOnScreen(
|
136
|
+
botao = pyautogui.locateCenterOnScreen(
|
137
|
+
imagem_botao, confidence=0.9
|
138
|
+
) # confidence precisa do opencv instalado
|
134
139
|
if botao:
|
135
140
|
pyautogui.click(botao)
|
136
141
|
print("Botão clicado com sucesso!")
|
@@ -140,7 +145,7 @@ async def extracao_saldo_estoque_fiscal(task: RpaProcessoEntradaDTO) -> RpaRetor
|
|
140
145
|
print(f"Erro ao localizar/clicar na imagem: {e}")
|
141
146
|
else:
|
142
147
|
print("Caminho da imagem não existe.")
|
143
|
-
|
148
|
+
|
144
149
|
##### Janela Perguntas da Geração Livros Fiscais #####
|
145
150
|
app = Application().connect(class_name="TPerguntasLivrosFiscaisForm")
|
146
151
|
main_window = app.window(class_name="TPerguntasLivrosFiscaisForm")
|
@@ -149,7 +154,9 @@ async def extracao_saldo_estoque_fiscal(task: RpaProcessoEntradaDTO) -> RpaRetor
|
|
149
154
|
respostas = ["Não", "Sim", "Não", "Não"]
|
150
155
|
|
151
156
|
for i, resposta in enumerate(respostas):
|
152
|
-
combo = main_window.child_window(
|
157
|
+
combo = main_window.child_window(
|
158
|
+
class_name="TDBIComboBoxValues", found_index=i
|
159
|
+
).wrapper_object()
|
153
160
|
combo.set_focus()
|
154
161
|
combo.click_input()
|
155
162
|
await worker_sleep(0.1)
|
@@ -159,12 +166,14 @@ async def extracao_saldo_estoque_fiscal(task: RpaProcessoEntradaDTO) -> RpaRetor
|
|
159
166
|
main_window.child_window(class_name="TButton", found_index=1).click_input()
|
160
167
|
|
161
168
|
await worker_sleep(2)
|
162
|
-
|
169
|
+
|
163
170
|
##### Janela Gerar Registros #####
|
164
171
|
app = Application(backend="win32").connect(title="Gerar Registros")
|
165
172
|
main_window = app.window(title="Gerar Registros")
|
166
173
|
# Clicar em Sim
|
167
|
-
btn_sim = main_window.child_window(
|
174
|
+
btn_sim = main_window.child_window(
|
175
|
+
class_name="Button", found_index=1
|
176
|
+
).click_input()
|
168
177
|
|
169
178
|
await worker_sleep(2)
|
170
179
|
|
@@ -172,14 +181,16 @@ async def extracao_saldo_estoque_fiscal(task: RpaProcessoEntradaDTO) -> RpaRetor
|
|
172
181
|
app = Application().connect(class_name="TFrmMotvoMotivoInventario")
|
173
182
|
main_window = app.window(class_name="TFrmMotvoMotivoInventario")
|
174
183
|
main_window.wait("exists enabled visible ready", timeout=20)
|
175
|
-
slc_01 = main_window.child_window(
|
184
|
+
slc_01 = main_window.child_window(
|
185
|
+
class_name="TDBIComboBoxValues", found_index=0
|
186
|
+
).click_input()
|
176
187
|
await worker_sleep(0.1)
|
177
188
|
keyboard.send_keys("01" + "{ENTER}")
|
178
189
|
await worker_sleep(0.2)
|
179
190
|
|
180
191
|
# Clicar em confirmar
|
181
192
|
main_window.child_window(class_name="TBitBtn", found_index=0).click_input()
|
182
|
-
|
193
|
+
|
183
194
|
await worker_sleep(5)
|
184
195
|
|
185
196
|
##### Conecta à janela Preview Relatorio #####
|
@@ -204,14 +215,16 @@ async def extracao_saldo_estoque_fiscal(task: RpaProcessoEntradaDTO) -> RpaRetor
|
|
204
215
|
|
205
216
|
await worker_sleep(2)
|
206
217
|
|
207
|
-
# Clicar em visualizar livro
|
218
|
+
# Clicar em visualizar livro
|
208
219
|
caminho = r"assets\\extracao_relatorios\\btn_visu_livros.png"
|
209
220
|
# Verifica se o arquivo existe
|
210
221
|
if os.path.isfile(caminho):
|
211
222
|
print("A imagem existe:", caminho)
|
212
223
|
|
213
224
|
# Procura a imagem na tela
|
214
|
-
pos = pyautogui.locateCenterOnScreen(
|
225
|
+
pos = pyautogui.locateCenterOnScreen(
|
226
|
+
caminho, confidence=0.9
|
227
|
+
) # ajuste o confidence se necessário
|
215
228
|
if pos:
|
216
229
|
pyautogui.click(pos) # clica no centro da imagem
|
217
230
|
print("Clique realizado na imagem.")
|
@@ -226,12 +239,16 @@ async def extracao_saldo_estoque_fiscal(task: RpaProcessoEntradaDTO) -> RpaRetor
|
|
226
239
|
app = Application().connect(class_name="TFrmMovtoLivroFiscal")
|
227
240
|
main_window = app.window(class_name="TFrmMovtoLivroFiscal")
|
228
241
|
main_window.wait("exists enabled visible ready", timeout=20)
|
229
|
-
input_7 = main_window.child_window(
|
242
|
+
input_7 = main_window.child_window(
|
243
|
+
class_name="TDBIEditCode", found_index=0
|
244
|
+
).click_input()
|
230
245
|
await worker_sleep(0.1)
|
231
246
|
keyboard.send_keys("7" + "{TAB}")
|
232
247
|
await worker_sleep(0.2)
|
233
248
|
# Clicar em imprimir
|
234
|
-
btn_imprimir = main_window.child_window(
|
249
|
+
btn_imprimir = main_window.child_window(
|
250
|
+
class_name="TBitBtn", found_index=0
|
251
|
+
).click_input()
|
235
252
|
|
236
253
|
await worker_sleep(2)
|
237
254
|
|
@@ -239,7 +256,9 @@ async def extracao_saldo_estoque_fiscal(task: RpaProcessoEntradaDTO) -> RpaRetor
|
|
239
256
|
app = Application().connect(class_name="TFrmFRVisualizaTemplateMenuNew")
|
240
257
|
main_window = app.window(class_name="TFrmFRVisualizaTemplateMenuNew")
|
241
258
|
main_window.wait("exists enabled visible ready", timeout=20)
|
242
|
-
btn_gerar_rel = main_window.child_window(
|
259
|
+
btn_gerar_rel = main_window.child_window(
|
260
|
+
class_name="TBitBtn", found_index=1
|
261
|
+
).click_input()
|
243
262
|
|
244
263
|
await worker_sleep(2)
|
245
264
|
|
@@ -247,16 +266,20 @@ async def extracao_saldo_estoque_fiscal(task: RpaProcessoEntradaDTO) -> RpaRetor
|
|
247
266
|
app = Application().connect(class_name="TFrmFRParametroRelatorio")
|
248
267
|
main_window = app.window(class_name="TFrmFRParametroRelatorio")
|
249
268
|
main_window.wait("exists enabled visible ready", timeout=20)
|
250
|
-
slc_nao = main_window.child_window(
|
269
|
+
slc_nao = main_window.child_window(
|
270
|
+
class_name="TComboBox", found_index=0
|
271
|
+
).click_input()
|
251
272
|
await worker_sleep(0.1)
|
252
273
|
keyboard.send_keys("NAO" + "{ENTER}")
|
253
274
|
await worker_sleep(0.2)
|
254
275
|
|
255
276
|
# Clicar BOTAO OK
|
256
|
-
slc_nao = main_window.child_window(
|
277
|
+
slc_nao = main_window.child_window(
|
278
|
+
class_name="TBitBtn", found_index=1
|
279
|
+
).click_input()
|
257
280
|
|
258
281
|
await worker_sleep(2)
|
259
|
-
|
282
|
+
|
260
283
|
# Clicar em salvar
|
261
284
|
caminho = r"assets\\extracao_relatorios\\btn_salvar.png"
|
262
285
|
# Verifica se o arquivo existe
|
@@ -264,7 +287,9 @@ async def extracao_saldo_estoque_fiscal(task: RpaProcessoEntradaDTO) -> RpaRetor
|
|
264
287
|
print("A imagem existe:", caminho)
|
265
288
|
|
266
289
|
# Procura a imagem na tela
|
267
|
-
pos = pyautogui.locateCenterOnScreen(
|
290
|
+
pos = pyautogui.locateCenterOnScreen(
|
291
|
+
caminho, confidence=0.9
|
292
|
+
) # ajuste o confidence se necessário
|
268
293
|
if pos:
|
269
294
|
pyautogui.click(pos) # clica no centro da imagem
|
270
295
|
print("Clique realizado na imagem.")
|
@@ -293,8 +318,8 @@ async def extracao_saldo_estoque_fiscal(task: RpaProcessoEntradaDTO) -> RpaRetor
|
|
293
318
|
|
294
319
|
# Clicar em Salvar
|
295
320
|
btn_salvar = main_window.child_window(
|
296
|
-
|
297
|
-
).click_input()
|
321
|
+
class_name="TBitBtn", found_index=1
|
322
|
+
).click_input()
|
298
323
|
|
299
324
|
await worker_sleep(5)
|
300
325
|
|
@@ -303,7 +328,9 @@ async def extracao_saldo_estoque_fiscal(task: RpaProcessoEntradaDTO) -> RpaRetor
|
|
303
328
|
main_window = app.window(title_re="Salvar para arquivo")
|
304
329
|
|
305
330
|
# Campo Nome (Edit) - use set_edit_text para evitar problemas de escape
|
306
|
-
campo_nome = main_window.child_window(
|
331
|
+
campo_nome = main_window.child_window(
|
332
|
+
class_name="Edit", control_id=1148
|
333
|
+
).wrapper_object()
|
307
334
|
caminho_arquivo = rf"C:\Users\automatehub\Downloads\saldo_estoque_fiscal_{periodo_format}_{filial}.xlsx"
|
308
335
|
campo_nome.set_focus()
|
309
336
|
campo_nome.set_edit_text(caminho_arquivo)
|
@@ -311,7 +338,7 @@ async def extracao_saldo_estoque_fiscal(task: RpaProcessoEntradaDTO) -> RpaRetor
|
|
311
338
|
print("✅ Texto inserido no campo Nome")
|
312
339
|
|
313
340
|
await worker_sleep(3)
|
314
|
-
|
341
|
+
|
315
342
|
# Clicar em ok para salvar
|
316
343
|
keyboard.send_keys("{TAB}{TAB}{ENTER}", pause=0.3)
|
317
344
|
|
@@ -331,7 +358,7 @@ async def extracao_saldo_estoque_fiscal(task: RpaProcessoEntradaDTO) -> RpaRetor
|
|
331
358
|
except findwindows.ElementNotFoundError:
|
332
359
|
print("Janela 'Printing' não estava aberta.")
|
333
360
|
|
334
|
-
nome_com_extensao = f
|
361
|
+
nome_com_extensao = f"saldo_estoque_fiscal_{periodo_format}_{filial}.xlsx"
|
335
362
|
# lê o arquivo
|
336
363
|
with open(f"{caminho_arquivo}", "rb") as file:
|
337
364
|
file_bytes = io.BytesIO(file.read())
|
@@ -350,7 +377,7 @@ async def extracao_saldo_estoque_fiscal(task: RpaProcessoEntradaDTO) -> RpaRetor
|
|
350
377
|
return RpaRetornoProcessoDTO(
|
351
378
|
sucesso=True,
|
352
379
|
retorno="Relatório enviado com sucesso",
|
353
|
-
status=RpaHistoricoStatusEnum.Sucesso
|
380
|
+
status=RpaHistoricoStatusEnum.Sucesso,
|
354
381
|
)
|
355
382
|
|
356
383
|
except Exception as e:
|
@@ -71,7 +71,7 @@ worker_automate_hub/tasks/jobs/exemplo_processo.py,sha256=nV0iLoip2FH2-FhLmhX3nP
|
|
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
73
|
worker_automate_hub/tasks/jobs/extracao_saldo_estoque.py,sha256=LocziY74XAKdFyyPJPRt9_zs3J59-kysggjmpASqdxU,8384
|
74
|
-
worker_automate_hub/tasks/jobs/extracao_saldo_estoque_fiscal.py,sha256=
|
74
|
+
worker_automate_hub/tasks/jobs/extracao_saldo_estoque_fiscal.py,sha256=GqqvSuqwUfZNMSq3uxk-0Fc1UMKhBHYB7Fx238NQ198,14925
|
75
75
|
worker_automate_hub/tasks/jobs/fechar_conexao_rdp.py,sha256=UWAKCS2dbfgDlSQOBdjmVJXfD1MMuUrOi3weDgB0CAc,5718
|
76
76
|
worker_automate_hub/tasks/jobs/fidc_exportacao_docs_portal_b2b.py,sha256=tWUmYy3Zhi3JEt8AoqTsWpU-wbf5-OxhCrTOooh1WH4,15616
|
77
77
|
worker_automate_hub/tasks/jobs/fidc_gerar_nosso_numero.py,sha256=FAmcCqKVjedf7wIped8XRLIZ9S3oWc6fakF-r1Zm0kg,12637
|
@@ -101,7 +101,7 @@ worker_automate_hub/utils/updater.py,sha256=en2FCGhI8aZ-JNP3LQm64NJDc4awCNW7UhbV
|
|
101
101
|
worker_automate_hub/utils/util.py,sha256=V2WtWoETdTrAtGA8UgeqAAVphUj9KkGSZFzYsHJFATA,210055
|
102
102
|
worker_automate_hub/utils/utils_nfe_entrada.py,sha256=TOXKSHOPxy8N3-ROpTGjNIHstX0i2b8qekcj1tRvjG8,38174
|
103
103
|
worker_automate_hub/worker.py,sha256=uhZ3f-iaQ1i8cANbljp50vkYl-Xm0_sHtjwwF_2y72o,7191
|
104
|
-
worker_automate_hub-0.5.
|
105
|
-
worker_automate_hub-0.5.
|
106
|
-
worker_automate_hub-0.5.
|
107
|
-
worker_automate_hub-0.5.
|
104
|
+
worker_automate_hub-0.5.757.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
|
105
|
+
worker_automate_hub-0.5.757.dist-info/METADATA,sha256=msJL7NFdXEr3XxVm9XQlMGC9jb-fmC_n4wpV5m422ME,3049
|
106
|
+
worker_automate_hub-0.5.757.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
107
|
+
worker_automate_hub-0.5.757.dist-info/RECORD,,
|
File without changes
|
{worker_automate_hub-0.5.756.dist-info → worker_automate_hub-0.5.757.dist-info}/entry_points.txt
RENAMED
File without changes
|