worker-automate-hub 0.5.757__py3-none-any.whl → 0.5.759__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 +87 -96
- worker_automate_hub/tasks/jobs/extracao_saldo_estoque_fiscal.py +4 -2
- {worker_automate_hub-0.5.757.dist-info → worker_automate_hub-0.5.759.dist-info}/METADATA +1 -1
- {worker_automate_hub-0.5.757.dist-info → worker_automate_hub-0.5.759.dist-info}/RECORD +6 -6
- {worker_automate_hub-0.5.757.dist-info → worker_automate_hub-0.5.759.dist-info}/WHEEL +0 -0
- {worker_automate_hub-0.5.757.dist-info → worker_automate_hub-0.5.759.dist-info}/entry_points.txt +0 -0
@@ -49,154 +49,142 @@ async def extracao_saldo_estoque(task: RpaProcessoEntradaDTO):
|
|
49
49
|
periodo_format = periodo.replace("/", "")
|
50
50
|
filial = task.configEntrada["filialEmpresaOrigem"]
|
51
51
|
historico_id = task.historico_id
|
52
|
+
|
53
|
+
console.print("Finalizando processos antigos do EMSys...", style="bold yellow")
|
52
54
|
await kill_all_emsys()
|
53
55
|
|
56
|
+
console.print("Iniciando EMSys...", style="bold green")
|
54
57
|
app = Application(backend="win32").start("C:\\Rezende\\EMSys3\\EMSys3_35.exe")
|
55
58
|
warnings.filterwarnings(
|
56
59
|
"ignore",
|
57
60
|
category=UserWarning,
|
58
61
|
message="32-bit application should be automated using 32-bit Python",
|
59
62
|
)
|
60
|
-
|
63
|
+
|
64
|
+
console.print("Fazendo login no EMSys...", style="bold cyan")
|
61
65
|
return_login = await login_emsys(
|
62
66
|
config.conConfiguracao, app, task, filial_origem=filial
|
63
67
|
)
|
64
68
|
|
65
|
-
if return_login.sucesso
|
69
|
+
if return_login.sucesso:
|
70
|
+
console.print("Login realizado com sucesso", style="bold green")
|
66
71
|
type_text_into_field(
|
67
72
|
"Rel. Saldo Estoque ", app["TFrmMenuPrincipal"]["Edit"], True, "50"
|
68
73
|
)
|
69
74
|
pyautogui.press("enter")
|
70
75
|
await worker_sleep(2)
|
71
76
|
pyautogui.press("enter")
|
72
|
-
|
73
77
|
else:
|
74
78
|
logger.info(f"\nError Message: {return_login.retorno}")
|
75
|
-
console.print(f"
|
79
|
+
console.print(f"Erro no login: {return_login.retorno}", style="bold red")
|
76
80
|
return return_login
|
77
81
|
|
78
82
|
await worker_sleep(2)
|
79
83
|
|
80
|
-
|
81
|
-
# Marcar check box data
|
84
|
+
console.print("Abrindo janela Relatório de Saldo de Estoque...", style="bold cyan")
|
82
85
|
app = Application().connect(class_name="TFrmRelSaldoEstoque", timeout=60)
|
83
86
|
main_window = app["TFrmRelSaldoEstoque"]
|
84
87
|
main_window.set_focus()
|
85
88
|
|
86
|
-
|
87
|
-
|
88
|
-
class_name="TCheckBox", found_index=3
|
89
|
-
).click_input()
|
89
|
+
console.print("Marcando campo de data...", style="bold cyan")
|
90
|
+
main_window.child_window(class_name="TCheckBox", found_index=3).click_input()
|
90
91
|
|
91
92
|
await worker_sleep(2)
|
92
|
-
# Insere a data
|
93
|
-
data_input = main_window.child_window(class_name="TDBIEditDate", found_index=0)
|
94
93
|
|
94
|
+
console.print(f"Inserindo período: {periodo}", style="bold cyan")
|
95
|
+
data_input = main_window.child_window(class_name="TDBIEditDate", found_index=0)
|
95
96
|
data_input.set_edit_text(periodo)
|
96
97
|
|
97
|
-
|
98
|
-
|
99
|
-
class_name="TBitBtn", found_index=0
|
100
|
-
).click_input()
|
98
|
+
console.print("Gerando relatório...", style="bold cyan")
|
99
|
+
main_window.child_window(class_name="TBitBtn", found_index=0).click_input()
|
101
100
|
|
102
|
-
# Aguarda até 60 segundos para a janela aparecer
|
103
101
|
timings.wait_until_passes(
|
104
102
|
timeout=1800,
|
105
103
|
retry_interval=1,
|
106
104
|
func=lambda: Application().connect(class_name="TFrmPreviewRelatorio"),
|
107
105
|
)
|
106
|
+
await worker_sleep(2)
|
108
107
|
|
109
|
-
|
110
|
-
|
111
|
-
# Conecta à janela Preview Relatorio
|
108
|
+
console.print("Abrindo Preview Relatório...", style="bold cyan")
|
112
109
|
app = Application().connect(class_name="TFrmPreviewRelatorio")
|
113
110
|
main_window = app["TFrmPreviewRelatorio"]
|
114
111
|
main_window.set_focus()
|
115
112
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
)
|
126
|
-
|
127
|
-
|
128
|
-
|
113
|
+
max_tentativas = 5
|
114
|
+
tentativa = 1
|
115
|
+
sucesso = False
|
116
|
+
|
117
|
+
while tentativa <= max_tentativas and not sucesso:
|
118
|
+
console.print(f"Tentativa {tentativa} de {max_tentativas}", style="bold cyan")
|
119
|
+
|
120
|
+
console.print("Procurando botão de salvar (imagem)...", style="bold cyan")
|
121
|
+
caminho = r'assets\\extracao_relatorios\\btn_salvar.png'
|
122
|
+
if os.path.isfile(caminho):
|
123
|
+
pos = pyautogui.locateCenterOnScreen(caminho, confidence=0.9)
|
124
|
+
if pos:
|
125
|
+
pyautogui.click(pos)
|
126
|
+
console.print("Clique realizado no botão salvar", style="bold green")
|
127
|
+
else:
|
128
|
+
console.print("Imagem encontrada mas não está visível na tela", style="bold yellow")
|
129
129
|
else:
|
130
|
-
print("Imagem
|
131
|
-
else:
|
132
|
-
print("A imagem NÃO existe:", caminho)
|
130
|
+
console.print("Imagem do botão salvar NÃO existe", style="bold red")
|
133
131
|
|
134
|
-
|
132
|
+
await worker_sleep(8)
|
135
133
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
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)
|
134
|
+
console.print("Selecionando formato Excel...", style="bold cyan")
|
135
|
+
app = Application().connect(class_name="TFrmRelatorioFormato")
|
136
|
+
main_window = app["TFrmRelatorioFormato"]
|
137
|
+
combo = main_window.ComboBox
|
138
|
+
console.print(f"Itens do ComboBox: {combo.texts()}", style="bold yellow")
|
139
|
+
combo.select(8)
|
149
140
|
|
150
|
-
|
151
|
-
|
152
|
-
# Clicar em Salvar
|
153
|
-
main_window.child_window(class_name="TBitBtn", found_index=1).click_input()
|
141
|
+
await worker_sleep(5)
|
154
142
|
|
155
|
-
|
143
|
+
console.print("Confirmando salvar...", style="bold cyan")
|
144
|
+
main_window.child_window(class_name="TBitBtn", found_index=1).click_input()
|
156
145
|
|
157
|
-
|
158
|
-
app = Application().connect(title_re="Salvar para arquivo", timeout=30)
|
159
|
-
main_window = app.window(title_re="Salvar para arquivo")
|
146
|
+
await worker_sleep(5)
|
160
147
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
).wrapper_object()
|
165
|
-
caminho_arquivo = f"C:\\Users\\automatehub\\Downloads\\saldo_estoque_{periodo_format}_{filial}.xlsx"
|
166
|
-
campo_nome.set_focus()
|
167
|
-
campo_nome.set_edit_text(caminho_arquivo)
|
148
|
+
console.print("Abrindo janela de salvar arquivo...", style="bold cyan")
|
149
|
+
app = Application().connect(title_re="Salvar para arquivo", timeout=30)
|
150
|
+
main_window = app.window(title_re="Salvar para arquivo")
|
168
151
|
|
169
|
-
|
152
|
+
caminho_arquivo = rf"C:\Users\automatehub\Downloads\saldo_estoque_{periodo_format}_{filial}.xlsx"
|
153
|
+
campo_nome = main_window.child_window(class_name="Edit", control_id=1148).wrapper_object()
|
154
|
+
campo_nome.set_edit_text(caminho_arquivo)
|
155
|
+
console.print(f"Arquivo configurado para: {caminho_arquivo}", style="bold green")
|
170
156
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
157
|
+
await worker_sleep(2)
|
158
|
+
|
159
|
+
main_window.child_window(class_name="Button", found_index=0).click_input()
|
160
|
+
|
161
|
+
await worker_sleep(4)
|
162
|
+
|
163
|
+
console.print("Aguardando finalização do processo de impressão/salvamento...", style="bold cyan")
|
164
|
+
try:
|
165
|
+
app = Application().connect(title_re="Printing")
|
166
|
+
janela = app.window(title_re="Printing")
|
167
|
+
janela.wait_not("visible", timeout=60)
|
168
|
+
console.print("Janela 'Printing' fechada.", style="bold green")
|
169
|
+
except findwindows.ElementNotFoundError:
|
170
|
+
console.print("Janela 'Printing' não apareceu.", style="bold yellow")
|
171
|
+
|
172
|
+
# Verifica se o arquivo foi salvo
|
173
|
+
if os.path.exists(caminho_arquivo):
|
174
|
+
console.print(f"Arquivo encontrado: {caminho_arquivo}", style="bold green")
|
175
|
+
with open(caminho_arquivo, "rb") as file:
|
176
|
+
file_bytes = io.BytesIO(file.read())
|
177
|
+
sucesso = True
|
178
|
+
else:
|
179
|
+
console.print("Arquivo não encontrado, tentando novamente...", style="bold red")
|
180
|
+
tentativa += 1
|
181
|
+
await worker_sleep(3)
|
192
182
|
|
193
|
-
|
194
|
-
|
195
|
-
print(caminho_arquivo)
|
196
|
-
with open(f"{caminho_arquivo}", "rb") as file:
|
197
|
-
file_bytes = io.BytesIO(file.read())
|
183
|
+
if not sucesso:
|
184
|
+
console.print("Falha após 5 tentativas. Arquivo não foi gerado.", style="bold red")
|
198
185
|
|
199
|
-
|
186
|
+
nome_com_extensao = f'saldo_estoque_{periodo_format}_{filial}.xlsx'
|
187
|
+
console.print("Enviando arquivo XLS para o BOF...", style="bold cyan")
|
200
188
|
try:
|
201
189
|
await send_file(
|
202
190
|
historico_id,
|
@@ -205,11 +193,11 @@ async def extracao_saldo_estoque(task: RpaProcessoEntradaDTO):
|
|
205
193
|
file_bytes,
|
206
194
|
file_extension="xlsx",
|
207
195
|
)
|
208
|
-
console.print("Removendo arquivo
|
209
|
-
os.remove(
|
196
|
+
console.print("Removendo arquivo da pasta downloads", style="bold yellow")
|
197
|
+
os.remove(caminho_arquivo)
|
210
198
|
return RpaRetornoProcessoDTO(
|
211
199
|
sucesso=True,
|
212
|
-
retorno="Relatório
|
200
|
+
retorno="Relatório enviado com sucesso!",
|
213
201
|
status=RpaHistoricoStatusEnum.Sucesso,
|
214
202
|
)
|
215
203
|
|
@@ -221,6 +209,9 @@ async def extracao_saldo_estoque(task: RpaProcessoEntradaDTO):
|
|
221
209
|
status=RpaHistoricoStatusEnum.Falha,
|
222
210
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
223
211
|
)
|
212
|
+
|
213
|
+
console.print("Processo concluído com sucesso!", style="bold green")
|
214
|
+
|
224
215
|
except Exception as ex:
|
225
216
|
retorno = f"Erro Processo Fechamento Balancete: {str(ex)}"
|
226
217
|
logger.error(retorno)
|
@@ -59,7 +59,9 @@ async def extracao_saldo_estoque_fiscal(
|
|
59
59
|
# Fecha a instancia do emsys - caso esteja aberta
|
60
60
|
await kill_all_emsys()
|
61
61
|
|
62
|
-
app = Application(backend="win32").start(
|
62
|
+
app = Application(backend="win32").start(
|
63
|
+
"C:\\Rezende\\EMSys3\\EMSysFiscal_39.exe"
|
64
|
+
)
|
63
65
|
warnings.filterwarnings(
|
64
66
|
"ignore",
|
65
67
|
category=UserWarning,
|
@@ -128,7 +130,7 @@ async def extracao_saldo_estoque_fiscal(
|
|
128
130
|
await worker_sleep(2)
|
129
131
|
|
130
132
|
# Caminho da imagem do botão
|
131
|
-
imagem_botao = r"
|
133
|
+
imagem_botao = r"assets\\extracao_relatorios\\btn_incluir_livro.png"
|
132
134
|
|
133
135
|
if os.path.exists(imagem_botao):
|
134
136
|
try:
|
@@ -70,8 +70,8 @@ worker_automate_hub/tasks/jobs/entrada_de_notas_9000.py,sha256=0mOmS28tQKF5m7vMz
|
|
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=
|
74
|
-
worker_automate_hub/tasks/jobs/extracao_saldo_estoque_fiscal.py,sha256=
|
73
|
+
worker_automate_hub/tasks/jobs/extracao_saldo_estoque.py,sha256=nFAv5Bvwwo2Mhy69q5BqR-XsKtg4KIqAunrUmGeW1S0,9173
|
74
|
+
worker_automate_hub/tasks/jobs/extracao_saldo_estoque_fiscal.py,sha256=OJQAkE6mqm7lNodleYRWwJq3syxrTqcPGt27_u6NPPs,14950
|
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.759.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
|
105
|
+
worker_automate_hub-0.5.759.dist-info/METADATA,sha256=tMWbnY_CoFvxTSMsKPGVRbkAsl_HM5XxtbKuLCk0Ajw,3049
|
106
|
+
worker_automate_hub-0.5.759.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
107
|
+
worker_automate_hub-0.5.759.dist-info/RECORD,,
|
File without changes
|
{worker_automate_hub-0.5.757.dist-info → worker_automate_hub-0.5.759.dist-info}/entry_points.txt
RENAMED
File without changes
|