DENISDIAKOV
(usa Outra)
Enviado em 06/10/2022 - 12:46h
Hoje só tenho isso aqui, que traz o progresso total para o prazo final da solução, ou seja quanto % falta para chegar na hora limite do chamado, logico que como observado a consulta traz mais coisas também .
SELECT
`glpi`.`glpi_tickets`.`id` AS `id_chamado`,
`glpi`.`glpi_tickets`.`status` AS `status`,
`glpi`.`glpi_tickets`.`type` AS `tipo`,
(SELECT
`glpi`.`glpi_entities`.`name`
FROM
`glpi`.`glpi_entities`
WHERE
(`glpi`.`glpi_entities`.`id` = `glpi`.`glpi_tickets`.`entities_id`)) AS `entidade`,
`glpi`.`glpi_itilcategories`.`name` AS `categoria`,
`glpi`.`glpi_tickets`.`name` AS `titulo`,
`glpi`.`glpi_tickets`.`date` AS `data_abertura`,
`glpi`.`glpi_tickets`.`actiontime` AS `duracao_total`,
SEC_TO_TIME(`glpi`.`glpi_tickets`.`actiontime`) AS `duracao_total_horas`,
(SELECT
COUNT(`glpi`.`glpi_tickettasks`.`id`)
FROM
`glpi`.`glpi_tickettasks`
WHERE
(`glpi`.`glpi_tickettasks`.`tickets_id` = `glpi`.`glpi_tickets`.`id`)) AS `tarefas`,
(SELECT
`glpi`.`glpi_requesttypes`.`name`
FROM
`glpi`.`glpi_requesttypes`
WHERE
(`glpi`.`glpi_requesttypes`.`id` = `glpi`.`glpi_tickets`.`requesttypes_id`)) AS `origem`,
(SELECT
`glpi`.`glpi_groups`.`name`
FROM
`glpi`.`glpi_groups`
WHERE
(`glpi`.`glpi_groups`.`id` = (SELECT
`glpi`.`glpi_groups_tickets`.`groups_id`
FROM
`glpi`.`glpi_groups_tickets`
WHERE
(`glpi`.`glpi_groups_tickets`.`id` = (SELECT
MAX(`glpi`.`glpi_groups_tickets`.`id`)
FROM
`glpi`.`glpi_groups_tickets`
WHERE
((`glpi`.`glpi_groups_tickets`.`type` = 2)
AND (`glpi`.`glpi_tickets`.`id` = `glpi`.`glpi_groups_tickets`.`tickets_id`))))))) AS `grupo_tecnico`,
(SELECT
`glpi`.`glpi_users`.`name`
FROM
`glpi`.`glpi_users`
WHERE
(`glpi`.`glpi_users`.`id` = (SELECT
`glpi`.`glpi_tickets_users`.`users_id`
FROM
`glpi`.`glpi_tickets_users`
WHERE
(`glpi`.`glpi_tickets_users`.`id` = (SELECT
MAX(`glpi`.`glpi_tickets_users`.`id`)
FROM
`glpi`.`glpi_tickets_users`
WHERE
((`glpi`.`glpi_tickets_users`.`type` = 2)
AND (`glpi`.`glpi_tickets`.`id` = `glpi`.`glpi_tickets_users`.`tickets_id`))))))) AS `tecnico`,
(SELECT
`glpi`.`glpi_users`.`name`
FROM
`glpi`.`glpi_users`
WHERE
(`glpi`.`glpi_users`.`id` = (SELECT
`glpi`.`glpi_tickets_users`.`users_id`
FROM
`glpi`.`glpi_tickets_users`
WHERE
(`glpi`.`glpi_tickets_users`.`id` = (SELECT
MAX(`glpi`.`glpi_tickets_users`.`id`)
FROM
`glpi`.`glpi_tickets_users`
WHERE
((`glpi`.`glpi_tickets_users`.`type` = 1)
AND (`glpi`.`glpi_tickets`.`id` = `glpi`.`glpi_tickets_users`.`tickets_id`))))))) AS `requerente`,
`glpi`.`glpi_tickets`.`solvedate` AS `data_solucao`,
`glpi`.`glpi_tickets`.`closedate` AS `data_fechamento`,
`glpi`.`glpi_tickets`.`time_to_resolve` AS `data_prevista_solucao`,
IF(((`glpi`.`glpi_tickets`.`time_to_resolve` IS NOT NULL)
AND (`glpi`.`glpi_tickets`.`status` <> 4)
AND ((`glpi`.`glpi_tickets`.`solvedate` > `glpi`.`glpi_tickets`.`time_to_resolve`)
OR (ISNULL(`glpi`.`glpi_tickets`.`solvedate`)
AND (`glpi`.`glpi_tickets`.`time_to_resolve` < NOW())))),
1,
0) AS `tempo_solucao_excedido`,
IF(((`glpi`.`glpi_tickets`.`time_to_own` IS NOT NULL)
AND (`glpi`.`glpi_tickets`.`status` <> 4)
AND ((`glpi`.`glpi_tickets`.`takeintoaccount_delay_stat` > TIME_TO_SEC(TIMEDIFF(`glpi`.`glpi_tickets`.`time_to_own`,
`glpi`.`glpi_tickets`.`date`)))
OR ((`glpi`.`glpi_tickets`.`takeintoaccount_delay_stat` = 0)
AND (`glpi`.`glpi_tickets`.`time_to_own` < NOW())))),
1,
0) AS `tempo_atendimento_excedido`,
IF((`glpi`.`glpi_tickets`.`status` > 4),
TIMEDIFF(`glpi`.`glpi_tickets`.`solvedate`,
`glpi`.`glpi_tickets`.`date`),
TIMEDIFF(NOW(), `glpi`.`glpi_tickets`.`date`)) AS `tma`,
((TIME_TO_SEC(IF((`glpi`.`glpi_tickets`.`status` > 4),
TIMEDIFF(`glpi`.`glpi_tickets`.`solvedate`,
`glpi`.`glpi_tickets`.`date`),
TIMEDIFF(NOW(), `glpi`.`glpi_tickets`.`date`))) / 60) / 60) AS `tma_horas_dec`,
`glpi`.`glpi_tickets`.`priority` AS `prioridade`,
(SELECT
`glpi`.`glpi_ticketsatisfactions`.`satisfaction`
FROM
`glpi`.`glpi_ticketsatisfactions`
WHERE
(`glpi`.`glpi_ticketsatisfactions`.`tickets_id` = `glpi`.`glpi_tickets`.`id`)) AS `satisfacao`,
(SELECT
`glpi`.`glpi_ticketsatisfactions`.`satisfaction`
FROM
`glpi`.`glpi_ticketsatisfactions`
WHERE
(`glpi`.`glpi_ticketsatisfactions`.`tickets_id` = `glpi`.`glpi_tickets`.`id`)) AS `satisfacao1`,
(SELECT
`glpi`.`glpi_ticketsatisfactions`.`date_answered`
FROM
`glpi`.`glpi_ticketsatisfactions`
WHERE
(`glpi`.`glpi_ticketsatisfactions`.`tickets_id` = `glpi`.`glpi_tickets`.`id`)) AS `data_resposta_satisfacao`,
IF(((((TIME_TO_SEC(TIMEDIFF(`glpi`.`glpi_tickets`.`time_to_resolve`,
NOW())) * 100) / TIME_TO_SEC(TIMEDIFF(`glpi`.`glpi_tickets`.`date`,
`glpi`.`glpi_tickets`.`time_to_resolve`))) + 100) > 100),
0,
IF(((((TIME_TO_SEC(TIMEDIFF(`glpi`.`glpi_tickets`.`time_to_resolve`,
NOW())) * 100) / TIME_TO_SEC(TIMEDIFF(`glpi`.`glpi_tickets`.`date`,
`glpi`.`glpi_tickets`.`time_to_resolve`))) + 100) BETWEEN 80 AND 100),
1,
IF(((((TIME_TO_SEC(TIMEDIFF(`glpi`.`glpi_tickets`.`time_to_resolve`,
NOW())) * 100) / TIME_TO_SEC(TIMEDIFF(`glpi`.`glpi_tickets`.`date`,
`glpi`.`glpi_tickets`.`time_to_resolve`))) + 100) < 80),
2,
3))) AS `progresso`,
IF(((IF((`glpi`.`glpi_tickets`.`status` > 4),
TIMEDIFF(`glpi`.`glpi_tickets`.`solvedate`,
`glpi`.`glpi_tickets`.`time_to_resolve`),
TIMEDIFF(NOW(),
`glpi`.`glpi_tickets`.`time_to_resolve`)) + INTERVAL 2 HOUR) > 0),
1,
IF(((IF((`glpi`.`glpi_tickets`.`status` > 4),
TIMEDIFF(`glpi`.`glpi_tickets`.`solvedate`,
`glpi`.`glpi_tickets`.`time_to_resolve`),
TIMEDIFF(NOW(),
`glpi`.`glpi_tickets`.`time_to_resolve`)) + INTERVAL 5 HOUR) > 0),
2,
0)) AS `criticidade`,
IF(((((TIME_TO_SEC(TIMEDIFF(`glpi`.`glpi_tickets`.`time_to_resolve`,
NOW())) * 100) / TIME_TO_SEC(TIMEDIFF(`glpi`.`glpi_tickets`.`date`,
`glpi`.`glpi_tickets`.`time_to_resolve`))) + 100) >= 100),
100,
(((TIME_TO_SEC(TIMEDIFF(`glpi`.`glpi_tickets`.`time_to_resolve`,
NOW())) * 100) / TIME_TO_SEC(TIMEDIFF(`glpi`.`glpi_tickets`.`date`,
`glpi`.`glpi_tickets`.`time_to_resolve`))) + 100)) AS `progresso_real`,
IF((`glpi`.`glpi_tickets`.`status` < 5),
0,
IF((DAYOFMONTH(`glpi`.`glpi_tickets`.`date`) >= 28),
0,
IF((MONTH(`glpi`.`glpi_tickets`.`date`) <> MONTH(`glpi`.`glpi_tickets`.`solvedate`)),
1,
0))) AS `backlog`,
IF((`glpi`.`glpi_tickets`.`status` > 4),
(TO_DAYS(`glpi`.`glpi_tickets`.`time_to_resolve`) - TO_DAYS(`glpi`.`glpi_tickets`.`date`)),
(TO_DAYS(NOW()) - TO_DAYS(`glpi`.`glpi_tickets`.`date`))) AS `dias_em_aberto`,
IF((`glpi`.`glpi_tickets`.`status` > 4),
SEC_TO_TIME(TIME_TO_SEC(TIMEDIFF(`glpi`.`glpi_tickets`.`solvedate`,
`glpi`.`glpi_tickets`.`date`))),
SEC_TO_TIME(TIME_TO_SEC(TIMEDIFF(NOW(), `glpi`.`glpi_tickets`.`date`)))) AS `horas_em_aberto`,
(SELECT
`glpi`.`glpi_plugin_formcreator_forms`.`name`
FROM
`glpi`.`glpi_plugin_formcreator_forms`
WHERE
(`glpi`.`glpi_plugin_formcreator_forms`.`id` = (SELECT
`glpi`.`glpi_plugin_formcreator_formanswers`.`plugin_formcreator_forms_id`
FROM
`glpi`.`glpi_plugin_formcreator_formanswers`
WHERE
(`glpi`.`glpi_plugin_formcreator_formanswers`.`id` = (SELECT
`glpi`.`glpi_items_tickets`.`items_id`
FROM
`glpi`.`glpi_items_tickets`
WHERE
((`glpi`.`glpi_items_tickets`.`tickets_id` = `glpi`.`glpi_tickets`.`id`)
AND (`glpi`.`glpi_items_tickets`.`itemtype` = 'PluginFormcreatorFormAnswer'))))))) AS `Formulario`,
IF((`glpi`.`glpi_tickets`.`status` <> 4),
NULL,
(SELECT
`glpi`.`glpi_plugin_moreticket_waitingtypes`.`name`
FROM
`glpi`.`glpi_plugin_moreticket_waitingtypes`
WHERE
(`glpi`.`glpi_plugin_moreticket_waitingtypes`.`id` = (SELECT
`glpi`.`glpi_plugin_moreticket_waitingtickets`.`plugin_moreticket_waitingtypes_id`
FROM
`glpi`.`glpi_plugin_moreticket_waitingtickets`
WHERE
(`glpi`.`glpi_plugin_moreticket_waitingtickets`.`id` = (SELECT
MAX(`glpi`.`glpi_plugin_moreticket_waitingtickets`.`id`)
FROM
`glpi`.`glpi_plugin_moreticket_waitingtickets`
WHERE
(`glpi`.`glpi_plugin_moreticket_waitingtickets`.`tickets_id` = `glpi`.`glpi_tickets`.`id`))))))) AS `tipo_espera`,
IF((`glpi`.`glpi_tickets`.`content` LIKE '%Toda a empresa está inoperante%'),
5,
IF((glpi.glpi_tickets.content LIKE '%O setor está inoperante%'),
4,
IF((glpi.glpi_tickets.content LIKE '%Apenas um grupo de pessoas está inoperante%'),
3,
IF((glpi.glpi_tickets.content LIKE '%Somente eu estou inoperante%'),
2,
IF((glpi.glpi_tickets.content LIKE '%Sem inoperância%'),
1,
0))))) AS impacto
FROM
(glpi.glpi_tickets
LEFT JOIN glpi.glpi_itilcategories ON ((glpi.glpi_itilcategories.id = glpi.glpi_tickets.itilcategories_id)))
WHERE
(glpi.glpi_tickets.is_deleted = 0)
ORDER BY glpi.glpi_tickets.id DESC