代码更新
This commit is contained in:
@@ -309,7 +309,7 @@ public class InfluxDBResultMapperCn {
|
||||
if (String.class.isAssignableFrom(fieldType)) {
|
||||
if("timeId".equals(field.getName()) || "time".equals(field.getName())){
|
||||
LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.from(DateTimeFormatter.ISO_DATE_TIME.parse(String.valueOf(value))), ZoneId.systemDefault());
|
||||
String time = localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
String time = localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
|
||||
field.set(object,time);
|
||||
}else {
|
||||
field.set(object, String.valueOf(value));
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
package com.njcn.influxdb.utils;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* 传入终端id集合返回influxdb使用sql
|
||||
* @author cdf
|
||||
* @date 2022/7/1
|
||||
*/
|
||||
@Component
|
||||
@Validated
|
||||
public class InfluxDBCommUtils {
|
||||
|
||||
/**
|
||||
@@ -19,7 +23,7 @@ public class InfluxDBCommUtils {
|
||||
* @param lineIds 监测点参数
|
||||
* @return StringBuilder
|
||||
*/
|
||||
public static StringBuilder assToInfluxParam(List<String> lineIds){
|
||||
public static StringBuilder assToInfluxParam(@NotEmpty List<String> lineIds){
|
||||
StringBuilder lineIdsStr = new StringBuilder("(");
|
||||
for (int i = 0; i < lineIds.size(); i++) {
|
||||
if (lineIds.size() - i != 1) {
|
||||
@@ -30,4 +34,23 @@ public class InfluxDBCommUtils {
|
||||
}
|
||||
return lineIdsStr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 组装为influxdb监测点参数
|
||||
*
|
||||
* @param devIds 设备ids参数
|
||||
* @return StringBuilder
|
||||
*/
|
||||
public static StringBuilder assToInfluxParamDev(@NotEmpty List<String> devIds){
|
||||
StringBuilder lineIdsStr = new StringBuilder("(");
|
||||
for (int i = 0; i < devIds.size(); i++) {
|
||||
if (devIds.size() - i != 1) {
|
||||
lineIdsStr.append("dev_id ='").append(devIds.get(i)).append("' or ");
|
||||
} else {
|
||||
lineIdsStr.append("dev_id ='").append(devIds.get(i)).append("') ");
|
||||
}
|
||||
}
|
||||
return lineIdsStr;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user