|
|
|
@ -29,8 +29,9 @@ public class S7DemoController {
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(S7DemoController.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/insertBatch")
|
|
|
|
|
public void insertBatch() throws InterruptedException {
|
|
|
|
|
//for 常规计量型
|
|
|
|
|
@PostMapping("/insertDemoDataForMetering")
|
|
|
|
|
public void insertDemoDataForMetering() throws InterruptedException {
|
|
|
|
|
List<Event> list = new ArrayList<>();
|
|
|
|
|
Random r = new Random();
|
|
|
|
|
|
|
|
|
@ -47,17 +48,15 @@ public class S7DemoController {
|
|
|
|
|
}else {
|
|
|
|
|
event.setArgValue("1");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Double d = r.nextDouble() * 2.5 + 66;
|
|
|
|
|
// event.setArgValue(d);
|
|
|
|
|
|
|
|
|
|
list.add(event);
|
|
|
|
|
}
|
|
|
|
|
InfluxClient.Client.batchInsert(list,"Weight");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/forTestInsertBatch")
|
|
|
|
|
public void forTestInsertBatch() throws InterruptedException {
|
|
|
|
|
|
|
|
|
|
//for 常规计数型
|
|
|
|
|
@PostMapping("/insertDemoDataForCount")
|
|
|
|
|
public void insertDemoDataForCount() throws InterruptedException {
|
|
|
|
|
List<Event> list = new ArrayList<>();
|
|
|
|
|
Random r = new Random();
|
|
|
|
|
|
|
|
|
@ -75,199 +74,199 @@ public class S7DemoController {
|
|
|
|
|
}
|
|
|
|
|
InfluxClient.Client.batchInsert(list,"Weight");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/insertBatchJYD")
|
|
|
|
|
public void insertBatchJYD() throws InterruptedException {
|
|
|
|
|
List<Event> list = new ArrayList<>();
|
|
|
|
|
Random r = new Random();
|
|
|
|
|
Instant instant = DataUtils.getBeforeDate(400).toInstant();
|
|
|
|
|
|
|
|
|
|
for(int j=0;j<10;j++){
|
|
|
|
|
for(int i=0;i<99;i++){
|
|
|
|
|
Thread.sleep(10);
|
|
|
|
|
Event event = new Event();
|
|
|
|
|
event.setTime(instant);
|
|
|
|
|
event.setTransationId("asas"+i);
|
|
|
|
|
event.setArgName("LTWeight");
|
|
|
|
|
Double d = r.nextDouble() * 2.5 + 66;
|
|
|
|
|
event.setInspectionSheetId(j+"");
|
|
|
|
|
event.setArgValue(d.toString());
|
|
|
|
|
event.setBatchNum(i+"");
|
|
|
|
|
list.add(event);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
InfluxClient.Client.batchInsert(list,"WeightHei");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/insertAndQuery")
|
|
|
|
|
public void insertAndQuery() throws InterruptedException {
|
|
|
|
|
Event event = new Event();
|
|
|
|
|
|
|
|
|
|
// long l = System.currentTimeMillis();
|
|
|
|
|
// System.out.println("l:"+l);
|
|
|
|
|
// event.setTime(new Date(1669874900889l).toInstant());
|
|
|
|
|
//
|
|
|
|
|
event.setTime(new Date().toInstant());
|
|
|
|
|
event.setTransationId("4444");
|
|
|
|
|
event.setBatchNum("44");
|
|
|
|
|
event.setArgName("forUpdate");
|
|
|
|
|
event.setArgValue("5555.1");
|
|
|
|
|
InfluxClient.Client.insert(event,"FORUPDATECAIXIANG");
|
|
|
|
|
// Thread.sleep(50000);
|
|
|
|
|
// @PostMapping("/insertBatchJYD")
|
|
|
|
|
// public void insertBatchJYD() throws InterruptedException {
|
|
|
|
|
// List<Event> list = new ArrayList<>();
|
|
|
|
|
// Random r = new Random();
|
|
|
|
|
// Instant instant = DataUtils.getBeforeDate(400).toInstant();
|
|
|
|
|
//
|
|
|
|
|
// for(int j=0;j<10;j++){
|
|
|
|
|
// for(int i=0;i<99;i++){
|
|
|
|
|
// Thread.sleep(10);
|
|
|
|
|
// Event event = new Event();
|
|
|
|
|
// event.setTime(instant);
|
|
|
|
|
// event.setTransationId("asas"+i);
|
|
|
|
|
// event.setArgName("LTWeight");
|
|
|
|
|
// Double d = r.nextDouble() * 2.5 + 66;
|
|
|
|
|
// event.setInspectionSheetId(j+"");
|
|
|
|
|
// event.setArgValue(d.toString());
|
|
|
|
|
// event.setBatchNum(i+"");
|
|
|
|
|
// list.add(event);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// InfluxClient.Client.batchInsert(list,"WeightHei");
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// @PostMapping("/insertAndQuery")
|
|
|
|
|
// public void insertAndQuery() throws InterruptedException {
|
|
|
|
|
// Event event = new Event();
|
|
|
|
|
//
|
|
|
|
|
//// long l = System.currentTimeMillis();
|
|
|
|
|
//// System.out.println("l:"+l);
|
|
|
|
|
//// event.setTime(new Date(1669874900889l).toInstant());
|
|
|
|
|
////
|
|
|
|
|
// event.setTime(new Date().toInstant());
|
|
|
|
|
// event.setTransationId("4444");
|
|
|
|
|
// event.setBatchNum("44");
|
|
|
|
|
// event.setArgName("forUpdate");
|
|
|
|
|
// event.setArgValue("5555.1");
|
|
|
|
|
// InfluxClient.Client.insert(event,"FORUPDATECAIXIANG");
|
|
|
|
|
//// Thread.sleep(50000);
|
|
|
|
|
////
|
|
|
|
|
//// event.setArgValue(333.3);
|
|
|
|
|
//// InfluxClient.Client.insert(event,"FORUPDATE");
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//// QueryDataParam queryDataParam = new QueryDataParam();
|
|
|
|
|
//// queryDataParam.setBucket("qgs-bucket");
|
|
|
|
|
//// queryDataParam.setMeasurement("FORUPDATECAIXIANG");
|
|
|
|
|
//// List<String> dropNames = new ArrayList<>();
|
|
|
|
|
//// dropNames.add("transationId");
|
|
|
|
|
//// dropNames.add("inspectionSheetId");
|
|
|
|
|
//// queryDataParam.setDropedTagNames(dropNames);
|
|
|
|
|
//// queryDataParam.setTag(new Tag("argName","forUpdate"));
|
|
|
|
|
//// queryDataParam.setRange(new Range(DataUtils.getBeforeDate(999).toInstant(),DataUtils.getAfterDate(999).toInstant()));
|
|
|
|
|
//// queryDataParam.setPageInfo(new PageInfo(1,10));
|
|
|
|
|
//// List<FluxTable> query = InfluxClient.Client.query(queryDataParam);
|
|
|
|
|
//// System.out.println();
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// @PostMapping("/insertBatchJYDForTest")
|
|
|
|
|
// public void insertBatchJYDForTest() throws InterruptedException {
|
|
|
|
|
// List<Event> list = new ArrayList<>();
|
|
|
|
|
// Random r = new Random();
|
|
|
|
|
//
|
|
|
|
|
// for(int i=0;i<999;i++){
|
|
|
|
|
// Thread.sleep(10);
|
|
|
|
|
// Event event = new Event();
|
|
|
|
|
// event.setTime(DataUtils.getAfterDate(i).toInstant());
|
|
|
|
|
// event.setTransationId("asas"+i);
|
|
|
|
|
// event.setArgName("LostDays");
|
|
|
|
|
// int i1 = r.nextInt(10);
|
|
|
|
|
// if(i1<4){
|
|
|
|
|
// event.setArgValue("0");
|
|
|
|
|
// }else {
|
|
|
|
|
// event.setArgValue("1");
|
|
|
|
|
// }
|
|
|
|
|
// event.setInspectionSheetId(i+"");
|
|
|
|
|
//
|
|
|
|
|
// event.setBatchNum(i+"");
|
|
|
|
|
// list.add(event);
|
|
|
|
|
// }
|
|
|
|
|
// InfluxClient.Client.batchInsert(list,"Weights");
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// @PostMapping("/insertBatchForNew")
|
|
|
|
|
// public void insertBatchForNew() throws InterruptedException {
|
|
|
|
|
// List<Event> list = new ArrayList<>();
|
|
|
|
|
// Random r = new Random();
|
|
|
|
|
//
|
|
|
|
|
// for(int i=0;i<999;i++){
|
|
|
|
|
// Thread.sleep(10);
|
|
|
|
|
// Event event = new Event();
|
|
|
|
|
// event.setTime(new Date().toInstant());
|
|
|
|
|
// event.setTransationId("asas"+i);
|
|
|
|
|
// event.setArgName("LiuWeight");
|
|
|
|
|
//// int i1 = r.nextInt(10);
|
|
|
|
|
//// if(i1<4){
|
|
|
|
|
//// event.setArgValue(new Double(0));
|
|
|
|
|
//// }else {
|
|
|
|
|
//// event.setArgValue(new Double(1));
|
|
|
|
|
//// }
|
|
|
|
|
// Double d = r.nextDouble() * 2.5 + 66;
|
|
|
|
|
// event.setArgValue(d.toString());
|
|
|
|
|
// event.setInspectionSheetId(i+"");
|
|
|
|
|
//
|
|
|
|
|
// event.setBatchNum(i+"");
|
|
|
|
|
// list.add(event);
|
|
|
|
|
// }
|
|
|
|
|
// InfluxClient.Client.batchInsert(list,"Weights");
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * 测试连接是否正常
|
|
|
|
|
// *
|
|
|
|
|
// * @return
|
|
|
|
|
// * true 服务正常健康
|
|
|
|
|
// * false 异常
|
|
|
|
|
// */
|
|
|
|
|
// @PostMapping("/ping")
|
|
|
|
|
// public void ping() throws InterruptedException {
|
|
|
|
|
// boolean ping = InfluxClient.Client.ping();
|
|
|
|
|
// System.out.println(ping);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// @PostMapping("/query")
|
|
|
|
|
// public void query() throws InterruptedException {
|
|
|
|
|
// List<Event> list = new ArrayList<>();
|
|
|
|
|
//
|
|
|
|
|
// event.setArgValue(333.3);
|
|
|
|
|
// InfluxClient.Client.insert(event,"FORUPDATE");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// QueryDataParam queryDataParam = new QueryDataParam();
|
|
|
|
|
// queryDataParam.setBucket("qgs-bucket");
|
|
|
|
|
// queryDataParam.setMeasurement("FORUPDATECAIXIANG");
|
|
|
|
|
// queryDataParam.setMeasurement("ASProcessCompleteEventAS");
|
|
|
|
|
// List<String> dropNames = new ArrayList<>();
|
|
|
|
|
// dropNames.add("transationId");
|
|
|
|
|
// dropNames.add("inspectionSheetId");
|
|
|
|
|
// queryDataParam.setDropedTagNames(dropNames);
|
|
|
|
|
// queryDataParam.setTag(new Tag("argName","forUpdate"));
|
|
|
|
|
// queryDataParam.setRange(new Range(DataUtils.getBeforeDate(999).toInstant(),DataUtils.getAfterDate(999).toInstant()));
|
|
|
|
|
// queryDataParam.setTag(new Tag("argName","arg6"));
|
|
|
|
|
// queryDataParam.setRange(new Range(DataUtils.getBeforeDate(10).toInstant(),Instant.now()));
|
|
|
|
|
// queryDataParam.setPageInfo(new PageInfo(1,10));
|
|
|
|
|
// List<FluxTable> query = InfluxClient.Client.query(queryDataParam);
|
|
|
|
|
// System.out.println();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/insertBatchJYDForTest")
|
|
|
|
|
public void insertBatchJYDForTest() throws InterruptedException {
|
|
|
|
|
List<Event> list = new ArrayList<>();
|
|
|
|
|
Random r = new Random();
|
|
|
|
|
|
|
|
|
|
for(int i=0;i<999;i++){
|
|
|
|
|
Thread.sleep(10);
|
|
|
|
|
Event event = new Event();
|
|
|
|
|
event.setTime(DataUtils.getAfterDate(i).toInstant());
|
|
|
|
|
event.setTransationId("asas"+i);
|
|
|
|
|
event.setArgName("LostDays");
|
|
|
|
|
int i1 = r.nextInt(10);
|
|
|
|
|
if(i1<4){
|
|
|
|
|
event.setArgValue("0");
|
|
|
|
|
}else {
|
|
|
|
|
event.setArgValue("1");
|
|
|
|
|
}
|
|
|
|
|
event.setInspectionSheetId(i+"");
|
|
|
|
|
|
|
|
|
|
event.setBatchNum(i+"");
|
|
|
|
|
list.add(event);
|
|
|
|
|
}
|
|
|
|
|
InfluxClient.Client.batchInsert(list,"Weights");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/insertBatchForNew")
|
|
|
|
|
public void insertBatchForNew() throws InterruptedException {
|
|
|
|
|
List<Event> list = new ArrayList<>();
|
|
|
|
|
Random r = new Random();
|
|
|
|
|
|
|
|
|
|
for(int i=0;i<999;i++){
|
|
|
|
|
Thread.sleep(10);
|
|
|
|
|
Event event = new Event();
|
|
|
|
|
event.setTime(new Date().toInstant());
|
|
|
|
|
event.setTransationId("asas"+i);
|
|
|
|
|
event.setArgName("LiuWeight");
|
|
|
|
|
// int i1 = r.nextInt(10);
|
|
|
|
|
// if(i1<4){
|
|
|
|
|
// event.setArgValue(new Double(0));
|
|
|
|
|
// }else {
|
|
|
|
|
// event.setArgValue(new Double(1));
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// for (FluxTable fluxTable : query) {
|
|
|
|
|
// List<FluxRecord> records = fluxTable.getRecords();
|
|
|
|
|
// for (FluxRecord fluxRecord : records) {
|
|
|
|
|
// System.out.println("value: " + fluxRecord.getValueByKey("_value"));
|
|
|
|
|
// }
|
|
|
|
|
Double d = r.nextDouble() * 2.5 + 66;
|
|
|
|
|
event.setArgValue(d.toString());
|
|
|
|
|
event.setInspectionSheetId(i+"");
|
|
|
|
|
|
|
|
|
|
event.setBatchNum(i+"");
|
|
|
|
|
list.add(event);
|
|
|
|
|
}
|
|
|
|
|
InfluxClient.Client.batchInsert(list,"Weights");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 测试连接是否正常
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
* true 服务正常健康
|
|
|
|
|
* false 异常
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/ping")
|
|
|
|
|
public void ping() throws InterruptedException {
|
|
|
|
|
boolean ping = InfluxClient.Client.ping();
|
|
|
|
|
System.out.println(ping);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/query")
|
|
|
|
|
public void query() throws InterruptedException {
|
|
|
|
|
List<Event> list = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
QueryDataParam queryDataParam = new QueryDataParam();
|
|
|
|
|
queryDataParam.setBucket("qgs-bucket");
|
|
|
|
|
queryDataParam.setMeasurement("ASProcessCompleteEventAS");
|
|
|
|
|
List<String> dropNames = new ArrayList<>();
|
|
|
|
|
dropNames.add("transationId");
|
|
|
|
|
dropNames.add("inspectionSheetId");
|
|
|
|
|
queryDataParam.setDropedTagNames(dropNames);
|
|
|
|
|
queryDataParam.setTag(new Tag("argName","arg6"));
|
|
|
|
|
queryDataParam.setRange(new Range(DataUtils.getBeforeDate(10).toInstant(),Instant.now()));
|
|
|
|
|
queryDataParam.setPageInfo(new PageInfo(1,10));
|
|
|
|
|
List<FluxTable> query = InfluxClient.Client.query(queryDataParam);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (FluxTable fluxTable : query) {
|
|
|
|
|
List<FluxRecord> records = fluxTable.getRecords();
|
|
|
|
|
for (FluxRecord fluxRecord : records) {
|
|
|
|
|
System.out.println("value: " + fluxRecord.getValueByKey("_value"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
System.out.println();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
List<Event> list = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
QueryDataParam queryDataParam = new QueryDataParam();
|
|
|
|
|
queryDataParam.setBucket("qgs-bucket");
|
|
|
|
|
queryDataParam.setMeasurement("ASProcessCompleteEventAS");
|
|
|
|
|
List<String> dropNames = new ArrayList<>();
|
|
|
|
|
dropNames.add("transationId");
|
|
|
|
|
dropNames.add("inspectionSheetId");
|
|
|
|
|
queryDataParam.setDropedTagNames(dropNames);
|
|
|
|
|
queryDataParam.setTag(new Tag("argName","arg7"));
|
|
|
|
|
queryDataParam.setRange(new Range(DataUtils.getBeforeDate(10).toInstant(),Instant.now()));
|
|
|
|
|
queryDataParam.setPageInfo(new PageInfo(2,10));
|
|
|
|
|
List<FluxTable> query = InfluxClient.Client.query(queryDataParam);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (FluxTable fluxTable : query) {
|
|
|
|
|
List<FluxRecord> records = fluxTable.getRecords();
|
|
|
|
|
for (FluxRecord fluxRecord : records) {
|
|
|
|
|
System.out.println("value: " + fluxRecord.getValueByKey("_value"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Point insert(Event event, String measurement){
|
|
|
|
|
Point point = Point.measurement(measurement)
|
|
|
|
|
.addTag("transationId", event.getTransationId())
|
|
|
|
|
.addTag("argName", event.getArgName())
|
|
|
|
|
.addField("argValue", event.getArgValue())
|
|
|
|
|
.time(event.getTime().toEpochMilli(), WritePrecision.MS);
|
|
|
|
|
return point;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/insert")
|
|
|
|
|
public void insert() throws InterruptedException {
|
|
|
|
|
Event event = new Event();
|
|
|
|
|
event.setTime(Instant.now());
|
|
|
|
|
event.setTransationId("asasd11");
|
|
|
|
|
event.setArgName("argName11");
|
|
|
|
|
event.setArgValue("900001");
|
|
|
|
|
Point asProcessCompleteEvent = insert(event, "ASProcessCompleteEvent");
|
|
|
|
|
InfluxClient.Client.insert(event,"ASProcessCompleteEvent");
|
|
|
|
|
}
|
|
|
|
|
// }
|
|
|
|
|
// System.out.println();
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// public static void main(String[] args) {
|
|
|
|
|
// List<Event> list = new ArrayList<>();
|
|
|
|
|
//
|
|
|
|
|
// QueryDataParam queryDataParam = new QueryDataParam();
|
|
|
|
|
// queryDataParam.setBucket("qgs-bucket");
|
|
|
|
|
// queryDataParam.setMeasurement("ASProcessCompleteEventAS");
|
|
|
|
|
// List<String> dropNames = new ArrayList<>();
|
|
|
|
|
// dropNames.add("transationId");
|
|
|
|
|
// dropNames.add("inspectionSheetId");
|
|
|
|
|
// queryDataParam.setDropedTagNames(dropNames);
|
|
|
|
|
// queryDataParam.setTag(new Tag("argName","arg7"));
|
|
|
|
|
// queryDataParam.setRange(new Range(DataUtils.getBeforeDate(10).toInstant(),Instant.now()));
|
|
|
|
|
// queryDataParam.setPageInfo(new PageInfo(2,10));
|
|
|
|
|
// List<FluxTable> query = InfluxClient.Client.query(queryDataParam);
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// for (FluxTable fluxTable : query) {
|
|
|
|
|
// List<FluxRecord> records = fluxTable.getRecords();
|
|
|
|
|
// for (FluxRecord fluxRecord : records) {
|
|
|
|
|
// System.out.println("value: " + fluxRecord.getValueByKey("_value"));
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// public Point insert(Event event, String measurement){
|
|
|
|
|
// Point point = Point.measurement(measurement)
|
|
|
|
|
// .addTag("transationId", event.getTransationId())
|
|
|
|
|
// .addTag("argName", event.getArgName())
|
|
|
|
|
// .addField("argValue", event.getArgValue())
|
|
|
|
|
// .time(event.getTime().toEpochMilli(), WritePrecision.MS);
|
|
|
|
|
// return point;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// @PostMapping("/insert")
|
|
|
|
|
// public void insert() throws InterruptedException {
|
|
|
|
|
// Event event = new Event();
|
|
|
|
|
// event.setTime(Instant.now());
|
|
|
|
|
// event.setTransationId("asasd11");
|
|
|
|
|
// event.setArgName("argName11");
|
|
|
|
|
// event.setArgValue("900001");
|
|
|
|
|
// Point asProcessCompleteEvent = insert(event, "ASProcessCompleteEvent");
|
|
|
|
|
// InfluxClient.Client.insert(event,"ASProcessCompleteEvent");
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|