feat: iot修改设备在线和离线
This commit is contained in:
+29
@@ -6,6 +6,8 @@ import com.alibaba.excel.support.ExcelTypeEnum;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.device.model.AgeDevice;
|
||||
import com.central.device.model.dto.DeviceStatusDTO;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.central.device.model.excel.AgeDeviceExcel;
|
||||
import com.central.device.model.vo.AgeDeviceLocationVO;
|
||||
import com.central.device.service.IAgeDeviceService;
|
||||
@@ -26,6 +28,7 @@ import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -323,4 +326,30 @@ public class AgeDeviceController {
|
||||
return Result.failed("更新失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设备状态(在线/离线)
|
||||
* deviceStatus: 0-在线,1-离线
|
||||
*/
|
||||
@Operation(summary = "修改设备状态")
|
||||
@PostMapping("/updateDeviceStatus")
|
||||
public Result updateDeviceStatus(@Validated @RequestBody DeviceStatusDTO dto) {
|
||||
try {
|
||||
log.info("修改设备状态,deviceSn: {}, deviceStatus: {}", dto.getDeviceSn(), dto.getDeviceStatus());
|
||||
|
||||
AgeDevice device = ageDeviceService.getByDeviceSn(dto.getDeviceSn());
|
||||
if (device == null) {
|
||||
return Result.failed("设备不存在");
|
||||
}
|
||||
|
||||
device.setBoundStatus(dto.getDeviceStatus());
|
||||
device.setBoundTime(new Date());
|
||||
boolean result = ageDeviceService.updateById(device);
|
||||
|
||||
return result ? Result.succeed("更新成功") : Result.failed("更新失败");
|
||||
} catch (Exception e) {
|
||||
log.error("修改设备状态失败", e);
|
||||
return Result.failed("更新失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class AgeDevice extends SuperEntity {
|
||||
private Date createTime;
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Date updateTime;
|
||||
private Long boundTime;
|
||||
private Date boundTime;
|
||||
private Integer boundStatus;
|
||||
private Long loginTime;
|
||||
private String deviceDesc;
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.central.device.model.dto;
|
||||
|
||||
import jakarta.validation.constraints.Max;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 修改设备状态DTO
|
||||
* deviceStatus: 0-在线,1-离线
|
||||
*/
|
||||
@Data
|
||||
public class DeviceStatusDTO {
|
||||
|
||||
/**
|
||||
* 设备SN
|
||||
*/
|
||||
@NotBlank(message = "设备SN不能为空")
|
||||
private String deviceSn;
|
||||
|
||||
/**
|
||||
* 设备状态(0-在线,1-离线)
|
||||
*/
|
||||
@NotNull(message = "设备状态不能为空")
|
||||
@Min(value = 0, message = "设备状态值无效,0-在线,1-离线")
|
||||
@Max(value = 1, message = "设备状态值无效,0-在线,1-离线")
|
||||
private Integer deviceStatus;
|
||||
}
|
||||
@@ -580,7 +580,7 @@ curl -X GET "http://test.gofly.com/api-device/device/alarm/msg-alarm/1581F8HHX25
|
||||
| wind_speed | Double | 风速(m/s) |
|
||||
| firmware_version | String | 固件版本 |
|
||||
| gear | Integer | 档位 |
|
||||
| mode_code | Integer | 飞行模式<br/> "0":"待机","1":"起飞准备","2":"起飞准备完毕","3":"手动飞行","4":"自动起飞","5":"航线飞行","6":"全景拍照","7":"智能跟随","8":"ADS-B 躲避","9":"自动返航","10":"自动降落","11":"强制降落","12":"三桨叶降落","13":"升级中","14":"未连接","15":"APAS","16":"虚拟摇杆状态","17":"指令飞行","18":"空中 RTK 收敛模式","19":"机场选址中","20":"POI环绕","21":"进离场航线飞行过程中"|
|
||||
| mode_code | Integer | 飞行模式 "0":"待机","1":"起飞准备","2":"起飞准备完毕","3":"手动飞行","4":"自动起飞","5":"航线飞行","6":"全景拍照","7":"智能跟随","8":"ADS-B 躲避","9":"自动返航","10":"自动降落","11":"强制降落","12":"三桨叶降落","13":"升级中","14":"未连接","15":"APAS","16":"虚拟摇杆状态","17":"指令飞行","18":"空中 RTK 收敛模式","19":"机场选址中","20":"POI环绕","21":"进离场航线飞行过程中" |
|
||||
|
||||
#### 无人机未开机响应
|
||||
|
||||
|
||||
Reference in New Issue
Block a user