Adding cms_alert option

This commit is contained in:
ragu 2023-04-05 07:41:11 +02:00
parent cc82e0856a
commit b7e6c91efd
13 changed files with 106 additions and 54 deletions

View file

@ -125,8 +125,8 @@ sub utctime {
#'deviceTime' => '2021-10-14T08:19:35.000+0000',
#'serverTime' => '2021-10-14T07:19:37.000+0000',
#$utc_epoch -= 2*60*60;# -2 std (Sommerzeit)
$utc_epoch -= 1*60*60;# -1 std (Winterzeit)
$utc_epoch -= 2*60*60;# -2 std (Sommerzeit)
#$utc_epoch -= 1*60*60;# -1 std (Winterzeit)
$utc_epoch += $latency;
$time = gmtime($utc_epoch);#epoch
@ -431,6 +431,9 @@ sub get_positions {
if($theftmove_count < 10){
system("$dbt->{copri_conf}->{basedir}/$op_name->{syshost}/src/scripts/mailTransportcms.pl '$op_name->{syshost}' 'send_alarm2hotline' '1' '$c_id' ''");
print FILE "$dbt->{copri_conf}->{basedir}/$op_name->{syshost}/src/scripts/mailTransportcms.pl '$op_name->{syshost}' 'send_alarm2hotline' '1' '$c_id' ''\n\n";
if($op_name->{sms_alert}){
system("$dbt->{copri_conf}->{basedir}/$op_name->{syshost}/src/scripts/sms_message.pl '$op_name->{syshost}' 'send_alarm2hotline' '' '$c_id'");
}
}
}

View file

@ -93,8 +93,8 @@ sub utctime {
my $time = Time::Piece->strptime($date, "%Y-%m-%dT%H:%M:%S");
print FILE "localtime: " . $time->datetime . "\n";#localtime
my $utc_epoch = $time->epoch;
#$utc_epoch -= 2*60*60;# -2 std (Sommerzeit)
$utc_epoch -= 1*60*60;# -1 std (Winterzeit)
$utc_epoch -= 2*60*60;# -2 std (Sommerzeit)
#$utc_epoch -= 1*60*60;# -1 std (Winterzeit)
$utc_epoch += $latency;
$time = gmtime($utc_epoch);#epoch
print FILE "utctime: " . $time->datetime . "\n";#utc zulu date time
@ -179,7 +179,7 @@ sub get_tripsum {
if($ctpos->{int13} eq $resp->{deviceId}){
print FILE "device Id: $resp->{deviceId}" . "\n";
print FILE "distance: $resp->{distance}" . "\n";
if($resp->{distance}){
if($resp->{distance} && $resp->{distance} > 0){
#my $distance = $resp->{distance} / 1000 * 1.60934; #distance in Meilen
my $distance = $resp->{distance} / 1000;
$distance = sprintf('%.2f', $distance);

View file

@ -9,6 +9,8 @@
#SMS message locking_progress after 60sec
#sudo su www-data -c "./src/scripts/sms_message.pl shareeapp-operator locking_progress '0179xxxx372' $pos_id"
#
#SMS theftalarm
#sudo su www-data -c "./src/scripts/sms_message.pl shareedms-kn 'send_alarm2hotline' '' '18498'"
#
use vars qw($syshost);
@ -23,11 +25,13 @@ use warnings;
use POSIX;
use DateTime;
use DateTime::Format::Pg;
use Data::Dumper;
use Lib::Config;
use Mod::DBtank;
use Mod::SMSTransport;
use Data::Dumper;
my $cf = new Config;
my %varenv = $cf->envonline();
my $dbt = new DBtank;
my $smstrans = new SMSTransport;
@ -35,6 +39,7 @@ my $todo = $ARGV[1] || die 'todo not defined';
my $phone = $ARGV[2] || "";
my $pos_id = $ARGV[3] || "";
my $dbh = "";
my $oprefix = $dbt->{operator}->{$varenv{dbname}}->{oprefix} || "";
#operator contact
my $pref_cc = {
@ -45,9 +50,9 @@ my $dbh = "";
};
my $record_cc = { c_id => 0 };
$record_cc = $dbt->fetch_record($dbh,$pref_cc);
my $hotline = "";
my $contact_hotline = "";
$record_cc->{txt07} =~ s/\s//g;
$hotline = "Hotline $record_cc->{txt01} $record_cc->{txt07}";
$contact_hotline = "Hotline $record_cc->{txt01} $record_cc->{txt07}";
#SMS message if 24h,48h,72h occupied
@ -82,8 +87,8 @@ if($todo eq "24h_occupied"){
if($dt1 >= $dt2_72h_occupied){
if($cttpos->{$pid}->{int33} != 3){
$todo = "72h_occupied";
print $dt1 . ">=" . $dt2_72h_occupied . "|$todo,$hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name}\n";
$smstrans->sms_message($todo,$hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name});
print $dt1 . ">=" . $dt2_72h_occupied . "|$todo,$contact_hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name}\n";
$smstrans->sms_message($todo,$contact_hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name});
$dbt->update_one($dbh,$update_pos,"int33=3",$cttpos->{$pid}->{c_id});
}
}
@ -91,16 +96,16 @@ if($todo eq "24h_occupied"){
#elsif($dt1 >= $dt2_48h_occupied){
# if($cttpos->{$pid}->{int33} != 2){
# $todo = "48h_occupied";
# print $dt1 . ">=" . $dt2_48h_occupied . "|$todo,$hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name}\n";
# $smstrans->sms_message($todo,$hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name});
# print $dt1 . ">=" . $dt2_48h_occupied . "|$todo,$contact_hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name}\n";
# $smstrans->sms_message($todo,$contact_hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name});
# $dbt->update_one($dbh,$update_pos,"int33=2",$cttpos->{$pid}->{c_id});
# }
#}
elsif($dt1 >= $dt2_24h_occupied){
if($cttpos->{$pid}->{int33} != 1){
$todo = "24h_occupied";
print $dt1 . ">=" . $dt2_24h_occupied . "|$todo,$hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name}\n";
$smstrans->sms_message($todo,$hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name});
print $dt1 . ">=" . $dt2_24h_occupied . "|$todo,$contact_hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name}\n";
$smstrans->sms_message($todo,$contact_hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name});
$dbt->update_one($dbh,$update_pos,"int33=1",$cttpos->{$pid}->{c_id});
}
}
@ -123,14 +128,44 @@ if($todo eq "locking_progress" && $phone && $pos_id){
my $booking = { c_id => 0 };
$booking = $dbt->fetch_tablerecord($dbh,$booking_pos);
if($booking->{int20} == 3){
$smstrans->sms_message($todo,$hotline,$phone,$booking->{ct_name});
$smstrans->sms_message($todo,$contact_hotline,$phone,$booking->{ct_name});
}
}#end
#SMS message theftalarm
if($todo eq "send_alarm2hotline" && $pos_id){
my $sms_to = "$dbt->{copri_conf}->{sms_to}";
#will be executed by Ilockit cron, that's because extern
my $client_encoding = "iso-8859-1";
my $dbh_operator = $dbt->dbconnect_extern($dbt->{operator}->{$varenv{dbname}}->{database}->{dbname},$client_encoding);
my $pref_ctu = {
table => "contentuser",
fetch => "one",
c_id => "1",#Kontakt-hotline
};
my $uadr = { c_id => 0 };
$uadr = $dbt->fetch_tablerecord($dbh_operator,$pref_ctu);
my $phone = $uadr->{txt07} || $sms_to;
my $pref_ct = {
table => "contenttheftpos",
fetch => "one",
c_id => $pos_id,
};
my $ct = { c_id => 0 };
$ct = $dbt->fetch_tablerecord($dbh_operator,$pref_ct);
$smstrans->sms_message($todo,"",$phone,"$oprefix$ct->{barcode}");
}#end
#SMS message fraud to me
if($todo eq "fraud_rental" && $pos_id){
#my $sms_to = "$dbt->{copri_conf}->{sms_to}";
my $sms_to = "01759776061";
my $sms_to = "$dbt->{copri_conf}->{sms_to}";
my $booking_pos = {
table => "contenttranspos",
@ -144,3 +179,5 @@ if($todo eq "fraud_rental" && $pos_id){
$smstrans->sms_message($todo,"",$sms_to,$booking->{ct_name});
}#end