debug
This commit is contained in:
parent
eea4a678c0
commit
3f6797fa9f
|
@ -122,6 +122,12 @@ public interface DeviceIotService {
|
|||
*/
|
||||
void monitor(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 监控设备
|
||||
* @param mac 设备mac地址
|
||||
*/
|
||||
void monitor(String mac);
|
||||
|
||||
/**
|
||||
* 设置声音
|
||||
* @param device 设备
|
||||
|
@ -131,4 +137,5 @@ public interface DeviceIotService {
|
|||
* @return 结果
|
||||
*/
|
||||
DeviceIotVO setMusic(DeviceVO device, String music, String reason, boolean requiredIot);
|
||||
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import com.ruoyi.bst.device.domain.enums.DeviceUnLockType;
|
|||
import com.ruoyi.bst.device.domain.vo.DeviceIotVO;
|
||||
import com.ruoyi.bst.device.mapper.DeviceMapper;
|
||||
import com.ruoyi.bst.device.service.DeviceIotService;
|
||||
import com.ruoyi.bst.device.service.DeviceService;
|
||||
import com.ruoyi.bst.device.utils.DeviceUtil;
|
||||
import com.ruoyi.bst.orderDevice.domain.enums.OrderDeviceStatus;
|
||||
import com.ruoyi.common.constants.ServiceCode;
|
||||
|
@ -51,6 +52,9 @@ public class DeviceIotServiceImpl implements DeviceIotService {
|
|||
@Autowired
|
||||
private DeviceMapper deviceMapper;
|
||||
|
||||
@Autowired
|
||||
private DeviceService deviceService;
|
||||
|
||||
@Autowired
|
||||
private ScheduledExecutorService scheduledExecutorService;
|
||||
|
||||
|
@ -352,12 +356,19 @@ public class DeviceIotServiceImpl implements DeviceIotService {
|
|||
scheduledExecutorService.schedule(() -> {
|
||||
// 获取设备最新信息
|
||||
DeviceVO device = deviceMapper.selectDeviceById(deviceId);
|
||||
this.refresh(device, null);
|
||||
this.monitor(device);
|
||||
},0, TimeUnit.SECONDS);
|
||||
} catch (Exception e) {
|
||||
log.error("监控设备id={}出错:{}", deviceId, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void monitor(DeviceVO device) {
|
||||
if (device == null) {
|
||||
return;
|
||||
}
|
||||
// 刷新信息
|
||||
this.refresh(device, null);
|
||||
|
||||
// 判断电门与设备锁状态是否一致,不一致则发送命令
|
||||
if (DeviceLockStatus.OPEN.getCode().equals(device.getLockStatus()) && !DeviceQuality.OPEN.getCode().equals(device.getQuality())) {
|
||||
iotService.unlock(device, SUB_FAST, "【设备监控】电门异常未开启");
|
||||
|
@ -365,12 +376,13 @@ public class DeviceIotServiceImpl implements DeviceIotService {
|
|||
if (DeviceLockStatus.CLOSE.getCode().equals(device.getLockStatus()) && !DeviceQuality.CLOSE.getCode().equals(device.getQuality())) {
|
||||
iotService.lock(device, SUB_SLOW, "【设备监控】电门异常未关闭");
|
||||
}
|
||||
}
|
||||
|
||||
},0, TimeUnit.SECONDS);
|
||||
} catch (Exception e) {
|
||||
log.error("监控设备id={}出错:{}", deviceId, e.getMessage());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void monitor(String mac) {
|
||||
DeviceVO device = deviceService.selectByMac(mac);
|
||||
this.refresh(device, null);
|
||||
this.monitor(device);
|
||||
}
|
||||
|
||||
private void asyncMonitorCount(Long deviceId, int count) {
|
||||
|
|
|
@ -87,7 +87,7 @@ public class IotReceiveServiceImpl implements IotReceiveService {
|
|||
LocalDateTime at = DateUtils.toLocalDateTime(msg.getAt());
|
||||
|
||||
// 处理设备定位BUG,若出现BUG则重启设备
|
||||
int handle = this.handleDeviceReboot(device, sys, at);
|
||||
int handle = this.handleDeviceLocationBug(device, sys, at);
|
||||
if (handle == 1) {
|
||||
return;
|
||||
}
|
||||
|
@ -108,16 +108,28 @@ public class IotReceiveServiceImpl implements IotReceiveService {
|
|||
this.handleLocationLog(device);
|
||||
}
|
||||
}
|
||||
// 生命周期
|
||||
// 生命周期(暂时不做,需要测试)
|
||||
else if (ReceiveType.DEVICE_STATUS.getType().equals(msg.getType())) {
|
||||
// this.handleReboot(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理设备重启
|
||||
*/
|
||||
private void handleReboot(ReceiveMsg msg) {
|
||||
if (msg == null || StringUtils.isBlank(msg.getDevName())) {
|
||||
return;
|
||||
}
|
||||
// 同步一次设备状态
|
||||
deviceIotService.monitor(msg.getDevName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理设备定位BUG
|
||||
* @param device
|
||||
*/
|
||||
private int handleDeviceReboot(DeviceVO device, IotDeviceSysInfo sys, LocalDateTime at) {
|
||||
private int handleDeviceLocationBug(DeviceVO device, IotDeviceSysInfo sys, LocalDateTime at) {
|
||||
if (device == null || StringUtils.isBlank(device.getMac()) || device.getLastLocationTime() == null || at == null) {
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user