|
|
@@ -6,11 +6,13 @@ import com.github.microservice.models.onLine.DeviceOnLineResult;
|
|
|
import com.github.microservice.net.ResultContent;
|
|
|
import com.zhongshu.iot.server.core.domain.ExecuteAnnotationService;
|
|
|
import com.zhongshu.iot.server.core.domain.ExecuteAnnotationServiceMethod;
|
|
|
+import com.zhongshu.iot.server.core.service.device.DeviceInfoService;
|
|
|
import com.zhongshu.iot.server.core.service.iotPlatform.PlatformTopic;
|
|
|
import com.zhongshu.iot.server.core.util.DateUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
/**
|
|
|
@@ -22,6 +24,9 @@ import org.springframework.stereotype.Component;
|
|
|
@Slf4j
|
|
|
public class OnLineTopic implements PlatformTopic {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private DeviceInfoService deviceInfoService;
|
|
|
+
|
|
|
@Override
|
|
|
public String topic() {
|
|
|
return "/platform/%s/online";
|
|
|
@@ -41,6 +46,14 @@ public class OnLineTopic implements PlatformTopic {
|
|
|
result.setSuccess();
|
|
|
result.setDeviceId(param.getDeviceId());
|
|
|
result.setGateWayId(param.getGateWayId());
|
|
|
+
|
|
|
+ // 验证设备是否可用
|
|
|
+ ResultContent resultContent = deviceInfoService.deviceCanUse(param.getDeviceId());
|
|
|
+ if (resultContent.isFailed()) {
|
|
|
+ result.setFailed(resultContent.getMsg());
|
|
|
+ return ResultContent.buildSuccess(result);
|
|
|
+ }
|
|
|
+ result.setSuccess();
|
|
|
result.setTime(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
|
|
|
result.setInfo(param.getInfo());
|
|
|
}
|