worker-automate-hub 0.5.749__py3-none-any.whl → 0.5.912__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/api/client.py +186 -68
- worker_automate_hub/api/rpa_historico_service.py +1 -0
- worker_automate_hub/cli.py +91 -111
- worker_automate_hub/tasks/jobs/abertura_livros_fiscais.py +112 -229
- worker_automate_hub/tasks/jobs/descartes.py +91 -77
- worker_automate_hub/tasks/jobs/devolucao_produtos.py +1386 -0
- worker_automate_hub/tasks/jobs/entrada_de_notas_15.py +3 -46
- worker_automate_hub/tasks/jobs/entrada_de_notas_22.py +833 -0
- worker_automate_hub/tasks/jobs/entrada_de_notas_36.py +29 -9
- worker_automate_hub/tasks/jobs/entrada_de_notas_37.py +619 -0
- worker_automate_hub/tasks/jobs/entrada_de_notas_39.py +1 -1
- worker_automate_hub/tasks/jobs/entrada_de_notas_9.py +63 -16
- worker_automate_hub/tasks/jobs/extracao_dados_nielsen.py +504 -0
- worker_automate_hub/tasks/jobs/extracao_saldo_estoque.py +242 -108
- worker_automate_hub/tasks/jobs/extracao_saldo_estoque_fiscal.py +688 -0
- worker_automate_hub/tasks/jobs/fidc_gerar_nosso_numero.py +2 -2
- worker_automate_hub/tasks/jobs/fidc_remessa_cobranca_cnab240.py +25 -16
- worker_automate_hub/tasks/jobs/geracao_balancetes_filial.py +330 -0
- worker_automate_hub/tasks/jobs/importacao_extratos.py +538 -0
- worker_automate_hub/tasks/jobs/importacao_extratos_748.py +800 -0
- worker_automate_hub/tasks/jobs/inclusao_pedidos_ipiranga.py +222 -0
- worker_automate_hub/tasks/jobs/inclusao_pedidos_raizen.py +174 -0
- worker_automate_hub/tasks/jobs/inclusao_pedidos_vibra.py +327 -0
- worker_automate_hub/tasks/jobs/notas_faturamento_sap.py +438 -157
- worker_automate_hub/tasks/jobs/opex_capex.py +540 -326
- worker_automate_hub/tasks/jobs/sped_fiscal.py +8 -8
- worker_automate_hub/tasks/jobs/transferencias.py +52 -41
- worker_automate_hub/tasks/task_definitions.py +46 -1
- worker_automate_hub/tasks/task_executor.py +11 -0
- worker_automate_hub/utils/util.py +252 -215
- worker_automate_hub/utils/utils_nfe_entrada.py +1 -1
- worker_automate_hub/worker.py +1 -9
- {worker_automate_hub-0.5.749.dist-info → worker_automate_hub-0.5.912.dist-info}/METADATA +4 -2
- {worker_automate_hub-0.5.749.dist-info → worker_automate_hub-0.5.912.dist-info}/RECORD +36 -25
- {worker_automate_hub-0.5.749.dist-info → worker_automate_hub-0.5.912.dist-info}/WHEEL +1 -1
- {worker_automate_hub-0.5.749.dist-info → worker_automate_hub-0.5.912.dist-info}/entry_points.txt +0 -0
|
@@ -18,6 +18,7 @@ from worker_automate_hub.models.dto.rpa_processo_entrada_dto import (
|
|
|
18
18
|
RpaProcessoEntradaDTO,
|
|
19
19
|
)
|
|
20
20
|
from worker_automate_hub.utils.logger import logger
|
|
21
|
+
from pywinauto.keyboard import send_keys
|
|
21
22
|
from worker_automate_hub.utils.toast import show_toast
|
|
22
23
|
from worker_automate_hub.utils.util import (
|
|
23
24
|
send_to_webhook,
|
|
@@ -65,7 +66,7 @@ async def descartes(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
|
65
66
|
|
|
66
67
|
# Fecha a instancia do emsys - caso esteja aberta
|
|
67
68
|
await kill_all_emsys()
|
|
68
|
-
app = Application(backend="win32").start("C:\\Rezende\\EMSys3\\
|
|
69
|
+
app = Application(backend="win32").start("C:\\Rezende\\EMSys3\\EMSys3_10.exe")
|
|
69
70
|
warnings.filterwarnings(
|
|
70
71
|
"ignore",
|
|
71
72
|
category=UserWarning,
|
|
@@ -151,18 +152,23 @@ async def descartes(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
|
151
152
|
# await worker_sleep(1)
|
|
152
153
|
|
|
153
154
|
# Preenche o campo do cliente com o número da filial
|
|
154
|
-
console.print("Preenchendo o campo do cliente com o número da filial...\n")
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
)
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
155
|
+
console.print("Preenchendo o campo do cliente com o número da filial...\n")
|
|
156
|
+
campo = pre_venda.child_window(class_name="TDBIEditNumber", found_index=2)
|
|
157
|
+
campo.set_focus()
|
|
158
|
+
send_keys(task.configEntrada["filialEmpresaOrigem"])
|
|
159
|
+
send_keys("{TAB}")
|
|
160
|
+
|
|
161
|
+
# cliente_field_position = await find_element_center(
|
|
162
|
+
# ASSETS_BASE_PATH + "field_cliente.png", (795, 354, 128, 50), 10
|
|
163
|
+
# )
|
|
164
|
+
# if cliente_field_position == None:
|
|
165
|
+
# cliente_field_position = (884, 384)
|
|
166
|
+
|
|
167
|
+
# pyautogui.click(cliente_field_position)
|
|
168
|
+
# pyautogui.hotkey("ctrl", "a")
|
|
169
|
+
# pyautogui.hotkey("del")
|
|
170
|
+
# pyautogui.write(task.configEntrada["filialEmpresaOrigem"])
|
|
171
|
+
# pyautogui.hotkey("tab")
|
|
166
172
|
await worker_sleep(10)
|
|
167
173
|
|
|
168
174
|
try:
|
|
@@ -273,34 +279,38 @@ async def descartes(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
|
273
279
|
|
|
274
280
|
# Define representante para "1"
|
|
275
281
|
console.print("Definindo representante para '1'\n")
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
)
|
|
282
|
+
campo_representate = pre_venda.child_window(class_name="TDBIEditCode", found_index=3)
|
|
283
|
+
campo_representate.set_focus()
|
|
284
|
+
send_keys("1")
|
|
285
|
+
send_keys("{TAB}")
|
|
286
|
+
# screenshot_path = take_screenshot()
|
|
287
|
+
# field_representante_position = find_target_position(
|
|
288
|
+
# screenshot_path, "Representante", 0, 50, attempts=15
|
|
289
|
+
# )
|
|
280
290
|
|
|
281
|
-
if field_representante_position == None:
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
if field_representante_position is not None:
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
else:
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
291
|
+
# if field_representante_position == None:
|
|
292
|
+
# field_representante_position = await find_element_center(
|
|
293
|
+
# ASSETS_BASE_PATH + "field_representante.png", (679, 416, 214, 72), 15
|
|
294
|
+
# )
|
|
295
|
+
# if field_representante_position is not None:
|
|
296
|
+
# lista = list(field_representante_position)
|
|
297
|
+
# lista[0] += 50
|
|
298
|
+
# lista[1] += 1
|
|
299
|
+
# field_representante_position = tuple(lista)
|
|
300
|
+
|
|
301
|
+
# if field_representante_position is not None:
|
|
302
|
+
# pyautogui.doubleClick(field_representante_position)
|
|
303
|
+
# pyautogui.hotkey("ctrl", "a")
|
|
304
|
+
# pyautogui.hotkey("del")
|
|
305
|
+
# pyautogui.write("1")
|
|
306
|
+
# pyautogui.hotkey("tab")
|
|
307
|
+
# else:
|
|
308
|
+
# pyautogui.doubleClick(800, 457)
|
|
309
|
+
# pyautogui.hotkey("ctrl", "a")
|
|
310
|
+
# pyautogui.hotkey("del")
|
|
311
|
+
# pyautogui.write("1")
|
|
312
|
+
# pyautogui.hotkey("tab")
|
|
313
|
+
# # pyautogui.move(789, 523)
|
|
304
314
|
await worker_sleep(5)
|
|
305
315
|
|
|
306
316
|
# Seleciona modelo de capa
|
|
@@ -322,29 +332,36 @@ async def descartes(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
|
322
332
|
# model_descarte_position = tuple(lista)
|
|
323
333
|
|
|
324
334
|
# if model_descarte_position == None:
|
|
325
|
-
model_descarte_position = (848, 527)
|
|
326
|
-
|
|
327
|
-
if model_descarte_position is not None:
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
else:
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
335
|
+
# model_descarte_position = (848, 527)
|
|
336
|
+
|
|
337
|
+
# if model_descarte_position is not None:
|
|
338
|
+
# # pyautogui.click(848, 527)
|
|
339
|
+
# pyautogui.click(model_descarte_position)
|
|
340
|
+
# pyautogui.click(1500, 800)
|
|
341
|
+
# pyautogui.write("B")
|
|
342
|
+
# pyautogui.hotkey("tab")
|
|
343
|
+
# else:
|
|
344
|
+
# log_msg = f"Campo Modelo na capa da nota não encontrado | Número da nota: {nota_fiscal} | Valor: {valor_nota}"
|
|
345
|
+
# await send_to_webhook(
|
|
346
|
+
# task.configEntrada["urlRetorno"],
|
|
347
|
+
# "ERRO",
|
|
348
|
+
# log_msg,
|
|
349
|
+
# task.configEntrada["uuidSimplifica"],
|
|
350
|
+
# nota_fiscal,
|
|
351
|
+
# valor_nota,
|
|
352
|
+
# True
|
|
353
|
+
# )
|
|
354
|
+
# return RpaRetornoProcessoDTO(
|
|
355
|
+
# sucesso=False, retorno=log_msg, status=RpaHistoricoStatusEnum.Falha, tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
|
356
|
+
# )
|
|
357
|
+
try:
|
|
358
|
+
modelo = pre_venda.child_window(class_name="TDBIComboBox", found_index=0)
|
|
359
|
+
modelo.set_focus()
|
|
360
|
+
modelo.select("BAIXA DE EST. DECORRENTE DE PERDA, ROUBO OU DETERIORACAO")
|
|
361
|
+
except:
|
|
344
362
|
return RpaRetornoProcessoDTO(
|
|
345
|
-
sucesso=False, retorno=
|
|
363
|
+
sucesso=False, retorno="Modelo de capa não existe", status=RpaHistoricoStatusEnum.Falha, tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
|
346
364
|
)
|
|
347
|
-
|
|
348
365
|
# Abre Menu itens
|
|
349
366
|
console.print("Abrindo Menu Itens...\n")
|
|
350
367
|
menu_itens = await find_element_center(
|
|
@@ -352,7 +369,7 @@ async def descartes(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
|
352
369
|
)
|
|
353
370
|
|
|
354
371
|
if menu_itens == None:
|
|
355
|
-
menu_itens = (570,
|
|
372
|
+
menu_itens = (570, 296)
|
|
356
373
|
|
|
357
374
|
if menu_itens is not None:
|
|
358
375
|
pyautogui.click(menu_itens)
|
|
@@ -380,10 +397,7 @@ async def descartes(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
|
380
397
|
screenshot_path = take_screenshot()
|
|
381
398
|
# Clica no botão inclui para abrir a tela de item
|
|
382
399
|
console.print("Clicando em Incluir...\n")
|
|
383
|
-
button_incluir = (
|
|
384
|
-
905,
|
|
385
|
-
573,
|
|
386
|
-
) # find_target_position(screenshot_path, "Incluir", 0, 0, attempts=15)
|
|
400
|
+
button_incluir = (905,546)
|
|
387
401
|
if button_incluir is not None:
|
|
388
402
|
pyautogui.click(button_incluir)
|
|
389
403
|
console.print("\nClicou em 'Incluir'", style="bold green")
|
|
@@ -401,6 +415,7 @@ async def descartes(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
|
401
415
|
return RpaRetornoProcessoDTO(
|
|
402
416
|
sucesso=False, retorno=log_msg, status=RpaHistoricoStatusEnum.Falha, tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
|
403
417
|
)
|
|
418
|
+
|
|
404
419
|
await worker_sleep(3)
|
|
405
420
|
|
|
406
421
|
# Digita Almoxarifado
|
|
@@ -417,7 +432,7 @@ async def descartes(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
|
417
432
|
task.configEntrada["filialEmpresaOrigem"] + ALMOXARIFADO_DEFAULT
|
|
418
433
|
)
|
|
419
434
|
pyautogui.hotkey("tab")
|
|
420
|
-
await worker_sleep(
|
|
435
|
+
await worker_sleep(10)
|
|
421
436
|
console.print(
|
|
422
437
|
f"\nDigitou almoxarifado {task.configEntrada["filialEmpresaOrigem"] + ALMOXARIFADO_DEFAULT}",
|
|
423
438
|
style="bold green",
|
|
@@ -441,13 +456,13 @@ async def descartes(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
|
441
456
|
console.print("Preenchendo o campo do item...\n")
|
|
442
457
|
field_item = (
|
|
443
458
|
841,
|
|
444
|
-
|
|
459
|
+
337,
|
|
445
460
|
) # find_target_position(screenshot_path, "Item", 0, 130, 15)
|
|
446
461
|
pyautogui.doubleClick(field_item)
|
|
447
462
|
pyautogui.hotkey("del")
|
|
448
463
|
pyautogui.write(item["codigoProduto"])
|
|
449
464
|
pyautogui.hotkey("tab")
|
|
450
|
-
await worker_sleep(
|
|
465
|
+
await worker_sleep(10)
|
|
451
466
|
console.print(f"\nDigitou item {item['codigoProduto']}", style="bold green")
|
|
452
467
|
|
|
453
468
|
# Checa tela de pesquisa de item
|
|
@@ -508,7 +523,7 @@ async def descartes(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
|
508
523
|
|
|
509
524
|
screenshot_path = take_screenshot()
|
|
510
525
|
|
|
511
|
-
await worker_sleep(
|
|
526
|
+
await worker_sleep(5)
|
|
512
527
|
|
|
513
528
|
# Seleciona o Saldo Disponivel e verifica se ah possibilidade do descarte
|
|
514
529
|
console.print(
|
|
@@ -521,7 +536,7 @@ async def descartes(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
|
521
536
|
class_name="TDBIEditNumber", found_index=9
|
|
522
537
|
).window_text()
|
|
523
538
|
except Exception as error:
|
|
524
|
-
console.print(f"Erro ao selecionar o Saldo Disponivel: {error}")
|
|
539
|
+
console.print(f"Erro ao selecionar o Saldo Disponivel: {str(error)}")
|
|
525
540
|
await send_to_webhook(
|
|
526
541
|
task.configEntrada["urlRetorno"],
|
|
527
542
|
"ERRO",
|
|
@@ -557,7 +572,7 @@ async def descartes(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
|
557
572
|
f"Saldo Disponivel: '{amount_avaliable}'", style="bold green"
|
|
558
573
|
)
|
|
559
574
|
except Exception as error:
|
|
560
|
-
console.print(f"Erro ao converter o Saldo Disponível: {error}")
|
|
575
|
+
console.print(f"Erro ao converter o Saldo Disponível: {str(error)}")
|
|
561
576
|
await send_to_webhook(
|
|
562
577
|
task.configEntrada["urlRetorno"],
|
|
563
578
|
"ERRO",
|
|
@@ -757,7 +772,7 @@ async def descartes(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
|
757
772
|
)
|
|
758
773
|
except Exception as e:
|
|
759
774
|
console.print(
|
|
760
|
-
f"Falha ao clicar no botão OK de pré-venda incluída: {e}",
|
|
775
|
+
f"Falha ao clicar no botão OK de pré-venda incluída: {str(e)}",
|
|
761
776
|
style="red",
|
|
762
777
|
)
|
|
763
778
|
return RpaRetornoProcessoDTO(
|
|
@@ -779,7 +794,7 @@ async def descartes(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
|
779
794
|
|
|
780
795
|
except Exception as e:
|
|
781
796
|
console.print(
|
|
782
|
-
f"O Botão OK de pré-venda incluída não foi encontrado: {e}", style="red"
|
|
797
|
+
f"O Botão OK de pré-venda incluída não foi encontrado: {str(e)}", style="red"
|
|
783
798
|
)
|
|
784
799
|
return RpaRetornoProcessoDTO(
|
|
785
800
|
sucesso=False,
|
|
@@ -917,7 +932,7 @@ async def descartes(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
|
917
932
|
|
|
918
933
|
await worker_sleep(15)
|
|
919
934
|
|
|
920
|
-
max_retries =
|
|
935
|
+
max_retries = 5
|
|
921
936
|
retry_count = 0
|
|
922
937
|
nf_sucesso = False
|
|
923
938
|
log_msg = ''
|
|
@@ -932,7 +947,6 @@ async def descartes(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
|
932
947
|
pyautogui.click(875, 596)
|
|
933
948
|
else:
|
|
934
949
|
pyautogui.click(581, 747)
|
|
935
|
-
|
|
936
950
|
logger.info("\nNota Transmitida")
|
|
937
951
|
console.print("\nNota Transmitida", style="bold green")
|
|
938
952
|
|
|
@@ -1027,7 +1041,7 @@ async def descartes(task: RpaProcessoEntradaDTO) -> RpaRetornoProcessoDTO:
|
|
|
1027
1041
|
)
|
|
1028
1042
|
|
|
1029
1043
|
except Exception as ex:
|
|
1030
|
-
log_msg = f"Erro Processo Descartes: {ex} | Número da nota: {nota_fiscal} | Valor: {valor_nota}"
|
|
1044
|
+
log_msg = f"Erro Processo Descartes: {str(ex)} | Número da nota: {nota_fiscal} | Valor: {valor_nota}"
|
|
1031
1045
|
logger.error(log_msg)
|
|
1032
1046
|
console.print(log_msg, style="bold red")
|
|
1033
1047
|
await send_to_webhook(
|