|
@@ -11,6 +11,7 @@ import com.shkpr.service.bespokegateway.core.domain.Device;
|
|
|
import com.shkpr.service.bespokegateway.core.domain.DeviceTag;
|
|
import com.shkpr.service.bespokegateway.core.domain.DeviceTag;
|
|
|
import com.shkpr.service.bespokegateway.core.domain.IntegrationKey;
|
|
import com.shkpr.service.bespokegateway.core.domain.IntegrationKey;
|
|
|
import com.shkpr.service.bespokegateway.core.exception.SelfException;
|
|
import com.shkpr.service.bespokegateway.core.exception.SelfException;
|
|
|
|
|
+import com.shkpr.service.bespokegateway.core.manager.IntegrationKeyManager;
|
|
|
import com.shkpr.service.bespokegateway.core.properties.CallingProperties;
|
|
import com.shkpr.service.bespokegateway.core.properties.CallingProperties;
|
|
|
import com.shkpr.service.bespokegateway.core.utils.CallingUtil;
|
|
import com.shkpr.service.bespokegateway.core.utils.CallingUtil;
|
|
|
import com.shkpr.service.bespokegateway.core.utils.InfluxDbUtil;
|
|
import com.shkpr.service.bespokegateway.core.utils.InfluxDbUtil;
|
|
@@ -27,7 +28,6 @@ import org.springframework.http.HttpMethod;
|
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -50,6 +50,8 @@ public class DataCollector {
|
|
|
final
|
|
final
|
|
|
CallingProperties callingProperties;
|
|
CallingProperties callingProperties;
|
|
|
final
|
|
final
|
|
|
|
|
+ IntegrationKeyManager integrationKeyManager;
|
|
|
|
|
+ final
|
|
|
DeviceRegistry deviceRegistry;
|
|
DeviceRegistry deviceRegistry;
|
|
|
final
|
|
final
|
|
|
DeviceIdGenerator deviceIdGenerator;
|
|
DeviceIdGenerator deviceIdGenerator;
|
|
@@ -58,11 +60,9 @@ public class DataCollector {
|
|
|
final
|
|
final
|
|
|
CallingUtil callingUtil;
|
|
CallingUtil callingUtil;
|
|
|
|
|
|
|
|
- //密钥
|
|
|
|
|
- public volatile IntegrationKey key = null;
|
|
|
|
|
-
|
|
|
|
|
- public DataCollector(CallingProperties callingProperties, DeviceRegistry deviceRegistry, DeviceIdGenerator deviceIdGenerator, InfluxDbUtil influxDbUtil, CallingUtil callingUtil) {
|
|
|
|
|
|
|
+ public DataCollector(CallingProperties callingProperties, IntegrationKeyManager integrationKeyManager, DeviceRegistry deviceRegistry, DeviceIdGenerator deviceIdGenerator, InfluxDbUtil influxDbUtil, CallingUtil callingUtil) {
|
|
|
this.callingProperties = callingProperties;
|
|
this.callingProperties = callingProperties;
|
|
|
|
|
+ this.integrationKeyManager = integrationKeyManager;
|
|
|
this.deviceRegistry = deviceRegistry;
|
|
this.deviceRegistry = deviceRegistry;
|
|
|
this.deviceIdGenerator = deviceIdGenerator;
|
|
this.deviceIdGenerator = deviceIdGenerator;
|
|
|
this.influxDbUtil = influxDbUtil;
|
|
this.influxDbUtil = influxDbUtil;
|
|
@@ -82,17 +82,8 @@ public class DataCollector {
|
|
|
|
|
|
|
|
//平台对接点
|
|
//平台对接点
|
|
|
CallingEndpoint endpoint = callingProperties.getEndpoint(IotPlatformMetadata.NAME);
|
|
CallingEndpoint endpoint = callingProperties.getEndpoint(IotPlatformMetadata.NAME);
|
|
|
-
|
|
|
|
|
- //===================获取密钥===================
|
|
|
|
|
- try {
|
|
|
|
|
- if (key == null) key = IotPlatformMetadata.getKey(endpoint);
|
|
|
|
|
- } catch (IOException e) {
|
|
|
|
|
- LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_WARN, BIZ_TYPE, CLASS_NAME,
|
|
|
|
|
- String.format("加载设备序号数据失败,error:%s", e));
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- if (key == null) return;
|
|
|
|
|
-
|
|
|
|
|
|
|
+ //密钥
|
|
|
|
|
+ IntegrationKey key = integrationKeyManager.getKey(IotPlatformMetadata.NAME);
|
|
|
//请求地址
|
|
//请求地址
|
|
|
String url = endpoint.getUrl() + IotPlatformMetadata.Uri.GET_DEVICE_HISTORY_DATA;
|
|
String url = endpoint.getUrl() + IotPlatformMetadata.Uri.GET_DEVICE_HISTORY_DATA;
|
|
|
//请求头
|
|
//请求头
|