mark
This commit is contained in:
parent
1477d05a69
commit
d26600892f
@ -73,6 +73,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
"/webjars/**",
|
"/webjars/**",
|
||||||
"/websocket/**",
|
"/websocket/**",
|
||||||
"/influx/**",
|
"/influx/**",
|
||||||
|
"/processInspection/**",
|
||||||
"/captcha").anonymous()
|
"/captcha").anonymous()
|
||||||
// .antMatchers("/testCors").hasAuthority("system:dept:list222")
|
// .antMatchers("/testCors").hasAuthority("system:dept:list222")
|
||||||
// 除上面外的所有请求全部需要鉴权认证
|
// 除上面外的所有请求全部需要鉴权认证
|
||||||
|
@ -2,6 +2,7 @@ package com.cnbm.common.spc.math;
|
|||||||
|
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class Math {
|
public class Math {
|
||||||
|
|
||||||
@ -17,7 +18,7 @@ public class Math {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
//8.1 10.6 9.8 9.0 9.4 9.3 10.2 11.7
|
//8.1 10.6 9.8 9.0 9.4 9.3 10.2 11.7
|
||||||
double[] d = new double[8];
|
Double[] d = new Double[8];
|
||||||
d[0] = new Double(8.1) ;
|
d[0] = new Double(8.1) ;
|
||||||
d[1] = new Double(10.6);
|
d[1] = new Double(10.6);
|
||||||
d[2] = new Double(9.8);
|
d[2] = new Double(9.8);
|
||||||
@ -32,12 +33,12 @@ public class Math {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//平均值
|
//平均值
|
||||||
public static double getMean(double...numbers) {
|
public static double getMean(Double...numbers) {
|
||||||
return format(getSum(numbers) / numbers.length);
|
return format(getSum(numbers) / numbers.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
//极差
|
//极差
|
||||||
public static double range(double[] in) {
|
public static double range(Double[] in) {
|
||||||
if (in == null) {
|
if (in == null) {
|
||||||
throw new NumberFormatException();
|
throw new NumberFormatException();
|
||||||
}
|
}
|
||||||
@ -51,14 +52,14 @@ public class Math {
|
|||||||
//return Mutil.subtract(max, min);
|
//return Mutil.subtract(max, min);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double format(double value) {
|
public static double format(Double value) {
|
||||||
DecimalFormat df = new DecimalFormat("0.00");//创建一个df对象,传入0.00表示构造一个保留小数点后两位的df对象
|
DecimalFormat df = new DecimalFormat("0.00");//创建一个df对象,传入0.00表示构造一个保留小数点后两位的df对象
|
||||||
df.setRoundingMode(RoundingMode.HALF_UP);//设置规则,这里采用的也是四舍五入规则
|
df.setRoundingMode(RoundingMode.HALF_UP);//设置规则,这里采用的也是四舍五入规则
|
||||||
return Double.parseDouble(df.format(value));//返回value(在返回之前使用df对象的格式化方法将数据格式化)
|
return Double.parseDouble(df.format(value));//返回value(在返回之前使用df对象的格式化方法将数据格式化)
|
||||||
}
|
}
|
||||||
|
|
||||||
//方差s^2=[(x1-x)^2 +...(xn-x)^2]/n 或者s^2=[(x1-x)^2 +...(xn-x)^2]/(n-1)
|
//方差s^2=[(x1-x)^2 +...(xn-x)^2]/n 或者s^2=[(x1-x)^2 +...(xn-x)^2]/(n-1)
|
||||||
public static double Variance(double[] x) {
|
public static double Variance(Double[] x) {
|
||||||
int m=x.length;
|
int m=x.length;
|
||||||
double sum=0;
|
double sum=0;
|
||||||
for(int i=0;i<m;i++){//求和
|
for(int i=0;i<m;i++){//求和
|
||||||
@ -72,8 +73,10 @@ public class Math {
|
|||||||
return format(dVar/m);
|
return format(dVar/m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//标准差σ=sqrt(s^2)
|
//标准差σ=sqrt(s^2)
|
||||||
public static double StandardDiviation(double[] x) {
|
public static StandardDiviation StandardDiviation(Double[] x) {
|
||||||
int m=x.length;
|
int m=x.length;
|
||||||
double sum=0;
|
double sum=0;
|
||||||
for(int i=0;i<m;i++){//求和
|
for(int i=0;i<m;i++){//求和
|
||||||
@ -84,13 +87,12 @@ public class Math {
|
|||||||
for(int i=0;i<m;i++){//求方差
|
for(int i=0;i<m;i++){//求方差
|
||||||
dVar+=(x[i]-dAve)*(x[i]-dAve);
|
dVar+=(x[i]-dAve)*(x[i]-dAve);
|
||||||
}
|
}
|
||||||
return format(java.lang.Math.sqrt(dVar/(m-1)));
|
return new StandardDiviation(format(java.lang.Math.sqrt(dVar/(m-1))),format(java.lang.Math.sqrt(dVar/(m))));
|
||||||
//return Math.sqrt(dVar/m);
|
//return Math.sqrt(dVar/m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//前n项和
|
//前n项和
|
||||||
public static double getSum(double...numbers) {
|
public static double getSum(Double...numbers) {
|
||||||
double sum = 0.0;
|
double sum = 0.0;
|
||||||
|
|
||||||
for (double i : numbers) {
|
for (double i : numbers) {
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.cnbm.common.spc.math;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Desc: ""
|
||||||
|
* @Author: caixiang
|
||||||
|
* @DATE: 2022/7/25 15:23
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class StandardDiviation {
|
||||||
|
//标准差
|
||||||
|
private Double normal;
|
||||||
|
//总体标准差
|
||||||
|
private Double totality;
|
||||||
|
|
||||||
|
public StandardDiviation(Double normal, Double totality) {
|
||||||
|
this.normal = normal;
|
||||||
|
this.totality = totality;
|
||||||
|
}
|
||||||
|
}
|
@ -49,23 +49,23 @@ public class Main {
|
|||||||
// InfluxClient.Client.insert(event,"ASProcessCompleteEvent");
|
// InfluxClient.Client.insert(event,"ASProcessCompleteEvent");
|
||||||
|
|
||||||
|
|
||||||
Point point = Point.measurement("ASProcessCompleteEvent")
|
// Point point = Point.measurement("ASProcessCompleteEvent")
|
||||||
.addTag("transationId", "112311")
|
// .addTag("transationId", "112311")
|
||||||
.addTag("argName", "argName11")
|
// .addTag("argName", "argName11")
|
||||||
.addField("argValue", 3D)
|
// .addField("argValue", 3D)
|
||||||
.time(Instant.now().toEpochMilli(), WritePrecision.MS);
|
// .time(Instant.now().toEpochMilli(), WritePrecision.MS);
|
||||||
|
//
|
||||||
|
//
|
||||||
Point point2 = Point.measurement("ASProcessCompleteEvent")
|
// Point point2 = Point.measurement("ASProcessCompleteEvent")
|
||||||
.addTag("transationId", "222312")
|
// .addTag("transationId", "222312")
|
||||||
.addTag("argName", "argName11")
|
// .addTag("argName", "argName11")
|
||||||
.addField("argValue", 4D)
|
// .addField("argValue", 4D)
|
||||||
.time(Instant.now().toEpochMilli(), WritePrecision.MS);
|
// .time(Instant.now().toEpochMilli(), WritePrecision.MS);
|
||||||
List<Point> list = new ArrayList<>();
|
// List<Point> list = new ArrayList<>();
|
||||||
list.add(point);
|
// list.add(point);
|
||||||
list.add(point2);
|
// list.add(point2);
|
||||||
|
//
|
||||||
writeApi.writePoints(list);
|
// writeApi.writePoints(list);
|
||||||
|
|
||||||
//todo api.writeMeasurements(WritePrecision.NS, Arrays.asList(new H2OFeetMeasurement("coyote_creek", 15.0D, null, Instant.ofEpochSecond(0, 15)), new H2OFeetMeasurement("coyote_creek", 16.0D, null, Instant.ofEpochSecond(0, 16))));
|
//todo api.writeMeasurements(WritePrecision.NS, Arrays.asList(new H2OFeetMeasurement("coyote_creek", 15.0D, null, Instant.ofEpochSecond(0, 15)), new H2OFeetMeasurement("coyote_creek", 16.0D, null, Instant.ofEpochSecond(0, 16))));
|
||||||
// List<Event> events = new ArrayList<>();
|
// List<Event> events = new ArrayList<>();
|
||||||
@ -105,23 +105,24 @@ public class Main {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// String flux = "from(bucket:\"mytest\") |> range(start: -60m)";
|
String flux = "from(bucket:\"mytest\") |> range(start: -6000000000000000m)";
|
||||||
// flux += "|> filter(fn: (r) =>\n" +
|
flux += "|> filter(fn: (r) =>\n" +
|
||||||
// " r._measurement == \"ASProcessCompleteEvent\" and \n" +
|
" r._measurement == \"ASProcessCompleteEvent\" and \n" +
|
||||||
//// " r._field == \"type\" and \n" + //对应 Field key
|
// " r._field == \"type\" and \n" + //对应 Field key
|
||||||
// " r.argName == \"arg3\"\n" + //对应 Tags key (Tag 信息无法在FluxRecord 里面获取。)
|
" r.argName == \"arg3\"\n" + //对应 Tags key (Tag 信息无法在FluxRecord 里面获取。)
|
||||||
// " )";
|
" )";
|
||||||
// QueryApi queryApi = influxDBClient.getQueryApi();
|
QueryApi queryApi = influxDBClient.getQueryApi();
|
||||||
//
|
|
||||||
// List<FluxTable> tables = queryApi.query(flux);
|
List<FluxTable> tables = queryApi.query(flux);
|
||||||
// for (FluxTable fluxTable : tables) {
|
for (FluxTable fluxTable : tables) {
|
||||||
// List<FluxRecord> records = fluxTable.getRecords();
|
List<FluxRecord> records = fluxTable.getRecords();
|
||||||
// for (FluxRecord fluxRecord : records) {
|
for (FluxRecord fluxRecord : records) {
|
||||||
// System.out.println("time: "+fluxRecord.getTime() +" key:"+fluxRecord.getField()+" value: " + fluxRecord.getValueByKey("_value")+" measurement: " + fluxRecord.getMeasurement());
|
Double o = (Double)fluxRecord.getValueByKey("_value");
|
||||||
//// System.out.println("time: "+fluxRecord.getTime() +" key:"++" value: " + fluxRecord.getValueByKey("_value")+" measurement: " + fluxRecord.getMeasurement());
|
System.out.println("time: "+fluxRecord.getTime() +" key:"+fluxRecord.getField()+" value: " + fluxRecord.getValueByKey("_value")+" measurement: " + fluxRecord.getMeasurement());
|
||||||
//
|
// System.out.println("time: "+fluxRecord.getTime() +" key:"++" value: " + fluxRecord.getValueByKey("_value")+" measurement: " + fluxRecord.getMeasurement());
|
||||||
// }
|
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// from(bucket: "mytest")
|
// from(bucket: "mytest")
|
||||||
|
@ -0,0 +1,70 @@
|
|||||||
|
package com.cnbm.processInspection.controller;
|
||||||
|
|
||||||
|
import com.cnbm.basic.dto.UnitDTO;
|
||||||
|
import com.cnbm.basic.entity.ProductFeatures;
|
||||||
|
import com.cnbm.common.spc.math.StandardDiviation;
|
||||||
|
import com.cnbm.common.spc.util.DataUtils;
|
||||||
|
import com.cnbm.common.utils.Result;
|
||||||
|
import com.cnbm.common.vo.R;
|
||||||
|
import com.cnbm.influx.config.InfluxClient;
|
||||||
|
import com.cnbm.influx.constant.Constant;
|
||||||
|
import com.cnbm.influx.param.PageInfo;
|
||||||
|
import com.cnbm.influx.param.QueryDataParam;
|
||||||
|
import com.cnbm.influx.param.Range;
|
||||||
|
import com.cnbm.influx.param.Tag;
|
||||||
|
import com.cnbm.influx.template.Event;
|
||||||
|
import com.cnbm.processInspection.dto.XbarSGraphData;
|
||||||
|
import com.cnbm.processInspection.graphAnalyzed.MeanStandardDeviationGraph;
|
||||||
|
import com.cnbm.qualityPlanning.entity.SpecificationLimit;
|
||||||
|
import com.influxdb.client.domain.WritePrecision;
|
||||||
|
import com.influxdb.client.write.Point;
|
||||||
|
import com.influxdb.query.FluxRecord;
|
||||||
|
import com.influxdb.query.FluxTable;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/processInspection")
|
||||||
|
public class ProcessInspectionController {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(ProcessInspectionController.class);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/XbarSGraph")
|
||||||
|
public R<XbarSGraphData> xbarSGraph() throws Exception {
|
||||||
|
ProductFeatures productFeatures = new ProductFeatures();
|
||||||
|
productFeatures.setSl(new Float(5));
|
||||||
|
productFeatures.setUsl(new Float(10));
|
||||||
|
productFeatures.setLsl(new Float(1));
|
||||||
|
|
||||||
|
productFeatures.setName("LTWeight");
|
||||||
|
productFeatures.setSampleSize(BigDecimal.TEN);
|
||||||
|
MeanStandardDeviationGraph meanStandardDeviationGraph = new MeanStandardDeviationGraph(productFeatures);
|
||||||
|
|
||||||
|
QueryDataParam queryDataParam = new QueryDataParam();
|
||||||
|
queryDataParam.setMeasurement("Weight");
|
||||||
|
queryDataParam.setRange(new Range(DataUtils.getBeforeDate(10).toInstant(), Instant.now()));
|
||||||
|
meanStandardDeviationGraph.initialDate(queryDataParam);
|
||||||
|
XbarSGraphData xbarSGraphData = new XbarSGraphData(
|
||||||
|
meanStandardDeviationGraph.getMsdGraphEntity(),
|
||||||
|
meanStandardDeviationGraph.getXbarCL(),
|
||||||
|
meanStandardDeviationGraph.getSCL(),
|
||||||
|
meanStandardDeviationGraph.getSpecificationLimit(),
|
||||||
|
meanStandardDeviationGraph.getProcessCapacity(),
|
||||||
|
new StandardDiviation(meanStandardDeviationGraph.getXigma(),meanStandardDeviationGraph.getTotalXigma())
|
||||||
|
);
|
||||||
|
|
||||||
|
return R.ok("成功",xbarSGraphData);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package com.cnbm.processInspection.dto;
|
||||||
|
|
||||||
|
import com.cnbm.common.spc.math.StandardDiviation;
|
||||||
|
import com.cnbm.processInspection.graphAnalyzed.MSDGraphEntity;
|
||||||
|
import com.cnbm.qualityPlanning.entity.ControlLimit;
|
||||||
|
import com.cnbm.qualityPlanning.entity.ProcessCapability;
|
||||||
|
import com.cnbm.qualityPlanning.entity.SpecificationLimit;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Desc: ""
|
||||||
|
* @Author: caixiang
|
||||||
|
* @DATE: 2022/7/22 14:18
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "均值标准差控制图 结果类")
|
||||||
|
public class XbarSGraphData {
|
||||||
|
@ApiModelProperty(value = "控制图list数据")
|
||||||
|
private MSDGraphEntity msdGraphEntity;
|
||||||
|
@ApiModelProperty(value = "xbar控制图 控制限")
|
||||||
|
private ControlLimit XBarCL;
|
||||||
|
@ApiModelProperty(value = "s控制图 控制限")
|
||||||
|
private ControlLimit SCL;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "工艺规格限")
|
||||||
|
private SpecificationLimit SL;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "工序能力")
|
||||||
|
private ProcessCapability processCapability;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "标准差/总体标准差")
|
||||||
|
private StandardDiviation standardDiviation;
|
||||||
|
|
||||||
|
|
||||||
|
public XbarSGraphData(MSDGraphEntity msdGraphEntity,ControlLimit xBarCL,ControlLimit sCL,SpecificationLimit sl,ProcessCapability processCapability,StandardDiviation standardDiviation){
|
||||||
|
this.msdGraphEntity = msdGraphEntity;
|
||||||
|
this.XBarCL = xBarCL;
|
||||||
|
this.SCL = sCL;
|
||||||
|
this.SL = sl;
|
||||||
|
this.processCapability = processCapability;
|
||||||
|
this.standardDiviation = standardDiviation;
|
||||||
|
}
|
||||||
|
}
|
@ -1,47 +0,0 @@
|
|||||||
package com.cnbm.processInspection.entity;
|
|
||||||
|
|
||||||
|
|
||||||
import com.cnbm.qualityPlanning.entity.Point;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Desc: ""
|
|
||||||
* @Author: caixiang
|
|
||||||
* @DATE: 2022/7/21 9:43
|
|
||||||
*/
|
|
||||||
public class XbarSPoint extends Point {
|
|
||||||
public XbarSPoint(Integer position, Double value) {
|
|
||||||
super(position, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer getPosition() {
|
|
||||||
return super.getPosition();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Double getValue() {
|
|
||||||
return super.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<Integer> getUnsatisfiedRules() {
|
|
||||||
return super.getUnsatisfiedRules();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setPosition(Integer position) {
|
|
||||||
super.setPosition(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setValue(Double value) {
|
|
||||||
super.setValue(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setUnsatisfiedRules(Set<Integer> unsatisfiedRules) {
|
|
||||||
super.setUnsatisfiedRules(unsatisfiedRules);
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,59 @@
|
|||||||
|
package com.cnbm.processInspection.graphAnalyzed;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import com.cnbm.qualityPlanning.entity.XbarSPoint;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Desc: ""
|
||||||
|
* @Author: caixiang
|
||||||
|
* @DATE: 2022/7/21 16:26
|
||||||
|
*/
|
||||||
|
public class MSDGraphEntity {
|
||||||
|
private List<XbarSPoint> list;
|
||||||
|
private Double xbarbar;
|
||||||
|
private Double sbar;
|
||||||
|
private Double Rbar;
|
||||||
|
|
||||||
|
public MSDGraphEntity(List<XbarSPoint> list,Double xbarbar,Double sbar,Double Rbar){
|
||||||
|
this.list = list;
|
||||||
|
this.Rbar = Rbar;
|
||||||
|
this.sbar = sbar;
|
||||||
|
this.xbarbar = xbarbar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<XbarSPoint> getList() {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setList(List<XbarSPoint> list) {
|
||||||
|
this.list = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getXbarbar() {
|
||||||
|
return xbarbar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setXbarbar(Double xbarbar) {
|
||||||
|
this.xbarbar = xbarbar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getSbar() {
|
||||||
|
return sbar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSbar(Double sbar) {
|
||||||
|
this.sbar = sbar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getRbar() {
|
||||||
|
return Rbar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRbar(Double rbar) {
|
||||||
|
Rbar = rbar;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,8 @@
|
|||||||
package com.cnbm.processInspection.graphAnalyzed;
|
package com.cnbm.processInspection.graphAnalyzed;
|
||||||
|
|
||||||
import com.cnbm.basic.entity.ProductFeatures;
|
import com.cnbm.basic.entity.ProductFeatures;
|
||||||
|
import com.cnbm.common.spc.math.Math;
|
||||||
|
import com.cnbm.common.spc.math.StandardDiviation;
|
||||||
import com.cnbm.common.spc.util.DataUtils;
|
import com.cnbm.common.spc.util.DataUtils;
|
||||||
import com.cnbm.common.utils.DateUtils;
|
import com.cnbm.common.utils.DateUtils;
|
||||||
import com.cnbm.influx.config.InfluxClient;
|
import com.cnbm.influx.config.InfluxClient;
|
||||||
@ -10,16 +12,25 @@ import com.cnbm.influx.param.QueryDataParam;
|
|||||||
import com.cnbm.influx.param.Range;
|
import com.cnbm.influx.param.Range;
|
||||||
import com.cnbm.influx.param.Tag;
|
import com.cnbm.influx.param.Tag;
|
||||||
import com.cnbm.processInspection.controlCoefficientConstant.XBarSCoefficients;
|
import com.cnbm.processInspection.controlCoefficientConstant.XBarSCoefficients;
|
||||||
|
|
||||||
|
import com.cnbm.qualityPlanning.entity.ControlLimit;
|
||||||
|
import com.cnbm.qualityPlanning.entity.ProcessCapability;
|
||||||
|
import com.cnbm.qualityPlanning.entity.SpecificationLimit;
|
||||||
|
import com.cnbm.qualityPlanning.entity.XbarSPoint;
|
||||||
import com.influxdb.query.FluxRecord;
|
import com.influxdb.query.FluxRecord;
|
||||||
import com.influxdb.query.FluxTable;
|
import com.influxdb.query.FluxTable;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Desc: ""
|
* @Desc: "均值标准差 控制图 , 计算类"
|
||||||
* @Author: caixiang
|
* @Author: caixiang
|
||||||
* @DATE: 2022/7/20 14:26
|
* @DATE: 2022/7/20 14:26
|
||||||
|
* 使用方式:① 先new MeanStandardDeviationGraph 对象 ;② 再initialData 初始化数据;③ 再get 控制限
|
||||||
*
|
*
|
||||||
* 步骤:
|
* 步骤:
|
||||||
* ① 先读mysql表,查询 product_features 表,先读到 sample_size(样本量)
|
* ① 先读mysql表,查询 product_features 表,先读到 sample_size(样本量)
|
||||||
@ -31,8 +42,16 @@ import java.util.List;
|
|||||||
* ④ 如果配置了判读方案,还要 调用 StatisticalControlledTest Function 检验。
|
* ④ 如果配置了判读方案,还要 调用 StatisticalControlledTest Function 检验。
|
||||||
* ⑤
|
* ⑤
|
||||||
*/
|
*/
|
||||||
|
@Data
|
||||||
public class MeanStandardDeviationGraph {
|
public class MeanStandardDeviationGraph {
|
||||||
|
//母体的 μ = xbarbar
|
||||||
|
private Double miu;
|
||||||
|
//母体的 xigma ,全局计算的;
|
||||||
|
private Double xigma;
|
||||||
|
//母体的 xigma ,全局计算的;
|
||||||
|
private Double totalXigma;
|
||||||
|
|
||||||
|
|
||||||
private Double sbar;
|
private Double sbar;
|
||||||
private Double xbarbar;
|
private Double xbarbar;
|
||||||
private Double as;
|
private Double as;
|
||||||
@ -41,16 +60,32 @@ public class MeanStandardDeviationGraph {
|
|||||||
private Integer sampleSize;
|
private Integer sampleSize;
|
||||||
private String argName;
|
private String argName;
|
||||||
|
|
||||||
|
private SpecificationLimit specificationLimit;
|
||||||
|
private MSDGraphEntity msdGraphEntity;
|
||||||
|
|
||||||
MeanStandardDeviationGraph(ProductFeatures productFeatures) throws Exception {
|
|
||||||
|
public MeanStandardDeviationGraph(ProductFeatures productFeatures) throws Exception {
|
||||||
if(productFeatures.getSampleSize()==null || productFeatures.getName()==null){
|
if(productFeatures.getSampleSize()==null || productFeatures.getName()==null){
|
||||||
throw new Exception("ProductFeatures 参数异常");
|
throw new Exception("ProductFeatures 参数异常");
|
||||||
}
|
}
|
||||||
|
this.argName = productFeatures.getName();
|
||||||
this.sampleSize = productFeatures.getSampleSize().intValue();
|
this.sampleSize = productFeatures.getSampleSize().intValue();
|
||||||
this.as = XBarSCoefficients.getAS(sampleSize);
|
this.as = XBarSCoefficients.getAS(sampleSize);
|
||||||
this.bu = XBarSCoefficients.getBU(sampleSize);
|
this.bu = XBarSCoefficients.getBU(sampleSize);
|
||||||
this.bl = XBarSCoefficients.getBU(sampleSize);
|
this.bl = XBarSCoefficients.getBU(sampleSize);
|
||||||
|
this.specificationLimit = new SpecificationLimit(
|
||||||
|
productFeatures.getUsl()==null?null:productFeatures.getUsl(),
|
||||||
|
productFeatures.getSl()==null?null:productFeatures.getSl(),
|
||||||
|
productFeatures.getUsl()==null?null:productFeatures.getUsl()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Double[] toDoubleArray(Object[] o){
|
||||||
|
Double[] res= new Double[o.length];
|
||||||
|
for(int i=0;i<o.length;i++){
|
||||||
|
res[i] = (Double) o[i];
|
||||||
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,24 +94,130 @@ public class MeanStandardDeviationGraph {
|
|||||||
* 步骤:
|
* 步骤:
|
||||||
* ①
|
* ①
|
||||||
* */
|
* */
|
||||||
public void initialDate(){
|
public void initialDate(QueryDataParam queryDataParam){
|
||||||
QueryDataParam queryDataParam = new QueryDataParam();
|
|
||||||
queryDataParam.setBucket(Constant.bucket);
|
queryDataParam.setBucket(Constant.bucket);
|
||||||
queryDataParam.setMeasurement("Weight");
|
|
||||||
queryDataParam.setDropedTagName("transationId");
|
queryDataParam.setDropedTagName("transationId");
|
||||||
queryDataParam.setTag(new Tag("argName","LTWeight"));
|
queryDataParam.setTag(new Tag("argName",argName));
|
||||||
queryDataParam.setRange(new Range(DataUtils.getBeforeDate(10).toInstant(), Instant.now()));
|
queryDataParam.setRange(new Range(DataUtils.getBeforeDate(10).toInstant(), Instant.now()));
|
||||||
queryDataParam.setPageInfo(new PageInfo(1,10));
|
|
||||||
List<FluxTable> query = InfluxClient.Client.query(queryDataParam);
|
List<FluxTable> query = InfluxClient.Client.query(queryDataParam);
|
||||||
List<List<FluxTable>> lists = DataUtils.fixedGroup(query, sampleSize);
|
//1. 先从fluxdb 里面提取原始数据
|
||||||
|
List<Double> originData = new ArrayList<>();
|
||||||
|
|
||||||
for (FluxTable fluxTable : query) {
|
for (FluxTable fluxTable : query) {
|
||||||
List<FluxRecord> records = fluxTable.getRecords();
|
List<FluxRecord> records = fluxTable.getRecords();
|
||||||
for (FluxRecord fluxRecord : records) {
|
for (FluxRecord fluxRecord : records) {
|
||||||
System.out.println("value: " + fluxRecord.getValueByKey("_value"));
|
//因为 传进去的就是Double 类型,所以取出来,自然而然就是Double
|
||||||
|
originData.add(Double.parseDouble(fluxRecord.getValueByKey("_value").toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//2. convert to XbarSPoint
|
||||||
|
List<List<Double>> doubleListList = DataUtils.fixedGroup(originData, sampleSize);
|
||||||
|
List<XbarSPoint> list = new ArrayList<>();
|
||||||
|
List<Double> xbarArray = new ArrayList<>();
|
||||||
|
List<Double> sArray = new ArrayList<>();
|
||||||
|
List<Double> rArray = new ArrayList<>();
|
||||||
|
for(int i=0;i<doubleListList.size();i++){
|
||||||
|
Double[] doubleList = toDoubleArray(doubleListList.get(i).toArray());
|
||||||
|
|
||||||
|
Double xbar = Math.getMean(doubleList);
|
||||||
|
Double s = Math.StandardDiviation(doubleList).getNormal();
|
||||||
|
Double r = Math.range(doubleList);
|
||||||
|
xbarArray.add(xbar);
|
||||||
|
sArray.add(s);
|
||||||
|
rArray.add(r);
|
||||||
|
list.add(new XbarSPoint(
|
||||||
|
i,
|
||||||
|
new Double(0),
|
||||||
|
xbar,
|
||||||
|
s,
|
||||||
|
r
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//3. 以及一些 控制图的全局参数。
|
||||||
|
Double xbarbar = Math.getMean(toDoubleArray(xbarArray.toArray()));
|
||||||
|
this.miu = xbarbar;
|
||||||
|
StandardDiviation standardDiviation =Math.StandardDiviation(toDoubleArray(originData.toArray()));
|
||||||
|
this.xigma = standardDiviation.getNormal();
|
||||||
|
this.totalXigma = standardDiviation.getTotality();
|
||||||
|
Double sbar = Math.getMean(toDoubleArray(sArray.toArray()));
|
||||||
|
Double rbar = Math.getMean(toDoubleArray(rArray.toArray()));
|
||||||
|
this.msdGraphEntity = new MSDGraphEntity(list,xbarbar,sbar,rbar);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* desc: get Xbar控制图 的控制限
|
||||||
|
* 注意:此函数 要在 initialDate()函数执行之后
|
||||||
|
* */
|
||||||
|
public ControlLimit getXbarCL(){
|
||||||
|
return new ControlLimit(
|
||||||
|
(as*this.msdGraphEntity.getSbar() + this.msdGraphEntity.getXbarbar()),
|
||||||
|
this.msdGraphEntity.getXbarbar(),
|
||||||
|
(this.msdGraphEntity.getXbarbar() - as*this.msdGraphEntity.getSbar())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* desc: get S控制图 的控制限
|
||||||
|
* 注意:此函数 要在 initialDate()函数执行之后
|
||||||
|
* */
|
||||||
|
public ControlLimit getSCL(){
|
||||||
|
return new ControlLimit(
|
||||||
|
( bu * this.msdGraphEntity.getSbar() ) ,
|
||||||
|
this.msdGraphEntity.getSbar() ,
|
||||||
|
(bl * this.msdGraphEntity.getSbar())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* desc: get 工序能力
|
||||||
|
* 注意:此函数 要在 initialDate()函数执行之后
|
||||||
|
* */
|
||||||
|
public ProcessCapability getProcessCapacity(){
|
||||||
|
SpecificationLimit sp = this.specificationLimit;
|
||||||
|
List<String> warming = new ArrayList<>();
|
||||||
|
Float usl = sp.getUSL();
|
||||||
|
Float lsl = sp.getLSL();
|
||||||
|
if(usl==null || lsl==null){
|
||||||
|
if(usl==null && lsl!=null){
|
||||||
|
if(this.miu<lsl){
|
||||||
|
warming.add("平均值已不能满足规范要求, 有相当多数据均为不合格, 则表示完全没有工序能力");
|
||||||
|
return new ProcessCapability(null,null,null,(double)0,warming);
|
||||||
|
}
|
||||||
|
Double cpl = ( (this.miu-lsl) / (3 * this.xigma) );
|
||||||
|
return new ProcessCapability(null,null,null,cpl,warming);
|
||||||
|
} else if (lsl == null && usl!=null) {
|
||||||
|
if(this.miu>usl){
|
||||||
|
warming.add("平均值已不能满足规范要求, 有相当多数据均为不合格, 则表示完全没有工序能力");
|
||||||
|
return new ProcessCapability(null,null,(double)0,null,warming);
|
||||||
|
}
|
||||||
|
|
||||||
|
Double cpu = ( (usl-this.miu) / (3 * this.xigma) );
|
||||||
|
return new ProcessCapability(null,null,cpu,null,warming);
|
||||||
|
}else {
|
||||||
|
return new ProcessCapability(null,null,null,null,warming);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//下面就是 usl 和 lsl 都部位null的情况
|
||||||
|
Float k1 = usl-lsl;
|
||||||
|
Float k2 = usl+lsl;
|
||||||
|
|
||||||
|
Double cp = ( k1 / (6*this.xigma) );
|
||||||
|
Double k = ( java.lang.Math.abs( (this.miu-k2/2) ) / (k1/2) );
|
||||||
|
if(k>1){
|
||||||
|
warming.add("此工艺参数K 大于1, 说明均值μ已经偏离到规范范围意外,即相当多的工艺参数均不满足规范要求,这说明工艺加工结果很差,该设备根本不适用于批量生产");
|
||||||
|
}
|
||||||
|
Double cpk = cp * ( 1- k);
|
||||||
|
if(cpk<0){
|
||||||
|
warming.add("Cpk=0,该工序完全没有能力 批量生产");
|
||||||
|
cpk = (double) 0;
|
||||||
|
}
|
||||||
|
Double cpu = ( (usl-this.miu) / (3 * this.xigma) );
|
||||||
|
Double cpl = ( (this.miu-lsl) / (3 * this.xigma) );
|
||||||
|
|
||||||
|
return new ProcessCapability(cp,cpk,cpu,cpl,warming);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ package com.cnbm.qualityPlanning.common;
|
|||||||
import com.cnbm.qualityPlanning.entity.ControlLimit;
|
import com.cnbm.qualityPlanning.entity.ControlLimit;
|
||||||
import com.cnbm.qualityPlanning.entity.ControlLimitDetail;
|
import com.cnbm.qualityPlanning.entity.ControlLimitDetail;
|
||||||
import com.cnbm.qualityPlanning.entity.Point;
|
import com.cnbm.qualityPlanning.entity.Point;
|
||||||
|
import com.cnbm.qualityPlanning.entity.XbarSPoint;
|
||||||
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@ -38,6 +40,15 @@ public class StatisticalControlledTest {
|
|||||||
Point point10 = new Point(10,new Double(3.7));
|
Point point10 = new Point(10,new Double(3.7));
|
||||||
Point point11 = new Point(11,new Double(3.7));
|
Point point11 = new Point(11,new Double(3.7));
|
||||||
Point point12 = new Point(12,new Double(3.7));
|
Point point12 = new Point(12,new Double(3.7));
|
||||||
|
Point point13 = new Point(13,new Double(3.7));
|
||||||
|
Point point14 = new Point(14,new Double(3.7));
|
||||||
|
Point point15 = new Point(15,new Double(3.7));
|
||||||
|
Point point16 = new Point(16,new Double(3.7));
|
||||||
|
Point point17 = new Point(17,new Double(3.7));
|
||||||
|
Point point18 = new Point(18,new Double(3.7));
|
||||||
|
Point point19 = new Point(19,new Double(3.7));
|
||||||
|
Point point20 = new Point(20,new Double(3.7));
|
||||||
|
|
||||||
List<Point> list = new ArrayList<>();
|
List<Point> list = new ArrayList<>();
|
||||||
list.add(point);
|
list.add(point);
|
||||||
list.add(point2);
|
list.add(point2);
|
||||||
@ -53,16 +64,68 @@ public class StatisticalControlledTest {
|
|||||||
list.add(point12);
|
list.add(point12);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
public static List<Point> createData2(){
|
||||||
|
XbarSPoint point = new XbarSPoint(1, new Double(2.5));
|
||||||
|
XbarSPoint point2 = new XbarSPoint(2, new Double(2.5));
|
||||||
|
XbarSPoint point3 = new XbarSPoint(3, new Double(2.5));
|
||||||
|
XbarSPoint point4 = new XbarSPoint(4, new Double(2.5));
|
||||||
|
XbarSPoint point5 = new XbarSPoint(5, new Double(2.5));
|
||||||
|
XbarSPoint point6 = new XbarSPoint(6, new Double(2.5));
|
||||||
|
XbarSPoint point7 = new XbarSPoint(7, new Double(2.5));
|
||||||
|
XbarSPoint point8 = new XbarSPoint(8, new Double(2));
|
||||||
|
XbarSPoint point9 = new XbarSPoint(9, new Double(2.5));
|
||||||
|
XbarSPoint point10 = new XbarSPoint(10, new Double(2.5));
|
||||||
|
XbarSPoint point11 = new XbarSPoint(11, new Double(2.5));
|
||||||
|
XbarSPoint point12 = new XbarSPoint(12, new Double(2.5));
|
||||||
|
XbarSPoint point13 = new XbarSPoint(13,new Double(2.5));
|
||||||
|
XbarSPoint point14 = new XbarSPoint(14,new Double(2.5));
|
||||||
|
XbarSPoint point15 = new XbarSPoint(15,new Double(2.5));
|
||||||
|
XbarSPoint point16 = new XbarSPoint(16,new Double(2));
|
||||||
|
XbarSPoint point17 = new XbarSPoint(17,new Double(2.5));
|
||||||
|
XbarSPoint point18 = new XbarSPoint(18,new Double(2.5));
|
||||||
|
XbarSPoint point19 = new XbarSPoint(19,new Double(2.5));
|
||||||
|
XbarSPoint point20 = new XbarSPoint(20,new Double(2.5));
|
||||||
|
XbarSPoint point21 = new XbarSPoint(21,new Double(2.5));
|
||||||
|
XbarSPoint point22 = new XbarSPoint(22,new Double(2.5));
|
||||||
|
XbarSPoint point23 = new XbarSPoint(23,new Double(2.5));
|
||||||
|
List<Point> list = new ArrayList<>();
|
||||||
|
list.add(point);
|
||||||
|
list.add(point2);
|
||||||
|
list.add(point3);
|
||||||
|
list.add(point4);
|
||||||
|
list.add(point5);
|
||||||
|
list.add(point6);
|
||||||
|
list.add(point7);
|
||||||
|
list.add(point8);
|
||||||
|
list.add(point9);
|
||||||
|
list.add(point10);
|
||||||
|
list.add(point11);
|
||||||
|
list.add(point12);
|
||||||
|
list.add(point13);
|
||||||
|
list.add(point14);
|
||||||
|
list.add(point15);
|
||||||
|
list.add(point16);
|
||||||
|
list.add(point17);
|
||||||
|
list.add(point18);
|
||||||
|
list.add(point19);
|
||||||
|
list.add(point20);
|
||||||
|
list.add(point21);
|
||||||
|
list.add(point22);
|
||||||
|
list.add(point23);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
List<Point> list = createData();
|
// List<Point> list = createData();
|
||||||
ControlLimit controlLimit = new ControlLimit(new Double(12),new Double(2),new Double(1));
|
List<Point> list = createData2();
|
||||||
|
ControlLimit controlLimit = new ControlLimit(new Double(12),new Double(3),new Double(1));
|
||||||
|
System.out.println("controlLimit : "+controlLimit.toString());
|
||||||
//
|
//
|
||||||
// //TEST FOR RULE1
|
// //TEST FOR RULE1
|
||||||
// Boolean aBoolean1 = rule1(list, controlLimit);
|
// Boolean aBoolean1 = rule1(list, controlLimit);
|
||||||
//
|
//
|
||||||
//TEST FOR RULE2
|
//TEST FOR RULE2
|
||||||
// Boolean aBoolean2 = rule2(list, controlLimit, 9);
|
// Boolean aBoolean2 = rule2(list, controlLimit, 5);
|
||||||
// System.out.println();
|
// System.out.println();
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@ -72,7 +135,7 @@ public class StatisticalControlledTest {
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
// //TEST FOR RULE4
|
// //TEST FOR RULE4
|
||||||
// Boolean aBoolean4 = rule4(list, 5);
|
// Boolean aBoolean4 = rule4(list, 6);
|
||||||
// System.out.println();
|
// System.out.println();
|
||||||
|
|
||||||
// //TEST FOR RULE5
|
// //TEST FOR RULE5
|
||||||
@ -80,17 +143,19 @@ public class StatisticalControlledTest {
|
|||||||
// System.out.println();
|
// System.out.println();
|
||||||
|
|
||||||
// //TEST FOR RULE6
|
// //TEST FOR RULE6
|
||||||
// Boolean aBoolean6 = rule6(list, controlLimit, 3,2);
|
// >6 或者 <2.3
|
||||||
|
// Boolean aBoolean6 = rule6(list, controlLimit, 5,4);
|
||||||
// System.out.println();
|
// System.out.println();
|
||||||
|
|
||||||
//TEST FOR RULE7
|
//TEST FOR RULE7
|
||||||
//LC0 = 1.6666 ;; UC1 = 5
|
//LC0 = 1.6666 ;; UC1 = 5
|
||||||
Boolean aBoolean7 = rule7(list, controlLimit,7);
|
// //>2.33 <3
|
||||||
System.out.println();
|
// Boolean aBoolean7 = rule7(list, controlLimit,7);
|
||||||
|
// System.out.println();
|
||||||
|
|
||||||
//TEST FOR RULE8
|
//TEST FOR RULE8
|
||||||
// Boolean aBoolean8 = rule8(list, controlLimit,8);
|
Boolean aBoolean8 = rule8(list, controlLimit,8);
|
||||||
// System.out.println();
|
System.out.println();
|
||||||
|
|
||||||
// int[] array={1,2,3,4,5,6};
|
// int[] array={1,2,3,4,5,6};
|
||||||
// int[] ret=new int[3];
|
// int[] ret=new int[3];
|
||||||
@ -99,6 +164,7 @@ public class StatisticalControlledTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* status : ok
|
||||||
* name : 规则1
|
* name : 规则1
|
||||||
* desc : 控制图上有 1 个点位于三倍标准差以外(对中心线来说)(母体的 $\sigma$ )
|
* desc : 控制图上有 1 个点位于三倍标准差以外(对中心线来说)(母体的 $\sigma$ )
|
||||||
* 注意: 如果存在满足rule1的点,会在原数组 Point.unsatisfiedRules 里标注出来。
|
* 注意: 如果存在满足rule1的点,会在原数组 Point.unsatisfiedRules 里标注出来。
|
||||||
@ -109,7 +175,7 @@ public class StatisticalControlledTest {
|
|||||||
private static Boolean rule1(List<Point> data, ControlLimit controlLimit){
|
private static Boolean rule1(List<Point> data, ControlLimit controlLimit){
|
||||||
Boolean flag = false;
|
Boolean flag = false;
|
||||||
for(Point i:data){
|
for(Point i:data){
|
||||||
if(i.getValue() > controlLimit.getUCL() || i.getValue() < controlLimit.getLCL()){
|
if(i.getValueForInterpretation() > controlLimit.getUCL() || i.getValueForInterpretation() < controlLimit.getLCL()){
|
||||||
i.getUnsatisfiedRules().add(rule1Number);
|
i.getUnsatisfiedRules().add(rule1Number);
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
@ -124,20 +190,23 @@ public class StatisticalControlledTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* status : ok
|
||||||
* name : 规则2
|
* name : 规则2
|
||||||
* desc : 连续 n 点落在中心线的用一侧 (默认:9)
|
* desc : 连续 n 点落在中心线的同一侧 (默认:9)
|
||||||
* 注意: 如果存在满足rule2的点,会在原数组 Point.unsatisfiedRules 里标注出来。
|
* 注意: 如果存在满足rule2的点,会在原数组 Point.unsatisfiedRules 里标注出来。
|
||||||
* return :
|
* return :
|
||||||
* 存在满足rule2的点 => true
|
* 存在满足rule2的点 => true
|
||||||
* 不存在满足rule2的点 => false
|
* 不存在满足rule2的点 => false
|
||||||
* */
|
* */
|
||||||
private static Boolean rule2(List<Point> data, ControlLimit controlLimit,Integer n){
|
private static Boolean rule2(List<Point> data, ControlLimit controlLimit,Integer n){
|
||||||
|
Boolean result = false;
|
||||||
|
|
||||||
List<Point> upList = new ArrayList<>();
|
List<Point> upList = new ArrayList<>();
|
||||||
List<Point> downList = new ArrayList<>();
|
List<Point> downList = new ArrayList<>();
|
||||||
for(Point i:data){
|
for(Point i:data){
|
||||||
if(i.getValue() > controlLimit.getCL()){
|
if(i.getValueForInterpretation() > controlLimit.getCL()){
|
||||||
upList.add(i);
|
upList.add(i);
|
||||||
}else if(i.getValue() < controlLimit.getCL()){
|
}else if(i.getValueForInterpretation() < controlLimit.getCL()){
|
||||||
downList.add(i);
|
downList.add(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -151,15 +220,17 @@ public class StatisticalControlledTest {
|
|||||||
|
|
||||||
while((upi+1) < upList.size()){
|
while((upi+1) < upList.size()){
|
||||||
//if((upList.get(upi).getPosition()+1)==upList.get(upi+1).getPosition()){
|
//if((upList.get(upi).getPosition()+1)==upList.get(upi+1).getPosition()){
|
||||||
if(isBetween(upList.get(upi),upList.get(upi+1))){
|
//|| upi==(n-1)
|
||||||
|
if( isBetween(upList.get(upi),upList.get(upi+1)) || upi==(n-1) ){
|
||||||
uptime +=1;
|
uptime +=1;
|
||||||
forMarkPoints.add(upList.get(upi));
|
forMarkPoints.add(upList.get(upi));
|
||||||
if((upi+1)==upTotalSize){
|
if((upi+1)==(upTotalSize-1)){
|
||||||
uptime +=1;
|
uptime +=1;
|
||||||
forMarkPoints.add(upList.get(upi+1));
|
forMarkPoints.add(upList.get(upi+1));
|
||||||
}
|
}
|
||||||
//只要到达n 了,就return,防止中间段到达 后面又被重置了
|
//只要到达n 了,就return,防止中间段到达 后面又被重置了
|
||||||
if(uptime>=n){
|
if(uptime>=n){
|
||||||
|
result = true;
|
||||||
//1.
|
//1.
|
||||||
for (Point key:forMarkPoints){
|
for (Point key:forMarkPoints){
|
||||||
for(Point j:data){
|
for(Point j:data){
|
||||||
@ -169,14 +240,12 @@ public class StatisticalControlledTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//2.
|
//2.不考虑 return ,先把所有点都找出来。( 重置所有标志位 )
|
||||||
// markUnsatisfiedRulesByKeys(data,forMarkKey,rule2Number);
|
uptime = 0;
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
forMarkPoints = new ArrayList<>();
|
forMarkPoints = new ArrayList<>();
|
||||||
upTotalSize-=1;
|
// upTotalSize--;
|
||||||
uptime = 0;
|
uptime = 0;
|
||||||
}
|
}
|
||||||
upi++;
|
upi++;
|
||||||
@ -189,15 +258,17 @@ public class StatisticalControlledTest {
|
|||||||
Integer totalSize = downList.size();
|
Integer totalSize = downList.size();
|
||||||
forMarkPoints = new ArrayList<>();
|
forMarkPoints = new ArrayList<>();
|
||||||
while((downi+1) < downList.size()){
|
while((downi+1) < downList.size()){
|
||||||
if(isBetween(downList.get(downi),downList.get(downi+1))){
|
//这里之所以 要加上downi==(n-1) 是因为,在比较顺序的时候,要把最后一种可能加上。
|
||||||
|
//|| downi==(n-1)
|
||||||
|
if(isBetween(downList.get(downi),downList.get(downi+1)) || downi==(n-1) ){
|
||||||
downtime +=1;
|
downtime +=1;
|
||||||
forMarkPoints.add(downList.get(downi));
|
forMarkPoints.add(downList.get(downi));
|
||||||
if((downi+1)==totalSize){
|
if((downi+1)==(totalSize-1)){
|
||||||
downtime++;
|
downtime++;
|
||||||
forMarkPoints.add(downList.get(downi+1));
|
forMarkPoints.add(downList.get(downi+1));
|
||||||
}
|
}
|
||||||
if(downtime>=n){
|
if(downtime>=n){
|
||||||
|
result = true;
|
||||||
for (Point key:forMarkPoints){
|
for (Point key:forMarkPoints){
|
||||||
for(Point j:data){
|
for(Point j:data){
|
||||||
if(key.getPosition().equals(j.getPosition())){
|
if(key.getPosition().equals(j.getPosition())){
|
||||||
@ -206,22 +277,22 @@ public class StatisticalControlledTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//2.不考虑 return ,先把所有点都找出来。( 重置所有标志位 )
|
||||||
return true;
|
downtime = 0;
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
totalSize-=1;
|
|
||||||
forMarkPoints = new ArrayList<>();
|
forMarkPoints = new ArrayList<>();
|
||||||
|
// totalSize--;
|
||||||
downtime = 0;
|
downtime = 0;
|
||||||
}
|
}
|
||||||
downi++;
|
downi++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* status : ok
|
||||||
* name : 规则3
|
* name : 规则3
|
||||||
* desc : 连续 n 点递增或者递减 (默认:6)
|
* desc : 连续 n 点递增或者递减 (默认:6)
|
||||||
* 注意: 如果存在满足rule3的点,会在原数组 Point.unsatisfiedRules 里标注出来。
|
* 注意: 如果存在满足rule3的点,会在原数组 Point.unsatisfiedRules 里标注出来。
|
||||||
@ -244,7 +315,9 @@ public class StatisticalControlledTest {
|
|||||||
data.get(key).getUnsatisfiedRules().add(rule3Number);
|
data.get(key).getUnsatisfiedRules().add(rule3Number);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
//不return了, 把所有不满足的点都找出来
|
||||||
|
// return true;
|
||||||
|
uptime = 0;
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
uptime = 0;
|
uptime = 0;
|
||||||
@ -267,7 +340,8 @@ public class StatisticalControlledTest {
|
|||||||
data.get(key).getUnsatisfiedRules().add(rule3Number);
|
data.get(key).getUnsatisfiedRules().add(rule3Number);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
// return true;
|
||||||
|
downtime = 0;
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
downtime = 0;
|
downtime = 0;
|
||||||
@ -280,18 +354,24 @@ public class StatisticalControlledTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* status : ok
|
||||||
* name : 规则4
|
* name : 规则4
|
||||||
* desc : 连续 n 点中 相邻点 交替上下 ( 默认:14 )
|
* desc : 连续 n 点中 相邻点 交替上下 ( 默认:14 ) (n>2)
|
||||||
* 注意: 如果存在满足rule4的点,会在原数组 Point.unsatisfiedRules 里标注出来。
|
* 注意: 如果存在满足rule4的点,会在原数组 Point.unsatisfiedRules 里标注出来。
|
||||||
* return :
|
* return :
|
||||||
* 存在满足rule4的点 => true
|
* 存在满足rule4的点 => true
|
||||||
* 不存在满足rule4的点 => false
|
* 不存在满足rule4的点 => false
|
||||||
* */
|
* */
|
||||||
private static Boolean rule4(List<Point> data, Integer n){
|
private static Boolean rule4(List<Point> data, Integer n){
|
||||||
|
if(n<=2){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Boolean result = false;
|
||||||
Integer upi = 0;
|
Integer upi = 0;
|
||||||
Boolean current;
|
Boolean current;
|
||||||
Boolean nextNeeded;
|
Boolean nextNeeded;
|
||||||
Integer times = 0;
|
Integer times = 0;
|
||||||
|
Integer isAgain = 1;
|
||||||
List<Integer> forMarkKey = new ArrayList<>();
|
List<Integer> forMarkKey = new ArrayList<>();
|
||||||
if(isSmall(data.get(0),data.get(1))){
|
if(isSmall(data.get(0),data.get(1))){
|
||||||
current = true;
|
current = true;
|
||||||
@ -303,11 +383,34 @@ public class StatisticalControlledTest {
|
|||||||
|
|
||||||
while((upi+1) < data.size()){
|
while((upi+1) < data.size()){
|
||||||
if(isBetween( data.get(upi),data.get(upi+1) )){
|
if(isBetween( data.get(upi),data.get(upi+1) )){
|
||||||
//
|
//最后一个节点情况
|
||||||
|
if((upi+1)==(data.size()-1)){
|
||||||
|
|
||||||
|
Double u1 = data.get(upi-1).getValueForInterpretation();
|
||||||
|
Double u2 = data.get(upi).getValueForInterpretation();
|
||||||
|
Double u3 = data.get(upi+1).getValueForInterpretation();
|
||||||
|
if(isUpAndDown(u1,u2,u3)){
|
||||||
|
forMarkKey.add(upi);
|
||||||
|
forMarkKey.add(upi+1);
|
||||||
|
times+=2;
|
||||||
|
}
|
||||||
|
if(times >= n){
|
||||||
|
for(Integer key:forMarkKey){
|
||||||
|
data.get(key).getUnsatisfiedRules().add(rule4Number);
|
||||||
|
}
|
||||||
|
|
||||||
|
//set完了就重置
|
||||||
|
result = true;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//formark 最后一个点的时候
|
||||||
if(forMarkKey.size()==(n-1)){
|
if(forMarkKey.size()==(n-1)){
|
||||||
Double u1 = data.get(upi-2).getValue();
|
Double u1 = data.get(upi-2).getValueForInterpretation();
|
||||||
Double u2 = data.get(upi-1).getValue();
|
Double u2 = data.get(upi-1).getValueForInterpretation();
|
||||||
Double u3 = data.get(upi).getValue();
|
Double u3 = data.get(upi).getValueForInterpretation();
|
||||||
if(isUpAndDown(u1,u2,u3)){
|
if(isUpAndDown(u1,u2,u3)){
|
||||||
forMarkKey.add(upi);
|
forMarkKey.add(upi);
|
||||||
times++;
|
times++;
|
||||||
@ -316,7 +419,16 @@ public class StatisticalControlledTest {
|
|||||||
for(Integer key:forMarkKey){
|
for(Integer key:forMarkKey){
|
||||||
data.get(key).getUnsatisfiedRules().add(rule4Number);
|
data.get(key).getUnsatisfiedRules().add(rule4Number);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
|
//set完了就重置
|
||||||
|
result = true;
|
||||||
|
times=0;
|
||||||
|
forMarkKey = new ArrayList<>();
|
||||||
|
|
||||||
|
//
|
||||||
|
isAgain =2;
|
||||||
|
//
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,6 +440,10 @@ public class StatisticalControlledTest {
|
|||||||
}else {
|
}else {
|
||||||
current = false;
|
current = false;
|
||||||
}
|
}
|
||||||
|
if(isAgain == 2){
|
||||||
|
nextNeeded = current;
|
||||||
|
isAgain = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (current.equals(nextNeeded)){
|
if (current.equals(nextNeeded)){
|
||||||
@ -335,9 +451,9 @@ public class StatisticalControlledTest {
|
|||||||
forMarkKey.add(upi);
|
forMarkKey.add(upi);
|
||||||
//加入最后一个元素的判断
|
//加入最后一个元素的判断
|
||||||
if((upi+1)==(data.size()-1)){
|
if((upi+1)==(data.size()-1)){
|
||||||
Double u0 = data.get(upi - 1).getValue();
|
Double u0 = data.get(upi - 1).getValueForInterpretation();
|
||||||
Double u1 = data.get(upi).getValue();
|
Double u1 = data.get(upi).getValueForInterpretation();
|
||||||
Double u2 = data.get(upi + 1).getValue();
|
Double u2 = data.get(upi + 1).getValueForInterpretation();
|
||||||
if(isUpAndDown(u0,u1,u2)){
|
if(isUpAndDown(u0,u1,u2)){
|
||||||
forMarkKey.add(upi+1);
|
forMarkKey.add(upi+1);
|
||||||
times++;
|
times++;
|
||||||
@ -349,7 +465,14 @@ public class StatisticalControlledTest {
|
|||||||
for(Integer key:forMarkKey){
|
for(Integer key:forMarkKey){
|
||||||
data.get(key).getUnsatisfiedRules().add(rule4Number);
|
data.get(key).getUnsatisfiedRules().add(rule4Number);
|
||||||
}
|
}
|
||||||
return true;
|
// return true;
|
||||||
|
result = true;
|
||||||
|
times=0;
|
||||||
|
forMarkKey = new ArrayList<>();
|
||||||
|
//
|
||||||
|
isAgain =2;
|
||||||
|
//
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
times=0;
|
times=0;
|
||||||
@ -363,7 +486,7 @@ public class StatisticalControlledTest {
|
|||||||
upi++;
|
upi++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -377,6 +500,7 @@ public class StatisticalControlledTest {
|
|||||||
* 不存在满足rule5的点 => false
|
* 不存在满足rule5的点 => false
|
||||||
* */
|
* */
|
||||||
private static Boolean rule5(List<Point> data,ControlLimit controlLimit, Integer m, Integer n){
|
private static Boolean rule5(List<Point> data,ControlLimit controlLimit, Integer m, Integer n){
|
||||||
|
Boolean result = false;
|
||||||
Integer upi = 0;
|
Integer upi = 0;
|
||||||
List<Point> upforMarkKey = new ArrayList<>();
|
List<Point> upforMarkKey = new ArrayList<>();
|
||||||
List<Point> downforMarkKey = new ArrayList<>();
|
List<Point> downforMarkKey = new ArrayList<>();
|
||||||
@ -401,37 +525,43 @@ public class StatisticalControlledTest {
|
|||||||
Integer upTimes = 0;
|
Integer upTimes = 0;
|
||||||
Integer downTimes = 0;
|
Integer downTimes = 0;
|
||||||
for(Point i:keyList){
|
for(Point i:keyList){
|
||||||
if(i.getValue()>controlLimitDetail.getUB()[1]){
|
if(i.getValueForInterpretation()>controlLimitDetail.getUB()[1]){
|
||||||
upTimes++;
|
upTimes++;
|
||||||
upforMarkKey.add(i);
|
upforMarkKey.add(i);
|
||||||
System.out.println();
|
System.out.println();
|
||||||
}
|
}
|
||||||
if(i.getValue()<controlLimitDetail.getLB()[0]){
|
if(i.getValueForInterpretation()<controlLimitDetail.getLB()[0]){
|
||||||
downTimes++;
|
downTimes++;
|
||||||
downforMarkKey.add(i);
|
downforMarkKey.add(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(upTimes>=n || downTimes>=n){
|
if(upTimes>=n || downTimes>=n){
|
||||||
|
result = true;
|
||||||
if(upTimes>=n){
|
if(upTimes>=n){
|
||||||
for(Point i:upforMarkKey){
|
for(Point i:upforMarkKey){
|
||||||
i.getUnsatisfiedRules().add(rule5Number);
|
i.getUnsatisfiedRules().add(rule5Number);
|
||||||
}
|
}
|
||||||
return true;
|
upforMarkKey = new ArrayList<>();
|
||||||
|
// return true;
|
||||||
}
|
}
|
||||||
if(downTimes>=n){
|
if(downTimes>=n){
|
||||||
for(Point i:downforMarkKey){
|
for(Point i:downforMarkKey){
|
||||||
i.getUnsatisfiedRules().add(rule5Number);
|
i.getUnsatisfiedRules().add(rule5Number);
|
||||||
}
|
}
|
||||||
return true;
|
downforMarkKey = new ArrayList<>();
|
||||||
|
// return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
// return true;
|
||||||
|
}else {
|
||||||
|
upforMarkKey = new ArrayList<>();
|
||||||
|
downforMarkKey = new ArrayList<>();
|
||||||
}
|
}
|
||||||
upi++;
|
upi++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return false;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -443,6 +573,7 @@ public class StatisticalControlledTest {
|
|||||||
* 不存在满足rule6的点 => false
|
* 不存在满足rule6的点 => false
|
||||||
* */
|
* */
|
||||||
private static Boolean rule6(List<Point> data,ControlLimit controlLimit, Integer m, Integer n){
|
private static Boolean rule6(List<Point> data,ControlLimit controlLimit, Integer m, Integer n){
|
||||||
|
Boolean result = false;
|
||||||
Integer upi = 0;
|
Integer upi = 0;
|
||||||
List<Point> upforMarkKey = new ArrayList<>();
|
List<Point> upforMarkKey = new ArrayList<>();
|
||||||
List<Point> downforMarkKey = new ArrayList<>();
|
List<Point> downforMarkKey = new ArrayList<>();
|
||||||
@ -467,37 +598,47 @@ public class StatisticalControlledTest {
|
|||||||
Integer upTimes = 0;
|
Integer upTimes = 0;
|
||||||
Integer downTimes = 0;
|
Integer downTimes = 0;
|
||||||
for(Point i:keyList){
|
for(Point i:keyList){
|
||||||
if(i.getValue()>controlLimitDetail.getUC()[1]){
|
if(i.getValueForInterpretation()>controlLimitDetail.getUC()[1]){
|
||||||
upTimes++;
|
upTimes++;
|
||||||
upforMarkKey.add(i);
|
upforMarkKey.add(i);
|
||||||
System.out.println();
|
|
||||||
}
|
}
|
||||||
if(i.getValue()<controlLimitDetail.getLC()[0]){
|
if(i.getValueForInterpretation()<controlLimitDetail.getLC()[0]){
|
||||||
downTimes++;
|
downTimes++;
|
||||||
downforMarkKey.add(i);
|
downforMarkKey.add(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(upTimes>=n || downTimes>=n){
|
if(upTimes>=n || downTimes>=n){
|
||||||
|
result = true;
|
||||||
if(upTimes>=n){
|
if(upTimes>=n){
|
||||||
for(Point i:upforMarkKey){
|
for(Point i:upforMarkKey){
|
||||||
|
|
||||||
i.getUnsatisfiedRules().add(rule6Number);
|
i.getUnsatisfiedRules().add(rule6Number);
|
||||||
}
|
}
|
||||||
return true;
|
upforMarkKey = new ArrayList<>();
|
||||||
|
// return true;
|
||||||
}
|
}
|
||||||
if(downTimes>=n){
|
if(downTimes>=n){
|
||||||
for(Point i:downforMarkKey){
|
for(Point i:downforMarkKey){
|
||||||
|
if(i.getPosition() == 13){
|
||||||
|
System.out.println(1);
|
||||||
|
}
|
||||||
i.getUnsatisfiedRules().add(rule6Number);
|
i.getUnsatisfiedRules().add(rule6Number);
|
||||||
}
|
}
|
||||||
return true;
|
// return true;
|
||||||
|
downforMarkKey = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
// return true;
|
||||||
|
}else {
|
||||||
|
upforMarkKey = new ArrayList<>();
|
||||||
|
downforMarkKey = new ArrayList<>();
|
||||||
}
|
}
|
||||||
upi++;
|
upi++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return false;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -510,6 +651,7 @@ public class StatisticalControlledTest {
|
|||||||
* */
|
* */
|
||||||
private static Boolean rule7(List<Point> data,ControlLimit controlLimit, Integer n){
|
private static Boolean rule7(List<Point> data,ControlLimit controlLimit, Integer n){
|
||||||
|
|
||||||
|
Boolean result = false;
|
||||||
|
|
||||||
//Integer upi = 0;
|
//Integer upi = 0;
|
||||||
ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL());
|
ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL());
|
||||||
@ -522,7 +664,7 @@ public class StatisticalControlledTest {
|
|||||||
//判断最后一次
|
//判断最后一次
|
||||||
if((i+1) == data.size()){
|
if((i+1) == data.size()){
|
||||||
Point point = data.get(i);
|
Point point = data.get(i);
|
||||||
if(point.getValue()>controlLimitDetail.getLC()[0] && point.getValue()<controlLimitDetail.getUC()[1]){
|
if(point.getValueForInterpretation()>controlLimitDetail.getLC()[0] && point.getValueForInterpretation()<controlLimitDetail.getUC()[1]){
|
||||||
times++;
|
times++;
|
||||||
markKey.add(point);
|
markKey.add(point);
|
||||||
if(times.equals(n)){
|
if(times.equals(n)){
|
||||||
@ -541,14 +683,17 @@ public class StatisticalControlledTest {
|
|||||||
//通常情况
|
//通常情况
|
||||||
Point point = data.get(i);
|
Point point = data.get(i);
|
||||||
if( isBetween( data.get(i),data.get(i+1) ) ){
|
if( isBetween( data.get(i),data.get(i+1) ) ){
|
||||||
if(point.getValue()>controlLimitDetail.getLC()[0] && point.getValue()<controlLimitDetail.getUC()[1]){
|
if(point.getValueForInterpretation()>controlLimitDetail.getLC()[0] && point.getValueForInterpretation()<controlLimitDetail.getUC()[1]){
|
||||||
times++;
|
times++;
|
||||||
markKey.add(point);
|
markKey.add(point);
|
||||||
if(times.equals(n)){
|
if(times.equals(n)){
|
||||||
for(Point j:markKey){
|
for(Point j:markKey){
|
||||||
j.getUnsatisfiedRules().add(rule7Number);
|
j.getUnsatisfiedRules().add(rule7Number);
|
||||||
}
|
}
|
||||||
return true;
|
// return true;
|
||||||
|
result = true;
|
||||||
|
times = 0;
|
||||||
|
markKey = new ArrayList<>();
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
times = 0;
|
times = 0;
|
||||||
@ -559,7 +704,7 @@ public class StatisticalControlledTest {
|
|||||||
markKey = new ArrayList<>();
|
markKey = new ArrayList<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -572,7 +717,7 @@ public class StatisticalControlledTest {
|
|||||||
* */
|
* */
|
||||||
private static Boolean rule8(List<Point> data,ControlLimit controlLimit, Integer n){
|
private static Boolean rule8(List<Point> data,ControlLimit controlLimit, Integer n){
|
||||||
|
|
||||||
|
Boolean result = true;
|
||||||
//Integer upi = 0;
|
//Integer upi = 0;
|
||||||
ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL());
|
ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL());
|
||||||
System.out.println(controlLimitDetail.toString());
|
System.out.println(controlLimitDetail.toString());
|
||||||
@ -584,7 +729,7 @@ public class StatisticalControlledTest {
|
|||||||
//判断最后一次
|
//判断最后一次
|
||||||
if((i+1) == data.size()){
|
if((i+1) == data.size()){
|
||||||
Point point = data.get(i);
|
Point point = data.get(i);
|
||||||
if( point.getValue()>controlLimitDetail.getUC()[1] || point.getValue()<controlLimitDetail.getLC()[0] ){
|
if( point.getValueForInterpretation()>controlLimitDetail.getUC()[1] || point.getValueForInterpretation()<controlLimitDetail.getLC()[0] ){
|
||||||
times++;
|
times++;
|
||||||
markKey.add(point);
|
markKey.add(point);
|
||||||
if(times.equals(n)){
|
if(times.equals(n)){
|
||||||
@ -603,14 +748,16 @@ public class StatisticalControlledTest {
|
|||||||
//通常情况
|
//通常情况
|
||||||
Point point = data.get(i);
|
Point point = data.get(i);
|
||||||
if( isBetween( data.get(i),data.get(i+1) ) ){
|
if( isBetween( data.get(i),data.get(i+1) ) ){
|
||||||
if( point.getValue()>controlLimitDetail.getUC()[1] || point.getValue()<controlLimitDetail.getLC()[0] ){
|
if( point.getValueForInterpretation()>controlLimitDetail.getUC()[1] || point.getValueForInterpretation()<controlLimitDetail.getLC()[0] ){
|
||||||
times++;
|
times++;
|
||||||
markKey.add(point);
|
markKey.add(point);
|
||||||
if(times.equals(n)){
|
if(times.equals(n)){
|
||||||
for(Point j:markKey){
|
for(Point j:markKey){
|
||||||
j.getUnsatisfiedRules().add(rule8Number);
|
j.getUnsatisfiedRules().add(rule8Number);
|
||||||
}
|
}
|
||||||
return true;
|
result = true;
|
||||||
|
times = 0;
|
||||||
|
markKey = new ArrayList<>();
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
times = 0;
|
times = 0;
|
||||||
@ -621,7 +768,7 @@ public class StatisticalControlledTest {
|
|||||||
markKey = new ArrayList<>();
|
markKey = new ArrayList<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -634,13 +781,13 @@ public class StatisticalControlledTest {
|
|||||||
* 如果 head 小于 after ==》 true
|
* 如果 head 小于 after ==》 true
|
||||||
* */
|
* */
|
||||||
private static boolean isSmall(Point head,Point after){
|
private static boolean isSmall(Point head,Point after){
|
||||||
return (head.getValue()- after.getValue()) < 0;
|
return (head.getValueForInterpretation()- after.getValueForInterpretation()) < 0;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 如果 head 大于 after ==》 true
|
* 如果 head 大于 after ==》 true
|
||||||
* */
|
* */
|
||||||
private static boolean isBig(Point head,Point after){
|
private static boolean isBig(Point head,Point after){
|
||||||
return (head.getValue()- after.getValue()) > 0;
|
return (head.getValueForInterpretation()- after.getValueForInterpretation()) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.cnbm.qualityPlanning.entity;
|
package com.cnbm.qualityPlanning.entity;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -8,12 +10,16 @@ import lombok.Data;
|
|||||||
* @DATE: 2022/7/12 15:17
|
* @DATE: 2022/7/12 15:17
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@ApiModel(value = "控制限")
|
||||||
public class ControlLimit {
|
public class ControlLimit {
|
||||||
//控制上限
|
//控制上限
|
||||||
|
@ApiModelProperty(value = "控制上限")
|
||||||
private Double UCL;
|
private Double UCL;
|
||||||
//控制中心线
|
//控制中心线
|
||||||
|
@ApiModelProperty(value = "控制中心线")
|
||||||
private Double CL;
|
private Double CL;
|
||||||
//控制下限
|
//控制下限
|
||||||
|
@ApiModelProperty(value = "控制下限")
|
||||||
private Double LCL;
|
private Double LCL;
|
||||||
|
|
||||||
public ControlLimit(Double UCL,Double CL,Double LCL){
|
public ControlLimit(Double UCL,Double CL,Double LCL){
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.cnbm.qualityPlanning.entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Desc: ""
|
||||||
|
* @Author: caixiang
|
||||||
|
* @DATE: 2022/7/25 16:31
|
||||||
|
*/
|
||||||
|
public class PCWarming {
|
||||||
|
}
|
@ -1,10 +1,8 @@
|
|||||||
package com.cnbm.qualityPlanning.entity;
|
package com.cnbm.qualityPlanning.entity;
|
||||||
|
|
||||||
import io.swagger.models.auth.In;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -15,14 +13,14 @@ import java.util.Set;
|
|||||||
@Data
|
@Data
|
||||||
public class Point {
|
public class Point {
|
||||||
private Integer position;
|
private Integer position;
|
||||||
private Double value;
|
private Double valueForInterpretation;
|
||||||
|
|
||||||
//不满足的 规则 例子 : [1,2] => 代表 不满足 规则1 和 规则2
|
//不满足的 规则 例子 : [1,2] => 代表 不满足 规则1 和 规则2
|
||||||
private Set<Integer> unsatisfiedRules;
|
private Set<Integer> unsatisfiedRules;
|
||||||
|
|
||||||
public Point(Integer position , Double value){
|
public Point(Integer position , Double valueForInterpretation){
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.value = value;
|
this.valueForInterpretation = valueForInterpretation;
|
||||||
this.unsatisfiedRules = new HashSet();
|
this.unsatisfiedRules = new HashSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
package com.cnbm.qualityPlanning.entity;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Desc: ""
|
||||||
|
* @Author: caixiang
|
||||||
|
* @DATE: 2022/7/12 15:17
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "工序能力")
|
||||||
|
public class ProcessCapability {
|
||||||
|
//工序能力指数CP
|
||||||
|
@ApiModelProperty(value = "工序能力指数CP")
|
||||||
|
private Double CP;
|
||||||
|
//实际工序能力指数CPK
|
||||||
|
@ApiModelProperty(value = "实际工序能力指数CPK")
|
||||||
|
private Double CPK;
|
||||||
|
//上侧规范 工序能力指数CPU
|
||||||
|
@ApiModelProperty(value = "上侧规范 工序能力指数CPU")
|
||||||
|
private Double CPU;
|
||||||
|
//下侧规范 工序能力指数CPL
|
||||||
|
@ApiModelProperty(value = "下侧规范 工序能力指数CPL")
|
||||||
|
private Double CPL;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "工序能力报警")
|
||||||
|
private List<String> warming;
|
||||||
|
|
||||||
|
public ProcessCapability(Double CP, Double CPK, Double CPU, Double CPL,List<String> warming) {
|
||||||
|
this.CP = CP;
|
||||||
|
this.CPK = CPK;
|
||||||
|
this.CPU = CPU;
|
||||||
|
this.CPL = CPL;
|
||||||
|
this.warming = warming;
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package com.cnbm.qualityPlanning.entity;
|
package com.cnbm.qualityPlanning.entity;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -8,11 +10,21 @@ import lombok.Data;
|
|||||||
* @DATE: 2022/7/12 15:19
|
* @DATE: 2022/7/12 15:19
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@ApiModel(value = "规格限")
|
||||||
public class SpecificationLimit {
|
public class SpecificationLimit {
|
||||||
//规格上限
|
//规格上限
|
||||||
private Double USL;
|
@ApiModelProperty(value = "规格上限")
|
||||||
|
private Float USL;
|
||||||
//规格中心线
|
//规格中心线
|
||||||
private Double SL;
|
@ApiModelProperty(value = "规格中心限")
|
||||||
|
private Float SL;
|
||||||
//规格下限
|
//规格下限
|
||||||
private Double LSL;
|
@ApiModelProperty(value = "规格下限")
|
||||||
|
private Float LSL;
|
||||||
|
|
||||||
|
public SpecificationLimit(Float USL, Float SL, Float LSL) {
|
||||||
|
this.USL = USL;
|
||||||
|
this.SL = SL;
|
||||||
|
this.LSL = LSL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,84 @@
|
|||||||
|
package com.cnbm.qualityPlanning.entity;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Desc: "整合,处理好 后的一行数据 (sampleSize 后的数据) "
|
||||||
|
* @Author: caixiang
|
||||||
|
* @DATE: 2022/7/21 9:43
|
||||||
|
*/
|
||||||
|
public class XbarSPoint extends Point {
|
||||||
|
List<Double> data = new ArrayList<>();
|
||||||
|
private Double xbar;
|
||||||
|
private Double s;
|
||||||
|
private Double r;
|
||||||
|
//position 是这个数据在数组中的位置 ;; value 是待被判读方案 分析的value(从 xbar、s、r 中选一)
|
||||||
|
public XbarSPoint(Integer position, Double value) {
|
||||||
|
super(position, value);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
public Double getXbar() {
|
||||||
|
return xbar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setXbar(Double xbar) {
|
||||||
|
this.xbar = xbar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getS() {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setS(Double s) {
|
||||||
|
this.s = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getR() {
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setR(Double r) {
|
||||||
|
this.r = r;
|
||||||
|
}
|
||||||
|
|
||||||
|
public XbarSPoint(Integer position, Double value, Double xbar, Double s, Double r) {
|
||||||
|
super(position,value);
|
||||||
|
this.xbar = xbar;
|
||||||
|
this.s = s;
|
||||||
|
this.r = r;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getPosition() {
|
||||||
|
return super.getPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Double getValueForInterpretation() {
|
||||||
|
return super.getValueForInterpretation();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Integer> getUnsatisfiedRules() {
|
||||||
|
return super.getUnsatisfiedRules();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPosition(Integer position) {
|
||||||
|
super.setPosition(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setValueForInterpretation(Double valueForInterpretation) {
|
||||||
|
super.setValueForInterpretation(valueForInterpretation);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUnsatisfiedRules(Set<Integer> unsatisfiedRules) {
|
||||||
|
super.setUnsatisfiedRules(unsatisfiedRules);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user