diff --git a/ym-influx/src/main/java/com/cnbm/influx/config/InfluxClient.java b/ym-influx/src/main/java/com/cnbm/influx/config/InfluxClient.java index 0a144ca..ed74b69 100644 --- a/ym-influx/src/main/java/com/cnbm/influx/config/InfluxClient.java +++ b/ym-influx/src/main/java/com/cnbm/influx/config/InfluxClient.java @@ -181,43 +181,43 @@ public enum InfluxClient { return queryApi.query(flux); } - public List queryByGroup(QueryDataParam param){ - String measurement = param.getMeasurement(); - List 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+"\")"; - } - } - -// 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 queryByGroup(QueryDataParam param){ +// String measurement = param.getMeasurement(); +// List 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+"\")"; +// } +// } +// +//// 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 queryGroupByTime(QueryDataGroupByTimeParam param){ String measurement = param.getMeasurement(); diff --git a/ym-influx/src/main/java/com/cnbm/influx/controller/SPCController.java b/ym-influx/src/main/java/com/cnbm/influx/controller/SPCController.java index ebd608c..cbabd12 100644 --- a/ym-influx/src/main/java/com/cnbm/influx/controller/SPCController.java +++ b/ym-influx/src/main/java/com/cnbm/influx/controller/SPCController.java @@ -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 query = InfluxClient.Client.query(param); return new Result>().ok(query); } diff --git a/ym-influx/src/main/java/com/cnbm/influx/param/PageInfo.java b/ym-influx/src/main/java/com/cnbm/influx/param/PageInfo.java index 5123a6a..92cf5b4 100644 --- a/ym-influx/src/main/java/com/cnbm/influx/param/PageInfo.java +++ b/ym-influx/src/main/java/com/cnbm/influx/param/PageInfo.java @@ -21,4 +21,7 @@ public class PageInfo { this.current = current; this.size = size; } + + public PageInfo() { + } } diff --git a/ym-influx/src/main/java/com/cnbm/influx/param/QueryDataParam.java b/ym-influx/src/main/java/com/cnbm/influx/param/QueryDataParam.java index 6195ad5..116a281 100644 --- a/ym-influx/src/main/java/com/cnbm/influx/param/QueryDataParam.java +++ b/ym-influx/src/main/java/com/cnbm/influx/param/QueryDataParam.java @@ -31,7 +31,9 @@ public class QueryDataParam extends BaseParam{ //查询的时候,需要忽略的字段。(transationId是唯一标识会对 最终的查询结果集产生影响) private List dropedTagNames; private String bucket; - private String groupName; //private String inspectionSheetId; + + public QueryDataParam() { + } } diff --git a/ym-influx/src/main/java/com/cnbm/influx/param/Range.java b/ym-influx/src/main/java/com/cnbm/influx/param/Range.java index 4450c46..1378b6b 100644 --- a/ym-influx/src/main/java/com/cnbm/influx/param/Range.java +++ b/ym-influx/src/main/java/com/cnbm/influx/param/Range.java @@ -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()); // } diff --git a/ym-influx/src/main/java/com/cnbm/influx/param/Tag.java b/ym-influx/src/main/java/com/cnbm/influx/param/Tag.java index fea0ab9..357d4e7 100644 --- a/ym-influx/src/main/java/com/cnbm/influx/param/Tag.java +++ b/ym-influx/src/main/java/com/cnbm/influx/param/Tag.java @@ -16,4 +16,7 @@ public class Tag { this.tagName = tagName; this.tagValue = tagValue; } + + public Tag() { + } }