This commit is contained in:
caixiang
2023-05-09 14:24:13 +08:00
parent 7c21dfe8e1
commit 5a9f5ee38b
8 changed files with 17 additions and 54 deletions

View File

@@ -74,7 +74,7 @@ public enum InfluxClient {
}
/**
* desc: 异步批量 写入数据/更新数据
* desc: 异步批量 写入数据 / 更新数据
* notes: 如果是更新数据要保证time字段不能改变
* auth: caixaing
* */
@@ -99,7 +99,6 @@ public enum InfluxClient {
.time(event.getTime().toEpochMilli(), WritePrecision.MS);
}
writeApi.writePoint(point);
}
/**
@@ -181,6 +180,7 @@ public enum InfluxClient {
return queryApi.query(flux);
}
// public List<FluxTable> queryByGroup(QueryDataParam param){
// String measurement = param.getMeasurement();
// List<String> dropedTagNames = param.getDropedTagNames();

View File

@@ -63,10 +63,9 @@ public class S7DemoController {
}
@PostMapping("/insertDemoOne")
public void insertDemoOne() throws InterruptedException {
public void insertDemoOne(){
List<Event> list = new ArrayList<>();
Event event = new Event();
event.setTime(new Date(1670554110451L).toInstant());
event.setArgName("failDayDay");
@@ -81,22 +80,9 @@ public class S7DemoController {
event2.setSampleNumber("10001");
list.add(event2);
InfluxClient.Client.batchInsert(list,"Weight");
// Thread.sleep(10000);
//
// List<Event> list2 = new ArrayList<>();
// Event event2 = new Event();
// event2.setTime(time);
//
// event2.setArgName("failDayDay");
// event2.setArgValue("20087");
// event2.setSampleNumber("10001");
// list2.add(event2);
//
// InfluxClient.Client.batchInsert(list2,"Weight");
}
@PostMapping("/readDemoOne")
public void readDemoOne() throws InterruptedException {
public void readDemoOne() {
List<String> dropNames = new ArrayList<>();
dropNames.add("transationId");
// dropNames.add("inspectionSheetId");
@@ -114,7 +100,7 @@ public class S7DemoController {
}
@PostMapping("/getFlux")
public Result<Instant> getFlux() throws InterruptedException {
public Result<Instant> getFlux() {
List<String> dropNames = new ArrayList<>();
dropNames.add("transationId");
dropNames.add("inspectionSheetId");
@@ -133,7 +119,7 @@ public class S7DemoController {
}
@PostMapping("/saveFlux1")
public Result<Instant> saveFlux1() throws InterruptedException {
public Result<Instant> saveFlux1() {
List<Event> list = new ArrayList<>();
Event event2 = new Event();
@@ -146,8 +132,9 @@ public class S7DemoController {
InfluxClient.Client.batchInsert(list,"Weight");
return new Result<Instant>().ok(instant);
}
@PostMapping("/saveFlux2")
public void saveFlux2(@RequestBody TIMETest timeTest) throws InterruptedException {
public void saveFlux2(@RequestBody TIMETest timeTest) {
List<Event> list = new ArrayList<>();
Event event2 = new Event();
@@ -209,7 +196,7 @@ public class S7DemoController {
// public void insertAndQuery() throws InterruptedException {
// Event event = new Event();
//
//// long l = System.currentTimeMillis();
// long l = System.currentTimeMillis();
//// System.out.println("l:"+l);
//// event.setTime(new Date(1669874900889l).toInstant());
////

View File

@@ -1,13 +1,9 @@
package com.cnbm.influx.controller;
import com.cnbm.common.spc.util.DataUtils;
import com.cnbm.common.utils.Result;
import com.cnbm.influx.config.InfluxClient;
import com.cnbm.influx.constant.Constant;
import com.cnbm.influx.param.QueryDataParam;
import com.cnbm.influx.param.Range;
import com.cnbm.influx.param.Tag;
import com.cnbm.influx.template.Event;
import com.influxdb.query.FluxTable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -15,8 +11,6 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.Instant;
import java.util.*;
@RestController
@@ -26,7 +20,6 @@ public class SPCController {
@PostMapping("/getData")
public Result getData(@RequestBody QueryDataParam param){
List<FluxTable> query = InfluxClient.Client.query(param);
return new Result<List<FluxTable>>().ok(query);
}