|
@@ -9,12 +9,12 @@ import com.zhongshu.iot.server.core.dao.mqtt.DeviceInfoDao;
|
|
|
import com.zhongshu.iot.server.core.dao.mqtt.GateWay2DeviceDao;
|
|
import com.zhongshu.iot.server.core.dao.mqtt.GateWay2DeviceDao;
|
|
|
import com.zhongshu.iot.server.core.domain.iot.device.DeviceInfo;
|
|
import com.zhongshu.iot.server.core.domain.iot.device.DeviceInfo;
|
|
|
import com.zhongshu.iot.server.core.domain.iot.device.GateWay2Device;
|
|
import com.zhongshu.iot.server.core.domain.iot.device.GateWay2Device;
|
|
|
-import com.zhongshu.iot.server.core.event.DeviceOnLineTimeChangeEvent;
|
|
|
|
|
import com.zhongshu.iot.server.core.event.DeviceStateChangeEvent;
|
|
import com.zhongshu.iot.server.core.event.DeviceStateChangeEvent;
|
|
|
import com.zhongshu.iot.server.core.event.DeviceSyncEvent;
|
|
import com.zhongshu.iot.server.core.event.DeviceSyncEvent;
|
|
|
import com.zhongshu.iot.server.core.httpRequest.ApiRequestService;
|
|
import com.zhongshu.iot.server.core.httpRequest.ApiRequestService;
|
|
|
import com.zhongshu.iot.server.core.httpRequest.conf.FullCardAPIConfig;
|
|
import com.zhongshu.iot.server.core.httpRequest.conf.FullCardAPIConfig;
|
|
|
import com.zhongshu.iot.server.core.service.base.SuperService;
|
|
import com.zhongshu.iot.server.core.service.base.SuperService;
|
|
|
|
|
+import com.zhongshu.iot.server.core.util.CommonUtil;
|
|
|
import com.zhongshu.iot.server.core.util.bean.BeanUtils;
|
|
import com.zhongshu.iot.server.core.util.bean.BeanUtils;
|
|
|
import lombok.SneakyThrows;
|
|
import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -174,37 +174,11 @@ public class DeviceSyncFullCardService extends SuperService {
|
|
|
param.setOnLineState(deviceInfo.getOnLineState().name());
|
|
param.setOnLineState(deviceInfo.getOnLineState().name());
|
|
|
param.setProjectInfoCode(deviceInfo.getProjectInfoCode());
|
|
param.setProjectInfoCode(deviceInfo.getProjectInfoCode());
|
|
|
param.setLastOfflineTime(deviceInfo.getLastOfflineTime());
|
|
param.setLastOfflineTime(deviceInfo.getLastOfflineTime());
|
|
|
-
|
|
|
|
|
param.setState(deviceInfo.getState());
|
|
param.setState(deviceInfo.getState());
|
|
|
|
|
+ param.setRandomId(CommonUtil.UUID());
|
|
|
APIResponseModel api = apiRequestService.sendFullCardAPI(FullCardAPIConfig.syncDeviceOnLineState, param);
|
|
APIResponseModel api = apiRequestService.sendFullCardAPI(FullCardAPIConfig.syncDeviceOnLineState, param);
|
|
|
log.info("同步设备在线情况:{} {}", api.isSuccess(), api.getMsg());
|
|
log.info("同步设备在线情况:{} {}", api.isSuccess(), api.getMsg());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public ResultContent noticeSyncDeviceOnlineTimeChange(String deviceId) {
|
|
|
|
|
- if (ObjectUtils.isNotEmpty(deviceId)) {
|
|
|
|
|
- DeviceOnLineTimeChangeEvent event = new DeviceOnLineTimeChangeEvent(this, deviceId);
|
|
|
|
|
- applicationContext.publishEvent(event);
|
|
|
|
|
- }
|
|
|
|
|
- return ResultContent.buildSuccess();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @EventListener(classes = DeviceOnLineTimeChangeEvent.class)
|
|
|
|
|
- @Async
|
|
|
|
|
- @SneakyThrows
|
|
|
|
|
- public void syncDeviceOnlineTimeChange(DeviceOnLineTimeChangeEvent event) {
|
|
|
|
|
- String deviceId = event.getDeviceId();
|
|
|
|
|
- log.info("event syncDeviceOnlineTimeChange: {}", deviceId);
|
|
|
|
|
- DeviceInfo deviceInfo = deviceInfoDao.findTopByDeviceId(deviceId);
|
|
|
|
|
- if (ObjectUtils.isNotEmpty(deviceInfo)) {
|
|
|
|
|
- DevicePingInfoParam param = new DevicePingInfoParam();
|
|
|
|
|
- param.setDeviceId(deviceInfo.getDeviceId());
|
|
|
|
|
- param.setLastOnlineTime(deviceInfo.getLastOnlineTime());
|
|
|
|
|
- param.setOnLineState(deviceInfo.getOnLineState().name());
|
|
|
|
|
- param.setProjectInfoCode(deviceInfo.getProjectInfoCode());
|
|
|
|
|
- APIResponseModel api = apiRequestService.sendFullCardAPI(FullCardAPIConfig.syncDeviceOnLineState, param);
|
|
|
|
|
- log.info("同步设备在线时间: {} {}", api.isSuccess(), api.getMsg());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|