FEAT: Chamados com status "Aguardnado Atendimento" e "Em Espera" são atualizados para "Em Atendimento" para que possam ser encerrados.
This commit is contained in:
parent
a082bad82c
commit
0c4538355a
@ -96,14 +96,10 @@ const processStatusAndClosureController = async () => {
|
||||
await TicketGlpiModel.forceCloseTicket(ticket.glpi_ticket_id);
|
||||
} else {
|
||||
// REGRA DE NEGÓCIO: Não pode fechar um ticket que está "Em Espera" ou "Aguardando Atendimento" no SN.
|
||||
// NOVA REGRA: Se estiver em espera/aguardando, primeiro muda para "Em Atendimento" e depois fecha.
|
||||
if (snCurrentStatus === 'Em Espera' || snCurrentStatus === 'Aguardando Atendimento') {
|
||||
logWarning(`Tentativa de fechar o ticket SN ${ticketSnDetails.ticket_number} que está '${snCurrentStatus}'. Ação bloqueada.`);
|
||||
// Não Adiciona uma nota no SN e reabre o ticket no GLPI para refletir o status do SN.
|
||||
//await addWorkNoteToServiceNow(ticket.sn_ticket_id, `O ticket correspondente no GLPI (${ticket.glpi_ticket_id}) foi solucionado, mas o chamado no ServiceNow está '${snCurrentStatus}'. É necessário retomar o atendimento para prosseguir com o encerramento.`);
|
||||
//Atualiza o status do GLPI
|
||||
await TicketGlpiModel.updateStatus(ticket.glpi_ticket_id, snCurrentStatus); // Reabre o GLPI imediatamente
|
||||
await TicketSyncModel.updateStatusAndSourceLast(ticket.sn_ticket_id, 'synced', 'synced', 'SNOW'); // Passa o bastão para o SN
|
||||
continue; // Pula para o próximo ticket
|
||||
logWarning(`Ticket SN ${ticketSnDetails.ticket_number} está '${snCurrentStatus}'. Atualizando para 'Em Atendimento' antes de fechar.`);
|
||||
await updateStatusInServiceNow(ticket.sn_ticket_id, 'Em Atendimento');
|
||||
}
|
||||
|
||||
// FLUXO NORMAL DE RESOLUÇÃO
|
||||
|
||||
@ -153,7 +153,6 @@ class TicketSyncModel {
|
||||
}
|
||||
static async getByTicketNumber(ticketNumber) {
|
||||
try {
|
||||
console.log(ticketNumber)
|
||||
const query = 'SELECT * FROM ticket_sync WHERE sn_ticket_id = $1';
|
||||
const { rows } = await pool.query(query, [ticketNumber]);
|
||||
return rows[0] || null;
|
||||
|
||||
@ -349,7 +349,7 @@ const updateStatusInServiceNow = async (snTicketId, state) => {
|
||||
const stateMap = {
|
||||
'Aguardando Atendimento': '1', // New
|
||||
'Em Atendimento': '2', // In Progress
|
||||
'Em Espera': '3', // On Hold
|
||||
'Em Espera': '-5', // On Hold
|
||||
'Encerrado': '6', // Resolved
|
||||
'Encerrado - Omitido': '7' // Closed
|
||||
};
|
||||
@ -435,13 +435,16 @@ const closeTicketInServiceNow = async (snTicketId, closeNotes, resolvedAt) => {
|
||||
work_notes: `Ticket Encerrado por Suporte Técnico Sothis: ${closeNotes}`
|
||||
};
|
||||
|
||||
|
||||
} else if (ticketType === 'requisicao') {
|
||||
|
||||
url = `${apiConfig.snTableRequestConfig.baseUrl}/${sysId}`;
|
||||
payload = {
|
||||
state: '6',
|
||||
work_notes: closeNotes || 'Requisição resolvida automaticamente via integração GLPI.'
|
||||
resolved_by: resolvedBySysId,
|
||||
resolved_at: new Date(resolvedAt).toISOString().slice(0, 19).replace('T', ' '),
|
||||
closeNotes: closeNotes,
|
||||
work_notes: `Ticket Encerrado por Suporte Técnico Sothis: ${closeNotes}`,
|
||||
|
||||
};
|
||||
|
||||
console.log(url);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user