diff --git a/ym-admin/src/main/java/com/cnbm/admin/config/SecurityConfig.java b/ym-admin/src/main/java/com/cnbm/admin/config/SecurityConfig.java index 45692d4..eb8dc4a 100644 --- a/ym-admin/src/main/java/com/cnbm/admin/config/SecurityConfig.java +++ b/ym-admin/src/main/java/com/cnbm/admin/config/SecurityConfig.java @@ -73,6 +73,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { "/webjars/**", "/websocket/**", "/influx/**", + // "/basic/**", // "/qualityPlanning/**", // "/processInspection/**", diff --git a/ym-common/pom.xml b/ym-common/pom.xml index e71100a..2e5bb82 100644 --- a/ym-common/pom.xml +++ b/ym-common/pom.xml @@ -15,5 +15,12 @@ ${project.artifactId} + + + org.apache.commons + commons-math3 + 3.6.1 + + \ No newline at end of file diff --git a/ym-common/src/main/java/com/cnbm/common/spc/math/Math.java b/ym-common/src/main/java/com/cnbm/common/spc/math/Math.java index 602548e..386fb4a 100644 --- a/ym-common/src/main/java/com/cnbm/common/spc/math/Math.java +++ b/ym-common/src/main/java/com/cnbm/common/spc/math/Math.java @@ -28,7 +28,6 @@ public class Math { d[6] = new Double(10.2); d[7] = new Double(11.7); - ; System.out.println("均值: "+getMean(d)+",,标准差:"+StandardDiviation(d)+",极差:"+range(d)); } diff --git a/ym-common/src/main/java/com/cnbm/common/spc/math/Matrix.java b/ym-common/src/main/java/com/cnbm/common/spc/math/Matrix.java new file mode 100644 index 0000000..2476988 --- /dev/null +++ b/ym-common/src/main/java/com/cnbm/common/spc/math/Matrix.java @@ -0,0 +1,793 @@ +package com.cnbm.common.spc.math; + +import com.cnbm.common.spc.math.entity.T2GraphEntity; +import org.apache.commons.math3.distribution.FDistribution; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.Arrays; +import java.util.List; + +/** + * @Desc: "" + * @Author: caixiang + * @DATE: 2022/9/2 15:33 + */ +public class Matrix { +// public static void main(String[] args) { +// double[] xbarbar = new double[2]; +// xbarbar[0] = 115.6084; +// xbarbar[1] = 1.0564; +// +// double[] xi = new double[2]; +// xi[0] = 115.84; +// xi[1] = 1.078; +// +// double[] xi2 = new double[2]; +// xi2[0] = 115.76; +// xi2[1] = 1.072; +// +// double[] xi3 = new double[2]; +// xi3[0] = 115.11; +// xi3[1] = 1.015; +// +// double[] xi4 = new double[2]; +// xi4[0] = 116.02; +// xi4[1] = 1.089; +// +// double[] xi5 = new double[2]; +// xi5[0] = 115.80; +// xi5[1] = 1.090; +// +// System.out.println("Ti1:"+ forTi2(xi,xbarbar)*10); +// System.out.println("Ti2:"+ forTi2(xi2,xbarbar)*10); +// System.out.println("Ti3:"+ forTi2(xi3,xbarbar)*10); +// System.out.println("Ti4:"+ forTi2(xi4,xbarbar)*10); +// System.out.println("Ti4:"+ forTi2(xi5,xbarbar)*10); +//// double ti = 10*() +// +// +// +// //创建一个F分布对象,参数为自由度 +// FDistribution fd = new FDistribution(2,179); +// //当α=0.05时,参数为1-α=0.95 +// double v = fd.inverseCumulativeProbability(0.99865); +// //输出值 +// System.out.println("v: "+v*342/179); +// +// +// //m = 25 n = 1 p = 3 +// FDistribution fd2 = new FDistribution(3,21); +// //当α=0.05时,参数为1-α=0.95 +// double v2 = fd2.inverseCumulativeProbability(0.99865); +// //输出值 +// System.out.println("v2: "+v2); +// } + +// public static void main(String[] args) { +// +// double[] xlv = new double[5]; +// xlv[0] = 155; +// xlv[1] = 170; +// xlv[2] = 160; +// xlv[3] = 162; +// xlv[4] = 163; +// +// double[] weigth = new double[5]; +// weigth[0] = 125; +// weigth[1] = 162; +// weigth[2] = 139; +// weigth[3] = 150; +// weigth[4] = 146; +// +// double x1bar = getBar(xlv); +// double x2bar = getBar(weigth); +// System.out.println(); +// double s11 = forS11(xlv,x1bar); +// double s12 = forS12(weigth,x1bar,xlv,x2bar); +// double s22 = forS22(weigth,x2bar); +// System.out.println(); +// +// } + + + public static double[][] initialDemoSource(){ + double[][] source = new double[60][6]; + source[0][0] = 1; + source[0][1] = 1; + source[0][2] = 155; + source[0][3] = 100; + source[0][4] = 60; + source[0][5] = 125; + + source[1][0] = 1; + source[1][1] = 2; + source[1][2] = 170; + source[1][3] = 120; + source[1][4] = 82; + source[1][5] = 162; + + source[2][0] = 1; + source[2][1] = 3; + source[2][2] = 160; + source[2][3] = 132; + source[2][4] = 71; + source[2][5] = 139; + + source[3][0] = 1; + source[3][1] = 4; + source[3][2] = 162; + source[3][3] = 139; + source[3][4] = 70; + source[3][5] = 150; + + source[4][0] = 1; + source[4][1] = 5; + source[4][2] = 163; + source[4][3] = 110; + source[4][4] = 80; + source[4][5] = 146; + + source[5][0] = 2; + source[5][1] = 1; + source[5][2] = 157; + source[5][3] = 110; + source[5][4] = 59; + source[5][5] = 124; + + source[6][0] = 2; + source[6][1] = 2; + source[6][2] = 171; + source[6][3] = 122; + source[6][4] = 81; + source[6][5] = 163; + + source[7][0] = 2; + source[7][1] = 3; + source[7][2] = 162; + source[7][3] = 133; + source[7][4] = 73; + source[7][5] = 139; + + source[8][0] = 2; + source[8][1] = 4; + source[8][2] = 165; + source[8][3] = 140; + source[8][4] = 72; + source[8][5] = 152; + + source[9][0] = 2; + source[9][1] = 5; + source[9][2] = 161; + source[9][3] = 112; + source[9][4] = 81; + source[9][5] = 147; + + source[10][0] = 3; + source[10][1] = 1; + source[10][2] = 153; + source[10][3] = 110; + source[10][4] = 63; + source[10][5] = 123; + + + source[11][0] = 3; + source[11][1] = 2; + source[11][2] = 169; + source[11][3] = 120; + source[11][4] = 86; + source[11][5] = 161; + + + source[12][0] = 3; + source[12][1] = 3; + source[12][2] = 161; + source[12][3] = 133; + source[12][4] = 79; + source[12][5] = 141; + + + source[13][0] = 3; + source[13][1] = 4; + source[13][2] = 160; + source[13][3] = 140; + source[13][4] = 72; + source[13][5] = 153; + + + source[14][0] = 3; + source[14][1] = 5; + source[14][2] = 159; + source[14][3] = 118; + source[14][4] = 82; + source[14][5] = 149; + + source[15][0] = 4; + source[15][1] = 1; + source[15][2] = 157; + source[15][3] = 109; + source[15][4] = 60; + source[15][5] = 126; + + + source[16][0] = 4; + source[16][1] = 2; + source[16][2] = 171; + source[16][3] = 126; + source[16][4] = 81; + source[16][5] = 163; + + + source[17][0] = 4; + source[17][1] = 3; + source[17][2] = 162; + source[17][3] = 135; + source[17][4] = 72; + source[17][5] = 142; + + + source[18][0] = 4; + source[18][1] = 4; + source[18][2] = 163; + source[18][3] = 135; + source[18][4] = 70; + source[18][5] = 151; + + + source[19][0] = 4; + source[19][1] = 5; + source[19][2] = 164; + source[19][3] = 108; + source[19][4] = 72; + source[19][5] = 147; + + source[20][0] = 5; + source[20][1] = 1; + source[20][2] = 156; + source[20][3] = 108; + source[20][4] = 70; + source[20][5] = 126; + + + source[21][0] = 5; + source[21][1] = 2; + source[21][2] = 172; + source[21][3] = 113; + source[21][4] = 80; + source[21][5] = 162; + + + source[22][0] = 5; + source[22][1] = 3; + source[22][2] = 162; + source[22][3] = 130; + source[22][4] = 70; + source[22][5] = 141; + + + source[23][0] = 5; + source[23][1] = 4; + source[23][2] = 162; + source[23][3] = 142; + source[23][4] = 76; + source[23][5] = 150; + + + source[24][0] = 5; + source[24][1] = 5; + source[24][2] = 164; + source[24][3] = 110; + source[24][4] = 83; + source[24][5] = 146; + + source[25][0] = 6; + source[25][1] = 1; + source[25][2] = 157; + source[25][3] = 100; + source[25][4] = 60; + source[25][5] = 128; + + + source[26][0] = 6; + source[26][1] = 2; + source[26][2] = 167; + source[26][3] = 122; + source[26][4] = 80; + source[26][5] = 162; + + + source[27][0] = 6; + source[27][1] = 3; + source[27][2] = 156; + source[27][3] = 133; + source[27][4] = 73; + source[27][5] = 142; + + + source[28][0] = 6; + source[28][1] = 4; + source[28][2] = 161; + source[28][3] = 140; + source[28][4] = 76; + source[28][5] = 150; + + + source[29][0] = 6; + source[29][1] = 5; + source[29][2] = 164; + source[29][3] = 111; + source[29][4] = 82; + source[29][5] = 147; + + source[30][0] = 7; + source[30][1] = 1; + source[30][2] = 157; + source[30][3] = 106; + source[30][4] = 62; + source[30][5] = 127; + + + source[31][0] = 7; + source[31][1] = 2; + source[31][2] = 167; + source[31][3] = 130; + source[31][4] = 83; + source[31][5] = 162; + + + source[32][0] = 7; + source[32][1] = 3; + source[32][2] = 162; + source[32][3] = 125; + source[32][4] = 73; + source[32][5] = 142; + + + source[33][0] = 7; + source[33][1] = 4; + source[33][2] = 161; + source[33][3] = 144; + source[33][4] = 76; + source[33][5] = 152; + + + source[34][0] = 7; + source[34][1] = 5; + source[34][2] = 160; + source[34][3] = 118; + source[34][4] = 85; + source[34][5] = 147; + + source[35][0] = 8; + source[35][1] = 1; + source[35][2] = 159; + source[35][3] = 108; + source[35][4] = 62; + source[35][5] = 128; + + + source[36][0] = 8; + source[36][1] = 2; + source[36][2] = 167; + source[36][3] = 118; + source[36][4] = 84; + source[36][5] = 162; + + + source[37][0] = 8; + source[37][1] = 3; + source[37][2] = 161; + source[37][3] = 120; + source[37][4] = 73; + source[37][5] = 144; + + + source[38][0] = 8; + source[38][1] = 4; + source[38][2] = 164; + source[38][3] = 135; + source[38][4] = 76; + source[38][5] = 151; + + + source[39][0] = 8; + source[39][1] = 5; + source[39][2] = 160; + source[39][3] = 101; + source[39][4] = 81; + source[39][5] = 146; + + source[40][0] = 9; + source[40][1] = 1; + source[40][2] = 157; + source[40][3] = 97; + source[40][4] = 57; + source[40][5] = 126; + + + source[41][0] = 9; + source[41][1] = 2; + source[41][2] = 171; + source[41][3] = 130; + source[41][4] = 72; + source[41][5] = 162; + + + source[42][0] = 9; + source[42][1] = 3; + source[42][2] = 162; + source[42][3] = 134; + source[42][4] = 68; + source[42][5] = 144; + + + source[43][0] = 9; + source[43][1] = 4; + source[43][2] = 164; + source[43][3] = 143; + source[43][4] = 70; + source[43][5] = 150; + + + source[44][0] = 9; + source[44][1] = 5; + source[44][2] = 166; + source[44][3] = 114; + source[44][4] = 80; + source[44][5] = 147; + + + source[45][0] = 10; + source[45][1] = 1; + source[45][2] = 157; + source[45][3] = 107; + source[45][4] = 62; + source[45][5] = 124; + + + source[46][0] = 10; + source[46][1] = 2; + source[46][2] = 172; + source[46][3] = 122; + source[46][4] = 81; + source[46][5] = 160; + + + source[47][0] = 10; + source[47][1] = 3; + source[47][2] = 163; + source[47][3] = 135; + source[47][4] = 72; + source[47][5] = 143; + + + source[48][0] = 10; + source[48][1] = 4; + source[48][2] = 164; + source[48][3] = 141; + source[48][4] = 70; + source[48][5] = 148; + + + source[49][0] = 10; + source[49][1] = 5; + source[49][2] = 166; + source[49][3] = 118; + source[49][4] = 82; + source[49][5] = 146; + + source[50][0] = 11; + source[50][1] = 1; + source[50][2] = 152; + source[50][3] = 106; + source[50][4] = 62; + source[50][5] = 124; + + + source[51][0] = 11; + source[51][1] = 2; + source[51][2] = 167; + source[51][3] = 122; + source[51][4] = 82; + source[51][5] = 162; + + + source[52][0] = 11; + source[52][1] = 3; + source[52][2] = 158; + source[52][3] = 137; + source[52][4] = 74; + source[52][5] = 146; + + + source[53][0] = 11; + source[53][1] = 4; + source[53][2] = 159; + source[53][3] = 146; + source[53][4] = 72; + source[53][5] = 150; + + + source[54][0] = 11; + source[54][1] = 5; + source[54][2] = 160; + source[54][3] = 98; + source[54][4] = 82; + source[54][5] = 145; + + source[55][0] = 12; + source[55][1] = 1; + source[55][2] = 153; + source[55][3] = 106; + source[55][4] = 62; + source[55][5] = 122; + + + source[56][0] = 12; + source[56][1] = 2; + source[56][2] = 168; + source[56][3] = 125; + source[56][4] = 85; + source[56][5] = 164; + + + source[57][0] = 12; + source[57][1] = 3; + source[57][2] = 159; + source[57][3] = 137; + source[57][4] = 72; + source[57][5] = 144; + + + source[58][0] = 12; + source[58][1] = 4; + source[58][2] = 162; + source[58][3] = 146; + source[58][4] = 73; + source[58][5] = 149; + + + source[59][0] = 12; + source[59][1] = 5; + source[59][2] = 167; + source[59][3] = 99; + source[59][4] = 70; + source[59][5] = 148; + return source; + } + + public static void main(String[] args) { + double[][] source = initialDemoSource(); + + T2GraphEntity[] all = new T2GraphEntity[12]; + + //取值 + for(int i=1;i<=12;i++){ + T2GraphEntity t = new T2GraphEntity(); + + for(int j=0;j list){ + Double[] doubles=new Double[list.size()]; + list.toArray(doubles); + if(doubles==null){ + return null; + } + double[] result=new double[doubles.length]; + for(int i=0;i x1Source; + private List x2Source; + + public T2GraphEntity(){ + x1Source = new ArrayList<>(); + x2Source = new ArrayList<>(); + + } + +} diff --git a/ym-common/src/main/java/com/cnbm/common/spc/util/DataUtils.java b/ym-common/src/main/java/com/cnbm/common/spc/util/DataUtils.java index 15ac26e..4f64b95 100644 --- a/ym-common/src/main/java/com/cnbm/common/spc/util/DataUtils.java +++ b/ym-common/src/main/java/com/cnbm/common/spc/util/DataUtils.java @@ -23,6 +23,8 @@ public class DataUtils { } + + public List> split(List value) { List> result = new ArrayList<>(); diff --git a/ym-gateway/src/main/resources/application-dev.yml b/ym-gateway/src/main/resources/application-dev.yml index be3f5ed..e7cc7d1 100644 --- a/ym-gateway/src/main/resources/application-dev.yml +++ b/ym-gateway/src/main/resources/application-dev.yml @@ -65,16 +65,16 @@ spring: # username: postgres # password: 123456 -influx: - url: http://192.168.0.170:8086 # URL to connect to InfluxDB. - username: caixiang # Username to use in the basic auth. - password: 251128856 # Password to use in the basic auth. - token: lkBsC27QZr1W50BSPlGxpTqNNpwuUk5uz1dZZRPSPbCG5VmNDDUo8P3UkZIhGWwfJwkuz6ZGZ7Et4_KBaG3gHw== # Token to use for the authorization. - org: qgs # Default destination organization for writes and queries. - bucket: qgs-bucket # Default destination bucket for writes. - logLevel: BODY # The log level for logging the HTTP request and HTTP response. (Default: NONE) - readTimeout: 5s # Read timeout for OkHttpClient. (Default: 10s) - writeTimeout: 5s # Write timeout for OkHttpClient. (Default: 10s) - connectTimeout: 5s # Connection timeout for OkHttpClient. (Default: 10s) +#influx: +# url: http://192.168.0.170:8086 # URL to connect to InfluxDB. +# username: caixiang # Username to use in the basic auth. +# password: 251128856 # Password to use in the basic auth. +# token: lkBsC27QZr1W50BSPlGxpTqNNpwuUk5uz1dZZRPSPbCG5VmNDDUo8P3UkZIhGWwfJwkuz6ZGZ7Et4_KBaG3gHw== # Token to use for the authorization. +# org: qgs # Default destination organization for writes and queries. +# bucket: qgs-bucket # Default destination bucket for writes. +# logLevel: BODY # The log level for logging the HTTP request and HTTP response. (Default: NONE) +# readTimeout: 5s # Read timeout for OkHttpClient. (Default: 10s) +# writeTimeout: 5s # Write timeout for OkHttpClient. (Default: 10s) +# connectTimeout: 5s # Connection timeout for OkHttpClient. (Default: 10s) # management.health.influx.enabled=true # Whether to enable InfluxDB 2.x health check. \ No newline at end of file diff --git a/ym-influx/pom.xml b/ym-influx/pom.xml index 423bd98..23b5b7e 100644 --- a/ym-influx/pom.xml +++ b/ym-influx/pom.xml @@ -23,6 +23,8 @@ influxdb-client-java 6.3.0 + + com.cnbm ym-common diff --git a/ym-influx/src/main/java/Main2.java b/ym-influx/src/main/java/Main2.java index 2c908e4..c6fd727 100644 --- a/ym-influx/src/main/java/Main2.java +++ b/ym-influx/src/main/java/Main2.java @@ -1,14 +1,8 @@ import com.cnbm.influx.config.InfluxClient; -import com.cnbm.influx.template.Event; -import com.influxdb.client.InfluxDBClient; -import com.influxdb.client.InfluxDBClientFactory; -import com.influxdb.client.WriteApi; import com.influxdb.client.domain.WritePrecision; import com.influxdb.client.write.Point; import java.time.Instant; -import java.util.ArrayList; -import java.util.List; /** * @Desc: "" diff --git a/ym-influx/src/main/java/com/cnbm/influx/Main.java b/ym-influx/src/main/java/com/cnbm/influx/Main.java index 1a6fbbb..8396ab7 100644 --- a/ym-influx/src/main/java/com/cnbm/influx/Main.java +++ b/ym-influx/src/main/java/com/cnbm/influx/Main.java @@ -1,21 +1,15 @@ package com.cnbm.influx; -import com.cnbm.influx.config.InfluxClient; import com.cnbm.influx.param.QueryDataParam; import com.cnbm.influx.param.PageInfo; import com.cnbm.influx.param.Range; -import com.cnbm.influx.param.Tag; -import com.cnbm.influx.template.Event; import com.influxdb.client.*; -import com.influxdb.client.domain.WritePrecision; -import com.influxdb.client.write.Point; import com.influxdb.query.FluxRecord; import com.influxdb.query.FluxTable; import java.text.SimpleDateFormat; -import java.time.Instant; import java.util.*; /** @@ -131,6 +125,8 @@ public class Main { // |> filter(fn: (r) => r["argName"] == "arg4") // |> drop(columns: ["transationId"]) // |> sort(columns: ["_time"], desc: true) + +// |> timeShift(duration: 12h) //用于时区转换 // 取前10条数据 // |> limit(n: 10, offset: 0) // @@ -142,31 +138,31 @@ public class Main { - QueryDataParam queryDataParam = new QueryDataParam(); - queryDataParam.setBucket("qgs-bucket"); - queryDataParam.setRange(new Range(getDate().toInstant(),new Date().toInstant())); - queryDataParam.setMeasurement("WeightHeiHei"); - queryDataParam.setTag(new Tag("argName","LTWeight")); -// queryDataParam.setDropedTagName("transationId"); - List dropNames = new ArrayList<>(); - dropNames.add("transationId"); - dropNames.add("inspectionSheetId"); - dropNames.add("batchNum"); - queryDataParam.setDropedTagNames(dropNames); - queryDataParam.setPageInfo(new PageInfo(1,10000)); - - List tables = query(queryDataParam,influxDBClient); - List records1 = tables.get(0).getRecords(); -// List> lists = Utils.fixedGroup(records1, 10); - - for (FluxTable fluxTable : tables) { - List records = fluxTable.getRecords(); - for (FluxRecord fluxRecord : records) { - Instant timms = fluxRecord.getTime(); - System.out.println("time: "+fluxRecord.getTime() +" key:"+fluxRecord.getField()+" value: " + fluxRecord.getValueByKey("_value")+" measurement: " + fluxRecord.getMeasurement()); - - } - } +// QueryDataParam queryDataParam = new QueryDataParam(); +// queryDataParam.setBucket("qgs-bucket"); +// queryDataParam.setRange(new Range(getDate().toInstant(),new Date().toInstant())); +// queryDataParam.setMeasurement("WeightHeiHei"); +// queryDataParam.setTag(new Tag("argName","LTWeight")); +//// queryDataParam.setDropedTagName("transationId"); +// List dropNames = new ArrayList<>(); +// dropNames.add("transationId"); +// dropNames.add("inspectionSheetId"); +// dropNames.add("batchNum"); +// queryDataParam.setDropedTagNames(dropNames); +// queryDataParam.setPageInfo(new PageInfo(1,10000)); +// +// List tables = query(queryDataParam,influxDBClient); +// List records1 = tables.get(0).getRecords(); +//// List> lists = Utils.fixedGroup(records1, 10); +// +// for (FluxTable fluxTable : tables) { +// List records = fluxTable.getRecords(); +// for (FluxRecord fluxRecord : records) { +// Instant timms = fluxRecord.getTime(); +// System.out.println("time: "+fluxRecord.getTime() +" key:"+fluxRecord.getField()+" value: " + fluxRecord.getValueByKey("_value")+" measurement: " + fluxRecord.getMeasurement()); +// +// } +// } influxDBClient.close(); } @@ -221,4 +217,6 @@ public class Main { return tables; } + + } 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 2146bbf..e311485 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 @@ -76,29 +76,65 @@ public enum InfluxClient { return isConnected; } + /** + * desc: 异步批量 写入数据/更新数据 + * notes: 如果是更新数据,要保证time字段不能改变 + * auth: caixaing + * */ public void insert(Event event, String measurement){ - Point point = Point.measurement(measurement) - .addTag("transationId", event.getTransationId()) - .addTag("inspectionSheetId", event.getInspectionSheetId()) - .addTag("argName", event.getArgName()) - .addField("argValue", event.getArgValue()) - .time(event.getTime().toEpochMilli(), WritePrecision.MS); + + Point point = null; + if(event.getBatchNum()==null){ + point = Point.measurement(measurement) + .addTag("transationId", 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("inspectionSheetId", event.getInspectionSheetId()) + .addTag("sampleNumber", event.getSampleNumber()) + .addTag("batchNum", event.getBatchNum()) + + .addTag("argName", event.getArgName()) + .addField("argValue", event.getArgValue()) + .time(event.getTime().toEpochMilli(), WritePrecision.MS); + } writeApi.writePoint(point); } - //异步 批量写入数据 - //如果要批量插入的话,一次也只能写入 + /** + * desc: 异步批量 写入数据/更新数据 + * notes: 如果是更新数据,要保证time字段不能改变 + * auth: caixaing + * */ public void batchInsert(List events, String measurement){ List list = new ArrayList<>(); for(Event event:events){ - Point point = Point.measurement(measurement) - .addTag("transationId", event.getTransationId()) - .addTag("inspectionSheetId", event.getInspectionSheetId()) - .addTag("batchNum", event.getBatchNum()) - .addTag("argName", event.getArgName()) - .addField("argValue", event.getArgValue()) - .time(event.getTime().toEpochMilli(), WritePrecision.MS); + Point point = null; + if(event.getBatchNum()==null){ + point = Point.measurement(measurement) + .addTag("transationId", 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("inspectionSheetId", event.getInspectionSheetId()) + .addTag("sampleNumber", event.getSampleNumber()) + .addTag("batchNum", event.getBatchNum()) + + .addTag("argName", event.getArgName()) + .addField("argValue", event.getArgValue()) + .time(event.getTime().toEpochMilli(), WritePrecision.MS); + } + + list.add(point); } writeApi.writePoints(list); @@ -118,6 +154,8 @@ 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+"\")"; + //调整时区,查询出的结果 +8个小时 + flux += "|> timeShift(duration: 8h)"; for(String dropName:dropedTagNames){ flux += "|> drop(columns: [\""+dropName+"\"])"; } @@ -125,16 +163,32 @@ public enum InfluxClient { if(pageInfo!=null){ flux += "|> limit(n: "+pageInfo.getSize()+", offset: "+(pageInfo.getCurrent()-1)* pageInfo.getSize()+")"; } + return queryApi.query(flux); + } + public List queryByGroup(QueryDataParam param){ + String measurement = param.getMeasurement(); + List dropedTagNames = param.getDropedTagNames(); + Range range = param.getRange(); + String bucket = param.getBucket(); + String tagName = param.getTag().getTagName(); + String tagValue = param.getTag().getTagValue(); + String groupName = param.getGroupName(); + PageInfo pageInfo = param.getPageInfo(); -// List tables = queryApi.query(flux); -// for (FluxTable fluxTable : tables) { -// List records = fluxTable.getRecords(); -// for (FluxRecord fluxRecord : records) { -// System.out.println("time: "+fluxRecord.getTime() +" key:"+fluxRecord.getField()+" value: " + fluxRecord.getValueByKey("_value")+" measurement: " + fluxRecord.getMeasurement()); -// -// } -// } + String flux = "from(bucket:\""+bucket+"\")"; + flux += "|> range(start: "+range.getBegin()+",stop:"+range.getEnd()+")"; + flux += "|> filter(fn: (r) => r[\"_measurement\"] == \""+measurement+"\")"; + flux += "|> filter(fn: (r) => r[\""+tagName+"\"] == \""+tagValue+"\")"; + flux += "|> timeShift(duration: 8h)"; + flux += "|> group(columns: [\""+groupName+"\"], mode: \"except\")"; + 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()+")"; + } return queryApi.query(flux); } @@ -151,6 +205,7 @@ 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 += "|> timeShift(duration: 8h)"; for(String dropName:dropedTagNames){ flux += "|> drop(columns: [\""+dropName+"\"])"; } @@ -178,4 +233,4 @@ public enum InfluxClient { // } return queryApi.query(flux); } -} +} \ No newline at end of file diff --git a/ym-influx/src/main/java/com/cnbm/influx/config/Main.java b/ym-influx/src/main/java/com/cnbm/influx/config/Main.java new file mode 100644 index 0000000..b61870a --- /dev/null +++ b/ym-influx/src/main/java/com/cnbm/influx/config/Main.java @@ -0,0 +1,78 @@ +package com.cnbm.influx.config; + +import com.cnbm.common.spc.util.DataUtils; +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.influxdb.client.InfluxDBClient; +import com.influxdb.client.InfluxDBClientFactory; +import com.influxdb.client.WriteApi; +import com.influxdb.client.domain.WritePrecision; +import com.influxdb.client.write.Point; +import com.influxdb.query.FluxTable; + +import java.time.Instant; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * @Desc: "" + * @Author: caixiang + * @DATE: 2022/11/30 16:56 + */ +public class Main { + public static void main(String[] args) throws InterruptedException { + //方式一 +// char[] token = "lkBsC27QZr1W50BSPlGxpTqNNpwuUk5uz1dZZRPSPbCG5VmNDDUo8P3UkZIhGWwfJwkuz6ZGZ7Et4_KBaG3gHw==".toCharArray(); +// String org = "qgs"; +// String bucket = "qgs-bucket"; +// InfluxDBClient influxDBClient = InfluxDBClientFactory.create("http://192.168.0.170:8086", token, org, bucket); +// +// +// WriteApi writeApi = influxDBClient.makeWriteApi(); +// +// +// +// Point point2 = Point.measurement("FORUPDATE") +// .addTag("transationId", "222312") +// .addTag("argName", "forUpdate") +// .addField("argValue", 4D) +// .time(Instant.now().toEpochMilli(), WritePrecision.MS); +// List list = new ArrayList<>(); +// list.add(point2); +// +// writeApi.writePoints(list); + + + //方式二 + Event event = new Event(); + + event.setTime(new Date().toInstant()); + event.setTransationId("2344"); + event.setBatchNum("22"); + event.setArgName("forUpdate"); + event.setArgValue("124.1"); + InfluxClient.Client.insert(event,"FORUPDATE"); +// Thread.sleep(50000); +// +// event.setArgValue(333.3); +// InfluxClient.Client.insert(event,"FORUPDATE"); + + + QueryDataParam queryDataParam = new QueryDataParam(); + queryDataParam.setBucket("qgs-bucket"); + queryDataParam.setMeasurement("FORUPDATE"); + List dropNames = new ArrayList<>(); + dropNames.add("transationId"); + dropNames.add("inspectionSheetId"); + queryDataParam.setDropedTagNames(dropNames); + queryDataParam.setTag(new Tag("argName","forUpdate")); + queryDataParam.setRange(new Range(DataUtils.getBeforeDate(999).toInstant(),DataUtils.getAfterDate(999).toInstant())); + queryDataParam.setPageInfo(new PageInfo(1,10)); + List query = InfluxClient.Client.query(queryDataParam); + System.out.println(); + } +} diff --git a/ym-influx/src/main/java/com/cnbm/influx/constant/Constant.java b/ym-influx/src/main/java/com/cnbm/influx/constant/Constant.java index ebf4cbf..113d69f 100644 --- a/ym-influx/src/main/java/com/cnbm/influx/constant/Constant.java +++ b/ym-influx/src/main/java/com/cnbm/influx/constant/Constant.java @@ -18,7 +18,7 @@ public class Constant { public static final LogLevel readTimeout = LogLevel.BODY; public static final LogLevel writeTimeout = LogLevel.BODY; public static final LogLevel connectTimeout = LogLevel.BODY; - public static final String measurement = "WeightHeiHei"; + public static final String measurement = "Weight"; } diff --git a/ym-influx/src/main/java/com/cnbm/influx/controller/S7DemoController.java b/ym-influx/src/main/java/com/cnbm/influx/controller/S7DemoController.java index d52e148..2d9adc4 100644 --- a/ym-influx/src/main/java/com/cnbm/influx/controller/S7DemoController.java +++ b/ym-influx/src/main/java/com/cnbm/influx/controller/S7DemoController.java @@ -17,7 +17,6 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.text.DateFormat; import java.time.Instant; import java.util.ArrayList; import java.util.Date; @@ -38,11 +37,40 @@ public class S7DemoController { for(int i=0;i<999;i++){ Thread.sleep(10); Event event = new Event(); - event.setTime(Instant.now()); + event.setTime(DataUtils.getAfterDate(i).toInstant()); event.setTransationId("asas"+i); + event.setArgName("failDay"); + + int i1 = r.nextInt(10); + if(i1<4){ + event.setArgValue("0"); + }else { + event.setArgValue("1"); + } + +// Double d = r.nextDouble() * 2.5 + 66; +// event.setArgValue(d); + + list.add(event); + } + InfluxClient.Client.batchInsert(list,"Weight"); + } + + @PostMapping("/forTestInsertBatch") + public void forTestInsertBatch() throws InterruptedException { + List list = new ArrayList<>(); + Random r = new Random(); + + for(int i=0;i<99;i++){ + Thread.sleep(10); + Event event = new Event(); + event.setTime(Instant.now()); + event.setTransationId("forbatch"+i); event.setArgName("LTWeight"); Double d = r.nextDouble() * 2.5 + 66; - event.setArgValue(d); + event.setArgValue(d.toString()); + event.setBatchNum(4+""); + event.setInspectionSheetId(i+""); list.add(event); } InfluxClient.Client.batchInsert(list,"Weight"); @@ -63,7 +91,7 @@ public class S7DemoController { event.setArgName("LTWeight"); Double d = r.nextDouble() * 2.5 + 66; event.setInspectionSheetId(j+""); - event.setArgValue(d); + event.setArgValue(d.toString()); event.setBatchNum(i+""); list.add(event); } @@ -71,6 +99,42 @@ public class S7DemoController { InfluxClient.Client.batchInsert(list,"WeightHei"); } + @PostMapping("/insertAndQuery") + public void insertAndQuery() throws InterruptedException { + Event event = new Event(); + +// long l = System.currentTimeMillis(); +// System.out.println("l:"+l); +// event.setTime(new Date(1669874900889l).toInstant()); +// + event.setTime(new Date().toInstant()); + event.setTransationId("4444"); + event.setBatchNum("44"); + event.setArgName("forUpdate"); + event.setArgValue("5555.1"); + InfluxClient.Client.insert(event,"FORUPDATECAIXIANG"); +// Thread.sleep(50000); +// +// event.setArgValue(333.3); +// InfluxClient.Client.insert(event,"FORUPDATE"); + + +// QueryDataParam queryDataParam = new QueryDataParam(); +// queryDataParam.setBucket("qgs-bucket"); +// queryDataParam.setMeasurement("FORUPDATECAIXIANG"); +// List dropNames = new ArrayList<>(); +// dropNames.add("transationId"); +// dropNames.add("inspectionSheetId"); +// queryDataParam.setDropedTagNames(dropNames); +// queryDataParam.setTag(new Tag("argName","forUpdate")); +// queryDataParam.setRange(new Range(DataUtils.getBeforeDate(999).toInstant(),DataUtils.getAfterDate(999).toInstant())); +// queryDataParam.setPageInfo(new PageInfo(1,10)); +// List query = InfluxClient.Client.query(queryDataParam); +// System.out.println(); + } + + + @PostMapping("/insertBatchJYDForTest") public void insertBatchJYDForTest() throws InterruptedException { List list = new ArrayList<>(); @@ -84,17 +148,43 @@ public class S7DemoController { event.setArgName("LostDays"); int i1 = r.nextInt(10); if(i1<4){ - event.setArgValue(new Double(0)); + event.setArgValue("0"); }else { - event.setArgValue(new Double(1)); + event.setArgValue("1"); } - event.setInspectionSheetId(i+""); event.setBatchNum(i+""); list.add(event); } - InfluxClient.Client.batchInsert(list,"WeightHeiHei"); + InfluxClient.Client.batchInsert(list,"Weights"); + } + + @PostMapping("/insertBatchForNew") + public void insertBatchForNew() throws InterruptedException { + List list = new ArrayList<>(); + Random r = new Random(); + + for(int i=0;i<999;i++){ + Thread.sleep(10); + Event event = new Event(); + event.setTime(new Date().toInstant()); + event.setTransationId("asas"+i); + event.setArgName("LiuWeight"); +// int i1 = r.nextInt(10); +// if(i1<4){ +// event.setArgValue(new Double(0)); +// }else { +// event.setArgValue(new Double(1)); +// } + Double d = r.nextDouble() * 2.5 + 66; + event.setArgValue(d.toString()); + event.setInspectionSheetId(i+""); + + event.setBatchNum(i+""); + list.add(event); + } + InfluxClient.Client.batchInsert(list,"Weights"); } /** @@ -131,7 +221,6 @@ public class S7DemoController { List records = fluxTable.getRecords(); for (FluxRecord fluxRecord : records) { System.out.println("value: " + fluxRecord.getValueByKey("_value")); - } } System.out.println(); @@ -157,7 +246,6 @@ public class S7DemoController { List records = fluxTable.getRecords(); for (FluxRecord fluxRecord : records) { System.out.println("value: " + fluxRecord.getValueByKey("_value")); - } } } @@ -178,7 +266,7 @@ public class S7DemoController { event.setTime(Instant.now()); event.setTransationId("asasd11"); event.setArgName("argName11"); - event.setArgValue(900001d); + event.setArgValue("900001"); Point asProcessCompleteEvent = insert(event, "ASProcessCompleteEvent"); InfluxClient.Client.insert(event,"ASProcessCompleteEvent"); } diff --git a/ym-influx/src/main/java/com/cnbm/influx/param/QueryDataParam.java b/ym-influx/src/main/java/com/cnbm/influx/param/QueryDataParam.java index 67b1746..f88ce6c 100644 --- a/ym-influx/src/main/java/com/cnbm/influx/param/QueryDataParam.java +++ b/ym-influx/src/main/java/com/cnbm/influx/param/QueryDataParam.java @@ -29,5 +29,6 @@ public class QueryDataParam extends BaseParam{ //查询的时候,需要忽略的字段。(transationId是唯一标识会对 最终的查询结果集产生影响) private List dropedTagNames; private String bucket; + private String groupName; } diff --git a/ym-influx/src/main/java/com/cnbm/influx/template/Event.java b/ym-influx/src/main/java/com/cnbm/influx/template/Event.java index 5c5009e..24c8124 100644 --- a/ym-influx/src/main/java/com/cnbm/influx/template/Event.java +++ b/ym-influx/src/main/java/com/cnbm/influx/template/Event.java @@ -17,14 +17,23 @@ public class Event { private Instant time; - private String inspectionSheetId; - private String transationId; private String argName; - private Double argValue; + private String argValue; - //批次号,可选的 + //batchNumber(必填), 作为区分 手动录入 和 自动录入的区别 private String batchNum; + + private String inspectionSheetId; + + private String sampleNumber; + + public Event() { + //自动录入,给个默认值 + this.batchNum = "-1"; + this.inspectionSheetId = "-1"; + this.sampleNumber = "-1"; + } } \ No newline at end of file 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 fb870b4..14d8f12 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 @@ -6,10 +6,13 @@ import com.cnbm.basic.service.IProductFeaturesService; import com.cnbm.common.spc.math.StandardDiviation; import com.cnbm.common.spc.util.DataUtils; import com.cnbm.common.vo.R; +import com.cnbm.influx.config.InfluxClient; import com.cnbm.influx.constant.Constant; import com.cnbm.influx.param.QueryDataGroupByTimeParam; 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.*; import com.cnbm.processInspection.graphAnalyzed.forCount.c.CGraph; import com.cnbm.processInspection.graphAnalyzed.forCount.np.NPGraph; @@ -18,6 +21,9 @@ import com.cnbm.processInspection.graphAnalyzed.forCount.u.UGraph; import com.cnbm.processInspection.graphAnalyzed.forMeterage.mr.MeanRGraph; import com.cnbm.processInspection.graphAnalyzed.forMeterage.ms.MeanStandardDeviationGraph; import com.cnbm.processInspection.graphAnalyzed.forMeterage.xmr.XMRGraph; +import com.cnbm.qualityPlanning.entity.ControlLimitDetail; +import com.influxdb.query.FluxRecord; +import com.influxdb.query.FluxTable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; @@ -30,6 +36,7 @@ import org.springframework.web.bind.annotation.RestController; import java.time.Instant; import java.util.ArrayList; import java.util.List; +import java.util.Random; @RestController @RequestMapping("/processInspection") @@ -42,9 +49,9 @@ public class ProcessInspectionController { @PostMapping("/XbarSGraphTest") public R xbarSGraphTest() throws Exception { ProductFeatures productFeatures = new ProductFeatures(); - productFeatures.setSl(new Float(5)); - productFeatures.setUsl(new Float(10)); - productFeatures.setLsl(new Float(1)); + productFeatures.setSl(new Float(65)); + productFeatures.setUsl(new Float(66)); + productFeatures.setLsl(new Float(69)); productFeatures.setName("LTWeight"); productFeatures.setSampleSize(10); @@ -58,16 +65,16 @@ public class ProcessInspectionController { QueryDataParam queryDataParam = new QueryDataParam(); queryDataParam.setMeasurement(Constant.measurement); - queryDataParam.setRange(new Range(DataUtils.getBeforeDate(10).toInstant(), Instant.now())); + queryDataParam.setRange(new Range(DataUtils.getBeforeDate(999).toInstant(), DataUtils.getAfterDate(999).toInstant() )); meanStandardDeviationGraph.initialDate(queryDataParam); XbarSGraphData xbarSGraphData = new XbarSGraphData( - meanStandardDeviationGraph.getMsdGraphEntity(), - meanStandardDeviationGraph.getXbarCL(), - meanStandardDeviationGraph.getSCL(), - meanStandardDeviationGraph.getSpecificationLimit(), - meanStandardDeviationGraph.getProcessCapacity(), - new StandardDiviation(meanStandardDeviationGraph.getXigma(),meanStandardDeviationGraph.getTotalXigma()) + meanStandardDeviationGraph.getMsdGraphEntity()==null?null:meanStandardDeviationGraph.getMsdGraphEntity(), + meanStandardDeviationGraph.getXbarCL()==null?null:new ControlLimitDetail(meanStandardDeviationGraph.getXbarCL().getUCL(), meanStandardDeviationGraph.getXbarCL().getCL(), meanStandardDeviationGraph.getXbarCL().getLCL()), + meanStandardDeviationGraph.getSCL()==null?null:new ControlLimitDetail(meanStandardDeviationGraph.getSCL().getUCL(), meanStandardDeviationGraph.getSCL().getCL(), meanStandardDeviationGraph.getSCL().getLCL()), + meanStandardDeviationGraph.getSpecificationLimit()==null?null:meanStandardDeviationGraph.getSpecificationLimit(), + meanStandardDeviationGraph.getProcessCapacity()==null?null:meanStandardDeviationGraph.getProcessCapacity(), + (meanStandardDeviationGraph.getXigma()==null||meanStandardDeviationGraph.getTotalXigma()==null)?null:new StandardDiviation(meanStandardDeviationGraph.getXigma(),meanStandardDeviationGraph.getTotalXigma()) ); return R.ok("成功",xbarSGraphData); @@ -75,10 +82,11 @@ public class ProcessInspectionController { @PostMapping("/XbarRGraphTest") public R XbarRGraphTest() throws Exception { + //todo SL/USL/LSL 和 sampleSize 需要从外面传过来。 ProductFeatures productFeatures = new ProductFeatures(); - productFeatures.setSl(new Float(5)); - productFeatures.setUsl(new Float(10)); - productFeatures.setLsl(new Float(1)); + productFeatures.setSl(new Float(65)); + productFeatures.setUsl(new Float(66)); + productFeatures.setLsl(new Float(69)); productFeatures.setName("LTWeight"); productFeatures.setSampleSize(10); @@ -92,16 +100,18 @@ public class ProcessInspectionController { QueryDataParam queryDataParam = new QueryDataParam(); queryDataParam.setMeasurement(Constant.measurement); - queryDataParam.setRange(new Range(DataUtils.getBeforeDate(10).toInstant(), Instant.now())); + queryDataParam.setRange(new Range(DataUtils.getBeforeDate(999).toInstant(), DataUtils.getAfterDate(999).toInstant() )); meanRGraph.initialDate(queryDataParam); XbarRGraphData xbarSGraphData = new XbarRGraphData( - meanRGraph.getMrGraphEntity(), - meanRGraph.getXbarCL(), - meanRGraph.getRCL(), - meanRGraph.getSpecificationLimit(), - meanRGraph.getProcessCapacity(), - new StandardDiviation(meanRGraph.getXigma(),meanRGraph.getTotalXigma()) + meanRGraph.getMrGraphEntity()==null?null:meanRGraph.getMrGraphEntity(), + + meanRGraph.getXbarCL()==null?null:new ControlLimitDetail(meanRGraph.getXbarCL().getUCL(), meanRGraph.getXbarCL().getCL(), meanRGraph.getXbarCL().getLCL()), + meanRGraph.getRCL()==null?null:new ControlLimitDetail(meanRGraph.getRCL().getUCL(), meanRGraph.getRCL().getCL(), meanRGraph.getRCL().getLCL()), + + meanRGraph.getSpecificationLimit()==null?null:meanRGraph.getSpecificationLimit(), + meanRGraph.getProcessCapacity()==null?null:meanRGraph.getProcessCapacity(), + (meanRGraph.getXigma()==null||meanRGraph.getTotalXigma()==null)?null:new StandardDiviation(meanRGraph.getXigma(),meanRGraph.getTotalXigma()) ); return R.ok("成功",xbarSGraphData); @@ -109,9 +119,9 @@ public class ProcessInspectionController { @PostMapping("/XMRGraphTest") public R XMRGraphTest() throws Exception { ProductFeatures productFeatures = new ProductFeatures(); - productFeatures.setSl(new Float(5)); - productFeatures.setUsl(new Float(10)); - productFeatures.setLsl(new Float(1)); + productFeatures.setSl(new Float(65)); + productFeatures.setUsl(new Float(66)); + productFeatures.setLsl(new Float(69)); productFeatures.setName("LTWeight"); productFeatures.setSampleSize(1); @@ -125,41 +135,81 @@ public class ProcessInspectionController { QueryDataParam queryDataParam = new QueryDataParam(); queryDataParam.setMeasurement(Constant.measurement); - queryDataParam.setRange(new Range(DataUtils.getBeforeDate(10).toInstant(), Instant.now())); + queryDataParam.setRange(new Range(DataUtils.getBeforeDate(999).toInstant(), DataUtils.getAfterDate(999).toInstant() )); xmrGraph.initialDate(queryDataParam); XMRGraphData xmrGraphData = new XMRGraphData( - xmrGraph.getXmrGraphEntity(), - xmrGraph.getXCL(), - xmrGraph.getRSCL(), - xmrGraph.getSpecificationLimit(), - xmrGraph.getProcessCapacity(), - new StandardDiviation(xmrGraph.getXigma(),xmrGraph.getTotalXigma()) + xmrGraph.getXmrGraphEntity()==null?null:xmrGraph.getXmrGraphEntity(), + xmrGraph.getXCL()==null?null:new ControlLimitDetail(xmrGraph.getXCL().getUCL(), xmrGraph.getXCL().getCL(), xmrGraph.getXCL().getLCL()), + xmrGraph.getRSCL()==null?null:new ControlLimitDetail(xmrGraph.getRSCL().getUCL(), xmrGraph.getRSCL().getCL(), xmrGraph.getRSCL().getLCL()), + 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.setTag(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") public R NPGraphTest() throws Exception { ProductFeatures productFeatures = new ProductFeatures(); - productFeatures.setSl(new Float(5)); - productFeatures.setUsl(new Float(10)); - productFeatures.setLsl(new Float(1)); + productFeatures.setSl(new Float(65)); + productFeatures.setUsl(new Float(66)); + productFeatures.setLsl(new Float(69)); - productFeatures.setName("LostDays"); + productFeatures.setName("failDay"); NPGraph npGraph = new NPGraph(productFeatures); QueryDataGroupByTimeParam queryDataParam = new QueryDataGroupByTimeParam(); queryDataParam.setMeasurement(Constant.measurement); - queryDataParam.setRange(new Range( Instant.now() , DataUtils.getAfterDate(999).toInstant() )); - queryDataParam.setTimeType(1); + queryDataParam.setRange(new Range(DataUtils.getBeforeDate(9999).toInstant(), DataUtils.getAfterDate(9999).toInstant() )); + queryDataParam.setTimeType(2); npGraph.initialDate(queryDataParam); NPGraphData npGraph1 = new NPGraphData( - npGraph.getList(), - npGraph.getSpecificationLimit(), - npGraph.getArgName() + npGraph.getList()==null?null:npGraph.getList(), + npGraph.getSpecificationLimit()==null?null:npGraph.getSpecificationLimit(), + npGraph.getArgName()==null?null:npGraph.getArgName() ); return R.ok("成功",npGraph1); @@ -167,24 +217,24 @@ public class ProcessInspectionController { @PostMapping("/PGraphTest") public R PGraphTest() throws Exception { ProductFeatures productFeatures = new ProductFeatures(); - productFeatures.setSl(new Float(5)); - productFeatures.setUsl(new Float(10)); - productFeatures.setLsl(new Float(1)); + productFeatures.setSl(new Float(65)); + productFeatures.setUsl(new Float(66)); + productFeatures.setLsl(new Float(69)); - productFeatures.setName("LostDays"); + productFeatures.setName("LTWeight"); PGraph pGraph = new PGraph(productFeatures); QueryDataGroupByTimeParam queryDataParam = new QueryDataGroupByTimeParam(); queryDataParam.setMeasurement(Constant.measurement); - queryDataParam.setRange(new Range( Instant.now() , DataUtils.getAfterDate(999).toInstant() )); + queryDataParam.setRange(new Range(DataUtils.getBeforeDate(999).toInstant(), DataUtils.getAfterDate(999).toInstant() )); queryDataParam.setTimeType(2); pGraph.initialDate(queryDataParam); PGraphData npGraph1 = new PGraphData( - pGraph.getList(), - pGraph.getSpecificationLimit(), - pGraph.getArgName() + pGraph.getList()==null?null:pGraph.getList(), + pGraph.getSpecificationLimit()==null?null:pGraph.getSpecificationLimit(), + pGraph.getArgName()==null?null:pGraph.getArgName() ); return R.ok("成功",npGraph1); @@ -192,24 +242,26 @@ public class ProcessInspectionController { @PostMapping("/CGraphTest") public R CGraphTest() throws Exception { ProductFeatures productFeatures = new ProductFeatures(); - productFeatures.setSl(new Float(5)); - productFeatures.setUsl(new Float(10)); - productFeatures.setLsl(new Float(1)); + productFeatures.setSl(new Float(65)); + productFeatures.setUsl(new Float(66)); + productFeatures.setLsl(new Float(69)); - productFeatures.setName("LostDays"); + productFeatures.setName("LTWeight"); CGraph cGraph = new CGraph(productFeatures); QueryDataGroupByTimeParam queryDataParam = new QueryDataGroupByTimeParam(); + //到时候 要看前端 传的,这里的measurement 其实就是 设备名。 queryDataParam.setMeasurement(Constant.measurement); - queryDataParam.setRange(new Range( Instant.now() , DataUtils.getAfterDate(999).toInstant() )); +// queryDataParam.setRange(new Range(DataUtils.getBeforeDate(10).toInstant(), Instant.now())); + queryDataParam.setRange(new Range(DataUtils.getBeforeDate(999).toInstant(), DataUtils.getAfterDate(999).toInstant() )); queryDataParam.setTimeType(2); cGraph.initialDate(queryDataParam); CGraphData npGraph1 = new CGraphData( - cGraph.getList(), - cGraph.getSpecificationLimit(), - cGraph.getArgName() + cGraph.getList()==null?null:cGraph.getList(), + cGraph.getSpecificationLimit()==null?null:cGraph.getSpecificationLimit(), + cGraph.getArgName()==null?null:cGraph.getArgName() ); return R.ok("成功",npGraph1); @@ -218,24 +270,24 @@ public class ProcessInspectionController { @PostMapping("/UGraphTest") public R UGraphTest() throws Exception { ProductFeatures productFeatures = new ProductFeatures(); - productFeatures.setSl(new Float(5)); - productFeatures.setUsl(new Float(10)); - productFeatures.setLsl(new Float(1)); + productFeatures.setSl(new Float(65)); + productFeatures.setUsl(new Float(66)); + productFeatures.setLsl(new Float(69)); - productFeatures.setName("LostDays"); + productFeatures.setName("LTWeight"); UGraph uGraph = new UGraph(productFeatures); QueryDataGroupByTimeParam queryDataParam = new QueryDataGroupByTimeParam(); queryDataParam.setMeasurement(Constant.measurement); - queryDataParam.setRange(new Range( Instant.now() , DataUtils.getAfterDate(999).toInstant() )); + queryDataParam.setRange(new Range(DataUtils.getBeforeDate(999).toInstant(), DataUtils.getAfterDate(999).toInstant() )); queryDataParam.setTimeType(2); uGraph.initialDate(queryDataParam); UGraphData npGraph1 = new UGraphData( - uGraph.getList(), - uGraph.getSpecificationLimit(), - uGraph.getArgName() + uGraph.getList()==null?null:uGraph.getList(), + uGraph.getSpecificationLimit()==null?null:uGraph.getSpecificationLimit(), + uGraph.getArgName()==null?null:uGraph.getArgName() ); return R.ok("成功",npGraph1); @@ -273,12 +325,12 @@ public class ProcessInspectionController { meanStandardDeviationGraph.initialDate(queryDataParam); XbarSGraphData xbarSGraphData = new XbarSGraphData( - meanStandardDeviationGraph.getMsdGraphEntity(), - meanStandardDeviationGraph.getXbarCL(), - meanStandardDeviationGraph.getSCL(), - meanStandardDeviationGraph.getSpecificationLimit(), - meanStandardDeviationGraph.getProcessCapacity(), - new StandardDiviation(meanStandardDeviationGraph.getXigma(),meanStandardDeviationGraph.getTotalXigma()) + meanStandardDeviationGraph.getMsdGraphEntity()==null?null:meanStandardDeviationGraph.getMsdGraphEntity(), + meanStandardDeviationGraph.getXbarCL()==null?null:new ControlLimitDetail(meanStandardDeviationGraph.getXbarCL().getUCL(), meanStandardDeviationGraph.getXbarCL().getCL(), meanStandardDeviationGraph.getXbarCL().getLCL()), + meanStandardDeviationGraph.getSCL()==null?null:new ControlLimitDetail(meanStandardDeviationGraph.getSCL().getUCL(), meanStandardDeviationGraph.getSCL().getCL(), meanStandardDeviationGraph.getSCL().getLCL()), + meanStandardDeviationGraph.getSpecificationLimit()==null?null:meanStandardDeviationGraph.getSpecificationLimit(), + meanStandardDeviationGraph.getProcessCapacity()==null?null:meanStandardDeviationGraph.getProcessCapacity(), + (meanStandardDeviationGraph.getXigma()==null||meanStandardDeviationGraph.getTotalXigma()==null)?null:new StandardDiviation(meanStandardDeviationGraph.getXigma(),meanStandardDeviationGraph.getTotalXigma()) ); return R.ok("成功",xbarSGraphData); @@ -300,13 +352,18 @@ public class ProcessInspectionController { 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()) + meanRGraph.getMrGraphEntity()==null?null:meanRGraph.getMrGraphEntity(), + + meanRGraph.getXbarCL()==null?null:new ControlLimitDetail(meanRGraph.getXbarCL().getUCL(), meanRGraph.getXbarCL().getCL(), meanRGraph.getXbarCL().getLCL()), + meanRGraph.getRCL()==null?null:new ControlLimitDetail(meanRGraph.getRCL().getUCL(), meanRGraph.getRCL().getCL(), meanRGraph.getRCL().getLCL()), + + meanRGraph.getSpecificationLimit()==null?null:meanRGraph.getSpecificationLimit(), + meanRGraph.getProcessCapacity()==null?null:meanRGraph.getProcessCapacity(), + (meanRGraph.getXigma()==null||meanRGraph.getTotalXigma()==null)?null:new StandardDiviation(meanRGraph.getXigma(),meanRGraph.getTotalXigma()) + + ); return R.ok("成功",xbarSGraphData); @@ -329,12 +386,13 @@ public class ProcessInspectionController { xmrGraph.initialDate(queryDataParam); XMRGraphData xmrGraphData = new XMRGraphData( - xmrGraph.getXmrGraphEntity(), - xmrGraph.getXCL(), - xmrGraph.getRSCL(), - xmrGraph.getSpecificationLimit(), - xmrGraph.getProcessCapacity(), - new StandardDiviation(xmrGraph.getXigma(),xmrGraph.getTotalXigma()) + xmrGraph.getXmrGraphEntity()==null?null:xmrGraph.getXmrGraphEntity(), + xmrGraph.getXCL()==null?null:new ControlLimitDetail(xmrGraph.getXCL().getUCL(), xmrGraph.getXCL().getCL(), xmrGraph.getXCL().getLCL()), + xmrGraph.getRSCL()==null?null:new ControlLimitDetail(xmrGraph.getRSCL().getUCL(), xmrGraph.getRSCL().getCL(), xmrGraph.getRSCL().getLCL()), + 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); @@ -354,9 +412,9 @@ public class ProcessInspectionController { npGraph.initialDate(queryDataParam); NPGraphData npGraph1 = new NPGraphData( - npGraph.getList(), - npGraph.getSpecificationLimit(), - npGraph.getArgName() + npGraph.getList()==null?null:npGraph.getList(), + npGraph.getSpecificationLimit()==null?null:npGraph.getSpecificationLimit(), + npGraph.getArgName()==null?null:npGraph.getArgName() ); return R.ok("成功",npGraph1); } @@ -375,9 +433,9 @@ public class ProcessInspectionController { pGraph.initialDate(queryDataParam); PGraphData npGraph1 = new PGraphData( - pGraph.getList(), - pGraph.getSpecificationLimit(), - pGraph.getArgName() + pGraph.getList()==null?null:pGraph.getList(), + pGraph.getSpecificationLimit()==null?null:pGraph.getSpecificationLimit(), + pGraph.getArgName()==null?null:pGraph.getArgName() ); return R.ok("成功",npGraph1); } @@ -395,9 +453,9 @@ public class ProcessInspectionController { cGraph.initialDate(queryDataParam); CGraphData npGraph1 = new CGraphData( - cGraph.getList(), - cGraph.getSpecificationLimit(), - cGraph.getArgName() + cGraph.getList()==null?null:cGraph.getList(), + cGraph.getSpecificationLimit()==null?null:cGraph.getSpecificationLimit(), + cGraph.getArgName()==null?null:cGraph.getArgName() ); return R.ok("成功",npGraph1); } @@ -416,9 +474,9 @@ public class ProcessInspectionController { uGraph.initialDate(queryDataParam); UGraphData uGraphData = new UGraphData( - uGraph.getList(), - uGraph.getSpecificationLimit(), - uGraph.getArgName() + uGraph.getList()==null?null:uGraph.getList(), + uGraph.getSpecificationLimit()==null?null:uGraph.getSpecificationLimit(), + uGraph.getArgName()==null?null:uGraph.getArgName() ); return R.ok("成功",uGraphData); } diff --git a/ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/XMRGraphData.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/XMRGraphData.java index 3842102..c21053d 100644 --- a/ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/XMRGraphData.java +++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/XMRGraphData.java @@ -3,6 +3,7 @@ package com.cnbm.processInspection.dto; import com.cnbm.common.spc.math.StandardDiviation; import com.cnbm.processInspection.graphAnalyzed.forMeterage.xmr.XMRGraphEntity; import com.cnbm.qualityPlanning.entity.ControlLimit; +import com.cnbm.qualityPlanning.entity.ControlLimitDetail; import com.cnbm.qualityPlanning.entity.ProcessCapability; import com.cnbm.qualityPlanning.entity.SpecificationLimit; import io.swagger.annotations.ApiModel; @@ -15,14 +16,14 @@ import lombok.Data; * @DATE: 2022/7/22 14:18 */ @Data -@ApiModel(value = "均值极差控制图 结果类") +@ApiModel(value = "单值-移动极差 结果类") public class XMRGraphData { @ApiModelProperty(value = "控制图list数据") private XMRGraphEntity xmrGraphEntity; @ApiModelProperty(value = "xbar控制图 控制限") - private ControlLimit XBarCL; + private ControlLimitDetail XBarCL; @ApiModelProperty(value = "R控制图 控制限") - private ControlLimit RCL; + private ControlLimitDetail RCL; @ApiModelProperty(value = "工艺规格限") private SpecificationLimit SL; @@ -34,7 +35,7 @@ public class XMRGraphData { private StandardDiviation standardDiviation; - public XMRGraphData(XMRGraphEntity xmrGraphEntity, ControlLimit xBarCL, ControlLimit rCL, SpecificationLimit sl, ProcessCapability processCapability, StandardDiviation standardDiviation){ + public XMRGraphData(XMRGraphEntity xmrGraphEntity, ControlLimitDetail xBarCL, ControlLimitDetail rCL, SpecificationLimit sl, ProcessCapability processCapability, StandardDiviation standardDiviation){ this.xmrGraphEntity = xmrGraphEntity; this.XBarCL = xBarCL; this.RCL = rCL; diff --git a/ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/XbarRGraphData.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/XbarRGraphData.java index 92132ec..9a80ae8 100644 --- a/ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/XbarRGraphData.java +++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/XbarRGraphData.java @@ -2,27 +2,31 @@ package com.cnbm.processInspection.dto; import com.cnbm.common.spc.math.StandardDiviation; import com.cnbm.processInspection.graphAnalyzed.forMeterage.mr.MRGraphEntity; -import com.cnbm.qualityPlanning.entity.ControlLimit; -import com.cnbm.qualityPlanning.entity.ProcessCapability; -import com.cnbm.qualityPlanning.entity.SpecificationLimit; +import com.cnbm.qualityPlanning.entity.*; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.ArrayList; +import java.util.List; +import java.util.Stack; + /** * @Desc: "" * @Author: caixiang * @DATE: 2022/7/22 14:18 */ @Data -@ApiModel(value = "均值极差控制图 结果类") +@ApiModel(value = "均值-极差控制图 结果类") public class XbarRGraphData { @ApiModelProperty(value = "控制图list数据") private MRGraphEntity mrGraphEntity; @ApiModelProperty(value = "xbar控制图 控制限") - private ControlLimit XBarCL; + private ControlLimitDetail XBarCL; + @ApiModelProperty(value = "R控制图 控制限") - private ControlLimit RCL; + private ControlLimitDetail RCL; + @ApiModelProperty(value = "工艺规格限") private SpecificationLimit SL; @@ -34,12 +38,14 @@ public class XbarRGraphData { private StandardDiviation standardDiviation; - public XbarRGraphData(MRGraphEntity mrGraphEntity, ControlLimit xBarCL, ControlLimit rCL, SpecificationLimit sl, ProcessCapability processCapability, StandardDiviation standardDiviation){ + public XbarRGraphData(MRGraphEntity mrGraphEntity, ControlLimitDetail xBarCLDetail , ControlLimitDetail rCLDetail, SpecificationLimit sl, ProcessCapability processCapability, StandardDiviation standardDiviation){ this.mrGraphEntity = mrGraphEntity; - this.XBarCL = xBarCL; - this.RCL = rCL; + this.XBarCL = xBarCLDetail; + this.RCL = rCLDetail; this.SL = sl; this.processCapability = processCapability; this.standardDiviation = standardDiviation; } + + } diff --git a/ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/XbarSGraphData.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/XbarSGraphData.java index 2798f71..38338ea 100644 --- a/ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/XbarSGraphData.java +++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/dto/XbarSGraphData.java @@ -3,6 +3,7 @@ package com.cnbm.processInspection.dto; import com.cnbm.common.spc.math.StandardDiviation; import com.cnbm.processInspection.graphAnalyzed.forMeterage.ms.MSDGraphEntity; import com.cnbm.qualityPlanning.entity.ControlLimit; +import com.cnbm.qualityPlanning.entity.ControlLimitDetail; import com.cnbm.qualityPlanning.entity.ProcessCapability; import com.cnbm.qualityPlanning.entity.SpecificationLimit; import io.swagger.annotations.ApiModel; @@ -15,14 +16,14 @@ import lombok.Data; * @DATE: 2022/7/22 14:18 */ @Data -@ApiModel(value = "均值标准差控制图 结果类") +@ApiModel(value = "均值-标准差控制图 结果类") public class XbarSGraphData { @ApiModelProperty(value = "控制图list数据") private MSDGraphEntity msdGraphEntity; @ApiModelProperty(value = "xbar控制图 控制限") - private ControlLimit XBarCL; + private ControlLimitDetail XBarCL; @ApiModelProperty(value = "s控制图 控制限") - private ControlLimit SCL; + private ControlLimitDetail SCL; @ApiModelProperty(value = "工艺规格限") private SpecificationLimit SL; @@ -34,7 +35,7 @@ public class XbarSGraphData { private StandardDiviation standardDiviation; - public XbarSGraphData(MSDGraphEntity msdGraphEntity,ControlLimit xBarCL,ControlLimit sCL,SpecificationLimit sl,ProcessCapability processCapability,StandardDiviation standardDiviation){ + public XbarSGraphData(MSDGraphEntity msdGraphEntity,ControlLimitDetail xBarCL,ControlLimitDetail sCL,SpecificationLimit sl,ProcessCapability processCapability,StandardDiviation standardDiviation){ this.msdGraphEntity = msdGraphEntity; this.XBarCL = xBarCL; this.SCL = sCL; diff --git a/ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/forCount/c/CGraph.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/forCount/c/CGraph.java index a18d5d3..c17458b 100644 --- a/ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/forCount/c/CGraph.java +++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/forCount/c/CGraph.java @@ -8,7 +8,6 @@ import com.cnbm.influx.param.QueryDataGroupByTimeParam; import com.cnbm.influx.param.Tag; import com.cnbm.qualityPlanning.entity.CPoint; import com.cnbm.qualityPlanning.entity.ControlLimit; -import com.cnbm.qualityPlanning.entity.PPoint; import com.cnbm.qualityPlanning.entity.SpecificationLimit; import com.influxdb.query.FluxRecord; import com.influxdb.query.FluxTable; diff --git a/ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/forCount/np/NPGraph.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/forCount/np/NPGraph.java index e70a802..207e680 100644 --- a/ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/forCount/np/NPGraph.java +++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/forCount/np/NPGraph.java @@ -1,22 +1,15 @@ package com.cnbm.processInspection.graphAnalyzed.forCount.np; import com.cnbm.basic.entity.ProductFeatures; -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.QueryDataGroupByTimeParam; -import com.cnbm.influx.param.QueryDataParam; import com.cnbm.influx.param.Tag; -import com.cnbm.processInspection.controlCoefficientConstant.XBarRCoefficients; -import com.cnbm.processInspection.dto.InterpretationListArg; -import com.cnbm.processInspection.dto.InterpretationListArgForCount; -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 org.omg.CORBA.PRIVATE_MEMBER; import java.util.ArrayList; import java.util.List; diff --git a/ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/forCount/p/PGraph.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/forCount/p/PGraph.java index 978572e..e622c33 100644 --- a/ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/forCount/p/PGraph.java +++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/forCount/p/PGraph.java @@ -7,7 +7,6 @@ import com.cnbm.influx.constant.Constant; import com.cnbm.influx.param.QueryDataGroupByTimeParam; import com.cnbm.influx.param.Tag; import com.cnbm.qualityPlanning.entity.ControlLimit; -import com.cnbm.qualityPlanning.entity.NPPoint; import com.cnbm.qualityPlanning.entity.PPoint; import com.cnbm.qualityPlanning.entity.SpecificationLimit; import com.influxdb.query.FluxRecord; @@ -15,7 +14,6 @@ import com.influxdb.query.FluxTable; import lombok.Data; import java.util.ArrayList; -import java.util.Date; import java.util.List; /** diff --git a/ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/forCount/u/UGraph.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/forCount/u/UGraph.java index 70ede0c..890f0fd 100644 --- a/ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/forCount/u/UGraph.java +++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/graphAnalyzed/forCount/u/UGraph.java @@ -7,7 +7,6 @@ import com.cnbm.influx.constant.Constant; import com.cnbm.influx.param.QueryDataGroupByTimeParam; import com.cnbm.influx.param.Tag; import com.cnbm.qualityPlanning.entity.ControlLimit; -import com.cnbm.qualityPlanning.entity.PPoint; import com.cnbm.qualityPlanning.entity.SpecificationLimit; import com.cnbm.qualityPlanning.entity.UPoint; import com.influxdb.query.FluxRecord; 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 744c6bd..dde11e6 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 @@ -107,6 +107,9 @@ public class MeanRGraph { queryDataParam.setTag(new Tag("argName",argName)); List query = InfluxClient.Client.query(queryDataParam); + if(query.size() == 0){ + return; + } //1. 先从fluxdb 里面提取原始数据 List originData = new ArrayList<>(); for (FluxTable fluxTable : query) { @@ -217,6 +220,9 @@ public class MeanRGraph { * 注意:此函数 要在 initialDate()函数执行之后 * */ public ControlLimit getXbarCL(){ + if(this.mrGraphEntity == null){ + return null; + } return new ControlLimit( (this.mrGraphEntity.getXbarbar() + a2*this.mrGraphEntity.getRbar()), this.mrGraphEntity.getXbarbar(), @@ -229,6 +235,9 @@ public class MeanRGraph { * 注意:此函数 要在 initialDate()函数执行之后 * */ public ControlLimit getRCL(){ + if(this.mrGraphEntity==null){ + return null; + } return new ControlLimit( ( d4 * this.mrGraphEntity.getRbar() ) , this.mrGraphEntity.getRbar() , @@ -241,6 +250,10 @@ public class MeanRGraph { * 注意:此函数 要在 initialDate()函数执行之后 * */ public ProcessCapability getProcessCapacity(){ + if(this.miu==null || this.xigma==null || this.specificationLimit==null){ + return null; + } + SpecificationLimit sp = this.specificationLimit; List warming = new ArrayList<>(); Float usl = sp.getUSL(); diff --git a/ym-process-inspection/src/main/java/com/cnbm/processInspection/service/impl/InspectionSheetServiceImpl.java b/ym-process-inspection/src/main/java/com/cnbm/processInspection/service/impl/InspectionSheetServiceImpl.java index c156944..989ba46 100644 --- a/ym-process-inspection/src/main/java/com/cnbm/processInspection/service/impl/InspectionSheetServiceImpl.java +++ b/ym-process-inspection/src/main/java/com/cnbm/processInspection/service/impl/InspectionSheetServiceImpl.java @@ -5,8 +5,6 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; -import com.cnbm.basic.dto.ProductFactoryRelationDTO; -import com.cnbm.basic.dto.ProductFeaturesDTO; import com.cnbm.basic.entity.Machine; import com.cnbm.basic.entity.Product; import com.cnbm.basic.entity.Shift; @@ -18,9 +16,6 @@ import com.cnbm.basic.service.impl.WorkingProcedureServiceImpl; import com.cnbm.common.page.PageData; import com.cnbm.common.service.impl.CrudServiceImpl; import com.cnbm.common.utils.ConvertUtils; -import com.cnbm.common.validator.ValidatorUtils; -import com.cnbm.common.validator.group.AddGroup; -import com.cnbm.common.validator.group.DefaultGroup; import com.cnbm.influx.config.InfluxClient; import com.cnbm.influx.param.QueryDataParam; import com.cnbm.influx.param.Range; @@ -30,7 +25,6 @@ import com.cnbm.processInspection.dto.InspectionSheetDTO; import com.cnbm.processInspection.entity.InspectionSheet; import com.cnbm.processInspection.mapper.InspectionSheetMapper; import com.cnbm.processInspection.service.IInspectionSheetService; -import com.fasterxml.jackson.core.JsonProcessingException; import com.influxdb.query.FluxTable; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -212,7 +206,7 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl true * 不存在满足rule5的点 => false + * + * Test status: OK(CaiXiang) + * * */ - public static Boolean rule5(List data,ControlLimit controlLimit, Integer m, Integer n){ - Boolean result = false; - Integer upi = 0; - List upforMarkKey = new ArrayList<>(); - List downforMarkKey = new ArrayList<>(); -// Double[] dataArray = (Double[])data.toArray(); - Object[] dataArray = data.toArray(); - ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL()); - System.out.println("controlLimitDetail : "+controlLimitDetail.toString()); - Boolean lastFlag = false; - while(upi < data.size()){ - Point[] keyList = new Point[m]; - if(m>=(data.size()-upi)){ - if(lastFlag){ - break; - } - //System.arraycopy(dataArray , 10 , keyList , 0 , 2 ); - System.arraycopy(dataArray,upi,keyList,0,(data.size()-upi)); - lastFlag = true; - }else { - System.arraycopy(dataArray,upi,keyList,0,m); - } - - Integer upTimes = 0; - Integer downTimes = 0; - for(Point i:keyList){ - if(i.getValueForInterpretation()>controlLimitDetail.getUB()[1]){ - upTimes++; - upforMarkKey.add(i); - System.out.println(); - } - if(i.getValueForInterpretation()=n || downTimes>=n){ - result = true; - if(upTimes>=n){ - for(Point i:upforMarkKey){ - i.getUnsatisfiedRules().add(rule5Number); - } - upforMarkKey = new ArrayList<>(); -// return true; - } - if(downTimes>=n){ - for(Point i:downforMarkKey){ - i.getUnsatisfiedRules().add(rule5Number); - } - downforMarkKey = new ArrayList<>(); -// return true; - } - -// return true; - }else { - upforMarkKey = new ArrayList<>(); - downforMarkKey = new ArrayList<>(); - } - upi++; + private static void rule5Core(List data,Integer m,Integer n){ + if(data.size() == 0 || data.size() == 1){ + return; } + //开始 + Stack stack = new Stack(); + int seqNum = 0; + int i = 0; + while((i+1)< data.size()){ + if(stack.size()==0){ + stack.push(data.get(i)); + i++; + seqNum++; + } + + Boolean sequence = ((stack.peek().getPosition()+1) == data.get(i).getPosition()); + if( sequence ){ + stack.push(data.get(i)); + }else { + Boolean stackIsFull = (stack.size()>=n); + Boolean seqNumIsOK = (seqNum>=m); + if(stackIsFull && seqNumIsOK){ + int size = stack.size(); + for(int s=0;s= data.size()?(i-1):i; + i = nowi; + Boolean sequence = ((stack.peek().getPosition()+1) == data.get(i).getPosition()); + if( sequence ){ + stack.push(data.get(i)); + seqNum++; + }else { + Boolean stackIsFull = (stack.size()>=n); + Boolean seqNumIsOK = (seqNum>=m); + if(stackIsFull && seqNumIsOK){ + int size = stack.size(); + for(int s=0;s=n); + Boolean seqNumIsOK = (seqNum>=m); + if(stackIsFull && seqNumIsOK){ + int size = stack.size(); + for(int s=0;s data,ControlLimit controlLimit, Integer m, Integer n){ + Boolean result = false; + + List upforMarkKey = new ArrayList<>(); + List downforMarkKey = new ArrayList<>(); + + ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL()); + System.out.println("controlLimitDetail : "+controlLimitDetail.toString()); + + + //1.先把异常数据都整理出来 +// for(Point i:data){ +// if(i.getValueForInterpretation()>controlLimitDetail.getUB()[1] || i.getValueForInterpretation()controlLimitDetail.getUB()[1]){ + upforMarkKey.add(i); + } + if(i.getValueForInterpretation() true * 不存在满足rule6的点 => false + * Test status: OK(CaiXiang) * */ - public static Boolean rule6(List data,ControlLimit controlLimit, Integer m, Integer n){ - Boolean result = false; - Integer upi = 0; - List upforMarkKey = new ArrayList<>(); - List downforMarkKey = new ArrayList<>(); -// Double[] dataArray = (Double[])data.toArray(); - Object[] dataArray = data.toArray(); - ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL()); - System.out.println("controlLimitDetail : "+controlLimitDetail.toString()); - Boolean lastFlag = false; - while(upi < data.size()){ - Point[] keyList = new Point[m]; - if(m>=(data.size()-upi)){ - if(lastFlag){ - break; - } - //System.arraycopy(dataArray , 10 , keyList , 0 , 2 ); - System.arraycopy(dataArray,upi,keyList,0,(data.size()-upi)); - lastFlag = true; +// public static Boolean rule6(List data,ControlLimit controlLimit, Integer m, Integer n){ +// Boolean result = false; +// Integer upi = 0; +// List upforMarkKey = new ArrayList<>(); +// List downforMarkKey = new ArrayList<>(); +//// Double[] dataArray = (Double[])data.toArray(); +// Object[] dataArray = data.toArray(); +// ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL()); +// System.out.println("controlLimitDetail : "+controlLimitDetail.toString()); +// Boolean lastFlag = false; +// while(upi < data.size()){ +// Point[] keyList = new Point[m]; +// if(m>=(data.size()-upi)){ +// if(lastFlag){ +// break; +// } +// //System.arraycopy(dataArray , 10 , keyList , 0 , 2 ); +// System.arraycopy(dataArray,upi,keyList,0,(data.size()-upi)); +// lastFlag = true; +// }else { +// System.arraycopy(dataArray,upi,keyList,0,m); +// } +// +// Integer upTimes = 0; +// Integer downTimes = 0; +// for(Point i:keyList){ +// if(i.getValueForInterpretation()>controlLimitDetail.getUC()[1]){ +// upTimes++; +// upforMarkKey.add(i); +// +// } +// if(i.getValueForInterpretation()=n || downTimes>=n){ +// result = true; +// if(upTimes>=n){ +// for(Point i:upforMarkKey){ +// +// i.getUnsatisfiedRules().add(rule6Number); +// } +// upforMarkKey = new ArrayList<>(); +//// return true; +// } +// if(downTimes>=n){ +// for(Point i:downforMarkKey){ +// if(i.getPosition() == 13){ +// System.out.println(1); +// } +// i.getUnsatisfiedRules().add(rule6Number); +// } +//// return true; +// downforMarkKey = new ArrayList<>(); +// } +// +//// return true; +// }else { +// upforMarkKey = new ArrayList<>(); +// downforMarkKey = new ArrayList<>(); +// } +// upi++; +// } +// +// +// return result; +// } + private static void rule6Core(List data,Integer m,Integer n){ + if(data.size() == 0 || data.size() == 1){ + return; + } + //开始 + Stack stack = new Stack(); + int seqNum = 0; + int i = 0; + while((i+1)< data.size()){ + if(stack.size()==0){ + stack.push(data.get(i)); + i++; + seqNum++; + } + + Boolean sequence = ((stack.peek().getPosition()+1) == data.get(i).getPosition()); + if( sequence ){ + stack.push(data.get(i)); }else { - System.arraycopy(dataArray,upi,keyList,0,m); - } - - Integer upTimes = 0; - Integer downTimes = 0; - for(Point i:keyList){ - if(i.getValueForInterpretation()>controlLimitDetail.getUC()[1]){ - upTimes++; - upforMarkKey.add(i); - - } - if(i.getValueForInterpretation()=n || downTimes>=n){ - result = true; - if(upTimes>=n){ - for(Point i:upforMarkKey){ - - i.getUnsatisfiedRules().add(rule6Number); + Boolean stackIsFull = (stack.size()>=n); + Boolean seqNumIsOK = (seqNum>=m); + if(stackIsFull && seqNumIsOK){ + int size = stack.size(); + for(int s=0;s(); -// return true; } - if(downTimes>=n){ - for(Point i:downforMarkKey){ - if(i.getPosition() == 13){ - System.out.println(1); - } - i.getUnsatisfiedRules().add(rule6Number); - } -// return true; - downforMarkKey = new ArrayList<>(); - } - -// return true; - }else { - upforMarkKey = new ArrayList<>(); - downforMarkKey = new ArrayList<>(); + stack.clear(); + stack.push(data.get(i)); } - upi++; + + i++; + seqNum++; + } + //判断最后一次情况 + Integer nowi = i>= data.size()?(i-1):i; + i = nowi; + Boolean sequence = ((stack.peek().getPosition()+1) == data.get(i).getPosition()); + if( sequence ){ + stack.push(data.get(i)); + seqNum++; + }else { + Boolean stackIsFull = (stack.size()>=n); + Boolean seqNumIsOK = (seqNum>=m); + if(stackIsFull && seqNumIsOK){ + int size = stack.size(); + for(int s=0;s=n); + Boolean seqNumIsOK = (seqNum>=m); + if(stackIsFull && seqNumIsOK){ + int size = stack.size(); + for(int s=0;s data,ControlLimit controlLimit, Integer m, Integer n){ + Boolean result = false; + + List upforMarkKey = new ArrayList<>(); + List downforMarkKey = new ArrayList<>(); + + ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL()); + System.out.println("controlLimitDetail : "+controlLimitDetail.toString()); + + + //1.先把异常数据都整理出来 +// for(Point i:data){ +// if(i.getValueForInterpretation()>controlLimitDetail.getUB()[1] || i.getValueForInterpretation()controlLimitDetail.getUC()[1]){ + upforMarkKey.add(i); + } + if(i.getValueForInterpretation() true * 不存在满足rule7的点 => false + * Test status: OK(CaiXiang) * */ - public static Boolean rule7(List data,ControlLimit controlLimit, Integer n){ - - Boolean result = false; - - //Integer upi = 0; - ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL()); - System.out.println(controlLimitDetail.toString()); - Integer times = 0; - List markKey = new ArrayList<>(); - - - for(int i=0;icontrolLimitDetail.getLC()[0] && point.getValueForInterpretation()(); - } - break; +// public static Boolean rule7(List data,ControlLimit controlLimit, Integer n){ +// +// Boolean result = false; +// +// //Integer upi = 0; +// ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL()); +// System.out.println(controlLimitDetail.toString()); +// Integer times = 0; +// List markKey = new ArrayList<>(); +// +// +// for(int i=0;icontrolLimitDetail.getLC()[0] && point.getValueForInterpretation()(); +// } +// break; +// } +// +// //通常情况 +// Point point = data.get(i); +// if( isBetween( data.get(i),data.get(i+1) ) ){ +// if(point.getValueForInterpretation()>controlLimitDetail.getLC()[0] && point.getValueForInterpretation()(); +// } +// }else { +// times = 0; +// markKey = new ArrayList<>(); +// } +// }else { +// times = 0; +// markKey = new ArrayList<>(); +// } +// } +// return result; +// } + private static void rule7Core(List data,Integer n){ + if(data.size() == 0 || data.size() == 1){ + return; + } + //开始 + Stack stack = new Stack(); + int i = 0; + while((i+1)< data.size()){ + if(stack.size()==0){ + stack.push(data.get(i)); + i++; } - //通常情况 - Point point = data.get(i); - if( isBetween( data.get(i),data.get(i+1) ) ){ - if(point.getValueForInterpretation()>controlLimitDetail.getLC()[0] && point.getValueForInterpretation()(); - } - }else { - times = 0; - markKey = new ArrayList<>(); - } + Boolean sequence = ((stack.peek().getPosition()+1) == data.get(i).getPosition()); + if( sequence ){ + stack.push(data.get(i)); }else { - times = 0; - markKey = new ArrayList<>(); + Boolean stackIsFull = (stack.size()>=n); + + if(stackIsFull){ + int size = stack.size(); + for(int s=0;s= data.size()?(i-1):i; + i = nowi; + Boolean sequence = ((stack.peek().getPosition()+1) == data.get(i).getPosition()); + if( sequence ){ + stack.push(data.get(i)); + + }else { + Boolean stackIsFull = (stack.size()>=n); + + if(stackIsFull){ + int size = stack.size(); + for(int s=0;s=n); + + if(stackIsFull){ + int size = stack.size(); + for(int s=0;s data,ControlLimit controlLimit, Integer n){ + Boolean result = false; + +// List upforMarkKey = new ArrayList<>(); +// List downforMarkKey = new ArrayList<>(); + List errforMarkKey = new ArrayList<>(); + + ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL()); + System.out.println("controlLimitDetail : "+controlLimitDetail.toString()); + + + //1.先把异常数据都整理出来 + for(Point i:data){ + if(i.getValueForInterpretation()>controlLimitDetail.getLC()[0] && i.getValueForInterpretation() true * 不存在满足rule8的点 => false + * Test status: OK(CaiXiang) * */ - public static Boolean rule8(List data,ControlLimit controlLimit, Integer n){ - - Boolean result = true; - //Integer upi = 0; - ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL()); - System.out.println(controlLimitDetail.toString()); - Integer times = 0; - List markKey = new ArrayList<>(); - - - for(int i=0;icontrolLimitDetail.getUC()[1] || point.getValueForInterpretation()(); - } - break; +// public static Boolean rule8(List data,ControlLimit controlLimit, Integer n){ +// +// Boolean result = true; +// //Integer upi = 0; +// ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL()); +// System.out.println(controlLimitDetail.toString()); +// Integer times = 0; +// List markKey = new ArrayList<>(); +// +// +// for(int i=0;icontrolLimitDetail.getUC()[1] || point.getValueForInterpretation()(); +// } +// break; +// } +// +// //通常情况 +// Point point = data.get(i); +// if( isBetween( data.get(i),data.get(i+1) ) ){ +// if( point.getValueForInterpretation()>controlLimitDetail.getUC()[1] || point.getValueForInterpretation()(); +// } +// }else { +// times = 0; +// markKey = new ArrayList<>(); +// } +// }else { +// times = 0; +// markKey = new ArrayList<>(); +// } +// } +// return result; +// } + private static void rule8Core(List data,Integer n){ + if(data.size() == 0 || data.size() == 1){ + return; + } + //开始 + Stack stack = new Stack(); + int i = 0; + while((i+1)< data.size()){ + if(stack.size()==0){ + stack.push(data.get(i)); + i++; } - //通常情况 - Point point = data.get(i); - if( isBetween( data.get(i),data.get(i+1) ) ){ - if( point.getValueForInterpretation()>controlLimitDetail.getUC()[1] || point.getValueForInterpretation()(); - } - }else { - times = 0; - markKey = new ArrayList<>(); - } + Boolean sequence = ((stack.peek().getPosition()+1) == data.get(i).getPosition()); + if( sequence ){ + stack.push(data.get(i)); }else { - times = 0; - markKey = new ArrayList<>(); + Boolean stackIsFull = (stack.size()>=n); + + if(stackIsFull){ + int size = stack.size(); + for(int s=0;s= data.size()?(i-1):i; + i = nowi; + Boolean sequence = ((stack.peek().getPosition()+1) == data.get(i).getPosition()); + if( sequence ){ + stack.push(data.get(i)); + + }else { + Boolean stackIsFull = (stack.size()>=n); + + if(stackIsFull){ + int size = stack.size(); + for(int s=0;s=n); + + if(stackIsFull){ + int size = stack.size(); + for(int s=0;s data,ControlLimit controlLimit, Integer n){ + Boolean result = false; + +// List upforMarkKey = new ArrayList<>(); +// List downforMarkKey = new ArrayList<>(); + List errforMarkKey = new ArrayList<>(); + + ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL()); + System.out.println("controlLimitDetail : "+controlLimitDetail.toString()); + + //1.先把异常数据都整理出来 + for(Point i:data){ + if(i.getValueForInterpretation()>controlLimitDetail.getUC()[1] && i.getValueForInterpretation() upforMarkKey){ + //开始 + Stack stack = new Stack(); + int seqNum = 0; + int i = 0; + while((i+1)< upforMarkKey.size()){ + if(stack.size()==0){ + stack.push(upforMarkKey.get(i)); + i++; + seqNum++; + } + + Boolean sequence = ((stack.peek().getPosition()+1) == upforMarkKey.get(i).getPosition()); + if( sequence ){ + stack.push(upforMarkKey.get(i)); + }else { + Boolean stackIsFull = (stack.size()>=3); + Boolean seqNumIsOK = (seqNum>=5); + if(stackIsFull && seqNumIsOK){ + int size = stack.size(); + for(int s=0;s= upforMarkKey.size()?(i-1):i; + i = nowi; + Integer c = (stack.peek().getPosition()+1); + Boolean sequence = ( c == upforMarkKey.get(i).getPosition()); + if( sequence ){ + stack.push(upforMarkKey.get(i)); + seqNum++; + }else { + Boolean stackIsFull = (stack.size()>=3); + Boolean seqNumIsOK = (seqNum>=5); + if(stackIsFull && seqNumIsOK){ + int size = stack.size(); + for(int s=0;s=3); + Boolean seqNumIsOK = (seqNum>=5); + if(stackIsFull && seqNumIsOK){ + int size = stack.size(); + for(int s=0;s upforMarkKey = new ArrayList<>(); + Point point1 = new Point(1,1.0); + Point point2 = new Point(2,1.0); + Point point3 = new Point(4,1.0); + Point point4 = new Point(5,1.0); + Point point5 = new Point(6,1.0); + Point point6 = new Point(7,1.0); + Point point7 = new Point(8,1.0); + Point point8 = new Point(10,1.0); + Point point9 = new Point(11,1.0); + Point point10 = new Point(13,1.0); + Point point11 = new Point(14,1.0); + Point point12 = new Point(15,1.0); + Point point13 = new Point(16,1.0); + Point point14 = new Point(17,1.0); + + + upforMarkKey.add(point1); +// upforMarkKey.add(point2); +// upforMarkKey.add(point3); +// upforMarkKey.add(point4); +// upforMarkKey.add(point5); +// upforMarkKey.add(point6); +// upforMarkKey.add(point7); +// upforMarkKey.add(point8); +// upforMarkKey.add(point9); +// upforMarkKey.add(point10); +// upforMarkKey.add(point11); +// upforMarkKey.add(point12); +// upforMarkKey.add(point13); +// upforMarkKey.add(point14); + + + rule5Core(upforMarkKey); + + System.out.println(); + + } +} diff --git a/ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/common/test/MainRule7TEST.java b/ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/common/test/MainRule7TEST.java new file mode 100644 index 0000000..b8b4598 --- /dev/null +++ b/ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/common/test/MainRule7TEST.java @@ -0,0 +1,112 @@ +package com.cnbm.qualityPlanning.common.test; + +import com.cnbm.qualityPlanning.entity.Point; + +import java.util.ArrayList; +import java.util.List; +import java.util.Stack; + +/** + * @Desc: "" + * @Author: caixiang + * @DATE: 2022/11/29 10:49 + */ +public class MainRule7TEST { + + private static void rule7Core(List data,Integer n){ + //开始 + Stack stack = new Stack(); + int i = 0; + while((i+1)< data.size()){ + if(stack.size()==0){ + stack.push(data.get(i)); + i++; + } + + Boolean sequence = ((stack.peek().getPosition()+1) == data.get(i).getPosition()); + if( sequence ){ + stack.push(data.get(i)); + }else { + Boolean stackIsFull = (stack.size()>=n); + + if(stackIsFull){ + int size = stack.size(); + for(int s=0;s=n); + + if(stackIsFull){ + int size = stack.size(); + for(int s=0;s=n); + + if(stackIsFull){ + int size = stack.size(); + for(int s=0;s upforMarkKey = new ArrayList<>(); + Point point1 = new Point(1,1.0); + Point point2 = new Point(2,1.0); + Point point3 = new Point(4,1.0); + Point point4 = new Point(5,1.0); + Point point5 = new Point(6,1.0); + Point point6 = new Point(7,1.0); + Point point7 = new Point(8,1.0); + Point point8 = new Point(10,1.0); + Point point9 = new Point(11,1.0); + Point point10 = new Point(13,1.0); + Point point11 = new Point(14,1.0); + Point point12 = new Point(15,1.0); + Point point13 = new Point(16,1.0); + Point point14 = new Point(17,1.0); + + + upforMarkKey.add(point1); + upforMarkKey.add(point2); + upforMarkKey.add(point3); + upforMarkKey.add(point4); + upforMarkKey.add(point5); + upforMarkKey.add(point6); + upforMarkKey.add(point7); + upforMarkKey.add(point8); + upforMarkKey.add(point9); + upforMarkKey.add(point10); + upforMarkKey.add(point11); + upforMarkKey.add(point12); + upforMarkKey.add(point13); + upforMarkKey.add(point14); + + + rule7Core(upforMarkKey,3); + + System.out.println(); + + } +} diff --git a/ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/entity/ControlLimitDetail.java b/ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/entity/ControlLimitDetail.java index 2d06b89..3ac0e62 100644 --- a/ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/entity/ControlLimitDetail.java +++ b/ym-quality-planning/src/main/java/com/cnbm/qualityPlanning/entity/ControlLimitDetail.java @@ -1,6 +1,8 @@ package com.cnbm.qualityPlanning.entity; +import cn.hutool.core.util.NumberUtil; import lombok.Data; +import org.springframework.util.NumberUtils; /** * @Desc: "" @@ -27,19 +29,19 @@ public class ControlLimitDetail { this.CL = CL; this.LCL = LCL; Double agv1 = (this.UCL-this.CL)/3; - this.UC[0] = this.CL; - this.UC[1] = this.CL+agv1; - this.UB[0] = this.UC[0]; - this.UB[1] = this.UC[0]+agv1; - this.UA[0] = this.UB[0]; - this.UA[1] = this.UB[0]+agv1; + this.UC[0] = NumberUtil.round(this.CL,4).doubleValue(); + this.UC[1] = NumberUtil.round(this.CL+agv1,4).doubleValue(); + this.UB[0] = NumberUtil.round(this.UC[1],4).doubleValue(); + this.UB[1] = NumberUtil.round(this.UB[0]+agv1,4).doubleValue(); + this.UA[0] = NumberUtil.round(this.UB[1],4).doubleValue(); + this.UA[1] = NumberUtil.round(this.UA[0]+agv1,4).doubleValue(); Double agv2 = (this.CL-this.LCL)/3; - this.LC[0] = this.CL-agv2; - this.LC[1] = this.CL; - this.LB[0] = this.LC[0]-agv2; - this.LB[1] = this.LC[0]; - this.LA[0] = this.LB[0]-agv2; - this.LA[1] = this.LB[0]; + this.LC[0] = NumberUtil.round(this.CL-agv2,4).doubleValue(); + this.LC[1] = NumberUtil.round(this.CL,4).doubleValue(); + this.LB[0] = NumberUtil.round(this.LC[0]-agv2,4).doubleValue(); + this.LB[1] = NumberUtil.round(this.LC[0],4).doubleValue(); + this.LA[0] = NumberUtil.round(this.LB[0]-agv2,4).doubleValue(); + this.LA[1] = NumberUtil.round(this.LB[0],4).doubleValue(); } }