|
|
|
|
@@ -148,6 +148,15 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|
|
|
|
locationMessage.setDeviceId(deviceId);
|
|
|
|
|
redisCache.setCacheObject(key, locationMessage);
|
|
|
|
|
|
|
|
|
|
// todo 推送实时位置和状态消息到外部
|
|
|
|
|
try {
|
|
|
|
|
GlobalMemory.customMqttDeviceMonitor.publish(mqttClientId,
|
|
|
|
|
String.format(MqttTopic.DEVICE_LOCATION_MESSAGE_TOPIC, deviceId),
|
|
|
|
|
JsonUtils.toJsonString(locationRelTimeDTO));
|
|
|
|
|
} catch (MqttException e) {
|
|
|
|
|
log.error("位置实时数据推送失败: deviceId={}, error={}", deviceId, e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("位置消息解析失败: deviceId={}, payload={}, error={}", deviceId, payload, e);
|
|
|
|
|
@@ -227,7 +236,6 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|
|
|
|
DeviceMapPushDTO dto = new DeviceMapPushDTO();
|
|
|
|
|
dto.setA(Double.parseDouble(altitude.getValue()));
|
|
|
|
|
dto.setId(deviceId);
|
|
|
|
|
// dto.setB();
|
|
|
|
|
// dto.setHa();
|
|
|
|
|
dto.setF(fix_status.getValue());
|
|
|
|
|
dto.setS(status.getValue());
|
|
|
|
|
@@ -235,6 +243,12 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|
|
|
|
dto.setLng(Double.parseDouble(lng.getValue()));
|
|
|
|
|
dto.setT(nettyDevice.getCurrentTaskId());
|
|
|
|
|
dto.setY(Double.parseDouble(yaw.getValue()));
|
|
|
|
|
siteMemory.getVehicleMessage(deviceId);
|
|
|
|
|
VehicleMessage vehicleMessage = siteMemory.getVehicleMessage(deviceId);
|
|
|
|
|
if (vehicleMessage != null) {
|
|
|
|
|
dto.setCm(vehicleMessage.getControl_mode());
|
|
|
|
|
dto.setB(vehicleMessage.getBattery_percentage());
|
|
|
|
|
}
|
|
|
|
|
siteMemory.saveMapPushDTO(deviceId, dto);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -248,17 +262,82 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|
|
|
|
WebStatusMessageDTO webStatusMessageDTO = new WebStatusMessageDTO();
|
|
|
|
|
List<DeviceStatusDetail> transferData = new ArrayList<>();
|
|
|
|
|
DeviceStatusDetail voltage = new DeviceStatusDetail();
|
|
|
|
|
voltage.setName("voltage");
|
|
|
|
|
voltage.setValue(String.valueOf(vehicleRelTimeDTO.getData().getBattery_voltage()));
|
|
|
|
|
voltage.setName("battery_percentage");
|
|
|
|
|
voltage.setValue(String.valueOf(vehicleRelTimeDTO.getData().getBattery_percentage()));
|
|
|
|
|
voltage.setUnit("");
|
|
|
|
|
|
|
|
|
|
transferData.add(voltage);
|
|
|
|
|
|
|
|
|
|
DeviceStatusDetail speed = new DeviceStatusDetail();
|
|
|
|
|
speed.setName("speed");
|
|
|
|
|
speed.setValue(String.valueOf(vehicleRelTimeDTO.getData().getSpeed()));
|
|
|
|
|
speed.setUnit("");
|
|
|
|
|
transferData.add(speed);
|
|
|
|
|
DeviceStatusDetail battery_voltage = new DeviceStatusDetail();
|
|
|
|
|
battery_voltage.setName("battery_voltage");
|
|
|
|
|
battery_voltage.setValue(String.valueOf(vehicleRelTimeDTO.getData().getBattery_voltage()));
|
|
|
|
|
battery_voltage.setUnit("");
|
|
|
|
|
transferData.add(battery_voltage);
|
|
|
|
|
|
|
|
|
|
DeviceStatusDetail left_motor_current = new DeviceStatusDetail();
|
|
|
|
|
left_motor_current.setName("left_motor_current");
|
|
|
|
|
left_motor_current.setValue(String.valueOf(vehicleRelTimeDTO.getData().getLeft_motor_current()));
|
|
|
|
|
left_motor_current.setUnit("");
|
|
|
|
|
transferData.add(left_motor_current);
|
|
|
|
|
|
|
|
|
|
DeviceStatusDetail right_motor_current = new DeviceStatusDetail();
|
|
|
|
|
right_motor_current.setName("right_motor_current");
|
|
|
|
|
right_motor_current.setValue(String.valueOf(vehicleRelTimeDTO.getData().getRight_motor_current()));
|
|
|
|
|
right_motor_current.setUnit("");
|
|
|
|
|
transferData.add(right_motor_current);
|
|
|
|
|
|
|
|
|
|
DeviceStatusDetail left_motor_temperature = new DeviceStatusDetail();
|
|
|
|
|
left_motor_temperature.setName("left_motor_temperature");
|
|
|
|
|
left_motor_temperature.setValue(String.valueOf(vehicleRelTimeDTO.getData().getLeft_motor_temperature()));
|
|
|
|
|
left_motor_temperature.setUnit("");
|
|
|
|
|
transferData.add(left_motor_temperature);
|
|
|
|
|
|
|
|
|
|
DeviceStatusDetail right_motor_temperature = new DeviceStatusDetail();
|
|
|
|
|
right_motor_temperature.setName("right_motor_temperature");
|
|
|
|
|
right_motor_temperature.setValue(String.valueOf(vehicleRelTimeDTO.getData().getRight_motor_temperature()));
|
|
|
|
|
right_motor_temperature.setUnit("");
|
|
|
|
|
transferData.add(right_motor_temperature);
|
|
|
|
|
|
|
|
|
|
DeviceStatusDetail main_temperature = new DeviceStatusDetail();
|
|
|
|
|
main_temperature.setName("main_temperature");
|
|
|
|
|
main_temperature.setValue(String.valueOf(vehicleRelTimeDTO.getData().getMain_temperature()));
|
|
|
|
|
main_temperature.setUnit("");
|
|
|
|
|
transferData.add(main_temperature);
|
|
|
|
|
|
|
|
|
|
DeviceStatusDetail yaw = new DeviceStatusDetail();
|
|
|
|
|
yaw.setName("yaw");
|
|
|
|
|
yaw.setValue(String.valueOf(vehicleRelTimeDTO.getData().getYaw()));
|
|
|
|
|
yaw.setUnit("");
|
|
|
|
|
transferData.add(yaw);
|
|
|
|
|
|
|
|
|
|
DeviceStatusDetail pitch = new DeviceStatusDetail();
|
|
|
|
|
pitch.setName("pitch");
|
|
|
|
|
pitch.setValue(String.valueOf(vehicleRelTimeDTO.getData().getPitch()));
|
|
|
|
|
pitch.setUnit("");
|
|
|
|
|
transferData.add(pitch);
|
|
|
|
|
|
|
|
|
|
DeviceStatusDetail heading_status = new DeviceStatusDetail();
|
|
|
|
|
heading_status.setName("heading_status");
|
|
|
|
|
heading_status.setValue(String.valueOf(vehicleRelTimeDTO.getData().getHeading_status()));
|
|
|
|
|
heading_status.setUnit("");
|
|
|
|
|
transferData.add(heading_status);
|
|
|
|
|
|
|
|
|
|
DeviceStatusDetail total_work_area = new DeviceStatusDetail();
|
|
|
|
|
total_work_area.setName("total_work_area");
|
|
|
|
|
total_work_area.setValue(String.valueOf(vehicleRelTimeDTO.getData().getTotal_work_area()));
|
|
|
|
|
total_work_area.setUnit("");
|
|
|
|
|
transferData.add(total_work_area);
|
|
|
|
|
|
|
|
|
|
DeviceStatusDetail total_work_duration = new DeviceStatusDetail();
|
|
|
|
|
total_work_duration.setName("total_work_duration");
|
|
|
|
|
total_work_duration.setValue(String.valueOf(vehicleRelTimeDTO.getData().getTotal_work_duration()));
|
|
|
|
|
total_work_duration.setUnit("");
|
|
|
|
|
transferData.add(total_work_duration);
|
|
|
|
|
|
|
|
|
|
DeviceStatusDetail total_work_distance = new DeviceStatusDetail();
|
|
|
|
|
total_work_distance.setName("total_work_distance");
|
|
|
|
|
total_work_distance.setValue(String.valueOf(vehicleRelTimeDTO.getData().getTotal_work_distance()));
|
|
|
|
|
total_work_distance.setUnit("");
|
|
|
|
|
transferData.add(total_work_distance);
|
|
|
|
|
|
|
|
|
|
DeviceStatusDetail motion = new DeviceStatusDetail();
|
|
|
|
|
motion.setName("motion");
|
|
|
|
|
@@ -266,11 +345,59 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|
|
|
|
motion.setUnit("");
|
|
|
|
|
transferData.add(motion);
|
|
|
|
|
|
|
|
|
|
DeviceStatusDetail percentage = new DeviceStatusDetail();
|
|
|
|
|
percentage.setName("percentage");
|
|
|
|
|
percentage.setValue(String.valueOf(vehicleRelTimeDTO.getData().getBattery_percentage()));
|
|
|
|
|
percentage.setUnit("");
|
|
|
|
|
transferData.add(percentage);
|
|
|
|
|
DeviceStatusDetail emergency_stop = new DeviceStatusDetail();
|
|
|
|
|
emergency_stop.setName("emergency_stop");
|
|
|
|
|
emergency_stop.setValue(String.valueOf(vehicleRelTimeDTO.getData().getEmergency_stop()));
|
|
|
|
|
emergency_stop.setUnit("");
|
|
|
|
|
transferData.add(emergency_stop);
|
|
|
|
|
|
|
|
|
|
DeviceStatusDetail left_target_rpm = new DeviceStatusDetail();
|
|
|
|
|
left_target_rpm.setName("left_target_rpm");
|
|
|
|
|
left_target_rpm.setValue(String.valueOf(vehicleRelTimeDTO.getData().getLeft_target_rpm()));
|
|
|
|
|
left_target_rpm.setUnit("");
|
|
|
|
|
transferData.add(left_target_rpm);
|
|
|
|
|
|
|
|
|
|
DeviceStatusDetail right_target_rpm = new DeviceStatusDetail();
|
|
|
|
|
right_target_rpm.setName("right_target_rpm");
|
|
|
|
|
right_target_rpm.setValue(String.valueOf(vehicleRelTimeDTO.getData().getRight_target_rpm()));
|
|
|
|
|
right_target_rpm.setUnit("");
|
|
|
|
|
transferData.add(right_target_rpm);
|
|
|
|
|
|
|
|
|
|
DeviceStatusDetail left_measured_rpm = new DeviceStatusDetail();
|
|
|
|
|
left_measured_rpm.setName("left_measured_rpm");
|
|
|
|
|
left_measured_rpm.setValue(String.valueOf(vehicleRelTimeDTO.getData().getLeft_measured_rpm()));
|
|
|
|
|
left_measured_rpm.setUnit("");
|
|
|
|
|
transferData.add(left_measured_rpm);
|
|
|
|
|
|
|
|
|
|
DeviceStatusDetail right_measured_rpm = new DeviceStatusDetail();
|
|
|
|
|
right_measured_rpm.setName("right_measured_rpm");
|
|
|
|
|
right_measured_rpm.setValue(String.valueOf(vehicleRelTimeDTO.getData().getRight_measured_rpm()));
|
|
|
|
|
right_measured_rpm.setUnit("");
|
|
|
|
|
transferData.add(right_measured_rpm);
|
|
|
|
|
|
|
|
|
|
DeviceStatusDetail left_motor_rpm = new DeviceStatusDetail();
|
|
|
|
|
left_motor_rpm.setName("left_motor_rpm");
|
|
|
|
|
left_motor_rpm.setValue(String.valueOf(vehicleRelTimeDTO.getData().getLeft_motor_rpm()));
|
|
|
|
|
left_motor_rpm.setUnit("");
|
|
|
|
|
transferData.add(left_motor_rpm);
|
|
|
|
|
|
|
|
|
|
DeviceStatusDetail right_motor_rpm = new DeviceStatusDetail();
|
|
|
|
|
right_motor_rpm.setName("right_motor_rpm");
|
|
|
|
|
right_motor_rpm.setValue(String.valueOf(vehicleRelTimeDTO.getData().getRight_motor_rpm()));
|
|
|
|
|
right_motor_rpm.setUnit("");
|
|
|
|
|
transferData.add(right_motor_rpm);
|
|
|
|
|
|
|
|
|
|
DeviceStatusDetail roll = new DeviceStatusDetail();
|
|
|
|
|
roll.setName("roll");
|
|
|
|
|
roll.setValue(String.valueOf(vehicleRelTimeDTO.getData().getRoll()));
|
|
|
|
|
roll.setUnit("");
|
|
|
|
|
transferData.add(roll);
|
|
|
|
|
|
|
|
|
|
DeviceStatusDetail control_mode = new DeviceStatusDetail();
|
|
|
|
|
control_mode.setName("control_mode");
|
|
|
|
|
control_mode.setValue(String.valueOf(vehicleRelTimeDTO.getData().getControl_mode()));
|
|
|
|
|
control_mode.setUnit("");
|
|
|
|
|
transferData.add(control_mode);
|
|
|
|
|
|
|
|
|
|
webStatusMessageDTO.setData(transferData);
|
|
|
|
|
webStatusMessageDTO.setType(MesType.deviceInfo);
|
|
|
|
|
@@ -287,7 +414,7 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|
|
|
|
if (vehicleRelTimeDTO != null) {
|
|
|
|
|
|
|
|
|
|
// todo 更新里程数 里程数 * 割幅0.8
|
|
|
|
|
vehicleRelTimeDTO.getData().getDistance();
|
|
|
|
|
vehicleRelTimeDTO.getData().getTotal_work_distance();
|
|
|
|
|
NettyDevice nettyDevice = deviceSessionManager.getDevice(deviceId);
|
|
|
|
|
if (nettyDevice != null) {
|
|
|
|
|
Long orgId = nettyDevice.getDevice().getOrgId();
|
|
|
|
|
@@ -299,9 +426,11 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|
|
|
|
deviceRunStatistics = new DeviceRunStatistics();
|
|
|
|
|
}
|
|
|
|
|
deviceRunStatistics.setDeviceId(deviceId);
|
|
|
|
|
deviceRunStatistics.setDistance(vehicleRelTimeDTO.getData().getDistance());
|
|
|
|
|
deviceRunStatistics.setWorkArea(vehicleRelTimeDTO.getData().getDistance() * 0.8);
|
|
|
|
|
deviceRunStatistics.setDistance(vehicleRelTimeDTO.getData().getTotal_work_distance());
|
|
|
|
|
deviceRunStatistics.setWorkArea(vehicleRelTimeDTO.getData().getTotal_work_distance() * 0.8);
|
|
|
|
|
siteMemory.saveRunStatistics(deviceRunStatistics);
|
|
|
|
|
|
|
|
|
|
siteMemory.saveVehicleMessage(deviceId, vehicleRelTimeDTO.getData());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -318,6 +447,14 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// todo 推送实时位置和状态消息到外部
|
|
|
|
|
try {
|
|
|
|
|
GlobalMemory.customMqttDeviceMonitor.publish(mqttClientId,
|
|
|
|
|
String.format(MqttTopic.DEVICE_VEHICLE_MESSAGE_TOPIC, deviceId),
|
|
|
|
|
JsonUtils.toJsonString(vehicleRelTimeDTO));
|
|
|
|
|
} catch (MqttException e) {
|
|
|
|
|
log.error("位置实时数据推送失败: deviceId={}, error={}", deviceId, e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("实时消息解析失败: deviceId={}, payload={}, error={}", deviceId, payload, e.getMessage());
|
|
|
|
|
@@ -371,7 +508,7 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|
|
|
|
try {
|
|
|
|
|
websocketMesDispather.dispather(x.getConnectorId(), JsonUtils.toJsonString(sendDto));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("实时数据websocket推送失败: connectorId={}, error={}", x.getConnectorId(),
|
|
|
|
|
log.error("实时数据websocket任务状态推送失败: connectorId={}, error={}", x.getConnectorId(),
|
|
|
|
|
e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -382,8 +519,7 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|
|
|
|
String.format(MqttTopic.DEVICE_TASK_STATUS_TOPIC, taskId),
|
|
|
|
|
JsonUtils.toJsonString(sendDto));
|
|
|
|
|
} catch (MqttException e) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
log.error("实时数据websocket任务状态推送失败: deviceId={}, error={}", deviceId, e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@@ -451,7 +587,7 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|
|
|
|
websocketMesDispather.dispather(x.getConnectorId(), JsonUtils.toJsonString(sendDto));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("实时数据websocket推送失败: connectorId={}, error={}", x.getConnectorId(),
|
|
|
|
|
e.getMessage());
|
|
|
|
|
e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -461,8 +597,7 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|
|
|
|
String.format(MqttTopic.DEVICE_TASK_STATUS_TOPIC, device.getTask().getId()),
|
|
|
|
|
JsonUtils.toJsonString(sendDto));
|
|
|
|
|
} catch (MqttException e) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
log.error("实时数据websocket推送失败: deviceId={}, error={}", deviceId, e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|