#一键寻车接口预留

This commit is contained in:
2026-10-14 09:08:33 +08:00
parent 11e209bcb3
commit 11984316d4
5 changed files with 44 additions and 15 deletions

View File

@@ -136,7 +136,6 @@ public class NettyDevice extends Connector {
return finishId; return finishId;
} }
public synchronized boolean cancelingTask() throws MqttException { public synchronized boolean cancelingTask() throws MqttException {
if (task != null) { if (task != null) {
WorkRecord workRecord = workRecordMapper.selectById(task.getRouteId()); WorkRecord workRecord = workRecordMapper.selectById(task.getRouteId());
@@ -294,7 +293,6 @@ public class NettyDevice extends Connector {
} }
} }
public void startTask() { public void startTask() {
try { try {
if (executingTask) if (executingTask)
@@ -414,8 +412,19 @@ public class NettyDevice extends Connector {
GlobalMemory.customMqttDeviceMonitor.publish( GlobalMemory.customMqttDeviceMonitor.publish(
mqttClientId, mqttClientId,
String.format(MqttTopic.MOWER_OTA_UPGRADE_SET, deviceId), String.format(MqttTopic.MOWER_OTA_UPGRADE_SET, deviceId),
JsonUtils.toJsonString(payload) JsonUtils.toJsonString(payload));
); }
public void searchDevice(String deviceId) throws MqttException {
Map<String, Object> payload = new HashMap<>();
payload.put("action", "search_device");
payload.put("timestamp", System.currentTimeMillis());
payload.put("message_id", "search_device_" + System.currentTimeMillis());
GlobalMemory.customMqttDeviceMonitor.publish(
mqttClientId,
String.format(MqttTopic.MOWER_SEARCH_DEVICE_SET, deviceId),
JsonUtils.toJsonString(payload));
} }
} }

View File

@@ -73,6 +73,9 @@ public class MqttTopic {
/** OTA 升级结果上报(设备->平台) */ /** OTA 升级结果上报(设备->平台) */
public static final String MOWER_OTA_RESULT_POST = "mower/+/ota/result/post"; public static final String MOWER_OTA_RESULT_POST = "mower/+/ota/result/post";
/** 寻车指令(平台->设备) */
public static final String MOWER_SEARCH_DEVICE_SET = "mower/%s/action/search/set";
// ==================== 设备信息 ==================== // ==================== 设备信息 ====================
// /** 查询设备信息(平台->设备) */ // /** 查询设备信息(平台->设备) */
// public static final String MOWER_INFO_DEVICE_GET = // public static final String MOWER_INFO_DEVICE_GET =

View File

@@ -44,5 +44,4 @@ public class NettyDeviceController extends BaseController {
nettyDeviceService.sendCommand(command); nettyDeviceService.sendCommand(command);
return AjaxResult.success(); return AjaxResult.success();
} }
} }

View File

@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
@@ -18,11 +19,13 @@ import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import com.maibu.core.business.DeviceRunParam;
import com.maibu.core.business.device.NettyDevice; import com.maibu.core.business.device.NettyDevice;
import com.maibu.core.business.dto.WebRouteStatusMessageDTO; import com.maibu.core.business.dto.WebRouteStatusMessageDTO;
import com.maibu.core.business.inter.WebsocketMesDispather; import com.maibu.core.business.inter.WebsocketMesDispather;
import com.maibu.core.business.path.LatAndLngEntity; import com.maibu.core.business.path.LatAndLngEntity;
import com.maibu.core.controller.BaseController; import com.maibu.core.controller.BaseController;
import com.maibu.core.domain.AjaxResult;
import com.maibu.core.domain.R; import com.maibu.core.domain.R;
import com.maibu.core.enums.MesType; import com.maibu.core.enums.MesType;
import com.maibu.memory.DeviceSessionManager; import com.maibu.memory.DeviceSessionManager;
@@ -245,4 +248,12 @@ public class HostComputerController extends BaseController {
String.format("%.6f", minLng), String.format("%.6f", maxLng)); String.format("%.6f", minLng), String.format("%.6f", maxLng));
} }
@GetMapping("/searchDevice")
public AjaxResult searchDevice(@RequestParam String deviceId) throws Exception {
hostComputerService.searchDevice(deviceId);
return success();
}
} }

View File

@@ -1,18 +1,25 @@
package com.maibu.service.impl; package com.maibu.service.impl;
import com.maibu.core.business.WorkRecord;
import com.maibu.memory.GlobalMemory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.maibu.core.business.device.NettyDevice;
import com.maibu.memory.DeviceSessionManager;
import lombok.extern.slf4j.Slf4j;
@Service @Service
@Slf4j @Slf4j
public class HostComputerService { public class HostComputerService {
@Autowired @Autowired
private WorkRecordService workRecordService; private DeviceSessionManager deviceSessionManager;
public void searchDevice(String deviceId) throws Exception {
NettyDevice device = deviceSessionManager.getDevice(deviceId);
if (device != null && device.getOnlineStatus() == 1) {
device.searchDevice(deviceId);
}
}
} }