foreach $prob (@problem) { # Start Problem Table loop
#
# Problem Table processing
#
chomp $prob;
my ($company, $logical_name, $numberprgn, $assignment, $uis_elapsed_start_time, $close_time, $res_anal_code,
$user_priority, $severity_code ) = split (/,/, $prob);
next unless ($logical_name);
#
# Exclude entries where the dates are non digits (headings)
#
next unless {($uis_elapsed_start_time =~ /\d+/) || ($close_time =~ /\d+/)};
###############################################################################################
#
# Problem Table exceptions
#
###############################################################################################
#
# Exception for Morgan Stanley
#
if ($key eq "mwd") {$severity_code = $user_priority;}
#
# Exceptions for International Paper
#
if ($key eq "ipa") {
next unless ($logical_name =~ /\.na\.ipa$/i);
}
if ($key eq "ipi") {
next unless ($logical_name =~ /\.na\.ipi$/i);
}
#
# Joint customer exceptions
#
if ($key =~ /^com|gld|mmc|npa|pjc|shr|thc|trc|plx|lmr|mwd$/) {
next unless ($logical_name =~ /\.na\.$key$/i);
}
#
# Split ticket open and close dates into chunks
#
my ($open_month, $open_day, $open_year, $junk2) = split (/-/,$uis_elapsed_start_time);
my ($close_month, $close_day, $close_year, $junk1) = split (/-/,$close_time);
#
# Count open and closed tickets for each month of the 4 months chart. We will use these
# for the one months chart as well.
#
#
# Closed tickets for last 4 months
#
if ($close_month == $last4months[0]) {$closed_cnt{$last4months[0]}++;}
if ($close_month == $last4months[1]) {$closed_cnt{$last4months[1]}++;}
if ($close_month == $last4months[2]) {$closed_cnt{$last4months[2]}++;}
if ($close_month == $last4months[3]) {$closed_cnt{$last4months[3]}++;}
#
# Opened tickets last 4 months
#
if ($open_month == $last4months[0]) {$open_cnt{$last4months[0]}++;}
if ($open_month == $last4months[1]) {$open_cnt{$last4months[1]}++;}
if ($open_month == $last4months[2]) {$open_cnt{$last4months[2]}++;}
if ($open_month == $last4months[3]) {$open_cnt{$last4months[3]}++;}
#
# Ending backlog last 4 months
#
if ($open_month == $last4months[0] && $close_month != $last4months[0]) {$end_backlog{$last4months[0]}++;}
if ($open_month == $last4months[1] && $close_month != $last4months[1]) {$end_backlog{$last4months[1]}++;}
if ($open_month == $last4months[2] && $close_month != $last4months[2]) {$end_backlog{$last4months[2]}++;}
if ($open_month == $last4months[3] && $close_month != $last4months[3]) {$end_backlog{$last4months[3]}++;}
#
# Starting backlog. We only need it for the current month
#
if ($open_month < $last4months[3]) {
$start_backlog{$last4months[3]}++ unless ($close_month);
$start_backlog{$last4months[3]}++ if ($close_month > $last4months[3] );
}
# if ($open_month < $last4months[1] && $close_month > $last4months[1]) {$start_backlog{$last4months[1]}++;}
# if ($open_month < $last4months[2] && $close_month > $last4months[2]) {$start_backlog{$last4months[2]}++;}
#if ($open_month < $last4months[3] && $close_month > $last4months[3]) {$start_backlog{$last4months[3]}++;}
#
# Exclude tickets closed before beginning, or opened after the end of the report period, then
# count each.
#
next if ($close_month < $rpt_month || $close_year < $rpt_yr); # exclude closed before beginning
next if ($open_month > $rpt_month || $open_year > $rpt_yr); #exclude open after end
if ($close_month == 01) {
$close_month = 13;
}
#
# Build and array of valid tickets for the report month. We will
# be using this later.
#
push (@prob_except, $prob);
#
# Get Problem type at resolution. Build a list of uniq problem types (res_anal_codes).
#
if ($close_month == $rpt_month) {
$close_cnt++; # Tickets Closed during the current month
next if ($res_anal_code =~ /cancel/i);
next if ($res_anal_code =~ /duplicate/i);
next if ($res_anal_code =~ /testing/i);
next if ($res_anal_code =~ /information/i);
#print "Res anal code:\t$res_anal_code\n";
#
# Count up the Problem types at resolution
#
if ($res_anal_code =~ /customer/i) {$changes++;}
elsif ($res_anal_code =~ /telco/i) {$telco++;}
elsif ($res_anal_code =~ /power/i) {$power++;}
elsif ($res_anal_code =~ /server/i) {$server++;}
elsif ($res_anal_code =~ /application/i) {$application++;}
else {$other++;}
}
#
# Handle defaults
#
unless ($severity_code) {$severity_code="critical";}
unless ($user_priority) {$user_priority = "S1";}
#
#
# For each entry in the problem table, loop through the device table, perform device table exclusions
# then match the logical_name from the problem table query with the logical_name from the device table
# query and if a match is found, populate the merge hash with the device table matching fields. If
# a match is not found, use default data to fill the hash with device table information.
#
#
foreach $dev (@device) { # Start Device Table loop.
#
# Device Table Processing
#
chomp $dev;
($log_name, $type, $subtype, $uis_support_level, $uis_tier, $uis_fstatus, $uis_managed_date, $uis_deactivated_date ) = split (/,/, $dev);
#select logical_name, type, subtype, uis_support_level, uis_tier, uis_fstatus, uis_managed_date, uis_deactivated_dat
########################################################################################
#
# Device Table exceptions
#
########################################################################################
#
# Joint customer exceptions
#
if ($key =~ /^com|gld|mmc|npa|pjc|shr|thc|trc|plx|lmr|mwd$/) {
next unless ($logical_name =~ /\.na\.$key$/i);
}
next if ($log_name =~ /default/i );
next if ($log_name =~ /imac/i );
next if ($type =~ /circuit/i );
#
# Build a list of unique device types
#
#$prob_type{$type} = "null";
#
# Build a list of types for each ticket
#
#print LOG "DEV = $log_name\tPROB = $logical_name\n";
if ($log_name eq $logical_name) {
#
# Merge it all
#
$match_cnt++;
push (@data,"$assignment, $res_anal_code, $user_priority, $severity_code, $type, $uis_support_level, $uis_tier, $uis_fstatus");
#print (LOG "merge for equal is = $Tickets\n");
#
# Could not find a match in the device table query. Populate the hash with default values
#
}elsif ($log_name ne $logical_name) { # Start logical name match loop.
#
# Assign default value to type based on assignment
#
if ($assignment =~ /nccbb/i) {
$type = "Network";
}elsif ($assignment =~ /smcbb/i) {
$type = "System";
}elsif ($assignment =~ /sccbb/i) {
$type = "Security"
}elsif ($assignment =~ /iptbb/i) {
$type = "VOIP";
}
#
# Assign default value to uis_tier
#
$uis_tier = "Tier 1";
#
# Assign default value to subtype
#
$subtype = "NULL";
#
# Assign default value to uis_support_level
#
$uis_support_level = "NULL";
#
# Merge it all
#
$merge{$numberprgn} = ("$logical_name, $numberprgn, $assignment, $uis_elapsed_start_time, $close_time,
$res_anal_code, $user_priority, $severity_code, $type, $subtype,
$uis_support_level, $uis_tier, $uis_fstatus, $uis_managed_date, $uis_deactivated_date");
print "$assignment, $res_anal_code, $user_priority, $severity_code, $type, $uis_support_level, $uis_tier, $uis_fstatus";
push (@data,"$assignment, $res_anal_code, $user_priority, $severity_code, $type, $uis_support_level, $uis_tier, $uis_fstatus");
$nomatch_cnt++;
# finished building records
} # End logical name match loop.
} # End Device Table loop.
} # End Problem Table Loop