初定 第一版

This commit is contained in:
caixiang 2023-01-11 15:58:24 +08:00
parent cafcdd65e0
commit 2bc72469a0
6 changed files with 51 additions and 41 deletions

View File

@ -181,43 +181,43 @@ public enum InfluxClient {
return queryApi.query(flux);
}
public List<FluxTable> queryByGroup(QueryDataParam param){
String measurement = param.getMeasurement();
List<String> dropedTagNames = param.getDropedTagNames();
Range range = param.getRange();
String bucket = param.getBucket();
String groupName = param.getGroupName();
PageInfo pageInfo = param.getPageInfo();
String flux = "from(bucket:\""+bucket+"\")";
flux += "|> range(start: "+range.getBegin()+",stop:"+range.getEnd()+")";
flux += "|> filter(fn: (r) => r[\"_measurement\"] == \""+measurement+"\")";
// String tagName = param.getTag().getTagName();
// String tagValue = param.getTag().getTagValue();
// public List<FluxTable> queryByGroup(QueryDataParam param){
// String measurement = param.getMeasurement();
// List<String> dropedTagNames = param.getDropedTagNames();
// Range range = param.getRange();
// String bucket = param.getBucket();
//
//
//
// String groupName = param.getGroupName();
// PageInfo pageInfo = param.getPageInfo();
//
// String flux = "from(bucket:\""+bucket+"\")";
// flux += "|> range(start: "+range.getBegin()+",stop:"+range.getEnd()+")";
// flux += "|> filter(fn: (r) => r[\"_measurement\"] == \""+measurement+"\")";
//
//// String tagName = param.getTag().getTagName();
//// String tagValue = param.getTag().getTagValue();
//// flux += "|> filter(fn: (r) => r[\""+tagName+"\"] == \""+tagValue+"\")";
// if(param.getTags()!=null && param.getTags().size()>0){
// for(Tag tag:param.getTags()){
// String tagName = tag.getTagName();
// String tagValue = tag.getTagValue();
// flux += "|> filter(fn: (r) => r[\""+tagName+"\"] == \""+tagValue+"\")";
if(param.getTags()!=null && param.getTags().size()>0){
for(Tag tag:param.getTags()){
String tagName = tag.getTagName();
String tagValue = tag.getTagValue();
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+"\"])";
}
flux += "|> sort(columns: [\"_time\"], desc: true)";
if(pageInfo!=null){
flux += "|> limit(n: "+pageInfo.getSize()+", offset: "+(pageInfo.getCurrent()-1)* pageInfo.getSize()+")";
}
return queryApi.query(flux);
}
// }
// }
//
//// flux += "|> timeShift(duration: 8h)";
// flux += "|> group(columns: [\""+groupName+"\"], mode: \"except\")";
// for(String dropName:dropedTagNames){
// flux += "|> drop(columns: [\""+dropName+"\"])";
// }
// flux += "|> sort(columns: [\"_time\"], desc: true)";
// if(pageInfo!=null){
// flux += "|> limit(n: "+pageInfo.getSize()+", offset: "+(pageInfo.getCurrent()-1)* pageInfo.getSize()+")";
// }
// return queryApi.query(flux);
// }
public List<FluxTable> queryGroupByTime(QueryDataGroupByTimeParam param){
String measurement = param.getMeasurement();

View File

@ -24,9 +24,9 @@ import java.util.*;
public class SPCController {
private static final Logger logger = LoggerFactory.getLogger(SPCController.class);
@PostMapping("/getData")
public Result getData(@RequestBody QueryDataParam param) throws InterruptedException {
public Result getData(@RequestBody QueryDataParam param){
List<FluxTable> query = InfluxClient.Client.query(param);
return new Result<List<FluxTable>>().ok(query);
}

View File

@ -21,4 +21,7 @@ public class PageInfo {
this.current = current;
this.size = size;
}
public PageInfo() {
}
}

View File

@ -31,7 +31,9 @@ public class QueryDataParam extends BaseParam{
//查询的时候需要忽略的字段(transationId是唯一标识会对 最终的查询结果集产生影响)
private List<String> dropedTagNames;
private String bucket;
private String groupName;
//private String inspectionSheetId;
public QueryDataParam() {
}
}

View File

@ -23,7 +23,9 @@ public class Range {
this.end = end;
}
// public static void main(String[] args) {
public Range() {
}
// public static void main(String[] args) {
// Date date = new Date();
// System.out.println(date.toInstant().toString());
// }

View File

@ -16,4 +16,7 @@ public class Tag {
this.tagName = tagName;
this.tagValue = tagValue;
}
public Tag() {
}
}