|
|
@@ -54,31 +54,47 @@ public class S7DemoController { |
|
|
|
InfluxClient.Client.batchInsert(list,"Weight"); |
|
|
|
} |
|
|
|
|
|
|
|
public static void main(String[] args) throws InterruptedException { |
|
|
|
long l1 = System.currentTimeMillis(); |
|
|
|
System.out.println(l1); |
|
|
|
Date date = new Date(l1); |
|
|
|
Thread.sleep(1000); |
|
|
|
Date date2 = new Date(l1); |
|
|
|
System.out.println(); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/insertDemoOne") |
|
|
|
public void insertDemoOne() throws InterruptedException { |
|
|
|
List<Event> list = new ArrayList<>(); |
|
|
|
Random r = new Random(); |
|
|
|
Thread.sleep(10); |
|
|
|
Instant time = new Date().toInstant(); |
|
|
|
Event event = new Event(); |
|
|
|
event.setTime(time); |
|
|
|
|
|
|
|
|
|
|
|
Event event = new Event(); |
|
|
|
event.setTime(new Date(1670554110451L).toInstant()); |
|
|
|
event.setArgName("failDayDay"); |
|
|
|
event.setArgValue("1"); |
|
|
|
event.setArgValue("30089"); |
|
|
|
event.setSampleNumber("10001"); |
|
|
|
list.add(event); |
|
|
|
|
|
|
|
Thread.sleep(1000); |
|
|
|
|
|
|
|
Event event2 = new Event(); |
|
|
|
event2.setTime(time); |
|
|
|
|
|
|
|
event2.setTime(new Date(1670555006702L).toInstant()); |
|
|
|
event2.setArgName("failDayDay"); |
|
|
|
event2.setArgValue("2"); |
|
|
|
event2.setArgValue("40088"); |
|
|
|
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 { |
|
|
@@ -95,6 +111,16 @@ public class S7DemoController { |
|
|
|
queryDataParam.setTag(new Tag("argName","failDayDay")); |
|
|
|
queryDataParam.setBucket(Constant.bucket); |
|
|
|
List<FluxTable> query = InfluxClient.Client.query(queryDataParam); |
|
|
|
Instant time = query.get(0).getRecords().get(0).getTime(); |
|
|
|
|
|
|
|
List<Event> list = new ArrayList<>(); |
|
|
|
Event event2 = new Event(); |
|
|
|
event2.setTime(time); |
|
|
|
event2.setArgName("failDayDay"); |
|
|
|
event2.setArgValue("40089"); |
|
|
|
event2.setSampleNumber("10001"); |
|
|
|
list.add(event2); |
|
|
|
InfluxClient.Client.batchInsert(list,"Weight"); |
|
|
|
System.out.println(); |
|
|
|
} |
|
|
|
|
|
|
|