60 lines
3.3 KiB
JavaScript
60 lines
3.3 KiB
JavaScript
|
|
// src/shared/repositories/hubsoft.repository.js
|
||
|
|
const { get } = require('pm2');
|
||
|
|
const db = require('../../../config/database.js');
|
||
|
|
const { logInfo, logError } = require('../../utils/logger.js');
|
||
|
|
|
||
|
|
|
||
|
|
async function getMundialeTickets() {
|
||
|
|
|
||
|
|
try {
|
||
|
|
const query = `SELECT a.id_atendimento, a.id_usuario_abertura, a.id_atendimento_status, a.protocolo, a.descricao_abertura, a.data_cadastro, a.nome_contato, c.codigo_cliente, s.descricao, cs.id_cliente_servico FROM atendimento AS a INNER JOIN cliente_servico AS cs ON a.id_cliente_servico = cs.id_cliente_servico INNER JOIN cliente AS c ON cs.id_cliente = c.id_cliente INNER JOIN servico AS s ON cs.id_servico = s.id_servico WHERE a.id_tipo_atendimento = 4 AND a.id_usuario_abertura = 248 AND a.id_atendimento_status IN (1, 2, 33) AND s.ativo = true;`;
|
||
|
|
const { rows } = await db.query(query);
|
||
|
|
return rows;
|
||
|
|
} catch (error) {
|
||
|
|
logError("Erro ao buscar tickets Mundiale:", error);
|
||
|
|
throw error;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
async function getImplantacaoTickets() {
|
||
|
|
try {
|
||
|
|
const query = `SELECT a.id_atendimento, a.id_usuario_abertura, a.id_atendimento_status, a.protocolo, a.descricao_abertura, a.data_cadastro, a.nome_contato, c.codigo_cliente, s.descricao, cs.id_cliente_servico FROM atendimento AS a INNER JOIN cliente_servico AS cs ON a.id_cliente_servico = cs.id_cliente_servico INNER JOIN cliente AS c ON cs.id_cliente = c.id_cliente INNER JOIN servico AS s ON cs.id_servico = s.id_servico WHERE a.id_tipo_atendimento = 21 AND a.id_atendimento_status IN (1, 2, 33) AND s.ativo = true;`;
|
||
|
|
const { rows } = await db.query(query);
|
||
|
|
return rows;
|
||
|
|
|
||
|
|
} catch (error) {
|
||
|
|
logError("Erro ao buscar tickets Implantação:", error);
|
||
|
|
throw error;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
async function getCancelamentoTickets() {
|
||
|
|
try {
|
||
|
|
const query = `SELECT a.id_atendimento, a.id_usuario_abertura, a.id_atendimento_status, a.protocolo, a.descricao_abertura, a.data_cadastro, a.nome_contato, c.codigo_cliente, s.descricao, cs.id_cliente_servico FROM atendimento AS a INNER JOIN cliente_servico AS cs ON a.id_cliente_servico = cs.id_cliente_servico INNER JOIN cliente AS c ON cs.id_cliente = c.id_cliente INNER JOIN servico AS s ON cs.id_servico = s.id_servico WHERE a.id_tipo_atendimento = 27 AND a.id_atendimento_status IN (1, 2, 33) AND s.ativo = true;`;
|
||
|
|
const { rows } = await db.query(query);
|
||
|
|
return rows;
|
||
|
|
} catch (error) {
|
||
|
|
logError("Erro ao buscar tickets Cancelamento:", error);
|
||
|
|
throw error;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
async function getSacTickets() {
|
||
|
|
try {
|
||
|
|
const query = `SELECT a.id_atendimento, a.id_usuario_abertura, a.id_atendimento_status, a.protocolo, a.descricao_abertura, a.data_cadastro, a.nome_contato, c.codigo_cliente, s.descricao, cs.id_cliente_servico FROM atendimento AS a INNER JOIN cliente_servico AS cs ON a.id_cliente_servico = cs.id_cliente_servico INNER JOIN cliente AS c ON cs.id_cliente = c.id_cliente INNER JOIN servico AS s ON cs.id_servico = s.id_servico WHERE a.id_tipo_atendimento = 41 AND a.id_atendimento_status IN (1, 2, 33) AND s.ativo = true;`;
|
||
|
|
const { rows } = await db.query(query);
|
||
|
|
return rows;
|
||
|
|
} catch (error) {
|
||
|
|
logError("Erro ao buscar tickets SAC:", error);
|
||
|
|
throw error;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
module.exports = {
|
||
|
|
getMundialeTickets,
|
||
|
|
getImplantacaoTickets,
|
||
|
|
getCancelamentoTickets,
|
||
|
|
getSacTickets
|
||
|
|
|
||
|
|
};
|