mark for pull

This commit is contained in:
caixiang 2022-12-01 11:44:39 +08:00
parent 4e413ac644
commit 183dcf7d48
3 changed files with 52 additions and 5 deletions

View File

@ -159,6 +159,7 @@ public enum InfluxClient {
String flux = "from(bucket:\""+bucket+"\")";
flux += "|> range(start: "+range.getBegin()+",stop:"+range.getEnd()+")";
flux += "|> filter(fn: (r) => r[\"_measurement\"] == \""+measurement+"\")";
flux += "|> timeShift(duration: 8h)";
if (tagName!=null){
flux += "|> filter(fn: (r) => r[\""+tagName+"\"] == \""+tagValue+"\")";
}
@ -187,6 +188,7 @@ public enum InfluxClient {
flux += "|> range(start: "+range.getBegin()+",stop:"+range.getEnd()+")";
flux += "|> filter(fn: (r) => r[\"_measurement\"] == \""+measurement+"\")";
flux += "|> filter(fn: (r) => r[\""+tagName+"\"] == \""+tagValue+"\")";
flux += "|> timeShift(duration: 8h)";
flux += "|> group(columns: [\""+groupName+"\"], mode: \"except\")";
for(String dropName:dropedTagNames){
flux += "|> drop(columns: [\""+dropName+"\"])";
@ -211,6 +213,7 @@ public enum InfluxClient {
flux += "|> range(start: "+range.getBegin()+",stop:"+range.getEnd()+")";
flux += "|> filter(fn: (r) => r[\"_measurement\"] == \""+measurement+"\")";
flux += "|> filter(fn: (r) => r[\""+tagName+"\"] == \""+tagValue+"\")";
flux += "|> timeShift(duration: 8h)";
for(String dropName:dropedTagNames){
flux += "|> drop(columns: [\""+dropName+"\"])";
}

View File

@ -0,0 +1,49 @@
package com.qgs.dc.influx.config;
import com.influxdb.query.FluxTable;
import com.qgs.dc.influx.common.DataUtils;
import com.qgs.dc.influx.param.PageInfo;
import com.qgs.dc.influx.param.QueryDataParam;
import com.qgs.dc.influx.param.Range;
import com.qgs.dc.influx.param.Tag;
import com.qgs.dc.influx.template.Event;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @Desc: ""
* @Author: caixiang
* @DATE: 2022/12/1 10:32
*/
public class MainTest {
public static void main(String[] args) {
Event event = new Event();
event.setTime(new Date().toInstant());
event.setTransationId("2344");
event.setBatchNum("22");
event.setArgName("forUpdate");
event.setArgValue("124.1");
InfluxClient.Client.insert(event,"FORUPDATEEEE");
// Thread.sleep(50000);
//
// event.setArgValue(333.3);
// InfluxClient.Client.insert(event,"FORUPDATE");
QueryDataParam queryDataParam = new QueryDataParam();
queryDataParam.setBucket("qgs-bucket");
queryDataParam.setMeasurement("FORUPDATEEEE");
List<String> dropNames = new ArrayList<>();
dropNames.add("transationId");
dropNames.add("inspectionSheetId");
queryDataParam.setDropedTagNames(dropNames);
queryDataParam.setTag(new Tag("argName","forUpdate"));
queryDataParam.setRange(new Range(DataUtils.getBeforeDate(999).toInstant(),DataUtils.getAfterDate(999).toInstant()));
queryDataParam.setPageInfo(new PageInfo(1,10));
List<FluxTable> query = InfluxClient.Client.query(queryDataParam);
System.out.println();
}
}

View File

@ -39,11 +39,6 @@ spring:
# bucket: 'qgs-bucket'
# org: 'qgs'
# token: 'lkBsC27QZr1W50BSPlGxpTqNNpwuUk5uz1dZZRPSPbCG5VmNDDUo8P3UkZIhGWwfJwkuz6ZGZ7Et4_KBaG3gHw=='
influx:
influxUrl: 'http://192.168.0.170:8086'
bucket: 'qgs-bucket'
org: 'qgs'
token: 'lkBsC27QZr1W50BSPlGxpTqNNpwuUk5uz1dZZRPSPbCG5VmNDDUo8P3UkZIhGWwfJwkuz6ZGZ7Et4_KBaG3gHw=='
# /health point
#management: