修改判读方案算法

This commit is contained in:
caixiang 2022-12-01 15:33:57 +08:00
parent 8bfcaaf429
commit f7712f184a
3 changed files with 49 additions and 28 deletions

View File

@ -76,21 +76,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);
@ -99,8 +106,11 @@ public enum InfluxClient {
}
//异步 批量写入数据
//如果要批量插入的话一次也只能写入
/**
* desc: 异步批量 写入数据/更新数据
* notes: 如果是更新数据要保证time字段不能改变
* auth: caixaing
* */
public void batchInsert(List<Event> events, String measurement){
List<Point> list = new ArrayList<>();
for(Event event:events){
@ -108,15 +118,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);

View File

@ -103,30 +103,34 @@ public class S7DemoController {
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("2344");
event.setBatchNum("22");
event.setTransationId("4444");
event.setBatchNum("44");
event.setArgName("forUpdate");
event.setArgValue("124.1");
InfluxClient.Client.insert(event,"FORUPDATEEEE");
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("FORUPDATEEEE");
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();
// 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();
}

View File

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