This commit is contained in:
于连琛 2022-10-18 09:23:00 +08:00
parent 89f6ccac9a
commit 0dfff37b3d

View File

@ -33,98 +33,98 @@ public class InfluxController {
private static final Logger logger = LoggerFactory.getLogger(InfluxController.class); private static final Logger logger = LoggerFactory.getLogger(InfluxController.class);
//
//
@PostMapping("/insertBatch") // @PostMapping("/insertBatch")
public void insertBatch() throws InterruptedException { // public void insertBatch() throws InterruptedException {
List<Event> list = new ArrayList<>(); // List<Event> list = new ArrayList<>();
Random r = new Random(); // Random r = new Random();
//
for(int i=0;i<999;i++){ // for(int i=0;i<999;i++){
Thread.sleep(10); // Thread.sleep(10);
Event event = new Event(); // Event event = new Event();
event.setTime(Instant.now()); // event.setTime(Instant.now());
event.setTransationId("asas"+i); // event.setTransationId("asas"+i);
event.setArgName("LTWeight"); // event.setArgName("LTWeight");
Double d = r.nextDouble() * 2.5 + 66; // Double d = r.nextDouble() * 2.5 + 66;
event.setArgValue(d); // event.setArgValue(d);
//
list.add(event); // list.add(event);
} // }
InfluxClient.Client.batchInsert(list,"Weight"); // InfluxClient.Client.batchInsert(list,"Weight");
} // }
//
@PostMapping("/forTestInsertBatch") // @PostMapping("/forTestInsertBatch")
public void forTestInsertBatch() throws InterruptedException { // public void forTestInsertBatch() throws InterruptedException {
List<Event> list = new ArrayList<>(); // List<Event> list = new ArrayList<>();
Random r = new Random(); // Random r = new Random();
for(int i=0;i<99;i++){ // for(int i=0;i<99;i++){
Thread.sleep(10); // Thread.sleep(10);
Event event = new Event(); // Event event = new Event();
event.setTime(Instant.now()); // event.setTime(Instant.now());
event.setTransationId("forbatch"+i); // event.setTransationId("forbatch"+i);
event.setArgName("LTWeight"); // event.setArgName("LTWeight");
Double d = r.nextDouble() * 2.5 + 66; // Double d = r.nextDouble() * 2.5 + 66;
event.setArgValue(d); // event.setArgValue(d);
event.setBatchNum(4); // event.setBatchNum(4);
event.setInspectionSheetId(i+""); // event.setInspectionSheetId(i+"");
list.add(event); // list.add(event);
} // }
InfluxClient.Client.batchInsert(list,"Weight"); // InfluxClient.Client.batchInsert(list,"Weight");
} // }
//
//
//
//
@PostMapping("/insertBatchJYD") // @PostMapping("/insertBatchJYD")
public void insertBatchJYD() throws InterruptedException { // public void insertBatchJYD() throws InterruptedException {
List<Event> list = new ArrayList<>(); // List<Event> list = new ArrayList<>();
Random r = new Random(); // Random r = new Random();
Instant instant = DataUtils.getBeforeDate(400).toInstant(); // Instant instant = DataUtils.getBeforeDate(400).toInstant();
//
for(int j=0;j<10;j++){ // for(int j=0;j<10;j++){
for(int i=0;i<99;i++){ // for(int i=0;i<99;i++){
Thread.sleep(10); // Thread.sleep(10);
Event event = new Event(); // Event event = new Event();
event.setTime(instant); // event.setTime(instant);
event.setTransationId("asas"+i); // event.setTransationId("asas"+i);
event.setArgName("LTWeight"); // event.setArgName("LTWeight");
Double d = r.nextDouble() * 2.5 + 66; // Double d = r.nextDouble() * 2.5 + 66;
event.setInspectionSheetId(j+""); // event.setInspectionSheetId(j+"");
event.setArgValue(d); // event.setArgValue(d);
event.setBatchNum(i); // event.setBatchNum(i);
list.add(event); // list.add(event);
} // }
} // }
InfluxClient.Client.batchInsert(list,"WeightHei"); // InfluxClient.Client.batchInsert(list,"WeightHei");
} // }
//
//
//
@PostMapping("/insertBatchJYDForTest") // @PostMapping("/insertBatchJYDForTest")
public void insertBatchJYDForTest() throws InterruptedException { // public void insertBatchJYDForTest() throws InterruptedException {
List<Event> list = new ArrayList<>(); // List<Event> list = new ArrayList<>();
Random r = new Random(); // Random r = new Random();
//
for(int i=0;i<999;i++){ // for(int i=0;i<999;i++){
Thread.sleep(10); // Thread.sleep(10);
Event event = new Event(); // Event event = new Event();
event.setTime(DataUtils.getAfterDate(i).toInstant()); // event.setTime(DataUtils.getAfterDate(i).toInstant());
event.setTransationId("asas"+i); // event.setTransationId("asas"+i);
event.setArgName("LostDays"); // event.setArgName("LostDays");
int i1 = r.nextInt(10); // int i1 = r.nextInt(10);
// if(i1<4){ //// if(i1<4){
// event.setArgValue(new Double(0)); //// event.setArgValue(new Double(0));
// }else { //// }else {
// event.setArgValue(new Double(1)); //// event.setArgValue(new Double(1));
//// }
// event.setInspectionSheetId(i+"");
//
// event.setBatchNum(i);
// list.add(event);
// }
// InfluxClient.Client.batchInsert(list,"WeightHeiHei");
// } // }
event.setInspectionSheetId(i+"");
event.setBatchNum(i);
list.add(event);
}
InfluxClient.Client.batchInsert(list,"WeightHeiHei");
}
/** /**
* 测试连接是否正常 * 测试连接是否正常
@ -207,7 +207,7 @@ public class InfluxController {
event.setTime(Instant.now()); event.setTime(Instant.now());
event.setTransationId("asasd11"); event.setTransationId("asasd11");
event.setArgName("argName11"); event.setArgName("argName11");
event.setArgValue(900001d); event.setArgValue("900001");
Point asProcessCompleteEvent = insert(event, "ASProcessCompleteEvent"); Point asProcessCompleteEvent = insert(event, "ASProcessCompleteEvent");
InfluxClient.Client.insert(event,"ASProcessCompleteEvent"); InfluxClient.Client.insert(event,"ASProcessCompleteEvent");
} }