This commit is contained in:
2026-08-19 11:02:52 +08:00
parent ffd9720939
commit 1b19e32aa5
30 changed files with 629 additions and 156 deletions

View File

@@ -11,6 +11,7 @@ import java.util.stream.Collectors;
import com.maibu.memory.DeviceSessionManager;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@@ -476,7 +477,7 @@ public class DeviceTaskService {
return task.getId();
}
public boolean cancelTask(DeviceTaskCommandDTO dto, String username) {
public boolean cancelTask(DeviceTaskCommandDTO dto) throws MqttException {
String deviceId = dto.getDeviceId();
DevicePlanTask devicePlanTask = null;
if (StringUtils.isEmpty(dto.getDeviceId())) {
@@ -488,7 +489,11 @@ public class DeviceTaskService {
}
NettyDevice device = deviceSessionManager.getDevice(deviceId);
if (device != null && device.getTask() != null) {
return device.cancelTask();
if(dto.isForceCancel()){
return device.canceledTask();
}else {
return device.cancelingTask();
}
} else {
if (devicePlanTask != null) {
devicePlanTask.setTaskStaus(DeviceTaskStaus.CANCELED);