mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-02-22 19:56:29 +01:00
service set battery charge
This commit is contained in:
parent
5cfcdb82f7
commit
14d1891695
3 changed files with 42 additions and 9 deletions
|
@ -623,7 +623,7 @@ sub service_update(){
|
|||
|
||||
if($action){
|
||||
my ($key,$val) = split /=/,$action;
|
||||
$update->{$key} = $val if($key eq "txt10");#pos station log on redistribution
|
||||
$update->{$key} = $val if($key =~ /txt1\d/);#logging redistribution and charge service action
|
||||
}elsif($q->param('work_id')){
|
||||
foreach (@tpl_order){
|
||||
my ($key,$val,$size) = split /=/,$_;
|
||||
|
@ -676,14 +676,20 @@ sub bikestate_update(){
|
|||
if(ref($update_hash) eq "HASH" && looks_like_number($update_hash->{int04})){
|
||||
$update->{int04} = "$update_hash->{int04}";
|
||||
}
|
||||
#set smartlock_battery_charge
|
||||
if(ref($update_hash) eq "HASH" && looks_like_number($update_hash->{int14})){
|
||||
$update->{int14} = "$update_hash->{int14}";
|
||||
}
|
||||
#set bike_battery_charge
|
||||
if(ref($update_hash) eq "HASH" && looks_like_number($update_hash->{int19})){
|
||||
$update->{int19} = "$update_hash->{int19}";
|
||||
}
|
||||
|
||||
$bw->log("bikestate_update bike to state c_id $c_id | $update->{int04} | $state | auth:$auth->{c_id}",$update,"");
|
||||
|
||||
my $record = { c_id => $c_id };
|
||||
my $rows = $dbt->update_record($dbh,$update,$record) if($record->{c_id} > 0);
|
||||
|
||||
#require "Mod/KMLout.pm";
|
||||
#my $kmlfile = KMLout::kmlGenerator($auth,"");
|
||||
|
||||
return $rows;
|
||||
}#bikestate_update
|
||||
|
||||
|
|
|
@ -780,7 +780,7 @@ elsif($q->param('request') eq "service_done"){
|
|||
$rows = $apif->service_update($q,$authraw,$node_template,$service_id);
|
||||
$response->{response_state} = "OK" if($rows > 0);
|
||||
$response->{response_text} = "OK, service_update" if($rows > 0);
|
||||
}
|
||||
}
|
||||
|
||||
#UPDATE bike content state
|
||||
if($q->param('work_id') eq "state" && looks_like_number($bike_id) && $q->param('work_val') =~ /available|maintenance|defect/){
|
||||
|
@ -793,16 +793,43 @@ elsif($q->param('request') eq "service_done"){
|
|||
$response->{response_text} = "OK, bikestate_update to state=$value";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#UPDATE bike battery charge
|
||||
if($q->param('work_id') =~ /smartlock_battery_charge|bike_battery_charge/ && looks_like_number($bike_id) && looks_like_number($q->param('work_val'))){
|
||||
#once again to get node_record template
|
||||
($xresponse->{$article}, $responseraw, $node_template, $crecord) = $apif->service_select($q,$authraw,"","1");
|
||||
my ($bikes_all,$bikes_allraw,$bikes_on_station) = $apif->bikes_all($q,\%varenv,$authraw,"");
|
||||
|
||||
if($q->param('work_id') eq "smartlock_battery_charge"){
|
||||
my $update_hash = { int14 => $q->param('work_val') };
|
||||
$rows = $apif->bikestate_update($authraw,$responseraw->{$service_id}->{cc_id},"",$update_hash);
|
||||
$response->{response_state} = "OK";
|
||||
$response->{response_text} = "OK, bikestate_update " . $q->param('work_id') . " to " . $q->param('work_val');
|
||||
#add-on to log
|
||||
my $action = "txt11=" . $bikes_allraw->{$bike_id}->{int14} . " - " . $q->param('work_val');
|
||||
$apif->service_update($q,$authraw,$node_template,$service_id,$action);
|
||||
}
|
||||
if($q->param('work_id') eq "bike_battery_charge"){
|
||||
my $update_hash = { int19 => $q->param('work_val') };
|
||||
$rows = $apif->bikestate_update($authraw,$responseraw->{$service_id}->{cc_id},"",$update_hash);
|
||||
$response->{response_state} = "OK";
|
||||
$response->{response_text} = "OK, bikestate_update " . $q->param('work_id') . " to " . $q->param('work_val');
|
||||
#add-on to log
|
||||
my $action = "txt12=" . $bikes_allraw->{$bike_id}->{int19} . " - " . $q->param('work_val');
|
||||
$apif->service_update($q,$authraw,$node_template,$service_id,$action);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#redistribution
|
||||
if(($q->param('work_id') eq "int04" || $q->param('work_id') eq "station") && looks_like_number($bike_id) && ($q->param('work_val') || looks_like_number($q->param('work_val')))){
|
||||
$q->param(-name=>'work_id',-value=>"int04") if($q->param('work_id') eq "station");#station db-field is int04
|
||||
my $to_station_id = $1 if($q->param('work_val') =~ /(\d+)/);
|
||||
my ($bikes_all,$bikes_allraw,$bikes_on_station) = $apif->bikes_all($q,\%varenv,$authraw,"");
|
||||
|
||||
#add-on to log redistribute#TODO dedicated db-fieled
|
||||
my $action = "txt10=" . $oprefix . $bikes_allraw->{$bike_id}->{int04} . " - " . $q->param('work_val');
|
||||
|
||||
#add-on to log redistribute
|
||||
my $action = "txt10=" . $bikes_allraw->{$bike_id}->{int04} . " - " . $q->param('work_val');
|
||||
$apif->service_update($q,$authraw,$node_template,$service_id,$action);
|
||||
|
||||
my ($stations_all,$stations_allraw) = $apif->stations_all($q,\%varenv,$bikes_on_station,$authraw);
|
||||
|
|
|
@ -134,7 +134,7 @@ sub tpl(){
|
|||
$searchref->{template_id_pos} = "$node_meta->{tpl_id}";
|
||||
$tpl_ids = "205";
|
||||
$tpl_ids = "225" if($node_meta->{tpl_id} == 499);
|
||||
$node_meta->{tpl_order} .= ",int04=Station on insert,txt10=Redistribution" if($node_meta->{tpl_id} != 499);
|
||||
$node_meta->{tpl_order} .= ",int04=Station on insert,txt10=Redistribution,txt11=smartlock_charge,txt12=bike_charge" if($node_meta->{tpl_id} != 499);
|
||||
}
|
||||
elsif($node_meta->{tpl_id} > 600 && $node_meta->{tpl_id} < 700){
|
||||
$table = "contentadr";
|
||||
|
|
Loading…
Add table
Reference in a new issue