#update
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user