opt:修改首页信息推送,头部状态推送为WebSocket。
This commit is contained in:
@@ -50,6 +50,7 @@ public enum EnMsgEnum {
|
|||||||
ModifyProfile("Cannot Modify Other User's Profile", "ModifyProfile"),
|
ModifyProfile("Cannot Modify Other User's Profile", "ModifyProfile"),
|
||||||
IncorrectPassword("Incorrect Password", "IncorrectPassword"),
|
IncorrectPassword("Incorrect Password", "IncorrectPassword"),
|
||||||
RoleCannotEmpty("Role Name Cannot Be Empty", "RoleCannotEmpty"),
|
RoleCannotEmpty("Role Name Cannot Be Empty", "RoleCannotEmpty"),
|
||||||
|
CannotCanceled("Only Tasks That Have Not Been Executed Can Be Canceled", "CannotCanceled"),
|
||||||
UserCannotEmpty("User Cannot Be Empty", "UserCannotEmpty"),
|
UserCannotEmpty("User Cannot Be Empty", "UserCannotEmpty"),
|
||||||
DeletedNoPermission("Deleted Or No Permission, Operation Failed", "DeletedNoPermission"),
|
DeletedNoPermission("Deleted Or No Permission, Operation Failed", "DeletedNoPermission"),
|
||||||
InfoNotExist("The Information Does Not Exist", "InfoNotExist"),
|
InfoNotExist("The Information Does Not Exist", "InfoNotExist"),
|
||||||
|
|||||||
@@ -14,26 +14,23 @@ import java.util.Optional;
|
|||||||
*/
|
*/
|
||||||
public enum VehicleOperateEnum{
|
public enum VehicleOperateEnum{
|
||||||
// 1-关机、2-显示屏控制、3-TCS控制、4-RC控制、5-Joy控制
|
// 1-关机、2-显示屏控制、3-TCS控制、4-RC控制、5-Joy控制
|
||||||
OFF("关机", "1"),
|
OFF(1,"关机", "1"),
|
||||||
SCREEN("显示屏控制", "2"),
|
SCREEN(2,"显示屏控制", "2"),
|
||||||
TCS("TCS控制", "3"),
|
TCS(3,"TCS控制", "3"),
|
||||||
SCHE("SCHE控制", "4"),
|
SCHE(4,"SCHE控制", "4"),
|
||||||
RC("RC控制", "5"),
|
RC(5,"RC控制", "5"),
|
||||||
JOY("Joy控制", "6"),
|
JOY(6,"Joy控制", "6"),
|
||||||
QUITNOW("退出", "7"),
|
QUITNOW(7,"退出", "7"),
|
||||||
REBORNINIT("软启动", "8"),
|
REBORNINIT(8,"软启动", "8"),
|
||||||
STARTCHECK("跳过起点", "9"),
|
STARTCHECK(9,"跳过起点", "9"),
|
||||||
REBOOT("重启", "10"),
|
REBOOT(10,"重启", "10"),
|
||||||
FULL("全屏", "11"),
|
FULL(11,"全屏", "11"),
|
||||||
SKIPPLATE("跳过检测", "12"),
|
SKIPPLATE(12,"跳过检测", "12"),
|
||||||
OTHER("其他", "13");
|
OTHER(13,"其他", "13");
|
||||||
private final String name;
|
|
||||||
private final String code;
|
|
||||||
|
|
||||||
VehicleOperateEnum(String name, String code) {
|
private int index;
|
||||||
this.name = name;
|
private String name;
|
||||||
this.code = code;
|
private String code;
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
@@ -43,6 +40,12 @@ public enum VehicleOperateEnum{
|
|||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VehicleOperateEnum(int index,String name, String code) {
|
||||||
|
this.index = index;
|
||||||
|
this.name = name;
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
public static VehicleOperateEnum getType(String type) {
|
public static VehicleOperateEnum getType(String type) {
|
||||||
Optional<VehicleOperateEnum> first = Arrays.stream(VehicleOperateEnum.values()).filter(a -> a.getCode().equals(type)).findFirst();
|
Optional<VehicleOperateEnum> first = Arrays.stream(VehicleOperateEnum.values()).filter(a -> a.getCode().equals(type)).findFirst();
|
||||||
return first.orElse(VehicleOperateEnum.OTHER);
|
return first.orElse(VehicleOperateEnum.OTHER);
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ public enum ZhMsgEnum {
|
|||||||
ModifyProfile("不能修改他人资料", "ModifyProfile"),
|
ModifyProfile("不能修改他人资料", "ModifyProfile"),
|
||||||
IncorrectPassword("密码错误", "IncorrectPassword"),
|
IncorrectPassword("密码错误", "IncorrectPassword"),
|
||||||
RoleCannotEmpty("角色名字不能为空", "RoleCannotEmpty"),
|
RoleCannotEmpty("角色名字不能为空", "RoleCannotEmpty"),
|
||||||
|
CannotCanceled("只能取消未执行的任务", "CannotCanceled"),
|
||||||
UserCannotEmpty("用户不能为空", "UserCannotEmpty"),
|
UserCannotEmpty("用户不能为空", "UserCannotEmpty"),
|
||||||
DeletedNoPermission("被删除或无权限,操作失败", "DeletedNoPermission"),
|
DeletedNoPermission("被删除或无权限,操作失败", "DeletedNoPermission"),
|
||||||
InfoNotExist("该信息不存在", "InfoNotExist"),
|
InfoNotExist("该信息不存在", "InfoNotExist"),
|
||||||
|
|||||||
@@ -2,12 +2,14 @@ package org.nl.agv.rest;
|
|||||||
|
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaIgnore;
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nl.agv.service.HomeService;
|
import org.nl.agv.service.HomeService;
|
||||||
import org.nl.common.anno.Log;
|
import org.nl.common.anno.Log;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.nl.agv.service.impl;
|
package org.nl.agv.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.StopWatch;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
@@ -22,6 +23,7 @@ import cn.hutool.core.util.IdUtil;
|
|||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
|
import com.mchange.lang.LongUtils;
|
||||||
import edu.wpi.rail.jrosbridge.services.ServiceResponse;
|
import edu.wpi.rail.jrosbridge.services.ServiceResponse;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
@@ -32,23 +34,28 @@ import org.nl.agv.enu.*;
|
|||||||
import org.nl.agv.service.HomeService;
|
import org.nl.agv.service.HomeService;
|
||||||
import org.nl.agv.unit.RosUtil;
|
import org.nl.agv.unit.RosUtil;
|
||||||
import org.nl.agv.unit.sendToAgvUtil;
|
import org.nl.agv.unit.sendToAgvUtil;
|
||||||
|
import org.nl.agv.websocket.SendHomeWebSocketServer;
|
||||||
import org.nl.common.utils.LangUtils;
|
import org.nl.common.utils.LangUtils;
|
||||||
import org.nl.common.utils.SecurityUtils;
|
import org.nl.common.utils.SecurityUtils;
|
||||||
import org.nl.modules.common.exception.BadRequestException;
|
import org.nl.modules.common.exception.BadRequestException;
|
||||||
import org.nl.modules.system.util.CodeUtil;
|
import org.nl.modules.system.util.CodeUtil;
|
||||||
import org.nl.modules.wql.core.bean.WQLObject;
|
import org.nl.modules.wql.core.bean.WQLObject;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.scheduling.TaskScheduler;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
|
||||||
import static org.nl.common.utils.LangUtils.getLanguage;
|
import static org.nl.common.utils.LangUtils.getLanguage;
|
||||||
@@ -61,19 +68,38 @@ import static org.nl.common.utils.LangUtils.getLanguage;
|
|||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class HomeServiceImpl implements HomeService {
|
public class HomeServiceImpl implements HomeService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private TaskScheduler scheduler;
|
||||||
@Resource
|
@Resource
|
||||||
@Qualifier("threadPool")
|
@Qualifier("threadPool")
|
||||||
private ThreadPoolExecutor pool;
|
private ThreadPoolExecutor pool;
|
||||||
|
|
||||||
|
@Value("${spring.profiles.active}")
|
||||||
|
private String isProd;
|
||||||
|
|
||||||
|
@Value("${timer.syncAgvInfo}")
|
||||||
|
private long syncAgvInfo;
|
||||||
|
|
||||||
|
@Value("${timer.sendHomeInfo}")
|
||||||
|
private long sendHomeInfo;
|
||||||
|
|
||||||
|
@Value("${timer.handleTask}")
|
||||||
|
private long handleTask;
|
||||||
|
|
||||||
|
@Value("${timer.deleteTask}")
|
||||||
|
private long deleteTask;
|
||||||
|
|
||||||
//定时器查询调试信息,放入json其他地方直接调用;
|
//定时器查询调试信息,放入json其他地方直接调用;
|
||||||
public static JSONObject debugInfoJson = new JSONObject();
|
public static JSONObject debugInfoJson = new JSONObject();
|
||||||
|
|
||||||
|
//特定场景调试信息,放入json其他地方直接调用;
|
||||||
public static JSONObject debugInfoJsonQuick = new JSONObject();
|
public static JSONObject debugInfoJsonQuick = new JSONObject();
|
||||||
|
|
||||||
public HomeServiceImpl(ThreadPoolExecutor pool) {
|
public HomeServiceImpl(ThreadPoolExecutor pool) {
|
||||||
this.pool = pool;
|
this.pool = pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Value("${spring.profiles.active}")
|
|
||||||
private String isProd;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 优化获取主页及状态栏信息
|
* 优化获取主页及状态栏信息
|
||||||
@@ -94,14 +120,14 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
// }
|
// }
|
||||||
// }, pool);
|
// }, pool);
|
||||||
//执行任务操作
|
//执行任务操作
|
||||||
CompletableFuture.runAsync(() -> {
|
// CompletableFuture.runAsync(() -> {
|
||||||
try {
|
// try {
|
||||||
handleTaskStatus();
|
// handleTaskStatus();
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
//记录异常日志
|
// //记录异常日志
|
||||||
log.error("queryHomePage-执行任务操作失败:{}", e.getMessage());
|
// log.error("queryHomePage-执行任务操作失败:{}", e.getMessage());
|
||||||
}
|
// }
|
||||||
}, pool);
|
// }, pool);
|
||||||
List<JSONObject> allTasks = WQLObject.getWQLObject("ST_TASK_INFO").query("is_delete= 0").getResultJSONArray(0).toJavaList(JSONObject.class);
|
List<JSONObject> allTasks = WQLObject.getWQLObject("ST_TASK_INFO").query("is_delete= 0").getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||||
// 执行中任务
|
// 执行中任务
|
||||||
Optional<JSONObject> taskingOptional = allTasks.stream().filter(task -> TaskStatusEnum.RUNNING.getCode().equals(task.getString("task_status")) && !TaskTypeEnum.REST.getCode().equals(task.getString("task_type"))).findFirst();
|
Optional<JSONObject> taskingOptional = allTasks.stream().filter(task -> TaskStatusEnum.RUNNING.getCode().equals(task.getString("task_status")) && !TaskTypeEnum.REST.getCode().equals(task.getString("task_type"))).findFirst();
|
||||||
@@ -266,7 +292,6 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> clickSave(Map<String, String> jsonObject) {
|
public Map<String, Object> clickSave(Map<String, String> jsonObject) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
WQLObject taskTable = WQLObject.getWQLObject("ST_TASK_INFO");
|
WQLObject taskTable = WQLObject.getWQLObject("ST_TASK_INFO");
|
||||||
String button_code = jsonObject.get("button_code");
|
String button_code = jsonObject.get("button_code");
|
||||||
@@ -407,6 +432,7 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 全局显示状态
|
* 全局显示状态
|
||||||
*/
|
*/
|
||||||
@@ -421,14 +447,15 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
String en_automatic_status_name = "";
|
String en_automatic_status_name = "";
|
||||||
String zh_automatic_status_name = "";
|
String zh_automatic_status_name = "";
|
||||||
String electric = "50";
|
String electric = "50";
|
||||||
CompletableFuture.runAsync(() -> {
|
// CompletableFuture.runAsync(() -> {
|
||||||
try {
|
// try {
|
||||||
handleTaskStatus();
|
// handleTaskStatus();
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
//记录异常日志
|
// //记录异常日志
|
||||||
}
|
// }
|
||||||
}, pool);
|
// }, pool);
|
||||||
|
//qeryDebuggerInfo();
|
||||||
electric = debugInfoJson.getString("PWR_Percent");
|
electric = debugInfoJson.getString("PWR_Percent");
|
||||||
//车辆运行还是待机是PathFollow_Enable 1为运行 0为待机
|
//车辆运行还是待机是PathFollow_Enable 1为运行 0为待机
|
||||||
if (StrUtil.equals(debugInfoJson.getString("PathFollow_Enable"), "1")) {
|
if (StrUtil.equals(debugInfoJson.getString("PathFollow_Enable"), "1")) {
|
||||||
@@ -474,7 +501,7 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
if ("prod".equals(isProd)) {
|
if ("prod".equals(isProd)) {
|
||||||
result = HttpUtil.get(urlInfo.get("javaUrl"));
|
result = HttpUtil.get(urlInfo.get("javaUrl"));
|
||||||
} else {
|
} else {
|
||||||
result = "{\"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\":11,\"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\":29,\"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\":1,\"Speedm_Tmp\":0.0,\"StartNode\":0,\"Sub_Warning_Code0\":0,\"Sys_Mode\":4,\"Task_Sch\":0,\"Task_State\":\"\",\"Update_Sch\":1,\"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}}}}";
|
result = "{\"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\":11,\"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\",\"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\":99,\"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\":1,\"Speedm_Tmp\":0.0,\"StartNode\":0,\"Sub_Warning_Code0\":0,\"Sys_Mode\":4,\"Task_Sch\":0,\"Task_State\":\"\",\"Update_Sch\":1,\"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"));
|
//String result = HttpUtil.get(urlInfo.get("javaUrl"));
|
||||||
JSONObject json = JSONObject.parseObject(result);
|
JSONObject json = JSONObject.parseObject(result);
|
||||||
@@ -545,7 +572,7 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
if ("prod".equals(isProd)) {
|
if ("prod".equals(isProd)) {
|
||||||
result = HttpUtil.get(urlInfo.get("javaUrl"));
|
result = HttpUtil.get(urlInfo.get("javaUrl"));
|
||||||
} else {
|
} else {
|
||||||
result = "{\"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\":11,\"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\":29,\"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\":1,\"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}}}}";
|
result = "{\"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\":11,\"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\",\"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\":99,\"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\":1,\"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"));
|
// String result = HttpUtil.get(urlInfo.get("javaUrl"));
|
||||||
JSONObject json = JSONObject.parseObject(result);
|
JSONObject json = JSONObject.parseObject(result);
|
||||||
@@ -555,65 +582,6 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void handleTaskStatus() {
|
|
||||||
JSONObject taskjo = WQLObject.getWQLObject("ST_TASK_INFO").query("is_delete='0'and task_status='01'").uniqueResult(0);
|
|
||||||
qeryDebuggerInfo();
|
|
||||||
//叉腿高度
|
|
||||||
String legHeight;
|
|
||||||
//小车停止,且已到达目标点位
|
|
||||||
if (ObjectUtil.isNotEmpty(taskjo) && StrUtil.equals("0", debugInfoJson.getString("PathFollow_Enable")) && debugInfoJson.getString("CurNodeID").equals(taskjo.getString("next_point_code"))) {
|
|
||||||
//普通任务
|
|
||||||
if (TaskTypeEnum.COMMON.getCode().equals(taskjo.getString("task_type"))) {
|
|
||||||
updateTaskStatus(taskjo, TaskStatusEnum.END);
|
|
||||||
} else if (TaskTypeEnum.TAKE.getCode().equals(taskjo.getString("task_type")) || TaskTypeEnum.PUT.getCode().equals(taskjo.getString("task_type"))) {
|
|
||||||
//取货
|
|
||||||
if (TaskTypeEnum.TAKE.getCode().equals(taskjo.getString("task_type"))) {
|
|
||||||
//已到达目标点
|
|
||||||
if (StringUtils.isBlank(taskjo.getString("step"))) {
|
|
||||||
//取货
|
|
||||||
ServiceResponse send = sendToAgvUtil.send("HMIStepOrRTPathFollow:0;2;0#");
|
|
||||||
JSONObject resjo = JSONObject.parseObject(send.toString());
|
|
||||||
String resultflag = resjo.getString("result");
|
|
||||||
if (StrUtil.equals("0", resultflag)) {
|
|
||||||
//叉腿已抬升
|
|
||||||
taskjo.put("step", "0");
|
|
||||||
updateTaskStatus(taskjo, null);
|
|
||||||
} else {
|
|
||||||
log.error("handleTaskStatus-叉抬升失败:{}",TaskSendBackStatusEnum.getName(resultflag));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
qeryDebuggerInfoQuick();
|
|
||||||
//叉腿高度
|
|
||||||
legHeight = debugInfoJsonQuick.getString("MissionCompleteAltitude_mm_RemoteOrHMI_FB") == null ? "0" : debugInfoJsonQuick.getString("MissionCompleteAltitude_mm_RemoteOrHMI_FB");
|
|
||||||
//叉腿抬高动作已下发,且高度为10或20且待机,发送返程任务
|
|
||||||
if (((Integer.parseInt(legHeight) == 20)) && StrUtil.equals("0", debugInfoJsonQuick.getString("PathFollow_Enable")) && "0".equals(taskjo.getString("step"))) {
|
|
||||||
createReturnTask(taskjo);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (StringUtils.isBlank(taskjo.getString("step"))) {
|
|
||||||
//放货
|
|
||||||
ServiceResponse send = sendToAgvUtil.send("HMIStepOrRTPathFollow:0;1;0#");
|
|
||||||
JSONObject resjo = JSONObject.parseObject(send.toString());
|
|
||||||
String resultflag = resjo.getString("result");
|
|
||||||
if (StrUtil.equals("0", resultflag)) {
|
|
||||||
//叉腿已下降
|
|
||||||
taskjo.put("step", "0");
|
|
||||||
updateTaskStatus(taskjo, null);
|
|
||||||
} else {
|
|
||||||
log.error("handleTaskStatus-叉腿下降失败:{}",TaskSendBackStatusEnum.getName(resultflag));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
qeryDebuggerInfoQuick();
|
|
||||||
legHeight = debugInfoJsonQuick.getString("MissionCompleteAltitude_mm_RemoteOrHMI_FB") == null ? "0" : debugInfoJsonQuick.getString("MissionCompleteAltitude_mm_RemoteOrHMI_FB");
|
|
||||||
//叉腿抬高动作已下发,且高度为10或20且待机,发送返程任务
|
|
||||||
if (((Integer.parseInt(legHeight) == 10)) && StrUtil.equals("0", debugInfoJsonQuick.getString("PathFollow_Enable")) && "0".equals(taskjo.getString("step"))) {
|
|
||||||
createReturnTask(taskjo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createReturnTask(JSONObject taskjo) {
|
private void createReturnTask(JSONObject taskjo) {
|
||||||
String a = "HMIStepOrRTPathFollow:0;" + taskjo.getString("next_point_code2") + ";1#";
|
String a = "HMIStepOrRTPathFollow:0;" + taskjo.getString("next_point_code2") + ";1#";
|
||||||
@@ -626,7 +594,7 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
taskjo.put("is_manualfinished", "1");
|
taskjo.put("is_manualfinished", "1");
|
||||||
updateTaskStatus(taskjo, TaskStatusEnum.END);
|
updateTaskStatus(taskjo, TaskStatusEnum.END);
|
||||||
} else {
|
} else {
|
||||||
log.error("handleTaskStatus-createReturnTask-返程指令执行失败:{}",TaskSendBackStatusEnum.getName(resultflag));
|
log.error("handleTaskStatus-createReturnTask-返程指令执行失败:{}", TaskSendBackStatusEnum.getName(resultflag));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -663,20 +631,134 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void scheduleTask() {
|
||||||
|
scheduler.scheduleAtFixedRate(this::sendHomeInfoTask, sendHomeInfo);
|
||||||
|
scheduler.scheduleAtFixedRate(this::queryAgvInfo, syncAgvInfo);
|
||||||
|
scheduler.scheduleAtFixedRate(this::handleTaskStatusTask, handleTask);
|
||||||
|
scheduler.scheduleAtFixedRate(this::autoDeleteTask, deleteTask);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理任务状态
|
* 首页及头部信息推送
|
||||||
*/
|
*/
|
||||||
@Async("taskExecutor")
|
@Async("taskExecutor")
|
||||||
@Scheduled(cron = "0/10 * * * * *")
|
public void sendHomeInfoTask() {
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void handleTaskStatuss() {
|
|
||||||
//StopWatch stopWatch = new StopWatch();
|
//StopWatch stopWatch = new StopWatch();
|
||||||
//stopWatch.start();
|
//stopWatch.start();
|
||||||
//handleTaskStatus();
|
CopyOnWriteArraySet<SendHomeWebSocketServer> webSocketSet =
|
||||||
|
SendHomeWebSocketServer.getWebSocketSet();
|
||||||
|
if (webSocketSet.size() > 0) {
|
||||||
|
webSocketSet.forEach(c -> {
|
||||||
|
Map<String, Object> homeInfoMap = new HashMap<>();
|
||||||
|
homeInfoMap.put("head", this.queryHead());
|
||||||
|
homeInfoMap.put("home", this.queryHomePage(null));
|
||||||
|
c.sendDataToClient(homeInfoMap);
|
||||||
|
});
|
||||||
|
}
|
||||||
//stopWatch.stop();
|
//stopWatch.stop();
|
||||||
//System.out.println("花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
|
//System.out.println("1task-首页及头部信息推送-sendHomeInfoTask-花费时间----------------------------------------------------------------****************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询小车状态
|
||||||
|
*/
|
||||||
|
@Async("taskExecutor")
|
||||||
|
public void queryAgvInfo() {
|
||||||
|
//StopWatch stopWatch = new StopWatch();
|
||||||
|
//stopWatch.start();
|
||||||
|
qeryDebuggerInfo();
|
||||||
|
//stopWatch.stop();
|
||||||
|
//System.out.println("2task-查询agv信息-queryAgvInfo-花费时间----------------------------------------------------------------****************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理自动取放货状态
|
||||||
|
*/
|
||||||
|
@Async("taskExecutor")
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void handleTaskStatusTask() {
|
||||||
|
//更新小车状态参数
|
||||||
|
//qeryDebuggerInfo();
|
||||||
|
//叉腿高度
|
||||||
|
String legHeight;
|
||||||
|
//StopWatch stopWatch = new StopWatch();
|
||||||
|
//stopWatch.start();
|
||||||
|
JSONObject taskjo = WQLObject.getWQLObject("ST_TASK_INFO").query("is_delete='0'and task_status='01'").uniqueResult(0);
|
||||||
|
//小车停止,且已到达目标点位
|
||||||
|
if (ObjectUtil.isNotEmpty(taskjo) && StrUtil.equals("0", debugInfoJson.getString("PathFollow_Enable")) && debugInfoJson.getString("CurNodeID").equals(taskjo.getString("next_point_code"))) {
|
||||||
|
//普通任务
|
||||||
|
if (TaskTypeEnum.COMMON.getCode().equals(taskjo.getString("task_type"))) {
|
||||||
|
updateTaskStatus(taskjo, TaskStatusEnum.END);
|
||||||
|
} else if (TaskTypeEnum.TAKE.getCode().equals(taskjo.getString("task_type")) || TaskTypeEnum.PUT.getCode().equals(taskjo.getString("task_type"))) {
|
||||||
|
//取货
|
||||||
|
if (TaskTypeEnum.TAKE.getCode().equals(taskjo.getString("task_type"))) {
|
||||||
|
//已到达目标点
|
||||||
|
if (StringUtils.isBlank(taskjo.getString("step"))) {
|
||||||
|
//取货
|
||||||
|
ServiceResponse send = sendToAgvUtil.send("HMIStepOrRTPathFollow:0;2;0#");
|
||||||
|
JSONObject resjo = JSONObject.parseObject(send.toString());
|
||||||
|
String resultflag = resjo.getString("result");
|
||||||
|
if (StrUtil.equals("0", resultflag)) {
|
||||||
|
//叉腿已抬升
|
||||||
|
taskjo.put("step", "0");
|
||||||
|
updateTaskStatus(taskjo, null);
|
||||||
|
} else {
|
||||||
|
log.error("handleTaskStatus-叉抬升失败:{}", TaskSendBackStatusEnum.getName(resultflag));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qeryDebuggerInfoQuick();
|
||||||
|
//叉腿高度
|
||||||
|
legHeight = debugInfoJsonQuick.getString("MissionCompleteAltitude_mm_RemoteOrHMI_FB") == null ? "0" : debugInfoJsonQuick.getString("MissionCompleteAltitude_mm_RemoteOrHMI_FB");
|
||||||
|
//叉腿抬高动作已下发,且高度为10或20且待机,发送返程任务
|
||||||
|
if (((Integer.parseInt(legHeight) == 20)) && StrUtil.equals("0", debugInfoJsonQuick.getString("PathFollow_Enable")) && "0".equals(taskjo.getString("step"))) {
|
||||||
|
createReturnTask(taskjo);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (StringUtils.isBlank(taskjo.getString("step"))) {
|
||||||
|
//放货
|
||||||
|
ServiceResponse send = sendToAgvUtil.send("HMIStepOrRTPathFollow:0;1;0#");
|
||||||
|
JSONObject resjo = JSONObject.parseObject(send.toString());
|
||||||
|
String resultflag = resjo.getString("result");
|
||||||
|
if (StrUtil.equals("0", resultflag)) {
|
||||||
|
//叉腿已下降
|
||||||
|
taskjo.put("step", "0");
|
||||||
|
updateTaskStatus(taskjo, null);
|
||||||
|
} else {
|
||||||
|
log.error("handleTaskStatus-叉腿下降失败:{}", TaskSendBackStatusEnum.getName(resultflag));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qeryDebuggerInfoQuick();
|
||||||
|
legHeight = debugInfoJsonQuick.getString("MissionCompleteAltitude_mm_RemoteOrHMI_FB") == null ? "0" : debugInfoJsonQuick.getString("MissionCompleteAltitude_mm_RemoteOrHMI_FB");
|
||||||
|
//叉腿抬高动作已下发,且高度为10或20且待机,发送返程任务
|
||||||
|
if (((Integer.parseInt(legHeight) == 10)) && StrUtil.equals("0", debugInfoJsonQuick.getString("PathFollow_Enable")) && "0".equals(taskjo.getString("step"))) {
|
||||||
|
createReturnTask(taskjo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//stopWatch.stop();
|
||||||
|
//System.out.println("3task-处理任务状态-handleTaskStatusTask-花费时间----------------------------------------------------------------****************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时清空过期任务
|
||||||
|
*/
|
||||||
|
@Async("taskExecutor")
|
||||||
|
public void autoDeleteTask() {
|
||||||
|
//StopWatch stopWatch = new StopWatch();
|
||||||
|
//stopWatch.start();
|
||||||
|
WQLObject taskTable = WQLObject.getWQLObject("ST_TASK_INFO");
|
||||||
|
String sqlWhere = "TASK_CODE NOT IN ( SELECT TASK_CODE FROM ( SELECT TASK_CODE FROM ST_TASK_INFO WHERE TASK_STATUS = '02' ORDER BY CREATE_TIME LIMIT 300 ) AS RECENT_TASKS ) AND TASK_STATUS = '02'";
|
||||||
|
taskTable.delete(sqlWhere);
|
||||||
|
//stopWatch.stop();
|
||||||
|
//System.out.println("4task-删除任务-autoDeleteTask-花费时间----------------------------------------------------------------****************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// public Map<String, Object> queryHomePage1(Map<String, String> jsonObject) {
|
// public Map<String, Object> queryHomePage1(Map<String, String> jsonObject) {
|
||||||
// String button_code = "";
|
// String button_code = "";
|
||||||
// String button_name = "";
|
// String button_name = "";
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.nl.agv.service.impl;
|
package org.nl.agv.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.StopWatch;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
@@ -26,6 +27,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.nl.agv.enu.TaskStatusEnum;
|
||||||
import org.nl.agv.enu.TaskTypeEnum;
|
import org.nl.agv.enu.TaskTypeEnum;
|
||||||
import org.nl.agv.service.TaskService;
|
import org.nl.agv.service.TaskService;
|
||||||
import org.nl.agv.unit.sendToAgvUtil;
|
import org.nl.agv.unit.sendToAgvUtil;
|
||||||
@@ -35,10 +37,14 @@ import org.nl.modules.common.exception.BadRequestException;
|
|||||||
import org.nl.modules.system.util.CodeUtil;
|
import org.nl.modules.system.util.CodeUtil;
|
||||||
import org.nl.modules.wql.WQL;
|
import org.nl.modules.wql.WQL;
|
||||||
import org.nl.modules.wql.core.bean.WQLObject;
|
import org.nl.modules.wql.core.bean.WQLObject;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.nl.agv.service.impl.HomeServiceImpl.debugInfoJson;
|
import static org.nl.agv.service.impl.HomeServiceImpl.debugInfoJson;
|
||||||
import static org.nl.common.utils.LangUtils.getLanguage;
|
import static org.nl.common.utils.LangUtils.getLanguage;
|
||||||
@@ -252,6 +258,7 @@ public class TaskServiceServiceImpl implements TaskService {
|
|||||||
return returnjo;
|
return returnjo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> deleteTask(Map<String, String> jsonObject) {
|
public Map<String, Object> deleteTask(Map<String, String> jsonObject) {
|
||||||
String task_num = jsonObject.get("task_num");
|
String task_num = jsonObject.get("task_num");
|
||||||
@@ -273,16 +280,26 @@ public class TaskServiceServiceImpl implements TaskService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> updateTask(Map<String, String> jsonObject) {
|
public Map<String, Object> updateTask(Map<String, String> jsonObject) {
|
||||||
|
JSONObject returnjo = new JSONObject();
|
||||||
JSONArray jsonArray = JSONArray.parseArray(JSON.toJSONString(jsonObject.get("param")));
|
JSONArray jsonArray = JSONArray.parseArray(JSON.toJSONString(jsonObject.get("param")));
|
||||||
WQLObject taskTable = WQLObject.getWQLObject("ST_TASK_INFO");
|
WQLObject taskTable = WQLObject.getWQLObject("ST_TASK_INFO");
|
||||||
//更新之前删除之前的所有未完成任务
|
JSONArray taskrows = taskTable.query("is_delete='0' and task_status<>'02'").getResultJSONArray(0);
|
||||||
JSONArray taskrows = taskTable.query("task_status='00' or task_status='01'").getResultJSONArray(0);
|
Set<String> commonTaskCodes = jsonArray.stream()
|
||||||
for (int i = 0; i < taskrows.size(); i++) {
|
.map(item -> ((JSONObject) item).getString("task_code"))
|
||||||
JSONObject taskrow = taskrows.getJSONObject(i);
|
.collect(Collectors.toSet());
|
||||||
taskrow.put("is_delete", "1");
|
JSONArray selectedTasks = taskrows.stream()
|
||||||
taskTable.update(taskrow);
|
.filter(item -> commonTaskCodes.contains(((JSONObject) item).getString("task_code")))
|
||||||
|
.collect(Collectors.toCollection(JSONArray::new));
|
||||||
|
String taskCodesAsString = taskrows.stream()
|
||||||
|
.filter(item -> !commonTaskCodes.contains(((JSONObject) item).getString("task_code")))
|
||||||
|
.map(item -> "'" + ((JSONObject) item).getString("task_code") + "'")
|
||||||
|
.collect(Collectors.joining(", "));
|
||||||
|
// 物理删除
|
||||||
|
if (StringUtils.isNotBlank(taskCodesAsString)) {
|
||||||
|
String sqlWhere = "task_code in (" + taskCodesAsString + ")";
|
||||||
|
taskTable.delete(sqlWhere);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < jsonArray.size(); i++) {
|
for (int i = 0; i < selectedTasks.size(); i++) {
|
||||||
JSONObject taskjo = jsonArray.getJSONObject(i);
|
JSONObject taskjo = jsonArray.getJSONObject(i);
|
||||||
String taskNum = taskjo.getString("task_code");
|
String taskNum = taskjo.getString("task_code");
|
||||||
JSONObject taskrow = taskTable.query("task_code='" + taskNum + "'").uniqueResult(0);
|
JSONObject taskrow = taskTable.query("task_code='" + taskNum + "'").uniqueResult(0);
|
||||||
@@ -291,7 +308,6 @@ public class TaskServiceServiceImpl implements TaskService {
|
|||||||
taskrow.put("update_by", SecurityUtils.getCurrentNickName());
|
taskrow.put("update_by", SecurityUtils.getCurrentNickName());
|
||||||
taskTable.update(taskrow);
|
taskTable.update(taskrow);
|
||||||
}
|
}
|
||||||
JSONObject returnjo = new JSONObject();
|
|
||||||
returnjo.put("code", "1");
|
returnjo.put("code", "1");
|
||||||
returnjo.put("desc", LangUtils.getMsgLanguage("UpdateSuccess", null));
|
returnjo.put("desc", LangUtils.getMsgLanguage("UpdateSuccess", null));
|
||||||
return returnjo;
|
return returnjo;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
package org.nl.common.websocket;
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2019-2020 Zheng Jie
|
* Copyright 2019-2020 Zheng Jie
|
||||||
*
|
*
|
||||||
@@ -14,18 +13,27 @@ package org.nl.common.websocket;
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
package org.nl.agv.websocket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ZhangHouYing
|
* @author ZhangHouYing
|
||||||
* @date 2019-08-10 9:56
|
* @date 2019-08-10 9:56
|
||||||
*/
|
*/
|
||||||
public enum MsgType {
|
public enum MsgType {
|
||||||
/** 连接 */
|
/**
|
||||||
|
* 连接
|
||||||
|
*/
|
||||||
CONNECT,
|
CONNECT,
|
||||||
/** 关闭 */
|
/**
|
||||||
|
* 关闭
|
||||||
|
*/
|
||||||
CLOSE,
|
CLOSE,
|
||||||
/** 信息 */
|
/**
|
||||||
|
* 信息
|
||||||
|
*/
|
||||||
INFO,
|
INFO,
|
||||||
/** 错误 */
|
/**
|
||||||
|
* 错误
|
||||||
|
*/
|
||||||
ERROR
|
ERROR
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Zheng Jie
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.nl.agv.websocket;
|
||||||
|
|
||||||
|
import cn.hutool.core.map.MapUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.websocket.*;
|
||||||
|
import javax.websocket.server.PathParam;
|
||||||
|
import javax.websocket.server.ServerEndpoint;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @author ZZQ
|
||||||
|
* @Date 2024/1/8 17:03
|
||||||
|
*/
|
||||||
|
@ServerEndpoint("/webSocket/SendHomeInfo/{sid}")
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class SendHomeWebSocketServer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* concurrent包的线程安全Set,用来存放每个客户端对应的MyWebSocket对象。
|
||||||
|
*/
|
||||||
|
private static CopyOnWriteArraySet<SendHomeWebSocketServer> webSocketSet = new CopyOnWriteArraySet<>();
|
||||||
|
|
||||||
|
/**静态变量,用来记录当前在线连接数。应该把它设计成线程安全的。*/
|
||||||
|
private static int onlineCount = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/**与某个客户端的连接会话,需要通过它来给客户端发送数据*/
|
||||||
|
private Session session;
|
||||||
|
/**
|
||||||
|
* 与某个客户端的连接会话,需要通过它来给客户端发送数据
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* 接收sid
|
||||||
|
*/
|
||||||
|
private String sid = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连接建立成功调用的方法
|
||||||
|
*/
|
||||||
|
@OnOpen
|
||||||
|
public void onOpen(Session session, @PathParam("sid") String sid) {
|
||||||
|
this.session = session;
|
||||||
|
//如果存在就先删除一个,防止重复推送消息
|
||||||
|
webSocketSet.removeIf(webSocket -> webSocket.sid.equals(sid));
|
||||||
|
webSocketSet.add(this);
|
||||||
|
this.sid = sid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连接关闭调用的方法
|
||||||
|
*/
|
||||||
|
@OnClose
|
||||||
|
public void onClose() {
|
||||||
|
webSocketSet.remove(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收到客户端消息后调用的方法
|
||||||
|
*
|
||||||
|
* @param message 客户端发送过来的消息
|
||||||
|
*/
|
||||||
|
@OnMessage
|
||||||
|
public void onMessage(String message, Session session) {
|
||||||
|
System.out.println(webSocketSet.size() + "_接收到消息_" + session.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnError
|
||||||
|
public void onError(Session session, Throwable error) {
|
||||||
|
log.error("发生错误");
|
||||||
|
webSocketSet.remove(session);
|
||||||
|
error.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Session getSession() {
|
||||||
|
Integer d = 1;
|
||||||
|
return session;
|
||||||
|
}
|
||||||
|
// 发送消息,在定时任务中会调用此方法
|
||||||
|
public void sendMessage(String message) throws IOException {
|
||||||
|
this.session.getBasicRemote().sendText(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void sendDataToClient(Map<String, Object> data) {
|
||||||
|
try {
|
||||||
|
if (this.session != null&& MapUtil.isNotEmpty(data)) {
|
||||||
|
this.session.getBasicRemote().sendText(JSON.toJSONString(data));
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("发送消息给客户端失败", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static synchronized int getOnlineCount() {
|
||||||
|
return onlineCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CopyOnWriteArraySet<SendHomeWebSocketServer> getWebSocketSet() {
|
||||||
|
return webSocketSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setSession(Session session) {
|
||||||
|
this.session = session;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Zheng Jie
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.nl.agv.websocket;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ZhangHouYing
|
||||||
|
* @date 2019-08-10 9:55
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SocketMsg {
|
||||||
|
private Object msg;
|
||||||
|
private MsgType msgType;
|
||||||
|
|
||||||
|
public SocketMsg(Object msg, MsgType msgType) {
|
||||||
|
this.msg = msg;
|
||||||
|
this.msgType = msgType;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package org.nl.modules.mnt.websocket;
|
||||||
|
|
||||||
|
import cn.hutool.core.map.MapUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.nl.agv.service.HomeService;
|
||||||
|
import org.nl.agv.service.impl.HomeServiceImpl;
|
||||||
|
import org.nl.agv.websocket.SendHomeWebSocketServer;
|
||||||
|
import org.nl.config.SpringContextHolder;
|
||||||
|
import org.nl.system.service.param.impl.SysParamServiceImpl;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
|
import javax.websocket.*;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
@EnableScheduling
|
||||||
|
public class WebSocketDataSender {
|
||||||
|
//@Scheduled(fixedRate = 2000)
|
||||||
|
public void sendDatabaseDataToClients() {
|
||||||
|
HomeServiceImpl homeService = new HomeServiceImpl();
|
||||||
|
CopyOnWriteArraySet<SendHomeWebSocketServer> webSocketSet =
|
||||||
|
SendHomeWebSocketServer.getWebSocketSet();
|
||||||
|
Map<String, Object> data1 = homeService.queryHead();
|
||||||
|
if (webSocketSet.size() > 0) {
|
||||||
|
Map<String, Object> data = homeService.queryHead();
|
||||||
|
webSocketSet.forEach(c -> {
|
||||||
|
c.sendDataToClient(data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
System.out.println("_发送到消息_11");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,7 +13,8 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.nl.common.websocket;
|
package org.nl.agv.websocket;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -24,6 +25,7 @@ import javax.websocket.server.ServerEndpoint;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.CopyOnWriteArraySet;
|
import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ZhangHouYing
|
* @author ZhangHouYing
|
||||||
* @date 2019-08-10 15:46
|
* @date 2019-08-10 15:46
|
||||||
@@ -46,21 +48,22 @@ public class WebSocketServer {
|
|||||||
/**
|
/**
|
||||||
* 接收sid
|
* 接收sid
|
||||||
*/
|
*/
|
||||||
private String sid="";
|
private String sid = "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 连接建立成功调用的方法
|
* 连接建立成功调用的方法
|
||||||
* */
|
*/
|
||||||
@OnOpen
|
@OnOpen
|
||||||
public void onOpen(Session session,@PathParam("sid") String sid) {
|
public void onOpen(Session session, @PathParam("sid") String sid) {
|
||||||
this.session = session;
|
this.session = session;
|
||||||
//如果存在就先删除一个,防止重复推送消息
|
//如果存在就先删除一个,防止重复推送消息
|
||||||
for (WebSocketServer webSocket:webSocketSet) {
|
for (WebSocketServer webSocket : webSocketSet) {
|
||||||
if (webSocket.sid.equals(sid)) {
|
if (webSocket.sid.equals(sid)) {
|
||||||
webSocketSet.remove(webSocket);
|
webSocketSet.remove(webSocket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
webSocketSet.add(this);
|
webSocketSet.add(this);
|
||||||
this.sid=sid;
|
this.sid = sid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,16 +76,18 @@ public class WebSocketServer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 收到客户端消息后调用的方法
|
* 收到客户端消息后调用的方法
|
||||||
* @param message 客户端发送过来的消息*/
|
*
|
||||||
|
* @param message 客户端发送过来的消息
|
||||||
|
*/
|
||||||
@OnMessage
|
@OnMessage
|
||||||
public void onMessage(String message, Session session) {
|
public void onMessage(String message, Session session) {
|
||||||
log.info("收到来"+sid+"的信息:"+message);
|
// log.info("收到来"+sid+"的信息:"+message);
|
||||||
//群发消息
|
//群发消息
|
||||||
for (WebSocketServer item : webSocketSet) {
|
for (WebSocketServer item : webSocketSet) {
|
||||||
try {
|
try {
|
||||||
item.sendMessage(message);
|
item.sendMessage(message);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error(e.getMessage(),e);
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,6 +97,7 @@ public class WebSocketServer {
|
|||||||
log.error("发生错误");
|
log.error("发生错误");
|
||||||
error.printStackTrace();
|
error.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实现服务器主动推送
|
* 实现服务器主动推送
|
||||||
*/
|
*/
|
||||||
@@ -102,19 +108,20 @@ public class WebSocketServer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 群发自定义消息
|
* 群发自定义消息
|
||||||
* */
|
*/
|
||||||
public static void sendInfo(SocketMsg socketMsg,@PathParam("sid") String sid) throws IOException {
|
public static void sendInfo(SocketMsg socketMsg, @PathParam("sid") String sid) throws IOException {
|
||||||
String message = JSONObject.toJSONString(socketMsg);
|
String message = JSONObject.toJSONString(socketMsg);
|
||||||
log.info("推送消息到"+sid+",推送内容:"+message);
|
// log.info("推送消息到"+sid+",推送内容:"+message);
|
||||||
for (WebSocketServer item : webSocketSet) {
|
for (WebSocketServer item : webSocketSet) {
|
||||||
try {
|
try {
|
||||||
//这里可以设定只推送给这个sid的,为null则全部推送
|
//这里可以设定只推送给这个sid的,为null则全部推送
|
||||||
if(sid==null) {
|
if (sid == null) {
|
||||||
item.sendMessage(message);
|
item.sendMessage(message);
|
||||||
}else if(item.sid.equals(sid)){
|
} else if (item.sid.equals(sid)) {
|
||||||
item.sendMessage(message);
|
item.sendMessage(message);
|
||||||
}
|
}
|
||||||
} catch (IOException ignored) { }
|
} catch (IOException ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package org.nl.common.websocket;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ZhangHouYing
|
|
||||||
* @date 2019-08-10 9:55
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class SocketMsg {
|
|
||||||
private Object msg;
|
|
||||||
private MsgType msgType;
|
|
||||||
|
|
||||||
public SocketMsg(Object msg, MsgType msgType) {
|
|
||||||
this.msg = msg;
|
|
||||||
this.msgType = msgType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,9 +8,9 @@ import com.alibaba.fastjson.JSONArray;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nl.common.websocket.MsgType;
|
import org.nl.agv.websocket.MsgType;
|
||||||
import org.nl.common.websocket.SocketMsg;
|
import org.nl.agv.websocket.SocketMsg;
|
||||||
import org.nl.common.websocket.WebSocketServer;
|
import org.nl.agv.websocket.WebSocketServer;
|
||||||
import org.nl.modules.common.exception.BadRequestException;
|
import org.nl.modules.common.exception.BadRequestException;
|
||||||
import org.nl.modules.wql.WQL;
|
import org.nl.modules.wql.WQL;
|
||||||
import org.nl.modules.wql.core.bean.WQLObject;
|
import org.nl.modules.wql.core.bean.WQLObject;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class QueryInfoSchedule{
|
|||||||
* @date 2023/10/17
|
* @date 2023/10/17
|
||||||
*/
|
*/
|
||||||
//@Async("taskExecutor")
|
//@Async("taskExecutor")
|
||||||
//@Scheduled(cron = "0/10 * * * * *")
|
//@Scheduled(cron = "0/1 * * * * *")
|
||||||
public void queryAgvInfo() {
|
public void queryAgvInfo() {
|
||||||
StopWatch stopWatch = new StopWatch();
|
StopWatch stopWatch = new StopWatch();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|||||||
@@ -198,4 +198,4 @@ jetcache:
|
|||||||
uri:
|
uri:
|
||||||
- redis://127.0.0.1:6379
|
- redis://127.0.0.1:6379
|
||||||
es:
|
es:
|
||||||
index: mes_log
|
index: mes_log
|
||||||
@@ -97,3 +97,8 @@ mybatis-plus:
|
|||||||
db-config:
|
db-config:
|
||||||
id-type: INPUT
|
id-type: INPUT
|
||||||
banner: false
|
banner: false
|
||||||
|
timer:
|
||||||
|
syncAgvInfo: 1000
|
||||||
|
sendHomeInfo: 1000
|
||||||
|
handleTask: 1000
|
||||||
|
deleteTask: 86400000
|
||||||
Reference in New Issue
Block a user