eliminazione utilizzo del db mums

This commit is contained in:
2018-03-29 21:35:54 +02:00
parent f12a30b1e8
commit 84e3bd28ee
2 changed files with 10 additions and 13 deletions

View File

@@ -8,11 +8,13 @@ use Mail::Sender;
# Variables # Variables
my $username = 'aseuser'; my $username = 'aseuser';
my $password = 'Mums0001!'; my $password = 'Mums0001!';
my $database = 'ase_mums'; #my $database = 'ase_mums';
my $database = 'ase_lar';
my $db_lar = 'ase_lar'; my $db_lar = 'ase_lar';
my $server = 'localhost'; my $server = 'localhost';
my ($email_msg, $email_obj, $tools_info, $ref_date); my ($email_msg, $email_obj, $tools_info, $ref_date);
my $act_tool = 0; my $act_tool = 0;
my $gd_tool = 0;
#my $email_addr = 'alessandro.battilani@gmail.com'; #my $email_addr = 'alessandro.battilani@gmail.com';
my $email_addr = 'aseparma@gmail.com,alessandro.battilani@gmail.com,corrado@geielettronica.it,luca.chiapponi@unipr.it'; my $email_addr = 'aseparma@gmail.com,alessandro.battilani@gmail.com,corrado@geielettronica.it,luca.chiapponi@unipr.it';
@@ -129,6 +131,9 @@ if ($sth->rows < 0) {
$ToolName{$results->{'ToolNameID'}}{'ErroriTotaliLetture'} = "--"; $ToolName{$results->{'ToolNameID'}}{'ErroriTotaliLetture'} = "--";
if ($results->{'ToolState'} eq "Active" ){ if ($results->{'ToolState'} eq "Active" ){
$act_tool++; $act_tool++;
}
if (substr($results->{'ToolNameID'},0,2) eq "GD" ){
$act_tool++;
} }
} }
} }
@@ -140,7 +145,7 @@ $dbh->disconnect;
$dbh = DBI->connect("DBI:mysql:$database;host=$server", $username, $password) $dbh = DBI->connect("DBI:mysql:$database;host=$server", $username, $password)
or die getLoggingTime() . " - Could not connect to database: $DBI::errstr"; or die getLoggingTime() . " - Could not connect to database: $DBI::errstr";
my $stw = $dbh->prepare("select ToolNameID, EventDate, count(EventTime) 'LettureNodi', truncate(Count(EventTime)/max(NodeNum),1) 'LettureCatene', max(NodeNum) 'NumeroNodi' from RAWDATA where ToolNameId not like 'DT009%' and EventDate = subdate(curdate(),1) group by ToolNameID") my $stw = $dbh->prepare("select ToolNameID, EventDate, count(EventTime) 'LettureNodi', truncate(Count(EventTime)/max(NodeNum),1) 'LettureCatene', max(NodeNum) 'NumeroNodi' from RAWDATACOR where EventDate = subdate(curdate(),1) group by ToolNameID")
or die getLoggingTime() . " - $DBI::errstr"; or die getLoggingTime() . " - $DBI::errstr";
$stw->execute(); $stw->execute();
@@ -154,7 +159,7 @@ if ($stw->rows == 0) {
$ToolName{$results->{'ToolNameID'}}{'NumeroNodi'} = $results->{'NumeroNodi'}; $ToolName{$results->{'ToolNameID'}}{'NumeroNodi'} = $results->{'NumeroNodi'};
$ref_date = $results->{'EventDate'}; $ref_date = $results->{'EventDate'};
} }
if ($act_tool == $stw->rows) { if (($act_tool + $gd_tool) == $stw->rows) {
$email_obj = "Tutte le letture pervenute."; $email_obj = "Tutte le letture pervenute.";
} else { } else {
$email_obj = "ATTENZIONE: alcune letture non pervenute!!!"; $email_obj = "ATTENZIONE: alcune letture non pervenute!!!";

View File

@@ -16,8 +16,8 @@ my $password = 'laravel';
my $db_lar = 'ase_lar'; my $db_lar = 'ase_lar';
my $db_sp = 'ase_lar'; my $db_sp = 'ase_lar';
my $server = 'localhost'; my $server = 'localhost';
my $db_name = "ase_mums"; my $db_name = "ase_lar";
my $table = "RAWDATA"; my $table = "RAWDATACOR";
my ( @CSVData, @sql ); my ( @CSVData, @sql );
my $outcount = 0; my $outcount = 0;
my $outfilenum = 0; my $outfilenum = 0;
@@ -81,14 +81,6 @@ sub writeOutSql {
@sql = (); @sql = ();
print SQLOUT "/* unlock table */\nUNLOCK TABLES;\n"; print SQLOUT "/* unlock table */\nUNLOCK TABLES;\n";
if ( $table eq 'RAWDATA' ) {
print SQLOUT "/* call stored procedure to copy in "
. $db_sp
. "*/\ncall "
. $db_sp
. ".CopyAndFill('$tn');\n";
}
close SQLOUT close SQLOUT
or die( getTimeStamp("log") or die( getTimeStamp("log")
. " - pid $$ >> Error in closing file " . " - pid $$ >> Error in closing file "