初定 第一版
This commit is contained in:
parent
cafcdd65e0
commit
2bc72469a0
@ -181,43 +181,43 @@ public enum InfluxClient {
|
|||||||
return queryApi.query(flux);
|
return queryApi.query(flux);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FluxTable> queryByGroup(QueryDataParam param){
|
// public List<FluxTable> queryByGroup(QueryDataParam param){
|
||||||
String measurement = param.getMeasurement();
|
// String measurement = param.getMeasurement();
|
||||||
List<String> dropedTagNames = param.getDropedTagNames();
|
// List<String> dropedTagNames = param.getDropedTagNames();
|
||||||
Range range = param.getRange();
|
// Range range = param.getRange();
|
||||||
String bucket = param.getBucket();
|
// String bucket = param.getBucket();
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
String groupName = param.getGroupName();
|
// String groupName = param.getGroupName();
|
||||||
PageInfo pageInfo = param.getPageInfo();
|
// PageInfo pageInfo = param.getPageInfo();
|
||||||
|
//
|
||||||
String flux = "from(bucket:\""+bucket+"\")";
|
// String flux = "from(bucket:\""+bucket+"\")";
|
||||||
flux += "|> range(start: "+range.getBegin()+",stop:"+range.getEnd()+")";
|
// flux += "|> range(start: "+range.getBegin()+",stop:"+range.getEnd()+")";
|
||||||
flux += "|> filter(fn: (r) => r[\"_measurement\"] == \""+measurement+"\")";
|
// flux += "|> filter(fn: (r) => r[\"_measurement\"] == \""+measurement+"\")";
|
||||||
|
//
|
||||||
// String tagName = param.getTag().getTagName();
|
//// String tagName = param.getTag().getTagName();
|
||||||
// String tagValue = param.getTag().getTagValue();
|
//// String tagValue = param.getTag().getTagValue();
|
||||||
// flux += "|> filter(fn: (r) => r[\""+tagName+"\"] == \""+tagValue+"\")";
|
//// flux += "|> filter(fn: (r) => r[\""+tagName+"\"] == \""+tagValue+"\")";
|
||||||
if(param.getTags()!=null && param.getTags().size()>0){
|
// if(param.getTags()!=null && param.getTags().size()>0){
|
||||||
for(Tag tag:param.getTags()){
|
// for(Tag tag:param.getTags()){
|
||||||
String tagName = tag.getTagName();
|
// String tagName = tag.getTagName();
|
||||||
String tagValue = tag.getTagValue();
|
// String tagValue = tag.getTagValue();
|
||||||
flux += "|> filter(fn: (r) => r[\""+tagName+"\"] == \""+tagValue+"\")";
|
// flux += "|> filter(fn: (r) => r[\""+tagName+"\"] == \""+tagValue+"\")";
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// flux += "|> timeShift(duration: 8h)";
|
//// flux += "|> timeShift(duration: 8h)";
|
||||||
flux += "|> group(columns: [\""+groupName+"\"], mode: \"except\")";
|
// flux += "|> group(columns: [\""+groupName+"\"], mode: \"except\")";
|
||||||
for(String dropName:dropedTagNames){
|
// for(String dropName:dropedTagNames){
|
||||||
flux += "|> drop(columns: [\""+dropName+"\"])";
|
// flux += "|> drop(columns: [\""+dropName+"\"])";
|
||||||
}
|
// }
|
||||||
flux += "|> sort(columns: [\"_time\"], desc: true)";
|
// flux += "|> sort(columns: [\"_time\"], desc: true)";
|
||||||
if(pageInfo!=null){
|
// if(pageInfo!=null){
|
||||||
flux += "|> limit(n: "+pageInfo.getSize()+", offset: "+(pageInfo.getCurrent()-1)* pageInfo.getSize()+")";
|
// flux += "|> limit(n: "+pageInfo.getSize()+", offset: "+(pageInfo.getCurrent()-1)* pageInfo.getSize()+")";
|
||||||
}
|
// }
|
||||||
return queryApi.query(flux);
|
// return queryApi.query(flux);
|
||||||
}
|
// }
|
||||||
|
|
||||||
public List<FluxTable> queryGroupByTime(QueryDataGroupByTimeParam param){
|
public List<FluxTable> queryGroupByTime(QueryDataGroupByTimeParam param){
|
||||||
String measurement = param.getMeasurement();
|
String measurement = param.getMeasurement();
|
||||||
|
@ -24,9 +24,9 @@ import java.util.*;
|
|||||||
public class SPCController {
|
public class SPCController {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(SPCController.class);
|
private static final Logger logger = LoggerFactory.getLogger(SPCController.class);
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/getData")
|
@PostMapping("/getData")
|
||||||
public Result getData(@RequestBody QueryDataParam param) throws InterruptedException {
|
public Result getData(@RequestBody QueryDataParam param){
|
||||||
|
|
||||||
List<FluxTable> query = InfluxClient.Client.query(param);
|
List<FluxTable> query = InfluxClient.Client.query(param);
|
||||||
return new Result<List<FluxTable>>().ok(query);
|
return new Result<List<FluxTable>>().ok(query);
|
||||||
}
|
}
|
||||||
|
@ -21,4 +21,7 @@ public class PageInfo {
|
|||||||
this.current = current;
|
this.current = current;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PageInfo() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,9 @@ public class QueryDataParam extends BaseParam{
|
|||||||
//查询的时候,需要忽略的字段。(transationId是唯一标识会对 最终的查询结果集产生影响)
|
//查询的时候,需要忽略的字段。(transationId是唯一标识会对 最终的查询结果集产生影响)
|
||||||
private List<String> dropedTagNames;
|
private List<String> dropedTagNames;
|
||||||
private String bucket;
|
private String bucket;
|
||||||
private String groupName;
|
|
||||||
//private String inspectionSheetId;
|
//private String inspectionSheetId;
|
||||||
|
|
||||||
|
|
||||||
|
public QueryDataParam() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,9 @@ public class Range {
|
|||||||
this.end = end;
|
this.end = end;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public static void main(String[] args) {
|
public Range() {
|
||||||
|
}
|
||||||
|
// public static void main(String[] args) {
|
||||||
// Date date = new Date();
|
// Date date = new Date();
|
||||||
// System.out.println(date.toInstant().toString());
|
// System.out.println(date.toInstant().toString());
|
||||||
// }
|
// }
|
||||||
|
@ -16,4 +16,7 @@ public class Tag {
|
|||||||
this.tagName = tagName;
|
this.tagName = tagName;
|
||||||
this.tagValue = tagValue;
|
this.tagValue = tagValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Tag() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user