新增:XMR 控制图
This commit is contained in:
parent
227a27295d
commit
e9c8f7857b
@ -9,21 +9,19 @@ import com.cnbm.common.vo.R;
|
|||||||
import com.cnbm.influx.constant.Constant;
|
import com.cnbm.influx.constant.Constant;
|
||||||
import com.cnbm.influx.param.QueryDataParam;
|
import com.cnbm.influx.param.QueryDataParam;
|
||||||
import com.cnbm.influx.param.Range;
|
import com.cnbm.influx.param.Range;
|
||||||
import com.cnbm.processInspection.dto.GraphArg;
|
import com.cnbm.processInspection.dto.*;
|
||||||
import com.cnbm.processInspection.dto.InterpretationListArg;
|
|
||||||
import com.cnbm.processInspection.dto.XbarRGraphData;
|
|
||||||
import com.cnbm.processInspection.dto.XbarSGraphData;
|
|
||||||
import com.cnbm.processInspection.graphAnalyzed.mr.MeanRGraph;
|
import com.cnbm.processInspection.graphAnalyzed.mr.MeanRGraph;
|
||||||
import com.cnbm.processInspection.graphAnalyzed.ms.MeanStandardDeviationGraph;
|
import com.cnbm.processInspection.graphAnalyzed.ms.MeanStandardDeviationGraph;
|
||||||
|
import com.cnbm.processInspection.graphAnalyzed.xmr.XMRGraph;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -106,7 +104,49 @@ public class ProcessInspectionController {
|
|||||||
|
|
||||||
return R.ok("成功",xbarSGraphData);
|
return R.ok("成功",xbarSGraphData);
|
||||||
}
|
}
|
||||||
|
@PostMapping("/XMRGraphTest")
|
||||||
|
public R<XMRGraphData> XMRGraphTest() 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(1);
|
||||||
|
XMRGraph xmrGraph = new XMRGraph(productFeatures);
|
||||||
|
//判读方案
|
||||||
|
List<InterpretationListArg> interpretationScheme = new ArrayList<>();
|
||||||
|
interpretationScheme.add(new InterpretationListArg(1,null,null));
|
||||||
|
interpretationScheme.add(new InterpretationListArg(5,3,2));
|
||||||
|
xmrGraph.isNeedInterpretation(interpretationScheme);
|
||||||
|
|
||||||
|
|
||||||
|
QueryDataParam queryDataParam = new QueryDataParam();
|
||||||
|
queryDataParam.setMeasurement("Weight");
|
||||||
|
queryDataParam.setRange(new Range(DataUtils.getBeforeDate(10).toInstant(), Instant.now()));
|
||||||
|
xmrGraph.initialDate(queryDataParam);
|
||||||
|
|
||||||
|
XMRGraphData xmrGraphData = new XMRGraphData(
|
||||||
|
xmrGraph.getXmrGraphEntity(),
|
||||||
|
xmrGraph.getXCL(),
|
||||||
|
xmrGraph.getRSCL(),
|
||||||
|
xmrGraph.getSpecificationLimit(),
|
||||||
|
xmrGraph.getProcessCapacity(),
|
||||||
|
new StandardDiviation(xmrGraph.getXigma(),xmrGraph.getTotalXigma())
|
||||||
|
);
|
||||||
|
|
||||||
|
return R.ok("成功",xmrGraphData);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ProductFeatures setRealSampleSize(GraphArg graphArg){
|
||||||
|
ProductFeaturesDTO productFeaturesDTO = productFeaturesService.get(graphArg.getProductFeaturesId());
|
||||||
|
if(graphArg.getSampleSize()!=null){
|
||||||
|
productFeaturesDTO.setSampleSize(graphArg.getSampleSize());
|
||||||
|
}
|
||||||
|
ProductFeatures productFeatures = new ProductFeatures();
|
||||||
|
BeanUtils.copyProperties(productFeaturesDTO, productFeatures);
|
||||||
|
return productFeatures;
|
||||||
|
}
|
||||||
|
|
||||||
//筛选条件顺序:
|
//筛选条件顺序:
|
||||||
// ① 先工厂(产品表) => ② 检验类型(产品表)=> ③ 产品名(产品表)=> ④ 工序(产品表)=> ⑤ 特性(检验参数name)( product_features 表) ;;
|
// ① 先工厂(产品表) => ② 检验类型(产品表)=> ③ 产品名(产品表)=> ④ 工序(产品表)=> ⑤ 特性(检验参数name)( product_features 表) ;;
|
||||||
@ -116,8 +156,7 @@ public class ProcessInspectionController {
|
|||||||
// 3.检验类型(产品表) ; 4.产品名 (产品表); 5.工艺流程(就是工序 ,也是设备名,用到工序表); 6.特性(product_features.name ,也是influxdb中的argName) ;
|
// 3.检验类型(产品表) ; 4.产品名 (产品表); 5.工艺流程(就是工序 ,也是设备名,用到工序表); 6.特性(product_features.name ,也是influxdb中的argName) ;
|
||||||
@PostMapping("/XbarSGraph")
|
@PostMapping("/XbarSGraph")
|
||||||
public R<XbarSGraphData> xbarSGraph(@RequestBody GraphArg graphArg) throws Exception {
|
public R<XbarSGraphData> xbarSGraph(@RequestBody GraphArg graphArg) throws Exception {
|
||||||
|
ProductFeatures productFeatures = setRealSampleSize(graphArg);
|
||||||
ProductFeatures productFeatures = graphArg.getProductFeatures();
|
|
||||||
|
|
||||||
MeanStandardDeviationGraph meanStandardDeviationGraph = new MeanStandardDeviationGraph(productFeatures);
|
MeanStandardDeviationGraph meanStandardDeviationGraph = new MeanStandardDeviationGraph(productFeatures);
|
||||||
if(graphArg.getInterpretationScheme()!=null){
|
if(graphArg.getInterpretationScheme()!=null){
|
||||||
@ -143,8 +182,8 @@ public class ProcessInspectionController {
|
|||||||
@PostMapping("/XbarRGraph")
|
@PostMapping("/XbarRGraph")
|
||||||
public R<XbarRGraphData> XbarRGraph(@RequestBody GraphArg graphArg) throws Exception {
|
public R<XbarRGraphData> XbarRGraph(@RequestBody GraphArg graphArg) throws Exception {
|
||||||
|
|
||||||
//new 对象
|
ProductFeatures productFeatures = setRealSampleSize(graphArg);
|
||||||
ProductFeatures productFeatures = graphArg.getProductFeatures();
|
|
||||||
MeanRGraph meanRGraph = new MeanRGraph(productFeatures);
|
MeanRGraph meanRGraph = new MeanRGraph(productFeatures);
|
||||||
//如果要检验,,那么set 判读方案
|
//如果要检验,,那么set 判读方案
|
||||||
if(graphArg.getInterpretationScheme()!=null){
|
if(graphArg.getInterpretationScheme()!=null){
|
||||||
@ -168,4 +207,32 @@ public class ProcessInspectionController {
|
|||||||
return R.ok("成功",xbarSGraphData);
|
return R.ok("成功",xbarSGraphData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/XMRGraph")
|
||||||
|
public R<XMRGraphData> XMRGraph(@RequestBody GraphArg graphArg) throws Exception {
|
||||||
|
|
||||||
|
ProductFeatures productFeatures = setRealSampleSize(graphArg);
|
||||||
|
|
||||||
|
XMRGraph xmrGraph = new XMRGraph(productFeatures);
|
||||||
|
//如果要检验,,那么set 判读方案
|
||||||
|
if(graphArg.getInterpretationScheme()!=null){
|
||||||
|
xmrGraph.isNeedInterpretation(graphArg.getInterpretationScheme());
|
||||||
|
}
|
||||||
|
|
||||||
|
QueryDataParam queryDataParam = new QueryDataParam();
|
||||||
|
queryDataParam.setMeasurement(Constant.measurement);
|
||||||
|
queryDataParam.setRange(new Range(graphArg.getBegin().toInstant(), graphArg.getEnd().toInstant()));
|
||||||
|
xmrGraph.initialDate(queryDataParam);
|
||||||
|
|
||||||
|
XMRGraphData xmrGraphData = new XMRGraphData(
|
||||||
|
xmrGraph.getXmrGraphEntity(),
|
||||||
|
xmrGraph.getXCL(),
|
||||||
|
xmrGraph.getRSCL(),
|
||||||
|
xmrGraph.getSpecificationLimit(),
|
||||||
|
xmrGraph.getProcessCapacity(),
|
||||||
|
new StandardDiviation(xmrGraph.getXigma(),xmrGraph.getTotalXigma())
|
||||||
|
);
|
||||||
|
|
||||||
|
return R.ok("成功",xmrGraphData);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@ import java.util.List;
|
|||||||
@Data
|
@Data
|
||||||
@ApiModel(value = "控制图 查询参数类")
|
@ApiModel(value = "控制图 查询参数类")
|
||||||
public class GraphArg {
|
public class GraphArg {
|
||||||
@ApiModelProperty(value = "检验特性,,全量传过来")
|
@ApiModelProperty(value = "检验特性Id")
|
||||||
private ProductFeatures productFeatures;
|
private Long productFeaturesId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "查询时间段,开始")
|
@ApiModelProperty(value = "查询时间段,开始")
|
||||||
private Date begin;
|
private Date begin;
|
||||||
|
@ -0,0 +1,45 @@
|
|||||||
|
package com.cnbm.processInspection.dto;
|
||||||
|
|
||||||
|
import com.cnbm.common.spc.math.StandardDiviation;
|
||||||
|
import com.cnbm.processInspection.graphAnalyzed.xmr.XMRGraphEntity;
|
||||||
|
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 XMRGraphData {
|
||||||
|
@ApiModelProperty(value = "控制图list数据")
|
||||||
|
private XMRGraphEntity xmrGraphEntity;
|
||||||
|
@ApiModelProperty(value = "xbar控制图 控制限")
|
||||||
|
private ControlLimit XBarCL;
|
||||||
|
@ApiModelProperty(value = "R控制图 控制限")
|
||||||
|
private ControlLimit RCL;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "工艺规格限")
|
||||||
|
private SpecificationLimit SL;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "工序能力")
|
||||||
|
private ProcessCapability processCapability;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "标准差/总体标准差")
|
||||||
|
private StandardDiviation standardDiviation;
|
||||||
|
|
||||||
|
|
||||||
|
public XMRGraphData(XMRGraphEntity xmrGraphEntity, ControlLimit xBarCL, ControlLimit rCL, SpecificationLimit sl, ProcessCapability processCapability, StandardDiviation standardDiviation){
|
||||||
|
this.xmrGraphEntity = xmrGraphEntity;
|
||||||
|
this.XBarCL = xBarCL;
|
||||||
|
this.RCL = rCL;
|
||||||
|
this.SL = sl;
|
||||||
|
this.processCapability = processCapability;
|
||||||
|
this.standardDiviation = standardDiviation;
|
||||||
|
}
|
||||||
|
}
|
@ -106,7 +106,6 @@ public class MeanRGraph {
|
|||||||
dropNames.add("inspectionSheetId");
|
dropNames.add("inspectionSheetId");
|
||||||
queryDataParam.setDropedTagNames(dropNames);
|
queryDataParam.setDropedTagNames(dropNames);
|
||||||
queryDataParam.setTag(new Tag("argName",argName));
|
queryDataParam.setTag(new Tag("argName",argName));
|
||||||
queryDataParam.setRange(new Range(DataUtils.getBeforeDate(10).toInstant(), Instant.now()));
|
|
||||||
|
|
||||||
List<FluxTable> query = InfluxClient.Client.query(queryDataParam);
|
List<FluxTable> query = InfluxClient.Client.query(queryDataParam);
|
||||||
//1. 先从fluxdb 里面提取原始数据
|
//1. 先从fluxdb 里面提取原始数据
|
||||||
|
@ -103,7 +103,6 @@ public class MeanStandardDeviationGraph {
|
|||||||
dropNames.add("inspectionSheetId");
|
dropNames.add("inspectionSheetId");
|
||||||
queryDataParam.setDropedTagNames(dropNames);
|
queryDataParam.setDropedTagNames(dropNames);
|
||||||
queryDataParam.setTag(new Tag("argName",argName));
|
queryDataParam.setTag(new Tag("argName",argName));
|
||||||
queryDataParam.setRange(new Range(DataUtils.getBeforeDate(10).toInstant(), Instant.now()));
|
|
||||||
|
|
||||||
List<FluxTable> query = InfluxClient.Client.query(queryDataParam);
|
List<FluxTable> query = InfluxClient.Client.query(queryDataParam);
|
||||||
//1. 先从fluxdb 里面提取原始数据
|
//1. 先从fluxdb 里面提取原始数据
|
||||||
|
@ -0,0 +1,301 @@
|
|||||||
|
package com.cnbm.processInspection.graphAnalyzed.xmr;
|
||||||
|
|
||||||
|
import com.cnbm.basic.entity.ProductFeatures;
|
||||||
|
import com.cnbm.common.spc.math.Math;
|
||||||
|
import com.cnbm.common.spc.math.StandardDiviation;
|
||||||
|
import com.cnbm.influx.config.InfluxClient;
|
||||||
|
import com.cnbm.influx.constant.Constant;
|
||||||
|
import com.cnbm.influx.param.QueryDataParam;
|
||||||
|
import com.cnbm.influx.param.Tag;
|
||||||
|
import com.cnbm.processInspection.dto.InterpretationListArg;
|
||||||
|
import com.cnbm.qualityPlanning.common.StatisticalControlledTest;
|
||||||
|
import com.cnbm.qualityPlanning.entity.*;
|
||||||
|
import com.influxdb.query.FluxRecord;
|
||||||
|
import com.influxdb.query.FluxTable;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Desc: "均值标准差 控制图 , 计算类"
|
||||||
|
* @Author: caixiang
|
||||||
|
* @DATE: 2022/7/20 14:26
|
||||||
|
* 使用方式:① 先new MeanStandardDeviationGraph 对象 ;② 再initialData 初始化数据;③ 再get 控制限
|
||||||
|
*
|
||||||
|
* 步骤:
|
||||||
|
* ① 先读mysql表,查询 product_features 表,先读到 sample_size(样本量)
|
||||||
|
* ② 再依据 influx.argName == mysql.product_feature.name && 时间段 查询所有的 参数数据
|
||||||
|
* ③ 拿到参数数据后,分组 整合成List<Point>,
|
||||||
|
* 计算控制限
|
||||||
|
* 计算 母体 的 \sigma 、 bar{x} 。。。
|
||||||
|
* 计算CPK 、CPU 、CPL这些
|
||||||
|
* ④ 如果配置了判读方案,还要 调用 StatisticalControlledTest Function 检验。
|
||||||
|
* ⑤
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class XMRGraph {
|
||||||
|
//母体的 μ = xbarbar
|
||||||
|
private Double miu;
|
||||||
|
//母体的 xigma ,全局计算的;
|
||||||
|
private Double xigma;
|
||||||
|
//母体的 xigma ,全局计算的;
|
||||||
|
private Double totalXigma;
|
||||||
|
|
||||||
|
//需要去检验的 判读方案 eg:[1,2,3,4,6]
|
||||||
|
private List<InterpretationListArg> interpretationScheme;
|
||||||
|
|
||||||
|
//这里 是特有参数 -- begin
|
||||||
|
|
||||||
|
//单值移动极差 控制图 xbar == xbarbar
|
||||||
|
private Double xbar;
|
||||||
|
private Double rsbar;
|
||||||
|
//这里 是特有参数 -- end
|
||||||
|
|
||||||
|
private Integer sampleSize;
|
||||||
|
private String argName;
|
||||||
|
|
||||||
|
private SpecificationLimit specificationLimit;
|
||||||
|
private XMRGraphEntity xmrGraphEntity;
|
||||||
|
|
||||||
|
|
||||||
|
public XMRGraph(ProductFeatures productFeatures) throws Exception {
|
||||||
|
if(productFeatures.getSampleSize()==null || productFeatures.getName()==null){
|
||||||
|
throw new Exception("ProductFeatures 参数异常");
|
||||||
|
}
|
||||||
|
this.argName = productFeatures.getName();
|
||||||
|
this.sampleSize = 1;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void isNeedInterpretation(List<InterpretationListArg> list){
|
||||||
|
this.interpretationScheme = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* name : 初始化数据函数
|
||||||
|
* desc : 从influxdb 里面读取数据,然后 加工处理成 我需要的
|
||||||
|
* 步骤:
|
||||||
|
* ①
|
||||||
|
* */
|
||||||
|
public void initialDate(QueryDataParam queryDataParam){
|
||||||
|
queryDataParam.setBucket(Constant.bucket);
|
||||||
|
List<String> dropNames = new ArrayList<>();
|
||||||
|
dropNames.add("transationId");
|
||||||
|
dropNames.add("inspectionSheetId");
|
||||||
|
queryDataParam.setDropedTagNames(dropNames);
|
||||||
|
queryDataParam.setTag(new Tag("argName",argName));
|
||||||
|
|
||||||
|
|
||||||
|
List<FluxTable> query = InfluxClient.Client.query(queryDataParam);
|
||||||
|
//1. 先从fluxdb 里面提取原始数据
|
||||||
|
List<Double> originData = new ArrayList<>();
|
||||||
|
for (FluxTable fluxTable : query) {
|
||||||
|
List<FluxRecord> records = fluxTable.getRecords();
|
||||||
|
for (FluxRecord fluxRecord : records) {
|
||||||
|
//因为 传进去的就是Double 类型,所以取出来,自然而然就是Double
|
||||||
|
originData.add(Double.parseDouble(fluxRecord.getValueByKey("_value").toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//2. convert to XbarSPoint
|
||||||
|
List<XMRPoint> list = new ArrayList<>();
|
||||||
|
Double lastOne = (double) 0;
|
||||||
|
List<Double> rsArray = new ArrayList<>();
|
||||||
|
for(int i=0;i<originData.size();i++){
|
||||||
|
if(i==0){
|
||||||
|
list.add(new XMRPoint(
|
||||||
|
i,
|
||||||
|
new Double(0),
|
||||||
|
originData.get(i),
|
||||||
|
null
|
||||||
|
));
|
||||||
|
lastOne = originData.get(i);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Double now = originData.get(i);
|
||||||
|
Double rs = ( java.lang.Math.abs( now - lastOne ) );
|
||||||
|
rsArray.add(rs);
|
||||||
|
list.add(new XMRPoint(
|
||||||
|
i,
|
||||||
|
new Double(0),
|
||||||
|
now,
|
||||||
|
rs
|
||||||
|
));
|
||||||
|
lastOne = now;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//3. 以及一些 控制图的全局参数。
|
||||||
|
this.xbar = Math.getMean(toDoubleArray(originData.toArray()));
|
||||||
|
this.miu = xbar;
|
||||||
|
StandardDiviation standardDiviation =Math.StandardDiviation(toDoubleArray(originData.toArray()));
|
||||||
|
this.xigma = standardDiviation.getNormal();
|
||||||
|
this.totalXigma = standardDiviation.getTotality();
|
||||||
|
this.rsbar = Math.getMean(toDoubleArray(rsArray.toArray()));
|
||||||
|
|
||||||
|
this.xmrGraphEntity = new XMRGraphEntity(list,xbar,rsbar);
|
||||||
|
|
||||||
|
//4.判读方案 校验
|
||||||
|
// 开始
|
||||||
|
if(this.interpretationScheme != null){
|
||||||
|
List<Point> forX = new ArrayList<>();
|
||||||
|
List<Point> forRS = new ArrayList<>();
|
||||||
|
for(XMRPoint x:list){
|
||||||
|
forX.add( new Point( x.getPosition() , x.getX() ) );
|
||||||
|
if(x.getPosition()!=0){
|
||||||
|
forRS.add( new Point( x.getPosition(), x.getRs() ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ControlLimit xcl = getXCL();
|
||||||
|
ControlLimit rscl = getRSCL();
|
||||||
|
|
||||||
|
for(InterpretationListArg arg : this.interpretationScheme){
|
||||||
|
switch (arg.getNumber())//值必须是整型或者字符型
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
StatisticalControlledTest.rule1(forX,xcl);
|
||||||
|
StatisticalControlledTest.rule1(forRS,rscl);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
StatisticalControlledTest.rule2(forX,xcl,arg.getArg1());
|
||||||
|
StatisticalControlledTest.rule2(forRS,rscl,arg.getArg1());
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
StatisticalControlledTest.rule3(forX,arg.getArg1());
|
||||||
|
StatisticalControlledTest.rule3(forRS,arg.getArg1());
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
StatisticalControlledTest.rule4(forX,arg.getArg1());
|
||||||
|
StatisticalControlledTest.rule4(forRS,arg.getArg1());
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
StatisticalControlledTest.rule5(forX,xcl,arg.getArg1(), arg.getArg2());
|
||||||
|
StatisticalControlledTest.rule5(forRS,rscl,arg.getArg1(), arg.getArg2());
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
StatisticalControlledTest.rule6(forX,xcl,arg.getArg1(), arg.getArg2());
|
||||||
|
StatisticalControlledTest.rule6(forRS,rscl,arg.getArg1(), arg.getArg2());
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
StatisticalControlledTest.rule7(forX,xcl,arg.getArg1());
|
||||||
|
StatisticalControlledTest.rule7(forRS,rscl, arg.getArg1());
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
StatisticalControlledTest.rule8(forX,xcl, arg.getArg1());
|
||||||
|
StatisticalControlledTest.rule8(forRS,rscl, arg.getArg1());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i=0;i<list.size();i++){
|
||||||
|
if(i==0){
|
||||||
|
list.get(i).setxUnsatisfiedRules(forX.get(i).getUnsatisfiedRules());
|
||||||
|
list.get(i).setRsUnsatisfiedRules(new HashSet<>());
|
||||||
|
}else {
|
||||||
|
list.get(i).setxUnsatisfiedRules(forX.get(i).getUnsatisfiedRules());
|
||||||
|
list.get(i).setRsUnsatisfiedRules(forRS.get(i-1).getUnsatisfiedRules());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
// 结束
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* desc: get X控制图(单值控制图) 的控制限
|
||||||
|
* 注意:此函数 要在 initialDate()函数执行之后
|
||||||
|
* */
|
||||||
|
public ControlLimit getXCL(){
|
||||||
|
return new ControlLimit(
|
||||||
|
(this.xmrGraphEntity.getXbar() + 2.66 * this.xmrGraphEntity.getRsbar()),
|
||||||
|
this.xmrGraphEntity.getXbar() ,
|
||||||
|
(this.xmrGraphEntity.getXbar() - 2.66 * this.xmrGraphEntity.getRsbar())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* desc: get R控制图 的控制限
|
||||||
|
* 注意:此函数 要在 initialDate()函数执行之后
|
||||||
|
* */
|
||||||
|
public ControlLimit getRSCL(){
|
||||||
|
return new ControlLimit(
|
||||||
|
( 3.267 * this.xmrGraphEntity.getRsbar() ) ,
|
||||||
|
this.xmrGraphEntity.getRsbar() ,
|
||||||
|
(double) 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package com.cnbm.processInspection.graphAnalyzed.xmr;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import com.cnbm.qualityPlanning.entity.XMRPoint;
|
||||||
|
import com.cnbm.qualityPlanning.entity.XbarRPoint;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Desc: "xbar-R 结果类"
|
||||||
|
* @Author: caixiang
|
||||||
|
* @DATE: 2022/7/21 16:26
|
||||||
|
*/
|
||||||
|
public class XMRGraphEntity {
|
||||||
|
private List<XMRPoint> list;
|
||||||
|
private Double xbar;
|
||||||
|
private Double rsbar;
|
||||||
|
|
||||||
|
public XMRGraphEntity(List<XMRPoint> list, Double xbar, Double rsbar){
|
||||||
|
this.list = list;
|
||||||
|
this.rsbar = rsbar;
|
||||||
|
|
||||||
|
this.xbar = xbar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<XMRPoint> getList() {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setList(List<XMRPoint> list) {
|
||||||
|
this.list = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getXbar() {
|
||||||
|
return xbar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setXbar(Double xbar) {
|
||||||
|
this.xbar = xbar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getRsbar() {
|
||||||
|
return rsbar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRsbar(Double rsbar) {
|
||||||
|
this.rsbar = rsbar;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,95 @@
|
|||||||
|
package com.cnbm.qualityPlanning.entity;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Desc: "整合,处理好 后的一行数据 (sampleSize 后的数据) "
|
||||||
|
* @Author: caixiang
|
||||||
|
* @DATE: 2022/7/21 9:43
|
||||||
|
*/
|
||||||
|
public class XMRPoint extends Point {
|
||||||
|
|
||||||
|
private Double x;
|
||||||
|
private Double rs;
|
||||||
|
//position 是这个数据在数组中的位置 ;; value 是待被判读方案 分析的value(从 xbar、s、r 中选一)
|
||||||
|
public XMRPoint(Integer position, Double value) {
|
||||||
|
super(position, value);
|
||||||
|
}
|
||||||
|
//r 不满足 的 判读方案
|
||||||
|
private Set<Integer> xUnsatisfiedRules;
|
||||||
|
//xbar 不满足 的 判读方案
|
||||||
|
private Set<Integer> rsUnsatisfiedRules;
|
||||||
|
|
||||||
|
|
||||||
|
private void setValueToTest(Double value){
|
||||||
|
setValueForInterpretation(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Integer> getxUnsatisfiedRules() {
|
||||||
|
return xUnsatisfiedRules;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setxUnsatisfiedRules(Set<Integer> xUnsatisfiedRules) {
|
||||||
|
this.xUnsatisfiedRules = xUnsatisfiedRules;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Integer> getRsUnsatisfiedRules() {
|
||||||
|
return rsUnsatisfiedRules;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRsUnsatisfiedRules(Set<Integer> rsUnsatisfiedRules) {
|
||||||
|
this.rsUnsatisfiedRules = rsUnsatisfiedRules;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getX() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setX(Double x) {
|
||||||
|
this.x = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getRs() {
|
||||||
|
return rs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRs(Double rs) {
|
||||||
|
this.rs = rs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public XMRPoint(Integer position, Double value, Double x, Double rs) {
|
||||||
|
super(position,value);
|
||||||
|
this.x = x;
|
||||||
|
this.rs = rs;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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