update
This commit is contained in:
@@ -62,7 +62,7 @@ async function listarArchivosEnCarpeta(folderId) {
|
||||
async function obtenerDatosHoja(spreadsheetId) {
|
||||
const response = await sheets.spreadsheets.values.get({
|
||||
spreadsheetId,
|
||||
range: 'A:F', // Ajusta el rango según tus necesidades
|
||||
range: 'A:G', // Ajusta el rango según tus necesidades
|
||||
});
|
||||
return response.data.values;
|
||||
}
|
||||
@@ -184,7 +184,7 @@ async function procesarCasoCorte(page, element, spreadsheetId, intentos = 1) {
|
||||
console.log('>> Invalid case number - must be 9 digits');
|
||||
await actualizarCelda(
|
||||
spreadsheetId,
|
||||
`C${element.fila}`,
|
||||
`D${element.fila}`,
|
||||
['Invalid case number - must contain exactly 9 digits']
|
||||
);
|
||||
return true;
|
||||
@@ -218,11 +218,38 @@ async function procesarCasoCorte(page, element, spreadsheetId, intentos = 1) {
|
||||
await page.waitForSelector('.codeInput > input:nth-child(1)', { visible: true, timeout: 10000 });
|
||||
await delay(2000);
|
||||
await page.type('.codeInput > input:nth-child(1)', element.valor);
|
||||
await delay(1000);
|
||||
await page.keyboard.press('Tab');
|
||||
await delay(1000);
|
||||
await page.keyboard.press('Tab');
|
||||
console.log('>> Se diligencio ID de caso');
|
||||
} catch (error) {
|
||||
console.log('>> No se pudo encontrar el campo de entrada de caso Corte.');
|
||||
}
|
||||
|
||||
await delay(2000);
|
||||
await delay(1000);
|
||||
|
||||
try {
|
||||
// await page.waitForSelector('input[type="text"]', { timeout: 10000 });
|
||||
await page.type('input[type="text"]', element.nacionalidad);
|
||||
console.log('>> Se diligencio nacionalidad');
|
||||
} catch (error) {
|
||||
console.log('>> No se pudo encontrar el campo nacionalidad');
|
||||
}
|
||||
|
||||
await delay(1000);
|
||||
|
||||
try {
|
||||
const elements = await page.$$('div[id^="react-select-2-option-"]');
|
||||
for (const element of elements) {
|
||||
await element.click();
|
||||
}
|
||||
console.log('>> Se dio click a la nacionalidad');
|
||||
} catch (error) {
|
||||
console.log('>> No se pudo encontrar el campo nacionalidad');
|
||||
}
|
||||
|
||||
await delay(1000);
|
||||
|
||||
try {
|
||||
await page.waitForSelector('#btn_submit', { visible: true, timeout: 10000 });
|
||||
@@ -252,7 +279,7 @@ async function procesarCasoCorte(page, element, spreadsheetId, intentos = 1) {
|
||||
console.log(">> No case found for this A-Number");
|
||||
await actualizarCelda(
|
||||
spreadsheetId,
|
||||
`C${element.fila}`,
|
||||
`D${element.fila}`,
|
||||
['No case found for this A-Number']
|
||||
);
|
||||
return true;
|
||||
@@ -271,7 +298,7 @@ async function procesarCasoCorte(page, element, spreadsheetId, intentos = 1) {
|
||||
console.log('>> hCaptcha detected');
|
||||
await actualizarCelda(
|
||||
spreadsheetId,
|
||||
`C${element.fila}`,
|
||||
`D${element.fila}`,
|
||||
['Captcha detected - Please try again later']
|
||||
);
|
||||
await delay(5000);
|
||||
@@ -312,7 +339,7 @@ async function procesarCasoCorte(page, element, spreadsheetId, intentos = 1) {
|
||||
|
||||
await actualizarCelda(
|
||||
spreadsheetId,
|
||||
`C${element.fila}:F${element.fila}`,
|
||||
`D${element.fila}:G${element.fila}`,
|
||||
[box1, box2, box3, box4]
|
||||
);
|
||||
|
||||
@@ -352,17 +379,18 @@ async function procesarArchivo(archivo) {
|
||||
.map((row, index) => ({
|
||||
valor: row[0], // Columna A
|
||||
fila: index + 2, // Número de fila real
|
||||
ultimaConsulta: row[1], // Columna B
|
||||
columnaC: row[2] // Columna C
|
||||
nacionalidad: row[1], // Nacionalidad
|
||||
ultimaConsulta: row[2], // Columna C
|
||||
columnaD: row[3] // Columna D
|
||||
}));
|
||||
|
||||
// Separate rows into three groups based on priority
|
||||
const filasVaciasC = todasLasFilas.filter(row => !row.columnaC);
|
||||
const filasVaciasD = todasLasFilas.filter(row => !row.columnaD);
|
||||
|
||||
const filasConCaptcha = todasLasFilas.filter(row => row.columnaC && row.columnaC.includes('Captcha detected - Please try again later'));
|
||||
const filasConCaptcha = todasLasFilas.filter(row => row.columnaD && row.columnaD.includes('Captcha detected - Please try again later'));
|
||||
|
||||
const filasConFechaB = todasLasFilas.filter(row => {
|
||||
if (!row.columnaC && !row.ultimaConsulta) return false; // Already handled by filasVaciasC or filasVaciasB
|
||||
if (!row.columnaD && !row.ultimaConsulta) return false; // Already handled by filasVaciasD or filasVaciasB
|
||||
if (!row.ultimaConsulta) return false; // Handled by filasVaciasB
|
||||
|
||||
const [date, time] = row.ultimaConsulta.split(', ');
|
||||
@@ -380,7 +408,7 @@ async function procesarArchivo(archivo) {
|
||||
});
|
||||
|
||||
const filasVaciasB = todasLasFilas.filter(row => {
|
||||
return !row.ultimaConsulta && row.columnaC; // Empty F, but G is not empty
|
||||
return !row.ultimaConsulta && row.columnaD; // Empty F, but G is not empty
|
||||
});
|
||||
|
||||
// Sort rows with date in B by oldest date first
|
||||
@@ -399,7 +427,7 @@ async function procesarArchivo(archivo) {
|
||||
});
|
||||
|
||||
// Combine the arrays in the specified priority order
|
||||
const filasOrdenadas = [...filasVaciasC, ...filasConCaptcha, ...filasConFechaB, ...filasVaciasB];
|
||||
const filasOrdenadas = [...filasVaciasD, ...filasConCaptcha, ...filasConFechaB, ...filasVaciasB];
|
||||
|
||||
console.log(filasOrdenadas);
|
||||
|
||||
@@ -432,12 +460,12 @@ async function procesarArchivo(archivo) {
|
||||
await Promise.all([
|
||||
actualizarCelda(
|
||||
archivo.id,
|
||||
`B${element.fila}`,
|
||||
`C${element.fila}`,
|
||||
[fechaHoraActual]
|
||||
),
|
||||
actualizarCelda(
|
||||
archivo.id,
|
||||
`C${element.fila}:F${element.fila}`,
|
||||
`D${element.fila}:G${element.fila}`,
|
||||
['', '', '', '']
|
||||
)
|
||||
]);
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
@echo off
|
||||
start cmd /k "C:\Users\Drackxus\AppData\Local\Programs\migracion\Migracion.exe"
|
||||
start /wait "" "C:\Users\Drackxus\AppData\Local\Programs\migracion\Migracion.exe"
|
||||
exit
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "migracion-corte",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.4",
|
||||
"main": "corte.mjs",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
|
||||
Reference in New Issue
Block a user