Merge branch 'master' of ssh://10.0.120.75:60000/home/desenvolvimento/HUBXGLPI/HUBXGLPI
This commit is contained in:
commit
16bbe4a612
@ -55,7 +55,7 @@ const formatDescription = (ticketData) => {
|
|||||||
<td style="padding: 8px; border: 1px solid #ddd;">${ticketData.ticket_mundiale}</td>
|
<td style="padding: 8px; border: 1px solid #ddd;">${ticketData.ticket_mundiale}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding: 8px; border: 1px solid #ddd;"><strong>Protocolo Hub (ServiceNow):</strong></td>
|
<td style="padding: 8px; border: 1px solid #ddd;"><strong>Protocolo Hub:</strong></td>
|
||||||
<td style="padding: 8px; border: 1px solid #ddd;">${ticketData.protocolo_hub || 'N/A'}</td>
|
<td style="padding: 8px; border: 1px solid #ddd;">${ticketData.protocolo_hub || 'N/A'}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@ -103,11 +103,13 @@ const formatTicketDataForGlpi = async (ticketData) => {
|
|||||||
const createGlpiTicket = async (ticketData) => {
|
const createGlpiTicket = async (ticketData) => {
|
||||||
try {
|
try {
|
||||||
const formattedTicketData = await formatTicketDataForGlpi(ticketData);
|
const formattedTicketData = await formatTicketDataForGlpi(ticketData);
|
||||||
console.log('Dados do ticket formatados para GLPI:', formattedTicketData);
|
// console.log('Dados do ticket formatados para GLPI:', formattedTicketData);
|
||||||
|
|
||||||
const glpiTicket = await glpiModel.insertTicket(formattedTicketData);
|
const glpiTicket = await glpiModel.insertTicket(formattedTicketData);
|
||||||
console.log('Ticket criado no GLPI:', glpiTicket);
|
console.log('Ticket criado no GLPI:', glpiTicket);
|
||||||
|
|
||||||
|
await glpiModel.insertGroupTickets(glpiTicket.insertId);
|
||||||
|
|
||||||
ticketData.status_sync = 'created_glpi';
|
ticketData.status_sync = 'created_glpi';
|
||||||
|
|
||||||
const updateSyncData = await hubglpiModel.update_syncData(ticketData);
|
const updateSyncData = await hubglpiModel.update_syncData(ticketData);
|
||||||
|
|||||||
@ -50,7 +50,7 @@ class GlpiModel {
|
|||||||
ticketData.urgency,
|
ticketData.urgency,
|
||||||
ticketData.impact,
|
ticketData.impact,
|
||||||
ticketData.priority,
|
ticketData.priority,
|
||||||
ticketData.type,
|
2,
|
||||||
ticketData.itilcategories_id,
|
ticketData.itilcategories_id,
|
||||||
ticketData.date_creation,
|
ticketData.date_creation,
|
||||||
37
|
37
|
||||||
@ -84,6 +84,24 @@ class GlpiModel {
|
|||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async insertGroupTickets(glpiTicketId) {
|
||||||
|
const query = `
|
||||||
|
INSERT INTO glpi_groups_tickets (tickets_id, groups_id, type)
|
||||||
|
VALUES (?, ?, ?)
|
||||||
|
`;
|
||||||
|
const values = [glpiTicketId, 25, 2];
|
||||||
|
try {
|
||||||
|
const res = await pool.query(query, values);
|
||||||
|
logInfo('ID de sync_data obtido com sucesso:', res.rows[0]);
|
||||||
|
return res.rows[0] ? res.rows[0].id : null;
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
logError('Erro ao obter ID de sync_data', err);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = GlpiModel;
|
module.exports = GlpiModel;
|
||||||
Loading…
Reference in New Issue
Block a user