Merge branch 'master' of http://git.picaiba.com/CaiXiang/SPC into yanyang
Conflicts: ym-influx/src/main/java/com/cnbm/influx/config/InfluxClient.java ym-influx/src/main/java/com/cnbm/influx/controller/S7DemoController.java ym-influx/src/main/java/com/cnbm/influx/template/Event.java
This commit is contained in:
commit
ab35b10130
@ -73,6 +73,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
"/webjars/**",
|
"/webjars/**",
|
||||||
"/websocket/**",
|
"/websocket/**",
|
||||||
"/influx/**",
|
"/influx/**",
|
||||||
|
|
||||||
// "/basic/**",
|
// "/basic/**",
|
||||||
// "/qualityPlanning/**",
|
// "/qualityPlanning/**",
|
||||||
// "/processInspection/**",
|
// "/processInspection/**",
|
||||||
|
@ -15,5 +15,12 @@
|
|||||||
<build>
|
<build>
|
||||||
<finalName>${project.artifactId}</finalName>
|
<finalName>${project.artifactId}</finalName>
|
||||||
</build>
|
</build>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-math3</artifactId>
|
||||||
|
<version>3.6.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -28,7 +28,6 @@ public class Math {
|
|||||||
d[6] = new Double(10.2);
|
d[6] = new Double(10.2);
|
||||||
d[7] = new Double(11.7);
|
d[7] = new Double(11.7);
|
||||||
|
|
||||||
;
|
|
||||||
System.out.println("均值: "+getMean(d)+",,标准差:"+StandardDiviation(d)+",极差:"+range(d));
|
System.out.println("均值: "+getMean(d)+",,标准差:"+StandardDiviation(d)+",极差:"+range(d));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
793
ym-common/src/main/java/com/cnbm/common/spc/math/Matrix.java
Normal file
793
ym-common/src/main/java/com/cnbm/common/spc/math/Matrix.java
Normal file
@ -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<source.length;j++){
|
||||||
|
if(source[j][0] == i){
|
||||||
|
|
||||||
|
//1=观察对象、2=心率 、3=收缩压 、4=舒张压 、5=体重 、
|
||||||
|
t.getX1Source().add(source[j][1]);
|
||||||
|
t.getX2Source().add(source[j][3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
all[i-1] = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
//计算每个子组的 x1bar、x2bar、S11、S12、S22
|
||||||
|
System.out.println();
|
||||||
|
for(int i=0;i<all.length;i++){
|
||||||
|
T2GraphEntity t2 = all[i];
|
||||||
|
double[] x1Source = ListTodouble(t2.getX1Source());
|
||||||
|
double[] x2Source = ListTodouble(t2.getX2Source());
|
||||||
|
double x1bar = getBar(x1Source);
|
||||||
|
double x2bar = getBar(x2Source);
|
||||||
|
t2.setX1bar(x1bar);
|
||||||
|
t2.setX2bar(x2bar);
|
||||||
|
t2.setS11(forS11(x1Source,x1bar));
|
||||||
|
t2.setS12(forS12(x1Source,x1bar,x2Source,x2bar));
|
||||||
|
t2.setS22(forS22(x2Source,x2bar));
|
||||||
|
}
|
||||||
|
|
||||||
|
//计算母体的 x1barbar、x2barbar、S11bar、S12bar、S22bar
|
||||||
|
double x1barbar = 0;
|
||||||
|
double x2barbar = 0;
|
||||||
|
double s11bar = 0;
|
||||||
|
double s12bar = 0;
|
||||||
|
double s22bar = 0;
|
||||||
|
for(int i=0;i<all.length;i++){
|
||||||
|
T2GraphEntity t2 = all[i];
|
||||||
|
x1barbar += t2.getX1bar();
|
||||||
|
x2barbar += t2.getX2bar();
|
||||||
|
s11bar += t2.getS11();
|
||||||
|
s12bar += t2.getS12();
|
||||||
|
s22bar += t2.getS22();
|
||||||
|
}
|
||||||
|
x1barbar /= all.length;
|
||||||
|
x2barbar /= all.length;
|
||||||
|
s11bar /= all.length;
|
||||||
|
s12bar /= all.length;
|
||||||
|
s22bar /= all.length;
|
||||||
|
|
||||||
|
//算 Ti2
|
||||||
|
double[][] sbar = new double[2][2];
|
||||||
|
sbar[0][0] = s11bar;
|
||||||
|
sbar[0][1] = s12bar;
|
||||||
|
sbar[1][0] = s12bar;
|
||||||
|
sbar[1][1] = s22bar;
|
||||||
|
double[][] inverse = inverseSE(sbar);
|
||||||
|
|
||||||
|
double[] xbarbar = new double[2];
|
||||||
|
xbarbar[0] = x1barbar;
|
||||||
|
xbarbar[1] = x2barbar;
|
||||||
|
for(int i=0;i<all.length;i++){
|
||||||
|
T2GraphEntity t2 = all[i];
|
||||||
|
double[] xibar = new double[2];
|
||||||
|
xibar[0] = t2.getX1bar();
|
||||||
|
xibar[1] = t2.getX2bar();
|
||||||
|
double ti = forTi2(xibar, xbarbar, inverse);
|
||||||
|
t2.setTi(ti*6);
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
|
//算 ucl
|
||||||
|
//创建一个F分布对象,参数为自由度
|
||||||
|
FDistribution fd = new FDistribution(2,59);
|
||||||
|
//当α=0.05时,参数为1-α=0.95
|
||||||
|
double v = fd.inverseCumulativeProbability(0.99865);
|
||||||
|
//输出值
|
||||||
|
System.out.println("v: "+v);
|
||||||
|
double m = 12;
|
||||||
|
double n = 6;
|
||||||
|
double p = 2;
|
||||||
|
double head = (double) 110/(double)59;
|
||||||
|
double ucl = head*v;
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
|
for(int i=0;i< all.length;i++){
|
||||||
|
T2GraphEntity t2GraphEntity = all[i];
|
||||||
|
System.out.println(i+" 位置: "+t2GraphEntity.getTi());
|
||||||
|
}
|
||||||
|
System.out.println("ucl:" + ucl);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double[] ListTodouble(List<Double> 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<doubles.length;i++){
|
||||||
|
result[i]=doubles[i].doubleValue();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static double getBar(double[] d){
|
||||||
|
return Arrays.stream(d).average().getAsDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double forS11(double[] source , double x1bar){
|
||||||
|
double all = 0;
|
||||||
|
for(int i=0;i<source.length;i++){
|
||||||
|
double c = source[i]-x1bar;
|
||||||
|
all += c*c;
|
||||||
|
}
|
||||||
|
return all/(source.length-1);
|
||||||
|
}
|
||||||
|
public static Double forS12(double[] source1 , double x1bar , double[] source2 , double x2bar){
|
||||||
|
double all = 0;
|
||||||
|
if(source1.length != source2.length){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for(int i=0;i<source1.length;i++){
|
||||||
|
double c1 = source1[i]-x1bar;
|
||||||
|
double c2 = source2[i]-x2bar;
|
||||||
|
all += c1*c2;
|
||||||
|
}
|
||||||
|
return all/(source1.length-1);
|
||||||
|
}
|
||||||
|
public static double forS22(double[] source , double x2bar){
|
||||||
|
double all = 0;
|
||||||
|
for(int i=0;i<source.length;i++){
|
||||||
|
double c = source[i]-x2bar;
|
||||||
|
all += c*c;
|
||||||
|
}
|
||||||
|
return all/(source.length-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double forTi2(double[] xibar,double[] xbarbar,double[][] inverse) {
|
||||||
|
|
||||||
|
double[] xf = new double[2];
|
||||||
|
xf[0] = xibar[0]-xbarbar[0];
|
||||||
|
xf[1] = xibar[1]-xbarbar[1];
|
||||||
|
|
||||||
|
double[] ff = new double[2];
|
||||||
|
ff[0] = xf[0]*inverse[0][0] + xf[1]*inverse[1][0];
|
||||||
|
ff[1] = xf[0]*inverse[0][1] + xf[1]*inverse[1][1];
|
||||||
|
|
||||||
|
return ff[0]*xf[0] + ff[1]*xf[1];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double formatDouble(double d) {
|
||||||
|
// 新方法,如果不需要四舍五入,可以使用RoundingMode.DOWN
|
||||||
|
BigDecimal bg = new BigDecimal(d).setScale(4, RoundingMode.UP);
|
||||||
|
return bg.doubleValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
//2阶矩阵 求逆
|
||||||
|
public static double[][] inverseSE(double[][] source){
|
||||||
|
double a = source[0][0];
|
||||||
|
double b = source[0][1];
|
||||||
|
double c = source[1][0];
|
||||||
|
double d = source[1][1];
|
||||||
|
double to = 1/(a*d-b*c);
|
||||||
|
double[][] res = new double[2][2];
|
||||||
|
// res[0][0] = formatDouble(d*to);
|
||||||
|
// res[0][1] = formatDouble(b*to*-1);
|
||||||
|
// res[1][0] = formatDouble(c*to*-1);
|
||||||
|
// res[1][1] = formatDouble(a*to);
|
||||||
|
res[0][0] = d*to;
|
||||||
|
res[0][1] = b*to*-1;
|
||||||
|
res[1][0] = c*to*-1;
|
||||||
|
res[1][1] = a*to;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取矩阵的逆
|
||||||
|
public static int[][] inverse(int[][] A) {
|
||||||
|
int[][] B = new int[A.length][A[0].length];
|
||||||
|
for (int i = 0; i < A.length; i++) {
|
||||||
|
for (int j = 0; j < A[0].length; j++) {
|
||||||
|
B[i][j] = A[i][j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int[][] C = new int[A.length][A[0].length];
|
||||||
|
for (int i = 0; i < A.length; i++) {
|
||||||
|
for (int j = 0; j < A[0].length; j++) {
|
||||||
|
C[i][j] = (int) java.lang.Math.pow(-1, i + j) * determinant(minor(B, j, i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int[][] D = new int[A.length][A[0].length];
|
||||||
|
for (int i = 0; i < A.length; i++) {
|
||||||
|
for (int j = 0; j < A[0].length; j++) {
|
||||||
|
D[i][j] = C[i][j] / determinant(A);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return D;
|
||||||
|
}
|
||||||
|
//求解矩阵的行列式
|
||||||
|
private static int determinant(int[][] a) {
|
||||||
|
if (a.length == 1) {
|
||||||
|
return a[0][0];
|
||||||
|
}
|
||||||
|
int det = 0;
|
||||||
|
for (int i = 0; i < a[0].length; i++) {
|
||||||
|
det += (int) java.lang.Math.pow(-1, i) * a[0][i] * determinant(minor(a, 0, i));
|
||||||
|
}
|
||||||
|
return det;
|
||||||
|
}
|
||||||
|
//求解二维矩阵在某一位置的伴随矩阵
|
||||||
|
private static int[][] minor(int[][] b, int i, int j) {
|
||||||
|
int[][] a = new int[b.length - 1][b[0].length - 1];
|
||||||
|
for (int x = 0, y = 0; x < b.length; x++) {
|
||||||
|
if (x == i) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (int m = 0,n = 0; m < b[0].length; m++) {
|
||||||
|
if (m == j) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
a[y][n] = b[x][m];
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package com.cnbm.common.spc.math;
|
package com.cnbm.common.spc.math;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -8,10 +10,13 @@ import lombok.Data;
|
|||||||
* @DATE: 2022/7/25 15:23
|
* @DATE: 2022/7/25 15:23
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@ApiModel(value = "标准差结果类")
|
||||||
public class StandardDiviation {
|
public class StandardDiviation {
|
||||||
//标准差
|
//组内标准差
|
||||||
|
@ApiModelProperty(value = "组内标准差")
|
||||||
private Double normal;
|
private Double normal;
|
||||||
//总体标准差
|
//总体标准差
|
||||||
|
@ApiModelProperty(value = "总体标准差")
|
||||||
private Double totality;
|
private Double totality;
|
||||||
|
|
||||||
public StandardDiviation(Double normal, Double totality) {
|
public StandardDiviation(Double normal, Double totality) {
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.cnbm.common.spc.math.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Desc: ""
|
||||||
|
* @Author: caixiang
|
||||||
|
* @DATE: 2022/9/9 15:26
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class T2GraphEntity {
|
||||||
|
private double x1bar;
|
||||||
|
private double x2bar;
|
||||||
|
private double s11;
|
||||||
|
private double s12;
|
||||||
|
private double s22;
|
||||||
|
private double ti;
|
||||||
|
private List<Double> x1Source;
|
||||||
|
private List<Double> x2Source;
|
||||||
|
|
||||||
|
public T2GraphEntity(){
|
||||||
|
x1Source = new ArrayList<>();
|
||||||
|
x2Source = new ArrayList<>();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -23,6 +23,8 @@ public class DataUtils {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public List<List<Date>> split(List<Date> value) {
|
public List<List<Date>> split(List<Date> value) {
|
||||||
List<List<Date>> result = new ArrayList<>();
|
List<List<Date>> result = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -65,16 +65,16 @@ spring:
|
|||||||
# username: postgres
|
# username: postgres
|
||||||
# password: 123456
|
# password: 123456
|
||||||
|
|
||||||
influx:
|
#influx:
|
||||||
url: http://192.168.0.170:8086 # URL to connect to InfluxDB.
|
# url: http://192.168.0.170:8086 # URL to connect to InfluxDB.
|
||||||
username: caixiang # Username to use in the basic auth.
|
# username: caixiang # Username to use in the basic auth.
|
||||||
password: 251128856 # Password to use in the basic auth.
|
# password: 251128856 # Password to use in the basic auth.
|
||||||
token: lkBsC27QZr1W50BSPlGxpTqNNpwuUk5uz1dZZRPSPbCG5VmNDDUo8P3UkZIhGWwfJwkuz6ZGZ7Et4_KBaG3gHw== # Token to use for the authorization.
|
# token: lkBsC27QZr1W50BSPlGxpTqNNpwuUk5uz1dZZRPSPbCG5VmNDDUo8P3UkZIhGWwfJwkuz6ZGZ7Et4_KBaG3gHw== # Token to use for the authorization.
|
||||||
org: qgs # Default destination organization for writes and queries.
|
# org: qgs # Default destination organization for writes and queries.
|
||||||
bucket: qgs-bucket # Default destination bucket for writes.
|
# bucket: qgs-bucket # Default destination bucket for writes.
|
||||||
logLevel: BODY # The log level for logging the HTTP request and HTTP response. (Default: NONE)
|
# logLevel: BODY # The log level for logging the HTTP request and HTTP response. (Default: NONE)
|
||||||
readTimeout: 5s # Read timeout for OkHttpClient. (Default: 10s)
|
# readTimeout: 5s # Read timeout for OkHttpClient. (Default: 10s)
|
||||||
writeTimeout: 5s # Write timeout for OkHttpClient. (Default: 10s)
|
# writeTimeout: 5s # Write timeout for OkHttpClient. (Default: 10s)
|
||||||
connectTimeout: 5s # Connection 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.
|
# management.health.influx.enabled=true # Whether to enable InfluxDB 2.x health check.
|
@ -23,6 +23,8 @@
|
|||||||
<artifactId>influxdb-client-java</artifactId>
|
<artifactId>influxdb-client-java</artifactId>
|
||||||
<version>6.3.0</version>
|
<version>6.3.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.cnbm</groupId>
|
<groupId>com.cnbm</groupId>
|
||||||
<artifactId>ym-common</artifactId>
|
<artifactId>ym-common</artifactId>
|
||||||
|
@ -1,14 +1,8 @@
|
|||||||
import com.cnbm.influx.config.InfluxClient;
|
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.domain.WritePrecision;
|
||||||
import com.influxdb.client.write.Point;
|
import com.influxdb.client.write.Point;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Desc: ""
|
* @Desc: ""
|
||||||
|
@ -1,21 +1,15 @@
|
|||||||
package com.cnbm.influx;
|
package com.cnbm.influx;
|
||||||
|
|
||||||
import com.cnbm.influx.config.InfluxClient;
|
|
||||||
import com.cnbm.influx.param.QueryDataParam;
|
import com.cnbm.influx.param.QueryDataParam;
|
||||||
|
|
||||||
import com.cnbm.influx.param.PageInfo;
|
import com.cnbm.influx.param.PageInfo;
|
||||||
import com.cnbm.influx.param.Range;
|
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.*;
|
||||||
import com.influxdb.client.domain.WritePrecision;
|
|
||||||
import com.influxdb.client.write.Point;
|
|
||||||
import com.influxdb.query.FluxRecord;
|
import com.influxdb.query.FluxRecord;
|
||||||
import com.influxdb.query.FluxTable;
|
import com.influxdb.query.FluxTable;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -131,6 +125,8 @@ public class Main {
|
|||||||
// |> filter(fn: (r) => r["argName"] == "arg4")
|
// |> filter(fn: (r) => r["argName"] == "arg4")
|
||||||
// |> drop(columns: ["transationId"])
|
// |> drop(columns: ["transationId"])
|
||||||
// |> sort(columns: ["_time"], desc: true)
|
// |> sort(columns: ["_time"], desc: true)
|
||||||
|
|
||||||
|
// |> timeShift(duration: 12h) //用于时区转换
|
||||||
// 取前10条数据
|
// 取前10条数据
|
||||||
// |> limit(n: 10, offset: 0)
|
// |> limit(n: 10, offset: 0)
|
||||||
//
|
//
|
||||||
@ -142,31 +138,31 @@ public class Main {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
QueryDataParam queryDataParam = new QueryDataParam();
|
// QueryDataParam queryDataParam = new QueryDataParam();
|
||||||
queryDataParam.setBucket("qgs-bucket");
|
// queryDataParam.setBucket("qgs-bucket");
|
||||||
queryDataParam.setRange(new Range(getDate().toInstant(),new Date().toInstant()));
|
// queryDataParam.setRange(new Range(getDate().toInstant(),new Date().toInstant()));
|
||||||
queryDataParam.setMeasurement("WeightHeiHei");
|
// queryDataParam.setMeasurement("WeightHeiHei");
|
||||||
queryDataParam.setTag(new Tag("argName","LTWeight"));
|
// queryDataParam.setTag(new Tag("argName","LTWeight"));
|
||||||
// queryDataParam.setDropedTagName("transationId");
|
//// queryDataParam.setDropedTagName("transationId");
|
||||||
List<String> dropNames = new ArrayList<>();
|
// List<String> dropNames = new ArrayList<>();
|
||||||
dropNames.add("transationId");
|
// dropNames.add("transationId");
|
||||||
dropNames.add("inspectionSheetId");
|
// dropNames.add("inspectionSheetId");
|
||||||
dropNames.add("batchNum");
|
// dropNames.add("batchNum");
|
||||||
queryDataParam.setDropedTagNames(dropNames);
|
// queryDataParam.setDropedTagNames(dropNames);
|
||||||
queryDataParam.setPageInfo(new PageInfo(1,10000));
|
// queryDataParam.setPageInfo(new PageInfo(1,10000));
|
||||||
|
//
|
||||||
List<FluxTable> tables = query(queryDataParam,influxDBClient);
|
// List<FluxTable> tables = query(queryDataParam,influxDBClient);
|
||||||
List<FluxRecord> records1 = tables.get(0).getRecords();
|
// List<FluxRecord> records1 = tables.get(0).getRecords();
|
||||||
// List<List<FluxRecord>> lists = Utils.fixedGroup(records1, 10);
|
//// List<List<FluxRecord>> lists = Utils.fixedGroup(records1, 10);
|
||||||
|
//
|
||||||
for (FluxTable fluxTable : tables) {
|
// for (FluxTable fluxTable : tables) {
|
||||||
List<FluxRecord> records = fluxTable.getRecords();
|
// List<FluxRecord> records = fluxTable.getRecords();
|
||||||
for (FluxRecord fluxRecord : records) {
|
// for (FluxRecord fluxRecord : records) {
|
||||||
Instant timms = fluxRecord.getTime();
|
// Instant timms = fluxRecord.getTime();
|
||||||
System.out.println("time: "+fluxRecord.getTime() +" key:"+fluxRecord.getField()+" value: " + fluxRecord.getValueByKey("_value")+" measurement: " + fluxRecord.getMeasurement());
|
// System.out.println("time: "+fluxRecord.getTime() +" key:"+fluxRecord.getField()+" value: " + fluxRecord.getValueByKey("_value")+" measurement: " + fluxRecord.getMeasurement());
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
influxDBClient.close();
|
influxDBClient.close();
|
||||||
}
|
}
|
||||||
@ -221,4 +217,6 @@ public class Main {
|
|||||||
|
|
||||||
return tables;
|
return tables;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -76,29 +76,65 @@ public enum InfluxClient {
|
|||||||
return isConnected;
|
return isConnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* desc: 异步批量 写入数据/更新数据
|
||||||
|
* notes: 如果是更新数据,要保证time字段不能改变
|
||||||
|
* auth: caixaing
|
||||||
|
* */
|
||||||
public void insert(Event event, String measurement){
|
public void insert(Event event, String measurement){
|
||||||
Point point = Point.measurement(measurement)
|
|
||||||
.addTag("transationId", event.getTransationId())
|
Point point = null;
|
||||||
.addTag("inspectionSheetId", event.getInspectionSheetId())
|
if(event.getBatchNum()==null){
|
||||||
.addTag("argName", event.getArgName())
|
point = Point.measurement(measurement)
|
||||||
.addField("argValue", event.getArgValue())
|
.addTag("transationId", event.getTransationId())
|
||||||
.time(event.getTime().toEpochMilli(), WritePrecision.MS);
|
.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);
|
writeApi.writePoint(point);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//异步 批量写入数据
|
/**
|
||||||
//如果要批量插入的话,一次也只能写入
|
* desc: 异步批量 写入数据/更新数据
|
||||||
|
* notes: 如果是更新数据,要保证time字段不能改变
|
||||||
|
* auth: caixaing
|
||||||
|
* */
|
||||||
public void batchInsert(List<Event> events, String measurement){
|
public void batchInsert(List<Event> events, String measurement){
|
||||||
List<Point> list = new ArrayList<>();
|
List<Point> list = new ArrayList<>();
|
||||||
for(Event event:events){
|
for(Event event:events){
|
||||||
Point point = Point.measurement(measurement)
|
Point point = null;
|
||||||
.addTag("transationId", event.getTransationId())
|
if(event.getBatchNum()==null){
|
||||||
.addTag("inspectionSheetId", event.getInspectionSheetId())
|
point = Point.measurement(measurement)
|
||||||
.addTag("batchNum", event.getBatchNum())
|
.addTag("transationId", event.getTransationId())
|
||||||
.addTag("argName", event.getArgName())
|
.addTag("argName", event.getArgName())
|
||||||
.addField("argValue", event.getArgValue())
|
.addField("argValue", event.getArgValue())
|
||||||
.time(event.getTime().toEpochMilli(), WritePrecision.MS);
|
.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);
|
list.add(point);
|
||||||
}
|
}
|
||||||
writeApi.writePoints(list);
|
writeApi.writePoints(list);
|
||||||
@ -118,6 +154,8 @@ public enum InfluxClient {
|
|||||||
flux += "|> range(start: "+range.getBegin()+",stop:"+range.getEnd()+")";
|
flux += "|> range(start: "+range.getBegin()+",stop:"+range.getEnd()+")";
|
||||||
flux += "|> filter(fn: (r) => r[\"_measurement\"] == \""+measurement+"\")";
|
flux += "|> filter(fn: (r) => r[\"_measurement\"] == \""+measurement+"\")";
|
||||||
flux += "|> filter(fn: (r) => r[\""+tagName+"\"] == \""+tagValue+"\")";
|
flux += "|> filter(fn: (r) => r[\""+tagName+"\"] == \""+tagValue+"\")";
|
||||||
|
//调整时区,查询出的结果 +8个小时
|
||||||
|
flux += "|> timeShift(duration: 8h)";
|
||||||
for(String dropName:dropedTagNames){
|
for(String dropName:dropedTagNames){
|
||||||
flux += "|> drop(columns: [\""+dropName+"\"])";
|
flux += "|> drop(columns: [\""+dropName+"\"])";
|
||||||
}
|
}
|
||||||
@ -125,16 +163,32 @@ public enum InfluxClient {
|
|||||||
if(pageInfo!=null){
|
if(pageInfo!=null){
|
||||||
flux += "|> limit(n: "+pageInfo.getSize()+", offset: "+(pageInfo.getCurrent()-1)* pageInfo.getSize()+")";
|
flux += "|> limit(n: "+pageInfo.getSize()+", offset: "+(pageInfo.getCurrent()-1)* pageInfo.getSize()+")";
|
||||||
}
|
}
|
||||||
|
return queryApi.query(flux);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FluxTable> queryByGroup(QueryDataParam param){
|
||||||
|
String measurement = param.getMeasurement();
|
||||||
|
List<String> 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<FluxTable> tables = queryApi.query(flux);
|
String flux = "from(bucket:\""+bucket+"\")";
|
||||||
// for (FluxTable fluxTable : tables) {
|
flux += "|> range(start: "+range.getBegin()+",stop:"+range.getEnd()+")";
|
||||||
// List<FluxRecord> records = fluxTable.getRecords();
|
flux += "|> filter(fn: (r) => r[\"_measurement\"] == \""+measurement+"\")";
|
||||||
// for (FluxRecord fluxRecord : records) {
|
flux += "|> filter(fn: (r) => r[\""+tagName+"\"] == \""+tagValue+"\")";
|
||||||
// System.out.println("time: "+fluxRecord.getTime() +" key:"+fluxRecord.getField()+" value: " + fluxRecord.getValueByKey("_value")+" measurement: " + fluxRecord.getMeasurement());
|
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);
|
return queryApi.query(flux);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,6 +205,7 @@ public enum InfluxClient {
|
|||||||
flux += "|> range(start: "+range.getBegin()+",stop:"+range.getEnd()+")";
|
flux += "|> range(start: "+range.getBegin()+",stop:"+range.getEnd()+")";
|
||||||
flux += "|> filter(fn: (r) => r[\"_measurement\"] == \""+measurement+"\")";
|
flux += "|> filter(fn: (r) => r[\"_measurement\"] == \""+measurement+"\")";
|
||||||
flux += "|> filter(fn: (r) => r[\""+tagName+"\"] == \""+tagValue+"\")";
|
flux += "|> filter(fn: (r) => r[\""+tagName+"\"] == \""+tagValue+"\")";
|
||||||
|
flux += "|> timeShift(duration: 8h)";
|
||||||
for(String dropName:dropedTagNames){
|
for(String dropName:dropedTagNames){
|
||||||
flux += "|> drop(columns: [\""+dropName+"\"])";
|
flux += "|> drop(columns: [\""+dropName+"\"])";
|
||||||
}
|
}
|
||||||
|
78
ym-influx/src/main/java/com/cnbm/influx/config/Main.java
Normal file
78
ym-influx/src/main/java/com/cnbm/influx/config/Main.java
Normal file
@ -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<Point> 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<String> 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<FluxTable> query = InfluxClient.Client.query(queryDataParam);
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
}
|
@ -18,7 +18,7 @@ public class Constant {
|
|||||||
public static final LogLevel readTimeout = LogLevel.BODY;
|
public static final LogLevel readTimeout = LogLevel.BODY;
|
||||||
public static final LogLevel writeTimeout = LogLevel.BODY;
|
public static final LogLevel writeTimeout = LogLevel.BODY;
|
||||||
public static final LogLevel connectTimeout = LogLevel.BODY;
|
public static final LogLevel connectTimeout = LogLevel.BODY;
|
||||||
public static final String measurement = "WeightHeiHei";
|
public static final String measurement = "Weight";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -38,11 +37,40 @@ public class S7DemoController {
|
|||||||
for(int i=0;i<999;i++){
|
for(int i=0;i<999;i++){
|
||||||
Thread.sleep(10);
|
Thread.sleep(10);
|
||||||
Event event = new Event();
|
Event event = new Event();
|
||||||
event.setTime(Instant.now());
|
event.setTime(DataUtils.getAfterDate(i).toInstant());
|
||||||
event.setTransationId("asas"+i);
|
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<Event> 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");
|
event.setArgName("LTWeight");
|
||||||
Double d = r.nextDouble() * 2.5 + 66;
|
Double d = r.nextDouble() * 2.5 + 66;
|
||||||
event.setArgValue(d);
|
event.setArgValue(d.toString());
|
||||||
|
event.setBatchNum(4+"");
|
||||||
|
event.setInspectionSheetId(i+"");
|
||||||
list.add(event);
|
list.add(event);
|
||||||
}
|
}
|
||||||
InfluxClient.Client.batchInsert(list,"Weight");
|
InfluxClient.Client.batchInsert(list,"Weight");
|
||||||
@ -63,7 +91,7 @@ public class S7DemoController {
|
|||||||
event.setArgName("LTWeight");
|
event.setArgName("LTWeight");
|
||||||
Double d = r.nextDouble() * 2.5 + 66;
|
Double d = r.nextDouble() * 2.5 + 66;
|
||||||
event.setInspectionSheetId(j+"");
|
event.setInspectionSheetId(j+"");
|
||||||
event.setArgValue(d);
|
event.setArgValue(d.toString());
|
||||||
event.setBatchNum(i+"");
|
event.setBatchNum(i+"");
|
||||||
list.add(event);
|
list.add(event);
|
||||||
}
|
}
|
||||||
@ -71,6 +99,42 @@ public class S7DemoController {
|
|||||||
InfluxClient.Client.batchInsert(list,"WeightHei");
|
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<String> 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<FluxTable> query = InfluxClient.Client.query(queryDataParam);
|
||||||
|
// System.out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/insertBatchJYDForTest")
|
@PostMapping("/insertBatchJYDForTest")
|
||||||
public void insertBatchJYDForTest() throws InterruptedException {
|
public void insertBatchJYDForTest() throws InterruptedException {
|
||||||
List<Event> list = new ArrayList<>();
|
List<Event> list = new ArrayList<>();
|
||||||
@ -84,17 +148,43 @@ public class S7DemoController {
|
|||||||
event.setArgName("LostDays");
|
event.setArgName("LostDays");
|
||||||
int i1 = r.nextInt(10);
|
int i1 = r.nextInt(10);
|
||||||
if(i1<4){
|
if(i1<4){
|
||||||
event.setArgValue(new Double(0));
|
event.setArgValue("0");
|
||||||
}else {
|
}else {
|
||||||
event.setArgValue(new Double(1));
|
event.setArgValue("1");
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setInspectionSheetId(i+"");
|
event.setInspectionSheetId(i+"");
|
||||||
|
|
||||||
event.setBatchNum(i+"");
|
event.setBatchNum(i+"");
|
||||||
list.add(event);
|
list.add(event);
|
||||||
}
|
}
|
||||||
InfluxClient.Client.batchInsert(list,"WeightHeiHei");
|
InfluxClient.Client.batchInsert(list,"Weights");
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/insertBatchForNew")
|
||||||
|
public void insertBatchForNew() throws InterruptedException {
|
||||||
|
List<Event> 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<FluxRecord> records = fluxTable.getRecords();
|
List<FluxRecord> records = fluxTable.getRecords();
|
||||||
for (FluxRecord fluxRecord : records) {
|
for (FluxRecord fluxRecord : records) {
|
||||||
System.out.println("value: " + fluxRecord.getValueByKey("_value"));
|
System.out.println("value: " + fluxRecord.getValueByKey("_value"));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println();
|
System.out.println();
|
||||||
@ -157,7 +246,6 @@ public class S7DemoController {
|
|||||||
List<FluxRecord> records = fluxTable.getRecords();
|
List<FluxRecord> records = fluxTable.getRecords();
|
||||||
for (FluxRecord fluxRecord : records) {
|
for (FluxRecord fluxRecord : records) {
|
||||||
System.out.println("value: " + fluxRecord.getValueByKey("_value"));
|
System.out.println("value: " + fluxRecord.getValueByKey("_value"));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,7 +266,7 @@ public class S7DemoController {
|
|||||||
event.setTime(Instant.now());
|
event.setTime(Instant.now());
|
||||||
event.setTransationId("asasd11");
|
event.setTransationId("asasd11");
|
||||||
event.setArgName("argName11");
|
event.setArgName("argName11");
|
||||||
event.setArgValue(900001d);
|
event.setArgValue("900001");
|
||||||
Point asProcessCompleteEvent = insert(event, "ASProcessCompleteEvent");
|
Point asProcessCompleteEvent = insert(event, "ASProcessCompleteEvent");
|
||||||
InfluxClient.Client.insert(event,"ASProcessCompleteEvent");
|
InfluxClient.Client.insert(event,"ASProcessCompleteEvent");
|
||||||
}
|
}
|
||||||
|
@ -29,5 +29,6 @@ public class QueryDataParam extends BaseParam{
|
|||||||
//查询的时候,需要忽略的字段。(transationId是唯一标识会对 最终的查询结果集产生影响)
|
//查询的时候,需要忽略的字段。(transationId是唯一标识会对 最终的查询结果集产生影响)
|
||||||
private List<String> dropedTagNames;
|
private List<String> dropedTagNames;
|
||||||
private String bucket;
|
private String bucket;
|
||||||
|
private String groupName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,14 +17,23 @@ public class Event {
|
|||||||
|
|
||||||
private Instant time;
|
private Instant time;
|
||||||
|
|
||||||
private String inspectionSheetId;
|
|
||||||
|
|
||||||
private String transationId;
|
private String transationId;
|
||||||
|
|
||||||
private String argName;
|
private String argName;
|
||||||
|
|
||||||
private Double argValue;
|
private String argValue;
|
||||||
|
|
||||||
//批次号,可选的
|
//batchNumber(必填), 作为区分 手动录入 和 自动录入的区别
|
||||||
private String batchNum;
|
private String batchNum;
|
||||||
|
|
||||||
|
private String inspectionSheetId;
|
||||||
|
|
||||||
|
private String sampleNumber;
|
||||||
|
|
||||||
|
public Event() {
|
||||||
|
//自动录入,给个默认值
|
||||||
|
this.batchNum = "-1";
|
||||||
|
this.inspectionSheetId = "-1";
|
||||||
|
this.sampleNumber = "-1";
|
||||||
|
}
|
||||||
}
|
}
|
@ -6,10 +6,13 @@ import com.cnbm.basic.service.IProductFeaturesService;
|
|||||||
import com.cnbm.common.spc.math.StandardDiviation;
|
import com.cnbm.common.spc.math.StandardDiviation;
|
||||||
import com.cnbm.common.spc.util.DataUtils;
|
import com.cnbm.common.spc.util.DataUtils;
|
||||||
import com.cnbm.common.vo.R;
|
import com.cnbm.common.vo.R;
|
||||||
|
import com.cnbm.influx.config.InfluxClient;
|
||||||
import com.cnbm.influx.constant.Constant;
|
import com.cnbm.influx.constant.Constant;
|
||||||
import com.cnbm.influx.param.QueryDataGroupByTimeParam;
|
import com.cnbm.influx.param.QueryDataGroupByTimeParam;
|
||||||
import com.cnbm.influx.param.QueryDataParam;
|
import com.cnbm.influx.param.QueryDataParam;
|
||||||
import com.cnbm.influx.param.Range;
|
import com.cnbm.influx.param.Range;
|
||||||
|
import com.cnbm.influx.param.Tag;
|
||||||
|
import com.cnbm.influx.template.Event;
|
||||||
import com.cnbm.processInspection.dto.*;
|
import com.cnbm.processInspection.dto.*;
|
||||||
import com.cnbm.processInspection.graphAnalyzed.forCount.c.CGraph;
|
import com.cnbm.processInspection.graphAnalyzed.forCount.c.CGraph;
|
||||||
import com.cnbm.processInspection.graphAnalyzed.forCount.np.NPGraph;
|
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.mr.MeanRGraph;
|
||||||
import com.cnbm.processInspection.graphAnalyzed.forMeterage.ms.MeanStandardDeviationGraph;
|
import com.cnbm.processInspection.graphAnalyzed.forMeterage.ms.MeanStandardDeviationGraph;
|
||||||
import com.cnbm.processInspection.graphAnalyzed.forMeterage.xmr.XMRGraph;
|
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.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
@ -30,6 +36,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/processInspection")
|
@RequestMapping("/processInspection")
|
||||||
@ -42,9 +49,9 @@ public class ProcessInspectionController {
|
|||||||
@PostMapping("/XbarSGraphTest")
|
@PostMapping("/XbarSGraphTest")
|
||||||
public R<XbarSGraphData> xbarSGraphTest() throws Exception {
|
public R<XbarSGraphData> xbarSGraphTest() throws Exception {
|
||||||
ProductFeatures productFeatures = new ProductFeatures();
|
ProductFeatures productFeatures = new ProductFeatures();
|
||||||
productFeatures.setSl(new Float(5));
|
productFeatures.setSl(new Float(65));
|
||||||
productFeatures.setUsl(new Float(10));
|
productFeatures.setUsl(new Float(66));
|
||||||
productFeatures.setLsl(new Float(1));
|
productFeatures.setLsl(new Float(69));
|
||||||
|
|
||||||
productFeatures.setName("LTWeight");
|
productFeatures.setName("LTWeight");
|
||||||
productFeatures.setSampleSize(10);
|
productFeatures.setSampleSize(10);
|
||||||
@ -58,16 +65,16 @@ public class ProcessInspectionController {
|
|||||||
|
|
||||||
QueryDataParam queryDataParam = new QueryDataParam();
|
QueryDataParam queryDataParam = new QueryDataParam();
|
||||||
queryDataParam.setMeasurement(Constant.measurement);
|
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);
|
meanStandardDeviationGraph.initialDate(queryDataParam);
|
||||||
|
|
||||||
XbarSGraphData xbarSGraphData = new XbarSGraphData(
|
XbarSGraphData xbarSGraphData = new XbarSGraphData(
|
||||||
meanStandardDeviationGraph.getMsdGraphEntity(),
|
meanStandardDeviationGraph.getMsdGraphEntity()==null?null:meanStandardDeviationGraph.getMsdGraphEntity(),
|
||||||
meanStandardDeviationGraph.getXbarCL(),
|
meanStandardDeviationGraph.getXbarCL()==null?null:new ControlLimitDetail(meanStandardDeviationGraph.getXbarCL().getUCL(), meanStandardDeviationGraph.getXbarCL().getCL(), meanStandardDeviationGraph.getXbarCL().getLCL()),
|
||||||
meanStandardDeviationGraph.getSCL(),
|
meanStandardDeviationGraph.getSCL()==null?null:new ControlLimitDetail(meanStandardDeviationGraph.getSCL().getUCL(), meanStandardDeviationGraph.getSCL().getCL(), meanStandardDeviationGraph.getSCL().getLCL()),
|
||||||
meanStandardDeviationGraph.getSpecificationLimit(),
|
meanStandardDeviationGraph.getSpecificationLimit()==null?null:meanStandardDeviationGraph.getSpecificationLimit(),
|
||||||
meanStandardDeviationGraph.getProcessCapacity(),
|
meanStandardDeviationGraph.getProcessCapacity()==null?null:meanStandardDeviationGraph.getProcessCapacity(),
|
||||||
new StandardDiviation(meanStandardDeviationGraph.getXigma(),meanStandardDeviationGraph.getTotalXigma())
|
(meanStandardDeviationGraph.getXigma()==null||meanStandardDeviationGraph.getTotalXigma()==null)?null:new StandardDiviation(meanStandardDeviationGraph.getXigma(),meanStandardDeviationGraph.getTotalXigma())
|
||||||
);
|
);
|
||||||
|
|
||||||
return R.ok("成功",xbarSGraphData);
|
return R.ok("成功",xbarSGraphData);
|
||||||
@ -75,10 +82,11 @@ public class ProcessInspectionController {
|
|||||||
|
|
||||||
@PostMapping("/XbarRGraphTest")
|
@PostMapping("/XbarRGraphTest")
|
||||||
public R<XbarRGraphData> XbarRGraphTest() throws Exception {
|
public R<XbarRGraphData> XbarRGraphTest() throws Exception {
|
||||||
|
//todo SL/USL/LSL 和 sampleSize 需要从外面传过来。
|
||||||
ProductFeatures productFeatures = new ProductFeatures();
|
ProductFeatures productFeatures = new ProductFeatures();
|
||||||
productFeatures.setSl(new Float(5));
|
productFeatures.setSl(new Float(65));
|
||||||
productFeatures.setUsl(new Float(10));
|
productFeatures.setUsl(new Float(66));
|
||||||
productFeatures.setLsl(new Float(1));
|
productFeatures.setLsl(new Float(69));
|
||||||
|
|
||||||
productFeatures.setName("LTWeight");
|
productFeatures.setName("LTWeight");
|
||||||
productFeatures.setSampleSize(10);
|
productFeatures.setSampleSize(10);
|
||||||
@ -92,16 +100,18 @@ public class ProcessInspectionController {
|
|||||||
|
|
||||||
QueryDataParam queryDataParam = new QueryDataParam();
|
QueryDataParam queryDataParam = new QueryDataParam();
|
||||||
queryDataParam.setMeasurement(Constant.measurement);
|
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);
|
meanRGraph.initialDate(queryDataParam);
|
||||||
|
|
||||||
XbarRGraphData xbarSGraphData = new XbarRGraphData(
|
XbarRGraphData xbarSGraphData = new XbarRGraphData(
|
||||||
meanRGraph.getMrGraphEntity(),
|
meanRGraph.getMrGraphEntity()==null?null:meanRGraph.getMrGraphEntity(),
|
||||||
meanRGraph.getXbarCL(),
|
|
||||||
meanRGraph.getRCL(),
|
meanRGraph.getXbarCL()==null?null:new ControlLimitDetail(meanRGraph.getXbarCL().getUCL(), meanRGraph.getXbarCL().getCL(), meanRGraph.getXbarCL().getLCL()),
|
||||||
meanRGraph.getSpecificationLimit(),
|
meanRGraph.getRCL()==null?null:new ControlLimitDetail(meanRGraph.getRCL().getUCL(), meanRGraph.getRCL().getCL(), meanRGraph.getRCL().getLCL()),
|
||||||
meanRGraph.getProcessCapacity(),
|
|
||||||
new StandardDiviation(meanRGraph.getXigma(),meanRGraph.getTotalXigma())
|
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);
|
return R.ok("成功",xbarSGraphData);
|
||||||
@ -109,9 +119,9 @@ public class ProcessInspectionController {
|
|||||||
@PostMapping("/XMRGraphTest")
|
@PostMapping("/XMRGraphTest")
|
||||||
public R<XMRGraphData> XMRGraphTest() throws Exception {
|
public R<XMRGraphData> XMRGraphTest() throws Exception {
|
||||||
ProductFeatures productFeatures = new ProductFeatures();
|
ProductFeatures productFeatures = new ProductFeatures();
|
||||||
productFeatures.setSl(new Float(5));
|
productFeatures.setSl(new Float(65));
|
||||||
productFeatures.setUsl(new Float(10));
|
productFeatures.setUsl(new Float(66));
|
||||||
productFeatures.setLsl(new Float(1));
|
productFeatures.setLsl(new Float(69));
|
||||||
|
|
||||||
productFeatures.setName("LTWeight");
|
productFeatures.setName("LTWeight");
|
||||||
productFeatures.setSampleSize(1);
|
productFeatures.setSampleSize(1);
|
||||||
@ -125,41 +135,81 @@ public class ProcessInspectionController {
|
|||||||
|
|
||||||
QueryDataParam queryDataParam = new QueryDataParam();
|
QueryDataParam queryDataParam = new QueryDataParam();
|
||||||
queryDataParam.setMeasurement(Constant.measurement);
|
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);
|
xmrGraph.initialDate(queryDataParam);
|
||||||
|
|
||||||
XMRGraphData xmrGraphData = new XMRGraphData(
|
XMRGraphData xmrGraphData = new XMRGraphData(
|
||||||
xmrGraph.getXmrGraphEntity(),
|
xmrGraph.getXmrGraphEntity()==null?null:xmrGraph.getXmrGraphEntity(),
|
||||||
xmrGraph.getXCL(),
|
xmrGraph.getXCL()==null?null:new ControlLimitDetail(xmrGraph.getXCL().getUCL(), xmrGraph.getXCL().getCL(), xmrGraph.getXCL().getLCL()),
|
||||||
xmrGraph.getRSCL(),
|
xmrGraph.getRSCL()==null?null:new ControlLimitDetail(xmrGraph.getRSCL().getUCL(), xmrGraph.getRSCL().getCL(), xmrGraph.getRSCL().getLCL()),
|
||||||
xmrGraph.getSpecificationLimit(),
|
xmrGraph.getSpecificationLimit()==null?null:xmrGraph.getSpecificationLimit(),
|
||||||
xmrGraph.getProcessCapacity(),
|
xmrGraph.getProcessCapacity()==null?null:xmrGraph.getProcessCapacity(),
|
||||||
new StandardDiviation(xmrGraph.getXigma(),xmrGraph.getTotalXigma())
|
(xmrGraph.getXigma()==null||xmrGraph.getTotalXigma()==null)?null:new StandardDiviation(xmrGraph.getXigma(),xmrGraph.getTotalXigma())
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return R.ok("成功",xmrGraphData);
|
return R.ok("成功",xmrGraphData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/getBatchs")
|
||||||
|
public R<List<String>> getBatchs() throws InterruptedException {
|
||||||
|
List<Event> list = new ArrayList<>();
|
||||||
|
Random r = new Random();
|
||||||
|
Instant instant = DataUtils.getBeforeDate(400).toInstant();
|
||||||
|
List<String> res = new ArrayList<>();
|
||||||
|
|
||||||
|
QueryDataParam queryDataParam = new QueryDataParam();
|
||||||
|
queryDataParam.setBucket("qgs-bucket");
|
||||||
|
queryDataParam.setMeasurement("Weight");
|
||||||
|
List<String> dropNames = new ArrayList<>();
|
||||||
|
dropNames.add("transationId");
|
||||||
|
dropNames.add("_value");
|
||||||
|
dropNames.add("_start");
|
||||||
|
dropNames.add("_stop");
|
||||||
|
dropNames.add("_time");
|
||||||
|
dropNames.add("_field");
|
||||||
|
dropNames.add("_measurement");
|
||||||
|
dropNames.add("inspectionSheetId");
|
||||||
|
dropNames.add("argName");
|
||||||
|
queryDataParam.setDropedTagNames(dropNames);
|
||||||
|
queryDataParam.setTag(new Tag("argName","LTWeight"));
|
||||||
|
queryDataParam.setRange(new Range(DataUtils.getBeforeDate(100).toInstant(),Instant.now()));
|
||||||
|
// queryDataParam.setPageInfo(new PageInfo(1,10));
|
||||||
|
List<FluxTable> query = InfluxClient.Client.queryByGroup(queryDataParam);
|
||||||
|
|
||||||
|
|
||||||
|
for (FluxTable fluxTable : query) {
|
||||||
|
List<FluxRecord> records = fluxTable.getRecords();
|
||||||
|
if(records.size()!=0){
|
||||||
|
res.add((String) records.get(0).getValueByKey("batchNum"));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return R.ok(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/NPGraphTest")
|
@PostMapping("/NPGraphTest")
|
||||||
public R<NPGraphData> NPGraphTest() throws Exception {
|
public R<NPGraphData> NPGraphTest() throws Exception {
|
||||||
ProductFeatures productFeatures = new ProductFeatures();
|
ProductFeatures productFeatures = new ProductFeatures();
|
||||||
productFeatures.setSl(new Float(5));
|
productFeatures.setSl(new Float(65));
|
||||||
productFeatures.setUsl(new Float(10));
|
productFeatures.setUsl(new Float(66));
|
||||||
productFeatures.setLsl(new Float(1));
|
productFeatures.setLsl(new Float(69));
|
||||||
|
|
||||||
productFeatures.setName("LostDays");
|
productFeatures.setName("failDay");
|
||||||
NPGraph npGraph = new NPGraph(productFeatures);
|
NPGraph npGraph = new NPGraph(productFeatures);
|
||||||
|
|
||||||
|
|
||||||
QueryDataGroupByTimeParam queryDataParam = new QueryDataGroupByTimeParam();
|
QueryDataGroupByTimeParam queryDataParam = new QueryDataGroupByTimeParam();
|
||||||
queryDataParam.setMeasurement(Constant.measurement);
|
queryDataParam.setMeasurement(Constant.measurement);
|
||||||
queryDataParam.setRange(new Range( Instant.now() , DataUtils.getAfterDate(999).toInstant() ));
|
queryDataParam.setRange(new Range(DataUtils.getBeforeDate(9999).toInstant(), DataUtils.getAfterDate(9999).toInstant() ));
|
||||||
queryDataParam.setTimeType(1);
|
queryDataParam.setTimeType(2);
|
||||||
npGraph.initialDate(queryDataParam);
|
npGraph.initialDate(queryDataParam);
|
||||||
|
|
||||||
NPGraphData npGraph1 = new NPGraphData(
|
NPGraphData npGraph1 = new NPGraphData(
|
||||||
npGraph.getList(),
|
npGraph.getList()==null?null:npGraph.getList(),
|
||||||
npGraph.getSpecificationLimit(),
|
npGraph.getSpecificationLimit()==null?null:npGraph.getSpecificationLimit(),
|
||||||
npGraph.getArgName()
|
npGraph.getArgName()==null?null:npGraph.getArgName()
|
||||||
);
|
);
|
||||||
|
|
||||||
return R.ok("成功",npGraph1);
|
return R.ok("成功",npGraph1);
|
||||||
@ -167,24 +217,24 @@ public class ProcessInspectionController {
|
|||||||
@PostMapping("/PGraphTest")
|
@PostMapping("/PGraphTest")
|
||||||
public R<PGraphData> PGraphTest() throws Exception {
|
public R<PGraphData> PGraphTest() throws Exception {
|
||||||
ProductFeatures productFeatures = new ProductFeatures();
|
ProductFeatures productFeatures = new ProductFeatures();
|
||||||
productFeatures.setSl(new Float(5));
|
productFeatures.setSl(new Float(65));
|
||||||
productFeatures.setUsl(new Float(10));
|
productFeatures.setUsl(new Float(66));
|
||||||
productFeatures.setLsl(new Float(1));
|
productFeatures.setLsl(new Float(69));
|
||||||
|
|
||||||
productFeatures.setName("LostDays");
|
productFeatures.setName("LTWeight");
|
||||||
PGraph pGraph = new PGraph(productFeatures);
|
PGraph pGraph = new PGraph(productFeatures);
|
||||||
|
|
||||||
|
|
||||||
QueryDataGroupByTimeParam queryDataParam = new QueryDataGroupByTimeParam();
|
QueryDataGroupByTimeParam queryDataParam = new QueryDataGroupByTimeParam();
|
||||||
queryDataParam.setMeasurement(Constant.measurement);
|
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);
|
queryDataParam.setTimeType(2);
|
||||||
pGraph.initialDate(queryDataParam);
|
pGraph.initialDate(queryDataParam);
|
||||||
|
|
||||||
PGraphData npGraph1 = new PGraphData(
|
PGraphData npGraph1 = new PGraphData(
|
||||||
pGraph.getList(),
|
pGraph.getList()==null?null:pGraph.getList(),
|
||||||
pGraph.getSpecificationLimit(),
|
pGraph.getSpecificationLimit()==null?null:pGraph.getSpecificationLimit(),
|
||||||
pGraph.getArgName()
|
pGraph.getArgName()==null?null:pGraph.getArgName()
|
||||||
);
|
);
|
||||||
|
|
||||||
return R.ok("成功",npGraph1);
|
return R.ok("成功",npGraph1);
|
||||||
@ -192,24 +242,26 @@ public class ProcessInspectionController {
|
|||||||
@PostMapping("/CGraphTest")
|
@PostMapping("/CGraphTest")
|
||||||
public R<CGraphData> CGraphTest() throws Exception {
|
public R<CGraphData> CGraphTest() throws Exception {
|
||||||
ProductFeatures productFeatures = new ProductFeatures();
|
ProductFeatures productFeatures = new ProductFeatures();
|
||||||
productFeatures.setSl(new Float(5));
|
productFeatures.setSl(new Float(65));
|
||||||
productFeatures.setUsl(new Float(10));
|
productFeatures.setUsl(new Float(66));
|
||||||
productFeatures.setLsl(new Float(1));
|
productFeatures.setLsl(new Float(69));
|
||||||
|
|
||||||
productFeatures.setName("LostDays");
|
productFeatures.setName("LTWeight");
|
||||||
CGraph cGraph = new CGraph(productFeatures);
|
CGraph cGraph = new CGraph(productFeatures);
|
||||||
|
|
||||||
|
|
||||||
QueryDataGroupByTimeParam queryDataParam = new QueryDataGroupByTimeParam();
|
QueryDataGroupByTimeParam queryDataParam = new QueryDataGroupByTimeParam();
|
||||||
|
//到时候 要看前端 传的,这里的measurement 其实就是 设备名。
|
||||||
queryDataParam.setMeasurement(Constant.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);
|
queryDataParam.setTimeType(2);
|
||||||
cGraph.initialDate(queryDataParam);
|
cGraph.initialDate(queryDataParam);
|
||||||
|
|
||||||
CGraphData npGraph1 = new CGraphData(
|
CGraphData npGraph1 = new CGraphData(
|
||||||
cGraph.getList(),
|
cGraph.getList()==null?null:cGraph.getList(),
|
||||||
cGraph.getSpecificationLimit(),
|
cGraph.getSpecificationLimit()==null?null:cGraph.getSpecificationLimit(),
|
||||||
cGraph.getArgName()
|
cGraph.getArgName()==null?null:cGraph.getArgName()
|
||||||
);
|
);
|
||||||
|
|
||||||
return R.ok("成功",npGraph1);
|
return R.ok("成功",npGraph1);
|
||||||
@ -218,24 +270,24 @@ public class ProcessInspectionController {
|
|||||||
@PostMapping("/UGraphTest")
|
@PostMapping("/UGraphTest")
|
||||||
public R<UGraphData> UGraphTest() throws Exception {
|
public R<UGraphData> UGraphTest() throws Exception {
|
||||||
ProductFeatures productFeatures = new ProductFeatures();
|
ProductFeatures productFeatures = new ProductFeatures();
|
||||||
productFeatures.setSl(new Float(5));
|
productFeatures.setSl(new Float(65));
|
||||||
productFeatures.setUsl(new Float(10));
|
productFeatures.setUsl(new Float(66));
|
||||||
productFeatures.setLsl(new Float(1));
|
productFeatures.setLsl(new Float(69));
|
||||||
|
|
||||||
productFeatures.setName("LostDays");
|
productFeatures.setName("LTWeight");
|
||||||
UGraph uGraph = new UGraph(productFeatures);
|
UGraph uGraph = new UGraph(productFeatures);
|
||||||
|
|
||||||
|
|
||||||
QueryDataGroupByTimeParam queryDataParam = new QueryDataGroupByTimeParam();
|
QueryDataGroupByTimeParam queryDataParam = new QueryDataGroupByTimeParam();
|
||||||
queryDataParam.setMeasurement(Constant.measurement);
|
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);
|
queryDataParam.setTimeType(2);
|
||||||
uGraph.initialDate(queryDataParam);
|
uGraph.initialDate(queryDataParam);
|
||||||
|
|
||||||
UGraphData npGraph1 = new UGraphData(
|
UGraphData npGraph1 = new UGraphData(
|
||||||
uGraph.getList(),
|
uGraph.getList()==null?null:uGraph.getList(),
|
||||||
uGraph.getSpecificationLimit(),
|
uGraph.getSpecificationLimit()==null?null:uGraph.getSpecificationLimit(),
|
||||||
uGraph.getArgName()
|
uGraph.getArgName()==null?null:uGraph.getArgName()
|
||||||
);
|
);
|
||||||
|
|
||||||
return R.ok("成功",npGraph1);
|
return R.ok("成功",npGraph1);
|
||||||
@ -273,12 +325,12 @@ public class ProcessInspectionController {
|
|||||||
meanStandardDeviationGraph.initialDate(queryDataParam);
|
meanStandardDeviationGraph.initialDate(queryDataParam);
|
||||||
|
|
||||||
XbarSGraphData xbarSGraphData = new XbarSGraphData(
|
XbarSGraphData xbarSGraphData = new XbarSGraphData(
|
||||||
meanStandardDeviationGraph.getMsdGraphEntity(),
|
meanStandardDeviationGraph.getMsdGraphEntity()==null?null:meanStandardDeviationGraph.getMsdGraphEntity(),
|
||||||
meanStandardDeviationGraph.getXbarCL(),
|
meanStandardDeviationGraph.getXbarCL()==null?null:new ControlLimitDetail(meanStandardDeviationGraph.getXbarCL().getUCL(), meanStandardDeviationGraph.getXbarCL().getCL(), meanStandardDeviationGraph.getXbarCL().getLCL()),
|
||||||
meanStandardDeviationGraph.getSCL(),
|
meanStandardDeviationGraph.getSCL()==null?null:new ControlLimitDetail(meanStandardDeviationGraph.getSCL().getUCL(), meanStandardDeviationGraph.getSCL().getCL(), meanStandardDeviationGraph.getSCL().getLCL()),
|
||||||
meanStandardDeviationGraph.getSpecificationLimit(),
|
meanStandardDeviationGraph.getSpecificationLimit()==null?null:meanStandardDeviationGraph.getSpecificationLimit(),
|
||||||
meanStandardDeviationGraph.getProcessCapacity(),
|
meanStandardDeviationGraph.getProcessCapacity()==null?null:meanStandardDeviationGraph.getProcessCapacity(),
|
||||||
new StandardDiviation(meanStandardDeviationGraph.getXigma(),meanStandardDeviationGraph.getTotalXigma())
|
(meanStandardDeviationGraph.getXigma()==null||meanStandardDeviationGraph.getTotalXigma()==null)?null:new StandardDiviation(meanStandardDeviationGraph.getXigma(),meanStandardDeviationGraph.getTotalXigma())
|
||||||
);
|
);
|
||||||
|
|
||||||
return R.ok("成功",xbarSGraphData);
|
return R.ok("成功",xbarSGraphData);
|
||||||
@ -300,13 +352,18 @@ public class ProcessInspectionController {
|
|||||||
queryDataParam.setRange(new Range(graphArg.getBegin().toInstant(), graphArg.getEnd().toInstant()));
|
queryDataParam.setRange(new Range(graphArg.getBegin().toInstant(), graphArg.getEnd().toInstant()));
|
||||||
meanRGraph.initialDate(queryDataParam);
|
meanRGraph.initialDate(queryDataParam);
|
||||||
|
|
||||||
|
|
||||||
XbarRGraphData xbarSGraphData = new XbarRGraphData(
|
XbarRGraphData xbarSGraphData = new XbarRGraphData(
|
||||||
meanRGraph.getMrGraphEntity(),
|
meanRGraph.getMrGraphEntity()==null?null:meanRGraph.getMrGraphEntity(),
|
||||||
meanRGraph.getXbarCL(),
|
|
||||||
meanRGraph.getRCL(),
|
meanRGraph.getXbarCL()==null?null:new ControlLimitDetail(meanRGraph.getXbarCL().getUCL(), meanRGraph.getXbarCL().getCL(), meanRGraph.getXbarCL().getLCL()),
|
||||||
meanRGraph.getSpecificationLimit(),
|
meanRGraph.getRCL()==null?null:new ControlLimitDetail(meanRGraph.getRCL().getUCL(), meanRGraph.getRCL().getCL(), meanRGraph.getRCL().getLCL()),
|
||||||
meanRGraph.getProcessCapacity(),
|
|
||||||
new StandardDiviation(meanRGraph.getXigma(),meanRGraph.getTotalXigma())
|
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);
|
return R.ok("成功",xbarSGraphData);
|
||||||
@ -329,12 +386,13 @@ public class ProcessInspectionController {
|
|||||||
xmrGraph.initialDate(queryDataParam);
|
xmrGraph.initialDate(queryDataParam);
|
||||||
|
|
||||||
XMRGraphData xmrGraphData = new XMRGraphData(
|
XMRGraphData xmrGraphData = new XMRGraphData(
|
||||||
xmrGraph.getXmrGraphEntity(),
|
xmrGraph.getXmrGraphEntity()==null?null:xmrGraph.getXmrGraphEntity(),
|
||||||
xmrGraph.getXCL(),
|
xmrGraph.getXCL()==null?null:new ControlLimitDetail(xmrGraph.getXCL().getUCL(), xmrGraph.getXCL().getCL(), xmrGraph.getXCL().getLCL()),
|
||||||
xmrGraph.getRSCL(),
|
xmrGraph.getRSCL()==null?null:new ControlLimitDetail(xmrGraph.getRSCL().getUCL(), xmrGraph.getRSCL().getCL(), xmrGraph.getRSCL().getLCL()),
|
||||||
xmrGraph.getSpecificationLimit(),
|
xmrGraph.getSpecificationLimit()==null?null:xmrGraph.getSpecificationLimit(),
|
||||||
xmrGraph.getProcessCapacity(),
|
xmrGraph.getProcessCapacity()==null?null:xmrGraph.getProcessCapacity(),
|
||||||
new StandardDiviation(xmrGraph.getXigma(),xmrGraph.getTotalXigma())
|
(xmrGraph.getXigma()==null||xmrGraph.getTotalXigma()==null)?null:new StandardDiviation(xmrGraph.getXigma(),xmrGraph.getTotalXigma())
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return R.ok("成功",xmrGraphData);
|
return R.ok("成功",xmrGraphData);
|
||||||
@ -354,9 +412,9 @@ public class ProcessInspectionController {
|
|||||||
npGraph.initialDate(queryDataParam);
|
npGraph.initialDate(queryDataParam);
|
||||||
|
|
||||||
NPGraphData npGraph1 = new NPGraphData(
|
NPGraphData npGraph1 = new NPGraphData(
|
||||||
npGraph.getList(),
|
npGraph.getList()==null?null:npGraph.getList(),
|
||||||
npGraph.getSpecificationLimit(),
|
npGraph.getSpecificationLimit()==null?null:npGraph.getSpecificationLimit(),
|
||||||
npGraph.getArgName()
|
npGraph.getArgName()==null?null:npGraph.getArgName()
|
||||||
);
|
);
|
||||||
return R.ok("成功",npGraph1);
|
return R.ok("成功",npGraph1);
|
||||||
}
|
}
|
||||||
@ -375,9 +433,9 @@ public class ProcessInspectionController {
|
|||||||
pGraph.initialDate(queryDataParam);
|
pGraph.initialDate(queryDataParam);
|
||||||
|
|
||||||
PGraphData npGraph1 = new PGraphData(
|
PGraphData npGraph1 = new PGraphData(
|
||||||
pGraph.getList(),
|
pGraph.getList()==null?null:pGraph.getList(),
|
||||||
pGraph.getSpecificationLimit(),
|
pGraph.getSpecificationLimit()==null?null:pGraph.getSpecificationLimit(),
|
||||||
pGraph.getArgName()
|
pGraph.getArgName()==null?null:pGraph.getArgName()
|
||||||
);
|
);
|
||||||
return R.ok("成功",npGraph1);
|
return R.ok("成功",npGraph1);
|
||||||
}
|
}
|
||||||
@ -395,9 +453,9 @@ public class ProcessInspectionController {
|
|||||||
cGraph.initialDate(queryDataParam);
|
cGraph.initialDate(queryDataParam);
|
||||||
|
|
||||||
CGraphData npGraph1 = new CGraphData(
|
CGraphData npGraph1 = new CGraphData(
|
||||||
cGraph.getList(),
|
cGraph.getList()==null?null:cGraph.getList(),
|
||||||
cGraph.getSpecificationLimit(),
|
cGraph.getSpecificationLimit()==null?null:cGraph.getSpecificationLimit(),
|
||||||
cGraph.getArgName()
|
cGraph.getArgName()==null?null:cGraph.getArgName()
|
||||||
);
|
);
|
||||||
return R.ok("成功",npGraph1);
|
return R.ok("成功",npGraph1);
|
||||||
}
|
}
|
||||||
@ -416,9 +474,9 @@ public class ProcessInspectionController {
|
|||||||
uGraph.initialDate(queryDataParam);
|
uGraph.initialDate(queryDataParam);
|
||||||
|
|
||||||
UGraphData uGraphData = new UGraphData(
|
UGraphData uGraphData = new UGraphData(
|
||||||
uGraph.getList(),
|
uGraph.getList()==null?null:uGraph.getList(),
|
||||||
uGraph.getSpecificationLimit(),
|
uGraph.getSpecificationLimit()==null?null:uGraph.getSpecificationLimit(),
|
||||||
uGraph.getArgName()
|
uGraph.getArgName()==null?null:uGraph.getArgName()
|
||||||
);
|
);
|
||||||
return R.ok("成功",uGraphData);
|
return R.ok("成功",uGraphData);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.cnbm.processInspection.dto;
|
|||||||
import com.cnbm.common.spc.math.StandardDiviation;
|
import com.cnbm.common.spc.math.StandardDiviation;
|
||||||
import com.cnbm.processInspection.graphAnalyzed.forMeterage.xmr.XMRGraphEntity;
|
import com.cnbm.processInspection.graphAnalyzed.forMeterage.xmr.XMRGraphEntity;
|
||||||
import com.cnbm.qualityPlanning.entity.ControlLimit;
|
import com.cnbm.qualityPlanning.entity.ControlLimit;
|
||||||
|
import com.cnbm.qualityPlanning.entity.ControlLimitDetail;
|
||||||
import com.cnbm.qualityPlanning.entity.ProcessCapability;
|
import com.cnbm.qualityPlanning.entity.ProcessCapability;
|
||||||
import com.cnbm.qualityPlanning.entity.SpecificationLimit;
|
import com.cnbm.qualityPlanning.entity.SpecificationLimit;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
@ -15,14 +16,14 @@ import lombok.Data;
|
|||||||
* @DATE: 2022/7/22 14:18
|
* @DATE: 2022/7/22 14:18
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@ApiModel(value = "均值极差控制图 结果类")
|
@ApiModel(value = "单值-移动极差 结果类")
|
||||||
public class XMRGraphData {
|
public class XMRGraphData {
|
||||||
@ApiModelProperty(value = "控制图list数据")
|
@ApiModelProperty(value = "控制图list数据")
|
||||||
private XMRGraphEntity xmrGraphEntity;
|
private XMRGraphEntity xmrGraphEntity;
|
||||||
@ApiModelProperty(value = "xbar控制图 控制限")
|
@ApiModelProperty(value = "xbar控制图 控制限")
|
||||||
private ControlLimit XBarCL;
|
private ControlLimitDetail XBarCL;
|
||||||
@ApiModelProperty(value = "R控制图 控制限")
|
@ApiModelProperty(value = "R控制图 控制限")
|
||||||
private ControlLimit RCL;
|
private ControlLimitDetail RCL;
|
||||||
|
|
||||||
@ApiModelProperty(value = "工艺规格限")
|
@ApiModelProperty(value = "工艺规格限")
|
||||||
private SpecificationLimit SL;
|
private SpecificationLimit SL;
|
||||||
@ -34,7 +35,7 @@ public class XMRGraphData {
|
|||||||
private StandardDiviation standardDiviation;
|
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.xmrGraphEntity = xmrGraphEntity;
|
||||||
this.XBarCL = xBarCL;
|
this.XBarCL = xBarCL;
|
||||||
this.RCL = rCL;
|
this.RCL = rCL;
|
||||||
|
@ -2,27 +2,31 @@ package com.cnbm.processInspection.dto;
|
|||||||
|
|
||||||
import com.cnbm.common.spc.math.StandardDiviation;
|
import com.cnbm.common.spc.math.StandardDiviation;
|
||||||
import com.cnbm.processInspection.graphAnalyzed.forMeterage.mr.MRGraphEntity;
|
import com.cnbm.processInspection.graphAnalyzed.forMeterage.mr.MRGraphEntity;
|
||||||
import com.cnbm.qualityPlanning.entity.ControlLimit;
|
import com.cnbm.qualityPlanning.entity.*;
|
||||||
import com.cnbm.qualityPlanning.entity.ProcessCapability;
|
|
||||||
import com.cnbm.qualityPlanning.entity.SpecificationLimit;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Stack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Desc: ""
|
* @Desc: ""
|
||||||
* @Author: caixiang
|
* @Author: caixiang
|
||||||
* @DATE: 2022/7/22 14:18
|
* @DATE: 2022/7/22 14:18
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@ApiModel(value = "均值极差控制图 结果类")
|
@ApiModel(value = "均值-极差控制图 结果类")
|
||||||
public class XbarRGraphData {
|
public class XbarRGraphData {
|
||||||
@ApiModelProperty(value = "控制图list数据")
|
@ApiModelProperty(value = "控制图list数据")
|
||||||
private MRGraphEntity mrGraphEntity;
|
private MRGraphEntity mrGraphEntity;
|
||||||
@ApiModelProperty(value = "xbar控制图 控制限")
|
@ApiModelProperty(value = "xbar控制图 控制限")
|
||||||
private ControlLimit XBarCL;
|
private ControlLimitDetail XBarCL;
|
||||||
|
|
||||||
@ApiModelProperty(value = "R控制图 控制限")
|
@ApiModelProperty(value = "R控制图 控制限")
|
||||||
private ControlLimit RCL;
|
private ControlLimitDetail RCL;
|
||||||
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "工艺规格限")
|
@ApiModelProperty(value = "工艺规格限")
|
||||||
private SpecificationLimit SL;
|
private SpecificationLimit SL;
|
||||||
@ -34,12 +38,14 @@ public class XbarRGraphData {
|
|||||||
private StandardDiviation standardDiviation;
|
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.mrGraphEntity = mrGraphEntity;
|
||||||
this.XBarCL = xBarCL;
|
this.XBarCL = xBarCLDetail;
|
||||||
this.RCL = rCL;
|
this.RCL = rCLDetail;
|
||||||
this.SL = sl;
|
this.SL = sl;
|
||||||
this.processCapability = processCapability;
|
this.processCapability = processCapability;
|
||||||
this.standardDiviation = standardDiviation;
|
this.standardDiviation = standardDiviation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.cnbm.processInspection.dto;
|
|||||||
import com.cnbm.common.spc.math.StandardDiviation;
|
import com.cnbm.common.spc.math.StandardDiviation;
|
||||||
import com.cnbm.processInspection.graphAnalyzed.forMeterage.ms.MSDGraphEntity;
|
import com.cnbm.processInspection.graphAnalyzed.forMeterage.ms.MSDGraphEntity;
|
||||||
import com.cnbm.qualityPlanning.entity.ControlLimit;
|
import com.cnbm.qualityPlanning.entity.ControlLimit;
|
||||||
|
import com.cnbm.qualityPlanning.entity.ControlLimitDetail;
|
||||||
import com.cnbm.qualityPlanning.entity.ProcessCapability;
|
import com.cnbm.qualityPlanning.entity.ProcessCapability;
|
||||||
import com.cnbm.qualityPlanning.entity.SpecificationLimit;
|
import com.cnbm.qualityPlanning.entity.SpecificationLimit;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
@ -15,14 +16,14 @@ import lombok.Data;
|
|||||||
* @DATE: 2022/7/22 14:18
|
* @DATE: 2022/7/22 14:18
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@ApiModel(value = "均值标准差控制图 结果类")
|
@ApiModel(value = "均值-标准差控制图 结果类")
|
||||||
public class XbarSGraphData {
|
public class XbarSGraphData {
|
||||||
@ApiModelProperty(value = "控制图list数据")
|
@ApiModelProperty(value = "控制图list数据")
|
||||||
private MSDGraphEntity msdGraphEntity;
|
private MSDGraphEntity msdGraphEntity;
|
||||||
@ApiModelProperty(value = "xbar控制图 控制限")
|
@ApiModelProperty(value = "xbar控制图 控制限")
|
||||||
private ControlLimit XBarCL;
|
private ControlLimitDetail XBarCL;
|
||||||
@ApiModelProperty(value = "s控制图 控制限")
|
@ApiModelProperty(value = "s控制图 控制限")
|
||||||
private ControlLimit SCL;
|
private ControlLimitDetail SCL;
|
||||||
|
|
||||||
@ApiModelProperty(value = "工艺规格限")
|
@ApiModelProperty(value = "工艺规格限")
|
||||||
private SpecificationLimit SL;
|
private SpecificationLimit SL;
|
||||||
@ -34,7 +35,7 @@ public class XbarSGraphData {
|
|||||||
private StandardDiviation standardDiviation;
|
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.msdGraphEntity = msdGraphEntity;
|
||||||
this.XBarCL = xBarCL;
|
this.XBarCL = xBarCL;
|
||||||
this.SCL = sCL;
|
this.SCL = sCL;
|
||||||
|
@ -8,7 +8,6 @@ import com.cnbm.influx.param.QueryDataGroupByTimeParam;
|
|||||||
import com.cnbm.influx.param.Tag;
|
import com.cnbm.influx.param.Tag;
|
||||||
import com.cnbm.qualityPlanning.entity.CPoint;
|
import com.cnbm.qualityPlanning.entity.CPoint;
|
||||||
import com.cnbm.qualityPlanning.entity.ControlLimit;
|
import com.cnbm.qualityPlanning.entity.ControlLimit;
|
||||||
import com.cnbm.qualityPlanning.entity.PPoint;
|
|
||||||
import com.cnbm.qualityPlanning.entity.SpecificationLimit;
|
import com.cnbm.qualityPlanning.entity.SpecificationLimit;
|
||||||
import com.influxdb.query.FluxRecord;
|
import com.influxdb.query.FluxRecord;
|
||||||
import com.influxdb.query.FluxTable;
|
import com.influxdb.query.FluxTable;
|
||||||
|
@ -1,22 +1,15 @@
|
|||||||
package com.cnbm.processInspection.graphAnalyzed.forCount.np;
|
package com.cnbm.processInspection.graphAnalyzed.forCount.np;
|
||||||
|
|
||||||
import com.cnbm.basic.entity.ProductFeatures;
|
import com.cnbm.basic.entity.ProductFeatures;
|
||||||
import com.cnbm.common.spc.math.StandardDiviation;
|
|
||||||
import com.cnbm.common.spc.util.DataUtils;
|
import com.cnbm.common.spc.util.DataUtils;
|
||||||
import com.cnbm.influx.config.InfluxClient;
|
import com.cnbm.influx.config.InfluxClient;
|
||||||
import com.cnbm.influx.constant.Constant;
|
import com.cnbm.influx.constant.Constant;
|
||||||
import com.cnbm.influx.param.QueryDataGroupByTimeParam;
|
import com.cnbm.influx.param.QueryDataGroupByTimeParam;
|
||||||
import com.cnbm.influx.param.QueryDataParam;
|
|
||||||
import com.cnbm.influx.param.Tag;
|
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.cnbm.qualityPlanning.entity.*;
|
||||||
import com.influxdb.query.FluxRecord;
|
import com.influxdb.query.FluxRecord;
|
||||||
import com.influxdb.query.FluxTable;
|
import com.influxdb.query.FluxTable;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.omg.CORBA.PRIVATE_MEMBER;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -7,7 +7,6 @@ import com.cnbm.influx.constant.Constant;
|
|||||||
import com.cnbm.influx.param.QueryDataGroupByTimeParam;
|
import com.cnbm.influx.param.QueryDataGroupByTimeParam;
|
||||||
import com.cnbm.influx.param.Tag;
|
import com.cnbm.influx.param.Tag;
|
||||||
import com.cnbm.qualityPlanning.entity.ControlLimit;
|
import com.cnbm.qualityPlanning.entity.ControlLimit;
|
||||||
import com.cnbm.qualityPlanning.entity.NPPoint;
|
|
||||||
import com.cnbm.qualityPlanning.entity.PPoint;
|
import com.cnbm.qualityPlanning.entity.PPoint;
|
||||||
import com.cnbm.qualityPlanning.entity.SpecificationLimit;
|
import com.cnbm.qualityPlanning.entity.SpecificationLimit;
|
||||||
import com.influxdb.query.FluxRecord;
|
import com.influxdb.query.FluxRecord;
|
||||||
@ -15,7 +14,6 @@ import com.influxdb.query.FluxTable;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -7,7 +7,6 @@ import com.cnbm.influx.constant.Constant;
|
|||||||
import com.cnbm.influx.param.QueryDataGroupByTimeParam;
|
import com.cnbm.influx.param.QueryDataGroupByTimeParam;
|
||||||
import com.cnbm.influx.param.Tag;
|
import com.cnbm.influx.param.Tag;
|
||||||
import com.cnbm.qualityPlanning.entity.ControlLimit;
|
import com.cnbm.qualityPlanning.entity.ControlLimit;
|
||||||
import com.cnbm.qualityPlanning.entity.PPoint;
|
|
||||||
import com.cnbm.qualityPlanning.entity.SpecificationLimit;
|
import com.cnbm.qualityPlanning.entity.SpecificationLimit;
|
||||||
import com.cnbm.qualityPlanning.entity.UPoint;
|
import com.cnbm.qualityPlanning.entity.UPoint;
|
||||||
import com.influxdb.query.FluxRecord;
|
import com.influxdb.query.FluxRecord;
|
||||||
|
@ -107,6 +107,9 @@ public class MeanRGraph {
|
|||||||
queryDataParam.setTag(new Tag("argName",argName));
|
queryDataParam.setTag(new Tag("argName",argName));
|
||||||
|
|
||||||
List<FluxTable> query = InfluxClient.Client.query(queryDataParam);
|
List<FluxTable> query = InfluxClient.Client.query(queryDataParam);
|
||||||
|
if(query.size() == 0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
//1. 先从fluxdb 里面提取原始数据
|
//1. 先从fluxdb 里面提取原始数据
|
||||||
List<Double> originData = new ArrayList<>();
|
List<Double> originData = new ArrayList<>();
|
||||||
for (FluxTable fluxTable : query) {
|
for (FluxTable fluxTable : query) {
|
||||||
@ -217,6 +220,9 @@ public class MeanRGraph {
|
|||||||
* 注意:此函数 要在 initialDate()函数执行之后
|
* 注意:此函数 要在 initialDate()函数执行之后
|
||||||
* */
|
* */
|
||||||
public ControlLimit getXbarCL(){
|
public ControlLimit getXbarCL(){
|
||||||
|
if(this.mrGraphEntity == null){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return new ControlLimit(
|
return new ControlLimit(
|
||||||
(this.mrGraphEntity.getXbarbar() + a2*this.mrGraphEntity.getRbar()),
|
(this.mrGraphEntity.getXbarbar() + a2*this.mrGraphEntity.getRbar()),
|
||||||
this.mrGraphEntity.getXbarbar(),
|
this.mrGraphEntity.getXbarbar(),
|
||||||
@ -229,6 +235,9 @@ public class MeanRGraph {
|
|||||||
* 注意:此函数 要在 initialDate()函数执行之后
|
* 注意:此函数 要在 initialDate()函数执行之后
|
||||||
* */
|
* */
|
||||||
public ControlLimit getRCL(){
|
public ControlLimit getRCL(){
|
||||||
|
if(this.mrGraphEntity==null){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return new ControlLimit(
|
return new ControlLimit(
|
||||||
( d4 * this.mrGraphEntity.getRbar() ) ,
|
( d4 * this.mrGraphEntity.getRbar() ) ,
|
||||||
this.mrGraphEntity.getRbar() ,
|
this.mrGraphEntity.getRbar() ,
|
||||||
@ -241,6 +250,10 @@ public class MeanRGraph {
|
|||||||
* 注意:此函数 要在 initialDate()函数执行之后
|
* 注意:此函数 要在 initialDate()函数执行之后
|
||||||
* */
|
* */
|
||||||
public ProcessCapability getProcessCapacity(){
|
public ProcessCapability getProcessCapacity(){
|
||||||
|
if(this.miu==null || this.xigma==null || this.specificationLimit==null){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
SpecificationLimit sp = this.specificationLimit;
|
SpecificationLimit sp = this.specificationLimit;
|
||||||
List<String> warming = new ArrayList<>();
|
List<String> warming = new ArrayList<>();
|
||||||
Float usl = sp.getUSL();
|
Float usl = sp.getUSL();
|
||||||
|
@ -5,8 +5,6 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
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.Machine;
|
||||||
import com.cnbm.basic.entity.Product;
|
import com.cnbm.basic.entity.Product;
|
||||||
import com.cnbm.basic.entity.Shift;
|
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.page.PageData;
|
||||||
import com.cnbm.common.service.impl.CrudServiceImpl;
|
import com.cnbm.common.service.impl.CrudServiceImpl;
|
||||||
import com.cnbm.common.utils.ConvertUtils;
|
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.config.InfluxClient;
|
||||||
import com.cnbm.influx.param.QueryDataParam;
|
import com.cnbm.influx.param.QueryDataParam;
|
||||||
import com.cnbm.influx.param.Range;
|
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.entity.InspectionSheet;
|
||||||
import com.cnbm.processInspection.mapper.InspectionSheetMapper;
|
import com.cnbm.processInspection.mapper.InspectionSheetMapper;
|
||||||
import com.cnbm.processInspection.service.IInspectionSheetService;
|
import com.cnbm.processInspection.service.IInspectionSheetService;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import com.influxdb.query.FluxTable;
|
import com.influxdb.query.FluxTable;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -212,7 +206,7 @@ public class InspectionSheetServiceImpl extends CrudServiceImpl<InspectionSheetM
|
|||||||
event.setBatchNum(batchNum);
|
event.setBatchNum(batchNum);
|
||||||
event.setArgName(argName);
|
event.setArgName(argName);
|
||||||
if(!Objects.equals(argValue, "") && argValue != null ){
|
if(!Objects.equals(argValue, "") && argValue != null ){
|
||||||
event.setArgValue(argValue);
|
event.setArgValue(argValue.toString());
|
||||||
}
|
}
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.cnbm.qualityPlanning.common;
|
|||||||
|
|
||||||
|
|
||||||
import com.cnbm.qualityPlanning.entity.*;
|
import com.cnbm.qualityPlanning.entity.*;
|
||||||
|
import io.swagger.models.auth.In;
|
||||||
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -608,75 +609,114 @@ public class StatisticalControlledTest {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* name : 规则5
|
* name : 规则5
|
||||||
* desc : 连续 m 点中 有 n 点 落在中心线同一侧,B区以外。( 默认 m:3 , n:2 )
|
* desc : 连续 m 点中 有 n 点 落在中心线同一侧,B区以外。( 默认 m:3 , n:2 )
|
||||||
* 注意: 如果存在满足rule5的点,会在原数组 Point.unsatisfiedRules 里标注出来。
|
* 注意:
|
||||||
|
* ① 如果存在满足rule5的点,会在原数组 Point.unsatisfiedRules 里标注出来。
|
||||||
|
* ② 如果如果存在UB外和 LB外的连续 数据也是算的
|
||||||
* return :
|
* return :
|
||||||
* 存在满足rule5的点 => true
|
* 存在满足rule5的点 => true
|
||||||
* 不存在满足rule5的点 => false
|
* 不存在满足rule5的点 => false
|
||||||
|
*
|
||||||
|
* Test status: OK(CaiXiang)
|
||||||
|
*
|
||||||
* */
|
* */
|
||||||
public static Boolean rule5(List<Point> data,ControlLimit controlLimit, Integer m, Integer n){
|
private static void rule5Core(List<Point> data,Integer m,Integer n){
|
||||||
Boolean result = false;
|
if(data.size() == 0 || data.size() == 1){
|
||||||
Integer upi = 0;
|
return;
|
||||||
List<Point> upforMarkKey = new ArrayList<>();
|
|
||||||
List<Point> 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()<controlLimitDetail.getLB()[0]){
|
|
||||||
downTimes++;
|
|
||||||
downforMarkKey.add(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(upTimes>=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++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//开始
|
||||||
|
Stack<Point> stack = new Stack<Point>();
|
||||||
|
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<size;s++){
|
||||||
|
stack.pop().getUnsatisfiedRules().add(rule5Number);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stack.clear();
|
||||||
|
stack.push(data.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
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<size;s++){
|
||||||
|
stack.pop().getUnsatisfiedRules().add(rule5Number);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stack.clear();
|
||||||
|
stack.push(data.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Boolean stackIsFull = (stack.size()>=n);
|
||||||
|
Boolean seqNumIsOK = (seqNum>=m);
|
||||||
|
if(stackIsFull && seqNumIsOK){
|
||||||
|
int size = stack.size();
|
||||||
|
for(int s=0;s<size;s++){
|
||||||
|
stack.pop().getUnsatisfiedRules().add(rule5Number);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//结束
|
||||||
|
}
|
||||||
|
public static Boolean rule5(List<Point> data,ControlLimit controlLimit, Integer m, Integer n){
|
||||||
|
Boolean result = false;
|
||||||
|
|
||||||
|
List<Point> upforMarkKey = new ArrayList<>();
|
||||||
|
List<Point> 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.getLB()[0]){
|
||||||
|
// upforMarkKey.add(i);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
for(Point i:data){
|
||||||
|
if(i.getValueForInterpretation()>controlLimitDetail.getUB()[1]){
|
||||||
|
upforMarkKey.add(i);
|
||||||
|
}
|
||||||
|
if(i.getValueForInterpretation()<controlLimitDetail.getLB()[0]){
|
||||||
|
downforMarkKey.add(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//2.再用rule5进行分析
|
||||||
|
rule5Core(upforMarkKey,m,n);
|
||||||
|
rule5Core(downforMarkKey,m,n);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -688,73 +728,170 @@ public class StatisticalControlledTest {
|
|||||||
* return :
|
* return :
|
||||||
* 存在满足rule6的点 => true
|
* 存在满足rule6的点 => true
|
||||||
* 不存在满足rule6的点 => false
|
* 不存在满足rule6的点 => false
|
||||||
|
* Test status: OK(CaiXiang)
|
||||||
* */
|
* */
|
||||||
public static Boolean rule6(List<Point> data,ControlLimit controlLimit, Integer m, Integer n){
|
// public static Boolean rule6(List<Point> data,ControlLimit controlLimit, Integer m, Integer n){
|
||||||
Boolean result = false;
|
// Boolean result = false;
|
||||||
Integer upi = 0;
|
// Integer upi = 0;
|
||||||
List<Point> upforMarkKey = new ArrayList<>();
|
// List<Point> upforMarkKey = new ArrayList<>();
|
||||||
List<Point> downforMarkKey = new ArrayList<>();
|
// List<Point> downforMarkKey = new ArrayList<>();
|
||||||
// Double[] dataArray = (Double[])data.toArray();
|
//// Double[] dataArray = (Double[])data.toArray();
|
||||||
Object[] dataArray = data.toArray();
|
// Object[] dataArray = data.toArray();
|
||||||
ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL());
|
// ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL());
|
||||||
System.out.println("controlLimitDetail : "+controlLimitDetail.toString());
|
// System.out.println("controlLimitDetail : "+controlLimitDetail.toString());
|
||||||
Boolean lastFlag = false;
|
// Boolean lastFlag = false;
|
||||||
while(upi < data.size()){
|
// while(upi < data.size()){
|
||||||
Point[] keyList = new Point[m];
|
// Point[] keyList = new Point[m];
|
||||||
if(m>=(data.size()-upi)){
|
// if(m>=(data.size()-upi)){
|
||||||
if(lastFlag){
|
// if(lastFlag){
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
//System.arraycopy(dataArray , 10 , keyList , 0 , 2 );
|
// //System.arraycopy(dataArray , 10 , keyList , 0 , 2 );
|
||||||
System.arraycopy(dataArray,upi,keyList,0,(data.size()-upi));
|
// System.arraycopy(dataArray,upi,keyList,0,(data.size()-upi));
|
||||||
lastFlag = true;
|
// 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()<controlLimitDetail.getLC()[0]){
|
||||||
|
// downTimes++;
|
||||||
|
// downforMarkKey.add(i);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if(upTimes>=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<Point> data,Integer m,Integer n){
|
||||||
|
if(data.size() == 0 || data.size() == 1){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//开始
|
||||||
|
Stack<Point> stack = new Stack<Point>();
|
||||||
|
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 {
|
}else {
|
||||||
System.arraycopy(dataArray,upi,keyList,0,m);
|
Boolean stackIsFull = (stack.size()>=n);
|
||||||
}
|
Boolean seqNumIsOK = (seqNum>=m);
|
||||||
|
if(stackIsFull && seqNumIsOK){
|
||||||
Integer upTimes = 0;
|
int size = stack.size();
|
||||||
Integer downTimes = 0;
|
for(int s=0;s<size;s++){
|
||||||
for(Point i:keyList){
|
stack.pop().getUnsatisfiedRules().add(rule6Number);
|
||||||
if(i.getValueForInterpretation()>controlLimitDetail.getUC()[1]){
|
|
||||||
upTimes++;
|
|
||||||
upforMarkKey.add(i);
|
|
||||||
|
|
||||||
}
|
|
||||||
if(i.getValueForInterpretation()<controlLimitDetail.getLC()[0]){
|
|
||||||
downTimes++;
|
|
||||||
downforMarkKey.add(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(upTimes>=n || downTimes>=n){
|
|
||||||
result = true;
|
|
||||||
if(upTimes>=n){
|
|
||||||
for(Point i:upforMarkKey){
|
|
||||||
|
|
||||||
i.getUnsatisfiedRules().add(rule6Number);
|
|
||||||
}
|
}
|
||||||
upforMarkKey = new ArrayList<>();
|
|
||||||
// return true;
|
|
||||||
}
|
}
|
||||||
if(downTimes>=n){
|
stack.clear();
|
||||||
for(Point i:downforMarkKey){
|
stack.push(data.get(i));
|
||||||
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++;
|
|
||||||
|
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<size;s++){
|
||||||
|
stack.pop().getUnsatisfiedRules().add(rule6Number);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stack.clear();
|
||||||
|
stack.push(data.get(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Boolean stackIsFull = (stack.size()>=n);
|
||||||
|
Boolean seqNumIsOK = (seqNum>=m);
|
||||||
|
if(stackIsFull && seqNumIsOK){
|
||||||
|
int size = stack.size();
|
||||||
|
for(int s=0;s<size;s++){
|
||||||
|
stack.pop().getUnsatisfiedRules().add(rule6Number);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//结束
|
||||||
|
}
|
||||||
|
public static Boolean rule6(List<Point> data,ControlLimit controlLimit, Integer m, Integer n){
|
||||||
|
Boolean result = false;
|
||||||
|
|
||||||
|
List<Point> upforMarkKey = new ArrayList<>();
|
||||||
|
List<Point> 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.getLB()[0]){
|
||||||
|
// upforMarkKey.add(i);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
for(Point i:data){
|
||||||
|
if(i.getValueForInterpretation()>controlLimitDetail.getUC()[1]){
|
||||||
|
upforMarkKey.add(i);
|
||||||
|
}
|
||||||
|
if(i.getValueForInterpretation()<controlLimitDetail.getLC()[0]){
|
||||||
|
downforMarkKey.add(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//2.再用rule5进行分析
|
||||||
|
rule6Core(upforMarkKey,m,n);
|
||||||
|
rule6Core(downforMarkKey,m,n);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -765,65 +902,156 @@ public class StatisticalControlledTest {
|
|||||||
* return :
|
* return :
|
||||||
* 存在满足rule7的点 => true
|
* 存在满足rule7的点 => true
|
||||||
* 不存在满足rule7的点 => false
|
* 不存在满足rule7的点 => false
|
||||||
|
* Test status: OK(CaiXiang)
|
||||||
* */
|
* */
|
||||||
public static Boolean rule7(List<Point> data,ControlLimit controlLimit, Integer n){
|
// public static Boolean rule7(List<Point> data,ControlLimit controlLimit, Integer n){
|
||||||
|
//
|
||||||
Boolean result = false;
|
// Boolean result = false;
|
||||||
|
//
|
||||||
//Integer upi = 0;
|
// //Integer upi = 0;
|
||||||
ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL());
|
// ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL());
|
||||||
System.out.println(controlLimitDetail.toString());
|
// System.out.println(controlLimitDetail.toString());
|
||||||
Integer times = 0;
|
// Integer times = 0;
|
||||||
List<Point> markKey = new ArrayList<>();
|
// List<Point> markKey = new ArrayList<>();
|
||||||
|
//
|
||||||
|
//
|
||||||
for(int i=0;i<data.size();i++){
|
// for(int i=0;i<data.size();i++){
|
||||||
//判断最后一次
|
// //判断最后一次
|
||||||
if((i+1) == data.size()){
|
// if((i+1) == data.size()){
|
||||||
Point point = data.get(i);
|
// Point point = data.get(i);
|
||||||
if(point.getValueForInterpretation()>controlLimitDetail.getLC()[0] && point.getValueForInterpretation()<controlLimitDetail.getUC()[1]){
|
// if(point.getValueForInterpretation()>controlLimitDetail.getLC()[0] && point.getValueForInterpretation()<controlLimitDetail.getUC()[1]){
|
||||||
times++;
|
// times++;
|
||||||
markKey.add(point);
|
// markKey.add(point);
|
||||||
if(times.equals(n)){
|
// if(times.equals(n)){
|
||||||
for(Point j:markKey){
|
// for(Point j:markKey){
|
||||||
j.getUnsatisfiedRules().add(rule7Number);
|
// j.getUnsatisfiedRules().add(rule7Number);
|
||||||
}
|
// }
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
}else {
|
// }else {
|
||||||
times = 0;
|
// times = 0;
|
||||||
markKey = new ArrayList<>();
|
// markKey = new ArrayList<>();
|
||||||
}
|
// }
|
||||||
break;
|
// break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //通常情况
|
||||||
|
// Point point = data.get(i);
|
||||||
|
// if( isBetween( data.get(i),data.get(i+1) ) ){
|
||||||
|
// if(point.getValueForInterpretation()>controlLimitDetail.getLC()[0] && point.getValueForInterpretation()<controlLimitDetail.getUC()[1]){
|
||||||
|
// times++;
|
||||||
|
// markKey.add(point);
|
||||||
|
// if(times.equals(n)){
|
||||||
|
// for(Point j:markKey){
|
||||||
|
// j.getUnsatisfiedRules().add(rule7Number);
|
||||||
|
// }
|
||||||
|
//// return true;
|
||||||
|
// result = true;
|
||||||
|
// times = 0;
|
||||||
|
// markKey = new ArrayList<>();
|
||||||
|
// }
|
||||||
|
// }else {
|
||||||
|
// times = 0;
|
||||||
|
// markKey = new ArrayList<>();
|
||||||
|
// }
|
||||||
|
// }else {
|
||||||
|
// times = 0;
|
||||||
|
// markKey = new ArrayList<>();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
private static void rule7Core(List<Point> data,Integer n){
|
||||||
|
if(data.size() == 0 || data.size() == 1){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//开始
|
||||||
|
Stack<Point> stack = new Stack<Point>();
|
||||||
|
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());
|
||||||
Point point = data.get(i);
|
if( sequence ){
|
||||||
if( isBetween( data.get(i),data.get(i+1) ) ){
|
stack.push(data.get(i));
|
||||||
if(point.getValueForInterpretation()>controlLimitDetail.getLC()[0] && point.getValueForInterpretation()<controlLimitDetail.getUC()[1]){
|
|
||||||
times++;
|
|
||||||
markKey.add(point);
|
|
||||||
if(times.equals(n)){
|
|
||||||
for(Point j:markKey){
|
|
||||||
j.getUnsatisfiedRules().add(rule7Number);
|
|
||||||
}
|
|
||||||
// return true;
|
|
||||||
result = true;
|
|
||||||
times = 0;
|
|
||||||
markKey = new ArrayList<>();
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
times = 0;
|
|
||||||
markKey = new ArrayList<>();
|
|
||||||
}
|
|
||||||
}else {
|
}else {
|
||||||
times = 0;
|
Boolean stackIsFull = (stack.size()>=n);
|
||||||
markKey = new ArrayList<>();
|
|
||||||
|
if(stackIsFull){
|
||||||
|
int size = stack.size();
|
||||||
|
for(int s=0;s<size;s++){
|
||||||
|
stack.pop().getUnsatisfiedRules().add(rule7Number);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stack.clear();
|
||||||
|
stack.push(data.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
|
|
||||||
|
}
|
||||||
|
//判断最后一次情况
|
||||||
|
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));
|
||||||
|
|
||||||
|
}else {
|
||||||
|
Boolean stackIsFull = (stack.size()>=n);
|
||||||
|
|
||||||
|
if(stackIsFull){
|
||||||
|
int size = stack.size();
|
||||||
|
for(int s=0;s<size;s++){
|
||||||
|
stack.pop().getUnsatisfiedRules().add(rule7Number);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stack.clear();
|
||||||
|
stack.push(data.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
Boolean stackIsFull = (stack.size()>=n);
|
||||||
|
|
||||||
|
if(stackIsFull){
|
||||||
|
int size = stack.size();
|
||||||
|
for(int s=0;s<size;s++){
|
||||||
|
stack.pop().getUnsatisfiedRules().add(rule7Number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//结束
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Boolean rule7(List<Point> data,ControlLimit controlLimit, Integer n){
|
||||||
|
Boolean result = false;
|
||||||
|
|
||||||
|
// List<Point> upforMarkKey = new ArrayList<>();
|
||||||
|
// List<Point> downforMarkKey = new ArrayList<>();
|
||||||
|
List<Point> 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()<controlLimitDetail.getUC()[1]){
|
||||||
|
errforMarkKey.add(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//2.再用rule5进行分析
|
||||||
|
rule7Core(errforMarkKey,n);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* name : 规则8
|
* name : 规则8
|
||||||
* desc : 连续 n 点 落在中心线两侧,且无一点在C区内。( 默认 n:8 )
|
* desc : 连续 n 点 落在中心线两侧,且无一点在C区内。( 默认 n:8 )
|
||||||
@ -831,63 +1059,149 @@ public class StatisticalControlledTest {
|
|||||||
* return :
|
* return :
|
||||||
* 存在满足rule8的点 => true
|
* 存在满足rule8的点 => true
|
||||||
* 不存在满足rule8的点 => false
|
* 不存在满足rule8的点 => false
|
||||||
|
* Test status: OK(CaiXiang)
|
||||||
* */
|
* */
|
||||||
public static Boolean rule8(List<Point> data,ControlLimit controlLimit, Integer n){
|
// public static Boolean rule8(List<Point> data,ControlLimit controlLimit, Integer n){
|
||||||
|
//
|
||||||
Boolean result = true;
|
// Boolean result = true;
|
||||||
//Integer upi = 0;
|
// //Integer upi = 0;
|
||||||
ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL());
|
// ControlLimitDetail controlLimitDetail = new ControlLimitDetail(controlLimit.getUCL(), controlLimit.getCL(), controlLimit.getLCL());
|
||||||
System.out.println(controlLimitDetail.toString());
|
// System.out.println(controlLimitDetail.toString());
|
||||||
Integer times = 0;
|
// Integer times = 0;
|
||||||
List<Point> markKey = new ArrayList<>();
|
// List<Point> markKey = new ArrayList<>();
|
||||||
|
//
|
||||||
|
//
|
||||||
for(int i=0;i<data.size();i++){
|
// for(int i=0;i<data.size();i++){
|
||||||
//判断最后一次
|
// //判断最后一次
|
||||||
if((i+1) == data.size()){
|
// if((i+1) == data.size()){
|
||||||
Point point = data.get(i);
|
// Point point = data.get(i);
|
||||||
if( point.getValueForInterpretation()>controlLimitDetail.getUC()[1] || point.getValueForInterpretation()<controlLimitDetail.getLC()[0] ){
|
// if( point.getValueForInterpretation()>controlLimitDetail.getUC()[1] || point.getValueForInterpretation()<controlLimitDetail.getLC()[0] ){
|
||||||
times++;
|
// times++;
|
||||||
markKey.add(point);
|
// markKey.add(point);
|
||||||
if(times.equals(n)){
|
// if(times.equals(n)){
|
||||||
for(Point j:markKey){
|
// for(Point j:markKey){
|
||||||
j.getUnsatisfiedRules().add(rule8Number);
|
// j.getUnsatisfiedRules().add(rule8Number);
|
||||||
}
|
// }
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
}else {
|
// }else {
|
||||||
times = 0;
|
// times = 0;
|
||||||
markKey = new ArrayList<>();
|
// markKey = new ArrayList<>();
|
||||||
}
|
// }
|
||||||
break;
|
// break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //通常情况
|
||||||
|
// Point point = data.get(i);
|
||||||
|
// if( isBetween( data.get(i),data.get(i+1) ) ){
|
||||||
|
// if( point.getValueForInterpretation()>controlLimitDetail.getUC()[1] || point.getValueForInterpretation()<controlLimitDetail.getLC()[0] ){
|
||||||
|
// times++;
|
||||||
|
// markKey.add(point);
|
||||||
|
// if(times.equals(n)){
|
||||||
|
// for(Point j:markKey){
|
||||||
|
// j.getUnsatisfiedRules().add(rule8Number);
|
||||||
|
// }
|
||||||
|
// result = true;
|
||||||
|
// times = 0;
|
||||||
|
// markKey = new ArrayList<>();
|
||||||
|
// }
|
||||||
|
// }else {
|
||||||
|
// times = 0;
|
||||||
|
// markKey = new ArrayList<>();
|
||||||
|
// }
|
||||||
|
// }else {
|
||||||
|
// times = 0;
|
||||||
|
// markKey = new ArrayList<>();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
private static void rule8Core(List<Point> data,Integer n){
|
||||||
|
if(data.size() == 0 || data.size() == 1){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//开始
|
||||||
|
Stack<Point> stack = new Stack<Point>();
|
||||||
|
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());
|
||||||
Point point = data.get(i);
|
if( sequence ){
|
||||||
if( isBetween( data.get(i),data.get(i+1) ) ){
|
stack.push(data.get(i));
|
||||||
if( point.getValueForInterpretation()>controlLimitDetail.getUC()[1] || point.getValueForInterpretation()<controlLimitDetail.getLC()[0] ){
|
|
||||||
times++;
|
|
||||||
markKey.add(point);
|
|
||||||
if(times.equals(n)){
|
|
||||||
for(Point j:markKey){
|
|
||||||
j.getUnsatisfiedRules().add(rule8Number);
|
|
||||||
}
|
|
||||||
result = true;
|
|
||||||
times = 0;
|
|
||||||
markKey = new ArrayList<>();
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
times = 0;
|
|
||||||
markKey = new ArrayList<>();
|
|
||||||
}
|
|
||||||
}else {
|
}else {
|
||||||
times = 0;
|
Boolean stackIsFull = (stack.size()>=n);
|
||||||
markKey = new ArrayList<>();
|
|
||||||
|
if(stackIsFull){
|
||||||
|
int size = stack.size();
|
||||||
|
for(int s=0;s<size;s++){
|
||||||
|
stack.pop().getUnsatisfiedRules().add(rule8Number);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stack.clear();
|
||||||
|
stack.push(data.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
|
|
||||||
|
}
|
||||||
|
//判断最后一次情况
|
||||||
|
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));
|
||||||
|
|
||||||
|
}else {
|
||||||
|
Boolean stackIsFull = (stack.size()>=n);
|
||||||
|
|
||||||
|
if(stackIsFull){
|
||||||
|
int size = stack.size();
|
||||||
|
for(int s=0;s<size;s++){
|
||||||
|
stack.pop().getUnsatisfiedRules().add(rule8Number);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stack.clear();
|
||||||
|
stack.push(data.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
Boolean stackIsFull = (stack.size()>=n);
|
||||||
|
|
||||||
|
if(stackIsFull){
|
||||||
|
int size = stack.size();
|
||||||
|
for(int s=0;s<size;s++){
|
||||||
|
stack.pop().getUnsatisfiedRules().add(rule8Number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
//结束
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Boolean rule8(List<Point> data,ControlLimit controlLimit, Integer n){
|
||||||
|
Boolean result = false;
|
||||||
|
|
||||||
|
// List<Point> upforMarkKey = new ArrayList<>();
|
||||||
|
// List<Point> downforMarkKey = new ArrayList<>();
|
||||||
|
List<Point> 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()<controlLimitDetail.getLC()[0]){
|
||||||
|
errforMarkKey.add(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//2.再用rule5进行分析
|
||||||
|
rule8Core(errforMarkKey,n);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 如果 这两个点是相邻的 ==》 true
|
* 如果 这两个点是相邻的 ==》 true
|
||||||
* */
|
* */
|
||||||
|
@ -0,0 +1,118 @@
|
|||||||
|
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 MainRule5TEST {
|
||||||
|
|
||||||
|
public static void rule5Core(List<Point> upforMarkKey){
|
||||||
|
//开始
|
||||||
|
Stack<Point> stack = new Stack<Point>();
|
||||||
|
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<size;s++){
|
||||||
|
stack.pop().getUnsatisfiedRules().add(5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stack.clear();
|
||||||
|
stack.push(upforMarkKey.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
|
seqNum++;
|
||||||
|
}
|
||||||
|
//判断最后一次情况
|
||||||
|
Integer nowi = i>= 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<size;s++){
|
||||||
|
stack.pop().getUnsatisfiedRules().add(5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stack.clear();
|
||||||
|
stack.push(upforMarkKey.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Boolean stackIsFull = (stack.size()>=3);
|
||||||
|
Boolean seqNumIsOK = (seqNum>=5);
|
||||||
|
if(stackIsFull && seqNumIsOK){
|
||||||
|
int size = stack.size();
|
||||||
|
for(int s=0;s<size;s++){
|
||||||
|
stack.pop().getUnsatisfiedRules().add(5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//结束
|
||||||
|
}
|
||||||
|
public static void main(String[] args) {
|
||||||
|
List<Point> 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();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -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<Point> data,Integer n){
|
||||||
|
//开始
|
||||||
|
Stack<Point> stack = new Stack<Point>();
|
||||||
|
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<size;s++){
|
||||||
|
stack.pop().getUnsatisfiedRules().add(7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stack.clear();
|
||||||
|
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<size;s++){
|
||||||
|
stack.pop().getUnsatisfiedRules().add(7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stack.clear();
|
||||||
|
stack.push(data.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
Boolean stackIsFull = (stack.size()>=n);
|
||||||
|
|
||||||
|
if(stackIsFull){
|
||||||
|
int size = stack.size();
|
||||||
|
for(int s=0;s<size;s++){
|
||||||
|
stack.pop().getUnsatisfiedRules().add(7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//结束
|
||||||
|
}
|
||||||
|
public static void main(String[] args) {
|
||||||
|
List<Point> 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();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,8 @@
|
|||||||
package com.cnbm.qualityPlanning.entity;
|
package com.cnbm.qualityPlanning.entity;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.NumberUtil;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.springframework.util.NumberUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Desc: ""
|
* @Desc: ""
|
||||||
@ -27,19 +29,19 @@ public class ControlLimitDetail {
|
|||||||
this.CL = CL;
|
this.CL = CL;
|
||||||
this.LCL = LCL;
|
this.LCL = LCL;
|
||||||
Double agv1 = (this.UCL-this.CL)/3;
|
Double agv1 = (this.UCL-this.CL)/3;
|
||||||
this.UC[0] = this.CL;
|
this.UC[0] = NumberUtil.round(this.CL,4).doubleValue();
|
||||||
this.UC[1] = this.CL+agv1;
|
this.UC[1] = NumberUtil.round(this.CL+agv1,4).doubleValue();
|
||||||
this.UB[0] = this.UC[0];
|
this.UB[0] = NumberUtil.round(this.UC[1],4).doubleValue();
|
||||||
this.UB[1] = this.UC[0]+agv1;
|
this.UB[1] = NumberUtil.round(this.UB[0]+agv1,4).doubleValue();
|
||||||
this.UA[0] = this.UB[0];
|
this.UA[0] = NumberUtil.round(this.UB[1],4).doubleValue();
|
||||||
this.UA[1] = this.UB[0]+agv1;
|
this.UA[1] = NumberUtil.round(this.UA[0]+agv1,4).doubleValue();
|
||||||
|
|
||||||
Double agv2 = (this.CL-this.LCL)/3;
|
Double agv2 = (this.CL-this.LCL)/3;
|
||||||
this.LC[0] = this.CL-agv2;
|
this.LC[0] = NumberUtil.round(this.CL-agv2,4).doubleValue();
|
||||||
this.LC[1] = this.CL;
|
this.LC[1] = NumberUtil.round(this.CL,4).doubleValue();
|
||||||
this.LB[0] = this.LC[0]-agv2;
|
this.LB[0] = NumberUtil.round(this.LC[0]-agv2,4).doubleValue();
|
||||||
this.LB[1] = this.LC[0];
|
this.LB[1] = NumberUtil.round(this.LC[0],4).doubleValue();
|
||||||
this.LA[0] = this.LB[0]-agv2;
|
this.LA[0] = NumberUtil.round(this.LB[0]-agv2,4).doubleValue();
|
||||||
this.LA[1] = this.LB[0];
|
this.LA[1] = NumberUtil.round(this.LB[0],4).doubleValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user