worker-automate-hub 0.5.912__py3-none-any.whl → 0.5.921__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/inclusao_pedidos_ipiranga.py +5 -4
- worker_automate_hub/tasks/jobs/inclusao_pedidos_raizen.py +48 -35
- worker_automate_hub/tasks/jobs/inclusao_pedidos_vibra.py +21 -3
- worker_automate_hub/tasks/jobs/lista_clientes_sap.py +631 -0
- worker_automate_hub/tasks/jobs/lista_devolucoes_sap.py +626 -0
- worker_automate_hub/tasks/task_definitions.py +8 -0
- {worker_automate_hub-0.5.912.dist-info → worker_automate_hub-0.5.921.dist-info}/METADATA +1 -1
- {worker_automate_hub-0.5.912.dist-info → worker_automate_hub-0.5.921.dist-info}/RECORD +10 -8
- {worker_automate_hub-0.5.912.dist-info → worker_automate_hub-0.5.921.dist-info}/WHEEL +0 -0
- {worker_automate_hub-0.5.912.dist-info → worker_automate_hub-0.5.921.dist-info}/entry_points.txt +0 -0
|
@@ -43,9 +43,10 @@ async def inclusao_pedidos_ipiranga(task: RpaRetornoProcessoDTO):
|
|
|
43
43
|
|
|
44
44
|
# Going to Main page
|
|
45
45
|
logger.print(f"Navigating to {config.get('url_ipiranga')}")
|
|
46
|
-
await page.goto(
|
|
47
|
-
config.get("url_ipiranga"), wait_until="load")
|
|
46
|
+
await page.goto(config.get("url_ipiranga"), wait_until="load")
|
|
48
47
|
# Wait page load
|
|
48
|
+
await page.wait_for_load_state('load')
|
|
49
|
+
# Wait for login
|
|
49
50
|
await page.wait_for_selector('[title="Login"]', timeout=90000)
|
|
50
51
|
|
|
51
52
|
# Login
|
|
@@ -66,6 +67,7 @@ async def inclusao_pedidos_ipiranga(task: RpaRetornoProcessoDTO):
|
|
|
66
67
|
raise Exception("Falha ao Logar no site.")
|
|
67
68
|
except:
|
|
68
69
|
logger.print("Login successful")
|
|
70
|
+
|
|
69
71
|
# Warn to change password
|
|
70
72
|
try:
|
|
71
73
|
await page.wait_for_selector(
|
|
@@ -108,6 +110,7 @@ async def inclusao_pedidos_ipiranga(task: RpaRetornoProcessoDTO):
|
|
|
108
110
|
await change_station.locator('[type="text"]').first.type(config_entrada.get("cnpjEmpresa"))
|
|
109
111
|
# cnpj = config_entrada.get("cnpjEmpresa")
|
|
110
112
|
# await page.locator(f'li[data-cdpessptoecli="{cnpj}"]').click()
|
|
113
|
+
await asyncio.sleep(3)
|
|
111
114
|
await change_station.get_by_text("Trocar", exact=True).locator("visible=true").click()
|
|
112
115
|
|
|
113
116
|
|
|
@@ -159,7 +162,6 @@ async def inclusao_pedidos_ipiranga(task: RpaRetornoProcessoDTO):
|
|
|
159
162
|
str(combustivel["quantidade"])
|
|
160
163
|
)
|
|
161
164
|
await fuel.locator(f'input[name="quantidade"]').press("Tab")
|
|
162
|
-
|
|
163
165
|
# Next
|
|
164
166
|
logger.print("Going to next page")
|
|
165
167
|
await iframe.locator(
|
|
@@ -208,7 +210,6 @@ async def inclusao_pedidos_ipiranga(task: RpaRetornoProcessoDTO):
|
|
|
208
210
|
raise Exception(f"Erro ao realizar pedido: {text}")
|
|
209
211
|
except Exception as e:
|
|
210
212
|
logger.print(f"An error occurred: {e}")
|
|
211
|
-
await capture_and_send_screenshot(task.historico_id, "Erro")
|
|
212
213
|
return RpaRetornoProcessoDTO(
|
|
213
214
|
sucesso=False,
|
|
214
215
|
retorno=f"An error occurred: {e}",
|
|
@@ -31,15 +31,14 @@ async def inclusao_pedidos_raizen(task: RpaRetornoProcessoDTO):
|
|
|
31
31
|
"--disable-dev-shm-usage",
|
|
32
32
|
"--disable-gpu",
|
|
33
33
|
"--disable-infobars",
|
|
34
|
-
"--window-size=1920,1080"
|
|
35
|
-
])
|
|
34
|
+
"--window-size=1920,1080"])
|
|
36
35
|
|
|
37
36
|
page = await browser.new_page()
|
|
38
37
|
await page.set_viewport_size({"width": 1850, "height": 900})
|
|
39
38
|
#Going to Main page
|
|
40
39
|
logger.print(f"Navigating to {config.get('url_raizen')}")
|
|
41
40
|
await page.goto(config.get('url_raizen'), wait_until="networkidle")
|
|
42
|
-
|
|
41
|
+
await page.wait_for_load_state('load')
|
|
43
42
|
#Login
|
|
44
43
|
logger.print(f"Logging")
|
|
45
44
|
await page.locator("#signInName").type(config.get('login_raizen'))
|
|
@@ -49,7 +48,7 @@ async def inclusao_pedidos_raizen(task: RpaRetornoProcessoDTO):
|
|
|
49
48
|
logger.print("Waiting for verification code")
|
|
50
49
|
logger.print("Sending verification code")
|
|
51
50
|
await page.locator("#readOnlyEmail_ver_but_send").click()
|
|
52
|
-
|
|
51
|
+
await page.wait_for_load_state('load')
|
|
53
52
|
await asyncio.sleep(60)
|
|
54
53
|
#chamar endpoint com código retornado
|
|
55
54
|
code = await get_mfa_code('mfa-raizen')
|
|
@@ -57,12 +56,14 @@ async def inclusao_pedidos_raizen(task: RpaRetornoProcessoDTO):
|
|
|
57
56
|
await page.locator('//*[@id="readOnlyEmail_ver_input"]').type(str(code['code']))
|
|
58
57
|
await page.locator('//*[@id="readOnlyEmail_ver_but_verify"]').click()
|
|
59
58
|
else:
|
|
59
|
+
await capture_and_send_screenshot(task.historico_id, "Erro MFA")
|
|
60
60
|
raise Exception("Failed to retrieve MFA code")
|
|
61
61
|
|
|
62
62
|
# Select Company
|
|
63
63
|
logger.print("Selecting company")
|
|
64
64
|
relacao_cod_raizen = await get_config_by_name("RelacaoCodigosRaizen")
|
|
65
65
|
relacao_cod_raizen = relacao_cod_raizen.conConfiguracao
|
|
66
|
+
await page.wait_for_load_state('load')
|
|
66
67
|
await page.wait_for_selector('//*[@id="api"]/div/form/div[2]/app-select/div/div', state="visible")
|
|
67
68
|
await page.locator('//*[@id="api"]/div/form/div[2]/app-select/div/div').click()
|
|
68
69
|
cod_cnpj = str(relacao_cod_raizen[config_entrada['cnpjEmpresa']]).lstrip('0')
|
|
@@ -96,41 +97,55 @@ async def inclusao_pedidos_raizen(task: RpaRetornoProcessoDTO):
|
|
|
96
97
|
await page.wait_for_timeout(10000)
|
|
97
98
|
await page.locator('//*[@id="undefined"]').click()
|
|
98
99
|
# Base
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
try:
|
|
101
|
+
logger.print("Selecting base")
|
|
102
|
+
rel_base_raizen = await get_config_by_name("relacaoBaseRaizen")
|
|
103
|
+
rel_base_raizen = rel_base_raizen.conConfiguracao
|
|
104
|
+
base_nome = rel_base_raizen[config_entrada['baseNome']]
|
|
105
|
+
await page.locator('//*[@id="orders-fuels-div-dropdown-withdrawal-place"]').click()
|
|
106
|
+
await page.locator(f'//*[contains(text(), "{base_nome}")]').click()
|
|
107
|
+
except:
|
|
108
|
+
await capture_and_send_screenshot(task.historico_id, "Erro ao selecionar base")
|
|
109
|
+
raise Exception("Erro ao selecionar base")
|
|
105
110
|
# Date
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
try:
|
|
112
|
+
logger.print("Selecting date")
|
|
113
|
+
date = config_entrada['dataRetirada']
|
|
114
|
+
date = datetime.fromisoformat(date)
|
|
115
|
+
date = date.strftime("%d/%m/%Y")
|
|
116
|
+
input_elem = page.locator("#orders-fuels-div-calendar-datepicker")
|
|
117
|
+
await input_elem.evaluate("(el, value) => { el.removeAttribute('readonly'); el.value = value; el.dispatchEvent(new Event('input', { bubbles: true })); el.dispatchEvent(new Event('change', { bubbles: true })); }", date)
|
|
118
|
+
except:
|
|
119
|
+
await capture_and_send_screenshot(task.historico_id, "Erro ao realizar pedido!")
|
|
120
|
+
raise Exception("Erro ao selecionar data")
|
|
112
121
|
# Veichle Sign
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
122
|
+
try:
|
|
123
|
+
logger.print("Selecting vehicle sign")
|
|
124
|
+
await page.locator('//*[@id="orders-fuels-div-dropdown-plate-place-button"]').click()
|
|
125
|
+
await page.locator('//*[@id="orders-fuels-div-dropdown-plate-place-button"]').fill(config_entrada["placaVeiculo"].upper())
|
|
126
|
+
await page.locator(f'//*[contains(text(), "{config_entrada["placaVeiculo"]}")]').click()
|
|
127
|
+
except:
|
|
128
|
+
await capture_and_send_screenshot(task.historico_id, "Erro ao selecionar placa do veiculo")
|
|
129
|
+
raise Exception("Erro ao selecionar placa do veiculo")
|
|
118
130
|
#Fill Fuels
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
131
|
+
try:
|
|
132
|
+
logger.print("Filling Fuels")
|
|
133
|
+
combusutiveis_ids = await get_config_by_name('ConsultaPrecoCombustiveisIds')
|
|
134
|
+
combusutiveis_ids = combusutiveis_ids.conConfiguracao
|
|
135
|
+
xpath_ids = await get_config_by_name('raizenXpathCombustiveis')
|
|
136
|
+
xpath_ids = xpath_ids.conConfiguracao
|
|
137
|
+
for combustivel in config_entrada['combustiveis']:
|
|
138
|
+
combustivel_uuid = combustivel['uuidItem']
|
|
139
|
+
xpath = xpath_ids[combustivel_uuid]
|
|
140
|
+
await page.locator(xpath).fill(str(combustivel['quantidade']))
|
|
141
|
+
await page.locator(xpath).click()
|
|
142
|
+
except:
|
|
143
|
+
await capture_and_send_screenshot(task.historico_id, "Erro preenchendo combustiveis")
|
|
144
|
+
raise Exception("Erro ao preencher combustiveis")
|
|
130
145
|
# Save order
|
|
131
146
|
logger.print("Saving order")
|
|
132
|
-
await asyncio.sleep(2)
|
|
133
147
|
await page.locator('//*[@id="orders-fuels-button-save"]').click()
|
|
148
|
+
await asyncio.sleep(10)
|
|
134
149
|
try:
|
|
135
150
|
logger.print("Confirming order")
|
|
136
151
|
await page.get_by_text("Continuar mesmo assim").click()
|
|
@@ -157,10 +172,8 @@ async def inclusao_pedidos_raizen(task: RpaRetornoProcessoDTO):
|
|
|
157
172
|
retorno=str(bof),
|
|
158
173
|
status=RpaHistoricoStatusEnum.Sucesso,
|
|
159
174
|
)
|
|
160
|
-
|
|
161
175
|
except Exception as e:
|
|
162
176
|
logger.print(f"An error occurred: {e}")
|
|
163
|
-
await capture_and_send_screenshot(task.historico_id, "Erro ao realizar pedido!")
|
|
164
177
|
return RpaRetornoProcessoDTO(
|
|
165
178
|
sucesso=False,
|
|
166
179
|
retorno=f"An error occurred: {e}",
|
|
@@ -42,6 +42,7 @@ async def inclusao_pedidos_vibra(task: RpaProcessoEntradaDTO):
|
|
|
42
42
|
await page.set_viewport_size({"width": 1850, "height": 900})
|
|
43
43
|
await page.goto(config.get('url_vibra'), wait_until="load")
|
|
44
44
|
#Login
|
|
45
|
+
await page.wait_for_load_state('load')
|
|
45
46
|
try:
|
|
46
47
|
await page.locator('//*[@id="usuario"]').type(config.get('login_vibra'))
|
|
47
48
|
await page.locator('//*[@id="senha"]').type(config.get('pass_vibra'))
|
|
@@ -49,6 +50,7 @@ async def inclusao_pedidos_vibra(task: RpaProcessoEntradaDTO):
|
|
|
49
50
|
await asyncio.sleep(20)
|
|
50
51
|
except Exception as e:
|
|
51
52
|
raise Exception("An error occurred: Erro ao efetuar login")
|
|
53
|
+
await page.wait_for_load_state('load')
|
|
52
54
|
await page.wait_for_selector("#img-menu-open", timeout=50000)
|
|
53
55
|
selector = '.btn.btn-informativo'
|
|
54
56
|
counter = 0
|
|
@@ -116,6 +118,7 @@ async def inclusao_pedidos_vibra(task: RpaProcessoEntradaDTO):
|
|
|
116
118
|
await asyncio.sleep(6)
|
|
117
119
|
except:
|
|
118
120
|
await page.goto('https://cn.vibraenergia.com.br/central-de-pedidos/#/vitrine')
|
|
121
|
+
await page.wait_for_load_state('load')
|
|
119
122
|
logger.print("Selecting Base")
|
|
120
123
|
base_ralation = await get_config_by_name("relacaoBaseVibra")
|
|
121
124
|
base_ralation = base_ralation.conConfiguracao
|
|
@@ -124,13 +127,16 @@ async def inclusao_pedidos_vibra(task: RpaProcessoEntradaDTO):
|
|
|
124
127
|
logger.print(f"{base}")
|
|
125
128
|
await page.wait_for_selector('input[formcontrolname="base"]', state="visible", timeout=60000)
|
|
126
129
|
await page.locator('input[formcontrolname="base"]').click()
|
|
130
|
+
await page.wait_for_load_state('load')
|
|
127
131
|
await asyncio.sleep(3)
|
|
128
132
|
await page.locator('.md-icons.adicionar-bases-icon').click()
|
|
133
|
+
await page.wait_for_load_state('load')
|
|
129
134
|
await asyncio.sleep(3)
|
|
130
135
|
base_selection = page.locator('.mat-option-text', has_text=base)
|
|
131
136
|
await base_selection.scroll_into_view_if_needed()
|
|
132
137
|
await asyncio.sleep(3)
|
|
133
138
|
await base_selection.click()
|
|
139
|
+
await page.wait_for_load_state('load')
|
|
134
140
|
await asyncio.sleep(4)
|
|
135
141
|
except:
|
|
136
142
|
await capture_and_send_screenshot(task.historico_id, "Erro")
|
|
@@ -147,6 +153,18 @@ async def inclusao_pedidos_vibra(task: RpaProcessoEntradaDTO):
|
|
|
147
153
|
xpath = xpaths[fuel['uuidItem']]
|
|
148
154
|
fuel_card = carrossel.locator(xpath)
|
|
149
155
|
await fuel_card.scroll_into_view_if_needed()
|
|
156
|
+
try:
|
|
157
|
+
warning_msg = await fuel_card.locator('.warning', has_text="restrição").inner_text()
|
|
158
|
+
if 'restrição' in warning_msg:
|
|
159
|
+
await capture_and_send_screenshot(task.historico_id, "Erro")
|
|
160
|
+
return RpaRetornoProcessoDTO(
|
|
161
|
+
sucesso=False,
|
|
162
|
+
retorno=f"{warning_msg} | {fuel['descricaoProduto']}",
|
|
163
|
+
status=RpaHistoricoStatusEnum.Falha,
|
|
164
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico), RpaTagDTO(descricao=RpaTagEnum.Negocio)],
|
|
165
|
+
)
|
|
166
|
+
except:
|
|
167
|
+
pass
|
|
150
168
|
card = fuel_card.filter(has=page.locator('button:not([disabled])', has_text="Adicionar"))
|
|
151
169
|
await card.scroll_into_view_if_needed()
|
|
152
170
|
await card.locator('button:not([disabled])', has_text="Adicionar").click()
|
|
@@ -260,12 +278,13 @@ async def inclusao_pedidos_vibra(task: RpaProcessoEntradaDTO):
|
|
|
260
278
|
#Confirm order
|
|
261
279
|
try:
|
|
262
280
|
msg = page.locator("text=Volume solicitado acima")
|
|
281
|
+
msg.scroll_into_view_if_needed()
|
|
263
282
|
if await msg.is_visible():
|
|
264
283
|
texto = await msg.inner_text()
|
|
265
284
|
await capture_and_send_screenshot(task.historico_id, "Erro")
|
|
266
285
|
raise Exception(texto)
|
|
267
|
-
except:
|
|
268
|
-
|
|
286
|
+
except Exception as e:
|
|
287
|
+
raise Exception(e)
|
|
269
288
|
try:
|
|
270
289
|
await page.wait_for_selector('//*[@id="user"]/app-root/div[2]/div/div/app-meu-carrinho/div/div[1]/app-carrinho/div/div[2]/button')
|
|
271
290
|
await page.locator('//*[@id="user"]/app-root/div[2]/div/div/app-meu-carrinho/div/div[1]/app-carrinho/div/div[2]/button').click()
|
|
@@ -316,7 +335,6 @@ async def inclusao_pedidos_vibra(task: RpaProcessoEntradaDTO):
|
|
|
316
335
|
status=RpaHistoricoStatusEnum.Sucesso)
|
|
317
336
|
except Exception as e:
|
|
318
337
|
logger.print(f"An error occurred: {e}")
|
|
319
|
-
await capture_and_send_screenshot(task.historico_id, "Erro")
|
|
320
338
|
return RpaRetornoProcessoDTO(
|
|
321
339
|
sucesso=False,
|
|
322
340
|
retorno=f"An error occurred: {e}",
|