|
|
@@ -3,11 +3,8 @@ package com.shkpr.service.customgateway.zydma.constants;
|
|
|
import com.fasterxml.jackson.annotation.JsonAlias;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.shkpr.service.customgateway.core.constants.*;
|
|
|
-import com.shkpr.service.customgateway.core.domain.Device;
|
|
|
-import com.shkpr.service.customgateway.core.domain.DeviceTag;
|
|
|
import com.shkpr.service.customgateway.core.domain.IntegrationKey;
|
|
|
import com.shkpr.service.customgateway.core.properties.CallingProperties;
|
|
|
-import com.shkpr.service.customgateway.zydma.domain.IotPlatformData;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.Data;
|
|
|
import lombok.Getter;
|
|
|
@@ -16,16 +13,12 @@ import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.http.HttpHeaders;
|
|
|
import org.apache.http.client.fluent.Request;
|
|
|
import org.apache.http.client.fluent.Response;
|
|
|
-import org.influxdb.dto.Point;
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.time.ZoneId;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
-import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -93,35 +86,6 @@ public abstract class IotPlatformMetadata {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 数据转influxdb
|
|
|
- *
|
|
|
- * @param data 数据
|
|
|
- * @param tag 采集标签
|
|
|
- * @return influxdb记录
|
|
|
- */
|
|
|
- public static Point dataToPoint(IotPlatformData.Data data, Device device, DeviceTag tag) {
|
|
|
- //获取时间戳
|
|
|
- long timestamp = data.getPt()
|
|
|
- .truncatedTo(ChronoUnit.MINUTES)
|
|
|
- .atZone(ZoneId.systemDefault())
|
|
|
- .toInstant()
|
|
|
- .toEpochMilli();
|
|
|
- //构建influxdb
|
|
|
- return Point
|
|
|
- //表名
|
|
|
- .measurement(tag.getMeasurement())
|
|
|
- //设备id
|
|
|
- .tag(InfluxdbMetadata.Tags.DEVICE_ID, device.getDeviceId())
|
|
|
- //时间
|
|
|
- .time(timestamp, TimeUnit.MILLISECONDS)
|
|
|
- //值
|
|
|
- .addField(tag.getField(), data.getPv())
|
|
|
- //
|
|
|
- .addField(InfluxdbMetadata.Tags.DEVICE_SN, device.getDeviceSn())
|
|
|
- .build();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* 设备映射
|
|
|
*/
|
|
|
@Getter
|