From c75c89cab975aab152fd9bb4c122c7a3f1b0e55f Mon Sep 17 00:00:00 2001 From: caixiang <939387484@qq.com> Date: Tue, 3 Jan 2023 09:24:12 +0800 Subject: [PATCH] commit for pull --- .../com/cnbm/influx/config/InfluxClient.java | 4 +- .../controller/InspectionSheetController.java | 1 + .../ProcessInspectionController.java | 149 ++++++++++-------- .../cnbm/processInspection/dto/GraphArg.java | 9 +- .../forMeterage/mr/MeanRGraph.java | 1 + .../ms/MeanStandardDeviationGraph.java | 3 + .../impl/InspectionSheetServiceImpl.java | 10 -- .../mapper/InspectionSheetMapper.xml | 6 +- .../cnbm/qualityPlanning/entity/XMRPoint.java | 14 +- .../qualityPlanning/entity/XbarRPoint.java | 17 +- .../qualityPlanning/entity/XbarSPoint.java | 20 ++- 11 files changed, 135 insertions(+), 99 deletions(-) diff --git a/ym-influx/src/main/java/com/cnbm/influx/config/InfluxClient.java b/ym-influx/src/main/java/com/cnbm/influx/config/InfluxClient.java index bed6e47..5e58b13 100644 --- a/ym-influx/src/main/java/com/cnbm/influx/config/InfluxClient.java +++ b/ym-influx/src/main/java/com/cnbm/influx/config/InfluxClient.java @@ -113,13 +113,13 @@ public enum InfluxClient { Point point = null; if(event.getSampleNumber()==null){ point = Point.measurement(measurement) - .addTag("transationId", event.getTransationId()) + .addTag("transationId", event.getTransationId()==null ? "" : event.getTransationId()) .addTag("argName", event.getArgName()) .addField("argValue", event.getArgValue()) .time(event.getTime().toEpochMilli(), WritePrecision.MS); }else { point = Point.measurement(measurement) - .addTag("transationId", event.getTransationId()) + .addTag("transationId", event.getTransationId()==null ? "" : event.getTransationId()) .addTag("inspectionSheetId", event.getInspectionSheetId()) // .addTag("batchNum", event.getBatchNum()) diff --git a/ym-process-inspection/src/main/java/com/cnbm/processInspection/controller/InspectionSheetController.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/controller/InspectionSheetController.java index 6a77494..1b73e6e 100644 --- a/ym-process-inspection/src/main/java/com/cnbm/processInspection/controller/InspectionSheetController.java +++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/controller/InspectionSheetController.java @@ -174,6 +174,7 @@ public class InspectionSheetController { return inspectionSheetService.getFluxParamList(inspectionSheetId); } + @PostMapping("saveFluxParamList") @ApiOperation("将样本检测参数写入influxdb") public Result saveFluxParamList(@RequestBody InspectionSampleDTO[] lists) throws InterruptedException{ diff --git a/ym-process-inspection/src/main/java/com/cnbm/processInspection/controller/ProcessInspectionController.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/controller/ProcessInspectionController.java index 121c8ed..b8d5322 100644 --- a/ym-process-inspection/src/main/java/com/cnbm/processInspection/controller/ProcessInspectionController.java +++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/controller/ProcessInspectionController.java @@ -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> getBatchs() throws InterruptedException { - List list = new ArrayList<>(); - Random r = new Random(); - Instant instant = DataUtils.getBeforeDate(400).toInstant(); - List res = new ArrayList<>(); - - QueryDataParam queryDataParam = new QueryDataParam(); - queryDataParam.setBucket("qgs-bucket"); - queryDataParam.setMeasurement("Weight"); - List 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 query = InfluxClient.Client.queryByGroup(queryDataParam); - - - for (FluxTable fluxTable : query) { - List records = fluxTable.getRecords(); - if(records.size()!=0){ - res.add((String) records.get(0).getValueByKey("batchNum")); - continue; - } - } - return R.ok(res); - } +// @PostMapping("/getBatchs") +// public R> getBatchs() throws InterruptedException { +// List list = new ArrayList<>(); +// Random r = new Random(); +// Instant instant = DataUtils.getBeforeDate(400).toInstant(); +// List res = new ArrayList<>(); +// +// QueryDataParam queryDataParam = new QueryDataParam(); +// queryDataParam.setBucket("qgs-bucket"); +// queryDataParam.setMeasurement("Weight"); +// List 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 query = InfluxClient.Client.queryByGroup(queryDataParam); +// +// +// for (FluxTable fluxTable : query) { +// List 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 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 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 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 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 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 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 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 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 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(); diff --git a/ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/GraphArg.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/GraphArg.java index 086dd43..0720310 100644 --- a/ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/GraphArg.java +++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/GraphArg.java @@ -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 interpretationScheme; @ApiModelProperty(value = "样本大小,不填的话用之前配置的") diff --git a/ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/forMeterage/mr/MeanRGraph.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/forMeterage/mr/MeanRGraph.java index f6d5686..e155eee 100644 --- a/ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/forMeterage/mr/MeanRGraph.java +++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/forMeterage/mr/MeanRGraph.java @@ -92,6 +92,7 @@ public class MeanRGraph { this.interpretationScheme = list; } + /** * name : 初始化数据函数 * desc : 从influxdb 里面读取数据,然后 加工处理成 我需要的 diff --git a/ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/forMeterage/ms/MeanStandardDeviationGraph.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/forMeterage/ms/MeanStandardDeviationGraph.java index ee92dcc..d66378e 100644 --- a/ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/forMeterage/ms/MeanStandardDeviationGraph.java +++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/forMeterage/ms/MeanStandardDeviationGraph.java @@ -123,6 +123,9 @@ public class MeanStandardDeviationGraph { List rArray = new ArrayList<>(); for(int i=0;i pf.valid = 1 and fspr.valid = 1 - + and pf.product_id = #{productId} - + and fspr.inspection_stage = #{inspectionStage} - + and fspr.working_procedure_id = #{workingProcedureId} diff --git a/ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/entity/XMRPoint.java b/ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/entity/XMRPoint.java index d47b8e7..f71e44d 100644 --- a/ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/entity/XMRPoint.java +++ b/ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/entity/XMRPoint.java @@ -1,5 +1,6 @@ package com.cnbm.qualityPlanning.entity; +import java.util.HashSet; import java.util.Set; /** @@ -20,6 +21,13 @@ public class XMRPoint extends Point { //xbar 不满足 的 判读方案 private Set rsUnsatisfiedRules; + public XMRPoint(Integer position, Double value, Double x, Double rs) { + super(position,value); + this.x = x; + this.rs = rs; + xUnsatisfiedRules = new HashSet(); + rsUnsatisfiedRules = new HashSet(); + } private void setValueToTest(Double value){ setValueForInterpretation(value); @@ -57,11 +65,7 @@ public class XMRPoint extends Point { 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() { diff --git a/ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/entity/XbarRPoint.java b/ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/entity/XbarRPoint.java index 2e9b5dd..4fb255f 100644 --- a/ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/entity/XbarRPoint.java +++ b/ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/entity/XbarRPoint.java @@ -1,6 +1,7 @@ package com.cnbm.qualityPlanning.entity; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Set; @@ -21,7 +22,14 @@ public class XbarRPoint extends Point { private Set rUnsatisfiedRules; //xbar 不满足 的 判读方案 private Set xbarUnsatisfiedRules; - + public XbarRPoint(Integer position, Double value, Double xbar, Double r, List data) { + super(position,value); + this.xbar = xbar; + this.r = r; + this.data = data; + rUnsatisfiedRules = new HashSet(); + xbarUnsatisfiedRules = new HashSet(); + } private void setValueToTest(Double value){ setValueForInterpretation(value); @@ -68,12 +76,7 @@ public class XbarRPoint extends Point { this.r = r; } - public XbarRPoint(Integer position, Double value, Double xbar, Double r, List data) { - super(position,value); - this.xbar = xbar; - this.r = r; - this.data = data; - } + @Override public Integer getPosition() { diff --git a/ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/entity/XbarSPoint.java b/ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/entity/XbarSPoint.java index 12ba008..5c81fd4 100644 --- a/ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/entity/XbarSPoint.java +++ b/ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/entity/XbarSPoint.java @@ -3,6 +3,7 @@ package com.cnbm.qualityPlanning.entity; import io.swagger.models.auth.In; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Set; @@ -20,12 +21,21 @@ public class XbarSPoint extends Point { public XbarSPoint(Integer position, Double value) { super(position, value); } + //s 不满足 的 判读方案 private Set sUnsatisfiedRules; //xbar 不满足 的 判读方案 private Set xbarUnsatisfiedRules; - + public XbarSPoint(Integer position, Double value, Double xbar, Double s, Double r,List data) { + super(position,value); + this.xbar = xbar; + this.s = s; + this.r = r; + this.data = data; + sUnsatisfiedRules = new HashSet(); + xbarUnsatisfiedRules = new HashSet(); + } private void setValueToTest(Double value){ setValueForInterpretation(value); } @@ -78,13 +88,7 @@ public class XbarSPoint extends Point { this.r = r; } - public XbarSPoint(Integer position, Double value, Double xbar, Double s, Double r,List data) { - super(position,value); - this.xbar = xbar; - this.s = s; - this.r = r; - this.data = data; - } + @Override public Integer getPosition() {