rev:修改定时刷新AGV信息

This commit is contained in:
2023-10-17 10:55:50 +08:00
parent 10aed154b2
commit c6e803319c
5 changed files with 267 additions and 229 deletions

View File

@@ -29,6 +29,7 @@ import java.util.Map;
@SaIgnore
public class HomeController {
private final HomeService homeService;
@PostMapping("/queryHead")

View File

@@ -44,49 +44,39 @@ import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
public class ErrorServiceImpl implements ErrorService{
@Override
public Map<String,Object> querryError(Map<String,String> jsonObject) {
String error_status = "无故障";
try {
List<String> errorCodeList = new ArrayList<>();
JSONObject debugInfoJson = HomeServiceImpl.debugInfoJson;
int Warning_Code = debugInfoJson.getInteger("Warning_Code");
Warning_Code = 754529;
JSONArray result = new JSONArray();
for (int bitPosition = 0; bitPosition < 28; bitPosition++) {
if ((Warning_Code >> bitPosition) % 2 == 1) {
error_status = "有故障";
String error_code = "bit" + bitPosition;
errorCodeList.add(error_code);
String errorStatus = "无故障";
List<String> errorCodeList = new ArrayList<>();
JSONArray result = new JSONArray();
JSONObject debugInfoJson = HomeServiceImpl.debugInfoJson;
if(debugInfoJson.size()>0) {
int warningCode = debugInfoJson.getInteger("Warning_Code");
for(int bitPosition = 0; bitPosition < 28; bitPosition++) {
if((warningCode >> bitPosition) % 2 == 1) {
errorStatus = "有故障";
String errorCode = "bit" + bitPosition;
errorCodeList.add(errorCode);
}
}
WQLObject wo = WQLObject.getWQLObject("st_agv_error");
String errorCodes = errorCodeList.stream().collect(Collectors.joining("', '", "'", "'"));
result = wo.query("error_code in ("+errorCodes+") order by error_code").getResultJSONArray(0);
JSONObject returnjo = new JSONObject();
returnjo.put("code", "1");
returnjo.put("desc", "查询成功");
returnjo.put("result", result);
returnjo.put("error_status", error_status);
return returnjo;
}
catch(Exception e) {
Log.error("通信失败:" + e.getMessage());
throw new BadRequestException(e.getMessage() == null ? "通信失败请检查系统参数中的Ros连接信息" : e.getMessage());
result = wo.query("error_code in (" + errorCodes + ") order by error_code").getResultJSONArray(0);
}
JSONObject returnjo = new JSONObject();
returnjo.put("code", "1");
returnjo.put("desc", "查询成功");
returnjo.put("result", result);
returnjo.put("error_status", errorStatus);
return returnjo;
}
//@Override
public Map<String,Object> querryError1(Map<String,String> jsonObject) {
String error_status = "无故障";
try {
JSONObject debugInfoJson = HomeServiceImpl.debugInfoJson;
int Warning_Code = debugInfoJson.getInteger("Warning_Code");
//int Warning_Code = 524305;
int ObstacleTouchState = debugInfoJson.getInteger("ObstacleTouchState");
JSONArray ja = new JSONArray();
String error_code = "";

View File

@@ -37,10 +37,14 @@ import org.nl.agv.unit.sendToAgvUtil;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.wql.core.bean.WQLObject;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadPoolExecutor;
/**
* @author qinx
@@ -49,89 +53,90 @@ import java.util.Map;
@Service
@RequiredArgsConstructor
public class HomeServiceImpl implements HomeService{
@Resource
@Qualifier("threadPool")
private ThreadPoolExecutor pool;
//定时器查询调试信息放入json其他地方直接调用
public static JSONObject debugInfoJson = new JSONObject();
public HomeServiceImpl(ThreadPoolExecutor pool) {
this.pool = pool;
}
@Override
public void qeryDebuggerInfo() {
try {
Map<String,String> urlInfo = RosUtil.getRosHostInfo();
//String result1 = HttpUtil.get("http://localhost:8011/api/pcsIfPurchaseorder/queryApt");
//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}}}}";
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"));
debugInfoJson.put("Sys_Mode", jo.getString("Sys_Mode"));
debugInfoJson.put("screen", jo.getString("Remote_Or_HMI_Ctrl"));
debugInfoJson.put("tcs", jo.getString("CAD_Or_TCS_Ctrl"));
debugInfoJson.put("sche", jo.getString("Sche_JSON_Sche_Enable"));
debugInfoJson.put("rc", jo.getString("VehicleCtrlRealRCEnable"));
debugInfoJson.put("joy", jo.getString("VehicleCtrlRealJoyEnable"));
debugInfoJson.put("VehicleCtrlExpThrottle", jo.getString("VehicleCtrlExpThrottle"));
debugInfoJson.put("Warning_Code", jo.getString("Warning_Code"));
debugInfoJson.put("Car_Global_rx", jo.getString("Car_Global_rx"));
debugInfoJson.put("Car_Global_ry", jo.getString("Car_Global_ry"));
debugInfoJson.put("Car_Global_Theta", jo.getString("Car_Global_Theta"));
debugInfoJson.put("Lateral_Deviation_m", jo.getString("Lateral_Deviation_m"));
debugInfoJson.put("Vertical_Deviation_deg", jo.getString("Vertical_Deviation_deg"));
debugInfoJson.put("Out_Of_Path_Times", jo.getString("Out_Of_Path_Times"));
debugInfoJson.put("PLC_Warning_Code", jo.getString("PLC_Warning_Code"));
debugInfoJson.put("Min_Dist", jo.getString("Min_Dist"));
debugInfoJson.put("Auto_In_Line_State", jo.getString("Auto_In_Line_State"));
debugInfoJson.put("PathFollow_Enable", jo.getString("PathFollow_Enable"));
debugInfoJson.put("StartNode", jo.getString("StartNode"));
debugInfoJson.put("EndNode", jo.getString("EndNode"));
debugInfoJson.put("RealAutoChargeState", jo.getString("RealAutoChargeState"));
debugInfoJson.put("PWR_Percent", jo.getString("PWR_Percent"));
debugInfoJson.put("SVreal_angle", jo.getString("SVreal_angle"));
debugInfoJson.put("Speedm_Tmp", jo.getString("Speedm_Tmp"));
debugInfoJson.put("VehicleCtrlRealAltitude_mm", jo.getString("VehicleCtrlRealAltitude_mm"));
debugInfoJson.put("ReachState", jo.getString("ReachState"));
debugInfoJson.put("ObstacleDetectState", jo.getString("ObstacleDetectState"));
debugInfoJson.put("ObstacleTouchState", jo.getString("ObstacleTouchState"));
debugInfoJson.put("PWR_Warn", jo.getString("PWR_Warn"));
debugInfoJson.put("VehicleCtrl_CAN_Err_Info", jo.getString("VehicleCtrl_CAN_Err_Info"));
debugInfoJson.put("Curtis_Warning_Code_Speed", jo.getString("Curtis_Warning_Code_Speed"));
debugInfoJson.put("Curtis_Warning_Code_Steer", jo.getString("Curtis_Warning_Code_Steer"));
debugInfoJson.put("VehicleCtrlRealCustomStateByte0", jo.getString("VehicleCtrlRealCustomStateByte0"));
debugInfoJson.put("VehicleCtrlRealCustomStateByte1", jo.getString("VehicleCtrlRealCustomStateByte1"));
debugInfoJson.put("VehicleCtrlRealCustomStateByte2", jo.getString("VehicleCtrlRealCustomStateByte2"));
debugInfoJson.put("VehicleCtrlRealCustomStateByte3", jo.getString("VehicleCtrlRealCustomStateByte3"));
debugInfoJson.put("LastAltitudeExpectValue_mm", jo.getString("LastAltitudeExpectValue_mm"));
debugInfoJson.put("Get_Nav350_Curr_Layer", jo.getString("Get_Nav350_Curr_Layer"));
debugInfoJson.put("Update_Sch", jo.getString("Update_Sch"));
debugInfoJson.put("Update_State", jo.getString("Update_State"));
debugInfoJson.put("Task_Sch", jo.getString("Task_Sch"));
debugInfoJson.put("Task_State", jo.getString("Task_State"));
debugInfoJson.put("PFC_Sch", jo.getString("PFC_Sch"));
debugInfoJson.put("PFC_State", jo.getString("PFC_State"));
debugInfoJson.put("License_Info", jo.getString("License_Info"));
debugInfoJson.put("Env_CustomName", jo.getString("Env_CustomName"));
debugInfoJson.put("Env_VehicleType", jo.getString("Env_VehicleType"));
debugInfoJson.put("Env_SoftwareVersion", jo.getString("Env_SoftwareVersion"));
debugInfoJson.put("Remote_Or_HMI_Ctrl", jo.getString("Remote_Or_HMI_Ctrl"));
debugInfoJson.put("CAD_Or_TCS_Ctrl", jo.getString("CAD_Or_TCS_Ctrl"));
debugInfoJson.put("Sche_JSON_Sche_Enable", jo.getString("Sche_JSON_Sche_Enable"));
debugInfoJson.put("VehicleCtrlRealRCEnable", jo.getString("VehicleCtrlRealRCEnable"));
debugInfoJson.put("VehicleCtrlRealJoyEnable", jo.getString("VehicleCtrlRealJoyEnable"));
String PathFollow_Enable = jo.getString("PathFollow_Enable");
if(StrUtil.equals("0", PathFollow_Enable)) {
JSONObject taskjo = WQLObject.getWQLObject("ST_TASK_INFO").query("is_delete='0'and task_status='01'").uniqueResult(0);
if(ObjectUtil.isNotEmpty(taskjo)) {
taskjo.put("task_status", "02");
taskjo.put("task_status_name", "任务完成");
taskjo.put("update_time", DateUtil.now());
WQLObject.getWQLObject("ST_TASK_INFO").update(taskjo);
}
Map<String,String> urlInfo = RosUtil.getRosHostInfo();
//String result1 = HttpUtil.get("http://localhost:8011/api/pcsIfPurchaseorder/queryApt");
//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}}}}";
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"));
debugInfoJson.put("Sys_Mode", jo.getString("Sys_Mode"));
debugInfoJson.put("screen", jo.getString("Remote_Or_HMI_Ctrl"));
debugInfoJson.put("tcs", jo.getString("CAD_Or_TCS_Ctrl"));
debugInfoJson.put("sche", jo.getString("Sche_JSON_Sche_Enable"));
debugInfoJson.put("rc", jo.getString("VehicleCtrlRealRCEnable"));
debugInfoJson.put("joy", jo.getString("VehicleCtrlRealJoyEnable"));
debugInfoJson.put("VehicleCtrlExpThrottle", jo.getString("VehicleCtrlExpThrottle"));
debugInfoJson.put("Warning_Code", jo.getString("Warning_Code"));
debugInfoJson.put("Car_Global_rx", jo.getString("Car_Global_rx"));
debugInfoJson.put("Car_Global_ry", jo.getString("Car_Global_ry"));
debugInfoJson.put("Car_Global_Theta", jo.getString("Car_Global_Theta"));
debugInfoJson.put("Lateral_Deviation_m", jo.getString("Lateral_Deviation_m"));
debugInfoJson.put("Vertical_Deviation_deg", jo.getString("Vertical_Deviation_deg"));
debugInfoJson.put("Out_Of_Path_Times", jo.getString("Out_Of_Path_Times"));
debugInfoJson.put("PLC_Warning_Code", jo.getString("PLC_Warning_Code"));
debugInfoJson.put("Min_Dist", jo.getString("Min_Dist"));
debugInfoJson.put("Auto_In_Line_State", jo.getString("Auto_In_Line_State"));
debugInfoJson.put("PathFollow_Enable", jo.getString("PathFollow_Enable"));
debugInfoJson.put("StartNode", jo.getString("StartNode"));
debugInfoJson.put("EndNode", jo.getString("EndNode"));
debugInfoJson.put("RealAutoChargeState", jo.getString("RealAutoChargeState"));
debugInfoJson.put("PWR_Percent", jo.getString("PWR_Percent"));
debugInfoJson.put("SVreal_angle", jo.getString("SVreal_angle"));
debugInfoJson.put("Speedm_Tmp", jo.getString("Speedm_Tmp"));
debugInfoJson.put("VehicleCtrlRealAltitude_mm", jo.getString("VehicleCtrlRealAltitude_mm"));
debugInfoJson.put("ReachState", jo.getString("ReachState"));
debugInfoJson.put("ObstacleDetectState", jo.getString("ObstacleDetectState"));
debugInfoJson.put("ObstacleTouchState", jo.getString("ObstacleTouchState"));
debugInfoJson.put("PWR_Warn", jo.getString("PWR_Warn"));
debugInfoJson.put("VehicleCtrl_CAN_Err_Info", jo.getString("VehicleCtrl_CAN_Err_Info"));
debugInfoJson.put("Curtis_Warning_Code_Speed", jo.getString("Curtis_Warning_Code_Speed"));
debugInfoJson.put("Curtis_Warning_Code_Steer", jo.getString("Curtis_Warning_Code_Steer"));
debugInfoJson.put("VehicleCtrlRealCustomStateByte0", jo.getString("VehicleCtrlRealCustomStateByte0"));
debugInfoJson.put("VehicleCtrlRealCustomStateByte1", jo.getString("VehicleCtrlRealCustomStateByte1"));
debugInfoJson.put("VehicleCtrlRealCustomStateByte2", jo.getString("VehicleCtrlRealCustomStateByte2"));
debugInfoJson.put("VehicleCtrlRealCustomStateByte3", jo.getString("VehicleCtrlRealCustomStateByte3"));
debugInfoJson.put("LastAltitudeExpectValue_mm", jo.getString("LastAltitudeExpectValue_mm"));
debugInfoJson.put("Get_Nav350_Curr_Layer", jo.getString("Get_Nav350_Curr_Layer"));
debugInfoJson.put("Update_Sch", jo.getString("Update_Sch"));
debugInfoJson.put("Update_State", jo.getString("Update_State"));
debugInfoJson.put("Task_Sch", jo.getString("Task_Sch"));
debugInfoJson.put("Task_State", jo.getString("Task_State"));
debugInfoJson.put("PFC_Sch", jo.getString("PFC_Sch"));
debugInfoJson.put("PFC_State", jo.getString("PFC_State"));
debugInfoJson.put("License_Info", jo.getString("License_Info"));
debugInfoJson.put("Env_CustomName", jo.getString("Env_CustomName"));
debugInfoJson.put("Env_VehicleType", jo.getString("Env_VehicleType"));
debugInfoJson.put("Env_SoftwareVersion", jo.getString("Env_SoftwareVersion"));
debugInfoJson.put("Remote_Or_HMI_Ctrl", jo.getString("Remote_Or_HMI_Ctrl"));
debugInfoJson.put("CAD_Or_TCS_Ctrl", jo.getString("CAD_Or_TCS_Ctrl"));
debugInfoJson.put("Sche_JSON_Sche_Enable", jo.getString("Sche_JSON_Sche_Enable"));
debugInfoJson.put("VehicleCtrlRealRCEnable", jo.getString("VehicleCtrlRealRCEnable"));
debugInfoJson.put("VehicleCtrlRealJoyEnable", jo.getString("VehicleCtrlRealJoyEnable"));
String PathFollow_Enable = jo.getString("PathFollow_Enable");
if(StrUtil.equals("0", PathFollow_Enable)) {
JSONObject taskjo = WQLObject.getWQLObject("ST_TASK_INFO").query("is_delete='0'and task_status='01'").uniqueResult(0);
if(ObjectUtil.isNotEmpty(taskjo)) {
taskjo.put("task_status", "02");
taskjo.put("task_status_name", "任务完成");
taskjo.put("update_time", DateUtil.now());
WQLObject.getWQLObject("ST_TASK_INFO").update(taskjo);
}
debugInfoJson.put("PathFollow_Enable", PathFollow_Enable);
}
catch(Exception e) {
Log.error("通信失败:" + e.getMessage());
throw new BadRequestException("通信失败请检查系统参数中的java端口信息");
}
debugInfoJson.put("PathFollow_Enable", PathFollow_Enable);
}
public void QueryDebuggerInfo2() {
@@ -254,134 +259,130 @@ public class HomeServiceImpl implements HomeService{
String error_name = "正常运行";
JSONObject returnjo = new JSONObject();
JSONObject row = new JSONObject();
try {
JSONObject tasking = WQLObject.getWQLObject("ST_TASK_INFO").query("is_delete= 0 and task_status='01' and task_type='1'").uniqueResult(0);
// 1 无任务 2 有任务未执行 3 执行中
String task_status = "";
//1确认完成 2确认完成继续下个任务 3继续搬运4返回休息点
String date = DateUtil.today();
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);
if(tasked != null) {
task_status = "有任务未执行";
}
if(tasking != null) {
task_status = "执行中";
task_name = "任务号:" + tasking.getString("task_code") + "-" + "目标点:" + tasking.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";
button_name = "确认完成";
}
if(unManFinishTask != null && tasked != null) {
button_code = "2";
button_name = "确认完成继续下个任务";
}
//任务都完成了,但是还有未完成的任务
if(unManFinishTask == null && tasked != null) {
button_code = "3";
button_name = "继续搬运";
}
if(unManFinishTask == null && tasked == null) {
button_code = "4";
button_name = "返回休息点";
//假如所有的任务都完成,包括返回休息点的任务,且最后一个完成任务的时间是返回休息电的任务也不显示
JSONObject doingtaskjo = WQLObject.getWQLObject("ST_TASK_INFO").query("is_delete= 0 ", "update_time desc").uniqueResult(0);
if(doingtaskjo != null && doingtaskjo.getString("task_type").equals("2")) {
button_code = "";
button_name = "";
}
}
//假如有执行中的任务,则不显示
JSONObject doingtaskjo = WQLObject.getWQLObject("ST_TASK_INFO").query("is_delete= 0 and task_status='01' and is_manualfinished='0'").uniqueResult(0);
if(doingtaskjo != null) {
//查询调试信息
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);
// 1 无任务 2 有任务未执行 3 执行中
String task_status = "";
//1确认完成 2确认完成继续下个任务 3继续搬运4返回休息点
String date = DateUtil.today();
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);
if(tasked != null) {
task_status = "有任务未执行";
}
if(tasking != null) {
task_status = "执行中";
task_name = "任务号:" + tasking.getString("task_code") + "-" + "目标点:" + tasking.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";
button_name = "确认完成";
}
if(unManFinishTask != null && tasked != null) {
button_code = "2";
button_name = "确认完成继续下个任务";
}
//任务都完成了,但是还有未完成的任务
if(unManFinishTask == null && tasked != null) {
button_code = "3";
button_name = "继续搬运";
}
if(unManFinishTask == null && tasked == null) {
button_code = "4";
button_name = "返回休息点";
//假如所有的任务都完成,包括返回休息点的任务,且最后一个完成任务的时间是返回休息电的任务也不显示
JSONObject doingtaskjo = WQLObject.getWQLObject("ST_TASK_INFO").query("is_delete= 0 ", "update_time desc").uniqueResult(0);
if(doingtaskjo != null && doingtaskjo.getString("task_type").equals("2")) {
button_code = "";
button_name = "";
}
String task_num = "待执行0";
//分母 今天所有的任务,分子今天未完成的任务
JSONArray alltaskja = WQLObject.getWQLObject("ST_TASK_INFO").query("is_delete= 0 and task_type='1' and date ='" + date + "'").getResultJSONArray(0);
if(alltaskja.size() > 0) {
JSONArray todaytaskja = WQLObject.getWQLObject("ST_TASK_INFO").query("is_delete= 0 and task_type='1' and date ='" + date + "' and task_status='00'").getResultJSONArray(0);
String alltask_num = String.valueOf(alltaskja.size());
String todaytask_num = String.valueOf(todaytaskja.size());
task_num = "待执行" + todaytask_num + "/" + alltask_num;
}
if(debugInfoJson.size() > 0) {
//车辆运行还是待机是PathFollow_Enable 1为运行 0为待机
String agvrun_status = debugInfoJson.getString("PathFollow_Enable");
if(StrUtil.equals(agvrun_status, "1")) {
automatic_status_name = "运行";
}
if(StrUtil.equals(agvrun_status, "0")) {
automatic_status_name = "待机";
}
//手自动是Sys_Mode 3 REMA手动 4自动 5 IO手持方式的手动这个车不装
String automatic_status = debugInfoJson.getString("Sys_Mode");
if(StrUtil.equals(automatic_status, "3")) {
agvrun_status_name = "REMA手动";
}
if(StrUtil.equals(automatic_status, "4")) {
agvrun_status_name = "自动";
}
if(StrUtil.equals(automatic_status, "5")) {
agvrun_status_name = "IO手持方式的手动";
}
//速度
speed = debugInfoJson.getString("Speedm_Tmp") == null ? "0" : debugInfoJson.getString("Speedm_Tmp");
row.put("speed", speed + "m/s");
//agv状态枚举
row.put("agvrun_status", agvrun_status);
//agv状态名称1为运行 0为待机
row.put("agvrun_status_name", agvrun_status_name);
//agv操纵枚举
row.put("automatic_status", automatic_status);
//agv操纵名称3 REMA手动 4自动
row.put("automatic_status_name", automatic_status_name);
//假如电量低于30 ,则返回休息电
electric = debugInfoJson.getInteger("PWR_Percent");
//电量
row.put("electric", electric);
if(electric < 30) {
button_code = "4";
button_name = "返回休息点";
}
String Env_CustomName = debugInfoJson.getString("Env_CustomName");
String Env_VehicleType = debugInfoJson.getString("Env_VehicleType");
//设备名称
device_info = Env_CustomName + Env_VehicleType;
}
ErrorServiceImpl errorServiceImpl = new ErrorServiceImpl();
//todo 此处检查
Map error = errorServiceImpl.querryError(null);
JSONArray errorResult = JSONArray.parseArray(JSON.toJSONString(error.get("result")));
if(errorResult.size() > 0) {
error_name = errorResult.getJSONObject(0).getString("error_name");
}
//row.put("agv_error", (String) error.get("error_status"));
//故障信息
row.put("error_name", error_name);
//设备信息
row.put("device_info", device_info);
//任务状态
row.put("task_status", task_status);
//当前任务
row.put("task_name", task_name);
row.put("task_num", task_num);
row.put("button_code", button_code);
row.put("button_name", button_name);
returnjo.put("code", "1");
returnjo.put("desc", "操作成功");
returnjo.put("result", row);
return returnjo;
}
catch(Exception e) {
Log.error("通信失败:" + e.getMessage());
throw new BadRequestException(e.getMessage() == null ? "通信失败请检查系统参数中的Ros连接信息" : e.getMessage());
//假如有执行中的任务,则不显示
JSONObject doingtaskjo = WQLObject.getWQLObject("ST_TASK_INFO").query("is_delete= 0 and task_status='01' and is_manualfinished='0'").uniqueResult(0);
if(doingtaskjo != null) {
button_code = "";
button_name = "";
}
String task_num = "待执行0";
//分母 今天所有的任务,分子今天未完成的任务
JSONArray alltaskja = WQLObject.getWQLObject("ST_TASK_INFO").query("is_delete= 0 and task_type='1' and date ='" + date + "'").getResultJSONArray(0);
if(alltaskja.size() > 0) {
JSONArray todaytaskja = WQLObject.getWQLObject("ST_TASK_INFO").query("is_delete= 0 and task_type='1' and date ='" + date + "' and task_status='00'").getResultJSONArray(0);
String alltask_num = String.valueOf(alltaskja.size());
String todaytask_num = String.valueOf(todaytaskja.size());
task_num = "待执行" + todaytask_num + "/" + alltask_num;
}
if(debugInfoJson.size() > 0) {
//车辆运行还是待机是PathFollow_Enable 1为运行 0为待机
String agvrun_status = debugInfoJson.getString("PathFollow_Enable");
if(StrUtil.equals(agvrun_status, "1")) {
automatic_status_name = "运行";
}
if(StrUtil.equals(agvrun_status, "0")) {
automatic_status_name = "待机";
}
//手自动是Sys_Mode 3 REMA手动 4自动 5 IO手持方式的手动这个车不装
String automatic_status = debugInfoJson.getString("Sys_Mode");
if(StrUtil.equals(automatic_status, "3")) {
agvrun_status_name = "REMA手动";
}
if(StrUtil.equals(automatic_status, "4")) {
agvrun_status_name = "自动";
}
if(StrUtil.equals(automatic_status, "5")) {
agvrun_status_name = "IO手持方式的手动";
}
//速度
speed = debugInfoJson.getString("Speedm_Tmp") == null ? "0" : debugInfoJson.getString("Speedm_Tmp");
row.put("speed", speed + "m/s");
//agv状态枚举
row.put("agvrun_status", agvrun_status);
//agv状态名称1为运行 0为待机
row.put("agvrun_status_name", agvrun_status_name);
//agv操纵枚举
row.put("automatic_status", automatic_status);
//agv操纵名称3 REMA手动 4自动
row.put("automatic_status_name", automatic_status_name);
//假如电量低于30 ,则返回休息电
electric = debugInfoJson.getInteger("PWR_Percent");
//电量
row.put("electric", electric);
if(electric < 30) {
button_code = "4";
button_name = "返回休息点";
}
String Env_CustomName = debugInfoJson.getString("Env_CustomName");
String Env_VehicleType = debugInfoJson.getString("Env_VehicleType");
//设备名称
device_info = Env_CustomName + Env_VehicleType;
}
ErrorServiceImpl errorServiceImpl = new ErrorServiceImpl();
//todo 此处检查
Map error = errorServiceImpl.querryError(null);
JSONArray errorResult = JSONArray.parseArray(JSON.toJSONString(error.get("result")));
if(errorResult.size() > 0) {
error_name = errorResult.getJSONObject(0).getString("error_name");
}
//row.put("agv_error", (String) error.get("error_status"));
//故障信息
row.put("error_name", error_name);
//设备信息
row.put("device_info", device_info);
//任务状态
row.put("task_status", task_status);
//当前任务
row.put("task_name", task_name);
row.put("task_num", task_num);
row.put("button_code", button_code);
row.put("button_name", button_name);
returnjo.put("code", "1");
returnjo.put("desc", "操作成功");
returnjo.put("result", row);
return returnjo;
}
@Override

View File

@@ -26,11 +26,14 @@ import org.nl.agv.enu.VehicleOperateEnum;
import org.nl.agv.service.VehicleInfoService;
import org.nl.agv.unit.sendToAgvUtil;
import org.nl.modules.common.exception.BadRequestException;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ThreadPoolExecutor;
/**
* @author qinx
@@ -39,6 +42,8 @@ import java.util.Map;
@Service
@RequiredArgsConstructor
public class VehicleInfoServiceImpl implements VehicleInfoService{
@Override
public Map<String,Object> queryRestPoint(Map<String,String> jsonObject) {
ServiceResponse response = sendToAgvUtil.send("GetNodePointManagerTable");
@@ -260,9 +265,9 @@ public class VehicleInfoServiceImpl implements VehicleInfoService{
JSONObject row = new JSONObject();
try {
JSONObject debugInfoJson = HomeServiceImpl.debugInfoJson;
//int ObstacleTouchState = debugInfoJson.getInteger("ObstacleTouchState");
int ObstacleTouchState = debugInfoJson.getInteger("ObstacleTouchState");
//todo 安全触边等传感器状态 ObstacleTouchState 识别不了
int ObstacleTouchState = 524305;
// int ObstacleTouchState = 524305;
int ObstacleDetectState = debugInfoJson.getInteger("ObstacleDetectState");
int VehicleCtrlRealCustomStateByte0 = debugInfoJson.getInteger("VehicleCtrlRealCustomStateByte0");
//避障停车

View File

@@ -0,0 +1,41 @@
package org.nl.utils;
import cn.hutool.core.date.StopWatch;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import lombok.extern.slf4j.Slf4j;
import org.nl.agv.service.HomeService;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
/**
* @author gbx
* @date 2023/10/17
*/
@Component
@Slf4j
@EnableScheduling
public class QueryInfoSchedule{
@Resource
private HomeService homeService;
/**
* 定时更新agv状态信息
*
* @author gbx
* @date 2023/10/17
*/
//@Async("taskExecutor")
//@Scheduled(cron = "0/10 * * * * *")
public void queryAgvInfo() {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
homeService.qeryDebuggerInfo();
stopWatch.stop();
System.out.println("查询AGV花费时间---= totalTime = " + stopWatch.getTotalTimeMillis());
}
}