commit for pull

This commit is contained in:
caixiang
2023-01-03 09:24:12 +08:00
parent 69f911c07c
commit c75c89cab9
11 changed files with 135 additions and 99 deletions

View File

@@ -174,6 +174,7 @@ public class InspectionSheetController {
return inspectionSheetService.getFluxParamList(inspectionSheetId);
}
@PostMapping("saveFluxParamList")
@ApiOperation("将样本检测参数写入influxdb")
public Result saveFluxParamList(@RequestBody InspectionSampleDTO[] lists) throws InterruptedException{

View File

@@ -147,49 +147,48 @@ public class ProcessInspectionController {
xmrGraph.getSpecificationLimit()==null?null:xmrGraph.getSpecificationLimit(),
xmrGraph.getProcessCapacity()==null?null:xmrGraph.getProcessCapacity(),
(xmrGraph.getXigma()==null||xmrGraph.getTotalXigma()==null)?null:new StandardDiviation(xmrGraph.getXigma(),xmrGraph.getTotalXigma())
);
return R.ok("成功",xmrGraphData);
}
@PostMapping("/getBatchs")
public R<List<String>> getBatchs() throws InterruptedException {
List<Event> list = new ArrayList<>();
Random r = new Random();
Instant instant = DataUtils.getBeforeDate(400).toInstant();
List<String> res = new ArrayList<>();
QueryDataParam queryDataParam = new QueryDataParam();
queryDataParam.setBucket("qgs-bucket");
queryDataParam.setMeasurement("Weight");
List<String> dropNames = new ArrayList<>();
dropNames.add("transationId");
dropNames.add("_value");
dropNames.add("_start");
dropNames.add("_stop");
dropNames.add("_time");
dropNames.add("_field");
dropNames.add("_measurement");
dropNames.add("inspectionSheetId");
dropNames.add("argName");
queryDataParam.setDropedTagNames(dropNames);
queryDataParam.setTags(Arrays.asList(new Tag("argName","LTWeight")));
queryDataParam.setRange(new Range(DataUtils.getBeforeDate(100).toInstant(),Instant.now()));
// queryDataParam.setPageInfo(new PageInfo(1,10));
List<FluxTable> query = InfluxClient.Client.queryByGroup(queryDataParam);
for (FluxTable fluxTable : query) {
List<FluxRecord> records = fluxTable.getRecords();
if(records.size()!=0){
res.add((String) records.get(0).getValueByKey("batchNum"));
continue;
}
}
return R.ok(res);
}
// @PostMapping("/getBatchs")
// public R<List<String>> getBatchs() throws InterruptedException {
// List<Event> list = new ArrayList<>();
// Random r = new Random();
// Instant instant = DataUtils.getBeforeDate(400).toInstant();
// List<String> res = new ArrayList<>();
//
// QueryDataParam queryDataParam = new QueryDataParam();
// queryDataParam.setBucket("qgs-bucket");
// queryDataParam.setMeasurement("Weight");
// List<String> dropNames = new ArrayList<>();
// dropNames.add("transationId");
// dropNames.add("_value");
// dropNames.add("_start");
// dropNames.add("_stop");
// dropNames.add("_time");
// dropNames.add("_field");
// dropNames.add("_measurement");
// dropNames.add("inspectionSheetId");
// dropNames.add("argName");
// queryDataParam.setDropedTagNames(dropNames);
//
// queryDataParam.setTags(Arrays.asList(new Tag("argName","LTWeight")));
//
// queryDataParam.setRange(new Range(DataUtils.getBeforeDate(100).toInstant(),Instant.now()));
//// queryDataParam.setPageInfo(new PageInfo(1,10));
// List<FluxTable> query = InfluxClient.Client.queryByGroup(queryDataParam);
//
//
// for (FluxTable fluxTable : query) {
// List<FluxRecord> records = fluxTable.getRecords();
// if(records.size()!=0){
// res.add((String) records.get(0).getValueByKey("batchNum"));
// continue;
// }
// }
// return R.ok(res);
// }
@PostMapping("/NPGraphTest")
@@ -216,6 +215,32 @@ public class ProcessInspectionController {
return R.ok("成功",npGraph1);
}
@PostMapping("/NPGraph")
public R<NPGraphData> NPGraph(@RequestBody GraphArg graphArg) throws Exception {
ProductFeatures productFeatures = setRealSampleSize(graphArg);
if(productFeatures == null){
return R.failed("检验参数异常");
}
NPGraph npGraph = new NPGraph(productFeatures);
QueryDataGroupByTimeParam queryDataParam = new QueryDataGroupByTimeParam();
queryDataParam.setMeasurement(Constant.measurement);
queryDataParam.setRange(new Range( graphArg.getBegin().toInstant() , graphArg.getEnd().toInstant() ));
queryDataParam.setTimeType(graphArg.getGroupType());
npGraph.initialDate(queryDataParam);
NPGraphData npGraph1 = new NPGraphData(
npGraph.getList()==null?null:npGraph.getList(),
npGraph.getArgName()==null?null:npGraph.getArgName()
);
return R.ok("成功",npGraph1);
}
@PostMapping("/PGraphTest")
public R<PGraphData> PGraphTest() throws Exception {
ProductFeatures productFeatures = new ProductFeatures();
@@ -296,9 +321,13 @@ public class ProcessInspectionController {
private ProductFeatures setRealSampleSize(GraphArg graphArg){
ProductFeaturesDTO productFeaturesDTO = productFeaturesService.get(graphArg.getProductFeaturesId());
if(productFeaturesDTO == null){
return null;
}
if(graphArg.getSampleSize()!=null){
productFeaturesDTO.setSampleSize(graphArg.getSampleSize());
}
ProductFeatures productFeatures = new ProductFeatures();
BeanUtils.copyProperties(productFeaturesDTO, productFeatures);
return productFeatures;
@@ -313,7 +342,9 @@ public class ProcessInspectionController {
@PostMapping("/XbarSGraph")
public R<XbarSGraphData> xbarSGraph(@RequestBody GraphArg graphArg) throws Exception {
ProductFeatures productFeatures = setRealSampleSize(graphArg);
if(productFeatures == null){
return R.failed("检验参数异常");
}
MeanStandardDeviationGraph meanStandardDeviationGraph = new MeanStandardDeviationGraph(productFeatures);
if(graphArg.getInterpretationScheme()!=null){
meanStandardDeviationGraph.isNeedInterpretation(graphArg.getInterpretationScheme());
@@ -339,7 +370,9 @@ public class ProcessInspectionController {
public R<XbarRGraphData> XbarRGraph(@RequestBody GraphArg graphArg) throws Exception {
ProductFeatures productFeatures = setRealSampleSize(graphArg);
if(productFeatures == null){
return R.failed("检验参数异常");
}
MeanRGraph meanRGraph = new MeanRGraph(productFeatures);
//如果要检验那么set 判读方案
if(graphArg.getInterpretationScheme()!=null){
@@ -372,7 +405,9 @@ public class ProcessInspectionController {
public R<XMRGraphData> XMRGraph(@RequestBody GraphArg graphArg) throws Exception {
ProductFeatures productFeatures = setRealSampleSize(graphArg);
if(productFeatures == null){
return R.failed("检验参数异常");
}
XMRGraph xmrGraph = new XMRGraph(productFeatures);
//如果要检验那么set 判读方案
if(graphArg.getInterpretationScheme()!=null){
@@ -397,31 +432,15 @@ public class ProcessInspectionController {
return R.ok("成功",xmrGraphData);
}
@PostMapping("/NPGraph")
public R<NPGraphData> NPGraph(@RequestBody GraphArg graphArg) throws Exception {
ProductFeatures productFeatures = setRealSampleSize(graphArg);
NPGraph npGraph = new NPGraph(productFeatures);
QueryDataGroupByTimeParam queryDataParam = new QueryDataGroupByTimeParam();
queryDataParam.setMeasurement(Constant.measurement);
queryDataParam.setRange(new Range( graphArg.getBegin().toInstant() , graphArg.getEnd().toInstant() ));
queryDataParam.setTimeType(graphArg.getGroupType());
npGraph.initialDate(queryDataParam);
NPGraphData npGraph1 = new NPGraphData(
npGraph.getList()==null?null:npGraph.getList(),
npGraph.getArgName()==null?null:npGraph.getArgName()
);
return R.ok("成功",npGraph1);
}
@PostMapping("/PGraph")
public R<PGraphData> PGraph(@RequestBody GraphArg graphArg) throws Exception {
ProductFeatures productFeatures = setRealSampleSize(graphArg);
if(productFeatures == null){
return R.failed("检验参数异常");
}
PGraph pGraph = new PGraph(productFeatures);
QueryDataGroupByTimeParam queryDataParam = new QueryDataGroupByTimeParam();
@@ -440,7 +459,9 @@ public class ProcessInspectionController {
public R<CGraphData> CGraph(@RequestBody GraphArg graphArg) throws Exception {
ProductFeatures productFeatures = setRealSampleSize(graphArg);
if(productFeatures == null){
return R.failed("检验参数异常");
}
CGraph cGraph = new CGraph(productFeatures);
QueryDataGroupByTimeParam queryDataParam = new QueryDataGroupByTimeParam();
@@ -460,7 +481,9 @@ public class ProcessInspectionController {
public R<UGraphData> UGraph(@RequestBody GraphArg graphArg) throws Exception {
ProductFeatures productFeatures = setRealSampleSize(graphArg);
if(productFeatures == null){
return R.failed("检验参数异常");
}
UGraph uGraph = new UGraph(productFeatures);
QueryDataGroupByTimeParam queryDataParam = new QueryDataGroupByTimeParam();

View File

@@ -2,10 +2,12 @@ package com.cnbm.processInspection.dto;
import com.cnbm.basic.entity.ProductFeatures;
import com.cnbm.influx.param.Range;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
@@ -18,15 +20,20 @@ import java.util.List;
@ApiModel(value = "控制图 查询参数类")
public class GraphArg {
@ApiModelProperty(value = "检验特性Id")
@NotNull(message = "检验特性Id 不能为空")
private Long productFeaturesId;
@ApiModelProperty(value = "查询时间段,开始")
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd")
@NotNull(message = "时间段,开始 不能为空")
private Date begin;
@ApiModelProperty(value = "查询时间段,结束")
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd")
@NotNull(message = "时间段,结束 不能为空")
private Date end;
@ApiModelProperty(value = "判读方案列表")
@ApiModelProperty(value = "判读方案列表,只用于 计量型")
private List<InterpretationListArg> interpretationScheme;
@ApiModelProperty(value = "样本大小,不填的话用之前配置的")

View File

@@ -92,6 +92,7 @@ public class MeanRGraph {
this.interpretationScheme = list;
}
/**
* name : 初始化数据函数
* desc : 从influxdb 里面读取数据,然后 加工处理成 我需要的

View File

@@ -123,6 +123,9 @@ public class MeanStandardDeviationGraph {
List<Double> rArray = new ArrayList<>();
for(int i=0;i<doubleListList.size();i++){
Double[] doubleList = toDoubleArray(doubleListList.get(i).toArray());
if(doubleList.length == 1){
continue;
}
Double xbar = Math.getMean(doubleList);
Double s = Math.StandardDiviation(doubleList).getNormal();

View File

@@ -294,19 +294,9 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
@Override
public void saveFluxParamList2(InspectionSampleDTO2[] lists){
for (InspectionSampleDTO2 dto : lists) {
//String jsonData = {"workingProcedureName":"test","inspectionSheetId":"116","param1":"0.47","param2":"0.687","param2":"0.53"};
String workingProcedureName = dto.getWorkingProcedureName();
String inspectionSheetId = dto.getInspectionSheetId();
// String batchNum = dto.getBatchNum();
String sampleNumber = dto.getSampleNumber();
// LocalDateTime sampleTime = dto.getSampleTime();
// Instant eventTime = sampleTime.toInstant(ZoneOffset.UTC);
InfluxClient.Client.batchInsert(dto.getEvents(), workingProcedureName);
}
// //样本数据更新后 计算检验单缺陷数不良数
// System.out.println("--------------------------------------");
// calculate(Long.valueOf(lists[0].getInspectionSheetId()));
}
private Event newEvent(Instant time, String inspectionSheetId, String argName, String argValue, String sampleNo) {