fix:设备保存状态为空修复

V0.5.x
xiwa 2024-03-05 19:58:35 +08:00
parent 3962caf969
commit 34e42df090
3 changed files with 3 additions and 10 deletions

View File

@ -142,9 +142,9 @@ public class DeviceInfoDataImpl implements IDeviceInfoData, IJPACommData<DeviceI
*/
private void parseStateToVo(DeviceInfo dto, TbDeviceInfo vo) {
DeviceInfo.State state = dto.getState();
vo.setState(state.isOnline() ? "online" : "offline");
vo.setOfflineTime(state.getOfflineTime());
vo.setOnlineTime(state.getOnlineTime());
vo.setState(state != null && state.isOnline() ? "online" : "offline");
vo.setOfflineTime(state != null ? state.getOfflineTime() : null);
vo.setOnlineTime(state != null ? state.getOnlineTime() : null);
DeviceInfo.Locate locate = dto.getLocate();
vo.setLongitude(locate.getLongitude());
vo.setLatitude(locate.getLatitude());

View File

@ -61,12 +61,6 @@ public class DeviceInfoBo extends BaseDto {
@ApiModelProperty(value = "纬度")
private String latitude;
@ApiModelProperty(value = "设备状态")
@Size(max = 255, message = "设备状态长度不正确")
@AutoMapping(ignore = true)
@ReverseAutoMapping(ignore = true)
private DeviceInfo.State state;
@ApiModelProperty(value = "用户id")
@Size(max = 255, message = "用户id长度不正确")
private String uid;

View File

@ -412,7 +412,6 @@ public class DeviceManagerServiceImpl implements IDeviceManagerService {
public boolean saveDevice(DeviceInfoBo data) {
DeviceInfo di = data.to(DeviceInfo.class);
di.setLocate(new DeviceInfo.Locate(data.getLongitude(), data.getLatitude()));
di.setState(data.getState());
if (StringUtils.isBlank(data.getSecret())) {
data.setSecret(RandomStringUtils.random(16));
}