修改 influxdb query函数

This commit is contained in:
caixiang 2022-12-08 15:28:10 +08:00
parent 2d9b0ea1f1
commit b93869c4a1
15 changed files with 69 additions and 48 deletions

View File

@ -124,10 +124,11 @@ public enum InfluxClient {
}else { }else {
point = Point.measurement(measurement) point = Point.measurement(measurement)
.addTag("transationId", event.getTransationId()) .addTag("transationId", event.getTransationId())
.addTag("inspectionSheetId", event.getInspectionSheetId()) .addTag("inspectionSheetId", event.getInspectionSheetId())
// .addTag("batchNum", event.getBatchNum())
.addTag("sampleNumber", event.getSampleNumber()) .addTag("sampleNumber", event.getSampleNumber())
.addTag("batchNum", event.getBatchNum()) .addField("batchNum", event.getBatchNum())
.addTag("argName", event.getArgName()) .addTag("argName", event.getArgName())
.addField("argValue", event.getArgValue()) .addField("argValue", event.getArgValue())
@ -146,9 +147,6 @@ public enum InfluxClient {
List<String> dropedTagNames = param.getDropedTagNames(); List<String> dropedTagNames = param.getDropedTagNames();
Range range = param.getRange(); Range range = param.getRange();
String bucket = param.getBucket(); String bucket = param.getBucket();
PageInfo pageInfo = param.getPageInfo(); PageInfo pageInfo = param.getPageInfo();
String flux = "from(bucket:\""+bucket+"\")"; String flux = "from(bucket:\""+bucket+"\")";
@ -162,7 +160,9 @@ public enum InfluxClient {
} }
//调整时区查询出的结果 +8个小时 //调整时区查询出的结果 +8个小时
flux += "|> timeShift(duration: 8h)"; //flux += "|> timeShift(duration: 8h)";
for(String dropName:dropedTagNames){ for(String dropName:dropedTagNames){
flux += "|> drop(columns: [\""+dropName+"\"])"; flux += "|> drop(columns: [\""+dropName+"\"])";
} }

View File

@ -53,6 +53,31 @@ public class S7DemoController {
InfluxClient.Client.batchInsert(list,"Weight"); InfluxClient.Client.batchInsert(list,"Weight");
} }
@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.setTransationId("asas123");
event.setArgName("failDayDay");
event.setArgValue("1");
list.add(event);
Thread.sleep(1000);
Event event2 = new Event();
event2.setTime(time);
event2.setTransationId("asas456");
event2.setArgName("failDayDay");
event2.setArgValue("2");
list.add(event2);
InfluxClient.Client.batchInsert(list,"Weight");
}
//for 常规计数型 //for 常规计数型
@PostMapping("/insertDemoDataForCount") @PostMapping("/insertDemoDataForCount")

View File

@ -208,7 +208,6 @@ public class ProcessInspectionController {
NPGraphData npGraph1 = new NPGraphData( NPGraphData npGraph1 = new NPGraphData(
npGraph.getList()==null?null:npGraph.getList(), npGraph.getList()==null?null:npGraph.getList(),
npGraph.getSpecificationLimit()==null?null:npGraph.getSpecificationLimit(),
npGraph.getArgName()==null?null:npGraph.getArgName() npGraph.getArgName()==null?null:npGraph.getArgName()
); );
@ -233,7 +232,6 @@ public class ProcessInspectionController {
PGraphData npGraph1 = new PGraphData( PGraphData npGraph1 = new PGraphData(
pGraph.getList()==null?null:pGraph.getList(), pGraph.getList()==null?null:pGraph.getList(),
pGraph.getSpecificationLimit()==null?null:pGraph.getSpecificationLimit(),
pGraph.getArgName()==null?null:pGraph.getArgName() pGraph.getArgName()==null?null:pGraph.getArgName()
); );
@ -260,7 +258,6 @@ public class ProcessInspectionController {
CGraphData npGraph1 = new CGraphData( CGraphData npGraph1 = new CGraphData(
cGraph.getList()==null?null:cGraph.getList(), cGraph.getList()==null?null:cGraph.getList(),
cGraph.getSpecificationLimit()==null?null:cGraph.getSpecificationLimit(),
cGraph.getArgName()==null?null:cGraph.getArgName() cGraph.getArgName()==null?null:cGraph.getArgName()
); );
@ -286,7 +283,6 @@ public class ProcessInspectionController {
UGraphData npGraph1 = new UGraphData( UGraphData npGraph1 = new UGraphData(
uGraph.getList()==null?null:uGraph.getList(), uGraph.getList()==null?null:uGraph.getList(),
uGraph.getSpecificationLimit()==null?null:uGraph.getSpecificationLimit(),
uGraph.getArgName()==null?null:uGraph.getArgName() uGraph.getArgName()==null?null:uGraph.getArgName()
); );
@ -413,7 +409,6 @@ public class ProcessInspectionController {
NPGraphData npGraph1 = new NPGraphData( NPGraphData npGraph1 = new NPGraphData(
npGraph.getList()==null?null:npGraph.getList(), npGraph.getList()==null?null:npGraph.getList(),
npGraph.getSpecificationLimit()==null?null:npGraph.getSpecificationLimit(),
npGraph.getArgName()==null?null:npGraph.getArgName() npGraph.getArgName()==null?null:npGraph.getArgName()
); );
return R.ok("成功",npGraph1); return R.ok("成功",npGraph1);
@ -434,7 +429,6 @@ public class ProcessInspectionController {
PGraphData npGraph1 = new PGraphData( PGraphData npGraph1 = new PGraphData(
pGraph.getList()==null?null:pGraph.getList(), pGraph.getList()==null?null:pGraph.getList(),
pGraph.getSpecificationLimit()==null?null:pGraph.getSpecificationLimit(),
pGraph.getArgName()==null?null:pGraph.getArgName() pGraph.getArgName()==null?null:pGraph.getArgName()
); );
return R.ok("成功",npGraph1); return R.ok("成功",npGraph1);
@ -454,7 +448,6 @@ public class ProcessInspectionController {
CGraphData npGraph1 = new CGraphData( CGraphData npGraph1 = new CGraphData(
cGraph.getList()==null?null:cGraph.getList(), cGraph.getList()==null?null:cGraph.getList(),
cGraph.getSpecificationLimit()==null?null:cGraph.getSpecificationLimit(),
cGraph.getArgName()==null?null:cGraph.getArgName() cGraph.getArgName()==null?null:cGraph.getArgName()
); );
return R.ok("成功",npGraph1); return R.ok("成功",npGraph1);
@ -475,7 +468,6 @@ public class ProcessInspectionController {
UGraphData uGraphData = new UGraphData( UGraphData uGraphData = new UGraphData(
uGraph.getList()==null?null:uGraph.getList(), uGraph.getList()==null?null:uGraph.getList(),
uGraph.getSpecificationLimit()==null?null:uGraph.getSpecificationLimit(),
uGraph.getArgName()==null?null:uGraph.getArgName() uGraph.getArgName()==null?null:uGraph.getArgName()
); );
return R.ok("成功",uGraphData); return R.ok("成功",uGraphData);

View File

@ -17,16 +17,17 @@ import java.util.List;
@Data @Data
@ApiModel(value = "C控制图 结果类") @ApiModel(value = "C控制图 结果类")
public class CGraphData { public class CGraphData {
@ApiModelProperty(value = "P控制图list数据") @ApiModelProperty(value = "C控制图list数据")
private List<CPoint> list; private List<CPoint> list;
@ApiModelProperty(value = "P控制图 规格线") //计数类参数不需要显示规格线
private SpecificationLimit specificationLimit; // @ApiModelProperty(value = "C控制图 规格线")
@ApiModelProperty(value = "P控制图 参数名") // private SpecificationLimit specificationLimit;
@ApiModelProperty(value = "C控制图 参数名")
private String argName; private String argName;
public CGraphData(List<CPoint> list, SpecificationLimit specificationLimit, String argName) { public CGraphData(List<CPoint> list, String argName) {
this.list = list; this.list = list;
this.specificationLimit = specificationLimit; // this.specificationLimit = specificationLimit;
this.argName = argName; this.argName = argName;
} }
} }

View File

@ -22,14 +22,14 @@ import java.util.List;
public class NPGraphData { public class NPGraphData {
@ApiModelProperty(value = "NP控制图list数据") @ApiModelProperty(value = "NP控制图list数据")
private List<NPPoint> list; private List<NPPoint> list;
@ApiModelProperty(value = "NP控制图 规格线") // @ApiModelProperty(value = "NP控制图 规格线")
private SpecificationLimit specificationLimit; // private SpecificationLimit specificationLimit;
@ApiModelProperty(value = "NP控制图 参数名") @ApiModelProperty(value = "NP控制图 参数名")
private String argName; private String argName;
public NPGraphData(List<NPPoint> list, SpecificationLimit specificationLimit, String argName) { public NPGraphData(List<NPPoint> list, String argName) {
this.list = list; this.list = list;
this.specificationLimit = specificationLimit; // this.specificationLimit = specificationLimit;
this.argName = argName; this.argName = argName;
} }
} }

View File

@ -19,14 +19,14 @@ import java.util.List;
public class PGraphData { public class PGraphData {
@ApiModelProperty(value = "P控制图list数据") @ApiModelProperty(value = "P控制图list数据")
private List<PPoint> list; private List<PPoint> list;
@ApiModelProperty(value = "P控制图 规格线") // @ApiModelProperty(value = "P控制图 规格线")
private SpecificationLimit specificationLimit; // private SpecificationLimit specificationLimit;
@ApiModelProperty(value = "P控制图 参数名") @ApiModelProperty(value = "P控制图 参数名")
private String argName; private String argName;
public PGraphData(List<PPoint> list, SpecificationLimit specificationLimit, String argName) { public PGraphData(List<PPoint> list, String argName) {
this.list = list; this.list = list;
this.specificationLimit = specificationLimit; // this.specificationLimit = specificationLimit;
this.argName = argName; this.argName = argName;
} }
} }

View File

@ -19,14 +19,14 @@ import java.util.List;
public class UGraphData { public class UGraphData {
@ApiModelProperty(value = "U控制图list数据") @ApiModelProperty(value = "U控制图list数据")
private List<UPoint> list; private List<UPoint> list;
@ApiModelProperty(value = "U控制图 规格线") // @ApiModelProperty(value = "U控制图 规格线")
private SpecificationLimit specificationLimit; // private SpecificationLimit specificationLimit;
@ApiModelProperty(value = "U控制图 参数名") @ApiModelProperty(value = "U控制图 参数名")
private String argName; private String argName;
public UGraphData(List<UPoint> list, SpecificationLimit specificationLimit, String argName) { public UGraphData(List<UPoint> list, String argName) {
this.list = list; this.list = list;
this.specificationLimit = specificationLimit; //this.specificationLimit = specificationLimit;
this.argName = argName; this.argName = argName;
} }
} }

View File

@ -8,6 +8,7 @@ import com.cnbm.influx.param.QueryDataGroupByTimeParam;
import com.cnbm.influx.param.Tag; import com.cnbm.influx.param.Tag;
import com.cnbm.qualityPlanning.entity.CPoint; import com.cnbm.qualityPlanning.entity.CPoint;
import com.cnbm.qualityPlanning.entity.ControlLimit; import com.cnbm.qualityPlanning.entity.ControlLimit;
import com.cnbm.qualityPlanning.entity.ControlLimitDetail;
import com.cnbm.qualityPlanning.entity.SpecificationLimit; import com.cnbm.qualityPlanning.entity.SpecificationLimit;
import com.influxdb.query.FluxRecord; import com.influxdb.query.FluxRecord;
import com.influxdb.query.FluxTable; import com.influxdb.query.FluxTable;
@ -139,11 +140,11 @@ public class CGraph {
* desc: get Xbar控制图 的控制限 * desc: get Xbar控制图 的控制限
* 注意此函数 要在 initialDate()函数执行之后 * 注意此函数 要在 initialDate()函数执行之后
* */ * */
public ControlLimit getCL(){ public ControlLimitDetail getCL(){
Double mul = 3 * Math.sqrt( this.cbar ); Double mul = 3 * Math.sqrt( this.cbar );
Double lcl = (this.cbar-mul)<0?0:(this.cbar-mul); Double lcl = (this.cbar-mul)<0?0:(this.cbar-mul);
return new ControlLimit( return new ControlLimitDetail(
this.cbar + mul, this.cbar + mul,
this.cbar, this.cbar,
lcl lcl

View File

@ -136,11 +136,11 @@ public class NPGraph {
* desc: get Xbar控制图 的控制限 * desc: get Xbar控制图 的控制限
* 注意此函数 要在 initialDate()函数执行之后 * 注意此函数 要在 initialDate()函数执行之后
* */ * */
public ControlLimit getCL(Double n){ public ControlLimitDetail getCL(Double n){
Double npbar = n * this.pbar; Double npbar = n * this.pbar;
Double mul = 3 * Math.sqrt(npbar*(1-this.pbar)); Double mul = 3 * Math.sqrt(npbar*(1-this.pbar));
Double lcl = (npbar-mul)<0?0:(npbar-mul); Double lcl = (npbar-mul)<0?0:(npbar-mul);
return new ControlLimit( return new ControlLimitDetail(
npbar + mul, npbar + mul,
npbar, npbar,
lcl lcl

View File

@ -7,6 +7,7 @@ import com.cnbm.influx.constant.Constant;
import com.cnbm.influx.param.QueryDataGroupByTimeParam; import com.cnbm.influx.param.QueryDataGroupByTimeParam;
import com.cnbm.influx.param.Tag; import com.cnbm.influx.param.Tag;
import com.cnbm.qualityPlanning.entity.ControlLimit; import com.cnbm.qualityPlanning.entity.ControlLimit;
import com.cnbm.qualityPlanning.entity.ControlLimitDetail;
import com.cnbm.qualityPlanning.entity.PPoint; import com.cnbm.qualityPlanning.entity.PPoint;
import com.cnbm.qualityPlanning.entity.SpecificationLimit; import com.cnbm.qualityPlanning.entity.SpecificationLimit;
import com.influxdb.query.FluxRecord; import com.influxdb.query.FluxRecord;
@ -148,11 +149,11 @@ public class PGraph {
* desc: get Xbar控制图 的控制限 * desc: get Xbar控制图 的控制限
* 注意此函数 要在 initialDate()函数执行之后 * 注意此函数 要在 initialDate()函数执行之后
* */ * */
public ControlLimit getCL(Double n){ public ControlLimitDetail getCL(Double n){
Double mul = 3 * Math.sqrt( ( this.pbar * (1-this.pbar) ) / n ); Double mul = 3 * Math.sqrt( ( this.pbar * (1-this.pbar) ) / n );
Double lcl = (this.pbar-mul)<0?0:(this.pbar-mul); Double lcl = (this.pbar-mul)<0?0:(this.pbar-mul);
return new ControlLimit( return new ControlLimitDetail(
this.pbar + mul, this.pbar + mul,
this.pbar, this.pbar,
lcl lcl

View File

@ -7,6 +7,7 @@ import com.cnbm.influx.constant.Constant;
import com.cnbm.influx.param.QueryDataGroupByTimeParam; import com.cnbm.influx.param.QueryDataGroupByTimeParam;
import com.cnbm.influx.param.Tag; import com.cnbm.influx.param.Tag;
import com.cnbm.qualityPlanning.entity.ControlLimit; import com.cnbm.qualityPlanning.entity.ControlLimit;
import com.cnbm.qualityPlanning.entity.ControlLimitDetail;
import com.cnbm.qualityPlanning.entity.SpecificationLimit; import com.cnbm.qualityPlanning.entity.SpecificationLimit;
import com.cnbm.qualityPlanning.entity.UPoint; import com.cnbm.qualityPlanning.entity.UPoint;
import com.influxdb.query.FluxRecord; import com.influxdb.query.FluxRecord;
@ -147,11 +148,11 @@ public class UGraph {
* desc: get Xbar控制图 的控制限 * desc: get Xbar控制图 的控制限
* 注意此函数 要在 initialDate()函数执行之后 * 注意此函数 要在 initialDate()函数执行之后
* */ * */
public ControlLimit getCL(Double n){ public ControlLimitDetail getCL(Double n){
Double mul = 3 * Math.sqrt( this.ubar / n ); Double mul = 3 * Math.sqrt( this.ubar / n );
Double lcl = (this.ubar-mul)<0?0:(this.ubar-mul); Double lcl = (this.ubar-mul)<0?0:(this.ubar-mul);
return new ControlLimit( return new ControlLimitDetail(
this.ubar + mul, this.ubar + mul,
this.ubar, this.ubar,
lcl lcl

View File

@ -10,7 +10,7 @@ import lombok.Data;
@Data @Data
public class CPoint { public class CPoint {
private ControlLimit controlLimit; private ControlLimitDetail controlLimit;
private Integer position; private Integer position;
@ -19,7 +19,7 @@ public class CPoint {
private String name; private String name;
public CPoint(ControlLimit controlLimit, Integer position, Double value, String name) { public CPoint(ControlLimitDetail controlLimit, Integer position, Double value, String name) {
this.controlLimit = controlLimit; this.controlLimit = controlLimit;
this.position = position; this.position = position;
this.value = value; this.value = value;

View File

@ -15,7 +15,7 @@ import java.util.Set;
@Data @Data
public class NPPoint{ public class NPPoint{
private ControlLimit controlLimit; private ControlLimitDetail controlLimit;
private Integer position; private Integer position;
@ -23,7 +23,7 @@ public class NPPoint{
private Integer value; private Integer value;
private String name; private String name;
public NPPoint(ControlLimit controlLimit, Integer position, Integer value,String name) { public NPPoint(ControlLimitDetail controlLimit, Integer position, Integer value,String name) {
this.controlLimit = controlLimit; this.controlLimit = controlLimit;
this.position = position; this.position = position;
this.value = value; this.value = value;

View File

@ -10,7 +10,7 @@ import lombok.Data;
@Data @Data
public class PPoint { public class PPoint {
private ControlLimit controlLimit; private ControlLimitDetail controlLimit;
private Integer position; private Integer position;
@ -19,7 +19,7 @@ public class PPoint {
private String name; private String name;
public PPoint(ControlLimit controlLimit, Integer position, Double value,String name) { public PPoint(ControlLimitDetail controlLimit, Integer position, Double value,String name) {
this.controlLimit = controlLimit; this.controlLimit = controlLimit;
this.position = position; this.position = position;
this.value = value; this.value = value;

View File

@ -10,7 +10,7 @@ import lombok.Data;
@Data @Data
public class UPoint { public class UPoint {
private ControlLimit controlLimit; private ControlLimitDetail controlLimit;
private Integer position; private Integer position;
@ -19,7 +19,7 @@ public class UPoint {
private String name; private String name;
public UPoint(ControlLimit controlLimit, Integer position, Double value, String name) { public UPoint(ControlLimitDetail controlLimit, Integer position, Double value, String name) {
this.controlLimit = controlLimit; this.controlLimit = controlLimit;
this.position = position; this.position = position;
this.value = value; this.value = value;