Диплом: Автоматизация учета и обработки заявок пользователей на техническую поддержку (Help Desk) в ООО "Сфера ИТ"

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
86
if ( !$Param{Tn} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => 'Need TN!'
);
return;
}
# get database object
my $DBObject = $Kernel::OM->Get('Kernel::System::DB');
# db query
return if !$DBObject->Prepare(
SQL => 'SELECT id FROM ticket WHERE tn = ?',
Bind => [ \$Param{Tn} ],
Limit => 1,
);
my $TicketID;
while ( my @Row = $DBObject->FetchrowArray() ) {
$TicketID = $Row[0];
}
# get main ticket id if ticket has been merged
return if !$TicketID;
# do not check deeper than 10 merges
my $Limit = 10;
my $Count = 1;
MERGELOOP:
87
for ( 1 .. $Limit ) {
my %Ticket = $Self->TicketGet(
TicketID => $TicketID,
DynamicFields => 0,
);
return $TicketID if $Ticket{StateType} ne 'merged';
# get ticket history
my @Lines = $Self->HistoryGet(
TicketID => $TicketID,
UserID => 1,
);
HISTORYLINE:
for my $Data ( reverse @Lines ) {
next HISTORYLINE if $Data->{HistoryType} ne 'Merged';
if ( $Data->{Name} =~ /^.*%%\d+?%%(\d+?)$/ ) {
$TicketID = $1;
$Count++;
next MERGELOOP if ( $Count <= $Limit );
# returns no found Ticket after 10 deep-merges, so it should create a new
one
return;
}
}
return $TicketID;
}
88
return;
}
=head2 TicketCreate()
creates a new ticket
my $TicketID = $TicketObject->TicketCreate(
Title => 'Some Ticket Title',
Queue => 'Raw', # or QueueID => 123,
Lock => 'unlock',
Priority => '3 normal', # or PriorityID => 2,
State => 'new', # or StateID => 5,
CustomerID => '123465',
CustomerUser => 'customer@example.com',
OwnerID => 123,
UserID => 123,
);
or
my $TicketID = $TicketObject->TicketCreate(
TN => $TicketObject->TicketCreateNumber(), # optional
Title => 'Some Ticket Title',
Queue => 'Raw', # or QueueID => 123,
Lock => 'unlock',
Priority => '3 normal', # or PriorityID => 2,
State => 'new', # or StateID => 5,
Type => 'Incident', # or TypeID = 1 or Ticket type default
(Ticket::Type::Default), not required
89
Service => 'Service A', # or ServiceID => 1, not required
SLA => 'SLA A', # or SLAID => 1, not required
CustomerID => '123465',
CustomerUser => 'customer@example.com',
OwnerID => 123,
ResponsibleID => 123, # not required
ArchiveFlag => 'y', # (y|n) not required
UserID => 123,
);
Events:
TicketCreate
=cut
sub TicketCreate {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Needed (qw(OwnerID UserID)) {
if ( !$Param{$Needed} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Needed!"
);
return;
}
}
my $ArchiveFlag = 0;
90
if ( $Param{ArchiveFlag} && $Param{ArchiveFlag} eq 'y' ) {
$ArchiveFlag = 1;
}
$Param{ResponsibleID} ||= 1;
# get type object
my $TypeObject = $Kernel::OM->Get('Kernel::System::Type');
if ( !$Param{TypeID} && !$Param{Type} ) {
# get default ticket type
my $DefaultTicketType = $Kernel::OM->Get('Kernel::Config')-
>Get('Ticket::Type::Default');
# check if default ticket type exists
my %AllTicketTypes = reverse $TypeObject->TypeList();
if ( $AllTicketTypes{$DefaultTicketType} ) {
$Param{Type} = $DefaultTicketType;
}
else {
$Param{TypeID} = 1;
}
}
# TypeID/Type lookup!
if ( !$Param{TypeID} && $Param{Type} ) {
$Param{TypeID} = $TypeObject->TypeLookup( Type => $Param{Type} );
}
91
elsif ( $Param{TypeID} && !$Param{Type} ) {
$Param{Type} = $TypeObject->TypeLookup( TypeID => $Param{TypeID} );
}
if ( !$Param{TypeID} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "No TypeID for '$Param{Type}'!",
);
return;
}
# get queue object
my $QueueObject = $Kernel::OM->Get('Kernel::System::Queue');
# QueueID/Queue lookup!
if ( !$Param{QueueID} && $Param{Queue} ) {
$Param{QueueID} = $QueueObject->QueueLookup( Queue =>
$Param{Queue} );
}
elsif ( !$Param{Queue} ) {
$Param{Queue} = $QueueObject->QueueLookup( QueueID =>
$Param{QueueID} );
}
if ( !$Param{QueueID} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "No QueueID for '$Param{Queue}'!",
);
return;
}
92
# get state object
my $StateObject = $Kernel::OM->Get('Kernel::System::State');
# StateID/State lookup!
if ( !$Param{StateID} ) {
my %State = $StateObject->StateGet( Name => $Param{State} );
$Param{StateID} = $State{ID};
}
elsif ( !$Param{State} ) {
my %State = $StateObject->StateGet( ID => $Param{StateID} );
$Param{State} = $State{Name};
}
if ( !$Param{StateID} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "No StateID for '$Param{State}'!",
);
return;
}
# LockID lookup!
if ( !$Param{LockID} && $Param{Lock} ) {
$Param{LockID} = $Kernel::OM->Get('Kernel::System::Lock')->LockLookup(
Lock => $Param{Lock},
);
}
if ( !$Param{LockID} && !$Param{Lock} ) {
93
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => 'No LockID and no LockType!',
);
return;
}
# get priority object
my $PriorityObject = $Kernel::OM->Get('Kernel::System::Priority');
# PriorityID/Priority lookup!
if ( !$Param{PriorityID} && $Param{Priority} ) {
$Param{PriorityID} = $PriorityObject->PriorityLookup(
Priority => $Param{Priority},
);
}
elsif ( $Param{PriorityID} && !$Param{Priority} ) {
$Param{Priority} = $PriorityObject->PriorityLookup(
PriorityID => $Param{PriorityID},
);
}
if ( !$Param{PriorityID} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => 'No PriorityID (invalid Priority Name?)!',
);
return;
}
# get service object
94
my $ServiceObject = $Kernel::OM->Get('Kernel::System::Service');
# ServiceID/Service lookup!
if ( !$Param{ServiceID} && $Param{Service} ) {
$Param{ServiceID} = $ServiceObject->ServiceLookup(
Name => $Param{Service},
);
}
elsif ( $Param{ServiceID} && !$Param{Service} ) {
$Param{Service} = $ServiceObject->ServiceLookup(
ServiceID => $Param{ServiceID},
);
}
# get sla object
my $SLAObject = $Kernel::OM->Get('Kernel::System::SLA');
# SLAID/SLA lookup!
if ( !$Param{SLAID} && $Param{SLA} ) {
$Param{SLAID} = $SLAObject->SLALookup( Name => $Param{SLA} );
}
elsif ( $Param{SLAID} && !$Param{SLA} ) {
$Param{SLA} = $SLAObject->SLALookup( SLAID => $Param{SLAID} );
}
# create ticket number if none is given
if ( !$Param{TN} ) {
$Param{TN} = $Self->TicketCreateNumber();
}
95
# check ticket title
if ( !defined $Param{Title} ) {
$Param{Title} = '';
}
# substitute title if needed
else {
$Param{Title} = substr( $Param{Title}, 0, 255 );
}
# check database undef/NULL (set value to undef/NULL to prevent database er-
rors)
$Param{ServiceID} ||= undef;
$Param{SLAID} ||= undef;
# create db record
return if !$Kernel::OM->Get('Kernel::System::DB')->Do(
SQL => '
INSERT INTO ticket (tn, title, type_id, queue_id, ticket_lock_id,
user_id, responsible_user_id, ticket_priority_id, ticket_state_id,
escalation_time, escalation_update_time, escalation_response_time,
escalation_solution_time, timeout, service_id, sla_id, until_time,
archive_flag, create_time, create_by, change_time, change_by)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 0, 0, 0, 0, 0, ?, ?, 0, ?,
current_timestamp, ?, current_timestamp, ?)',
Bind => [
\$Param{TN}, \$Param{Title}, \$Param{TypeID}, \$Param{QueueID},
\$Param{LockID}, \$Param{OwnerID}, \$Param{ResponsibleID},
\$Param{PriorityID}, \$Param{StateID}, \$Param{ServiceID},
\$Param{SLAID}, \$ArchiveFlag, \$Param{UserID}, \$Param{UserID},

Смотрите также:

"Автоматизация обработки заявок ООО "Проектно-Строительная Компания"
"Автоматизация процесса аттестации персонала для ООО "Нэт Бай Нэт Холдинг"
"Анализ интернет-активности конкурентов ( на примере конкурентов "Газпром нефть")
"Бухгалтерский учёт и аудит расчётов с подотчётними лицами в организации на примере ООО "ЛОЦ 10""
«Психологическое сопровождение персонала в организации на примере ООО «Крокус»
Cовершенствование деловой оценки персонала в организации (на примере ООО "Даймонд кейтеринг развитие")
IPO - инструмент финансирования деятельности организации. На примере ПАО «Нефтяная компания «Лукойл»
PR как средство продвижения организации (на примере ПАО "Тамбовский завод "Комсомолец им. Н.С. Артемова")
PR-коммуникации в сфере общественного питания (на примере кафе-кондитерской «Cream Cheese»)
SMM как средство повышения эффективности работы учреждений социокультурной сферы (на примере Малого театра)