Actualizar robot.js

This commit is contained in:
2026-03-22 20:53:48 +00:00
parent f996947f68
commit 0baba3101f

View File

@@ -198,13 +198,13 @@ async function runMultiasistencia(ownerId, user, pass, gremiosDB) {
const expedientes = Array.from(todosExpedientes); const expedientes = Array.from(todosExpedientes);
console.log(`\n✅ [Multi] TOTAL EXPEDIENTES LEÍDOS EN WEB: ${expedientes.length}`); console.log(`\n✅ [Multi] TOTAL EXPEDIENTES LEÍDOS EN WEB: ${expedientes.length}`);
console.log(`📋 REFERENCIAS LEÍDAS:`, expedientes.join(', '));
if (expedientes.length > 0) { // 🛑 NUEVO SEGURO DE VIDA: Si lee menos de 5, desconfiamos de la web y NO archivamos nada, por si es un error puntual.
if (expedientes.length > 5 || paginaActual === 1) {
console.log(`🧹 Llamando a la escoba (syncAndArchive) con ${expedientes.length} refs...`); console.log(`🧹 Llamando a la escoba (syncAndArchive) con ${expedientes.length} refs...`);
await syncAndArchive(ownerId, 'multiasistencia', expedientes); await syncAndArchive(ownerId, 'multiasistencia', expedientes);
} else { } else {
console.log("⚠️ [Multi] ¡CUIDADO! Se han detectado 0 expedientes. ABORTANDO LA ESCOBA para no cerrar nada."); console.log("⚠️ [Multi] Pocos expedientes detectados. ABORTANDO ARCHIVADO DE SEGURIDAD.");
} }
for (const ref of expedientes) { for (const ref of expedientes) {
@@ -460,7 +460,8 @@ async function syncAndArchive(ownerId, provider, currentWebRefs) {
const statusQ = await client.query("SELECT id FROM service_statuses WHERE owner_id = $1 AND name ILIKE '%anulado%' LIMIT 1", [ownerId]); const statusQ = await client.query("SELECT id FROM service_statuses WHERE owner_id = $1 AND name ILIKE '%anulado%' LIMIT 1", [ownerId]);
const idAnulado = statusQ.rowCount > 0 ? statusQ.rows[0].id : null; const idAnulado = statusQ.rowCount > 0 ? statusQ.rows[0].id : null;
if (idAnulado) { // 🛑 PARCHE: Desactivamos el escudo anti-viajes para Multiasistencia hasta que mapeemos bien sus 200 estados raros.
if (idAnulado && provider !== 'multiasistencia') {
for (const svc of missingServices) { for (const svc of missingServices) {
// Si el expediente estaba asignado a un técnico... // Si el expediente estaba asignado a un técnico...
if (svc.assigned_to) { if (svc.assigned_to) {