topsapp: usa id_ap para buscar equipamento
Signed-off-by: Rodrigo Bertoldo de Sousa Martins <rodrigo@MacBook-Air-de-Rodrigo.local>
This commit is contained in:
1 parent
bb32aebfc9
commit
f6bc0749e6
1 file changed
+22
-9
+22
-9
@@ -1231,6 +1231,7 @@ Digite /help para ver todos os comandos disponíveis!
|
|||||||
const cidade = servico.instalacao_cidade || null;
|
const cidade = servico.instalacao_cidade || null;
|
||||||
// Campo base/AP usado para rotear para a OLT correta
|
// Campo base/AP usado para rotear para a OLT correta
|
||||||
const baseInfo = servico.base || (servico.id_ap ? `AP ${servico.id_ap}` : null);
|
const baseInfo = servico.base || (servico.id_ap ? `AP ${servico.id_ap}` : null);
|
||||||
|
const idAp = servico.id_ap !== undefined ? servico.id_ap : null;
|
||||||
|
|
||||||
// Executar consultas em paralelo: Juniper + ONU + GenieACS (por TAG/login)
|
// Executar consultas em paralelo: Juniper + ONU + GenieACS (por TAG/login)
|
||||||
// No concentrador Juniper usa-se só o usuário (antes do @)
|
// No concentrador Juniper usa-se só o usuário (antes do @)
|
||||||
@@ -1242,7 +1243,7 @@ Digite /help para ver todos os comandos disponíveis!
|
|||||||
? this.ssh.getJuniperSubscriberInfo(juniperId, pppoeUser).catch(e => ({ success: false, error: e.message }))
|
? this.ssh.getJuniperSubscriberInfo(juniperId, pppoeUser).catch(e => ({ success: false, error: e.message }))
|
||||||
: Promise.resolve({ success: false, skipped: true }),
|
: Promise.resolve({ success: false, skipped: true }),
|
||||||
serial
|
serial
|
||||||
? this._diagnosticarONU(serial, baseInfo, activeSite.id).catch(e => ({ success: false, error: e.message }))
|
? this._diagnosticarONU(serial, baseInfo, activeSite.id, idAp).catch(e => ({ success: false, error: e.message }))
|
||||||
: Promise.resolve({ success: false, skipped: true }),
|
: Promise.resolve({ success: false, skipped: true }),
|
||||||
pppoeLogin && this.genieacs.isReady()
|
pppoeLogin && this.genieacs.isReady()
|
||||||
? this.genieacs.buscarRoteador(pppoeLogin).catch(() => ({ success: false }))
|
? this.genieacs.buscarRoteador(pppoeLogin).catch(() => ({ success: false }))
|
||||||
@@ -1393,10 +1394,20 @@ Digite /help para ver todos os comandos disponíveis!
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mapeia o campo base/AP do TopSapp para o ID da OLT Datacom (ou 'fiberhome')
|
* Mapeia o campo base/AP (e o id_ap) do TopSapp para o ID da OLT Datacom (ou 'fiberhome')
|
||||||
* As bases DITO/COLMEIA/CANAA só existem em Guaraí; em outro site, ignora a dica.
|
* As bases DITO/COLMEIA/CANAA só existem em Guaraí; em outro site, ignora a dica.
|
||||||
|
* Em Pedro Afonso a base "DOBLERNET FIBRA ÓPTICA" é compartilhada por duas OLTs
|
||||||
|
* (Pedro Afonso e Canavieiras) — a única forma de saber qual delas é o id_ap:
|
||||||
|
* id_ap 2 = OLT Pedro Afonso, id_ap 4 = OLT Canavieiras.
|
||||||
*/
|
*/
|
||||||
_resolverOLTporBase(baseInfo, siteId = 'guarai') {
|
_resolverOLTporBase(baseInfo, siteId = 'guarai', idAp = null) {
|
||||||
|
if (siteId === 'pedro_afonso') {
|
||||||
|
const ap = idAp !== null && idAp !== undefined ? String(idAp) : null;
|
||||||
|
if (ap === '2') return 'olt_pedro_afonso';
|
||||||
|
if (ap === '4') return 'olt_canavieiras';
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (!baseInfo) return null;
|
if (!baseInfo) return null;
|
||||||
const b = String(baseInfo).toUpperCase();
|
const b = String(baseInfo).toUpperCase();
|
||||||
if (/INTERNET\s+FIBRA\s+OPTICA/i.test(b)) return 'fiberhome';
|
if (/INTERNET\s+FIBRA\s+OPTICA/i.test(b)) return 'fiberhome';
|
||||||
@@ -1413,10 +1424,11 @@ Digite /help para ver todos os comandos disponíveis!
|
|||||||
* @param {string} serial - Serial da ONU
|
* @param {string} serial - Serial da ONU
|
||||||
* @param {string|null} baseInfo - Campo base/AP do TopSapp para rotear para OLT correta
|
* @param {string|null} baseInfo - Campo base/AP do TopSapp para rotear para OLT correta
|
||||||
* @param {string} siteId - Cidade/provedor ativo, usado para restringir a busca
|
* @param {string} siteId - Cidade/provedor ativo, usado para restringir a busca
|
||||||
|
* @param {number|string|null} idAp - id_ap do TopSapp (necessário em Pedro Afonso)
|
||||||
*/
|
*/
|
||||||
async _diagnosticarONU(serial, baseInfo, siteId = 'guarai') {
|
async _diagnosticarONU(serial, baseInfo, siteId = 'guarai', idAp = null) {
|
||||||
const serialUpper = serial.toUpperCase();
|
const serialUpper = serial.toUpperCase();
|
||||||
const oltHint = this._resolverOLTporBase(baseInfo, siteId);
|
const oltHint = this._resolverOLTporBase(baseInfo, siteId, idAp);
|
||||||
|
|
||||||
// Usar base description para decidir se é FiberHome
|
// Usar base description para decidir se é FiberHome
|
||||||
if (oltHint === 'fiberhome' ||
|
if (oltHint === 'fiberhome' ||
|
||||||
@@ -8857,6 +8869,7 @@ Digite /help para ver todos os comandos disponíveis!
|
|||||||
async _confirmarReiniciarOnu(chatId, idCliente, servico, location) {
|
async _confirmarReiniciarOnu(chatId, idCliente, servico, location) {
|
||||||
const serial = servico.serial || servico.comodato_serial || servico.mac || '';
|
const serial = servico.serial || servico.comodato_serial || servico.mac || '';
|
||||||
const base = servico.base || '';
|
const base = servico.base || '';
|
||||||
|
const idAp = servico.id_ap !== undefined ? servico.id_ap : null;
|
||||||
const nome = servico.descricao || servico.nome || 'Serviço';
|
const nome = servico.descricao || servico.nome || 'Serviço';
|
||||||
|
|
||||||
if (!serial) {
|
if (!serial) {
|
||||||
@@ -8864,14 +8877,14 @@ Digite /help para ver todos os comandos disponíveis!
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const oltHint = this._resolverOLTporBase(base, this.getActiveSite(chatId).id);
|
const oltHint = this._resolverOLTporBase(base, this.getActiveSite(chatId).id, idAp);
|
||||||
const tipoOLT = oltHint === 'fiberhome' ? '🔶 Fiberhome (TL1)' : '🔷 Datacom (SSH)';
|
const tipoOLT = oltHint === 'fiberhome' ? '🔶 Fiberhome (TL1)' : '🔷 Datacom (SSH)';
|
||||||
|
|
||||||
const serialEscaped = serial.replace(/_/g, '\\_');
|
const serialEscaped = serial.replace(/_/g, '\\_');
|
||||||
|
|
||||||
// Gerar ID curto para callback_data
|
// Gerar ID curto para callback_data
|
||||||
const restartId = String(++this._restartIdCounter);
|
const restartId = String(++this._restartIdCounter);
|
||||||
this.pendingRestarts.set(restartId, { serial, base, location });
|
this.pendingRestarts.set(restartId, { serial, base, idAp, location });
|
||||||
|
|
||||||
await this.bot.sendMessage(chatId,
|
await this.bot.sendMessage(chatId,
|
||||||
`⚠️ *Confirmar Reinicialização de ONU*\n\n` +
|
`⚠️ *Confirmar Reinicialização de ONU*\n\n` +
|
||||||
@@ -8954,9 +8967,9 @@ Digite /help para ver todos os comandos disponíveis!
|
|||||||
}
|
}
|
||||||
this.pendingRestarts.delete(restartId);
|
this.pendingRestarts.delete(restartId);
|
||||||
|
|
||||||
const { serial, base } = pending;
|
const { serial, base, idAp } = pending;
|
||||||
const siteId = this.getActiveSite(chatId).id;
|
const siteId = this.getActiveSite(chatId).id;
|
||||||
const oltHint = this._resolverOLTporBase(base, siteId);
|
const oltHint = this._resolverOLTporBase(base, siteId, idAp);
|
||||||
const serialEscaped = serial.replace(/_/g, '\\_');
|
const serialEscaped = serial.replace(/_/g, '\\_');
|
||||||
|
|
||||||
await this.bot.editMessageText(
|
await this.bot.editMessageText(
|
||||||
|
|||||||
Reference in new issue
Block a user