worker-automate-hub 0.5.674__py3-none-any.whl → 0.5.675__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.
Potentially problematic release.
This version of worker-automate-hub might be problematic. Click here for more details.
- worker_automate_hub/tasks/jobs/abertura_livros_fiscais.py +375 -167
- {worker_automate_hub-0.5.674.dist-info → worker_automate_hub-0.5.675.dist-info}/METADATA +1 -1
- {worker_automate_hub-0.5.674.dist-info → worker_automate_hub-0.5.675.dist-info}/RECORD +5 -5
- {worker_automate_hub-0.5.674.dist-info → worker_automate_hub-0.5.675.dist-info}/WHEEL +0 -0
- {worker_automate_hub-0.5.674.dist-info → worker_automate_hub-0.5.675.dist-info}/entry_points.txt +0 -0
|
@@ -5,8 +5,9 @@ import sys
|
|
|
5
5
|
import os
|
|
6
6
|
import sys
|
|
7
7
|
import os
|
|
8
|
+
from pywinauto.findwindows import ElementNotFoundError
|
|
8
9
|
from pywinauto.keyboard import send_keys
|
|
9
|
-
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..')))
|
|
10
|
+
# sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..')))
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
from worker_automate_hub.utils.logger import logger
|
|
@@ -121,31 +122,17 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
|
121
122
|
pass
|
|
122
123
|
|
|
123
124
|
##### Janela Principal ####
|
|
124
|
-
console.print("Navegando para Livros Fiscais")
|
|
125
125
|
app = Application().connect(class_name="TFrmPrincipalFiscal", timeout=60)
|
|
126
126
|
main_window = app["TFrmPrincipalFiscal"]
|
|
127
127
|
main_window.set_focus()
|
|
128
|
-
input_livros = main_window.child_window(class_name="TEdit", found_index=0)
|
|
129
|
-
type_text_into_field(
|
|
130
|
-
"Livros Fiscais", input_livros, True, "50"
|
|
131
|
-
)
|
|
132
|
-
await worker_sleep(5)
|
|
133
128
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
console.print("Navegando nos elementos...\n")
|
|
142
|
-
main_window.child_window(class_name="TButton", found_index=0).click()
|
|
143
|
-
await worker_sleep(2)
|
|
144
|
-
except:
|
|
145
|
-
pass
|
|
146
|
-
|
|
147
|
-
# Clicar no input inicial
|
|
148
|
-
input_livros = main_window.child_window(class_name="TEdit", found_index=0).click_input()
|
|
129
|
+
# Localiza o campo TEdit
|
|
130
|
+
input_livros = main_window.child_window(class_name="TEdit", found_index=0)
|
|
131
|
+
input_livros.click_input()
|
|
132
|
+
await worker_sleep(1)
|
|
133
|
+
input_livros.set_edit_text("") # Limpa o campo
|
|
134
|
+
input_livros.type_keys("Livros Fiscais", with_spaces=True)
|
|
135
|
+
await worker_sleep(1)
|
|
149
136
|
pyautogui.press("enter")
|
|
150
137
|
await worker_sleep(2)
|
|
151
138
|
pyautogui.press("down")
|
|
@@ -155,68 +142,89 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
|
155
142
|
"\nPesquisa: 'Livros Fiscais' realizada com sucesso.",
|
|
156
143
|
style="bold green",
|
|
157
144
|
)
|
|
158
|
-
|
|
159
|
-
await worker_sleep(10)
|
|
160
|
-
|
|
161
|
-
try:
|
|
162
|
-
##### Janela Confirm #####
|
|
163
|
-
app = Application().connect(class_name="TMessageForm", timeout=5)
|
|
164
|
-
main_window = app["TMessageForm"]
|
|
165
|
-
main_window.set_focus()
|
|
166
|
-
|
|
167
|
-
# Clicar em Não
|
|
168
|
-
console.print("Navegando nos elementos...\n")
|
|
169
|
-
main_window.child_window(class_name="TButton", found_index=0).click()
|
|
170
|
-
await worker_sleep(2)
|
|
171
|
-
except:
|
|
172
|
-
pass
|
|
173
|
-
|
|
174
|
-
await worker_sleep(2)
|
|
175
145
|
|
|
176
|
-
##### Janela Principal ####
|
|
177
|
-
app = Application().connect(class_name="TFrmPrincipalFiscal", timeout=60)
|
|
178
|
-
main_window = app["TFrmPrincipalFiscal"]
|
|
179
|
-
main_window.set_focus()
|
|
180
|
-
|
|
181
|
-
# Clicar no input inicial
|
|
182
|
-
input_livros = main_window.child_window(class_name="TEdit", found_index=0).click_input()
|
|
183
|
-
pyautogui.press("enter")
|
|
184
|
-
await worker_sleep(2)
|
|
185
|
-
pyautogui.press("down")
|
|
186
146
|
await worker_sleep(2)
|
|
187
|
-
pyautogui.press("enter")
|
|
188
|
-
console.print(
|
|
189
|
-
"\nPesquisa: 'Livros Fiscais' realizada com sucesso.",
|
|
190
|
-
style="bold green",
|
|
191
|
-
)
|
|
192
147
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
148
|
+
console.print("Aguardando janela 'Movimento de Livro Fiscal' aparecer...")
|
|
149
|
+
|
|
150
|
+
# Tempo limite de espera (em segundos)
|
|
151
|
+
timeout = 60
|
|
152
|
+
inicio = time.time()
|
|
153
|
+
|
|
154
|
+
# Espera até a janela aparecer
|
|
155
|
+
while True:
|
|
156
|
+
try:
|
|
157
|
+
app = Application().connect(class_name="TFrmMovtoLivroFiscal", timeout=5)
|
|
158
|
+
break # Se conectar, sai do loop
|
|
159
|
+
except ElementNotFoundError:
|
|
160
|
+
if time() - inicio > timeout:
|
|
161
|
+
console.print("[bold red]Erro: Janela 'TFrmMovtoLivroFiscal' não apareceu dentro do tempo limite.[/bold red]")
|
|
162
|
+
raise
|
|
163
|
+
await worker_sleep(2)
|
|
164
|
+
|
|
165
|
+
console.print("Janela encontrada. Inserindo competência...")
|
|
166
|
+
|
|
167
|
+
# Acessa a janela e insere a competência
|
|
197
168
|
main_window = app["TFrmMovtoLivroFiscal"]
|
|
198
169
|
main_window.set_focus()
|
|
170
|
+
|
|
199
171
|
data_input = main_window.child_window(class_name="TDBIEditDate", found_index=0)
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
)
|
|
172
|
+
data_input.click_input()
|
|
173
|
+
await worker_sleep(1)
|
|
174
|
+
data_input.set_edit_text("")
|
|
204
175
|
|
|
205
|
-
#
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
competencia
|
|
209
|
-
|
|
210
|
-
await worker_sleep(
|
|
176
|
+
competencia = task.configEntrada.get("periodo") # Ex: "07/2025"
|
|
177
|
+
data_input.type_keys(competencia, with_spaces=True)
|
|
178
|
+
|
|
179
|
+
console.print(f"Competência '{competencia}' inserida com sucesso.")
|
|
180
|
+
|
|
181
|
+
await worker_sleep(2)
|
|
211
182
|
|
|
212
183
|
# Marcando caixa Entrada
|
|
213
184
|
console.print("Marcando caixa entrada")
|
|
214
185
|
entrada = main_window.child_window(class_name="TcxCheckBox", found_index=9).click_input()
|
|
215
186
|
|
|
187
|
+
await worker_sleep(2)
|
|
188
|
+
|
|
216
189
|
# Marcando caixa Saida
|
|
217
190
|
console.print("Marcando caixa saida")
|
|
218
|
-
|
|
219
|
-
|
|
191
|
+
saida_checkbox = main_window.child_window(class_name="TcxCheckBox", found_index=8)
|
|
192
|
+
|
|
193
|
+
# Tenta clicar inicialmente
|
|
194
|
+
saida_checkbox.click_input()
|
|
195
|
+
|
|
196
|
+
console.print("Aguardar marcar caixa de saida")
|
|
197
|
+
imagem = "assets\\abertura_livros\\saida_marcada.png"
|
|
198
|
+
|
|
199
|
+
tempo_limite = 600 # 10 minutos
|
|
200
|
+
intervalo = 2 # segundos entre verificações
|
|
201
|
+
|
|
202
|
+
inicio = time.time()
|
|
203
|
+
|
|
204
|
+
while True:
|
|
205
|
+
try:
|
|
206
|
+
localizacao = pyautogui.locateOnScreen(imagem, confidence=0.9)
|
|
207
|
+
except Exception as e:
|
|
208
|
+
print(f"Erro ao localizar imagem: {e}")
|
|
209
|
+
localizacao = None
|
|
210
|
+
|
|
211
|
+
if localizacao:
|
|
212
|
+
print("Imagem encontrada.")
|
|
213
|
+
break
|
|
214
|
+
|
|
215
|
+
if time.time() - inicio > tempo_limite:
|
|
216
|
+
print("Tempo esgotado. A imagem não apareceu.")
|
|
217
|
+
break
|
|
218
|
+
|
|
219
|
+
print("Imagem não apareceu na tela. Tentando clicar novamente na caixa de saída...")
|
|
220
|
+
try:
|
|
221
|
+
saida_checkbox.click_input()
|
|
222
|
+
except Exception as e:
|
|
223
|
+
print(f"Erro ao clicar na checkbox: {e}")
|
|
224
|
+
|
|
225
|
+
time.sleep(intervalo)
|
|
226
|
+
|
|
227
|
+
|
|
220
228
|
await worker_sleep(2)
|
|
221
229
|
|
|
222
230
|
# Clicando em incluir livro
|
|
@@ -238,41 +246,56 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
|
238
246
|
app = Application().connect(class_name="TPerguntasLivrosFiscaisForm", timeout=20)
|
|
239
247
|
main_window = app["TPerguntasLivrosFiscaisForm"]
|
|
240
248
|
main_window.set_focus()
|
|
241
|
-
console.print("Clicando sim em janela somar os valores de IPI Frete")
|
|
242
|
-
main_window.child_window(class_name="TDBIComboBoxValues", found_index=0).click_input()
|
|
243
249
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
250
|
+
try:
|
|
251
|
+
console.print("Clicando sim em janela somar os valores de IPI Frete")
|
|
252
|
+
main_window.child_window(class_name="TDBIComboBoxValues", found_index=0).click_input()
|
|
253
|
+
|
|
254
|
+
await worker_sleep(1)
|
|
255
|
+
send_keys("{ENTER}")
|
|
256
|
+
await worker_sleep(2)
|
|
257
|
+
except:
|
|
258
|
+
pass
|
|
248
259
|
console.print("Clicando sim em janela gerar Numero de Serie do SAT")
|
|
249
|
-
main_window.child_window(class_name="TDBIComboBoxValues", found_index=4).click_input()
|
|
250
|
-
|
|
251
|
-
await worker_sleep(1)
|
|
252
|
-
send_keys("Sim{ENTER}")
|
|
253
|
-
await worker_sleep(2)
|
|
254
|
-
|
|
255
|
-
console.print("Clicando sim em janela gerar Numero de Serie a partir da chave do documento")
|
|
256
|
-
main_window.child_window(class_name="TDBIComboBoxValues", found_index=1).click_input()
|
|
257
260
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
await worker_sleep(2)
|
|
261
|
-
|
|
262
|
-
console.print("Clicando sim em janela gerar livro com observação da nota fiscal")
|
|
263
|
-
main_window.child_window(class_name="TDBIComboBoxValues", found_index=3).click_input()
|
|
264
|
-
|
|
265
|
-
await worker_sleep(1)
|
|
266
|
-
send_keys("Sim{ENTER}")
|
|
267
|
-
await worker_sleep(2)
|
|
268
|
-
|
|
269
|
-
console.print("Clicando sim em janela somar valores de ICMS...")
|
|
270
|
-
main_window.child_window(class_name="TDBIComboBoxValues", found_index=2).click_input()
|
|
261
|
+
try:
|
|
262
|
+
main_window.child_window(class_name="TDBIComboBoxValues", found_index=4).click_input()
|
|
271
263
|
|
|
272
|
-
|
|
273
|
-
|
|
264
|
+
await worker_sleep(1)
|
|
265
|
+
send_keys("{ENTER}")
|
|
266
|
+
await worker_sleep(2)
|
|
267
|
+
except:
|
|
268
|
+
pass
|
|
274
269
|
|
|
275
|
-
|
|
270
|
+
try:
|
|
271
|
+
console.print("Clicando sim em janela gerar Numero de Serie a partir da chave do documento")
|
|
272
|
+
main_window.child_window(class_name="TDBIComboBoxValues", found_index=1).click_input()
|
|
273
|
+
|
|
274
|
+
await worker_sleep(1)
|
|
275
|
+
send_keys("{ENTER}")
|
|
276
|
+
await worker_sleep(2)
|
|
277
|
+
except:
|
|
278
|
+
pass
|
|
279
|
+
|
|
280
|
+
try:
|
|
281
|
+
console.print("Clicando sim em janela gerar livro com observação da nota fiscal")
|
|
282
|
+
main_window.child_window(class_name="TDBIComboBoxValues", found_index=3).click_input()
|
|
283
|
+
|
|
284
|
+
await worker_sleep(1)
|
|
285
|
+
send_keys("{ENTER}")
|
|
286
|
+
await worker_sleep(2)
|
|
287
|
+
except:
|
|
288
|
+
pass
|
|
289
|
+
|
|
290
|
+
try:
|
|
291
|
+
console.print("Clicando sim em janela somar valores de ICMS...")
|
|
292
|
+
main_window.child_window(class_name="TDBIComboBoxValues", found_index=2).click_input()
|
|
293
|
+
|
|
294
|
+
await worker_sleep(1)
|
|
295
|
+
send_keys("{ENTER}")
|
|
296
|
+
except:
|
|
297
|
+
pass
|
|
298
|
+
await worker_sleep(3)
|
|
276
299
|
|
|
277
300
|
# Clicar em confirmar
|
|
278
301
|
main_window.child_window(class_name="TButton", found_index=1).click_input()
|
|
@@ -287,16 +310,96 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
|
287
310
|
# Clicar em Sim
|
|
288
311
|
main_window.child_window(class_name="Button", found_index=0).click_input()
|
|
289
312
|
|
|
290
|
-
# try:
|
|
291
|
-
# # Esperando janela aguarde
|
|
292
|
-
# console.print("Aguardando tela de aguarde ser finalizada")
|
|
293
|
-
# await wait_aguarde_window_closed(app)
|
|
294
|
-
# await worker_sleep(5)
|
|
295
|
-
# except:
|
|
296
|
-
# pass
|
|
297
|
-
|
|
298
313
|
await worker_sleep(5)
|
|
299
314
|
|
|
315
|
+
console.print("Aguardar o término de carregar")
|
|
316
|
+
imagem = "assets\\abertura_livros\\livros_incluidos.png"
|
|
317
|
+
|
|
318
|
+
tempo_limite = 1200 # 20 minutos
|
|
319
|
+
intervalo = 2 # segundos entre as verificações
|
|
320
|
+
|
|
321
|
+
inicio = time.time()
|
|
322
|
+
|
|
323
|
+
while True:
|
|
324
|
+
janela_aberta = False
|
|
325
|
+
|
|
326
|
+
# 1. Verifica se a imagem apareceu e clica em 'Sim' na janela "Informação"
|
|
327
|
+
try:
|
|
328
|
+
if pyautogui.locateOnScreen(imagem, confidence=0.9):
|
|
329
|
+
print("Imagem 'livros_incluidos' apareceu na tela.")
|
|
330
|
+
try:
|
|
331
|
+
app_info = Application().connect(title="Informação", timeout=5)
|
|
332
|
+
info_window = app_info["Informação"]
|
|
333
|
+
info_window.set_focus()
|
|
334
|
+
console.print("Clicando em 'Sim' na janela Informação...")
|
|
335
|
+
info_window.child_window(class_name="Button", found_index=0).click_input()
|
|
336
|
+
except Exception as e:
|
|
337
|
+
print(f"Erro ao clicar em 'Sim' na janela Informação: {e}")
|
|
338
|
+
except Exception as e:
|
|
339
|
+
print(f"[Erro ao procurar imagem]: {e}")
|
|
340
|
+
|
|
341
|
+
# Verifica se a janela TMsgBox de aviso está aberta
|
|
342
|
+
try:
|
|
343
|
+
app_msgbox = Application().connect(class_name="TMsgBox", timeout=10)
|
|
344
|
+
box = app_msgbox["TMsgBox"]
|
|
345
|
+
print("Janela 'TMsgBox' encontrada.")
|
|
346
|
+
box.set_focus()
|
|
347
|
+
box.child_window(class_name="TBitBtn", found_index=0).click_input()
|
|
348
|
+
print("Clicou no botão 'TBitBtn'.")
|
|
349
|
+
except ElementNotFoundError:
|
|
350
|
+
pass
|
|
351
|
+
except Exception as e:
|
|
352
|
+
print(f"[Erro ao procurar/clicar na TMessageForm]: {e}")
|
|
353
|
+
|
|
354
|
+
# 2. Verifica e trata janela de confirmação TMessageForm
|
|
355
|
+
try:
|
|
356
|
+
app_msg = Application().connect(class_name="TMessageForm", timeout=2)
|
|
357
|
+
form = app_msg["TMessageForm"]
|
|
358
|
+
console.print("Janela de confirmação 'TMessageForm' encontrada.")
|
|
359
|
+
form.set_focus()
|
|
360
|
+
form.child_window(class_name="TButton", found_index=0).click_input()
|
|
361
|
+
print("Clicou no botão de confirmação.")
|
|
362
|
+
except ElementNotFoundError:
|
|
363
|
+
pass
|
|
364
|
+
except Exception as e:
|
|
365
|
+
print(f"[Erro ao procurar/clicar na TMessageForm]: {e}")
|
|
366
|
+
|
|
367
|
+
# 3. Verifica se a janela do relatório está aberta
|
|
368
|
+
try:
|
|
369
|
+
app_report = Application().connect(class_name="TFrmPreviewRelatorio", timeout=2)
|
|
370
|
+
janela = app_report["TFrmPreviewRelatorio"]
|
|
371
|
+
print("Janela 'TFrmPreviewRelatorio' encontrada.")
|
|
372
|
+
janela_aberta = True
|
|
373
|
+
except ElementNotFoundError:
|
|
374
|
+
pass
|
|
375
|
+
except Exception as e:
|
|
376
|
+
print(f"[Erro ao procurar TFrmPreviewRelatorio]: {e}")
|
|
377
|
+
|
|
378
|
+
# Se encontrou a janela de relatório, sai
|
|
379
|
+
if janela_aberta:
|
|
380
|
+
print("Relatório carregado. Saindo do loop.")
|
|
381
|
+
break
|
|
382
|
+
|
|
383
|
+
# Verifica tempo limite
|
|
384
|
+
if time.time() - inicio > tempo_limite:
|
|
385
|
+
print("Tempo esgotado. Relatório não carregado.")
|
|
386
|
+
break
|
|
387
|
+
|
|
388
|
+
print("Aguardando janela de relatório... (verificando novas confirmações se houver)")
|
|
389
|
+
time.sleep(intervalo)
|
|
390
|
+
|
|
391
|
+
await worker_sleep(5)
|
|
392
|
+
|
|
393
|
+
try:
|
|
394
|
+
app_msg = Application().connect(class_name="TMessageForm", timeout=5)
|
|
395
|
+
form = app_msg["TMessageForm"]
|
|
396
|
+
console.print("Janela de confirmação 'TMessageForm' encontrada.")
|
|
397
|
+
form.set_focus()
|
|
398
|
+
form.child_window(class_name="TButton", found_index=0).click_input()
|
|
399
|
+
print("Clicou no botão de confirmação.")
|
|
400
|
+
except:
|
|
401
|
+
pass
|
|
402
|
+
|
|
300
403
|
##### Janela Pré-visualizando Relatório #####
|
|
301
404
|
console.print("Fechar Janela Pré-visualizando Relatório ")
|
|
302
405
|
app = Application().connect(class_name="TFrmPreviewRelatorio", timeout=60)
|
|
@@ -306,32 +409,40 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
|
306
409
|
# Clicar em fechar
|
|
307
410
|
main_window.close()
|
|
308
411
|
|
|
309
|
-
await worker_sleep(
|
|
412
|
+
await worker_sleep(5)
|
|
310
413
|
|
|
311
|
-
|
|
312
|
-
console.print("Navegando para Livro de Apuração ICMS... ")
|
|
414
|
+
# Conecta na janela principal
|
|
313
415
|
app = Application().connect(class_name="TFrmPrincipalFiscal", timeout=60)
|
|
314
|
-
|
|
315
|
-
input_principal.set_focus()
|
|
316
|
-
input_livros = input_principal.child_window(class_name="TEdit", found_index=0)
|
|
317
|
-
type_text_into_field(
|
|
318
|
-
"Livro de Apuração ICMS", input_livros, True, "50"
|
|
319
|
-
)
|
|
320
|
-
await worker_sleep(5)
|
|
416
|
+
main_window = app["TFrmPrincipalFiscal"]
|
|
321
417
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
pass
|
|
330
|
-
console.print("Selecionar Livro de Apuração")
|
|
331
|
-
input_livros = input_principal.child_window(class_name="TEdit", found_index=0).click_input()
|
|
332
|
-
pyautogui.press("enter")
|
|
418
|
+
# Captura todos os controles do tipo Edit (inclui TEdit do Delphi)
|
|
419
|
+
edits = main_window.descendants(class_name="TEdit")
|
|
420
|
+
|
|
421
|
+
print(f"Foram encontrados {len(edits)} campos TEdit.")
|
|
422
|
+
|
|
423
|
+
campo = edits[0] # ou outro índice correto
|
|
424
|
+
campo.click_input()
|
|
333
425
|
await worker_sleep(1)
|
|
334
|
-
|
|
426
|
+
|
|
427
|
+
# Tenta limpar o campo e verifica se realmente foi limpo
|
|
428
|
+
max_tentativas = 3
|
|
429
|
+
for tentativa in range(max_tentativas):
|
|
430
|
+
campo.set_edit_text("")
|
|
431
|
+
await worker_sleep(0.5)
|
|
432
|
+
|
|
433
|
+
texto_atual = campo.window_text().strip()
|
|
434
|
+
if texto_atual == "":
|
|
435
|
+
break # Campo foi limpo com sucesso
|
|
436
|
+
print(f"Tentativa {tentativa+1}: campo ainda contém texto: '{texto_atual}'")
|
|
437
|
+
|
|
438
|
+
# Continua se o campo estiver limpo
|
|
439
|
+
campo.type_keys("Livro de Apuração ICMS", with_spaces=True)
|
|
440
|
+
await worker_sleep(1)
|
|
441
|
+
|
|
442
|
+
send_keys("{ENTER}")
|
|
443
|
+
await worker_sleep(2)
|
|
444
|
+
send_keys("{ENTER}")
|
|
445
|
+
|
|
335
446
|
|
|
336
447
|
await worker_sleep(5)
|
|
337
448
|
|
|
@@ -352,12 +463,13 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
|
352
463
|
|
|
353
464
|
main_window.close()
|
|
354
465
|
|
|
355
|
-
await worker_sleep(
|
|
466
|
+
await worker_sleep(5)
|
|
356
467
|
|
|
357
468
|
console.print("Selecionar Livro Saída aberto")
|
|
358
469
|
|
|
359
470
|
# Selecionar linha livro de saída aberto
|
|
360
|
-
imagem =
|
|
471
|
+
# imagem = "assets\\abertura_livros\\livro_saida_aberto.png"
|
|
472
|
+
imagem = "assets\\abertura_livros\\livro_saida_aberto.png"
|
|
361
473
|
|
|
362
474
|
# Tenta localizar a imagem na tela
|
|
363
475
|
localizacao = pyautogui.locateCenterOnScreen(imagem, confidence=0.9)
|
|
@@ -370,8 +482,8 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
|
370
482
|
console.print("Imagem livro de saída aberto não encontrado na tela.")
|
|
371
483
|
|
|
372
484
|
# Clicar em alterar livro
|
|
373
|
-
imagem =
|
|
374
|
-
|
|
485
|
+
# imagem = "assets\\abertura_livros\\alterar_livro.png"
|
|
486
|
+
imagem = "assets\\abertura_livros\\alterar_livro.png"
|
|
375
487
|
# Tenta localizar a imagem na tela
|
|
376
488
|
localizacao = pyautogui.locateCenterOnScreen(imagem, confidence=0.9) # você pode ajustar o confidence
|
|
377
489
|
|
|
@@ -385,8 +497,8 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
|
385
497
|
await worker_sleep(4)
|
|
386
498
|
|
|
387
499
|
# Clicar em Livro fiscal
|
|
388
|
-
imagem =
|
|
389
|
-
|
|
500
|
+
# imagem = "assets\\abertura_livros\\livro_fiscal.png"
|
|
501
|
+
imagem = "assets\\abertura_livros\\livro_fiscal.png"
|
|
390
502
|
# Tenta localizar a imagem na tela
|
|
391
503
|
localizacao = pyautogui.locateCenterOnScreen(imagem, confidence=0.9) # você pode ajustar o confidence
|
|
392
504
|
|
|
@@ -400,7 +512,8 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
|
400
512
|
await worker_sleep(4)
|
|
401
513
|
|
|
402
514
|
# Clicar em Gerar Relatório
|
|
403
|
-
imagem =
|
|
515
|
+
# imagem = "assets\\abertura_livros\\gerar_registros.png"
|
|
516
|
+
imagem = "assets\\abertura_livros\\gerar_registros.png"
|
|
404
517
|
|
|
405
518
|
# Tenta localizar a imagem na tela
|
|
406
519
|
localizacao = pyautogui.locateCenterOnScreen(imagem, confidence=0.9) # você pode ajustar o confidence
|
|
@@ -429,51 +542,139 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
|
429
542
|
main_window.set_focus()
|
|
430
543
|
main_window.child_window(class_name="TButton", found_index=1).click_input()
|
|
431
544
|
|
|
432
|
-
|
|
433
|
-
imagem = r"C:\Users\automatehub\Documents\GitHub\worker-automate-hub\assets\abertura_livros\janela_carregada.png"
|
|
545
|
+
await worker_sleep(5)
|
|
434
546
|
|
|
435
|
-
#
|
|
436
|
-
|
|
437
|
-
|
|
547
|
+
# Clicar no aviso
|
|
548
|
+
try:
|
|
549
|
+
app_msgbox = Application().connect(class_name="TMsgBox", timeout=10)
|
|
550
|
+
box = app_msgbox["TMsgBox"]
|
|
551
|
+
print("Janela 'TMsgBox' encontrada.")
|
|
552
|
+
box.set_focus()
|
|
553
|
+
box.child_window(class_name="TBitBtn", found_index=0).click_input()
|
|
554
|
+
print("Clicou no botão 'TBitBtn'.")
|
|
555
|
+
except:
|
|
556
|
+
pass
|
|
438
557
|
|
|
439
|
-
|
|
558
|
+
try:
|
|
559
|
+
app_msg = Application().connect(class_name="TMessageForm", timeout=10)
|
|
560
|
+
form = app_msg["TMessageForm"]
|
|
561
|
+
console.print("Janela de confirmação 'TMessageForm' encontrada.")
|
|
562
|
+
form.set_focus()
|
|
563
|
+
form.child_window(class_name="TButton", found_index=1).click_input()
|
|
564
|
+
print("Clicou no botão de confirmação.")
|
|
565
|
+
except:
|
|
566
|
+
pass
|
|
567
|
+
try:
|
|
568
|
+
app_msg = Application().connect(class_name="TMessageForm", timeout=10)
|
|
569
|
+
form = app_msg["TMessageForm"]
|
|
570
|
+
console.print("Janela de confirmação 'TMessageForm' encontrada.")
|
|
571
|
+
form.set_focus()
|
|
572
|
+
form.child_window(class_name="TButton", found_index=0).click_input()
|
|
573
|
+
print("Clicou no botão de confirmação.")
|
|
574
|
+
except:
|
|
575
|
+
pass
|
|
576
|
+
try:
|
|
577
|
+
app_msg = Application().connect(class_name="TMessageForm", timeout=10)
|
|
578
|
+
form = app_msg["TMessageForm"]
|
|
579
|
+
console.print("Janela de confirmação 'TMessageForm' encontrada.")
|
|
580
|
+
form.set_focus()
|
|
581
|
+
form.child_window(class_name="TButton", found_index=1).click_input()
|
|
582
|
+
print("Clicou no botão de confirmação.")
|
|
583
|
+
except:
|
|
584
|
+
pass
|
|
585
|
+
try:
|
|
586
|
+
app_msg = Application().connect(class_name="TMessageForm", timeout=10)
|
|
587
|
+
form = app_msg["TMessageForm"]
|
|
588
|
+
console.print("Janela de confirmação 'TMessageForm' encontrada.")
|
|
589
|
+
form.set_focus()
|
|
590
|
+
form.child_window(class_name="TButton", found_index=0).click_input()
|
|
591
|
+
print("Clicou no botão de confirmação.")
|
|
592
|
+
except:
|
|
593
|
+
pass
|
|
440
594
|
|
|
441
|
-
|
|
442
|
-
|
|
595
|
+
try:
|
|
596
|
+
# Caminho da imagem que deve desaparecer
|
|
597
|
+
console.print("Aguardar carregar dados")
|
|
598
|
+
# imagem = "assets\\abertura_livros\\janela_carregada.png"
|
|
599
|
+
imagem = "assets\\abertura_livros\\janela_carregada.png"
|
|
443
600
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
601
|
+
# Tempo máximo de espera (em segundos)
|
|
602
|
+
tempo_limite = 600 # 10 minutos
|
|
603
|
+
intervalo = 2 # segundos entre as verificações
|
|
447
604
|
|
|
448
|
-
|
|
449
|
-
print("Tempo esgotado. A imagem não desapareceu.")
|
|
450
|
-
break
|
|
605
|
+
inicio = time.time()
|
|
451
606
|
|
|
452
|
-
|
|
453
|
-
|
|
607
|
+
while True:
|
|
608
|
+
localizacao = pyautogui.locateOnScreen(imagem, confidence=0.9)
|
|
454
609
|
|
|
455
|
-
|
|
456
|
-
|
|
610
|
+
if localizacao:
|
|
611
|
+
print("Imagem ainda presente... aguardando")
|
|
612
|
+
else:
|
|
613
|
+
print("Imagem desapareceu da tela.")
|
|
614
|
+
break # A imagem sumiu, podemos seguir
|
|
615
|
+
|
|
616
|
+
if time.time() - inicio > tempo_limite:
|
|
617
|
+
print("Tempo esgotado. A imagem não desapareceu.")
|
|
618
|
+
break
|
|
619
|
+
|
|
620
|
+
time.sleep(intervalo)
|
|
621
|
+
except:
|
|
622
|
+
pass
|
|
623
|
+
# Conecta na janela principal
|
|
624
|
+
console.print("Janela Livro de Apuração ICMS 2ª Etapa")
|
|
457
625
|
app = Application().connect(class_name="TFrmPrincipalFiscal", timeout=60)
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
)
|
|
464
|
-
|
|
626
|
+
main_window = app["TFrmPrincipalFiscal"]
|
|
627
|
+
|
|
628
|
+
# Captura todos os controles do tipo Edit (inclui TEdit do Delphi)
|
|
629
|
+
edits = main_window.descendants(class_name="TEdit")
|
|
630
|
+
|
|
631
|
+
print(f"Foram encontrados {len(edits)} campos TEdit.")
|
|
632
|
+
|
|
633
|
+
campo = edits[0]
|
|
634
|
+
campo.click_input()
|
|
635
|
+
await worker_sleep(1)
|
|
636
|
+
|
|
637
|
+
# Tenta limpar o campo e verifica se realmente foi limpo
|
|
638
|
+
max_tentativas = 3
|
|
639
|
+
for tentativa in range(max_tentativas):
|
|
640
|
+
campo.set_edit_text("")
|
|
641
|
+
await worker_sleep(0.5)
|
|
465
642
|
|
|
643
|
+
texto_atual = campo.window_text().strip()
|
|
644
|
+
if texto_atual == "":
|
|
645
|
+
break # Campo foi limpo com sucesso
|
|
646
|
+
print(f"Tentativa {tentativa+1}: campo ainda contém texto: '{texto_atual}'")
|
|
647
|
+
|
|
648
|
+
# Continua se o campo estiver limpo
|
|
649
|
+
campo.type_keys("Livro de Apuração ICMS", with_spaces=True)
|
|
650
|
+
await worker_sleep(1)
|
|
651
|
+
|
|
652
|
+
send_keys("{ENTER}")
|
|
653
|
+
await worker_sleep(2)
|
|
654
|
+
send_keys("{ENTER}")
|
|
655
|
+
|
|
656
|
+
await worker_sleep(5)
|
|
657
|
+
console.print("Inserindo competência...")
|
|
658
|
+
|
|
659
|
+
# Conecta na janela
|
|
466
660
|
app = Application().connect(class_name="TFrmMovtoApuraIcmsNew", timeout=60)
|
|
467
661
|
main_window = app["TFrmMovtoApuraIcmsNew"]
|
|
468
662
|
main_window.set_focus()
|
|
663
|
+
|
|
664
|
+
# Captura o campo de data (TDBIEditDate)
|
|
469
665
|
data_input = main_window.child_window(class_name="TDBIEditDate", found_index=0)
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
666
|
+
data_input.click_input()
|
|
667
|
+
await worker_sleep(1)
|
|
668
|
+
data_input.set_edit_text("") # Limpa o campo
|
|
669
|
+
|
|
670
|
+
# Define a competência
|
|
671
|
+
# Ex: "07/2025"
|
|
672
|
+
data_input.type_keys(competencia, with_spaces=True)
|
|
474
673
|
|
|
674
|
+
console.print("Clicando no botão incluir apuração")
|
|
475
675
|
# Clicar em incluir apuração
|
|
476
|
-
imagem =
|
|
676
|
+
# imagem = "assets\\abertura_livros\\btn_incluir_apuracao.png"
|
|
677
|
+
imagem = "assets\\abertura_livros\btn_incluir_apuracao.png"
|
|
477
678
|
|
|
478
679
|
# Tenta localizar a imagem na tela
|
|
479
680
|
localizacao = pyautogui.locateCenterOnScreen(imagem, confidence=0.9) # você pode ajustar o confidence
|
|
@@ -482,6 +683,13 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
|
482
683
|
print(f"Imagem incluir apuração encontrado em: {localizacao}")
|
|
483
684
|
pyautogui.moveTo(localizacao)
|
|
484
685
|
pyautogui.click()
|
|
686
|
+
console.print("Apuração incluida com sucesso")
|
|
687
|
+
retorno = "Apuração incluida com sucesso"
|
|
688
|
+
return RpaRetornoProcessoDTO(
|
|
689
|
+
sucesso=True,
|
|
690
|
+
retorno=retorno,
|
|
691
|
+
status=RpaHistoricoStatusEnum.Sucesso
|
|
692
|
+
)
|
|
485
693
|
else:
|
|
486
694
|
console.print("Imagem incluir apuração não encontrada na tela.")
|
|
487
695
|
|
|
@@ -36,7 +36,7 @@ worker_automate_hub/models/dto/rpa_sap_dto.py,sha256=eovdvKCtVIhRct3PL98KjsdlngL
|
|
|
36
36
|
worker_automate_hub/models/dto/rpa_sistema_dto.py,sha256=sLkmJei8x6sl-1-IXUKDmYQuKx0sotYQREPyhQqPmRg,161
|
|
37
37
|
worker_automate_hub/tasks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
38
38
|
worker_automate_hub/tasks/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
39
|
-
worker_automate_hub/tasks/jobs/abertura_livros_fiscais.py,sha256=
|
|
39
|
+
worker_automate_hub/tasks/jobs/abertura_livros_fiscais.py,sha256=jizPxeSddqPuWgdZj8TAsBlmZY_ZQyx-9qwwAdOSiVY,28657
|
|
40
40
|
worker_automate_hub/tasks/jobs/coleta_dje_process.py,sha256=UkLWTC5Ub2qBb0yY-8IZ0DLLOVJOfNTq_z9krx_t25Q,29476
|
|
41
41
|
worker_automate_hub/tasks/jobs/conexao_rdp.py,sha256=S6QC4xhuo0pB5FjaUJZNMm1LIgEjpjifReCTBDqxH-U,11719
|
|
42
42
|
worker_automate_hub/tasks/jobs/cte_manual.py,sha256=JucHpRMjMiy-QEJ0wtFnytLpN53tKXgCDI05nGLGclU,603
|
|
@@ -98,7 +98,7 @@ worker_automate_hub/utils/updater.py,sha256=en2FCGhI8aZ-JNP3LQm64NJDc4awCNW7UhbV
|
|
|
98
98
|
worker_automate_hub/utils/util.py,sha256=xA13nQqZglwkvfAKH18Unv4UoZUyvL58CacSrzUpYTw,206352
|
|
99
99
|
worker_automate_hub/utils/utils_nfe_entrada.py,sha256=L_z1Aps6BFWl-6_Ibm45vDid1S4kFDz5O78N2uO1Rq0,36458
|
|
100
100
|
worker_automate_hub/worker.py,sha256=axdrr1xLTjWEyWfcyH3OCSpPTsyzck_fL_0u1DBLjvw,6525
|
|
101
|
-
worker_automate_hub-0.5.
|
|
102
|
-
worker_automate_hub-0.5.
|
|
103
|
-
worker_automate_hub-0.5.
|
|
104
|
-
worker_automate_hub-0.5.
|
|
101
|
+
worker_automate_hub-0.5.675.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
|
|
102
|
+
worker_automate_hub-0.5.675.dist-info/METADATA,sha256=ykAlCapXBc41PAm3kga2NMs70z76Ih7JdMAt_BpX9_I,3049
|
|
103
|
+
worker_automate_hub-0.5.675.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
104
|
+
worker_automate_hub-0.5.675.dist-info/RECORD,,
|
|
File without changes
|
{worker_automate_hub-0.5.674.dist-info → worker_automate_hub-0.5.675.dist-info}/entry_points.txt
RENAMED
|
File without changes
|