Merge branch 'master' of ssh://10.0.120.75:60000/home/desenvolvimento/SNGLPI/sn-glpi-sync-new

This commit is contained in:
Gabriel Amancio 2025-09-09 14:16:11 -03:00
commit 78a7a5247b
9 changed files with 1212 additions and 28500 deletions

1066
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,9 @@
"dependencies": {
"axios": "^0.21.4",
"dotenv": "^10.0.0",
"pg": "^8.7.1"
"express": "^5.1.0",
"pg": "^8.7.1",
"winston": "^3.17.0"
},
"author": "Your Name",
"license": "MIT"

File diff suppressed because it is too large Load Diff

View File

@ -1,944 +0,0 @@
{
"result": [
{
"variables.caller_id": {
"display_value": "SOTHIS CAOA",
"value": "b131d6ed1b2ba510c5e163923b4bcb77"
},
"number": {
"display_value": "INC0140378",
"value": "INC0140378"
},
"opened_at": {
"display_value": "26/08/2025 10:13:20",
"value": "2025-08-26 13:13:20"
},
"short_description": {
"display_value": "Problemas com Telefonia Fixa",
"value": "Problemas com Telefonia Fixa"
},
"variables.telephone_favorecido_rh": {
"display_value": "(11) 2222-2222",
"value": "(11) 2222-2222"
},
"opened_by.email": {
"display_value": "",
"value": ""
},
"opened_by": {
"display_value": "SOTHIS CAOA",
"link": "https://caoadev.service-now.com/api/now/table/sys_user/b131d6ed1b2ba510c5e163923b4bcb77",
"value": "b131d6ed1b2ba510c5e163923b4bcb77"
},
"variables.numero_ramal": {
"display_value": "666",
"value": "666"
},
"description": {
"display_value": "teste",
"value": "teste"
},
"location": {
"display_value": "CAOA MONTADORA - ANAPOLIS",
"link": "https://caoadev.service-now.com/api/now/table/cmn_location/af22f6e91b6f1050e77eb9121b4bcbc3",
"value": "af22f6e91b6f1050e77eb9121b4bcbc3"
},
"variables.location": {
"display_value": "CAOA MONTADORA - ANAPOLIS",
"value": "af22f6e91b6f1050e77eb9121b4bcbc3"
}
},
{
"variables.caller_id": {
"display_value": "SOTHIS CAOA",
"value": "b131d6ed1b2ba510c5e163923b4bcb77"
},
"number": {
"display_value": "INC0140377",
"value": "INC0140377"
},
"opened_at": {
"display_value": "25/08/2025 10:47:40",
"value": "2025-08-25 13:47:40"
},
"short_description": {
"display_value": "Problemas com Telefonia Fixa",
"value": "Problemas com Telefonia Fixa"
},
"variables.telephone_favorecido_rh": {
"display_value": "(11) 2222-2222",
"value": "(11) 2222-2222"
},
"opened_by.email": {
"display_value": "",
"value": ""
},
"opened_by": {
"display_value": "SOTHIS CAOA",
"link": "https://caoadev.service-now.com/api/now/table/sys_user/b131d6ed1b2ba510c5e163923b4bcb77",
"value": "b131d6ed1b2ba510c5e163923b4bcb77"
},
"variables.numero_ramal": {
"display_value": "666",
"value": "666"
},
"description": {
"display_value": "Teste",
"value": "Teste"
},
"location": {
"display_value": "HMB - ANHAIA MELO",
"link": "https://caoadev.service-now.com/api/now/table/cmn_location/ab22f6e91b6f1050e77eb9121b4bcbcd",
"value": "ab22f6e91b6f1050e77eb9121b4bcbcd"
},
"variables.location": {
"display_value": "HMB - ANHAIA MELO",
"value": "ab22f6e91b6f1050e77eb9121b4bcbcd"
}
},
{
"variables.caller_id": {
"display_value": "SOTHIS CAOA",
"value": "b131d6ed1b2ba510c5e163923b4bcb77"
},
"number": {
"display_value": "INC0140376",
"value": "INC0140376"
},
"opened_at": {
"display_value": "25/08/2025 10:25:32",
"value": "2025-08-25 13:25:32"
},
"short_description": {
"display_value": "Problemas com Telefonia Fixa",
"value": "Problemas com Telefonia Fixa"
},
"variables.telephone_favorecido_rh": {
"display_value": "(11) 2222-2222",
"value": "(11) 2222-2222"
},
"opened_by.email": {
"display_value": "",
"value": ""
},
"opened_by": {
"display_value": "SOTHIS CAOA",
"link": "https://caoadev.service-now.com/api/now/table/sys_user/b131d6ed1b2ba510c5e163923b4bcb77",
"value": "b131d6ed1b2ba510c5e163923b4bcb77"
},
"variables.numero_ramal": {
"display_value": "666",
"value": "666"
},
"description": {
"display_value": "teste",
"value": "teste"
},
"location": {
"display_value": "HYUNDAI - MATRIZ",
"link": "https://caoadev.service-now.com/api/now/table/cmn_location/a3223ae91b6f1050e77eb9121b4bcb12",
"value": "a3223ae91b6f1050e77eb9121b4bcb12"
},
"variables.location": {
"display_value": "HYUNDAI - MATRIZ",
"value": "a3223ae91b6f1050e77eb9121b4bcb12"
}
},
{
"variables.caller_id": {
"display_value": "Vanessa Aparecida Dos Santos Mota",
"value": "a39a8abb1be2d01029846538fa4bcb82"
},
"number": {
"display_value": "INC0140349",
"value": "INC0140349"
},
"opened_at": {
"display_value": "17/07/2025 15:47:53",
"value": "2025-07-17 18:47:53"
},
"short_description": {
"display_value": "Problemas com Telefonia Fixa",
"value": "Problemas com Telefonia Fixa"
},
"variables.telephone_favorecido_rh": {
"display_value": "(12) 99118-5984",
"value": "(12) 99118-5984"
},
"opened_by.email": {
"display_value": "vanessa.mota@caoa.com.br",
"value": "vanessa.mota@caoa.com.br"
},
"opened_by": {
"display_value": "Vanessa Aparecida Dos Santos Mota",
"link": "https://caoadev.service-now.com/api/now/table/sys_user/a39a8abb1be2d01029846538fa4bcb82",
"value": "a39a8abb1be2d01029846538fa4bcb82"
},
"variables.numero_ramal": {
"display_value": "1239040620",
"value": "1239040620"
},
"description": {
"display_value": "Boa tarde, telefone principal da loja não está recebendo ligação, já mandei mensagem para o pessoal da Sothis e até o momento não tive retorno. Obrigada.",
"value": "Boa tarde, telefone principal da loja não está recebendo ligação, já mandei mensagem para o pessoal da Sothis e até o momento não tive retorno. Obrigada."
},
"location": {
"display_value": "HMB - SAO JOSE DOS CAMPOS",
"link": "https://caoadev.service-now.com/api/now/table/cmn_location/eb22f6e91b6f1050e77eb9121b4bcbeb",
"value": "eb22f6e91b6f1050e77eb9121b4bcbeb"
},
"variables.location": {
"display_value": "HMB - SAO JOSE DOS CAMPOS",
"value": "eb22f6e91b6f1050e77eb9121b4bcbeb"
}
},
{
"variables.caller_id": {
"display_value": "Rebeca Maila Pereira De Jesus Da Silva",
"value": "c8ed818d870cea90ab40c8440cbb3532"
},
"number": {
"display_value": "INC0140292",
"value": "INC0140292"
},
"opened_at": {
"display_value": "17/07/2025 09:07:35",
"value": "2025-07-17 12:07:35"
},
"short_description": {
"display_value": "Problemas com Telefonia Fixa",
"value": "Problemas com Telefonia Fixa"
},
"variables.telephone_favorecido_rh": {
"display_value": "(71) 3032-2350",
"value": "(71) 3032-2350"
},
"opened_by.email": {
"display_value": "rebeca.dsilva@caoa.com.br",
"value": "rebeca.dsilva@caoa.com.br"
},
"opened_by": {
"display_value": "Rebeca Maila Pereira De Jesus Da Silva",
"link": "https://caoadev.service-now.com/api/now/table/sys_user/c8ed818d870cea90ab40c8440cbb3532",
"value": "c8ed818d870cea90ab40c8440cbb3532"
},
"variables.numero_ramal": {
"display_value": "2357, 2386, 2384, 2370",
"value": "2357, 2386, 2384, 2370"
},
"description": {
"display_value": "Ao tentar realizar chamadas, aparece a mensagem de \"rede indisponível\", impossibilitando o atendimento aos clientes.",
"value": "Ao tentar realizar chamadas, aparece a mensagem de \"rede indisponível\", impossibilitando o atendimento aos clientes."
},
"location": {
"display_value": "HMB - LAURO DE FREITAS",
"link": "https://caoadev.service-now.com/api/now/table/cmn_location/af22f6e91b6f1050e77eb9121b4bcbdd",
"value": "af22f6e91b6f1050e77eb9121b4bcbdd"
},
"variables.location": {
"display_value": "HMB - LAURO DE FREITAS",
"value": "af22f6e91b6f1050e77eb9121b4bcbdd"
}
},
{
"variables.caller_id": {
"display_value": "Edson Goncalves Da Silva Junior",
"value": "a28a0a7b1be2d01029846538fa4bcb9d"
},
"number": {
"display_value": "INC0140279",
"value": "INC0140279"
},
"opened_at": {
"display_value": "16/07/2025 18:08:06",
"value": "2025-07-16 21:08:06"
},
"short_description": {
"display_value": "Problemas com Telefonia Fixa",
"value": "Problemas com Telefonia Fixa"
},
"variables.telephone_favorecido_rh": {
"display_value": "(43) 99127-1402",
"value": "(43) 99127-1402"
},
"opened_by.email": {
"display_value": "edson.gjunior@d21motors.com.br",
"value": "edson.gjunior@d21motors.com.br"
},
"opened_by": {
"display_value": "Edson Goncalves Da Silva Junior",
"link": "https://caoadev.service-now.com/api/now/table/sys_user/a28a0a7b1be2d01029846538fa4bcb9d",
"value": "a28a0a7b1be2d01029846538fa4bcb9d"
},
"variables.numero_ramal": {
"display_value": "4330313200",
"value": "4330313200"
},
"description": {
"display_value": "Gostaria de informar que diversos cliente estão relatando a incompatibilidade ao tentar entra em contato com a unidade, e notamos que ocorre principalmente com feitas pela operadora vivo.",
"value": "Gostaria de informar que diversos cliente estão relatando a incompatibilidade ao tentar entra em contato com a unidade, e notamos que ocorre principalmente com feitas pela operadora vivo."
},
"location": {
"display_value": "YELLOW - LONDRINA",
"link": "https://caoadev.service-now.com/api/now/table/cmn_location/37223ae91b6f1050e77eb9121b4bcb4e",
"value": "37223ae91b6f1050e77eb9121b4bcb4e"
},
"variables.location": {
"display_value": "YELLOW - LONDRINA",
"value": "37223ae91b6f1050e77eb9121b4bcb4e"
}
},
{
"variables.caller_id": {
"display_value": "Vanessa Klenk Ribeiro Dos Santos",
"value": "21a5900cdb93701015471403149619e2"
},
"number": {
"display_value": "INC0140253",
"value": "INC0140253"
},
"opened_at": {
"display_value": "16/07/2025 13:51:05",
"value": "2025-07-16 16:51:05"
},
"short_description": {
"display_value": "Problemas com Internet",
"value": "Problemas com Internet"
},
"variables.telephone_favorecido_rh": {
"display_value": "(41) 99202-2250",
"value": "(41) 99202-2250"
},
"opened_by.email": {
"display_value": "gustavo.tavares@globalweb.com.br",
"value": "gustavo.tavares@globalweb.com.br"
},
"opened_by": {
"display_value": "Gustavo Oliveira Tavares",
"link": "https://caoadev.service-now.com/api/now/table/sys_user/93a51e5f87dd9a10ab40c8440cbb356d",
"value": "93a51e5f87dd9a10ab40c8440cbb356d"
},
"description": {
"display_value": "Colaboradora informa que teve uma queda de energia na localidade e quando retornou a energia, apenas sua máquina não está conectado com a internet. Poderiam verificar?\r\n\r\nKb não localizado\r\n\r\nContato: (41) 99202-2250\r\ne-mail: vanessa.santos@caoa.com.br",
"value": "Colaboradora informa que teve uma queda de energia na localidade e quando retornou a energia, apenas sua máquina não está conectado com a internet. Poderiam verificar?\r\n\r\nKb não localizado\r\n\r\nContato: (41) 99202-2250\r\ne-mail: vanessa.santos@caoa.com.br"
},
"location": {
"display_value": "HMB - ALTO DA XV",
"link": "https://caoadev.service-now.com/api/now/table/cmn_location/6f22f6e91b6f1050e77eb9121b4bcbcc",
"value": "6f22f6e91b6f1050e77eb9121b4bcbcc"
},
"variables.location": {
"display_value": "HMB - ALTO DA XV",
"value": "6f22f6e91b6f1050e77eb9121b4bcbcc"
}
},
{
"variables.caller_id": {
"display_value": "Alexandre Elizeu De Almeida",
"value": "988a427b1be2d01029846538fa4bcb56"
},
"number": {
"display_value": "INC0140250",
"value": "INC0140250"
},
"opened_at": {
"display_value": "16/07/2025 13:21:51",
"value": "2025-07-16 16:21:51"
},
"short_description": {
"display_value": "Problemas com Internet",
"value": "Problemas com Internet"
},
"variables.telephone_favorecido_rh": {
"display_value": "(44) 99108-9896",
"value": "(44) 99108-9896"
},
"opened_by.email": {
"display_value": "alexandre.almeida@d21motors.com.br",
"value": "alexandre.almeida@d21motors.com.br"
},
"opened_by": {
"display_value": "Alexandre Elizeu De Almeida",
"link": "https://caoadev.service-now.com/api/now/table/sys_user/988a427b1be2d01029846538fa4bcb56",
"value": "988a427b1be2d01029846538fa4bcb56"
},
"description": {
"display_value": "Boa tarde! A filial D21 Maringá está toda sem internet. Tanto a rede cabeada quanto wi-fi estão fora. Poderiam por gentileza verificar?",
"value": "Boa tarde! A filial D21 Maringá está toda sem internet. Tanto a rede cabeada quanto wi-fi estão fora. Poderiam por gentileza verificar?"
},
"location": {
"display_value": "YELLOW - MARINGA",
"link": "https://caoadev.service-now.com/api/now/table/cmn_location/73223ae91b6f1050e77eb9121b4bcb4f",
"value": "73223ae91b6f1050e77eb9121b4bcb4f"
},
"variables.location": {
"display_value": "YELLOW - MARINGA",
"value": "73223ae91b6f1050e77eb9121b4bcb4f"
}
},
{
"variables.caller_id": {
"display_value": "Vanessa Klenk Ribeiro Dos Santos",
"value": "21a5900cdb93701015471403149619e2"
},
"number": {
"display_value": "INC0140220",
"value": "INC0140220"
},
"opened_at": {
"display_value": "16/07/2025 09:33:05",
"value": "2025-07-16 12:33:05"
},
"short_description": {
"display_value": "Problemas com Internet",
"value": "Problemas com Internet"
},
"variables.telephone_favorecido_rh": {
"display_value": "(41) 99202-2250",
"value": "(41) 99202-2250"
},
"opened_by.email": {
"display_value": "guilhermefo@globalweb.com.br",
"value": "guilhermefo@globalweb.com.br"
},
"opened_by": {
"display_value": "Guilherme Henrique Fonseca Oliveira",
"link": "https://caoadev.service-now.com/api/now/table/sys_user/bf3d28ad872c16d0ab40c8440cbb3599",
"value": "bf3d28ad872c16d0ab40c8440cbb3599"
},
"description": {
"display_value": "Colaborador(a) relata que toda a localidade está sem acesso à internet, poderiam verificar por gentileza?\r\n\r\nOBS: Colaboradora informou que ontem houve uma queda de energia na localidade por volta das 18 e após isso a internet não voltou \r\nOBS: Segue em anexo prints evidenciando a indisponibilidade da Internet \r\n\r\nProblemas com Internet - Nenhum site está navegando-KB0010694",
"value": "Colaborador(a) relata que toda a localidade está sem acesso à internet, poderiam verificar por gentileza?\r\n\r\nOBS: Colaboradora informou que ontem houve uma queda de energia na localidade por volta das 18 e após isso a internet não voltou \r\nOBS: Segue em anexo prints evidenciando a indisponibilidade da Internet \r\n\r\nProblemas com Internet - Nenhum site está navegando-KB0010694"
},
"location": {
"display_value": "HMB - ALTO DA XV",
"link": "https://caoadev.service-now.com/api/now/table/cmn_location/6f22f6e91b6f1050e77eb9121b4bcbcc",
"value": "6f22f6e91b6f1050e77eb9121b4bcbcc"
},
"variables.location": {
"display_value": "HMB - ALTO DA XV",
"value": "6f22f6e91b6f1050e77eb9121b4bcbcc"
}
},
{
"variables.caller_id": {
"display_value": "Amanda Dos Santos Silva",
"value": "c88a027b1be2d01029846538fa4bcbdd"
},
"number": {
"display_value": "INC0140170",
"value": "INC0140170"
},
"opened_at": {
"display_value": "15/07/2025 14:43:01",
"value": "2025-07-15 17:43:01"
},
"short_description": {
"display_value": "Problemas com Wi-Fi/Rede Corporativa",
"value": "Problemas com Wi-Fi/Rede Corporativa"
},
"variables.telephone_favorecido_rh": {
"display_value": "(11) 3060-2865",
"value": "(11) 3060-2865"
},
"opened_by.email": {
"display_value": "amanda.ssilva@caoa.com.br",
"value": "amanda.ssilva@caoa.com.br"
},
"opened_by": {
"display_value": "Amanda Dos Santos Silva",
"link": "https://caoadev.service-now.com/api/now/table/sys_user/c88a027b1be2d01029846538fa4bcbdd",
"value": "c88a027b1be2d01029846538fa4bcbdd"
},
"description": {
"display_value": "Boa tarde!\r\nInternet não atinge a velocidade exigida pela montadora devido ao sinal, necessário instalação de uma nova antena de internet na sala dos consultores.\r\nCaso sendo tratado e acompanhado pelo Raphael Anjos.",
"value": "Boa tarde!\r\nInternet não atinge a velocidade exigida pela montadora devido ao sinal, necessário instalação de uma nova antena de internet na sala dos consultores.\r\nCaso sendo tratado e acompanhado pelo Raphael Anjos."
},
"location": {
"display_value": "ELIVEL - CEASA",
"link": "https://caoadev.service-now.com/api/now/table/cmn_location/6722f6e91b6f1050e77eb9121b4bcbc6",
"value": "6722f6e91b6f1050e77eb9121b4bcbc6"
},
"variables.location": {
"display_value": "ELIVEL - CEASA",
"value": "6722f6e91b6f1050e77eb9121b4bcbc6"
}
},
{
"variables.caller_id": {
"display_value": "Marcelo Machado",
"value": "1cd863e31bbcd550598a2021f54bcb8f"
},
"number": {
"display_value": "INC0140127",
"value": "INC0140127"
},
"opened_at": {
"display_value": "15/07/2025 08:35:12",
"value": "2025-07-15 11:35:12"
},
"short_description": {
"display_value": "Wi-fi Clientes",
"value": "Wi-fi Clientes"
},
"variables.telephone_favorecido_rh": {
"display_value": "(11) 94748-8877",
"value": "(11) 94748-8877"
},
"opened_by.email": {
"display_value": "gustavo.tavares@globalweb.com.br",
"value": "gustavo.tavares@globalweb.com.br"
},
"opened_by": {
"display_value": "Gustavo Oliveira Tavares",
"link": "https://caoadev.service-now.com/api/now/table/sys_user/93a51e5f87dd9a10ab40c8440cbb356d",
"value": "93a51e5f87dd9a10ab40c8440cbb356d"
},
"description": {
"display_value": "Colaborador informa que o wifi dos clientes da loja está conectando mas não está recebendo internet, impossibilitando a não navegação. Colaborador informa também que não sabe qual roteador deve reiniciar e por isso segue com esse problema. Poderiam verificar?\r\n\r\nContato: (11) 94748-8877\r\ne-mail: machado.marcelo@d21motors.com.br\r\nKb não localizado",
"value": "Colaborador informa que o wifi dos clientes da loja está conectando mas não está recebendo internet, impossibilitando a não navegação. Colaborador informa também que não sabe qual roteador deve reiniciar e por isso segue com esse problema. Poderiam verificar?\r\n\r\nContato: (11) 94748-8877\r\ne-mail: machado.marcelo@d21motors.com.br\r\nKb não localizado"
},
"location": {
"display_value": "YELLOW - SÃO BERNARDO",
"link": "https://caoadev.service-now.com/api/now/table/cmn_location/77223ae91b6f1050e77eb9121b4bcb69",
"value": "77223ae91b6f1050e77eb9121b4bcb69"
},
"variables.location": {
"display_value": "YELLOW - SÃO BERNARDO",
"value": "77223ae91b6f1050e77eb9121b4bcb69"
}
},
{
"variables.caller_id": {
"display_value": "Mayara Santos Duarte",
"value": "6fd0181d1b334ed0c5e163923b4bcb60"
},
"number": {
"display_value": "INC0140090",
"value": "INC0140090"
},
"opened_at": {
"display_value": "14/07/2025 15:22:54",
"value": "2025-07-14 18:22:54"
},
"short_description": {
"display_value": "Problemas com Telefonia Fixa",
"value": "Problemas com Telefonia Fixa"
},
"variables.telephone_favorecido_rh": {
"display_value": "(11) 97766-5397",
"value": "(11) 97766-5397"
},
"opened_by.email": {
"display_value": "gustavo.tavares@globalweb.com.br",
"value": "gustavo.tavares@globalweb.com.br"
},
"opened_by": {
"display_value": "Gustavo Oliveira Tavares",
"link": "https://caoadev.service-now.com/api/now/table/sys_user/93a51e5f87dd9a10ab40c8440cbb356d",
"value": "93a51e5f87dd9a10ab40c8440cbb356d"
},
"variables.numero_ramal": {
"display_value": "3883 / 3880 / 3882",
"value": "3883 / 3880 / 3882"
},
"description": {
"display_value": "Colaboradora informa que os ramais dos consultores não estão recebendo e nem efetuando ligações. No ramal aparece a mensagem a procurar serviço. Poderiam verificar?\r\n\r\nKb não localizado",
"value": "Colaboradora informa que os ramais dos consultores não estão recebendo e nem efetuando ligações. No ramal aparece a mensagem a procurar serviço. Poderiam verificar?\r\n\r\nKb não localizado"
},
"location": {
"display_value": "HMB - NACOES UNIDAS MATRIZ",
"link": "https://caoadev.service-now.com/api/now/table/cmn_location/ef22f6e91b6f1050e77eb9121b4bcbe1",
"value": "ef22f6e91b6f1050e77eb9121b4bcbe1"
},
"variables.location": {
"display_value": "HMB - NACOES UNIDAS MATRIZ",
"value": "ef22f6e91b6f1050e77eb9121b4bcbe1"
}
},
{
"variables.caller_id": {
"display_value": "Raphael Ranquini Da Rocha Araujo",
"value": "1275062d3be16210f6e903f136e45a95"
},
"number": {
"display_value": "INC0140089",
"value": "INC0140089"
},
"opened_at": {
"display_value": "14/07/2025 15:17:38",
"value": "2025-07-14 18:17:38"
},
"short_description": {
"display_value": "Problemas com Telefonia Fixa",
"value": "Problemas com Telefonia Fixa"
},
"variables.telephone_favorecido_rh": {
"display_value": "(21) 98438-5173",
"value": "(21) 98438-5173"
},
"opened_by.email": {
"display_value": "tales.lima@globalweb.com.br",
"value": "tales.lima@globalweb.com.br"
},
"opened_by": {
"display_value": "Tales da Silva de Lima",
"link": "https://caoadev.service-now.com/api/now/table/sys_user/f5f3499e3be312102b4dd037f4e45a01",
"value": "f5f3499e3be312102b4dd037f4e45a01"
},
"variables.numero_ramal": {
"display_value": "9257",
"value": "9257"
},
"description": {
"display_value": "O colaborador entrou em contato para solicitar ajuda com seu ramala que nçao recebe nem faz ligações. Relatou que os outros rmais da loja estão funcionando normalmente, exceto da sua mesa vizinha.\r\nKb não localizado",
"value": "O colaborador entrou em contato para solicitar ajuda com seu ramala que nçao recebe nem faz ligações. Relatou que os outros rmais da loja estão funcionando normalmente, exceto da sua mesa vizinha.\r\nKb não localizado"
},
"location": {
"display_value": "HMB - ITAUNA",
"link": "https://caoadev.service-now.com/api/now/table/cmn_location/e722f6e91b6f1050e77eb9121b4bcbdb",
"value": "e722f6e91b6f1050e77eb9121b4bcbdb"
},
"variables.location": {
"display_value": "HMB - ITAUNA",
"value": "e722f6e91b6f1050e77eb9121b4bcbdb"
}
},
{
"variables.caller_id": {
"display_value": "Rebeca Maila Pereira De Jesus Da Silva",
"value": "c8ed818d870cea90ab40c8440cbb3532"
},
"number": {
"display_value": "INC0140067",
"value": "INC0140067"
},
"opened_at": {
"display_value": "14/07/2025 11:03:11",
"value": "2025-07-14 14:03:11"
},
"short_description": {
"display_value": "Problemas com Telefonia Fixa",
"value": "Problemas com Telefonia Fixa"
},
"variables.telephone_favorecido_rh": {
"display_value": "(71) 3032-2350",
"value": "(71) 3032-2350"
},
"opened_by.email": {
"display_value": "rebeca.dsilva@caoa.com.br",
"value": "rebeca.dsilva@caoa.com.br"
},
"opened_by": {
"display_value": "Rebeca Maila Pereira De Jesus Da Silva",
"link": "https://caoadev.service-now.com/api/now/table/sys_user/c8ed818d870cea90ab40c8440cbb3532",
"value": "c8ed818d870cea90ab40c8440cbb3532"
},
"variables.numero_ramal": {
"display_value": "RAMAIS DO SETOR DE VENDAS EM GERAL: 2368, 2350...",
"value": "RAMAIS DO SETOR DE VENDAS EM GERAL: 2368, 2350..."
},
"description": {
"display_value": "O telefone 7130322350 não esta recebendo ligações externas, mesmo todos os cabos de redes estando conectados. Foi feito o teste efetuando a ligação com o telefone de colaboradores para a loja, mas a chamada não completa.\r\n\r\nPeço, por gentileza, a regularização com urgência pois esta impactando o atendimento aos clientes.",
"value": "O telefone 7130322350 não esta recebendo ligações externas, mesmo todos os cabos de redes estando conectados. Foi feito o teste efetuando a ligação com o telefone de colaboradores para a loja, mas a chamada não completa.\r\n\r\nPeço, por gentileza, a regularização com urgência pois esta impactando o atendimento aos clientes."
},
"location": {
"display_value": "HMB - LAURO DE FREITAS",
"link": "https://caoadev.service-now.com/api/now/table/cmn_location/af22f6e91b6f1050e77eb9121b4bcbdd",
"value": "af22f6e91b6f1050e77eb9121b4bcbdd"
},
"variables.location": {
"display_value": "HMB - LAURO DE FREITAS",
"value": "af22f6e91b6f1050e77eb9121b4bcbdd"
}
},
{
"variables.caller_id": {
"display_value": "Danieli Da Silva Lourenco",
"value": "0fbaae3bdba00210154714031496198c"
},
"number": {
"display_value": "INC0140062",
"value": "INC0140062"
},
"opened_at": {
"display_value": "14/07/2025 10:41:24",
"value": "2025-07-14 13:41:24"
},
"short_description": {
"display_value": "Problemas com Telefonia Fixa",
"value": "Problemas com Telefonia Fixa"
},
"variables.telephone_favorecido_rh": {
"display_value": "(11) 95437-2858",
"value": "(11) 95437-2858"
},
"opened_by.email": {
"display_value": "andrey.muniz@globalweb.com.br",
"value": "andrey.muniz@globalweb.com.br"
},
"opened_by": {
"display_value": "Andrey Chaves de Assuncao Barros Muniz",
"link": "https://caoadev.service-now.com/api/now/table/sys_user/530501c087f45e14ab40c8440cbb358c",
"value": "530501c087f45e14ab40c8440cbb358c"
},
"variables.numero_ramal": {
"display_value": "4229",
"value": "4229"
},
"description": {
"display_value": "Colaboradora diz que ao entrarem em contato com a loja uma das opções da ura de atendkmeto, da como indisponivel, poderiam verificar?",
"value": "Colaboradora diz que ao entrarem em contato com a loja uma das opções da ura de atendkmeto, da como indisponivel, poderiam verificar?"
},
"location": {
"display_value": "YELLOW - BERRINI",
"link": "https://caoadev.service-now.com/api/now/table/cmn_location/73223ae91b6f1050e77eb9121b4bcb35",
"value": "73223ae91b6f1050e77eb9121b4bcb35"
},
"variables.location": {
"display_value": "YELLOW - BERRINI",
"value": "73223ae91b6f1050e77eb9121b4bcb35"
}
},
{
"variables.caller_id": {
"display_value": "Halyff Lucas Zembrsuski",
"value": "bcca8efb1be2d01029846538fa4bcb82"
},
"number": {
"display_value": "INC0140050",
"value": "INC0140050"
},
"opened_at": {
"display_value": "14/07/2025 09:17:29",
"value": "2025-07-14 12:17:29"
},
"short_description": {
"display_value": "Problemas com Telefonia Fixa",
"value": "Problemas com Telefonia Fixa"
},
"variables.telephone_favorecido_rh": {
"display_value": "(51) 98404-0351",
"value": "(51) 98404-0351"
},
"opened_by.email": {
"display_value": "talison.costa@globalweb.com.br",
"value": "talison.costa@globalweb.com.br"
},
"opened_by": {
"display_value": "Talison Medeiros Costa",
"link": "https://caoadev.service-now.com/api/now/table/sys_user/664e5b4e8701a290ab40c8440cbb3598",
"value": "664e5b4e8701a290ab40c8440cbb3598"
},
"variables.numero_ramal": {
"display_value": "30758998",
"value": "30758998"
},
"description": {
"display_value": "Colaborador informa que o telefone da marca FAVIL está indisponível e mesmo trocando de ponto de rede continua sem dar sinal. Poderiam verificar?\r\n\r\nContato: (51) 98404-0351\r\n\r\nKb não localizado",
"value": "Colaborador informa que o telefone da marca FAVIL está indisponível e mesmo trocando de ponto de rede continua sem dar sinal. Poderiam verificar?\r\n\r\nContato: (51) 98404-0351\r\n\r\nKb não localizado"
},
"location": {
"display_value": "YELLOW - CANOAS",
"link": "https://caoadev.service-now.com/api/now/table/cmn_location/f3223ae91b6f1050e77eb9121b4bcb3d",
"value": "f3223ae91b6f1050e77eb9121b4bcb3d"
},
"variables.location": {
"display_value": "YELLOW - CANOAS",
"value": "f3223ae91b6f1050e77eb9121b4bcb3d"
}
},
{
"variables.caller_id": {
"display_value": "Alexandre Filgueiras Sampaio",
"value": "678b8ad1db1f715015471403149619b1"
},
"number": {
"display_value": "INC0140047",
"value": "INC0140047"
},
"opened_at": {
"display_value": "14/07/2025 09:03:05",
"value": "2025-07-14 12:03:05"
},
"short_description": {
"display_value": "Problemas com Telefonia Fixa",
"value": "Problemas com Telefonia Fixa"
},
"variables.telephone_favorecido_rh": {
"display_value": "(91) 98142-5518",
"value": "(91) 98142-5518"
},
"opened_by.email": {
"display_value": "guilhermefo@globalweb.com.br",
"value": "guilhermefo@globalweb.com.br"
},
"opened_by": {
"display_value": "Guilherme Henrique Fonseca Oliveira",
"link": "https://caoadev.service-now.com/api/now/table/sys_user/bf3d28ad872c16d0ab40c8440cbb3599",
"value": "bf3d28ad872c16d0ab40c8440cbb3599"
},
"variables.numero_ramal": {
"display_value": "33234109",
"value": "33234109"
},
"description": {
"display_value": "Colaborador entrou em contato informando que ao receber ligações os ramais ficam mudo, poderiam verificar?\r\n\r\nOBS: Problema se iniciou hoje\r\n\r\nContato: (91) 98142-5518\r\nKB não localizado ",
"value": "Colaborador entrou em contato informando que ao receber ligações os ramais ficam mudo, poderiam verificar?\r\n\r\nOBS: Problema se iniciou hoje\r\n\r\nContato: (91) 98142-5518\r\nKB não localizado "
},
"location": {
"display_value": "YELLOW - BELEM",
"link": "https://caoadev.service-now.com/api/now/table/cmn_location/f7223ae91b6f1050e77eb9121b4bcb33",
"value": "f7223ae91b6f1050e77eb9121b4bcb33"
},
"variables.location": {
"display_value": "YELLOW - BELEM",
"value": "f7223ae91b6f1050e77eb9121b4bcb33"
}
},
{
"variables.caller_id": {
"display_value": "Ester Da Conceicao Pinheiro Bandeira",
"value": "031cfdab97822a14501634a6f053afe1"
},
"number": {
"display_value": "INC0140037",
"value": "INC0140037"
},
"opened_at": {
"display_value": "12/07/2025 11:04:20",
"value": "2025-07-12 14:04:20"
},
"short_description": {
"display_value": "Problemas com Telefonia Fixa",
"value": "Problemas com Telefonia Fixa"
},
"variables.telephone_favorecido_rh": {
"display_value": "(91) 98293-5650",
"value": "(91) 98293-5650"
},
"opened_by.email": {
"display_value": "tales.lima@globalweb.com.br",
"value": "tales.lima@globalweb.com.br"
},
"opened_by": {
"display_value": "Tales da Silva de Lima",
"link": "https://caoadev.service-now.com/api/now/table/sys_user/f5f3499e3be312102b4dd037f4e45a01",
"value": "f5f3499e3be312102b4dd037f4e45a01"
},
"variables.numero_ramal": {
"display_value": "4108",
"value": "4108"
},
"description": {
"display_value": "A colaboradora informou que seu ramal se encontra fora. Não está recebendo nem fazendo ligações, sejam internas ou externas. Poderiam verificar, por genitleza?\r\nKb não localizado",
"value": "A colaboradora informou que seu ramal se encontra fora. Não está recebendo nem fazendo ligações, sejam internas ou externas. Poderiam verificar, por genitleza?\r\nKb não localizado"
},
"location": {
"display_value": "YELLOW - BELEM",
"link": "https://caoadev.service-now.com/api/now/table/cmn_location/f7223ae91b6f1050e77eb9121b4bcb33",
"value": "f7223ae91b6f1050e77eb9121b4bcb33"
},
"variables.location": {
"display_value": "YELLOW - BELEM",
"value": "f7223ae91b6f1050e77eb9121b4bcb33"
}
},
{
"variables.caller_id": {
"display_value": "Marcelo Silva Vaz",
"value": "919eba291bbc3510598a2021f54bcb06"
},
"number": {
"display_value": "INC0140013",
"value": "INC0140013"
},
"opened_at": {
"display_value": "11/07/2025 14:46:41",
"value": "2025-07-11 17:46:41"
},
"short_description": {
"display_value": "Problemas com Telefonia Fixa",
"value": "Problemas com Telefonia Fixa"
},
"variables.telephone_favorecido_rh": {
"display_value": "(11) 96786-6325",
"value": "(11) 96786-6325"
},
"opened_by.email": {
"display_value": "marcelo.vaz@d21motors.com.br",
"value": "marcelo.vaz@d21motors.com.br"
},
"opened_by": {
"display_value": "Marcelo Silva Vaz",
"link": "https://caoadev.service-now.com/api/now/table/sys_user/919eba291bbc3510598a2021f54bcb06",
"value": "919eba291bbc3510598a2021f54bcb06"
},
"variables.numero_ramal": {
"display_value": "203",
"value": "203"
},
"description": {
"display_value": "RAMAL Sem Serviço",
"value": "RAMAL Sem Serviço"
},
"location": {
"display_value": "YELLOW - TATUAPE",
"link": "https://caoadev.service-now.com/api/now/table/cmn_location/b988f06fdbc909101547140314961969",
"value": "b988f06fdbc909101547140314961969"
},
"variables.location": {
"display_value": "YELLOW - TATUAPE",
"value": "b988f06fdbc909101547140314961969"
}
},
{
"variables.caller_id": {
"display_value": "Gabrielle Araujo Barbosa",
"value": "556a8ef71be2d01029846538fa4bcbe9"
},
"number": {
"display_value": "INC0140002",
"value": "INC0140002"
},
"opened_at": {
"display_value": "11/07/2025 13:45:18",
"value": "2025-07-11 16:45:18"
},
"short_description": {
"display_value": "Problemas com Telefonia Fixa",
"value": "Problemas com Telefonia Fixa"
},
"variables.telephone_favorecido_rh": {
"display_value": "(21) 96817-2060",
"value": "(21) 96817-2060"
},
"opened_by.email": {
"display_value": "guilhermefo@globalweb.com.br",
"value": "guilhermefo@globalweb.com.br"
},
"opened_by": {
"display_value": "Guilherme Henrique Fonseca Oliveira",
"link": "https://caoadev.service-now.com/api/now/table/sys_user/bf3d28ad872c16d0ab40c8440cbb3599",
"value": "bf3d28ad872c16d0ab40c8440cbb3599"
},
"variables.numero_ramal": {
"display_value": "35398723",
"value": "35398723"
},
"description": {
"display_value": "Colaboradora entrou em contato informando que seu ramal consta como indisponível, poderiam verificar?\r\n\r\nOBS: Colaboradora informa que a internet no seu computador esta funcionando \r\n\r\nContato:(21) 96817-2060\r\nKb não localizado ",
"value": "Colaboradora entrou em contato informando que seu ramal consta como indisponível, poderiam verificar?\r\n\r\nOBS: Colaboradora informa que a internet no seu computador esta funcionando \r\n\r\nContato:(21) 96817-2060\r\nKb não localizado "
},
"location": {
"display_value": "HMB - TIJUCA",
"link": "https://caoadev.service-now.com/api/now/table/cmn_location/a322f6e91b6f1050e77eb9121b4bcbee",
"value": "a322f6e91b6f1050e77eb9121b4bcbee"
},
"variables.location": {
"display_value": "HMB - TIJUCA",
"value": "a322f6e91b6f1050e77eb9121b4bcbee"
}
}
]
}

View File

@ -1,3 +1,10 @@
const { snServices } = require('./controllers/servicenowController');
const { logInfo } = require('./utils/logger');
logInfo('Aplicação iniciada', {
timestamp: new Date().toISOString(),
environment: process.env.NODE_ENV || 'development'
});
snServices();

View File

@ -1,53 +0,0 @@
//Conetnando ao banco de dados
const pool = require('../data/database');
class TicketSnModel {
// Salvar os tickets
static async saveTickets(ticketData, typeTicket) {
//Query SQL
const query = `INSERT INTO tickets_sn
(ticket_number, short_description, description, caller_email,
location_name, ramal, telefone, opened_at, tipo)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
ON CONFLICT (ticket_number)
DO UPDATE SET
short_description = EXCLUDED.short_description,
description = EXCLUDED.description,
location_name = EXCLUDED.location_name,
updated_at = NOW()
RETURNING id
`;
// Dados do ticket
const values = [
ticketData.number?.value || null,
ticketData.short_description?.value || null,
ticketData.description?.value || null,
ticketData.caller_email?.value || null,
ticketData.location_name?.value || null,
ticketData.u_ramal?.value || null,
ticketData.u_telefone?.value || null,
ticketData.opened_at?.value || null,
typeTicket
];
// Executa a query
try {
console.log('Salvando ticket:', values[0]);
const result = await pool.query(query, values);
console.log('Ticket salvo com sucesso, ID:', result.rows[0].id);
return result.rows[0].id;
} catch (error) {
console.error('Erro ao salvar ticket:', error);
throw error;
}
}
// Poderemos adicionar mais métodos aqui para outras operações no banco de dados, se necessário.
// Exemplo: buscar tickets, atualizar tickets.
}
module.exports = TicketSnModel;

View File

@ -1,44 +1,62 @@
// src/models/ticketModel.js
const pool = require('../data/database');
const { logInfo, logError, logWarning } = require('../utils/logger');
const { DataTypes } = require('sequelize');
const db = require('./db');
class TicketSnModel {
// Define the Ticket model
const Ticket = db.define('Ticket', {
id: {
type: DataTypes.STRING,
primaryKey: true,
allowNull: false,
},
short_description: {
type: DataTypes.STRING,
allowNull: false,
},
description: {
type: DataTypes.TEXT,
allowNull: true,
},
state: {
type: DataTypes.STRING,
allowNull: false,
},
priority: {
type: DataTypes.STRING,
allowNull: true,
},
created_at: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW,
},
updated_at: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW,
},
}, {
timestamps: false, // Disable automatic timestamps
static async saveTicket(ticketData, typeTicket) {
const query = `
INSERT INTO tickets_sn
(ticket_number, short_description, description, caller_email,
location_name, ramal, telefone, opened_at, tipo)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
ON CONFLICT (ticket_number)
DO UPDATE SET
short_description = EXCLUDED.short_description,
description = EXCLUDED.description,
location_name = EXCLUDED.location_name,
caller_email = EXCLUDED.caller_email,
ramal = EXCLUDED.ramal,
telefone = EXCLUDED.telefone,
updated_at = NOW()
RETURNING id, xmax = 0 as inserted -- xmax = 0 indica INSERT, >0 indica UPDATE`;
const values = [
ticketData.number?.value || null,
ticketData.short_description?.value || null,
ticketData.description?.value || null,
ticketData['opened_by.email']?.value || null,
ticketData.location?.display_value || null,
ticketData['variables.numero_ramal']?.value || null,
ticketData['variables.telephone_favorecido_rh']?.value || null,
ticketData.opened_at?.value ? new Date(ticketData.opened_at.value) : null,
typeTicket
];
try {
const result = await pool.query(query, values);
const wasInserted = result.rows[0].inserted; // true = INSERT, false = UPDATE
if (wasInserted) {
logInfo(`✅ NOVO ticket salvo! ID: ${result.rows[0].id}`, {
ticket_id: result.rows[0].id,
ticket_number: values[0],
action: 'insert'
});
} else {
logInfo(`🔄 Ticket atualizado! ID: ${result.rows[0].id}`, {
ticket_id: result.rows[0].id,
ticket_number: values[0],
action: 'update'
});
}
// Export the Ticket model
module.exports = Ticket;
return result.rows[0].id;
} catch (error) {
logError(error, `❌ Erro ao salvar ticket ${values[0]}`);
throw error;
}
}
}
module.exports = TicketSnModel;

View File

@ -1,51 +1,56 @@
const axios = require('axios');
const apiConfig = require('../../config/apiConfig');
const fs = require('fs');
const TicketSnModel = require('../models/databaseModel');
const { Console } = require('console');
const TicketSnModel = require('../models/ticketSnModel');
const { logInfo, logError, logSync } = require('../utils/logger');
const fetchTicketsFromServiceNow = async () => {
try {
logInfo('📡 Buscando incidentes do ServiceNow...', { service: 'servicenow' });
const ticketsResponse = await axios.get(apiConfig.snIncidentConfig.baseUrl, {
auth: apiConfig.servicenowAuthentication.auth
});
// gerar um JSON das respostas da API //Mantive o json enquanto testo a integração com o banco
fs.writeFileSync('servicenow_tickets.json', JSON.stringify(ticketsResponse.data, null, 2));
// comentado para evitar muitos arquivos
//fs.writeFileSync('servicenow_tickets.json', JSON.stringify(ticketsResponse.data, null, 2));
//logInfo('💾 Backup JSON de incidentes salvo', { count: ticketsResponse.data.result.length });
// Salvar os tickets no banco de dados
console.log('Iniciando salvamento dos tickets no banco de dados...');
logInfo('💾 Iniciando salvamento de incidentes no banco...');
for (const ticket of ticketsResponse.data.result) {
await TicketSnModel.saveTickets(ticket, 'incidente');
await TicketSnModel.saveTicket(ticket, 'incidente');
}
logSync('ServiceNow', ticketsResponse.data.result.length, 'incidentes');
} catch (error) {
console.log('SERVICE NOW Tickets error: ', error.message);
logError(error, 'SERVICE NOW Tickets');
}
}
const fetchRequestsFromServiceNow = async () => {
try {
logInfo('📡 Buscando requisições do ServiceNow...', { service: 'servicenow' });
const requestsResponse = await axios.get(apiConfig.snRequestConfig.baseUrl, {
auth: apiConfig.servicenowAuthentication.auth
});
// gerar um JSON das respostas da API //Mantive o json enquanto testo a integração com o banco
fs.writeFileSync('servicenow_requests.json', JSON.stringify(requestsResponse.data, null, 2));
// Comentado para evitar muitos arquivos
//fs.writeFileSync('servicenow_requests.json', JSON.stringify(requestsResponse.data, null, 2));
//logInfo('💾 Backup JSON de requisições salvo', { count: requestsResponse.data.result.length });
// Salvar os tickets no banco de dados
console.log('Iniciando salvamento das requisições no banco de dados...');
// Salvar as requisições no banco de dados
logInfo('💾 Iniciando salvamento de requisições no banco...');
for (const request of requestsResponse.data.result) {
await TicketSnModel.saveTickets(request, 'requisicao');
await TicketSnModel.saveTicket(request, 'requisicao');
}
logSync('ServiceNow', requestsResponse.data.result.length, 'requisições');
} catch (error) {
console.log('SERVICE NOW Requests error: ', error.message);
logError(error, 'SERVICE NOW Requests');
}
}

View File

@ -1,39 +1,82 @@
const winston = require('winston');
const path = require('path');
const fs = require('fs');
// Create a logger instance with specified settings
// verifica se a pasta de logs existe, se não, cria
const logsDir = path.join(__dirname, '../../logs');
if (!fs.existsSync(logsDir)) {
fs.mkdirSync(logsDir, { recursive: true });
}
// Configuração do logger com winston
const logger = winston.createLogger({
level: 'info',
format: winston.format.combine(
winston.format.timestamp(),
winston.format.timestamp({
format: 'YYYY-MM-DD HH:mm:ss'
}),
winston.format.errors({ stack: true }), // ← Mostra stack trace de erros
winston.format.json()
),
transports: [
// Log to a file for application events
new winston.transports.File({ filename: path.join(__dirname, '../../logs/app.log') }),
// Log to a file for error events
new winston.transports.File({ filename: path.join(__dirname, '../../logs/error.log'), level: 'error' }),
// Log geral da aplicação
new winston.transports.File({
filename: path.join(logsDir, 'app.log'),
maxsize: 5242880, // 5MB
maxFiles: 5
}),
// Log de erros
new winston.transports.File({
filename: path.join(logsDir, 'error.log'),
level: 'error',
maxsize: 5242880,
maxFiles: 3
}),
],
});
// If not in production, log to the console as well
// Log no console em desenvolvimento
if (process.env.NODE_ENV !== 'production') {
logger.add(new winston.transports.Console({
format: winston.format.simple(),
format: winston.format.combine(
winston.format.colorize(),
winston.format.printf(({ timestamp, level, message, stack }) => {
return `${timestamp} [${level}]: ${stack || message}`;
})
)
}));
}
// Utility function to log errors
const logError = (error) => {
logger.error(error);
// Funções utilitárias
const logError = (error, context = '') => {
if (error instanceof Error) {
logger.error(`${context} - ${error.message}`, { stack: error.stack });
} else {
logger.error(`${context} - ${error}`);
}
};
// Utility function to log info messages
const logInfo = (message) => {
logger.info(message);
const logInfo = (message, meta = {}) => {
logger.info(message, meta);
};
const logWarning = (message, meta = {}) => {
logger.warn(message, meta);
};
// Log de sincronização específico
const logSync = (service, count, type) => {
logger.info(`SYNC: ${service} - ${count} ${type} sincronizados`, {
service,
count,
type
});
};
module.exports = {
logger,
logError,
logInfo,
logWarning,
logSync
};