新增判读方案
This commit is contained in:
@@ -23,7 +23,11 @@
|
||||
<artifactId>influxdb-client-java</artifactId>
|
||||
<version>6.3.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.cnbm</groupId>
|
||||
<artifactId>ym-common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!--- begin -->
|
||||
<!-- <dependency>-->
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
package com.cnbm.influx.common;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Desc: ""
|
||||
* @Author: caixiang
|
||||
* @DATE: 2022/6/29 16:23
|
||||
*/
|
||||
public class Utils {
|
||||
public static void main(String[] args) {
|
||||
ArrayList<Integer> arrs = new ArrayList<>();
|
||||
|
||||
for(int i=0;i<100;i++){
|
||||
arrs.add(i);
|
||||
}
|
||||
List<List<Integer>> lists = fixedGroup(arrs, 10);
|
||||
System.out.println();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static Date getBeforeDate(Integer number){
|
||||
Date date = new Date();//获取当前日期
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");//格式化一下
|
||||
Calendar calendar1 = Calendar.getInstance();//获取对日期操作的类对象
|
||||
//两种写法都可以获取到前三天的日期
|
||||
// calendar1.set(Calendar.DAY_OF_YEAR,calendar1.get(Calendar.DAY_OF_YEAR) -3);
|
||||
//在当前时间的基础上获取前三天的日期
|
||||
calendar1.add(Calendar.DATE, 0-number);
|
||||
//add方法 参数也可传入 月份,获取的是前几月或后几月的日期
|
||||
//calendar1.add(Calendar.MONTH, -3);
|
||||
Date day = calendar1.getTime();
|
||||
return day;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将一组数据固定分组,每组n个元素
|
||||
*
|
||||
* @param source 要分组的数据源
|
||||
* @param limit 每组n个元素
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> List<List<T>> fixedGroup(List<T> source, int limit) {
|
||||
if (null == source || source.size() == 0 || limit <= 0)
|
||||
return null;
|
||||
List<List<T>> result = new ArrayList<List<T>>();
|
||||
int remainder = source.size() % limit;
|
||||
int size = (source.size() / limit);
|
||||
for (int i = 0; i < size; i++) {
|
||||
List<T> subset = null;
|
||||
subset = source.subList(i * limit, (i + 1) * limit);
|
||||
result.add(subset);
|
||||
}
|
||||
if (remainder > 0) {
|
||||
List<T> subset = null;
|
||||
subset = source.subList(size * limit, size * limit + remainder);
|
||||
result.add(subset);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -60,16 +60,17 @@ public enum InfluxClient {
|
||||
* true 服务正常健康
|
||||
* false 异常
|
||||
*/
|
||||
private boolean ping() {
|
||||
public boolean ping() {
|
||||
boolean isConnected = false;
|
||||
Boolean pong;
|
||||
try {
|
||||
pong = influxDBClient.ping();
|
||||
if (pong != null) {
|
||||
isConnected = true;
|
||||
isConnected = pong;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return isConnected;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.cnbm.influx.controller;
|
||||
|
||||
import com.cnbm.influx.common.Utils;
|
||||
import com.cnbm.common.spc.util.DataUtils;
|
||||
import com.cnbm.influx.config.InfluxClient;
|
||||
import com.cnbm.influx.param.PageInfo;
|
||||
import com.cnbm.influx.param.QueryDataParam;
|
||||
@@ -44,6 +44,19 @@ public class S7DemoController {
|
||||
InfluxClient.Client.batchInsert(list,"ASProcessCompleteEventAS");
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试连接是否正常
|
||||
*
|
||||
* @return
|
||||
* true 服务正常健康
|
||||
* false 异常
|
||||
*/
|
||||
@PostMapping("/ping")
|
||||
public void ping() throws InterruptedException {
|
||||
boolean ping = InfluxClient.Client.ping();
|
||||
System.out.println(ping);
|
||||
}
|
||||
|
||||
@PostMapping("/query")
|
||||
public void query() throws InterruptedException {
|
||||
List<Event> list = new ArrayList<>();
|
||||
@@ -53,7 +66,7 @@ public class S7DemoController {
|
||||
queryDataParam.setMeasurement("ASProcessCompleteEventAS");
|
||||
queryDataParam.setDropedTagName("transationId");
|
||||
queryDataParam.setTag(new Tag("argName","arg6"));
|
||||
queryDataParam.setRange(new Range(Utils.getBeforeDate(10).toInstant(),Instant.now()));
|
||||
queryDataParam.setRange(new Range(DataUtils.getBeforeDate(10).toInstant(),Instant.now()));
|
||||
queryDataParam.setPageInfo(new PageInfo(1,10));
|
||||
List<FluxTable> query = InfluxClient.Client.query(queryDataParam);
|
||||
|
||||
@@ -76,7 +89,7 @@ public class S7DemoController {
|
||||
queryDataParam.setMeasurement("ASProcessCompleteEventAS");
|
||||
queryDataParam.setDropedTagName("transationId");
|
||||
queryDataParam.setTag(new Tag("argName","arg7"));
|
||||
queryDataParam.setRange(new Range(Utils.getBeforeDate(10).toInstant(),Instant.now()));
|
||||
queryDataParam.setRange(new Range(DataUtils.getBeforeDate(10).toInstant(),Instant.now()));
|
||||
queryDataParam.setPageInfo(new PageInfo(2,10));
|
||||
List<FluxTable> query = InfluxClient.Client.query(queryDataParam);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user