@@ -22,12 +22,12 @@ import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil ;
import cn.hutool.core.util.StrUtil ;
import cn.hutool.http.HttpUtil ;
import com.esotericsoftware.minlog.Log ;
import edu.wpi.rail.jrosbridge.Ros ;
import edu.wpi.rail.jrosbridge.Topic ;
import edu.wpi.rail.jrosbridge.callback.TopicCallback ;
import edu.wpi.rail.jrosbridge.messages.Message ;
import edu.wpi.rail.jrosbridge.services.ServiceResponse ;
import jline.internal.Log ;
import lombok.RequiredArgsConstructor ;
import com.alibaba.fastjson.JSONObject ;
import org.nl.agv.enu.TaskSendBackStatusEnum ;
@@ -41,6 +41,8 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service ;
import javax.annotation.Resource ;
import java.math.BigDecimal ;
import java.math.RoundingMode ;
import java.util.HashMap ;
import java.util.Map ;
import java.util.concurrent.CompletableFuture ;
@@ -66,12 +68,13 @@ public class HomeServiceImpl implements HomeService{
@Override
public void qeryDebuggerInfo ( ) {
Map < String , String > urlInfo = RosUtil . getRosHostInfo ( ) ;
//todo RosJons模拟数据用, 正式需改回
//String result1 = HttpUtil.get("http://localhost:8011/api/pcsIfPurchaseorder/queryApt");
//todo 用,正式需改回
//String result1 = "{\"Msg_DisplayState\":{\"AGV_ID\":255,\"Auto_In_Line_State\":0,\"Bosch_Car_Global_Theta\":-90.19221757272916,\"Bosch_Car_Global_rx\":-1.0619603784858553,\"Bosch_Car_Global_ry\":0.0020978358374357303,\"Bosch_Loc_State\":-2,\"Bosch_No_Rec_State\":0,\"Bosch_raw_age\":0.01389455795288086,\"Bosch_raw_epoch\":1,\"Bosch_raw_locState\":-2,\"Bosch_raw_qw\":0.9999999908132869,\"Bosch_raw_qx\":0.0,\"Bosch_raw_qy\":0.0,\"Bosch_raw_qz\":0.00013554861104682667,\"Bosch_raw_timestamp\":1695633231.1093392,\"Bosch_raw_uniqueId\":0,\"Bosch_raw_x\":0.0008994877773440588,\"Bosch_raw_x_odo\":0.0008994877773440588,\"Bosch_raw_y\":0.0006906610801896382,\"Bosch_raw_y_odo\":0.0006906610801896382,\"Bosch_raw_yaw\":0.00027109722292381746,\"Bosch_raw_yaw_odo\":0.0006906610801896382,\"Bosch_raw_z\":0.0,\"CAD_Or_TCS_Ctrl\":0,\"Car_Global_Theta\":-90.19221757272916,\"Car_Global_rx\":-1.0619603784858553,\"Car_Global_ry\":0.0020978358374357303,\"CurNodeID\":0,\"Cur_Stop_Info1_Authorized_Pass\":1,\"Cur_Stop_Info1_High_Precious_Enable\":1,\"Cur_Stop_Info1_Reached_Stop\":0,\"Cur_Stop_Info1_Set_Patht\":0.0,\"Cur_Stop_Info1_Set_Pathx\":0.0,\"Cur_Stop_Info1_Set_Pathy\":0.0,\"Cur_Stop_Info1_Single_Request_Sch\":0,\"Cur_Stop_Info1_Single_Stop_Sch\":0,\"Cur_Stop_Info1_StopEndNode\":0,\"Cur_Stop_Info1_StopStartNode\":0,\"Cur_Stop_Info1_Stop_Endt\":0.0,\"Cur_Stop_Info1_Stop_Endx\":0.0,\"Cur_Stop_Info1_Stop_Endy\":0.0,\"Cur_Stop_Info1_Stop_Num\":0,\"Cur_Stop_Info2_Authorized_Pass\":1,\"Cur_Stop_Info2_High_Precious_Enable\":1,\"Cur_Stop_Info2_Reached_Stop\":0,\"Cur_Stop_Info2_Set_Patht\":0.0,\"Cur_Stop_Info2_Set_Pathx\":0.0,\"Cur_Stop_Info2_Set_Pathy\":0.0,\"Cur_Stop_Info2_Single_Request_Sch\":0,\"Cur_Stop_Info2_Single_Stop_Sch\":0,\"Cur_Stop_Info2_StopEndNode\":0,\"Cur_Stop_Info2_StopStartNode\":0,\"Cur_Stop_Info2_Stop_Endt\":0.0,\"Cur_Stop_Info2_Stop_Endx\":0.0,\"Cur_Stop_Info2_Stop_Endy\":0.0,\"Cur_Stop_Info2_Stop_Num\":0,\"Curtis_Warning_Code_Pump\":0,\"Curtis_Warning_Code_Speed\":82,\"Curtis_Warning_Code_Steer\":0,\"EndNode\":0,\"Env_CustomName\":\"NobleLift\",\"Env_HMIUseJavaApp\":\"true\",\"Env_LearnEnable\":\"true\",\"Env_Lu_ROS_IP2\":\"\",\"Env_SoftwareVersion\":\"[Version]Magic4.1[Info]2023_09_21_20_41_37_Lu_ROS_magic4_waypointab_v31\",\"Env_VehicleType\":\"PS10LMT_HuaHai\",\"Get_Nav350_Curr_Layer\":0,\"Language\":1022739087,\"LastAltitudeExpectValue_mm\":0,\"LastGantryXExpectValue_mm\":0,\"LastGantryYExpectValue_mm\":0,\"Lateral_Deviation_m\":0.0,\"License_Info\":\"EC060800FFFBEBBF 6B7685747EBC EC060800FFFBEBBF 6B7685747EBC 2021/8/26 13:46:47 2021/8/26 13:46:47 1 UserClass5 Magic4_1\",\"LindeAgwSteerCenterPivotPlateAng\":0,\"LindeAgwSteerErrorFlag\":0,\"LindeAgwSteerModeSelectorState\":0,\"LindeAgwTracLiftErrorFlag\":0,\"LindeAgwTracLiftModeSelectorState\":0,\"LindeDriveErrCode1\":0,\"LindeDriveErrCode2\":0,\"LindeDriveErrCode3\":0,\"LindeDriveErrCode4\":0,\"LindeLiftErrCode1\":0,\"LindeLiftErrCode2\":0,\"LindeLiftErrCode3\":0,\"LindeLiftErrCode4\":0,\"LindeSteerErrCode1\":0,\"LindeSteerErrCode2\":0,\"LindeSteerErrCode3\":0,\"LindeSteerErrCode4\":0,\"Login_Info\":\"\",\"Min_Dist\":0.0,\"MissionCompleteAltitude_mm_RemoteOrHMI_FB\":0,\"MissionCompleteGantryX_mm_RemoteOrHMI_FB\":0,\"MissionCompleteGantryY_mm_RemoteOrHMI_FB\":0,\"Navi_Method\":3,\"ObstacleDetectState\":0,\"ObstacleTouchState\":0,\"Out_Of_Path_Times\":0,\"PFC_Sch\":0,\"PFC_State\":\"[PathFollow_Control_Handle_WLANJSON][PathFollow_Schedule_WLANJSON=0]\\n\",\"PLC_Warning_Code\":0,\"PWR_Percent\":100,\"PWR_Warn\":0,\"PathFollow_Enable\":0,\"PathFollow_Expect_AltitudeCtrlEnable\":0,\"PathFollow_Expect_GantryXCtrlEnable\":0,\"PathFollow_Expect_GantryYCtrlEnable\":0,\"Plate_Check_Err_Code\":0,\"ReachState\":0,\"RealAutoChargeState\":0,\"Ref_std_rt\":0.0,\"Ref_std_rx\":0.0,\"Ref_std_ry\":0.0,\"Remote_Or_HMI_Ctrl\":1,\"SVreal_angle\":0.0,\"Sche_JSON_Sche_Enable\":0,\"Speedm_Tmp\":0.0,\"StartNode\":0,\"Sub_Warning_Code0\":0,\"Sys_Mode\":4,\"Task_Sch\":0,\"Task_State\":\"\",\"Update_Sch\":0,\"Update_State\":\"\",\"VehicleCtrlExpThrottle\":0,\"VehicleCtrlRealAltitude_mm\":998,\"VehicleCtrlRealCustomStateByte0\":0,\"VehicleCtrlRealCustomStateByte1\":0,\"VehicleCtrlRealCustomStateByte2\":0,\"VehicleCtrlRealCustomStateByte3\":0,\"VehicleCtrlRealGantryX_mm\":0,\"VehicleCtrlRealGantryY_mm\":0,\"VehicleCtrlRealJoyEnable\":0,\"VehicleCtrlRealRCEnable\":0,\"VehicleCtrl_CAN_Err_Info\":0,\"Vertical_Deviation_deg\":0.0,\"Warning_Code\":754529,\"header\":{\"frame_id\":\"\",\"seq\":1904,\"stamp\":{\"nsec\":160948865,\"sec\":1695633231}}}}" ;
//JSONObject json = JSONObject.parseObject(result1);
String result = HttpUtil . get ( urlInfo . get ( " javaUrl " ) ) ;
JSONObject json = JSONObject. parseObject( result) ;
String result1 = " { \" Msg_DisplayState \" :{ \" AGV_ID \" :255, \" Auto_In_Line_State \" :0, \" Bosch_Car_Global_Theta \" :-90.19221757272916, \" Bosch_Car_Global_rx \" :-1.0619603784858553, \" Bosch_Car_Global_ry \" :0.0020978358374357303, \" Bosch_Loc_State \" :-2, \" Bosch_No_Rec_State \" :0, \" Bosch_raw_age \" :0.01389455795288086, \" Bosch_raw_epoch \" :1, \" Bosch_raw_locState \" :-2, \" Bosch_raw_qw \" :0.9999999908132869, \" Bosch_raw_qx \" :0.0, \" Bosch_raw_qy \" :0.0, \" Bosch_raw_qz \" :0.00013554861104682667, \" Bosch_raw_timestamp \" :1695633231.1093392, \" Bosch_raw_uniqueId \" :0, \" Bosch_raw_x \" :0.0008994877773440588, \" Bosch_raw_x_odo \" :0.0008994877773440588, \" Bosch_raw_y \" :0.0006906610801896382, \" Bosch_raw_y_odo \" :0.0006906610801896382, \" Bosch_raw_yaw \" :0.00027109722292381746, \" Bosch_raw_yaw_odo \" :0.0006906610801896382, \" Bosch_raw_z \" :0.0, \" CAD_Or_TCS_Ctrl \" :0, \" Car_Global_Theta \" :-90.19221757272916, \" Car_Global_rx \" :-1.0619603784858553, \" Car_Global_ry \" :0.0020978358374357303, \" CurNodeID \" :0, \" Cur_Stop_Info1_Authorized_Pass \" :1, \" Cur_Stop_Info1_High_Precious_Enable \" :1, \" Cur_Stop_Info1_Reached_Stop \" :0, \" Cur_Stop_Info1_Set_Patht \" :0.0, \" Cur_Stop_Info1_Set_Pathx \" :0.0, \" Cur_Stop_Info1_Set_Pathy \" :0.0, \" Cur_Stop_Info1_Single_Request_Sch \" :0, \" Cur_Stop_Info1_Single_Stop_Sch \" :0, \" Cur_Stop_Info1_StopEndNode \" :0, \" Cur_Stop_Info1_StopStartNode \" :0, \" Cur_Stop_Info1_Stop_Endt \" :0.0, \" Cur_Stop_Info1_Stop_Endx \" :0.0, \" Cur_Stop_Info1_Stop_Endy \" :0.0, \" Cur_Stop_Info1_Stop_Num \" :0, \" Cur_Stop_Info2_Authorized_Pass \" :1, \" Cur_Stop_Info2_High_Precious_Enable \" :1, \" Cur_Stop_Info2_Reached_Stop \" :0, \" Cur_Stop_Info2_Set_Patht \" :0.0, \" Cur_Stop_Info2_Set_Pathx \" :0.0, \" Cur_Stop_Info2_Set_Pathy \" :0.0, \" Cur_Stop_Info2_Single_Request_Sch \" :0, \" Cur_Stop_Info2_Single_Stop_Sch \" :0, \" Cur_Stop_Info2_StopEndNode \" :0, \" Cur_Stop_Info2_StopStartNode \" :0, \" Cur_Stop_Info2_Stop_Endt \" :0.0, \" Cur_Stop_Info2_Stop_Endx \" :0.0, \" Cur_Stop_Info2_Stop_Endy \" :0.0, \" Cur_Stop_Info2_Stop_Num \" :0, \" Curtis_Warning_Code_Pump \" :0, \" Curtis_Warning_Code_Speed \" :82, \" Curtis_Warning_Code_Steer \" :0, \" EndNode \" :0, \" Env_CustomName \" : \" NobleLift \" , \" Env_HMIUseJavaApp \" : \" true \" , \" Env_LearnEnable \" : \" true \" , \" Env_Lu_ROS_IP2 \" : \" \" , \" Env_SoftwareVersion \" : \" [Version]Magic4.1[Info]2023_09_21_20_41_37_Lu_ROS_magic4_waypointab_v31 \" , \" Env_VehicleType \" : \" PS10LMT_HuaHai \" , \" Get_Nav350_Curr_Layer \" :0, \" Language \" :1022739087, \" LastAltitudeExpectValue_mm \" :0, \" LastGantryXExpectValue_mm \" :0, \" LastGantryYExpectValue_mm \" :0, \" Lateral_Deviation_m \" :0.0, \" License_Info \" : \" EC060800FFFBEBBF 6B7685747EBC EC060800FFFBEBBF 6B7685747EBC 2021/8/26 13:46:47 2021/8/26 13:46:47 1 UserClass5 Magic4_1 \" , \" LindeAgwSteerCenterPivotPlateAng \" :0, \" LindeAgwSteerErrorFlag \" :0, \" LindeAgwSteerModeSelectorState \" :0, \" LindeAgwTracLiftErrorFlag \" :0, \" LindeAgwTracLiftModeSelectorState \" :0, \" LindeDriveErrCode1 \" :0, \" LindeDriveErrCode2 \" :0, \" LindeDriveErrCode3 \" :0, \" LindeDriveErrCode4 \" :0, \" LindeLiftErrCode1 \" :0, \" LindeLiftErrCode2 \" :0, \" LindeLiftErrCode3 \" :0, \" LindeLiftErrCode4 \" :0, \" LindeSteerErrCode1 \" :0, \" LindeSteerErrCode2 \" :0, \" LindeSteerErrCode3 \" :0, \" LindeSteerErrCode4 \" :0, \" Login_Info \" : \" \" , \" Min_Dist \" :0.0, \" MissionCompleteAltitude_mm_RemoteOrHMI_FB \" :0, \" MissionCompleteGantryX_mm_RemoteOrHMI_FB \" :0, \" MissionCompleteGantryY_mm_RemoteOrHMI_FB \" :0, \" Navi_Method \" :3, \" ObstacleDetectState \" :0, \" ObstacleTouchState \" :0, \" Out_Of_Path_Times \" :0, \" PFC_Sch \" :0, \" PFC_State \" : \" [PathFollow_Control_Handle_WLANJSON][PathFollow_Schedule_WLANJSON=0] \\ n \" , \" PLC_Warning_Code \" :0, \" PWR_Percent \" :100, \" PWR_Warn \" :0, \" PathFollow_Enable \" :0, \" PathFollow_Expect_AltitudeCtrlEnable \" :0, \" PathFollow_Expect_GantryXCtrlEnable \" :0, \" PathFollow_Expect_GantryYCtrlEnable \" :0, \" Plate_Check_Err_Code \" :0, \" ReachState \" :0, \" RealAutoChargeState \" :0, \" Ref_std_rt \" :0.0, \" Ref_std_rx \" :0.0, \" Ref_std_ry \" :0.0, \" Remote_Or_HMI_Ctrl \" :1, \" SVreal_angle \" :0.0, \" Sche_JSON_Sche_Enable \" :0, \" Speedm_Tmp \" :0.0, \" StartNode \" :0, \" Sub_Warning_Code0 \" :0, \" Sys_Mode \" :4, \" Task_Sch \" :0, \" Task_State \" : \" \" , \" Update_Sch \" :0, \" Update_State \" : \" \" , \" VehicleCtrlExpThrottle \" :0, \" VehicleCtrlRealAltitude_mm \" :998, \" VehicleCtrlRealCustomStateByte0 \" :0, \" VehicleCtrlRealCustomStateByte1 \" :0, \" VehicleCtrlRealCustomStateByte2 \" :0, \" VehicleCtrlRealCustomStateByte3 \" :0, \" VehicleCtrlRealGantryX_mm \" :0, \" VehicleCtrlRealGantryY_mm \" :0, \" VehicleCtrlRealJoyEnable \" :0, \" VehicleCtrlRealRCEnable \" :0, \" VehicleCtrl_CAN_Err_Info \" :0, \" Vertical_Deviation_deg \" :0.0, \" Warning_Code \" :754529, \" header \" :{ \" frame_id \" : \" \" , \" seq \" :1904, \" stamp \" :{ \" nsec \" :160948865, \" sec \" :1695633231}}}} " ;
JSONObject json = JSONObject . parseObject ( result1 ) ;
try {
// String result = HttpUtil.get(urlInfo.get("javaUrl")) ;
// JSONObject json = JSONObject. parseObject( result) ;
JSONObject jo = JSONObject . parseObject ( json . getString ( " Msg_DisplayState " ) ) ;
debugInfoJson . put ( " Msg_Timestamp " , jo . getJSONObject ( " header " ) . getJSONObject ( " stamp " ) . getString ( " sec " ) ) ;
debugInfoJson . put ( " AGV_ID " , jo . getString ( " AGV_ID " ) ) ;
@@ -140,6 +143,11 @@ public class HomeServiceImpl implements HomeService{
}
debugInfoJson . put ( " PathFollow_Enable " , PathFollow_Enable ) ;
}
catch ( Exception e ) {
Log . error ( " 通信失败: " + e . getMessage ( ) ) ;
throw new BadRequestException ( e . getMessage ( ) = = null ? " 通信失败, 请检查系统参数中的Ros连接信息 " : e . getMessage ( ) ) ;
}
}
public void QueryDebuggerInfo2 ( ) {
debugInfoJson = new JSONObject ( ) ;
@@ -230,7 +238,7 @@ public class HomeServiceImpl implements HomeService{
//手自动是Sys_Mode 3 REMA手动 4自动 5 IO手持方式的手动, 这个车不装
String automatic_status = debugInfoJson . getString ( " Sys_Mode " ) ;
if ( StrUtil . equals ( automatic_status , " 3 " ) ) {
agvrun_status_name = " REMA 手动" ;
agvrun_status_name = " 手动 " ;
}
if ( StrUtil . equals ( automatic_status , " 4 " ) ) {
agvrun_status_name = " 自动 " ;
@@ -256,11 +264,13 @@ public class HomeServiceImpl implements HomeService{
String automatic_status_name = " " ;
String device_info = " " ;
String task_name = " " ;
String task_info = " " ;
Integer electric = 0 ;
String speed = " " ;
String error_name = " 正常运行 " ;
JSONObject returnjo = new JSONObject ( ) ;
JSONObject row = new JSONObject ( ) ;
try {
//查询调试信息
CompletableFuture . runAsync ( this : : qeryDebuggerInfo , pool ) ;
JSONObject tasking = WQLObject . getWQLObject ( " ST_TASK_INFO " ) . query ( " is_delete= 0 and task_status='01' and task_type='1' " ) . uniqueResult ( 0 ) ;
@@ -271,14 +281,21 @@ public class HomeServiceImpl implements HomeService{
if ( tasking = = null ) {
task_status = " 无任务 " ;
}
JSONObject tasked = WQLObject. getWQLObject( " ST_TASK_INFO" ) . query ( " is_delete= 0 and task_status='00'and task_type='1'" ) . uniqueResult( 0 ) ;
// JSONObject tasked = WQLObject. getWQLObject(" ST_TASK_INFO").query(" is_delete= 0 and task_status='00'and task_type='1' order by seq_num "). uniqueResult(0) ;
JSONObject tasked = WQLObject . getWQLObject ( " ST_TASK_INFO " ) . query ( " is_delete= 0 and task_status='00'and task_type='1' order by seq_num " ) . uniqueResult ( 0 ) ;
if ( tasked ! = null ) {
task_status = " 有任务未执行 " ;
}
if ( tasking ! = null ) {
task_status = " 执行中 " ;
task_name = " 任务号: " + tasking . getString ( " task_code " ) + " - " + " 目标点: " + tasking . getString ( " next_point_code " ) ;
task_name = " 任务号: " + tasking . getString ( " task_code " ) ;
task_info = " 目标点: " + tasking . getString ( " next_point_code " ) ;
}
// else if(tasked!=null)
// {
// task_name = "任务号:" + tasked.getString("task_code");
// task_info = "目标点:" + tasked.getString("next_point_code");
// }
JSONObject unManFinishTask = WQLObject . getWQLObject ( " ST_TASK_INFO " ) . query ( " is_delete= 0 and task_status='02' and is_manualfinished='0'and task_type='1' " ) . uniqueResult ( 0 ) ;
if ( unManFinishTask ! = null & & tasked = = null ) {
button_code = " 1 " ;
@@ -330,17 +347,18 @@ public class HomeServiceImpl implements HomeService{
//手自动是Sys_Mode 3 REMA手动 4自动 5 IO手持方式的手动, 这个车不装
String automatic_status = debugInfoJson . getString ( " Sys_Mode " ) ;
if ( StrUtil . equals ( automatic_status , " 3 " ) ) {
agvrun_status_name = " REMA 手动" ;
agvrun_status_name = " 手动 " ;
}
if ( StrUtil . equals ( automatic_status , " 4 " ) ) {
agvrun_status_name = " 自动 " ;
}
if ( StrUtil . equals ( automatic_status , " 5 " ) ) {
agvrun_status_name = " IO手持方式的手动 " ;
agvrun_status_name = " IO " ;
}
//速度
speed = debugInfoJson . getString ( " Speedm_Tmp " ) = = null ? " 0 " : debugInfoJson . getString ( " Speedm_Tmp " ) ;
row . put ( " speed " , speed + " m/s " ) ;
BigDecimal e = new BigDecimal ( speed ) . setScale ( 3 , RoundingMode . HALF_UP ) ;
row . put ( " speed " , e + " m/s " ) ;
//agv状态枚举
row . put ( " agvrun_status " , agvrun_status ) ;
//agv状态名称, 1为运行 0为待机
@@ -377,6 +395,7 @@ public class HomeServiceImpl implements HomeService{
row . put ( " task_status " , task_status ) ;
//当前任务
row . put ( " task_name " , task_name ) ;
row . put ( " task_info " , task_info ) ;
row . put ( " task_num " , task_num ) ;
row . put ( " button_code " , button_code ) ;
row . put ( " button_name " , button_name ) ;
@@ -385,6 +404,11 @@ public class HomeServiceImpl implements HomeService{
returnjo . put ( " result " , row ) ;
return returnjo ;
}
catch ( Exception e ) {
Log . error ( " 通信失败: " + e . getMessage ( ) ) ;
throw new BadRequestException ( e . getMessage ( ) = = null ? " 通信失败, 请检查系统参数中的Ros连接信息 " : e . getMessage ( ) ) ;
}
}
@Override
public Map < String , Object > clickSave ( Map < String , String > jsonObject ) {
@@ -460,7 +484,7 @@ public class HomeServiceImpl implements HomeService{
JSONObject doingtaskjo = WQLObject . getWQLObject ( " ST_TASK_INFO " ) . query ( " is_delete= 0 and task_status='01' " ) . uniqueResult ( 0 ) ;
if ( ObjectUtil . isNotEmpty ( doingtaskjo ) ) {
returnjo . put ( " code " , " 0 " ) ;
returnjo . put ( " desc " , " 有正在执行的任务,不能生产 返回休息点的任务 " ) ;
returnjo . put ( " desc " , " 有正在执行的任务,不能生成 返回休息点的任务 " ) ;
return returnjo ;
}
String rest_pointcode = ( String ) taskServiceServiceImpl . queryPoint ( new HashMap < > ( ) ) . get ( " rest_pointcode " ) ;