|
@@ -115,7 +115,18 @@ Error_manager Dispatch_command::dispatch_request_to_sql(int device_floor, int di
|
|
|
|
|
|
m_dispatch_process_type = Common_data::DISPATCH_PROCESS_PICKUP;
|
|
|
|
|
|
- m_dispatch_command_map[m_car_number_optimal].m_measure_info_msg = m_dispatch_vehicle_info.m_actually_measure_info_msg;
|
|
|
+ //查询 取车的车辆plc感测信息 取车指令 根据key 查询感测信息
|
|
|
+ t_error = query_dispatch_vehicle_for_primary_key_ex();
|
|
|
+ if ( t_error == Error_code::SUCCESS &&
|
|
|
+ m_dispatch_vehicle_info.m_plc_measure_info_msg.wheelbase()>1)
|
|
|
+ {
|
|
|
+ m_dispatch_command_map[m_car_number_optimal].m_measure_info_msg = m_dispatch_vehicle_info.m_plc_measure_info_msg;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ m_dispatch_command_map[m_car_number_optimal].m_measure_info_msg = m_dispatch_vehicle_info.m_actually_measure_info_msg;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
//更新 指令队列, 根据车牌号 修改状态即可, //指令状态, 0排队中, 1正在工作, 2已完成, 3故障异常
|
|
|
t_error = update_command_queue_for_statu(1);
|
|
@@ -901,6 +912,69 @@ Error_manager Dispatch_command::query_dispatch_vehicle_for_primary_key()
|
|
|
}
|
|
|
|
|
|
|
|
|
+//查询 取车的车辆plc感测信息 取车指令 根据key 查询感测信息
|
|
|
+Error_manager Dispatch_command::query_dispatch_vehicle_for_primary_key_ex()
|
|
|
+{
|
|
|
+ //查询 车辆表
|
|
|
+ char query_parkspace_sql[1024];
|
|
|
+ memset(query_parkspace_sql, 0, 1024);
|
|
|
+ int t_statu = 0; //车位状态, 0可用, 1故障
|
|
|
+ sprintf(query_parkspace_sql,"select * from vehicle where primary_key = '%s' ",m_dispatch_command_map[m_car_number_optimal].m_primary_key.c_str());
|
|
|
+// std::cout<<"query_parkspace_sql = "<<query_parkspace_sql<<std::endl;
|
|
|
+ boost::shared_ptr<sql::ResultSet> tp_result = nullptr;
|
|
|
+ Error_manager ec = Database_controller::get_instance_pointer()->sql_query(query_parkspace_sql, tp_result);
|
|
|
+ if(ec == SUCCESS)
|
|
|
+ {
|
|
|
+ if(tp_result == nullptr)
|
|
|
+ {
|
|
|
+ return DB_RESULT_SET_EMPTY;
|
|
|
+ }
|
|
|
+ //只取第一条结果, 默认是id最小的,
|
|
|
+ if (tp_result->next())
|
|
|
+ {
|
|
|
+ char buf[1024];
|
|
|
+ memset(buf, 0, 1024);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ //解析数据
|
|
|
+ m_dispatch_vehicle_info.m_car_number = tp_result->getString("car_number");
|
|
|
+ m_dispatch_vehicle_info.m_primary_key = tp_result->getString("primary_key");
|
|
|
+ m_dispatch_vehicle_info.m_plc_measure_info = tp_result->getString("plc_measure_info");
|
|
|
+
|
|
|
+ //取车, 数据库特有车位信息
|
|
|
+ if(! google::protobuf::TextFormat::ParseFromString(m_dispatch_vehicle_info.m_plc_measure_info, &m_dispatch_vehicle_info.m_plc_measure_info_msg))
|
|
|
+ {
|
|
|
+ return Error_manager(Error_code::ERROR, Error_level::MINOR_ERROR,
|
|
|
+ "ParseFromString fun error, m_space_info ");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (sql::SQLException &e)
|
|
|
+ {
|
|
|
+ /* Use what() (derived from std::runtime_error) to fetch the error message */
|
|
|
+ sprintf(buf, "# ERR: %s\n (MySQL error code: %d, SQLState: %s", e.what(), e.getErrorCode(), e.getSQLState().c_str());
|
|
|
+ return Error_manager(DB_RESULT_SET_PARSE_ERROR, NEGLIGIBLE_ERROR, buf);
|
|
|
+ }
|
|
|
+ catch (std::runtime_error &e)
|
|
|
+ {
|
|
|
+ sprintf(buf, "# ERR: %s\n ERR: runtime_error in %s ", e.what(), __FILE__);
|
|
|
+ return Error_manager(DB_RESULT_SET_PARSE_ERROR, NEGLIGIBLE_ERROR, buf);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return Error_manager(Error_code::DB_QUERY_NOT_DATA, Error_level::MINOR_ERROR,
|
|
|
+ "数据库未查询到数据 Parkspace_operating_function::query_one_parkspace_with_license error ");
|
|
|
+
|
|
|
+ }
|
|
|
+ return SUCCESS;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return ec;
|
|
|
+ }
|
|
|
+ return SUCCESS;
|
|
|
+}
|
|
|
+
|
|
|
//更新 车位状态, 根据车位ID 写入车牌号即可
|
|
|
Error_manager Dispatch_command::update_parkspace_info_write_car_number()
|
|
|
{
|