|
@@ -362,12 +362,23 @@ void Parkspace_manager:: execute_for_allocate(message::Car_info car_info, int te
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- t_error.set_error_code(SUCCESS);
|
|
|
- t_error.set_error_level(message::Error_level::NORMAL);
|
|
|
- LOG(INFO) << " 分配车位成功! ";
|
|
|
- LOG(INFO) << " 车位ID:"<<t_allocated_space.parkingspace_index_id()<<" 单元号:"<<t_allocated_space.parkingspace_unit_id()<<" 单元内部ID:"<<t_allocated_space.parkingspace_label_id();
|
|
|
- }
|
|
|
-
|
|
|
+ message::Vehicle_status t_car_status = message::Vehicle_status::eVehicle_parking;
|
|
|
+ error = m_parkspace_operating_function.update_vehicle_with_parkspace(t_allocated_space,t_car_status);
|
|
|
+ if ( error != Error_code::SUCCESS)
|
|
|
+ {
|
|
|
+ t_error.set_error_code(error.get_error_code());
|
|
|
+ t_error.set_error_level((message::Error_level)error.get_error_level());
|
|
|
+ t_error.set_error_description(error.get_error_description());
|
|
|
+ LOG(ERROR) << car_info.license() << " 停车更新数据库车辆表失败! " << error.to_string();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ t_error.set_error_code(SUCCESS);
|
|
|
+ t_error.set_error_level(message::Error_level::NORMAL);
|
|
|
+ LOG(INFO) << " 分配车位成功! ";
|
|
|
+ LOG(INFO) << " 车位ID:"<<t_allocated_space.parkingspace_index_id()<<" 单元号:"<<t_allocated_space.parkingspace_unit_id()<<" 单元内部ID:"<<t_allocated_space.parkingspace_label_id();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -727,6 +738,7 @@ Error_manager Parkspace_manager::release_parkspace_function(message::Parkspace_i
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ // search vehicle info
|
|
|
message::Vehicle_status t_vehicle_status;
|
|
|
//获取预约ID
|
|
|
int t_park_record_id;
|
|
@@ -736,6 +748,8 @@ Error_manager Parkspace_manager::release_parkspace_function(message::Parkspace_i
|
|
|
{
|
|
|
LOG(ERROR) << "释放车位 数据库查询车辆信息失败 " << error.to_string();
|
|
|
}
|
|
|
+
|
|
|
+ // update vehicle info
|
|
|
t_vehicle_status=message::eVehicle_idle;
|
|
|
error = m_parkspace_operating_function.update_vehicle_with_parkspace(release_parkspace_info, t_vehicle_status);
|
|
|
if (error != SUCCESS)
|
|
@@ -746,23 +760,26 @@ Error_manager Parkspace_manager::release_parkspace_function(message::Parkspace_i
|
|
|
error.set_error_code(SUCCESS);
|
|
|
error.set_error_level_location(Error_level::NORMAL);
|
|
|
|
|
|
- time_t tt = time(NULL);
|
|
|
- tm *t = localtime(&tt);
|
|
|
- char my_time_buf[255];
|
|
|
- memset(my_time_buf, 0, 255);
|
|
|
- sprintf(my_time_buf, "%d-%02d-%02d %02d:%02d:%02d",
|
|
|
- t->tm_year + 1900,
|
|
|
- t->tm_mon + 1,
|
|
|
- t->tm_mday,
|
|
|
- t->tm_hour,
|
|
|
- t->tm_min,
|
|
|
- t->tm_sec);
|
|
|
- release_parkspace_info.set_leave_time(my_time_buf);
|
|
|
- error = m_parkspace_operating_function.update_parking_record(release_parkspace_info, t_park_record_id);
|
|
|
- if (error != SUCCESS)
|
|
|
+ // update records if neeeded (only in fetch)
|
|
|
+ if(t_park_record_id>0)
|
|
|
{
|
|
|
- LOG(ERROR) << "更新停车记录失败: " << error.to_string();
|
|
|
- }
|
|
|
+ time_t tt = time(NULL);
|
|
|
+ tm *t = localtime(&tt);
|
|
|
+ char my_time_buf[255];
|
|
|
+ memset(my_time_buf, 0, 255);
|
|
|
+ sprintf(my_time_buf, "%d-%02d-%02d %02d:%02d:%02d",
|
|
|
+ t->tm_year + 1900,
|
|
|
+ t->tm_mon + 1,
|
|
|
+ t->tm_mday,
|
|
|
+ t->tm_hour,
|
|
|
+ t->tm_min,
|
|
|
+ t->tm_sec);
|
|
|
+ release_parkspace_info.set_leave_time(my_time_buf);
|
|
|
+ error = m_parkspace_operating_function.update_parking_record(release_parkspace_info, t_park_record_id);
|
|
|
+ if (error != SUCCESS) {
|
|
|
+ LOG(ERROR) << "更新停车记录失败: " << error.to_string();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else
|