新增 MR MS 控制图
This commit is contained in:
джерело
fde6a8b684
коміт
e7a542d386
@ -182,7 +182,7 @@ public class Main {
|
||||
|
||||
private static List<FluxTable> query(QueryDataParam param,InfluxDBClient influxDBClient){
|
||||
String measurement = param.getMeasurement();
|
||||
String dropedTagName = param.getDropedTagName();
|
||||
List<String> dropedTagName = param.getDropedTagNames();
|
||||
Range range = param.getRange();
|
||||
String bucket = param.getBucket();
|
||||
String tagName = param.getTag().getTagName();
|
||||
@ -193,7 +193,9 @@ public class Main {
|
||||
flux += "|> range(start: "+range.getBegin().toString()+",stop:"+range.getEnd().toString()+") \n";
|
||||
flux += "|> filter(fn: (r) => r[\"_measurement\"] == \""+measurement+"\") \n";
|
||||
flux += "|> filter(fn: (r) => r[\""+tagName+"\"] == \""+tagValue+"\") \n";
|
||||
flux += "|> drop(columns: [\""+dropedTagName+"\"]) \n";
|
||||
for(String dropName:dropedTagName){
|
||||
flux += "|> drop(columns: [\""+ dropName +"\"]) \n";
|
||||
}
|
||||
flux += "|> sort(columns: [\"_time\"], desc: true) \n";
|
||||
if(pageInfo!=null){
|
||||
flux += "|> limit(n: "+pageInfo.getSize()+", offset: "+(pageInfo.getCurrent()-1)* pageInfo.getSize()+")";
|
||||
|
@ -78,6 +78,7 @@ public enum InfluxClient {
|
||||
public void insert(Event event, String measurement){
|
||||
Point point = Point.measurement(measurement)
|
||||
.addTag("transationId", event.getTransationId())
|
||||
.addTag("inspectionSheet", event.getInspectionSheet())
|
||||
.addTag("argName", event.getArgName())
|
||||
.addField("argValue", event.getArgValue())
|
||||
.time(event.getTime().toEpochMilli(), WritePrecision.MS);
|
||||
@ -92,6 +93,7 @@ public enum InfluxClient {
|
||||
for(Event event:events){
|
||||
Point point = Point.measurement(measurement)
|
||||
.addTag("transationId", event.getTransationId())
|
||||
.addTag("inspectionSheet", event.getInspectionSheet())
|
||||
.addTag("argName", event.getArgName())
|
||||
.addField("argValue", event.getArgValue())
|
||||
.time(event.getTime().toEpochMilli(), WritePrecision.MS);
|
||||
@ -103,7 +105,7 @@ public enum InfluxClient {
|
||||
|
||||
public List<FluxTable> query(QueryDataParam param){
|
||||
String measurement = param.getMeasurement();
|
||||
String dropedTagName = param.getDropedTagName();
|
||||
List<String> dropedTagNames = param.getDropedTagNames();
|
||||
Range range = param.getRange();
|
||||
String bucket = param.getBucket();
|
||||
String tagName = param.getTag().getTagName();
|
||||
@ -114,7 +116,9 @@ public enum InfluxClient {
|
||||
flux += "|> range(start: "+range.getBegin()+",stop:"+range.getEnd()+")";
|
||||
flux += "|> filter(fn: (r) => r[\"_measurement\"] == \""+measurement+"\")";
|
||||
flux += "|> filter(fn: (r) => r[\""+tagName+"\"] == \""+tagValue+"\")";
|
||||
flux += "|> drop(columns: [\""+dropedTagName+"\"])";
|
||||
for(String dropName:dropedTagNames){
|
||||
flux += "|> drop(columns: [\""+dropName+"\"])";
|
||||
}
|
||||
flux += "|> sort(columns: [\"_time\"], desc: true)";
|
||||
if(pageInfo!=null){
|
||||
flux += "|> limit(n: "+pageInfo.getSize()+", offset: "+(pageInfo.getCurrent()-1)* pageInfo.getSize()+")";
|
||||
|
@ -32,7 +32,6 @@ public class S7DemoController {
|
||||
List<Event> list = new ArrayList<>();
|
||||
Random r = new Random();
|
||||
|
||||
|
||||
for(int i=0;i<999;i++){
|
||||
Thread.sleep(10);
|
||||
Event event = new Event();
|
||||
@ -46,6 +45,27 @@ public class S7DemoController {
|
||||
InfluxClient.Client.batchInsert(list,"Weight");
|
||||
}
|
||||
|
||||
@PostMapping("/insertBatchJYD")
|
||||
public void insertBatchJYD() throws InterruptedException {
|
||||
List<Event> list = new ArrayList<>();
|
||||
Random r = new Random();
|
||||
|
||||
for(int j=0;j<10;j++){
|
||||
for(int i=0;i<99;i++){
|
||||
Thread.sleep(10);
|
||||
Event event = new Event();
|
||||
event.setTime(Instant.now());
|
||||
event.setTransationId("asas"+i);
|
||||
event.setArgName("LTWeight");
|
||||
Double d = r.nextDouble() * 2.5 + 66;
|
||||
event.setInspectionSheet(j+"");
|
||||
event.setArgValue(d);
|
||||
list.add(event);
|
||||
}
|
||||
}
|
||||
InfluxClient.Client.batchInsert(list,"Weight");
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试连接是否正常
|
||||
*
|
||||
@ -66,7 +86,10 @@ public class S7DemoController {
|
||||
QueryDataParam queryDataParam = new QueryDataParam();
|
||||
queryDataParam.setBucket("qgs-bucket");
|
||||
queryDataParam.setMeasurement("ASProcessCompleteEventAS");
|
||||
queryDataParam.setDropedTagName("transationId");
|
||||
List<String> dropNames = new ArrayList<>();
|
||||
dropNames.add("transationId");
|
||||
dropNames.add("inspectionSheet");
|
||||
queryDataParam.setDropedTagNames(dropNames);
|
||||
queryDataParam.setTag(new Tag("argName","arg6"));
|
||||
queryDataParam.setRange(new Range(DataUtils.getBeforeDate(10).toInstant(),Instant.now()));
|
||||
queryDataParam.setPageInfo(new PageInfo(1,10));
|
||||
@ -89,7 +112,10 @@ public class S7DemoController {
|
||||
QueryDataParam queryDataParam = new QueryDataParam();
|
||||
queryDataParam.setBucket("qgs-bucket");
|
||||
queryDataParam.setMeasurement("ASProcessCompleteEventAS");
|
||||
queryDataParam.setDropedTagName("transationId");
|
||||
List<String> dropNames = new ArrayList<>();
|
||||
dropNames.add("transationId");
|
||||
dropNames.add("inspectionSheet");
|
||||
queryDataParam.setDropedTagNames(dropNames);
|
||||
queryDataParam.setTag(new Tag("argName","arg7"));
|
||||
queryDataParam.setRange(new Range(DataUtils.getBeforeDate(10).toInstant(),Instant.now()));
|
||||
queryDataParam.setPageInfo(new PageInfo(2,10));
|
||||
|
@ -4,6 +4,8 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Desc: "influx 查询条件构造"
|
||||
* @Author: caixiang
|
||||
@ -25,7 +27,7 @@ import lombok.experimental.Accessors;
|
||||
public class QueryDataParam extends BaseParam{
|
||||
private Tag tag;
|
||||
//查询的时候,需要忽略的字段。(transationId是唯一标识会对 最终的查询结果集产生影响)
|
||||
private String dropedTagName;
|
||||
private List<String> dropedTagNames;
|
||||
private String bucket;
|
||||
|
||||
}
|
||||
|
@ -14,11 +14,14 @@ import java.time.Instant;
|
||||
*/
|
||||
@Data
|
||||
public class Event {
|
||||
|
||||
private Instant time;
|
||||
|
||||
private String inspectionSheet;
|
||||
|
||||
private String transationId;
|
||||
|
||||
private String argName;
|
||||
|
||||
private Double argValue;
|
||||
}
|
||||
}
|
@ -1,34 +1,20 @@
|
||||
package com.cnbm.processInspection.controller;
|
||||
|
||||
import com.cnbm.basic.dto.FactoryDTO;
|
||||
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.GraphArg;
|
||||
import com.cnbm.processInspection.dto.InterpretationListArg;
|
||||
import com.cnbm.processInspection.dto.XbarRGraphData;
|
||||
import com.cnbm.processInspection.dto.XbarSGraphData;
|
||||
import com.cnbm.processInspection.graphAnalyzed.MeanStandardDeviationGraph;
|
||||
import com.cnbm.qualityPlanning.common.StatisticalControlledTest;
|
||||
import com.cnbm.qualityPlanning.entity.ControlLimit;
|
||||
import com.cnbm.qualityPlanning.entity.Point;
|
||||
import com.cnbm.qualityPlanning.entity.SpecificationLimit;
|
||||
import com.cnbm.qualityPlanning.entity.XbarSPoint;
|
||||
import com.influxdb.client.domain.WritePrecision;
|
||||
import com.influxdb.query.FluxRecord;
|
||||
import com.influxdb.query.FluxTable;
|
||||
import com.cnbm.processInspection.graphAnalyzed.mr.MeanRGraph;
|
||||
import com.cnbm.processInspection.graphAnalyzed.ms.MeanStandardDeviationGraph;
|
||||
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.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -37,9 +23,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/processInspection")
|
||||
@ -58,6 +42,12 @@ public class ProcessInspectionController {
|
||||
productFeatures.setName("LTWeight");
|
||||
productFeatures.setSampleSize(BigDecimal.TEN);
|
||||
MeanStandardDeviationGraph meanStandardDeviationGraph = new MeanStandardDeviationGraph(productFeatures);
|
||||
//判读方案
|
||||
List<InterpretationListArg> interpretationScheme = new ArrayList<>();
|
||||
interpretationScheme.add(new InterpretationListArg(1,null,null));
|
||||
interpretationScheme.add(new InterpretationListArg(5,3,2));
|
||||
meanStandardDeviationGraph.isNeedInterpretation(interpretationScheme);
|
||||
|
||||
|
||||
QueryDataParam queryDataParam = new QueryDataParam();
|
||||
queryDataParam.setMeasurement("Weight");
|
||||
@ -76,6 +66,40 @@ public class ProcessInspectionController {
|
||||
return R.ok("成功",xbarSGraphData);
|
||||
}
|
||||
|
||||
@PostMapping("/XbarRGraphTest")
|
||||
public R<XbarRGraphData> XbarRGraphTest() 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);
|
||||
MeanRGraph meanRGraph = new MeanRGraph(productFeatures);
|
||||
//判读方案
|
||||
List<InterpretationListArg> interpretationScheme = new ArrayList<>();
|
||||
interpretationScheme.add(new InterpretationListArg(1,null,null));
|
||||
interpretationScheme.add(new InterpretationListArg(5,3,2));
|
||||
meanRGraph.isNeedInterpretation(interpretationScheme);
|
||||
|
||||
|
||||
QueryDataParam queryDataParam = new QueryDataParam();
|
||||
queryDataParam.setMeasurement("Weight");
|
||||
queryDataParam.setRange(new Range(DataUtils.getBeforeDate(10).toInstant(), Instant.now()));
|
||||
meanRGraph.initialDate(queryDataParam);
|
||||
|
||||
XbarRGraphData xbarSGraphData = new XbarRGraphData(
|
||||
meanRGraph.getMrGraphEntity(),
|
||||
meanRGraph.getXbarCL(),
|
||||
meanRGraph.getRCL(),
|
||||
meanRGraph.getSpecificationLimit(),
|
||||
meanRGraph.getProcessCapacity(),
|
||||
new StandardDiviation(meanRGraph.getXigma(),meanRGraph.getTotalXigma())
|
||||
);
|
||||
|
||||
return R.ok("成功",xbarSGraphData);
|
||||
}
|
||||
|
||||
|
||||
//筛选条件顺序:
|
||||
// ① 先工厂(产品表) => ② 检验类型(产品表)=> ③ 产品名(产品表)=> ④ 工序(产品表)=> ⑤ 特性(检验参数name)( product_features 表) ;;
|
||||
@ -109,4 +133,32 @@ public class ProcessInspectionController {
|
||||
return R.ok("成功",xbarSGraphData);
|
||||
}
|
||||
|
||||
@PostMapping("/XbarRGraph")
|
||||
public R<XbarRGraphData> XbarRGraph(@RequestBody GraphArg graphArg) throws Exception {
|
||||
|
||||
//new 对象
|
||||
ProductFeatures productFeatures = graphArg.getProductFeatures();
|
||||
MeanRGraph meanRGraph = new MeanRGraph(productFeatures);
|
||||
//如果要检验,,那么set 判读方案
|
||||
if(graphArg.getInterpretationScheme()!=null){
|
||||
meanRGraph.isNeedInterpretation(graphArg.getInterpretationScheme());
|
||||
}
|
||||
|
||||
QueryDataParam queryDataParam = new QueryDataParam();
|
||||
queryDataParam.setMeasurement(Constant.measurement);
|
||||
queryDataParam.setRange(new Range(graphArg.getBegin().toInstant(), graphArg.getEnd().toInstant()));
|
||||
meanRGraph.initialDate(queryDataParam);
|
||||
|
||||
XbarRGraphData xbarSGraphData = new XbarRGraphData(
|
||||
meanRGraph.getMrGraphEntity(),
|
||||
meanRGraph.getXbarCL(),
|
||||
meanRGraph.getRCL(),
|
||||
meanRGraph.getSpecificationLimit(),
|
||||
meanRGraph.getProcessCapacity(),
|
||||
new StandardDiviation(meanRGraph.getXigma(),meanRGraph.getTotalXigma())
|
||||
);
|
||||
|
||||
return R.ok("成功",xbarSGraphData);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,4 +15,13 @@ public class InterpretationListArg {
|
||||
private Integer number;
|
||||
private Integer arg1;
|
||||
private Integer arg2;
|
||||
|
||||
public InterpretationListArg() {
|
||||
}
|
||||
|
||||
public InterpretationListArg(Integer number, Integer arg1, Integer arg2) {
|
||||
this.number = number;
|
||||
this.arg1 = arg1;
|
||||
this.arg2 = arg2;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,45 @@
|
||||
package com.cnbm.processInspection.dto;
|
||||
|
||||
import com.cnbm.common.spc.math.StandardDiviation;
|
||||
import com.cnbm.processInspection.graphAnalyzed.mr.MRGraphEntity;
|
||||
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 XbarRGraphData {
|
||||
@ApiModelProperty(value = "控制图list数据")
|
||||
private MRGraphEntity mrGraphEntity;
|
||||
@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 XbarRGraphData(MRGraphEntity mrGraphEntity, ControlLimit xBarCL, ControlLimit rCL, SpecificationLimit sl, ProcessCapability processCapability, StandardDiviation standardDiviation){
|
||||
this.mrGraphEntity = mrGraphEntity;
|
||||
this.XBarCL = xBarCL;
|
||||
this.RCL = rCL;
|
||||
this.SL = sl;
|
||||
this.processCapability = processCapability;
|
||||
this.standardDiviation = standardDiviation;
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package com.cnbm.processInspection.dto;
|
||||
|
||||
import com.cnbm.common.spc.math.StandardDiviation;
|
||||
import com.cnbm.processInspection.graphAnalyzed.MSDGraphEntity;
|
||||
import com.cnbm.processInspection.graphAnalyzed.ms.MSDGraphEntity;
|
||||
import com.cnbm.qualityPlanning.entity.ControlLimit;
|
||||
import com.cnbm.qualityPlanning.entity.ProcessCapability;
|
||||
import com.cnbm.qualityPlanning.entity.SpecificationLimit;
|
||||
|
@ -0,0 +1,50 @@
|
||||
package com.cnbm.processInspection.graphAnalyzed.mr;
|
||||
|
||||
|
||||
|
||||
import com.cnbm.qualityPlanning.entity.XbarRPoint;
|
||||
import com.cnbm.qualityPlanning.entity.XbarSPoint;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Desc: "xbar-R 结果类"
|
||||
* @Author: caixiang
|
||||
* @DATE: 2022/7/21 16:26
|
||||
*/
|
||||
public class MRGraphEntity {
|
||||
private List<XbarRPoint> list;
|
||||
private Double xbarbar;
|
||||
private Double Rbar;
|
||||
|
||||
public MRGraphEntity(List<XbarRPoint> list, Double xbarbar,Double Rbar){
|
||||
this.list = list;
|
||||
this.Rbar = Rbar;
|
||||
|
||||
this.xbarbar = xbarbar;
|
||||
}
|
||||
|
||||
public List<XbarRPoint> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setList(List<XbarRPoint> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public Double getXbarbar() {
|
||||
return xbarbar;
|
||||
}
|
||||
|
||||
public void setXbarbar(Double xbarbar) {
|
||||
this.xbarbar = xbarbar;
|
||||
}
|
||||
|
||||
public Double getRbar() {
|
||||
return Rbar;
|
||||
}
|
||||
|
||||
public void setRbar(Double rbar) {
|
||||
Rbar = rbar;
|
||||
}
|
||||
}
|
@ -0,0 +1,290 @@
|
||||
package com.cnbm.processInspection.graphAnalyzed.mr;
|
||||
|
||||
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.influx.config.InfluxClient;
|
||||
import com.cnbm.influx.constant.Constant;
|
||||
import com.cnbm.influx.param.QueryDataParam;
|
||||
import com.cnbm.influx.param.Range;
|
||||
import com.cnbm.influx.param.Tag;
|
||||
import com.cnbm.processInspection.controlCoefficientConstant.XBarRCoefficients;
|
||||
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.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
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 MeanRGraph {
|
||||
//母体的 μ = xbarbar
|
||||
private Double miu;
|
||||
//母体的 xigma ,全局计算的;
|
||||
private Double xigma;
|
||||
//母体的 xigma ,全局计算的;
|
||||
private Double totalXigma;
|
||||
|
||||
//需要去检验的 判读方案 eg:[1,2,3,4,6]
|
||||
private List<InterpretationListArg> interpretationScheme;
|
||||
|
||||
//这里 是特有参数 -- begin
|
||||
private Double rbar;
|
||||
private Double xbarbar;
|
||||
private Double a2;
|
||||
private Double d3;
|
||||
private Double d4;
|
||||
|
||||
//这里 是特有参数 -- end
|
||||
|
||||
private Integer sampleSize;
|
||||
private String argName;
|
||||
|
||||
private SpecificationLimit specificationLimit;
|
||||
private MRGraphEntity mrGraphEntity;
|
||||
|
||||
|
||||
public MeanRGraph(ProductFeatures productFeatures) throws Exception {
|
||||
if(productFeatures.getSampleSize()==null || productFeatures.getName()==null){
|
||||
throw new Exception("ProductFeatures 参数异常");
|
||||
}
|
||||
this.argName = productFeatures.getName();
|
||||
this.sampleSize = productFeatures.getSampleSize().intValue();
|
||||
this.a2 = XBarRCoefficients.getA2(sampleSize);
|
||||
this.d3 = XBarRCoefficients.getD3(sampleSize);
|
||||
this.d4 = XBarRCoefficients.getD4(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;
|
||||
}
|
||||
|
||||
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("inspectionSheet");
|
||||
queryDataParam.setDropedTagNames(dropNames);
|
||||
queryDataParam.setTag(new Tag("argName",argName));
|
||||
queryDataParam.setRange(new Range(DataUtils.getBeforeDate(10).toInstant(), Instant.now()));
|
||||
|
||||
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<List<Double>> doubleListList = DataUtils.fixedGroup(originData, sampleSize);
|
||||
List<XbarRPoint> list = new ArrayList<>();
|
||||
List<Double> xbarArray = 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 r = Math.range(doubleList);
|
||||
xbarArray.add(xbar);
|
||||
rArray.add(r);
|
||||
list.add(new XbarRPoint(
|
||||
i,
|
||||
new Double(0),
|
||||
xbar,
|
||||
r,
|
||||
doubleListList.get(i)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
//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 rbar = Math.getMean(toDoubleArray(rArray.toArray()));
|
||||
this.mrGraphEntity = new MRGraphEntity(list,xbarbar,rbar);
|
||||
|
||||
//4.判读方案 校验
|
||||
// 开始
|
||||
if(this.interpretationScheme != null){
|
||||
List<Point> forXBar = new ArrayList<>();
|
||||
List<Point> forR = new ArrayList<>();
|
||||
for(XbarRPoint x:list){
|
||||
forXBar.add(new Point(x.getPosition(),x.getXbar()));
|
||||
forR.add(new Point(x.getPosition(),x.getR()));
|
||||
}
|
||||
ControlLimit xbarcl = getXbarCL();
|
||||
ControlLimit rcl = getRCL();
|
||||
|
||||
for(InterpretationListArg arg : this.interpretationScheme){
|
||||
switch (arg.getNumber())//值必须是整型或者字符型
|
||||
{
|
||||
case 1:
|
||||
StatisticalControlledTest.rule1(forXBar,xbarcl);
|
||||
StatisticalControlledTest.rule1(forR,rcl);
|
||||
break;
|
||||
case 2:
|
||||
StatisticalControlledTest.rule2(forXBar,xbarcl,arg.getArg1());
|
||||
StatisticalControlledTest.rule2(forR,rcl,arg.getArg1());
|
||||
break;
|
||||
case 3:
|
||||
StatisticalControlledTest.rule3(forXBar,arg.getArg1());
|
||||
StatisticalControlledTest.rule3(forR,arg.getArg1());
|
||||
break;
|
||||
case 4:
|
||||
StatisticalControlledTest.rule4(forXBar,arg.getArg1());
|
||||
StatisticalControlledTest.rule4(forR,arg.getArg1());
|
||||
break;
|
||||
case 5:
|
||||
StatisticalControlledTest.rule5(forXBar,xbarcl,arg.getArg1(), arg.getArg2());
|
||||
StatisticalControlledTest.rule5(forR,rcl,arg.getArg1(), arg.getArg2());
|
||||
break;
|
||||
case 6:
|
||||
StatisticalControlledTest.rule6(forXBar,xbarcl,arg.getArg1(), arg.getArg2());
|
||||
StatisticalControlledTest.rule6(forR,rcl,arg.getArg1(), arg.getArg2());
|
||||
break;
|
||||
case 7:
|
||||
StatisticalControlledTest.rule7(forXBar,xbarcl,arg.getArg1());
|
||||
StatisticalControlledTest.rule7(forR,rcl, arg.getArg1());
|
||||
|
||||
break;
|
||||
case 8:
|
||||
StatisticalControlledTest.rule8(forXBar,xbarcl, arg.getArg1());
|
||||
StatisticalControlledTest.rule8(forR,rcl, arg.getArg1());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0;i<list.size();i++){
|
||||
list.get(i).setrUnsatisfiedRules(forR.get(i).getUnsatisfiedRules());
|
||||
list.get(i).setXbarUnsatisfiedRules(forXBar.get(i).getUnsatisfiedRules());
|
||||
}
|
||||
}
|
||||
// 结束
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* desc: get Xbar控制图 的控制限
|
||||
* 注意:此函数 要在 initialDate()函数执行之后
|
||||
* */
|
||||
public ControlLimit getXbarCL(){
|
||||
return new ControlLimit(
|
||||
(this.mrGraphEntity.getXbarbar() + a2*this.mrGraphEntity.getRbar()),
|
||||
this.mrGraphEntity.getXbarbar(),
|
||||
(this.mrGraphEntity.getXbarbar() - a2*this.mrGraphEntity.getRbar())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* desc: get R控制图 的控制限
|
||||
* 注意:此函数 要在 initialDate()函数执行之后
|
||||
* */
|
||||
public ControlLimit getRCL(){
|
||||
return new ControlLimit(
|
||||
( d4 * this.mrGraphEntity.getRbar() ) ,
|
||||
this.mrGraphEntity.getRbar() ,
|
||||
( d3 * this.mrGraphEntity.getRbar())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.cnbm.processInspection.graphAnalyzed;
|
||||
package com.cnbm.processInspection.graphAnalyzed.ms;
|
||||
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Desc: ""
|
||||
* @Desc: "xbar-s 结果类"
|
||||
* @Author: caixiang
|
||||
* @DATE: 2022/7/21 16:26
|
||||
*/
|
@ -1,4 +1,4 @@
|
||||
package com.cnbm.processInspection.graphAnalyzed;
|
||||
package com.cnbm.processInspection.graphAnalyzed.ms;
|
||||
|
||||
import com.cnbm.basic.entity.ProductFeatures;
|
||||
import com.cnbm.common.spc.math.Math;
|
||||
@ -20,7 +20,6 @@ import lombok.Data;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -99,7 +98,10 @@ public class MeanStandardDeviationGraph {
|
||||
* */
|
||||
public void initialDate(QueryDataParam queryDataParam){
|
||||
queryDataParam.setBucket(Constant.bucket);
|
||||
queryDataParam.setDropedTagName("transationId");
|
||||
List<String> dropNames = new ArrayList<>();
|
||||
dropNames.add("transationId");
|
||||
dropNames.add("inspectionSheet");
|
||||
queryDataParam.setDropedTagNames(dropNames);
|
||||
queryDataParam.setTag(new Tag("argName",argName));
|
||||
queryDataParam.setRange(new Range(DataUtils.getBeforeDate(10).toInstant(), Instant.now()));
|
||||
|
||||
@ -141,12 +143,12 @@ public class MeanStandardDeviationGraph {
|
||||
}
|
||||
|
||||
//3. 以及一些 控制图的全局参数。
|
||||
Double xbarbar = Math.getMean(toDoubleArray(xbarArray.toArray()));
|
||||
this.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()));
|
||||
this.sbar = Math.getMean(toDoubleArray(sArray.toArray()));
|
||||
Double rbar = Math.getMean(toDoubleArray(rArray.toArray()));
|
||||
this.msdGraphEntity = new MSDGraphEntity(list,xbarbar,sbar,rbar);
|
||||
|
@ -0,0 +1,107 @@
|
||||
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 XbarRPoint extends Point {
|
||||
List<Double> data = new ArrayList<>();
|
||||
private Double xbar;
|
||||
private Double r;
|
||||
//position 是这个数据在数组中的位置 ;; value 是待被判读方案 分析的value(从 xbar、s、r 中选一)
|
||||
public XbarRPoint(Integer position, Double value) {
|
||||
super(position, value);
|
||||
}
|
||||
//r 不满足 的 判读方案
|
||||
private Set<Integer> rUnsatisfiedRules;
|
||||
//xbar 不满足 的 判读方案
|
||||
private Set<Integer> xbarUnsatisfiedRules;
|
||||
|
||||
|
||||
private void setValueToTest(Double value){
|
||||
setValueForInterpretation(value);
|
||||
}
|
||||
|
||||
public Set<Integer> getrUnsatisfiedRules() {
|
||||
return rUnsatisfiedRules;
|
||||
}
|
||||
|
||||
public void setrUnsatisfiedRules(Set<Integer> rUnsatisfiedRules) {
|
||||
this.rUnsatisfiedRules = rUnsatisfiedRules;
|
||||
}
|
||||
|
||||
public Set<Integer> getXbarUnsatisfiedRules() {
|
||||
return xbarUnsatisfiedRules;
|
||||
}
|
||||
|
||||
public void setXbarUnsatisfiedRules(Set<Integer> xbarUnsatisfiedRules) {
|
||||
this.xbarUnsatisfiedRules = xbarUnsatisfiedRules;
|
||||
}
|
||||
|
||||
public List<Double> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(List<Double> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public Double getXbar() {
|
||||
return xbar;
|
||||
}
|
||||
|
||||
public void setXbar(Double xbar) {
|
||||
this.xbar = xbar;
|
||||
}
|
||||
|
||||
|
||||
public Double getR() {
|
||||
return r;
|
||||
}
|
||||
|
||||
public void setR(Double r) {
|
||||
this.r = r;
|
||||
}
|
||||
|
||||
public XbarRPoint(Integer position, Double value, Double xbar, Double r, List<Double> data) {
|
||||
super(position,value);
|
||||
this.xbar = xbar;
|
||||
this.r = r;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
Завантаження…
Посилання в новій задачі
Block a user