|
@@ -95,13 +95,13 @@ Error_manager Parkspace_operating_function::get_all_parkspace_info(message::Park
|
|
return ec;
|
|
return ec;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-// 从数据库获得所有指定类型车位信息,用于车位模块初始化
|
|
|
|
|
|
+// 从数据库获得所有指定类型空车位车位信息,用于车位模块初始化
|
|
Error_manager Parkspace_operating_function::get_specify_the_type_parkspace_info(message::Parkspace_allocation_data_msg &all_specify_the_type_parkspace_info,int parkspace_type)
|
|
Error_manager Parkspace_operating_function::get_specify_the_type_parkspace_info(message::Parkspace_allocation_data_msg &all_specify_the_type_parkspace_info,int parkspace_type)
|
|
{
|
|
{
|
|
//执行sql操作
|
|
//执行sql操作
|
|
char all_specify_the_type_sql[1024];
|
|
char all_specify_the_type_sql[1024];
|
|
memset(all_specify_the_type_sql, 0, 1024);
|
|
memset(all_specify_the_type_sql, 0, 1024);
|
|
- sprintf(all_specify_the_type_sql,"select * from parkingspace where parkingspace_type= %d",parkspace_type);
|
|
|
|
|
|
+ sprintf(all_specify_the_type_sql,"select * from parkingspace where parkingspace_type= %d and parkingspace_status = 0",parkspace_type);
|
|
boost::shared_ptr<sql::ResultSet> tp_result = nullptr;
|
|
boost::shared_ptr<sql::ResultSet> tp_result = nullptr;
|
|
Error_manager ec = Database_controller::get_instance_pointer()->sql_query(all_specify_the_type_sql, tp_result);
|
|
Error_manager ec = Database_controller::get_instance_pointer()->sql_query(all_specify_the_type_sql, tp_result);
|
|
if(ec == SUCCESS)
|
|
if(ec == SUCCESS)
|
|
@@ -254,6 +254,7 @@ Error_manager Parkspace_operating_function::update_vehicle_with_parkspace(messag
|
|
return Error_manager(Error_code::PARAMETER_ERROR, Error_level::MINOR_ERROR,
|
|
return Error_manager(Error_code::PARAMETER_ERROR, Error_level::MINOR_ERROR,
|
|
"参数错误 Parkspace_operating_function::update_vehicle_with_parkspace error ");;
|
|
"参数错误 Parkspace_operating_function::update_vehicle_with_parkspace error ");;
|
|
}
|
|
}
|
|
|
|
+
|
|
std::string find_vehicle_sql = std::string("select * from vehicle where numberPlate = '").append(parkspace_info.car_info().license()).append("'");
|
|
std::string find_vehicle_sql = std::string("select * from vehicle where numberPlate = '").append(parkspace_info.car_info().license()).append("'");
|
|
boost::shared_ptr<sql::ResultSet> query_vehicle_result = nullptr;
|
|
boost::shared_ptr<sql::ResultSet> query_vehicle_result = nullptr;
|
|
Database_controller::get_instance_pointer()->sql_query(find_vehicle_sql, query_vehicle_result);
|
|
Database_controller::get_instance_pointer()->sql_query(find_vehicle_sql, query_vehicle_result);
|
|
@@ -264,6 +265,7 @@ Error_manager Parkspace_operating_function::update_vehicle_with_parkspace(messag
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
|
|
+
|
|
char update_vehicle_sql[1024];
|
|
char update_vehicle_sql[1024];
|
|
memset(update_vehicle_sql, 0, 1024);
|
|
memset(update_vehicle_sql, 0, 1024);
|
|
int vehicle_status_code = -1;
|
|
int vehicle_status_code = -1;
|
|
@@ -289,8 +291,13 @@ Error_manager Parkspace_operating_function::update_vehicle_with_parkspace(messag
|
|
"参数错误 Parkspace_operating_function::update_vehicle_with_parkspace error ");
|
|
"参数错误 Parkspace_operating_function::update_vehicle_with_parkspace error ");
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
+ if ( vehicle_status_code == 0 )
|
|
|
|
+ {
|
|
|
|
+ sprintf(update_vehicle_sql, "update vehicle set vehicleParkState = 0,carLength=NULL,carWidth=NULL,carHeight=NULL,carWheelBase = NULL,carWheelWidth = NULL,parkingSpaceID=NULL,parkingRecordsID=NULL where numberPlate = '%s'",
|
|
|
|
+ parkspace_info.car_info().license().c_str());
|
|
|
|
+ }
|
|
//车位为空,仅更新车辆状态与长宽高
|
|
//车位为空,仅更新车辆状态与长宽高
|
|
- if(parkspace_info.parkingspace_index_id() <= 0)
|
|
|
|
|
|
+ else if(parkspace_info.parkingspace_index_id() <= 0)
|
|
{
|
|
{
|
|
sprintf(update_vehicle_sql, "update vehicle set vehicleParkState = %d,carLength=%.3f,carWidth=%.3f,carHeight=%.3f,carWheelBase = %.3f,carWheelWidth = %.3f where numberPlate = '%s'",
|
|
sprintf(update_vehicle_sql, "update vehicle set vehicleParkState = %d,carLength=%.3f,carWidth=%.3f,carHeight=%.3f,carWheelBase = %.3f,carWheelWidth = %.3f where numberPlate = '%s'",
|
|
vehicle_status_code,
|
|
vehicle_status_code,
|
|
@@ -374,7 +381,7 @@ Error_manager Parkspace_operating_function::insert_vehicle_with_parkspace(messag
|
|
//车位为空,仅更新车辆状态与长宽高
|
|
//车位为空,仅更新车辆状态与长宽高
|
|
if(parkspace_info.parkingspace_index_id() <= 0)
|
|
if(parkspace_info.parkingspace_index_id() <= 0)
|
|
{
|
|
{
|
|
- sprintf(insert_vehicle_sql, "INSERT INTO vehicle (numberPlate,vehicleParkState,carLength,carWidth,carHeight,carWheelBase,carWheelWidth) values ('%s',%d,%.3f,%.3f,%.3f)",
|
|
|
|
|
|
+ sprintf(insert_vehicle_sql, "INSERT INTO vehicle (numberPlate,vehicleParkState,carLength,carWidth,carHeight,carWheelBase,carWheelWidth) values ('%s',%d,%.3f,%.3f,%.3f,%.3f,%.3f)",
|
|
parkspace_info.car_info().license().c_str(),
|
|
parkspace_info.car_info().license().c_str(),
|
|
vehicle_status_code,
|
|
vehicle_status_code,
|
|
parkspace_info.car_info().car_length(),
|
|
parkspace_info.car_info().car_length(),
|
|
@@ -386,7 +393,7 @@ Error_manager Parkspace_operating_function::insert_vehicle_with_parkspace(messag
|
|
//车位不为空,表示车辆在车位,同时更新
|
|
//车位不为空,表示车辆在车位,同时更新
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- sprintf(insert_vehicle_sql, "INSERT INTO vehicle (numberPlate,vehicleParkState,carLength,carWidth,carHeight,carWheelBase,carWheelWidth,parkingSpaceID) values ('%s',%d,%.3f,%.3f,%.3f,%d)",
|
|
|
|
|
|
+ sprintf(insert_vehicle_sql, "INSERT INTO vehicle (numberPlate,vehicleParkState,carLength,carWidth,carHeight,carWheelBase,carWheelWidth,parkingSpaceID) values ('%s',%d,%.3f,%.3f,%.3f,%.3f,%.3f,%d)",
|
|
parkspace_info.car_info().license().c_str(),
|
|
parkspace_info.car_info().license().c_str(),
|
|
vehicle_status_code,
|
|
vehicle_status_code,
|
|
parkspace_info.car_info().car_length(),
|
|
parkspace_info.car_info().car_length(),
|