mark for pull

This commit is contained in:
caixiang 2022-12-01 15:33:37 +08:00
vanhempi 183dcf7d48
commit f00b1fe530
2 muutettua tiedostoa jossa 33 lisäystä ja 22 poistoa

Näytä tiedosto

@ -80,20 +80,28 @@ public enum InfluxClient {
return isConnected;
}
/**
* desc: 异步批量 写入数据/更新数据
* notes: 如果是更新数据要保证time字段不能改变
* auth: caixaing
* */
public void insert(Event event, String measurement){
Point point = null;
if(event.getBatchNum()==null){
point = Point.measurement(measurement)
.addTag("transationId", event.getTransationId())
.addTag("inspectionSheetId", event.getInspectionSheetId())
.addTag("argName", event.getArgName())
.addField("argValue", event.getArgValue())
.time(event.getTime().toEpochMilli(), WritePrecision.MS);
}else {
point = Point.measurement(measurement)
.addTag("transationId", event.getTransationId())
//.addTag("inspectionSheetId", event.getInspectionSheetId())
.addTag("batchNum", event.getBatchNum().toString())
.addTag("inspectionSheetId", event.getInspectionSheetId())
.addTag("sampleNumber", event.getSampleNumber())
.addTag("batchNum", event.getBatchNum())
.addTag("argName", event.getArgName())
.addField("argValue", event.getArgValue())
.time(event.getTime().toEpochMilli(), WritePrecision.MS);
@ -102,20 +110,11 @@ public enum InfluxClient {
}
//异步 批量写入数据
//如果要批量插入的话一次也只能写入
// public void batchInsert(List<Event> events, String measurement){
// List<Point> list = new ArrayList<>();
// for(Event event:events){
// Point point = Point.measurement(measurement)
// .addTag("transationId", event.getTransationId())
// .addTag("argName", event.getArgName())
// .addField("argValue", event.getArgValue())
// .time(event.getTime().toEpochMilli(), WritePrecision.MS);
// list.add(point);
// }
// writeApi.writePoints(list);
// }
/**
* desc: 异步批量 写入数据/更新数据
* notes: 如果是更新数据要保证time字段不能改变
* auth: caixaing
* */
public void batchInsert(List<Event> events, String measurement){
List<Point> list = new ArrayList<>();
for(Event event:events){
@ -123,15 +122,17 @@ public enum InfluxClient {
if(event.getBatchNum()==null){
point = Point.measurement(measurement)
.addTag("transationId", event.getTransationId())
.addTag("inspectionSheetId", event.getInspectionSheetId())
.addTag("argName", event.getArgName())
.addField("argValue", event.getArgValue())
.time(event.getTime().toEpochMilli(), WritePrecision.MS);
}else {
point = Point.measurement(measurement)
.addTag("transationId", event.getTransationId())
//.addTag("inspectionSheetId", event.getInspectionSheetId())
.addTag("batchNum", event.getBatchNum().toString())
.addTag("inspectionSheetId", event.getInspectionSheetId())
.addTag("sampleNumber", event.getSampleNumber())
.addTag("batchNum", event.getBatchNum())
.addTag("argName", event.getArgName())
.addField("argValue", event.getArgValue())
.time(event.getTime().toEpochMilli(), WritePrecision.MS);

Näytä tiedosto

@ -20,9 +20,19 @@ public class Event {
private String argValue;
private String BatchNum;
//batchNumber必填 作为区分 手动录入 自动录入的区别
private String batchNum;
private String InspectionSheetId;
private String inspectionSheetId;
private String sampleNumber;
public Event() {
//自动录入给个默认值
this.batchNum = "-1";
this.inspectionSheetId = "-1";
this.sampleNumber = "-1";
}
}