mark for pull
This commit is contained in:
		@@ -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;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -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<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -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>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -92,13 +92,25 @@ public enum InfluxClient {
 | 
				
			|||||||
    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().toString())
 | 
					                        .addTag("transationId", event.getTransationId())
 | 
				
			||||||
                    .addTag("argName", event.getArgName())
 | 
					                        .addTag("inspectionSheetId", event.getInspectionSheetId())
 | 
				
			||||||
                    .addField("argValue", event.getArgValue())
 | 
					                        .addTag("argName", event.getArgName())
 | 
				
			||||||
                    .time(event.getTime().toEpochMilli(), WritePrecision.MS);
 | 
					                        .addField("argValue", event.getArgValue())
 | 
				
			||||||
 | 
					                        .time(event.getTime().toEpochMilli(), WritePrecision.MS);
 | 
				
			||||||
 | 
					            }else {
 | 
				
			||||||
 | 
					                point = Point.measurement(measurement)
 | 
				
			||||||
 | 
					                        .addTag("transationId", event.getTransationId())
 | 
				
			||||||
 | 
					                        .addTag("inspectionSheetId", event.getInspectionSheetId())
 | 
				
			||||||
 | 
					                        .addTag("batchNum", event.getBatchNum().toString())
 | 
				
			||||||
 | 
					                        .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);
 | 
				
			||||||
@@ -125,16 +137,31 @@ 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 += "|> 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);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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 = "Weights";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,8 @@
 | 
				
			|||||||
package com.cnbm.influx.controller;
 | 
					package com.cnbm.influx.controller;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.cnbm.common.spc.util.DataUtils;
 | 
					import com.cnbm.common.spc.util.DataUtils;
 | 
				
			||||||
 | 
					import com.cnbm.common.utils.Result;
 | 
				
			||||||
 | 
					import com.cnbm.common.vo.R;
 | 
				
			||||||
import com.cnbm.influx.config.InfluxClient;
 | 
					import com.cnbm.influx.config.InfluxClient;
 | 
				
			||||||
import com.cnbm.influx.param.PageInfo;
 | 
					import com.cnbm.influx.param.PageInfo;
 | 
				
			||||||
import com.cnbm.influx.param.QueryDataParam;
 | 
					import com.cnbm.influx.param.QueryDataParam;
 | 
				
			||||||
@@ -43,6 +45,27 @@ public class S7DemoController {
 | 
				
			|||||||
            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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            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");
 | 
				
			||||||
 | 
					            Double d = r.nextDouble() * 2.5  + 66;
 | 
				
			||||||
 | 
					            event.setArgValue(d);
 | 
				
			||||||
 | 
					            event.setBatchNum(4);
 | 
				
			||||||
 | 
					            event.setInspectionSheetId(i+"");
 | 
				
			||||||
            list.add(event);
 | 
					            list.add(event);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        InfluxClient.Client.batchInsert(list,"Weight");
 | 
					        InfluxClient.Client.batchInsert(list,"Weight");
 | 
				
			||||||
@@ -71,6 +94,8 @@ public class S7DemoController {
 | 
				
			|||||||
        InfluxClient.Client.batchInsert(list,"WeightHei");
 | 
					        InfluxClient.Client.batchInsert(list,"WeightHei");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @PostMapping("/insertBatchJYDForTest")
 | 
					    @PostMapping("/insertBatchJYDForTest")
 | 
				
			||||||
    public void insertBatchJYDForTest() throws InterruptedException {
 | 
					    public void insertBatchJYDForTest() throws InterruptedException {
 | 
				
			||||||
        List<Event> list = new ArrayList<>();
 | 
					        List<Event> list = new ArrayList<>();
 | 
				
			||||||
@@ -88,13 +113,39 @@ public class S7DemoController {
 | 
				
			|||||||
            }else {
 | 
					            }else {
 | 
				
			||||||
                event.setArgValue(new Double(1));
 | 
					                event.setArgValue(new Double(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);
 | 
				
			||||||
 | 
					            event.setInspectionSheetId(i+"");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            event.setBatchNum(i);
 | 
				
			||||||
 | 
					            list.add(event);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        InfluxClient.Client.batchInsert(list,"Weights");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -131,7 +182,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 +207,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"));
 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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,8 @@ 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.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 +35,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")
 | 
				
			||||||
@@ -46,7 +52,7 @@ public class ProcessInspectionController {
 | 
				
			|||||||
        productFeatures.setUsl(new Float(10));
 | 
					        productFeatures.setUsl(new Float(10));
 | 
				
			||||||
        productFeatures.setLsl(new Float(1));
 | 
					        productFeatures.setLsl(new Float(1));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        productFeatures.setName("LTWeight");
 | 
					        productFeatures.setName("LostDays");
 | 
				
			||||||
        productFeatures.setSampleSize(10);
 | 
					        productFeatures.setSampleSize(10);
 | 
				
			||||||
        MeanStandardDeviationGraph meanStandardDeviationGraph = new MeanStandardDeviationGraph(productFeatures);
 | 
					        MeanStandardDeviationGraph meanStandardDeviationGraph = new MeanStandardDeviationGraph(productFeatures);
 | 
				
			||||||
        //判读方案
 | 
					        //判读方案
 | 
				
			||||||
@@ -58,7 +64,7 @@ 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(
 | 
				
			||||||
@@ -75,12 +81,13 @@ 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(5));
 | 
				
			||||||
        productFeatures.setUsl(new Float(10));
 | 
					        productFeatures.setUsl(new Float(10));
 | 
				
			||||||
        productFeatures.setLsl(new Float(1));
 | 
					        productFeatures.setLsl(new Float(1));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        productFeatures.setName("LTWeight");
 | 
					        productFeatures.setName("LostDays");
 | 
				
			||||||
        productFeatures.setSampleSize(10);
 | 
					        productFeatures.setSampleSize(10);
 | 
				
			||||||
        MeanRGraph meanRGraph = new MeanRGraph(productFeatures);
 | 
					        MeanRGraph meanRGraph = new MeanRGraph(productFeatures);
 | 
				
			||||||
        //判读方案
 | 
					        //判读方案
 | 
				
			||||||
@@ -92,7 +99,7 @@ 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(
 | 
				
			||||||
@@ -113,7 +120,7 @@ public class ProcessInspectionController {
 | 
				
			|||||||
        productFeatures.setUsl(new Float(10));
 | 
					        productFeatures.setUsl(new Float(10));
 | 
				
			||||||
        productFeatures.setLsl(new Float(1));
 | 
					        productFeatures.setLsl(new Float(1));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        productFeatures.setName("LTWeight");
 | 
					        productFeatures.setName("LostDays");
 | 
				
			||||||
        productFeatures.setSampleSize(1);
 | 
					        productFeatures.setSampleSize(1);
 | 
				
			||||||
        XMRGraph xmrGraph = new XMRGraph(productFeatures);
 | 
					        XMRGraph xmrGraph = new XMRGraph(productFeatures);
 | 
				
			||||||
        //判读方案
 | 
					        //判读方案
 | 
				
			||||||
@@ -125,7 +132,7 @@ 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(
 | 
				
			||||||
@@ -139,6 +146,45 @@ public class ProcessInspectionController {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        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();
 | 
				
			||||||
@@ -152,7 +198,7 @@ public class ProcessInspectionController {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        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(1);
 | 
					        queryDataParam.setTimeType(1);
 | 
				
			||||||
        npGraph.initialDate(queryDataParam);
 | 
					        npGraph.initialDate(queryDataParam);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -177,7 +223,7 @@ public class ProcessInspectionController {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -201,8 +247,10 @@ public class ProcessInspectionController {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -228,7 +276,7 @@ public class ProcessInspectionController {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,7 +15,7 @@ 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;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,7 +15,7 @@ import lombok.Data;
 | 
				
			|||||||
 * @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;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,7 +15,7 @@ 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;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user