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 4ffc395..e1a140b 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 @@ -84,7 +84,7 @@ public enum InfluxClient { public void insert(Event event, String measurement){ Point point = null; - if(event.getBatchNum()==null){ + if(event.getSampleNumber()==null){ point = Point.measurement(measurement) .addTag("transationId", event.getTransationId()) .addTag("argName", event.getArgName()) @@ -96,7 +96,6 @@ public enum InfluxClient { .addTag("inspectionSheetId", event.getInspectionSheetId()) .addTag("sampleNumber", event.getSampleNumber()) - .addTag("batchNum", event.getBatchNum()) .addTag("argName", event.getArgName()) .addField("argValue", event.getArgValue()) @@ -128,7 +127,7 @@ public enum InfluxClient { // .addTag("batchNum", event.getBatchNum()) .addTag("sampleNumber", event.getSampleNumber()) - .addField("batchNum", event.getBatchNum()) + //.addField("batchNum", event.getBatchNum()) .addTag("argName", event.getArgName()) .addField("argValue", event.getArgValue()) diff --git a/ym-influx/src/main/java/com/cnbm/influx/config/Main.java b/ym-influx/src/main/java/com/cnbm/influx/config/Main.java index b61870a..6bbebe9 100644 --- a/ym-influx/src/main/java/com/cnbm/influx/config/Main.java +++ b/ym-influx/src/main/java/com/cnbm/influx/config/Main.java @@ -52,7 +52,7 @@ public class Main { event.setTime(new Date().toInstant()); event.setTransationId("2344"); - event.setBatchNum("22"); + event.setArgName("forUpdate"); event.setArgValue("124.1"); InfluxClient.Client.insert(event,"FORUPDATE"); diff --git a/ym-influx/src/main/java/com/cnbm/influx/controller/S7DemoController.java b/ym-influx/src/main/java/com/cnbm/influx/controller/S7DemoController.java index bf0177c..dcbcf42 100644 --- a/ym-influx/src/main/java/com/cnbm/influx/controller/S7DemoController.java +++ b/ym-influx/src/main/java/com/cnbm/influx/controller/S7DemoController.java @@ -2,6 +2,7 @@ package com.cnbm.influx.controller; import com.cnbm.common.spc.util.DataUtils; import com.cnbm.influx.config.InfluxClient; +import com.cnbm.influx.constant.Constant; import com.cnbm.influx.param.PageInfo; import com.cnbm.influx.param.QueryDataParam; import com.cnbm.influx.param.Range; @@ -61,22 +62,41 @@ public class S7DemoController { Instant time = new Date().toInstant(); Event event = new Event(); event.setTime(time); - event.setBatchNum("1"); + event.setArgName("failDayDay"); event.setArgValue("1"); + event.setSampleNumber("10001"); list.add(event); Thread.sleep(1000); Event event2 = new Event(); event2.setTime(time); - event.setBatchNum("2"); + event2.setArgName("failDayDay"); event2.setArgValue("2"); + event2.setSampleNumber("10001"); list.add(event2); InfluxClient.Client.batchInsert(list,"Weight"); } + @PostMapping("/readDemoOne") + public void readDemoOne() throws InterruptedException { + List dropNames = new ArrayList<>(); + dropNames.add("transationId"); + dropNames.add("inspectionSheetId"); + dropNames.add("batchNum"); + + QueryDataParam queryDataParam = new QueryDataParam(); + queryDataParam.setMeasurement(Constant.measurement); + queryDataParam.setRange(new Range(DataUtils.getBeforeDate(999).toInstant(), DataUtils.getAfterDate(999).toInstant() )); + + queryDataParam.setDropedTagNames(dropNames); + queryDataParam.setTag(new Tag("argName","failDayDay")); + queryDataParam.setBucket(Constant.bucket); + List query = InfluxClient.Client.query(queryDataParam); + System.out.println(); + } //for 常规计数型 @@ -93,7 +113,7 @@ public class S7DemoController { event.setArgName("LTWeight"); Double d = r.nextDouble() * 2.5 + 66; event.setArgValue(d.toString()); - event.setBatchNum(4+""); + event.setInspectionSheetId(i+""); list.add(event); } diff --git a/ym-influx/src/main/java/com/cnbm/influx/template/Event.java b/ym-influx/src/main/java/com/cnbm/influx/template/Event.java index 24c8124..efca4f5 100644 --- a/ym-influx/src/main/java/com/cnbm/influx/template/Event.java +++ b/ym-influx/src/main/java/com/cnbm/influx/template/Event.java @@ -23,8 +23,8 @@ public class Event { private String argValue; - //batchNumber(必填), 作为区分 手动录入 和 自动录入的区别 - private String batchNum; + //batchNum 舍弃了,influxdb中不存批次号,存在mysql - inspection_sheet表 中批次号字段 + //private String batchNum; private String inspectionSheetId; @@ -32,7 +32,7 @@ public class Event { public Event() { //自动录入,给个默认值 - this.batchNum = "-1"; +// this.batchNum = "-1"; this.inspectionSheetId = "-1"; this.sampleNumber = "-1"; }